|
From: <gem...@li...> - 2011-12-19 15:56:17
|
Revision: 375
http://gemstracker.svn.sourceforge.net/gemstracker/?rev=375&view=rev
Author: mennodekker
Date: 2011-12-19 15:56:11 +0000 (Mon, 19 Dec 2011)
Log Message:
-----------
Allow the menu parameter filter to be an array of allowed options
StaffAction now takes all allowed organizations into account
Modified Paths:
--------------
trunk/library/classes/Gems/Default/StaffAction.php
trunk/library/classes/Gems/Menu/MenuAbstract.php
trunk/library/classes/Gems/Menu/SubMenuItem.php
Modified: trunk/library/classes/Gems/Default/StaffAction.php
===================================================================
--- trunk/library/classes/Gems/Default/StaffAction.php 2011-12-19 15:00:59 UTC (rev 374)
+++ trunk/library/classes/Gems/Default/StaffAction.php 2011-12-19 15:56:11 UTC (rev 375)
@@ -204,7 +204,7 @@
$model->set('gsf_email', 'label', $this->_('E-Mail'), 'itemDisplay', 'MUtil_Html_AElement::ifmail');
if ($detailed || $this->escort->hasPrivilege('pr.staff.see.all')) {
- $this->menu->getParameterSource()->offsetSet('gsf_id_organization', $this->escort->getCurrentOrganization());
+ //$this->menu->getParameterSource()->offsetSet('gsf_id_organization', $this->escort->getCurrentOrganization());
$model->set('gsf_id_organization', 'label', $this->_('Organization'),
'multiOptions', $this->util->getDbLookup()->getOrganizations(),
Modified: trunk/library/classes/Gems/Menu/MenuAbstract.php
===================================================================
--- trunk/library/classes/Gems/Menu/MenuAbstract.php 2011-12-19 15:00:59 UTC (rev 374)
+++ trunk/library/classes/Gems/Menu/MenuAbstract.php 2011-12-19 15:56:11 UTC (rev 375)
@@ -385,8 +385,8 @@
$editPage = $page->addEditAction();
$delPage = $page->addDeleteAction();
if (! $this->escort->hasPrivilege('pr.staff.edit.all')) {
- $editPage->setParameterFilter('gsf_id_organization', $this->escort->getCurrentOrganization());
- $delPage->setParameterFilter('gsf_id_organization', $this->escort->getCurrentOrganization());
+ $editPage->setParameterFilter('gsf_id_organization', array_keys($this->escort->loader->getCurrentUser()->getAllowedOrganizations()));
+ $delPage->setParameterFilter('gsf_id_organization', array_keys($this->escort->loader->getCurrentUser()->getAllowedOrganizations()));
}
return $page;
Modified: trunk/library/classes/Gems/Menu/SubMenuItem.php
===================================================================
--- trunk/library/classes/Gems/Menu/SubMenuItem.php 2011-12-19 15:00:59 UTC (rev 374)
+++ trunk/library/classes/Gems/Menu/SubMenuItem.php 2011-12-19 15:56:11 UTC (rev 375)
@@ -96,6 +96,14 @@
{
if ($this->_parameterFilter) {
foreach ($this->_parameterFilter as $name => $testValue) {
+ //Transform single value to array for uniform processing
+ if (!is_array($testValue)) {
+ $testArray = array();
+ $testArray[] = $testValue;
+ } else {
+ $testArray = $testValue;
+ }
+
$paramValue = $source->getMenuParameter($name);
if ($paramValue instanceof MUtil_Lazy_LazyInterface) {
@@ -103,7 +111,8 @@
$paramValue = MUtil_Lazy::rise($paramValue);
} else {
- $newCondition = MUtil_Lazy::comp($testValue, '==', $paramValue);
+ $newCondition = new MUtil_Lazy_Call('in_array', array($paramValue, $testArray));
+ //$newCondition = MUtil_Lazy::comp($testValue, '==', $paramValue);
if ($condition instanceof MUtil_Lazy_LazyInterface) {
$condition = $condition->if($newCondition);
} else {
@@ -113,13 +122,22 @@
}
}
- if ($testValue !== $paramValue) {
- if (Gems_Menu::$verbose) {
- // Mutil_Echo::backtrace();
- MUtil_Echo::r($name . ' => ' . $testValue . ' !== ' . $paramValue, $this->get('label') . ' (' . $this->get('controller') . '/' . $this->get('action') . ')');
+
+ foreach($testArray as $currentTestValue) {
+ if ($currentTestValue == $paramValue) {
+ if (Gems_Menu::$verbose) {
+ // Mutil_Echo::backtrace();
+ MUtil_Echo::r($name . ' => ' . $currentTestValue . ' == ' . $paramValue, $this->get('label') . ' (' . $this->get('controller') . '/' . $this->get('action') . ')');
+ }
+ return;
+ } else {
+ if (Gems_Menu::$verbose) {
+ // Mutil_Echo::backtrace();
+ MUtil_Echo::r($name . ' => ' . $currentTestValue . ' !== ' . $paramValue, $this->get('label') . ' (' . $this->get('controller') . '/' . $this->get('action') . ')');
+ }
}
- return true;
}
+ return true;
}
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|