From: <gem...@li...> - 2012-06-14 15:30:48
|
Revision: 764 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=764&view=rev Author: matijsdejong Date: 2012-06-14 15:30:38 +0000 (Thu, 14 Jun 2012) Log Message: ----------- new privilege: respondent multi org When user has privilege and org cannot contain respondents, then all orgs respondents are shown (looking at them is step 2) Modified Paths: -------------- trunk/library/classes/Gems/Default/RespondentAction.php trunk/library/classes/Gems/Menu.php trunk/library/classes/Gems/Model/HiddenOrganizationModel.php trunk/library/classes/Gems/Model/RespondentModel.php trunk/library/classes/MUtil/Model/ModelAbstract.php trunk/library/classes/MUtil/Model/ModelTransformerAbstract.php trunk/library/classes/MUtil/Registry/TargetInterface.php trunk/library/configs/db/patches.sql Modified: trunk/library/classes/Gems/Default/RespondentAction.php =================================================================== --- trunk/library/classes/Gems/Default/RespondentAction.php 2012-06-14 14:33:38 UTC (rev 763) +++ trunk/library/classes/Gems/Default/RespondentAction.php 2012-06-14 15:30:38 UTC (rev 764) @@ -342,7 +342,9 @@ */ public function indexAction() { - if ($this->loader->getOrganization()->canHaveRespondents()) { + $user = $this->loader->getCurrentUser(); + + if ($user->hasPrivilege('pr.respondent.multiorg') || $this->loader->getOrganization()->canHaveRespondents()) { parent::indexAction(); } else { $this->addSnippet('Organization_ChooseOrganizationSnippet'); @@ -414,7 +416,7 @@ $params['respondentData'] = $data; $this->addSnippets($this->showSnippets, $params); } - + public function exportAction() { $this->_reroute(array('controller' => 'respondent-export', 'action' => 'index')); Modified: trunk/library/classes/Gems/Menu.php =================================================================== --- trunk/library/classes/Gems/Menu.php 2012-06-14 14:33:38 UTC (rev 763) +++ trunk/library/classes/Gems/Menu.php 2012-06-14 15:30:38 UTC (rev 764) @@ -548,12 +548,12 @@ // SETUP CONTAINER $this->addGemsSetupContainer($this->_('Setup')); + // TRACK BUILDER + $this->addTrackBuilderMenu($this->_('Track Builder')); + // MAIL CONTAINER $this->addMailSetupMenu($this->_('Mail')); - // TRACK BUILDER - $this->addTrackBuilderMenu($this->_('Track Builder')); - // EXPORT DATA $this->addContainer('Export data', 'pr.export', array('controller'=>'export', 'action'=>'index')); @@ -569,6 +569,7 @@ // Privileges not associated with menu item //$this->addHiddenPrivilige('pr.plan.choose-org'); $this->addHiddenPrivilige('pr.plan.mail-as-application'); + $this->addHiddenPrivilige('pr.respondent.multiorg'); $this->addHiddenPrivilige('pr.respondent.result'); $this->addHiddenPrivilige('pr.respondent.who'); $this->addHiddenPrivilige('pr.staff.edit.all'); Modified: trunk/library/classes/Gems/Model/HiddenOrganizationModel.php =================================================================== --- trunk/library/classes/Gems/Model/HiddenOrganizationModel.php 2012-06-14 14:33:38 UTC (rev 763) +++ trunk/library/classes/Gems/Model/HiddenOrganizationModel.php 2012-06-14 15:30:38 UTC (rev 764) @@ -48,6 +48,31 @@ class Gems_Model_HiddenOrganizationModel extends Gems_Model_JoinModel { /** + * + * @var Gems_Loader + */ + protected $loader; + + /** + * + * @var Gems_User_User + */ + protected $user; + + /** + * Called after the check that all required registry values + * have been set correctly has run. + * + * @return void + */ + public function afterRegistry() + { + if (! $this->user) { + $this->user = $this->loader->getCurrentUser(); + } + } + + /** * Stores the fields that can be used for sorting or filtering in the * sort / filter objects attached to this model. * @@ -73,18 +98,42 @@ unset($parameters[MUtil_Model::REQUEST_ID]); } - return parent::applyParameters($parameters); } return array(); } + /** + * Should be called after answering the request to allow the Target + * to check if all required registry values have been set correctly. + * + * @return boolean False if required are missing. + */ + public function checkRegistryRequestsAnswers() + { + return ($this->loader instanceof Gems_Loader); + } + + /** + * The current organization id of the current user + * + * @return int + */ public function getCurrentOrganization() { - return GemsEscort::getInstance()->getCurrentOrganization(); + return $this->user->getCurrentOrganizationId(); } + /** + * Return an identifier the item specified by $forData + * + * basically transforms the fieldnames ointo oan IDn => value array + * + * @param mixed $forData Array value to vilter on + * @param array $href Or ArrayObject + * @return array That can by used as href + */ public function getKeyRef($forData, $href = array(), $organizationInKey = null) { $keys = $this->getKeys(); Modified: trunk/library/classes/Gems/Model/RespondentModel.php =================================================================== --- trunk/library/classes/Gems/Model/RespondentModel.php 2012-06-14 14:33:38 UTC (rev 763) +++ trunk/library/classes/Gems/Model/RespondentModel.php 2012-06-14 15:30:38 UTC (rev 764) @@ -104,7 +104,11 @@ $filter = parent::_checkFilterUsed($filter); if (! isset($filter['gr2o_id_organization'])) { - $filter['gr2o_id_organization'] = $this->getCurrentOrganization(); + if ($this->user->hasPrivilege('pr.respondent.multiorg') && (! $this->user->getCurrentOrganization()->canHaveRespondents())) { + $filter[] = 'gr2o_id_organization IN (' . implode(', ', array_keys($this->user->getAllowedOrganizations())) . ')'; + } else { + $filter['gr2o_id_organization'] = $this->getCurrentOrganization(); + } } if (self::SSN_HASH === $this->hashSsn) { Modified: trunk/library/classes/MUtil/Model/ModelAbstract.php =================================================================== --- trunk/library/classes/MUtil/Model/ModelAbstract.php 2012-06-14 14:33:38 UTC (rev 763) +++ trunk/library/classes/MUtil/Model/ModelAbstract.php 2012-06-14 15:30:38 UTC (rev 764) @@ -565,6 +565,15 @@ } } + /** + * Return an identifier the item specified by $forData + * + * basically transforms the fieldnames ointo oan IDn => value array + * + * @param mixed $forData Array value to vilter on + * @param array $href Or ArrayObject + * @return array That can by used as href + */ public function getKeyRef($forData, $href = array()) { $keys = $this->getKeys(); Modified: trunk/library/classes/MUtil/Model/ModelTransformerAbstract.php =================================================================== --- trunk/library/classes/MUtil/Model/ModelTransformerAbstract.php 2012-06-14 14:33:38 UTC (rev 763) +++ trunk/library/classes/MUtil/Model/ModelTransformerAbstract.php 2012-06-14 15:30:38 UTC (rev 764) @@ -127,6 +127,15 @@ } } + /** + * Return an identifier the item specified by $forData + * + * basically transforms the fieldnames ointo oan IDn => value array + * + * @param mixed $forData Array value to vilter on + * @param array $href Or ArrayObject + * @return array That can by used as href + */ public function getKeyRef($forData, $href = array()) { if ($this->sourceModel) { Modified: trunk/library/classes/MUtil/Registry/TargetInterface.php =================================================================== --- trunk/library/classes/MUtil/Registry/TargetInterface.php 2012-06-14 14:33:38 UTC (rev 763) +++ trunk/library/classes/MUtil/Registry/TargetInterface.php 2012-06-14 15:30:38 UTC (rev 764) @@ -1,6 +1,5 @@ <?php - /** * Copyright (c) 2011, Erasmus MC * All rights reserved. Modified: trunk/library/configs/db/patches.sql =================================================================== --- trunk/library/configs/db/patches.sql 2012-06-14 14:33:38 UTC (rev 763) +++ trunk/library/configs/db/patches.sql 2012-06-14 15:30:38 UTC (rev 764) @@ -411,3 +411,6 @@ -- GEMS VERSION: 48 -- PATCH: Add duration to surveys ALTER TABLE gems__surveys ADD gsu_duration varchar(50) CHARACTER SET 'utf8' COLLATE 'utf8_general_ci' AFTER gsu_result_field; + +-- PATCH: Allow multi org view for supers +UPDATE gems__roles SET grl_privileges = CONCAT(grl_privileges, ',pr.respondent.multiorg') WHERE grl_name = 'super' AND grl_privileges NOT LIKE '%pr.respondent.multiorg%'; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |