From: <gem...@li...> - 2011-11-04 09:59:37
|
Revision: 180 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=180&view=rev Author: matijsdejong Date: 2011-11-04 09:59:31 +0000 (Fri, 04 Nov 2011) Log Message: ----------- Implementation of #39: the user should return to the screen from which he or she started filling in the survey. Modified Paths: -------------- trunk/library/classes/Gems/Default/AskAction.php trunk/library/classes/Gems/Default/RespondentAction.php trunk/library/classes/Gems/Default/StaffAction.php trunk/library/classes/Gems/Default/TrackActionAbstract.php Modified: trunk/library/classes/Gems/Default/AskAction.php =================================================================== --- trunk/library/classes/Gems/Default/AskAction.php 2011-11-04 09:31:20 UTC (rev 179) +++ trunk/library/classes/Gems/Default/AskAction.php 2011-11-04 09:59:31 UTC (rev 180) @@ -186,6 +186,9 @@ public function indexAction() { + // Make sure to return to ask screen + $this->session->return_controller = $this->getRequest()->getControllerName(); + $tracker = $this->loader->getTracker(); $max_length = $tracker->getTokenLibrary()->getLength(); @@ -242,11 +245,40 @@ public function returnAction() { - if (isset($this->session->user_id)) { + if (isset($this->session->user_id) && $this->session->user_id) { $tracker = $this->loader->getTracker(); $token = $tracker->getToken($tracker->filterToken($this->_getParam(MUtil_Model::REQUEST_ID))); - $this->_reroute(array('controller' => 'respondent', 'action' => 'show', MUtil_Model::REQUEST_ID => $token->getPatientNumber()), true); + // Check for completed tokens + $this->loader->getTracker()->processCompletedTokens($token->getRespondentId(), $this->session->user_id); + + if (isset($this->session->return_controller) && $this->session->return_controller) { + $return = $this->session->return_controller; + } else { + $return = 'respondent'; + } + + $parameters['controller'] = $return; + $parameters['action'] = 'show'; + $parameters[MUtil_Model::REQUEST_ID] = $token->getPatientNumber(); + switch ($return) { + case 'track': + $parameters['action'] = 'show-track'; + $parameters[Gems_Model::RESPONDENT_TRACK] = $token->getRespondentTrackId(); + break; + + case 'survey': + $parameters[MUtil_Model::REQUEST_ID] = $token->getTokenId(); + break; + + case 'ask': + $this->_forward('forward'); + return; + + default: + $parameters['controller'] = 'respondent'; + } + $this->_reroute($parameters, true); } else { $this->_forward('forward'); } Modified: trunk/library/classes/Gems/Default/RespondentAction.php =================================================================== --- trunk/library/classes/Gems/Default/RespondentAction.php 2011-11-04 09:31:20 UTC (rev 179) +++ trunk/library/classes/Gems/Default/RespondentAction.php 2011-11-04 09:59:31 UTC (rev 180) @@ -360,6 +360,20 @@ return $this->_('Respondents'); } + /** + * Initialize translate and html objects + * + * Called from {@link __construct()} as final step of object instantiation. + * + * @return void + */ + public function init() + { + parent::init(); + + $this->session->return_controller = $this->getRequest()->getControllerName(); + } + protected function openedRespondent($patientId, $orgId = null, $userId = null) { if ($patientId) { @@ -387,12 +401,6 @@ // Log $this->openedRespondent($data['gr2o_patient_nr'], $data['gr2o_id_organization'], $data['grs_id_user']); - // Check for completed tokens - if ($this->loader->getTracker()->processCompletedTokens($data['grs_id_user'], $this->session->user_id)) { - //As data might have changed due to token events... reload - $data = $model->applyRequest($this->getRequest(), true)->loadFirst(); - } - if ($data['gr2o_consent'] == $model->get('gr2o_consent', 'default')) { $url = $this->view->url(array('controller' => 'respondent', 'action' => 'edit', 'id' => $data['gr2o_patient_nr'])) . '#tabContainer-frag-3'; $this->addMessage(MUtil_Html::create()->a($url, $this->_('Please settle the informed consent form for this respondent.'))); Modified: trunk/library/classes/Gems/Default/StaffAction.php =================================================================== --- trunk/library/classes/Gems/Default/StaffAction.php 2011-11-04 09:31:20 UTC (rev 179) +++ trunk/library/classes/Gems/Default/StaffAction.php 2011-11-04 09:59:31 UTC (rev 180) @@ -107,7 +107,7 @@ $bridge->addHidden( 'gsf_id_user'); // Needed for e-mail validation $bridge->addHidden( 'gsu_user_class'); $bridge->addText( 'gsu_login', 'size', 15, 'minlength', 4, - 'validator', $model->createUniqueValidator('gsu_login')); + 'validator', $model->createUniqueValidator('gsu_login', array('gsu_id_user'))); // Can the organization be changed? if ($this->escort->hasPrivilege('pr.staff.edit.all')) { Modified: trunk/library/classes/Gems/Default/TrackActionAbstract.php =================================================================== --- trunk/library/classes/Gems/Default/TrackActionAbstract.php 2011-11-04 09:31:20 UTC (rev 179) +++ trunk/library/classes/Gems/Default/TrackActionAbstract.php 2011-11-04 09:59:31 UTC (rev 180) @@ -352,6 +352,20 @@ parent::indexAction(); } + /** + * Initialize translate and html objects + * + * Called from {@link __construct()} as final step of object instantiation. + * + * @return void + */ + public function init() + { + parent::init(); + + $this->session->return_controller = $this->getRequest()->getControllerName(); + } + public function initFilter() { // FROM REQUEST This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |