From: <gem...@li...> - 2012-06-21 12:10:48
|
Revision: 777 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=777&view=rev Author: matijsdejong Date: 2012-06-21 12:10:37 +0000 (Thu, 21 Jun 2012) Log Message: ----------- Third step in multi organizational view: everything seems to work as intended but found issue at token return that needs to be fixed Modified Paths: -------------- trunk/library/changelog.txt trunk/library/classes/Gems/Default/RespondentAction.php trunk/library/classes/Gems/Menu/SubMenuItem.php trunk/library/classes/Gems/Model.php trunk/library/classes/Gems/Tracker/Snippets/ShowTokenSnippetAbstract.php trunk/library/classes/MUtil/Html/ArrayAttribute.php trunk/library/snippets/ShowSingleSurveyTokenSnippet.php trunk/library/snippets/ShowTrackTokenSnippet.php Added Paths: ----------- trunk/library/classes/Gems/Menu/HiddenOrganizationHrefAttribute.php Removed Paths: ------------- trunk/library/classes/Gems/Model/ModelAbstract.php Modified: trunk/library/changelog.txt =================================================================== --- trunk/library/changelog.txt 2012-06-21 12:07:52 UTC (rev 776) +++ trunk/library/changelog.txt 2012-06-21 12:10:37 UTC (rev 777) @@ -1,3 +1,9 @@ +Important changes from 1.5.4 => 1.5.5 +============================================================ +Internally code no longer uses the 'Hidden Organization' but expects both an id1/patientNr plus an id2/organizationId to be specified +Externally the organization id is still left out of the url when not needed +Check all your (snippet) extensions to RespondentAction and project specific versions of ShowTrackTokenSnippet and ShowSingleSurveySnippet: you may need to specify extra parameters as the menu items need to know the organization id + Important changes from 1.5.3 => 1.5.4 ============================================================ New logLevel project.ini setting Modified: trunk/library/classes/Gems/Default/RespondentAction.php =================================================================== --- trunk/library/classes/Gems/Default/RespondentAction.php 2012-06-21 12:07:52 UTC (rev 776) +++ trunk/library/classes/Gems/Default/RespondentAction.php 2012-06-21 12:10:37 UTC (rev 777) @@ -52,7 +52,7 @@ 'RespondentTokenTabsSnippet', 'RespondentTokenSnippet', ); - + public $exportSnippets = array('RespondentDetailsSnippet'); public $filterStandard = array('grc_success' => 1); @@ -60,10 +60,10 @@ public $sortKey = array('gr2o_opened' => SORT_DESC); public $useTabbedForms = true; - + /** - * Constructs the form - * + * Constructs the form + * * @param Gems_Export_RespondentExport $export * @return Gems_Form_TableForm */ @@ -71,12 +71,12 @@ { $form = new Gems_Form_TableForm(); $form->setAttrib('target', '_blank'); - + $element = new Zend_Form_Element_Checkbox('group'); $element->setLabel($this->_('Group surveys')); $element->setValue(1); $form->addElement($element); - + $element = new Zend_Form_Element_Select('format'); $element->setLabel($this->_('Output format')); $outputFormats = array('html' => 'HTML'); @@ -86,12 +86,12 @@ } $element->setMultiOptions($outputFormats); $form->addElement($element); - + $element = new Zend_Form_Element_Submit('export'); $element->setLabel($this->_('Export')) ->setAttrib('class', 'button'); $form->addElement($element); - + return $form; } @@ -245,7 +245,7 @@ $model->addColumn('CASE WHEN grs_email IS NULL OR LENGTH(TRIM(grs_email)) = 0 THEN 1 ELSE 0 END', 'calc_email'); } - $model->set('gr2o_id_organization', 'default', $model->getCurrentOrganization()); + $model->set('gr2o_id_organization', 'default', $this->getOrganizationId()); return $model; } @@ -343,6 +343,20 @@ $this->html[] = $form; } + /** + * Returns the currently used organization + * + * @return int An organization id + */ + protected function getOrganizationId() + { + if ($orgId = $this->_getParam(MUtil_Model::REQUEST_ID2)) { + return $orgId; + } + + return $this->loader->getCurrentUser()->getCurrentOrganizationId(); + } + public function getMenuParameter($name, $default) { switch ($name) { @@ -476,18 +490,18 @@ } $params['respondentData'] = $data; $this->addSnippets($this->exportSnippets, $params); - + //Now show the export form $export = $this->loader->getRespondentExport($this); $form = $this->_getExportForm($export); $this->html->h2($this->_('Export respondent')); $div = $this->html->div(array('id' => 'mainform')); $div[] = $form; - + $request = $this->getRequest(); - + $form->populate($request->getParams()); - + if ($request->isPost()) { $export->render((array) $data['gr2o_patient_nr'], $this->getRequest()->getParam('group'), $this->getRequest()->getParam('format')); } Added: trunk/library/classes/Gems/Menu/HiddenOrganizationHrefAttribute.php =================================================================== --- trunk/library/classes/Gems/Menu/HiddenOrganizationHrefAttribute.php (rev 0) +++ trunk/library/classes/Gems/Menu/HiddenOrganizationHrefAttribute.php 2012-06-21 12:10:37 UTC (rev 777) @@ -0,0 +1,78 @@ +<?php + +/** + * Copyright (c) 2011, Erasmus MC + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Erasmus MC nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * + * @package Gems + * @subpackage Menu + * @author Matijs de Jong <mj...@ma...> + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @version $Id$ + */ + +/** + * A class that hides the current organization when it is specified as parameter + * + * @package Gems + * @subpackage Menu + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @since Class available since version 1.5.5 + */ +class Gems_Menu_HiddenOrganizationHrefAttribute extends MUtil_Html_HrefArrayAttribute +{ + private $_hiddenOrgId; + + /** + * Returns the rendered values of th earray elements + * + * @return array + */ + protected function _getArrayRendered() + { + $results = parent::_getArrayRendered(); + + // MUtil_Echo::track($results); + + if (isset($results[MUtil_Model::REQUEST_ID1], $results[MUtil_Model::REQUEST_ID2]) && ($results[MUtil_Model::REQUEST_ID2] == $this->_hiddenOrgId)) { + $results[MUtil_Model::REQUEST_ID] = $results[MUtil_Model::REQUEST_ID1]; + unset($results[MUtil_Model::REQUEST_ID1], $results[MUtil_Model::REQUEST_ID2]); + } + + return $results; + } + + /** + * The organization id that should not be displayed. + * + * @param int $orgId Organization id + */ + public function setHiddenOrgId($orgId) { + $this->_hiddenOrgId = $orgId; + } +} Modified: trunk/library/classes/Gems/Menu/SubMenuItem.php =================================================================== --- trunk/library/classes/Gems/Menu/SubMenuItem.php 2012-06-21 12:07:52 UTC (rev 776) +++ trunk/library/classes/Gems/Menu/SubMenuItem.php 2012-06-21 12:10:37 UTC (rev 777) @@ -161,6 +161,15 @@ } } + /** + * A function that determines the parameters that this menu item should have using these paramter + * sources. + * + * @param Gems_Menu_ParameterCollector $source A source of parameter values + * @param array $parameters A usually empty array of parameters that is filled from the sources + * @param boolean $raiseConditions When true, no lazyness is returned + * @return boolean Or lazy condition. When true menu item is enabled otherwise false + */ private function _applyParameterSources(Gems_Menu_ParameterCollector $source, array &$parameters, $raiseConditions) { // Gems_Menu::$verbose = true; @@ -185,10 +194,9 @@ } } - if ($this->_hiddenOrgId) { - // Remove org paramter that should remain hidden. + if ($this->_hiddenOrgId && $raiseConditions) { + // Remove org paramter that should remain hidden when conditions have been raised. if (isset($parameters[MUtil_Model::REQUEST_ID1], $parameters[MUtil_Model::REQUEST_ID2]) && - (! $parameters[MUtil_Model::REQUEST_ID2] instanceof MUtil_Lazy_LazyInterface) && ($parameters[MUtil_Model::REQUEST_ID2] == $this->_hiddenOrgId)) { $parameters[MUtil_Model::REQUEST_ID] = $parameters[MUtil_Model::REQUEST_ID1]; unset($parameters[MUtil_Model::REQUEST_ID1], $parameters[MUtil_Model::REQUEST_ID2]); @@ -198,6 +206,13 @@ return $condition; } + /** + * Generate a hrf attribute using these sources + * + * @param Gems_Menu_ParameterCollector $source A parameter source collection + * @param boolean $condition When true the system may create a Lazy condition for the url + * @return MUtil_Html_HrefArrayAttribute + */ private function _toHRef(Gems_Menu_ParameterCollector $source, &$condition) { if ($this->get('allowed')) { @@ -205,7 +220,12 @@ if ($condition = $this->_applyParameterSources($source, $parameters, ! $condition)) { - $url = new MUtil_Html_HrefArrayAttribute($parameters); + if ($this->_hiddenOrgId) { + $url = new Gems_Menu_HiddenOrganizationHrefAttribute($parameters); + $url->setHiddenOrgId($this->_hiddenOrgId); + } else { + $url = new MUtil_Html_HrefArrayAttribute($parameters); + } $url->setRouteReset($this->get('reset_param', true)); foreach (array('module', 'controller', 'action', 'route') as $name) { @@ -577,6 +597,7 @@ if ($patientId = $request->getParam(MUtil_Model::REQUEST_ID)) { $request->setParam(MUtil_Model::REQUEST_ID1, $patientId); $request->setParam(MUtil_Model::REQUEST_ID2, $this->_hiddenOrgId); + $request->setParam(MUtil_Model::REQUEST_ID, null); } } @@ -781,6 +802,7 @@ public function removeParameters() { + $this->_parameters = true; $this->_requiredParameters = null; return $this; } Deleted: trunk/library/classes/Gems/Model/ModelAbstract.php =================================================================== --- trunk/library/classes/Gems/Model/ModelAbstract.php 2012-06-21 12:07:52 UTC (rev 776) +++ trunk/library/classes/Gems/Model/ModelAbstract.php 2012-06-21 12:10:37 UTC (rev 777) @@ -1,111 +0,0 @@ -<?php -/** - * Copyright (c) 2011, Erasmus MC - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of Erasmus MC nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * Short description of file - * - * @package Gems - * @subpackage - * @copyright Copyright (c) 2011 Erasmus MC - * @license New BSD License - * @version $Id: Sample.php 215 2011-07-12 08:52:54Z michiel $ - */ - -/** - * Short description for ModelAbstract - * - * Long description for class ModelAbstract (if any)... - * - * @package Gems - * @subpackage Sample - * @copyright Copyright (c) 2011 Erasmus MC - * @license New BSD License - * @since Class available since version 1.0 - * @deprecated Class deprecated since version 2.0 - */ -class Gems_Model_ModelAbstract extends Gems_Model_JoinModel implements MUtil_Registry_TargetInterface -{ - /** - * Allows the loader to set resources. - * - * @param string $name Name of resource to set - * @param mixed $resource The resource. - * @return boolean True if $resource was OK - */ - public function answerRegistryRequest($name, $resource) - { - $this->$name = $resource; - - return true; - } - - /** - * 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 true; - } - - /** - * Filters the names that should not be requested. - * - * Can be overriden. - * - * @param string $name - * @return boolean - */ - protected function filterRequestNames($name) - { - return '_' !== $name[0]; - } - - /** - * Allows the loader to know the resources to set. - * - * Returns those object variables defined by the subclass but not at the level of this definition. - * - * Can be overruled. - * - * @return array of string names - */ - public function getRegistryRequests() - { - // Filter using the $this->filterRequestNames() callback - return array_filter(array_keys(get_object_vars($this)), array($this, 'filterRequestNames')); - } - - /** - * This is the place to put code to run after object initialization has finished and when all - * registry requests have been answered - */ - public function init() - { - } -} \ No newline at end of file Modified: trunk/library/classes/Gems/Model.php =================================================================== --- trunk/library/classes/Gems/Model.php 2012-06-21 12:07:52 UTC (rev 776) +++ trunk/library/classes/Gems/Model.php 2012-06-21 12:10:37 UTC (rev 777) @@ -121,7 +121,7 @@ /** * Create a Gems project wide unique user id * - * @see Gems_Model_ModelAbstract + * @see Gems_Model_RespondentModel * * @param mixed $value The value being saved * @param boolean $isNew True when a new item is being saved Modified: trunk/library/classes/Gems/Tracker/Snippets/ShowTokenSnippetAbstract.php =================================================================== --- trunk/library/classes/Gems/Tracker/Snippets/ShowTokenSnippetAbstract.php 2012-06-21 12:07:52 UTC (rev 776) +++ trunk/library/classes/Gems/Tracker/Snippets/ShowTokenSnippetAbstract.php 2012-06-21 12:10:37 UTC (rev 777) @@ -36,7 +36,7 @@ */ /** - * Generic extension for displaying tokens + * Generic extension for displaying tokens * * @package Gems * @subpackage Tracker Modified: trunk/library/classes/MUtil/Html/ArrayAttribute.php =================================================================== --- trunk/library/classes/MUtil/Html/ArrayAttribute.php 2012-06-21 12:07:52 UTC (rev 776) +++ trunk/library/classes/MUtil/Html/ArrayAttribute.php 2012-06-21 12:10:37 UTC (rev 777) @@ -91,6 +91,11 @@ parent::__construct($name, $value); } + /** + * Returns the rendered values of th earray elements + * + * @return array + */ protected function _getArrayRendered() { $results = array(); Modified: trunk/library/snippets/ShowSingleSurveyTokenSnippet.php =================================================================== --- trunk/library/snippets/ShowSingleSurveyTokenSnippet.php 2012-06-21 12:07:52 UTC (rev 776) +++ trunk/library/snippets/ShowSingleSurveyTokenSnippet.php 2012-06-21 12:10:37 UTC (rev 777) @@ -62,6 +62,9 @@ // Extra parameter needed for menu items $bridge->gtr_track_type; + $bridge->gr2t_id_respondent_track; + $bridge->gr2o_patient_nr; + $bridge->gr2o_id_organization; $bridge->grc_success; $controller = $this->request->getControllerName(); Modified: trunk/library/snippets/ShowTrackTokenSnippet.php =================================================================== --- trunk/library/snippets/ShowTrackTokenSnippet.php 2012-06-21 12:07:52 UTC (rev 776) +++ trunk/library/snippets/ShowTrackTokenSnippet.php 2012-06-21 12:10:37 UTC (rev 777) @@ -1,6 +1,5 @@ <?php - /** * Copyright (c) 2011, Erasmus MC * All rights reserved. @@ -63,6 +62,9 @@ // Extra item needed for menu items $bridge->gtr_track_type; + $bridge->gr2t_id_respondent_track; + $bridge->gr2o_patient_nr; + $bridge->gr2o_id_organization; $bridge->grc_success; $controller = $this->request->getControllerName(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |