From: <gem...@li...> - 2012-03-29 09:42:23
|
Revision: 573 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=573&view=rev Author: michieltcs Date: 2012-03-29 09:42:13 +0000 (Thu, 29 Mar 2012) Log Message: ----------- Revert r571 and r572 (going another route) Revision Links: -------------- http://gemstracker.svn.sourceforge.net/gemstracker/?rev=571&view=rev http://gemstracker.svn.sourceforge.net/gemstracker/?rev=572&view=rev Modified Paths: -------------- trunk/library/classes/Gems/Tracker/Engine/TrackEngineAbstract.php trunk/library/classes/Gems/Tracker/Snippets/EditRoundSnippetAbstract.php trunk/library/classes/Gems/Util/TrackData.php Modified: trunk/library/classes/Gems/Tracker/Engine/TrackEngineAbstract.php =================================================================== --- trunk/library/classes/Gems/Tracker/Engine/TrackEngineAbstract.php 2012-03-28 19:45:36 UTC (rev 572) +++ trunk/library/classes/Gems/Tracker/Engine/TrackEngineAbstract.php 2012-03-29 09:42:13 UTC (rev 573) @@ -733,7 +733,7 @@ $model->set('gro_id_track', 'label', $this->_('Track'), 'elementClass', 'exhibitor', 'multiOptions', MUtil_Lazy::call($this->util->getTrackData()->getAllTracks)); } - $model->set('gro_id_survey', 'label', $this->_('Survey'), 'multiOptions', $this->util->getTrackData()->getActiveSurveysAndDescriptions()); + $model->set('gro_id_survey', 'label', $this->_('Survey'), 'multiOptions', $this->util->getTrackData()->getAllSurveysAndDescriptions()); $model->set('gro_icon_file', 'label', $this->_('Icon')); $model->set('gro_id_order', 'label', $this->_('Order'), 'default', 10, 'validators[]', $model->createUniqueValidator(array('gro_id_order', 'gro_id_track'))); $model->set('gro_round_description', 'label', $this->_('Description'), 'size', '30'); //, 'minlength', 4, 'required', true); Modified: trunk/library/classes/Gems/Tracker/Snippets/EditRoundSnippetAbstract.php =================================================================== --- trunk/library/classes/Gems/Tracker/Snippets/EditRoundSnippetAbstract.php 2012-03-28 19:45:36 UTC (rev 572) +++ trunk/library/classes/Gems/Tracker/Snippets/EditRoundSnippetAbstract.php 2012-03-29 09:42:13 UTC (rev 573) @@ -182,7 +182,7 @@ } // Check the survey name - $surveys = $this->util->getTrackData()->getActiveSurveys(); + $surveys = $this->util->getTrackData()->getAllSurveys(); if (isset($surveys[$this->formData['gro_id_survey']])) { $this->formData['gro_survey_name'] = $surveys[$this->formData['gro_id_survey']]; } else { Modified: trunk/library/classes/Gems/Util/TrackData.php =================================================================== --- trunk/library/classes/Gems/Util/TrackData.php 2012-03-28 19:45:36 UTC (rev 572) +++ trunk/library/classes/Gems/Util/TrackData.php 2012-03-29 09:42:13 UTC (rev 573) @@ -82,42 +82,20 @@ return $dates; } // */ - /** - * Retrieve an array of key/value pairs for gsu_id_survey and gsu_survey_name - * only the active surveys - * - * @staticvar array $activeSurveys - * @return array - */ + /* public function getActiveSurveys() { - static $activeSurveys; + static $surveys; - if (! $activeSurveys) { - $activeSurveys = $this->db->fetchPairs('SELECT gsu_id_survey, gsu_survey_name FROM gems__surveys WHERE gsu_active = 1 AND gsu_surveyor_active = 1 ORDER BY gsu_survey_name'); + if (! $surveys) { + $surveys = $this->util->getTranslated()->getEmptyDropdownArray(); + $surveys = $surveys + $this->db->fetchPairs('SELECT gsu_id_survey, gsu_survey_name FROM gems__surveys WHERE gsu_active = 1 AND gsu_surveyor_active = 1 ORDER BY gsu_survey_name'); } - return $activeSurveys; - } + return $surveys; + } // */ - /** - * Retrieve an array of key/value pairs for gsu_id_survey and gsu_survey_name - * only the active surveys - * - * @staticvar array $activeSurveys - * @return array - */ - public function getActiveSurveysAndDescriptions() - { - static $activeSurveys; - if (! $activeSurveys) { - $activeSurveys = $this->db->fetchPairs('SELECT gsu_id_survey, LEFT(CONCAT_WS(" - ", gsu_survey_name, gsu_survey_description),50) FROM gems__surveys WHERE gsu_active = 1 AND gsu_surveyor_active = 1 ORDER BY gsu_survey_name'); - } - - return $activeSurveys; - } - /** * Retrieve an array of key/value pairs for gsu_id_survey and gsu_survey_name * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2012-03-29 19:58:04
|
Revision: 578 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=578&view=rev Author: matijsdejong Date: 2012-03-29 19:57:58 +0000 (Thu, 29 Mar 2012) Log Message: ----------- Implement generic return mechanism for ask/return Added tables to TokenSelect.php Modified Paths: -------------- trunk/library/classes/Gems/Default/AskAction.php trunk/library/classes/Gems/Tracker/Token/TokenSelect.php Modified: trunk/library/classes/Gems/Default/AskAction.php =================================================================== --- trunk/library/classes/Gems/Default/AskAction.php 2012-03-29 17:08:31 UTC (rev 577) +++ trunk/library/classes/Gems/Default/AskAction.php 2012-03-29 19:57:58 UTC (rev 578) @@ -303,7 +303,13 @@ return; default: - $parameters['controller'] = 'respondent'; + // Allow open specification of return + if (strpos($return, '/') !== false) { + $parameters = MUtil_Ra::pairs(explode('/', $return)); + // MUtil_Echo::track($parameters); + } else { + $parameters['controller'] = 'respondent'; + } } $this->_reroute($parameters, true); } else { Modified: trunk/library/classes/Gems/Tracker/Token/TokenSelect.php =================================================================== --- trunk/library/classes/Gems/Tracker/Token/TokenSelect.php 2012-03-29 17:08:31 UTC (rev 577) +++ trunk/library/classes/Gems/Tracker/Token/TokenSelect.php 2012-03-29 19:57:58 UTC (rev 578) @@ -136,6 +136,20 @@ } /** + * Add Respondent Track info to the select statement + * + * @param string|array $fields + * @return Gems_Tracker_Token_TokenSelect + */ + public function andRespondentTracks($fields = '*') { + $this->sql_select->join('gems__respondent2track', + 'gto_id_respondent_track = gr2t_id_respondent_track', + $fields); + + return $this; + } + + /** * Adds round info to the select statement * * @param string|array $fields This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2012-04-05 15:50:42
|
Revision: 599 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=599&view=rev Author: matijsdejong Date: 2012-04-05 15:50:36 +0000 (Thu, 05 Apr 2012) Log Message: ----------- New survey return mechanism that allows more flexible return mechanism Database patches now sorted on date changed, plus more cache cleanup for database objects Modified Paths: -------------- trunk/library/classes/Gems/Default/AskAction.php trunk/library/classes/Gems/Default/DatabaseAction.php trunk/library/classes/Gems/Default/RespondentAction.php trunk/library/classes/Gems/Default/TrackActionAbstract.php trunk/library/classes/Gems/User/User.php Modified: trunk/library/classes/Gems/Default/AskAction.php =================================================================== --- trunk/library/classes/Gems/Default/AskAction.php 2012-04-05 14:29:54 UTC (rev 598) +++ trunk/library/classes/Gems/Default/AskAction.php 2012-04-05 15:50:36 UTC (rev 599) @@ -272,46 +272,25 @@ public function returnAction() { - if (isset($this->session->user_id) && $this->session->user_id) { + $user = $this->loader->getCurrentUser(); + + if ($user->isActive()) { $tracker = $this->loader->getTracker(); $token = $tracker->getToken($tracker->filterToken($this->_getParam(MUtil_Model::REQUEST_ID))); // Check for completed tokens - $this->loader->getTracker()->processCompletedTokens($token->getRespondentId(), $this->session->user_id); + $this->loader->getTracker()->processCompletedTokens($token->getRespondentId(), $user->getUserId()); - if (isset($this->session->return_controller) && $this->session->return_controller) { - $return = $this->session->return_controller; - } else { - $return = 'respondent'; + $parameters = $user->getSurveyReturn(); + if (! $parameters) { + // Default + $request = $this->getRequest(); + $parameters[$request->getControllerKey()] = 'respondent'; + $parameters[$request->getActionKey()] = 'show'; + $parameters[MUtil_Model::REQUEST_ID] = $token->getPatientNumber(); } - $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: - // Allow open specification of return - if (strpos($return, '/') !== false) { - $parameters = MUtil_Ra::pairs(explode('/', $return)); - // MUtil_Echo::track($parameters); - } else { - $parameters['controller'] = 'respondent'; - } - } - $this->_reroute($parameters, true); + $this->_reroute($parameters, true); } else { $this->_forward('forward'); } Modified: trunk/library/classes/Gems/Default/DatabaseAction.php =================================================================== --- trunk/library/classes/Gems/Default/DatabaseAction.php 2012-04-05 14:29:54 UTC (rev 598) +++ trunk/library/classes/Gems/Default/DatabaseAction.php 2012-04-05 15:50:36 UTC (rev 599) @@ -61,6 +61,22 @@ } /** + * Make sure the cache is cleaned. + * + * As a lot of cache depends on the database, it is best to clean the cache + * now since import tables might have changed. + * + * @return void + */ + private function _cleanCache() + { + if ($this->cache instanceof Zend_Cache_Core) { + $this->cache->clean(); + $this->addMessage($this->_('Cache cleaned')); + } + } + + /** * Adds elements from the model to the bridge that creates the form. * * Overrule this function to add different elements to the browse table, without @@ -181,6 +197,7 @@ try { $stmt = $this->db->query($sql); $this->addMessage(sprintf($this->_('%1$s %2$s dropped'), $data['name'], $this->_(strtolower($data['type'])))); + $this->_cleanCache(); $model->save(array('exists' => false), $model->getFilter()); @@ -266,13 +283,14 @@ $patcher = new Gems_Util_DatabasePatcher($this->db, 'patches.sql', $this->escort->getDatabasePaths()); $changed = $patcher->uploadPatches($this->loader->getVersions()->getBuild()); $tableSql = sprintf( - 'SELECT gpa_level AS `%s`, gpa_location AS `%s`, COUNT(*) AS `%s`, COUNT(*) - SUM(gpa_executed) AS `%s`, SUM(gpa_executed) AS `%s`, SUM(gpa_completed) AS `%s` FROM gems__patches GROUP BY gpa_level, gpa_location ORDER BY gpa_level DESC, gpa_location', + 'SELECT gpa_level AS `%s`, gpa_location AS `%s`, COUNT(*) AS `%s`, COUNT(*) - SUM(gpa_executed) AS `%s`, SUM(gpa_executed) AS `%s`, SUM(gpa_completed) AS `%s`, MAX(gpa_changed) AS `%s` FROM gems__patches GROUP BY gpa_level, gpa_location ORDER BY gpa_level DESC, gpa_location', $this->_('Level'), $this->_('Subtype'), $this->_('Patches'), $this->_('To be executed'), $this->_('Executed'), - $this->_('Finished')); + $this->_('Finished'), + $this->_('Changed on')); if ($changed == -1) { $this->addMessage($this->_('Create the patch table!')); @@ -306,18 +324,11 @@ $form->getElement('db_level')->setValue($data['db_level']); $this->addMessage(sprintf($this->_('%d patch(es) executed.'), $changed)); - - //As a lot of cache depends on the database, it is best to clean the cache now - //since import tables might have changed - $cache = $this->escort->cache; - if ($cache instanceof Zend_Cache_Core) { - $cache->clean(); - $this->addMessage($this->_('Cache cleaned')); - } + $this->_cleanCache(); } $tableSql = sprintf( - 'SELECT gpa_id_patch AS `%s`, gpa_level AS `%s`, gpa_location AS `%s`, gpa_name AS `%s`, gpa_sql AS `%s`, gpa_executed AS `%s`, gpa_completed AS `%s`, gpa_result as `%s` FROM gems__patches WHERE gpa_level = ? ORDER BY gpa_level, gpa_location, gpa_name, gpa_order', + 'SELECT gpa_id_patch AS `%s`, gpa_level AS `%s`, gpa_location AS `%s`, gpa_name AS `%s`, gpa_sql AS `%s`, gpa_executed AS `%s`, gpa_completed AS `%s`, gpa_result AS `%s`, gpa_changed AS `%s` FROM gems__patches WHERE gpa_level = ? ORDER BY gpa_level, gpa_changed DESC, gpa_location, gpa_name, gpa_order', $this->_('Patch'), $this->_('Level'), $this->_('Subtype'), @@ -325,7 +336,8 @@ $this->_('Query'), $this->_('Executed'), $this->_('Finished'), - $this->_('Result')); + $this->_('Result'), + $this->_('Changed on')); $tableSql = $this->db->quoteInto($tableSql, $form->getValue('level')); } @@ -439,6 +451,7 @@ $results = $model->runScript($data); $this->addMessage($results); + $this->_cleanCache(); $this->_reroute(array('action' => 'show')); } } @@ -461,10 +474,12 @@ $results[] = sprintf($this->_('Finished %s creation script for object %d of %d'), $this->_(strtolower($data['type'])), $i, $oCount) . '<br/>'; $i++; } + } else { $results[] = $this->_('All objects exist. Nothing was executed.'); } $this->addMessage($results); + $this->_cleanCache(); $this->_reroute(array('action' => 'index'), true); } Modified: trunk/library/classes/Gems/Default/RespondentAction.php =================================================================== --- trunk/library/classes/Gems/Default/RespondentAction.php 2012-04-05 14:29:54 UTC (rev 598) +++ trunk/library/classes/Gems/Default/RespondentAction.php 2012-04-05 15:50:36 UTC (rev 599) @@ -355,7 +355,8 @@ { parent::init(); - $this->session->return_controller = $this->getRequest()->getControllerName(); + // Tell the system where to return to after a survey has been taken + $this->loader->getCurrentUser()->setSurveyReturn($this->getRequest()); } protected function openedRespondent($patientId, $orgId = null, $userId = null) Modified: trunk/library/classes/Gems/Default/TrackActionAbstract.php =================================================================== --- trunk/library/classes/Gems/Default/TrackActionAbstract.php 2012-04-05 14:29:54 UTC (rev 598) +++ trunk/library/classes/Gems/Default/TrackActionAbstract.php 2012-04-05 15:50:36 UTC (rev 599) @@ -365,7 +365,8 @@ { parent::init(); - $this->session->return_controller = $this->getRequest()->getControllerName(); + // Tell the system where to return to after a survey has been taken + $this->loader->getCurrentUser()->setSurveyReturn($this->getRequest()); } public function initFilter() Modified: trunk/library/classes/Gems/User/User.php =================================================================== --- trunk/library/classes/Gems/User/User.php 2012-04-05 14:29:54 UTC (rev 598) +++ trunk/library/classes/Gems/User/User.php 2012-04-05 15:50:36 UTC (rev 599) @@ -846,6 +846,16 @@ } /** + * get the parameters where the survey should return to + * + * @return array + */ + public function getSurveyReturn() + { + return $this->_getVar('surveyReturn', array()); + } + + /** * Returns the user id, that identifies this user within this installation. * * One user id might be connected to multiple logins for multiple organizations. @@ -1317,6 +1327,25 @@ } /** + * Set the parameters where the survey should return to + * + * @param mixed $return Zend_Controller_Request_Abstract, array of something that can be turned into one. + * @return Gems_User_User + */ + public function setSurveyReturn($return) + { + if ($return instanceof Zend_Controller_Request_Abstract) { + $return = $return->getParams(); + } elseif (! is_array($return)) { + $return = MUtil_Ra::to($return); + } + + $this->_setVar('surveyReturn', $return); + + return $this; + } + + /** * Unsets this user as the current user. * * This means that the data about this user will no longer be stored in a session. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2012-04-05 16:40:41
|
Revision: 600 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=600&view=rev Author: matijsdejong Date: 2012-04-05 16:40:35 +0000 (Thu, 05 Apr 2012) Log Message: ----------- Changed token forward mechanism: token is inserted in Lime Survey only when the user clicks on the link Modified Paths: -------------- trunk/library/classes/Gems/Default/AskAction.php trunk/library/classes/Gems/Menu.php trunk/library/classes/Gems/Tracker/Source/LimeSurvey1m9Database.php Modified: trunk/library/classes/Gems/Default/AskAction.php =================================================================== --- trunk/library/classes/Gems/Default/AskAction.php 2012-04-05 15:50:36 UTC (rev 599) +++ trunk/library/classes/Gems/Default/AskAction.php 2012-04-05 16:40:35 UTC (rev 600) @@ -50,7 +50,6 @@ public function forwardAction() { $tracker = $this->loader->getTracker(); - $language = $this->locale->getLanguage(); /************** * Find token * @@ -82,16 +81,14 @@ /*************** * Get the url * ***************/ - $user = $this->loader->getCurrentUser(); - $url = $token->getUrl($language, $user->getUserId() ? $user->getUserId() : $respId); + $request = $this->getRequest(); + $params[$request->getActionKey()] = 'to-survey'; + $params[MUtil_Model::REQUEST_ID] = $token->getTokenId(); + + $href = new MUtil_Html_HrefArrayAttribute($params); + $href->setRouteReset(false); + $url = $href->render($this->view); - /************************ - * Optional user logout * - ************************/ - if ($user->isLogoutOnSurvey()) { - $user->unsetAsCurrentUser(); - } - /*********************************** * Should we stay or should we go? * ***********************************/ @@ -144,7 +141,7 @@ } $buttonDiv = $this->html->buttonDiv(array('class' => 'centerAlign')); - $buttonDiv->actionLink(MUtil_Html::raw($url), $token->getSurveyName()); + $buttonDiv->actionLink($href, $token->getSurveyName()); if (isset($delay)) { $buttonDiv->actionLink(array('delay_cancelled' => 1), $this->_('Cancel')); @@ -299,15 +296,47 @@ public function takeAction() { // Dummy to enable separate rights - $this->_forward('forward'); + $this->_forward('to-survey'); } + /** + * Old action mentioned on some documentation + */ public function tokenAction() { - // Staat om sommige documentatie $this->_forward('index'); } + /** + * Go directly to url + */ + public function toSurveyAction() + { + $tracker = $this->loader->getTracker(); + if ($tokenId = $this->_getParam(MUtil_Model::REQUEST_ID)) { + $tokenId = $tracker->filterToken($tokenId); + + if ($token = $tracker->getToken($tokenId)) { + $language = $this->locale->getLanguage(); + $user = $this->loader->getCurrentUser(); + $url = $token->getUrl($language, $user->getUserId() ? $user->getUserId() : $token->getRespondentId()); + + /************************ + * Optional user logout * + ************************/ + if ($user->isLogoutOnSurvey()) { + $user->unsetAsCurrentUser(); + } + + // Redirect at once + header('Location: ' . $url); + exit(); + } + } + + // Default option + $this->_forward('index'); + } public function routeError($message) { // TODO make nice Modified: trunk/library/classes/Gems/Menu.php =================================================================== --- trunk/library/classes/Gems/Menu.php 2012-04-05 15:50:36 UTC (rev 599) +++ trunk/library/classes/Gems/Menu.php 2012-04-05 16:40:35 UTC (rev 600) @@ -114,6 +114,7 @@ // Routes for token controller $page->addAction(null, null, 'forward'); $page->addAction(null, null, 'return'); + $page->addAction(null, null, 'to-survey')->setModelParameters(1); $page->addAction(null, null, 'token'); return $page; Modified: trunk/library/classes/Gems/Tracker/Source/LimeSurvey1m9Database.php =================================================================== --- trunk/library/classes/Gems/Tracker/Source/LimeSurvey1m9Database.php 2012-04-05 15:50:36 UTC (rev 599) +++ trunk/library/classes/Gems/Tracker/Source/LimeSurvey1m9Database.php 2012-04-05 16:40:35 UTC (rev 600) @@ -365,7 +365,7 @@ { $messages = array(); $survey = $this->tracker->getSurvey($surveyId); - + if (null === $sourceSurveyId) { // Was removed $values['gsu_active'] = 0; @@ -995,7 +995,8 @@ } // mgzdev.erasmusmc.nl/incant/index.php?sid=1&token=o7l9_b8z2 - return $this->getBaseUrl() . '/index.php?sid=' . $sourceSurveyId . '&token=' . $tokenId . $langUrl; + $baseurl = $this->getBaseUrl(); + return $baseurl . ('/' == substr($baseurl, -1) ? '' : '/') . 'index.php?sid=' . $sourceSurveyId . '&token=' . $tokenId . $langUrl; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2012-04-08 13:41:26
|
Revision: 607 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=607&view=rev Author: matijsdejong Date: 2012-04-08 13:41:19 +0000 (Sun, 08 Apr 2012) Log Message: ----------- Adapted User object so the user can never login to an organization url of an organization where he/she has no access ChangePasswordForm.php now uses the same default sizes for password input as the other user forms Simplified displayResetForm parameters Modified Paths: -------------- trunk/library/classes/Gems/Default/IndexAction.php trunk/library/classes/Gems/Default/OptionAction.php trunk/library/classes/Gems/User/Form/ChangePasswordForm.php trunk/library/classes/Gems/User/User.php Modified: trunk/library/classes/Gems/Default/IndexAction.php =================================================================== --- trunk/library/classes/Gems/Default/IndexAction.php 2012-04-06 18:15:38 UTC (rev 606) +++ trunk/library/classes/Gems/Default/IndexAction.php 2012-04-08 13:41:19 UTC (rev 607) @@ -146,11 +146,13 @@ * @param Gems_Form_AutoLoadFormAbstract $form Rset password or reset request form * @param mixed $errors */ - protected function displayResetForm(Gems_Form_AutoLoadFormAbstract $form, $errors, Gems_User_User $user = null) + protected function displayResetForm(Gems_Form_AutoLoadFormAbstract $form, $errors) { - if ($form instanceof Gems_User_Form_ResetRequestForm) { + if ($form instanceof Gems_User_Validate_GetUserInterface) { $user = $form->getUser(); + } + if ($form instanceof Gems_User_Form_ResetRequestForm) { $this->html->h3($this->_('Request password reset')); $p = $this->html->pInfo(); @@ -162,7 +164,8 @@ $this->html->p($this->_('We will then send you an e-mail with a link. The link will bring you to a page where you can set a new password of your choice.')); } elseif ($form instanceof Gems_User_Form_ChangePasswordForm) { - $form->getUser()->getCurrentOrganization()->setAsCurrentOrganization(); + + $this->setCurrentOrganizationTo($user); if ($user->hasPassword()) { $this->html->h3($this->_('Execute password reset')); $p = $this->html->pInfo($this->_('We received your password reset request.')); @@ -179,7 +182,7 @@ $this->addMessage($errors); } - if ($user) { + if (isset($user)) { $this->setCurrentOrganizationTo($user); } @@ -276,13 +279,12 @@ $errors = array(); $form = $this->createResetRequestForm(); $request = $this->getRequest(); - $user = null; if ($key = $this->_getParam('key')) { $user = $this->loader->getUserLoader()->getUserByResetKey($key); if ($user->hasValidResetKey()) { - $form = $user->getChangePasswordForm(array('askOld' => false, 'askCheck' => true)); + $form = $user->getChangePasswordForm(array('askOld' => false, 'askCheck' => true, 'labelWidthFactor' => $this->labelWidthFactor)); } else { if (! $request->isPost()) { if ($user->hasPassword() || (! $user->isActive())) { @@ -317,6 +319,7 @@ } elseif ($form instanceof Gems_User_Form_ChangePasswordForm) { $this->addMessage($this->_('New password is active.')); + // User set before this form was initiated $user->setAsCurrentUser(); $user->gotoStartPage($this->menu, $this->getRequest()); } @@ -324,7 +327,7 @@ } $form->populate($request->getParams()); - $this->displayResetForm($form, $errors, $user); + $this->displayResetForm($form, $errors); } /** Modified: trunk/library/classes/Gems/Default/OptionAction.php =================================================================== --- trunk/library/classes/Gems/Default/OptionAction.php 2012-04-06 18:15:38 UTC (rev 606) +++ trunk/library/classes/Gems/Default/OptionAction.php 2012-04-08 13:41:19 UTC (rev 607) @@ -85,7 +85,7 @@ /************* * Make form * *************/ - $form = $user->getChangePasswordForm(array('showReport' => false)); + $form = $user->getChangePasswordForm(array('showReport' => false, 'useTableLayout' => true)); /**************** * Process form * Modified: trunk/library/classes/Gems/User/Form/ChangePasswordForm.php =================================================================== --- trunk/library/classes/Gems/User/Form/ChangePasswordForm.php 2012-04-06 18:15:38 UTC (rev 606) +++ trunk/library/classes/Gems/User/Form/ChangePasswordForm.php 2012-04-08 13:41:19 UTC (rev 607) @@ -44,7 +44,7 @@ * @license New BSD License * @since Class available since version 1.5 */ -class Gems_User_Form_ChangePasswordForm extends Gems_Form_AutoLoadFormAbstract +class Gems_User_Form_ChangePasswordForm extends Gems_Form_AutoLoadFormAbstract implements Gems_User_Validate_GetUserInterface { /** * The field name for the new password element. @@ -132,7 +132,7 @@ * * @var boolean */ - protected $useTableLayout = true; + protected $useTableLayout = false; public function addButtons($links) { @@ -176,6 +176,21 @@ } /** + * 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 values are missing. + */ + public function checkRegistryRequestsAnswers() + { + if ($this->translate && $this->user) { + return parent::checkRegistryRequestsAnswers(); + } else { + return false; + } + } + + /** * Should a user specific check question be asked? * * @return boolean @@ -218,8 +233,7 @@ // Field new password $element = new Zend_Form_Element_Password($this->_newPasswordFieldName); $element->setLabel($this->translate->_('New password')); - $element->setAttrib('size', 10); - $element->setAttrib('maxlength', 20); + $element->setAttrib('size', 40); $element->setRequired(true); $element->setRenderPassword(true); $element->addValidator(new Gems_User_Validate_NewPasswordValidator($this->user)); @@ -247,8 +261,7 @@ // Field current password $element = new Zend_Form_Element_Password($this->_oldPasswordFieldName); $element->setLabel($this->translate->_('Current password')); - $element->setAttrib('size', 10); - $element->setAttrib('maxlength', 20); + $element->setAttrib('size', 40); $element->setRenderPassword(true); $element->setRequired(true); $element->addValidator(new Gems_User_Validate_UserPasswordValidator($this->user, $this->translate->_('Wrong password.'))); @@ -272,8 +285,7 @@ // Field repeat password $element = new Zend_Form_Element_Password($this->_repeatPasswordFieldName); $element->setLabel($this->translate->_('Repeat password')); - $element->setAttrib('size', 10); - $element->setAttrib('maxlength', 20); + $element->setAttrib('size', 40); $element->setRequired(true); $element->setRenderPassword(true); @@ -330,6 +342,16 @@ } /** + * Returns a user + * + * @return Gems_User_User + */ + public function getUser() + { + return $this->user; + } + + /** * Validate the form * * As it is better for translation utilities to set the labels etc. translated, Modified: trunk/library/classes/Gems/User/User.php =================================================================== --- trunk/library/classes/Gems/User/User.php 2012-04-06 18:15:38 UTC (rev 606) +++ trunk/library/classes/Gems/User/User.php 2012-04-08 13:41:19 UTC (rev 607) @@ -445,6 +445,27 @@ } /** + * True when the current url is one where this user is allowed to login. + * + * If the url is a fixed organization url and the user is not allowed to + * access this organization, then this function returns false. + * + * @return boolean + */ + public function canLoginHere() + { + if (! $this->_hasVar('can_login_here')) { + $this->_setVar('can_login_here', true); + if ($orgId = $this->userLoader->getOrganizationIdByUrl()) { + if (! $this->isAllowedOrganization($orgId)) { + $this->_setVar('can_login_here', false);; + } + } + } + return $this->_getVar('can_login_here'); + } + + /** * Return true if a password reset key can be created. * * @return boolean @@ -461,7 +482,7 @@ */ public function canSetPassword() { - return $this->definition->canSetPassword(); + return $this->isActive() && $this->definition->canSetPassword(); } /** @@ -472,7 +493,7 @@ */ public function checkPasswordResetKey($key) { - return $this->definition->checkPasswordResetKey($this, $key); + return $this->isActive() && $this->definition->checkPasswordResetKey($this, $key); } /** @@ -955,13 +976,13 @@ } /** - * True when the reset key is within it's timeframe + * True when the reset key is within it's timeframe and OK for the current organization * * @return boolean */ public function hasValidResetKey() { - return (boolean) $this->_getVar('user_resetkey_valid'); + return (boolean) $this->isActive() && $this->_getVar('user_resetkey_valid'); } /** @@ -970,7 +991,7 @@ */ public function isActive() { - return (boolean) $this->_getVar('user_active'); + return (boolean) $this->canLoginHere() && $this->_getVar('user_active'); } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2012-04-08 16:27:38
|
Revision: 609 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=609&view=rev Author: matijsdejong Date: 2012-04-08 16:27:31 +0000 (Sun, 08 Apr 2012) Log Message: ----------- Did some more testing on the forward loop and fixed some return issues Modified Paths: -------------- trunk/library/classes/Gems/Default/AskAction.php trunk/library/classes/Gems/User/User.php Modified: trunk/library/classes/Gems/Default/AskAction.php =================================================================== --- trunk/library/classes/Gems/Default/AskAction.php 2012-04-08 15:05:02 UTC (rev 608) +++ trunk/library/classes/Gems/Default/AskAction.php 2012-04-08 16:27:31 UTC (rev 609) @@ -105,13 +105,12 @@ */ public function forwardAction() { - $tracker = $this->loader->getTracker(); - /************** * Find token * **************/ if ($tokenId = $this->_getParam(MUtil_Model::REQUEST_ID)) { + $tracker = $this->loader->getTracker(); $tokenId = $tracker->filterToken($tokenId); if ($token = $tracker->getToken($tokenId)) { @@ -129,16 +128,16 @@ // Snippet had nothing to display, because of an answer if ($this->getRequest()->getActionName() == 'return') { - $this->addMessage(sprintf($this->_('Thank you for answering. At the moment we have no further surveys for you to take.'), $tokenId)); + $this->addMessage(sprintf($this->_('Thank you for answering. At the moment we have no further surveys for you to take.'), strtoupper($tokenId))); } else { - $this->addMessage(sprintf($this->_('The survey for token %s has been answered and no further surveys are open.'), $tokenId)); + $this->addMessage(sprintf($this->_('The survey for token %s has been answered and no further surveys are open.'), strtoupper($tokenId))); } // Do not enter a loop!! Reroute! $this->_reroute(array('controller' => 'ask', 'action' => 'index'), true); } else { - $this->addMessage(sprintf($this->_('The token %s does not exist (any more).'), $tokenId)); + $this->addMessage(sprintf($this->_('The token %s does not exist (any more).'), strtoupper($tokenId))); } } @@ -152,8 +151,8 @@ */ public function indexAction() { - // Make sure to return to ask screen - $this->loader->getCurrentUser()->setSurveyReturn($this->getRequest()); + // Make sure to return to the forward screen + $this->loader->getCurrentUser()->setSurveyReturn(); $request = $this->getRequest(); $tracker = $this->loader->getTracker(); @@ -175,14 +174,13 @@ { $user = $this->loader->getCurrentUser(); - if ($user->isActive()) { + if ($user->isActive() && ($parameters = $user->getSurveyReturn())) { $tracker = $this->loader->getTracker(); $token = $tracker->getToken($tracker->filterToken($this->_getParam(MUtil_Model::REQUEST_ID))); // Check for completed tokens $this->loader->getTracker()->processCompletedTokens($token->getRespondentId(), $user->getUserId()); - $parameters = $user->getSurveyReturn(); if (! $parameters) { // Default $request = $this->getRequest(); Modified: trunk/library/classes/Gems/User/User.php =================================================================== --- trunk/library/classes/Gems/User/User.php 2012-04-08 15:05:02 UTC (rev 608) +++ trunk/library/classes/Gems/User/User.php 2012-04-08 16:27:31 UTC (rev 609) @@ -1343,8 +1343,13 @@ * @param mixed $return Zend_Controller_Request_Abstract, array of something that can be turned into one. * @return Gems_User_User */ - public function setSurveyReturn($return) + public function setSurveyReturn($return = null) { + if (null === $return) { + $this->_unsetVar('surveyReturn'); + return $this; + } + if ($return instanceof Zend_Controller_Request_Abstract) { $return = $return->getParams(); } elseif (! is_array($return)) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2012-04-26 09:08:05
|
Revision: 636 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=636&view=rev Author: matijsdejong Date: 2012-04-26 09:07:54 +0000 (Thu, 26 Apr 2012) Log Message: ----------- Fixes for attack pattern identified by Michiel Modified Paths: -------------- trunk/library/classes/Gems/Registry/CachedArrayTargetAbstract.php trunk/library/classes/Gems/User/Organization.php Modified: trunk/library/classes/Gems/Registry/CachedArrayTargetAbstract.php =================================================================== --- trunk/library/classes/Gems/Registry/CachedArrayTargetAbstract.php 2012-04-25 14:43:30 UTC (rev 635) +++ trunk/library/classes/Gems/Registry/CachedArrayTargetAbstract.php 2012-04-26 09:07:54 UTC (rev 636) @@ -102,7 +102,7 @@ * @return string */ private function _getCacheId() { - return GEMS_PROJECT_NAME . '__' . get_class($this) . '__' . $this->_id; + return GEMS_PROJECT_NAME . '__' . get_class($this) . '__' . preg_replace('/[^a-zA-Z0-9_]/', '_', $this->_id); } /** Modified: trunk/library/classes/Gems/User/Organization.php =================================================================== --- trunk/library/classes/Gems/User/Organization.php 2012-04-25 14:43:30 UTC (rev 635) +++ trunk/library/classes/Gems/User/Organization.php 2012-04-26 09:07:54 UTC (rev 636) @@ -285,7 +285,7 @@ { try { $sql = "SELECT * FROM gems__organizations WHERE gor_id_organization = ? LIMIT 1"; - $data = $this->db->fetchRow($sql, $id); + $data = $this->db->fetchRow($sql, intval($id)); } catch (Exception $e) { $data = false; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2012-04-26 15:44:22
|
Revision: 645 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=645&view=rev Author: matijsdejong Date: 2012-04-26 15:44:13 +0000 (Thu, 26 Apr 2012) Log Message: ----------- New support functions for TrackData.php Made the use of the round editor slightly simpler Modified Paths: -------------- trunk/library/classes/Gems/Tracker/Engine/StepEngineAbstract.php trunk/library/classes/Gems/Util/TrackData.php Modified: trunk/library/classes/Gems/Tracker/Engine/StepEngineAbstract.php =================================================================== --- trunk/library/classes/Gems/Tracker/Engine/StepEngineAbstract.php 2012-04-26 14:51:22 UTC (rev 644) +++ trunk/library/classes/Gems/Tracker/Engine/StepEngineAbstract.php 2012-04-26 15:44:13 UTC (rev 645) @@ -442,17 +442,17 @@ // Calculate valid from $model->set('valid_after', 'elementClass', 'html', 'label', ' ', 'value', MUTil_Html::create()->h4($this->_('Valid from calculation'))); - $model->set('grp_valid_after_source', 'label', $this->_('Date source'), 'default', self::TOKEN_TABLE, 'elementClass', 'Radio', 'escape', false, 'required', true); - $model->set('grp_valid_after_id', 'label', $this->_('Round used')); - $model->set('grp_valid_after_field', 'label', $this->_('Date used'), 'default', 'gto_valid_from'); + $model->set('grp_valid_after_source', 'label', $this->_('Date source'), 'default', self::TOKEN_TABLE, 'elementClass', 'Radio', 'escape', false, 'required', true, 'onchange', 'this.form.submit();'); + $model->set('grp_valid_after_id', 'label', $this->_('Round used'), 'onchange', 'this.form.submit();'); + $model->set('grp_valid_after_field', 'label', $this->_('Date used'), 'default', 'gto_valid_from', 'onchange', 'this.form.submit();'); $model->set('grp_valid_after_length', 'label', $this->_('Add to date'), 'required', false); $model->set('grp_valid_after_unit', 'label', $this->_('Add to date unit'), 'multiOptions', $this->getDateUnitsList(true)); // Calculate valid until $model->set('valid_for', 'elementClass', 'html', 'label', ' ', 'value', MUTil_Html::create()->h4($this->_('Valid for calculation'))); - $model->set('grp_valid_for_source', 'label', $this->_('Date source'), 'default', self::TOKEN_TABLE, 'elementClass', 'Radio', 'escape', false, 'required', true); - $model->set('grp_valid_for_id', 'label', $this->_('Round used'), 'default', ''); - $model->set('grp_valid_for_field', 'label', $this->_('Date used'), 'default', 'gto_valid_from'); + $model->set('grp_valid_for_source', 'label', $this->_('Date source'), 'default', self::TOKEN_TABLE, 'elementClass', 'Radio', 'escape', false, 'required', true, 'onchange', 'this.form.submit();'); + $model->set('grp_valid_for_id', 'label', $this->_('Round used'), 'default', '', 'onchange', 'this.form.submit();'); + $model->set('grp_valid_for_field', 'label', $this->_('Date used'), 'default', 'gto_valid_from', 'onchange', 'this.form.submit();'); $model->set('grp_valid_for_length', 'label', $this->_('Add to date'), 'required', false, 'default', 2); $model->set('grp_valid_for_unit', 'label', $this->_('Add to date unit'), 'multiOptions', $this->getDateUnitsList(false)); Modified: trunk/library/classes/Gems/Util/TrackData.php =================================================================== --- trunk/library/classes/Gems/Util/TrackData.php 2012-04-26 14:51:22 UTC (rev 644) +++ trunk/library/classes/Gems/Util/TrackData.php 2012-04-26 15:44:13 UTC (rev 645) @@ -97,6 +97,21 @@ /** + * Returns array (id => name) of all ronds in all tracks, sorted by order + * + * @return array + */ + public function getAllRounds() + { + static $rounds; + if (! $rounds) { + $rounds = $this->db->fetchPairs("SELECT gro_id_round, CONCAT(gro_id_order, ' - ', SUBSTR(gsu_survey_name, 1, 80)) AS name FROM gems__rounds INNER JOIN gems__surveys ON gro_id_survey = gsu_id_survey ORDER BY gro_id_order"); + } + + return $rounds; + } + + /** * Retrieve an array of key/value pairs for gsu_id_survey and gsu_survey_name * * @staticvar array $surveys @@ -124,13 +139,13 @@ static $surveys; if (! $surveys) { - $surveys = $this->db->fetchPairs('SELECT gsu_id_survey, + $surveys = $this->db->fetchPairs('SELECT gsu_id_survey, CONCAT( LEFT(CONCAT_WS( " - ", gsu_survey_name, CASE WHEN LENGTH(TRIM(gsu_survey_description)) = 0 THEN NULL ELSE gsu_survey_description END ), 50), CASE WHEN gsu_active = 1 THEN " (' . $this->translate->_('Active') . ')" ELSE " (' . $this->translate->_('Inactive') . ')" END - ) + ) FROM gems__surveys ORDER BY gsu_survey_name'); } @@ -151,4 +166,30 @@ return $tracks; } + + /** + * Returns array (id => name) of all ronds in a track, sorted by order + * + * @param int $trackId + * @return array + */ + public function getRoundsFor($trackId) + { + return $this->db->fetchPairs("SELECT gro_id_round, CONCAT(gro_id_order, ' - ', SUBSTR(gsu_survey_name, 1, 80)) AS name FROM gems__rounds INNER JOIN gems__surveys ON gro_id_survey = gsu_id_survey WHERE gro_id_track = ? ORDER BY gro_id_order", $trackId); + } + + /** + * Returns array (id => name) of all 'T' tracks, sorted alphabetically + * @return array + */ + public function getSteppedTracks() + { + static $tracks; + + if (! $tracks) { + $tracks = $this->db->fetchPairs("SELECT gtr_id_track, gtr_track_name FROM gems__tracks WHERE gtr_track_type = 'T' ORDER BY gtr_track_name"); + } + + return $tracks; + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2012-05-03 14:37:17
|
Revision: 660 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=660&view=rev Author: matijsdejong Date: 2012-05-03 14:37:07 +0000 (Thu, 03 May 2012) Log Message: ----------- Documented name of alternative loop snippet Content of fields with 'password' in name is no longer logged. Modified Paths: -------------- trunk/library/classes/Gems/Default/AskAction.php trunk/library/classes/Gems/Log.php Modified: trunk/library/classes/Gems/Default/AskAction.php =================================================================== --- trunk/library/classes/Gems/Default/AskAction.php 2012-05-03 14:30:08 UTC (rev 659) +++ trunk/library/classes/Gems/Default/AskAction.php 2012-05-03 14:37:07 UTC (rev 660) @@ -46,9 +46,13 @@ class Gems_Default_AskAction extends Gems_Controller_Action { /** + * Usually a child of Gems_Tracker_Snippets_ShowTokenLoopAbstract, + * Track_Token_ShowAllOpenSnippet or Track_Token_ShowFirstOpenSnippet or + * a project specific one. * * @var array Or string of snippet names, presumably Gems_Tracker_Snippets_ShowTokenLoopAbstract snippets */ + // protected $forwardSnippets = 'Track_Token_ShowAllOpenSnippet'; protected $forwardSnippets = 'Track_Token_ShowFirstOpenSnippet'; /** Modified: trunk/library/classes/Gems/Log.php =================================================================== --- trunk/library/classes/Gems/Log.php 2012-05-03 14:30:08 UTC (rev 659) +++ trunk/library/classes/Gems/Log.php 2012-05-03 14:37:07 UTC (rev 660) @@ -26,6 +26,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * + * * @version $Id$ * @package Gems * @subpackage Log @@ -110,7 +111,12 @@ if (!empty($request)) { $info[] = 'Request Parameters:'; foreach ($request->getParams() as $key => $value) { - $info[] = $key . ' => ' . $value; + // Make sure a password does not end in the logfile + if (false === strpos(strtolower($key), 'password')) { + $info[] = $key . ' => ' . $value; + } else { + $info[] = $key . ' => ' . str_repeat('*', strlen($value)); + } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2012-05-04 11:38:39
|
Revision: 668 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=668&view=rev Author: matijsdejong Date: 2012-05-04 11:38:33 +0000 (Fri, 04 May 2012) Log Message: ----------- Fix for #505 in Pulse bugtracker display order of answers corrected Showing anwsers no longer results in returning to that answer screen after answering a new survey. Modified Paths: -------------- trunk/library/classes/Gems/Default/TrackActionAbstract.php trunk/library/classes/Gems/Tracker/Snippets/AnswerModelSnippetGeneric.php Modified: trunk/library/classes/Gems/Default/TrackActionAbstract.php =================================================================== --- trunk/library/classes/Gems/Default/TrackActionAbstract.php 2012-05-04 11:36:04 UTC (rev 667) +++ trunk/library/classes/Gems/Default/TrackActionAbstract.php 2012-05-04 11:38:33 UTC (rev 668) @@ -365,8 +365,11 @@ { parent::init(); - // Tell the system where to return to after a survey has been taken - $this->loader->getCurrentUser()->setSurveyReturn($this->getRequest()); + $request = $this->getRequest(); + if ('answer' !== $request->getActionName()) { + // Tell the system where to return to after a survey has been taken + $this->loader->getCurrentUser()->setSurveyReturn($request); + } } public function initFilter() Modified: trunk/library/classes/Gems/Tracker/Snippets/AnswerModelSnippetGeneric.php =================================================================== --- trunk/library/classes/Gems/Tracker/Snippets/AnswerModelSnippetGeneric.php 2012-05-04 11:36:04 UTC (rev 667) +++ trunk/library/classes/Gems/Tracker/Snippets/AnswerModelSnippetGeneric.php 2012-05-04 11:38:33 UTC (rev 668) @@ -53,7 +53,7 @@ * * @var array */ - protected $_fixedSort = array('gto_valid_from' => SORT_ASC, 'gto_round_order' => SORT_ASC); + protected $_fixedSort = array('grc_success' => SORT_DESC, 'gto_round_order' => SORT_ASC, 'gto_valid_from' => SORT_ASC); /** * Shortfix to add class attribute This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2012-05-04 12:49:58
|
Revision: 670 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=670&view=rev Author: mennodekker Date: 2012-05-04 12:49:48 +0000 (Fri, 04 May 2012) Log Message: ----------- Speed up overview pages by only checking tokens for the organization we are working with also trying if we can move away form $tracker->processTokens Modified Paths: -------------- trunk/library/classes/Gems/Default/TokenPlanAction.php trunk/library/classes/Gems/Tracker/Token.php trunk/library/classes/Gems/Tracker.php Modified: trunk/library/classes/Gems/Default/TokenPlanAction.php =================================================================== --- trunk/library/classes/Gems/Default/TokenPlanAction.php 2012-05-04 11:51:42 UTC (rev 669) +++ trunk/library/classes/Gems/Default/TokenPlanAction.php 2012-05-04 12:49:48 UTC (rev 670) @@ -496,7 +496,10 @@ // MUtil_Model::$verbose = true; // Check for unprocessed tokens - $this->loader->getTracker()->processCompletedTokens(null, $this->session->user_id); + //$this->loader->getTracker()->processCompletedTokens(null, $this->session->user_id); + $filter = $this->getCachedRequestData(true); + $orgId = array_key_exists('gto_id_organization', $filter) ? $filter['gto_id_organization'] : null; + $this->loader->getTracker()->processCompletedTokensBatch(null, $this->session->user_id, $orgId); parent::indexAction(); } Modified: trunk/library/classes/Gems/Tracker/Token.php =================================================================== --- trunk/library/classes/Gems/Tracker/Token.php 2012-05-04 11:51:42 UTC (rev 669) +++ trunk/library/classes/Gems/Tracker/Token.php 2012-05-04 12:49:48 UTC (rev 670) @@ -219,7 +219,7 @@ } // Update values in this object - $this->_gemsData = $values + $this->_gemsData; + $this->_gemsData = $values + (array) $this->_gemsData; // return 1; return $this->db->update('gems__tokens', $values, array('gto_id_token = ?' => $this->_tokenId)); Modified: trunk/library/classes/Gems/Tracker.php =================================================================== --- trunk/library/classes/Gems/Tracker.php 2012-05-04 11:51:42 UTC (rev 669) +++ trunk/library/classes/Gems/Tracker.php 2012-05-04 12:49:48 UTC (rev 670) @@ -757,7 +757,9 @@ */ public function processCompletedTokens($respondentId, $userId = null) { - $userId = $this->_checkUserId($userId); + return $this->processCompletedTokensBatch($respondentId, $userId, null); + + /*$userId = $this->_checkUserId($userId); $tokenSelect = $this->getTokenSelect(true) ->onlyActive() ->forRespondent($respondentId) @@ -773,8 +775,45 @@ } return $changes->hasChanged(); + */ } + public function processCompletedTokensBatch($respondentId, $userId = null, $orgId = null) + { + $userId = $this->_checkUserId($userId); + $tokenSelect = $this->getTokenSelect(); + $tokenSelect->onlyActive() + ->forRespondent($respondentId) + ->andSurveys(array()) + ->forWhere('gsu_surveyor_active = 1'); + + if (!is_null($orgId)) { + $tokenSelect->forWhere('gto_id_organization = ?', $orgId); + } + + $batch = $this->loader->getTaskRunnerBatch('completed'); + + if (! $batch->isLoaded()) { + $statement = $tokenSelect->getSelect()->query(); + //Process one row at a time to prevent out of memory errors for really big resultsets + while ($tokenData = $statement->fetch()) { + $tokenId = $tokenData['gto_id_token']; + $batch->setTask('Tracker_CheckTokenCompletion', 'tokchk-' . $tokenId, $tokenData, $userId); + $batch->addToCounter('tokens'); + } + } + + $batch->runAll(); + if ($batch->getCounter('resultDataChanges') > 0 || $batch->getCounter('surveyCompletionChanges')>0) { + $changed = true; + } else { + $changed = false; + } + + $batch->reset(); + return $changed; + } + /** * Checks the token table to see if there are any answered surveys to be processed * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2012-05-07 12:53:52
|
Revision: 673 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=673&view=rev Author: mennodekker Date: 2012-05-07 11:51:02 +0000 (Mon, 07 May 2012) Log Message: ----------- Add Gems_Model_ModelAbstract, that runs init() method after registry requests have been answered. This allows cleanup of existing models and later on the createmodel method of controllers can be simplified as common information can be stored in the model Modified Paths: -------------- trunk/library/classes/Gems/Model/OrganizationModel.php trunk/library/classes/Gems/Model/StaffModel.php trunk/library/classes/Gems/Model.php Added Paths: ----------- trunk/library/classes/Gems/Model/ModelAbstract.php Added: trunk/library/classes/Gems/Model/ModelAbstract.php =================================================================== --- trunk/library/classes/Gems/Model/ModelAbstract.php (rev 0) +++ trunk/library/classes/Gems/Model/ModelAbstract.php 2012-05-07 11:51:02 UTC (rev 673) @@ -0,0 +1,111 @@ +<?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/OrganizationModel.php =================================================================== --- trunk/library/classes/Gems/Model/OrganizationModel.php 2012-05-07 09:27:28 UTC (rev 672) +++ trunk/library/classes/Gems/Model/OrganizationModel.php 2012-05-07 11:51:02 UTC (rev 673) @@ -45,7 +45,7 @@ * @license New BSD License * @since Class available since version 1.5 */ -class Gems_Model_OrganizationModel extends Gems_Model_JoinModel implements MUtil_Registry_TargetInterface +class Gems_Model_OrganizationModel extends Gems_Model_ModelAbstract { /** * @var Gems_Loader @@ -58,58 +58,6 @@ } /** - * 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() - { - return array_filter(array_keys(get_object_vars($this)), array($this, 'filterRequestNames')); - } - - /** * Save a single model item. * * Makes sure the password is saved too using the userclass Modified: trunk/library/classes/Gems/Model/StaffModel.php =================================================================== --- trunk/library/classes/Gems/Model/StaffModel.php 2012-05-07 09:27:28 UTC (rev 672) +++ trunk/library/classes/Gems/Model/StaffModel.php 2012-05-07 11:51:02 UTC (rev 673) @@ -45,7 +45,7 @@ * @license New BSD License * @since Class available since version 1.5 */ -class Gems_Model_StaffModel extends Gems_Model_JoinModel implements MUtil_Registry_TargetInterface +class Gems_Model_StaffModel extends Gems_Model_ModelAbstract { /** * @var Gems_Loader @@ -58,58 +58,6 @@ } /** - * 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() - { - return array_filter(array_keys(get_object_vars($this)), array($this, 'filterRequestNames')); - } - - /** * Save a single model item. * * Makes sure the password is saved too using the userclass Modified: trunk/library/classes/Gems/Model.php =================================================================== --- trunk/library/classes/Gems/Model.php 2012-05-07 09:27:28 UTC (rev 672) +++ trunk/library/classes/Gems/Model.php 2012-05-07 11:51:02 UTC (rev 673) @@ -96,6 +96,30 @@ protected $util; /** + * Create or loads the class. When only loading, this function returns a StaticCall object that + * can be invoked lazely. + * + * @see MUtil_Lazy_StaticCall + * @see MUtil_Registry_TargetInterface + * + * @param type $name + * @param type $create + * @param array $arguments + * @return Gems_Model_ModelAbstract + */ + protected function _loadClass($name, $create = false, array $arguments = array()) + { + $obj = parent::_loadClass($name, $create, $arguments); + + // If it as a Gems_Model_ModelAbstract, run the init method now + if ($obj instanceof Gems_Model_ModelAbstract) { + $obj->init(); + } + + return $obj; + } + + /** * Link the model to the user_logins table. * * @param Gems_Model_JoinModel $model @@ -111,6 +135,7 @@ * Link the model to the user_passwords table. * * @param Gems_Model_JoinModel $model + * @deprecated since version 1.5.4 */ public static function addUserPassword(Gems_Model_JoinModel $model) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2012-05-18 10:50:26
|
Revision: 687 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=687&view=rev Author: michieltcs Date: 2012-05-18 10:50:20 +0000 (Fri, 18 May 2012) Log Message: ----------- Round description is empty with single survey tracks, only show tracks with reception code OK Modified Paths: -------------- trunk/library/classes/Gems/Default/RespondentExportAction.php trunk/library/classes/Gems/Tracker/RespondentTrack.php Modified: trunk/library/classes/Gems/Default/RespondentExportAction.php =================================================================== --- trunk/library/classes/Gems/Default/RespondentExportAction.php 2012-05-18 10:29:26 UTC (rev 686) +++ trunk/library/classes/Gems/Default/RespondentExportAction.php 2012-05-18 10:50:20 UTC (rev 687) @@ -75,6 +75,8 @@ */ protected function _exportTrackTokens(Gems_Tracker_RespondentTrack $track) { + $engine = $track->getTrackEngine(); + $table = $this->html->table(array('class' => 'browser')); $table->th($this->_('Survey')) ->th($this->_('Round')) @@ -87,7 +89,7 @@ while ($token) { $table->tr()->td($token->getSurveyName()) - ->td($token->getRoundDescription()) + ->td(($engine->getTrackType() == 'T' ? $token->getRoundDescription() : $this->_('Single Survey'))) ->td(strtoupper($token->getTokenId())) ->td(($token->isCompleted() ? $this->_('Yes') : $this->_('No'))); @@ -110,6 +112,10 @@ */ protected function _exportTrack(Gems_Tracker_RespondentTrack $track) { + if ($track->getReceptionCode() != GemsEscort::RECEPTION_OK) { + return; + } + $trackModel = $this->loader->getTracker()->getRespondentTrackModel(); $trackModel->resetOrder(); $trackModel->set('gtr_track_name', 'label', $this->_('Track')); Modified: trunk/library/classes/Gems/Tracker/RespondentTrack.php =================================================================== --- trunk/library/classes/Gems/Tracker/RespondentTrack.php 2012-05-18 10:29:26 UTC (rev 686) +++ trunk/library/classes/Gems/Tracker/RespondentTrack.php 2012-05-18 10:50:20 UTC (rev 687) @@ -504,6 +504,11 @@ { return $this->_respTrackData['gr2t_id_organization']; } + + public function getReceptionCode() + { + return $this->_respTrackData['gr2t_reception_code']; + } /** * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2012-05-21 09:39:50
|
Revision: 695 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=695&view=rev Author: michieltcs Date: 2012-05-21 09:39:40 +0000 (Mon, 21 May 2012) Log Message: ----------- Correct some date formats Modified Paths: -------------- trunk/library/classes/Gems/Default/SurveyAction.php trunk/library/classes/Gems/Default/TrackAction.php trunk/library/classes/Gems/Default/TrackActionAbstract.php trunk/library/classes/Gems/Tracker/Snippets/EditTrackSnippetAbstract.php trunk/library/classes/Gems/Tracker/Snippets/ShowTrackUsageAbstract.php Modified: trunk/library/classes/Gems/Default/SurveyAction.php =================================================================== --- trunk/library/classes/Gems/Default/SurveyAction.php 2012-05-21 09:00:49 UTC (rev 694) +++ trunk/library/classes/Gems/Default/SurveyAction.php 2012-05-21 09:39:40 UTC (rev 695) @@ -190,9 +190,9 @@ //$model->resetOrder(); $model->set('gsu_survey_name', 'label', $this->_('Survey')); $model->set('ggp_name', 'label', $this->_('By'), 'elementClass', 'Exhibitor'); - $model->set('gtr_date_start', 'label', $this->_('From'), 'dateFormat', 'dd-MM-yyyy', 'tdClass', 'date', + $model->set('gtr_date_start', 'label', $this->_('From'), 'dateFormat', Gems_Tracker::DB_DATE_FORMAT, 'tdClass', 'date', 'formatFunction', $this->util->getTranslated()->formatDate); - $model->set('gtr_date_until', 'label', $this->_('Until'), 'dateFormat', 'dd-MM-yyyy', 'tdClass', 'date', + $model->set('gtr_date_until', 'label', $this->_('Until'), 'dateFormat', Gems_Tracker::DB_DATE_FORMAT, 'tdClass', 'date', 'formatFunction', $this->util->getTranslated()->formatDateNa); return $model; Modified: trunk/library/classes/Gems/Default/TrackAction.php =================================================================== --- trunk/library/classes/Gems/Default/TrackAction.php 2012-05-21 09:00:49 UTC (rev 694) +++ trunk/library/classes/Gems/Default/TrackAction.php 2012-05-21 09:39:40 UTC (rev 695) @@ -327,9 +327,9 @@ //$model->resetOrder(); $model->set('gtr_track_name', 'label', $this->_('Track')); $model->set('gtr_survey_rounds', 'label', $this->_('Survey #'), 'tdClass', 'centerAlign', 'thClass', 'centerAlign'); - $model->set('gtr_date_start', 'label', $this->_('From'), 'dateFormat', 'dd-MM-yyyy', + $model->set('gtr_date_start', 'label', $this->_('From'), 'dateFormat', Gems_Tracker::DB_DATE_FORMAT, 'formatFunction', $this->util->getTranslated()->formatDate); - $model->set('gtr_date_until', 'label', $this->_('Until'), 'dateFormat', 'dd-MM-yyyy', + $model->set('gtr_date_until', 'label', $this->_('Until'), 'dateFormat', Gems_Tracker::DB_DATE_FORMAT, 'formatFunction', $this->util->getTranslated()->formatDateNa); return $model; Modified: trunk/library/classes/Gems/Default/TrackActionAbstract.php =================================================================== --- trunk/library/classes/Gems/Default/TrackActionAbstract.php 2012-05-21 09:00:49 UTC (rev 694) +++ trunk/library/classes/Gems/Default/TrackActionAbstract.php 2012-05-21 09:39:40 UTC (rev 695) @@ -209,6 +209,7 @@ 'description', $this->_('Enter the particulars concerning the assignment to this respondent.')); $model->set('assigned_by', 'label', $this->_('Assigned by')); $model->set('gr2t_start_date', 'label', $this->_('Start'), + 'dateFormat', Gems_Tracker::DB_DATE_FORMAT, 'formatFunction', $this->util->getTranslated()->formatDate, 'default', MUtil_Date::format(new Zend_date(), 'dd-MM-yyyy')); $model->set('gr2t_reception_code'); Modified: trunk/library/classes/Gems/Tracker/Snippets/EditTrackSnippetAbstract.php =================================================================== --- trunk/library/classes/Gems/Tracker/Snippets/EditTrackSnippetAbstract.php 2012-05-21 09:00:49 UTC (rev 694) +++ trunk/library/classes/Gems/Tracker/Snippets/EditTrackSnippetAbstract.php 2012-05-21 09:39:40 UTC (rev 695) @@ -150,7 +150,7 @@ $model->set('gr2t_track_info', 'label', $this->_('Description')); $model->set('assigned_by', 'label', $this->_('Assigned by')); $model->set('gr2t_start_date', 'label', $this->_('Start'), - 'dateFormat', 'dd-MM-yyyy', + 'dateFormat', Gems_Tracker::DB_DATE_FORMAT, 'formatFunction', $this->loader->getUtil()->getTranslated()->formatDate, 'default', MUtil_Date::format(new Zend_date(), 'dd-MM-yyyy')); $model->set('gr2t_reception_code'); Modified: trunk/library/classes/Gems/Tracker/Snippets/ShowTrackUsageAbstract.php =================================================================== --- trunk/library/classes/Gems/Tracker/Snippets/ShowTrackUsageAbstract.php 2012-05-21 09:00:49 UTC (rev 694) +++ trunk/library/classes/Gems/Tracker/Snippets/ShowTrackUsageAbstract.php 2012-05-21 09:39:40 UTC (rev 695) @@ -149,7 +149,7 @@ 'description', $this->_('Enter the particulars concerning the assignment to this respondent.')); $model->set('assigned_by', 'label', $this->_('Assigned by')); $model->set('gr2t_start_date', 'label', $this->_('Start'), - 'dateFormat', 'dd-MM-yyyy', + 'dateFormat', Gems_Tracker::DB_DATE_FORMAT, 'formatFunction', $this->loader->getUtil()->getTranslated()->formatDate, 'default', MUtil_Date::format(new Zend_date(), 'dd-MM-yyyy')); $model->set('gr2t_reception_code'); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2012-05-31 09:17:27
|
Revision: 715 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=715&view=rev Author: michieltcs Date: 2012-05-31 09:17:16 +0000 (Thu, 31 May 2012) Log Message: ----------- Fix a few E_NOTICE issues Modified Paths: -------------- trunk/library/classes/Gems/Tracker/Survey.php trunk/library/classes/Gems/User/Form/OrganizationFormAbstract.php Modified: trunk/library/classes/Gems/Tracker/Survey.php =================================================================== --- trunk/library/classes/Gems/Tracker/Survey.php 2012-05-31 09:16:04 UTC (rev 714) +++ trunk/library/classes/Gems/Tracker/Survey.php 2012-05-31 09:17:16 UTC (rev 715) @@ -385,7 +385,7 @@ */ public function getSource() { - if (! $this->_source) { + if (! $this->_source && isset($this->_gemsSurvey['gsu_id_source'])) { $this->_source = $this->tracker->getSource($this->_gemsSurvey['gsu_id_source']); if (! $this->_source) { Modified: trunk/library/classes/Gems/User/Form/OrganizationFormAbstract.php =================================================================== --- trunk/library/classes/Gems/User/Form/OrganizationFormAbstract.php 2012-05-31 09:16:04 UTC (rev 714) +++ trunk/library/classes/Gems/User/Form/OrganizationFormAbstract.php 2012-05-31 09:17:16 UTC (rev 715) @@ -254,7 +254,8 @@ */ public function isValid($data, $disableTranslateValidators = null) { - $this->_user = $this->loader->getUser($data[$this->usernameFieldName], $data[$this->organizationFieldName]); + $this->_user = $this->loader->getUser($data[$this->usernameFieldName], + (isset($data[$this->organizationFieldName]) ? $data[$this->organizationFieldName] : '')); return parent::isValid($data, $disableTranslateValidators); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2012-05-31 13:36:59
|
Revision: 718 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=718&view=rev Author: mennodekker Date: 2012-05-31 13:36:48 +0000 (Thu, 31 May 2012) Log Message: ----------- Removed session from DbLookup Prevented setting primary group when editing a user with a group we can not set (not superadmin downgrades superadmin while editing) Made staff browse-edit a little more compact Modified Paths: -------------- trunk/library/classes/Gems/Default/StaffAction.php trunk/library/classes/Gems/Util/DbLookup.php Modified: trunk/library/classes/Gems/Default/StaffAction.php =================================================================== --- trunk/library/classes/Gems/Default/StaffAction.php 2012-05-31 12:22:35 UTC (rev 717) +++ trunk/library/classes/Gems/Default/StaffAction.php 2012-05-31 13:36:48 UTC (rev 718) @@ -69,9 +69,41 @@ if ($menuItem = $this->findAllowedMenuItem('show')) { $bridge->addItemLink($menuItem->toActionLinkLower($this->getRequest(), $bridge)); } + + $br = MUtil_Html::create('br'); + $orgCount = count($model->get('gsf_id_organization', 'multiOptions')); foreach($model->getItemsOrdered() as $name) { if ($label = $model->get($name, 'label')) { - $bridge->addSortable($name, $label); + switch ($name) { + case 'name': + if ($orgCount > 1) { + $bridge->addMultiSort('name', $br, 'gsf_email'); + } else { + $bridge->addSortable($name, $label); + } + + break; + + case 'gsf_email': + if ($orgCount > 1) { + //Do nothing as it is already linked in the 'name' field + } else { + $bridge->addSortable($name, $label); + } + break; + + case 'gsf_id_organization': + if ($orgCount > 1) { + $bridge->addSortable($name, $label); + } else { + //Don't show as it is always the same + } + break; + + default: + $bridge->addSortable($name, $label); + break; + } } } // Add edit button if allowed, otherwise show, again if allowed @@ -102,9 +134,16 @@ $user = $this->loader->getUserLoader()->getUserByStaffId($data['gsf_id_user']); // MUtil_Echo::track($data['gsf_id_user'], $user->getLoginName()); } - $dbLookup = $this->util->getDbLookup(); - $model->set('gsf_id_primary_group', 'multiOptions', MUtil_Lazy::call($dbLookup->getAllowedStaffGroups)); + // Find out if this group is in the inheritance path of the current user + $allowedGroups = $this->util->getDbLookup()->getAllowedStaffGroups(); + if (!array_key_exists($data['gsf_id_primary_group'], $allowedGroups)) { + //Not allowed to update + $model->set('gsf_id_primary_group', 'elementClass', 'Exhibitor'); + } else { + //Allow only certain groups + $model->set('gsf_id_primary_group', 'multiOptions', $allowedGroups); + } if ($new) { $model->set('gsf_id_primary_group', 'default', $dbLookup->getDefaultGroup()); } @@ -150,7 +189,7 @@ $bridge->addFilter( 'gsf_last_name', $ucfirst); $bridge->addText( 'gsf_email', array('size' => 30))->addValidator('SimpleEmail'); - $bridge->addSelect('gsf_id_primary_group'); + $bridge->add('gsf_id_primary_group'); $bridge->addCheckbox('gul_can_login', 'description', $this->_('Users can only login when this box is checked.')); $bridge->addCheckbox('gsf_logout_on_survey', 'description', $this->_('If checked the user will logoff when answering a survey.')); Modified: trunk/library/classes/Gems/Util/DbLookup.php =================================================================== --- trunk/library/classes/Gems/Util/DbLookup.php 2012-05-31 12:22:35 UTC (rev 717) +++ trunk/library/classes/Gems/Util/DbLookup.php 2012-05-31 13:36:48 UTC (rev 718) @@ -70,12 +70,6 @@ protected $util; /** - * - * @var Zend_Session - */ - protected $session; - - /** * Retrieve a list of orgid/name pairs * * @staticvar array $organizations @@ -148,11 +142,12 @@ public function getAllowedStaffGroups() { $groups = $this->getActiveStaffGroups(); - if ($this->session->user_role === 'master') { + $user = GemsEscort::getInstance()->getLoader()->getCurrentUser(); + if ($user->getRole() === 'master') { return $groups; } else { - $rolesAllowed = $this->acl->getRoleAndParents($this->session->user_role); + $rolesAllowed = $user->getRoles(); $roles = $this->db->fetchPairs('SELECT ggp_id_group, ggp_role FROM gems__groups WHERE ggp_group_active=1 AND ggp_staff_members=1 ORDER BY ggp_name'); $result = array(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2012-06-07 14:32:19
|
Revision: 746 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=746&view=rev Author: mennodekker Date: 2012-06-07 14:32:08 +0000 (Thu, 07 Jun 2012) Log Message: ----------- cleanup debug code Modified Paths: -------------- trunk/library/classes/Gems/Controller/BrowseEditAction.php trunk/library/classes/Gems/Default/StaffAction.php Modified: trunk/library/classes/Gems/Controller/BrowseEditAction.php =================================================================== --- trunk/library/classes/Gems/Controller/BrowseEditAction.php 2012-06-07 14:04:22 UTC (rev 745) +++ trunk/library/classes/Gems/Controller/BrowseEditAction.php 2012-06-07 14:32:08 UTC (rev 746) @@ -939,7 +939,7 @@ } //MUtil_Echo::r($data, 'after process'); - if ($this->afterSaveRoute($data, $isNew)) { + if ($this->afterSaveRoute($data)) { return null; } } Modified: trunk/library/classes/Gems/Default/StaffAction.php =================================================================== --- trunk/library/classes/Gems/Default/StaffAction.php 2012-06-07 14:04:22 UTC (rev 745) +++ trunk/library/classes/Gems/Default/StaffAction.php 2012-06-07 14:32:08 UTC (rev 746) @@ -369,7 +369,7 @@ if (! $this->_user) { $this->_user = $this->loader->getUser($data['gul_login'], $data['gul_id_organization']); } - MUtil_Echo::track($this->_user->canSetPassword()); + //MUtil_Echo::track($this->_user->canSetPassword()); if ($this->_user->canSetPassword()) { if ($currentItem = $this->menu->getCurrent()) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2012-06-14 16:10:25
|
Revision: 765 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=765&view=rev Author: matijsdejong Date: 2012-06-14 16:10:18 +0000 (Thu, 14 Jun 2012) Log Message: ----------- First attempt to get menu working with multi org. Is promising. Modified Paths: -------------- trunk/library/classes/Gems/Menu/SubMenuItem.php trunk/library/classes/Gems/Menu.php Modified: trunk/library/classes/Gems/Menu/SubMenuItem.php =================================================================== --- trunk/library/classes/Gems/Menu/SubMenuItem.php 2012-06-14 15:30:38 UTC (rev 764) +++ trunk/library/classes/Gems/Menu/SubMenuItem.php 2012-06-14 16:10:18 UTC (rev 765) @@ -154,12 +154,10 @@ foreach ($this->_parameters as $param => $name) { $parameters[$param] = $source->getMenuParameter($name, $param); if (Gems_Menu::$verbose) { - MUtil_Echo::r($param . '/' . $name . ' => ' . $parameters[$param], $this->get('label')); + MUtil_Echo::r($param . '/' . $name . ' => ' . $parameters[$param], $this->get('label')); } } } - - return false; } private function _applyParameterSources(Gems_Menu_ParameterCollector $source, array &$parameters, $raiseConditions) Modified: trunk/library/classes/Gems/Menu.php =================================================================== --- trunk/library/classes/Gems/Menu.php 2012-06-14 15:30:38 UTC (rev 764) +++ trunk/library/classes/Gems/Menu.php 2012-06-14 16:10:18 UTC (rev 765) @@ -262,11 +262,14 @@ public function addRespondentPage($label) { + $params = array(MUtil_Model::REQUEST_ID => 'gr2o_patient_nr'); + // $params = array(MUtil_Model::REQUEST_ID . '1' => 'gr2o_patient_nr', MUtil_Model::REQUEST_ID . '2' => 'gr2o_id_organization'); + // MAIN RESPONDENTS ITEM $page = $this->addPage($label, 'pr.respondent', 'respondent'); $page->addAutofilterAction(); $page->addCreateAction('pr.respondent.create')->setParameterFilter('can_add_respondents', true);; - $page->addShowAction()->addNamedParameters(MUtil_Model::REQUEST_ID, 'gr2o_patient_nr'); + $page->addShowAction()->setNamedParameters($params); /* iff( @@ -276,14 +279,14 @@ ); */ - $page->addEditAction('pr.respondent.edit')->addNamedParameters(MUtil_Model::REQUEST_ID, 'gr2o_patient_nr'); - $page->addAction($this->_('Export'), 'pr.respondent.export-html', 'export')->addNamedParameters(MUtil_Model::REQUEST_ID, 'gr2o_patient_nr'); + $page->addEditAction('pr.respondent.edit')->setNamedParameters($params); + $page->addAction($this->_('Export'), 'pr.respondent.export-html', 'export')->setNamedParameters($params); if ($this->escort instanceof Gems_Project_Tracks_SingleTrackInterface) { $trType = 'T'; $subPage = $page->addPage($this->_('Track'), 'pr.track', 'track', 'show-track') - ->addNamedParameters(MUtil_Model::REQUEST_ID, 'gr2o_patient_nr') + ->setNamedParameters($params) ->addHiddenParameter(Gems_Model::TRACK_ID, $this->escort->getTrackId(), 'gtr_track_type', $trType); $tkPages[$trType] = $subPage->addAction($this->_('Token'), 'pr.token', 'show') @@ -384,7 +387,7 @@ ->set('target', MUtil_Model::REQUEST_ID); } - $page->addDeleteAction('pr.respondent.delete')->addNamedParameters(MUtil_Model::REQUEST_ID, 'gr2o_patient_nr'); + $page->addDeleteAction('pr.respondent.delete')->setNamedParameters($params); return $page; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2012-06-15 10:30:31
|
Revision: 767 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=767&view=rev Author: mennodekker Date: 2012-06-15 10:30:24 +0000 (Fri, 15 Jun 2012) Log Message: ----------- Load snippets via Gems_Loader, allowing prefixed snippets. Added some backward compatibility to loader: no prefix with multiple dirs is handled fine now. The backup to defer to the Mutil_Snippets_SnippetLoader will throw an error but that should not happen. Modified Paths: -------------- trunk/library/classes/Gems/Controller/Action.php trunk/library/classes/Gems/Controller/ModelActionAbstract.php trunk/library/classes/Gems/Controller/ModelSnippetActionAbstract.php trunk/library/classes/Gems/Loader/LoaderAbstract.php trunk/library/classes/Gems/Loader.php Added Paths: ----------- trunk/library/classes/Gems/Snippets/SnippetLoader.php Modified: trunk/library/classes/Gems/Controller/Action.php =================================================================== --- trunk/library/classes/Gems/Controller/Action.php 2012-06-15 07:47:40 UTC (rev 766) +++ trunk/library/classes/Gems/Controller/Action.php 2012-06-15 10:30:24 UTC (rev 767) @@ -1,34 +1,34 @@ <?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. - */ - + /** + * 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. + */ + +/** * File descr * * @author Matijs de Jong <mj...@ma...> @@ -79,4 +79,13 @@ parent::initHtml(); } + + /** + * Stub for overruling default snippet loader initiation. + */ + protected function loadSnippetLoader() + { + // Create the snippet with this controller as the parameter source + $this->snippetLoader = $this->loader->getSnippetLoader($this); + } } \ No newline at end of file Modified: trunk/library/classes/Gems/Controller/ModelActionAbstract.php =================================================================== --- trunk/library/classes/Gems/Controller/ModelActionAbstract.php 2012-06-15 07:47:40 UTC (rev 766) +++ trunk/library/classes/Gems/Controller/ModelActionAbstract.php 2012-06-15 10:30:24 UTC (rev 767) @@ -218,4 +218,13 @@ parent::initHtml($reset); } + + /** + * Stub for overruling default snippet loader initiation. + */ + protected function loadSnippetLoader() + { + // Create the snippet with this controller as the parameter source + $this->snippetLoader = $this->loader->getSnippetLoader($this); + } } Modified: trunk/library/classes/Gems/Controller/ModelSnippetActionAbstract.php =================================================================== --- trunk/library/classes/Gems/Controller/ModelSnippetActionAbstract.php 2012-06-15 07:47:40 UTC (rev 766) +++ trunk/library/classes/Gems/Controller/ModelSnippetActionAbstract.php 2012-06-15 10:30:24 UTC (rev 767) @@ -406,6 +406,15 @@ } /** + * Stub for overruling default snippet loader initiation. + */ + protected function loadSnippetLoader() + { + // Create the snippet with this controller as the parameter source + $this->snippetLoader = $this->loader->getSnippetLoader($this); + } + + /** * Action for showing an item page with title */ public function showAction() Modified: trunk/library/classes/Gems/Loader/LoaderAbstract.php =================================================================== --- trunk/library/classes/Gems/Loader/LoaderAbstract.php 2012-06-15 07:47:40 UTC (rev 766) +++ trunk/library/classes/Gems/Loader/LoaderAbstract.php 2012-06-15 10:30:24 UTC (rev 767) @@ -73,7 +73,7 @@ * * @var array Of prefix => path strings for class lookup */ - private $_dirs; + protected $_dirs; /** * This array holds a cache of requested class -> resulting classname pairs so we don't have @@ -159,7 +159,7 @@ { // echo $name . ($create ? ' create' : ' not created') . "<br/>\n"; - $cname = '_' . trim(str_replace('/', '_', ucfirst($name)), '_'); + $cname = trim(str_replace('/', '_', ucfirst($name)), '_'); $cfile = str_replace('_', '/', $cname) . '.php'; $found = false; @@ -173,13 +173,24 @@ } if (!$found) { - foreach ($this->_dirs as $prefix => $path) { - $fprefix = str_replace('_', '/', $prefix); - if ($obj = $this->_loadClassPath($path . '/' . $fprefix . $cfile, $prefix . $cname, $create, $arguments)) { - $found = true; - $this->_loaded[$cname] = get_class($obj); - break; + foreach ($this->_dirs as $prefix => $paths) { + if (!empty($prefix)) { + $fprefix = '/' . str_replace('_', '/', $prefix); + $prefix .= '_'; + } else { + $fprefix = ''; } + + if (!is_array($paths)) { + $paths = array($paths); + } + foreach ($paths as $path) { + if ($obj = $this->_loadClassPath($path . $fprefix . '/' . $cfile, $prefix . $cname, $create, $arguments)) { + $found = true; + $this->_loaded[$cname] = get_class($obj); + break 2; + } + } } } @@ -192,7 +203,9 @@ return $obj; } - //print_r($this->_dirs); + + // Throw exception when not found + throw new Gems_Exception_Coding(__CLASS__ . '->' . __FUNCTION__ . ' cannot find class with name ' .$name . ' in ' . print_r($this->_dirs, true)); } /** Modified: trunk/library/classes/Gems/Loader.php =================================================================== --- trunk/library/classes/Gems/Loader.php 2012-06-15 07:47:40 UTC (rev 766) +++ trunk/library/classes/Gems/Loader.php 2012-06-15 10:30:24 UTC (rev 767) @@ -83,6 +83,12 @@ /** * + * @var Gems_Snippets_SnippetLoader + */ + protected $snippetLoader; + + /** + * * @var Gems_Tracker */ protected $tracker; @@ -202,6 +208,19 @@ } /** + * + * @return Gems_Snippets_SnippetLoader + */ + public function getSnippetLoader($container) + { + $class = $this->_getClass('snippetLoader', 'Snippets_SnippetLoader'); + + //now add the calling class as a container + $class->addRegistryContainer($container); + return $class; + } + + /** * * @return Gems_Task_TaskAbstract */ Added: trunk/library/classes/Gems/Snippets/SnippetLoader.php =================================================================== --- trunk/library/classes/Gems/Snippets/SnippetLoader.php (rev 0) +++ trunk/library/classes/Gems/Snippets/SnippetLoader.php 2012-06-15 10:30:24 UTC (rev 767) @@ -0,0 +1,117 @@ +<?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 SnippetLoader + * + * Long description for class SnippetLoader (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_Snippets_SnippetLoader extends Gems_Loader_TargetLoaderAbstract implements MUtil_Snippets_SnippetLoaderInterface +{ + protected $cascade = 'Snippets'; + + protected $loader; + + /** + * @var MUtil_Snippets_SnippetLoader + */ + protected $backup; + + public function __construct($container = null, $dirs = array()) { + parent::__construct($container, $dirs); + $this->backup = new MUtil_Snippets_SnippetLoader($this); + } + + + public function addDirectory($dir) + { + if (!array_key_exists('', $this->_dirs)) { + $this->_dirs[''] = array(); + } + array_unshift($this->_dirs[''], $dir); + + $this->backup->addDirectory($dir); + } + + public function addSource($container_or_pairs) + { + $this->backup->addSource($container_or_pairs); + } + + public function getDirectories() + { + $this->backup->getDirectories(); + } + + public function getSnippet($filename, array $extraSourceParameters = null) + { + try { + $this->addRegistryContainer($extraSourceParameters, 'tmpContainer'); + $snippet = $this->_loadClass($filename, true); + $this->removeRegistryContainer('tmpContainer'); + } catch (Exception $exc) { + MUtil_Echo::track($exc->getMessage()); + throwException($exc); + //Class loading failed, now defer + //$snippet = $this->backup->getSnippet($filename, $extraSourceParameters); + } + + return $snippet; + } + + public function getSource() + { + $this->backup->getSource(); + } + + public function setDirectories(array $dirs) + { + $this->backup->setDirectories($dirs); + } + + public function setSource(MUtil_Registry_SourceInterface $source) + { + $this->backup->setSource($source); + } +} \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2012-06-15 11:42:31
|
Revision: 768 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=768&view=rev Author: mennodekker Date: 2012-06-15 11:42:19 +0000 (Fri, 15 Jun 2012) Log Message: ----------- Moved some of the RespondentExportAction output to snippets so project can change it. Added getStatus to token to allow projects to have other status info than open, completed, future and missed Modified Paths: -------------- trunk/library/classes/Gems/Default/RespondentExportAction.php trunk/library/classes/Gems/Tracker/Token.php Added Paths: ----------- trunk/library/classes/Gems/Snippets/Export/ trunk/library/classes/Gems/Snippets/Export/ReportFooter.php trunk/library/classes/Gems/Snippets/Export/ReportHeader.php trunk/library/classes/Gems/Snippets/Export/RespondentSnippet.php Modified: trunk/library/classes/Gems/Default/RespondentExportAction.php =================================================================== --- trunk/library/classes/Gems/Default/RespondentExportAction.php 2012-06-15 10:30:24 UTC (rev 767) +++ trunk/library/classes/Gems/Default/RespondentExportAction.php 2012-06-15 11:42:19 UTC (rev 768) @@ -48,6 +48,10 @@ protected $_wkhtmltopdfLocation = ""; + protected $_reportFooter = 'Export_ReportFooter'; + protected $_reportHeader = 'Export_ReportHeader'; + protected $_respondentSnippet = 'Export_RespondentSnippet'; + protected $_groupedSurveySnippet = 'TrackAnswersModelSnippet'; protected $_singleSurveySnippet = 'AnswerModelSnippet'; @@ -161,7 +165,6 @@ $groupSurveys = $this->getRequest()->getParam('group'); $token = $track->getFirstToken(); $engine = $track->getTrackEngine(); - $today = new Zend_Date(); $surveys = array(); $table = $this->html->table(array('class' => 'browser')); @@ -172,33 +175,18 @@ $this->html->br(); while ($token) { + //Should this token be in the list? if (!$this->_isTokenInFilter($token)) { $token = $token->getNextToken(); continue; } - - $status = $this->_('Open'); - - if ($token->isCompleted()) { - $status = $this->_('Completed'); - } else { - $validFrom = $token->getValidFrom(); - $validUntil = $token->getValidUntil(); - - if (!empty($validUntil) && $validUntil->isEarlier($today)) { - $status = $this->_('Missed'); - } else if (!empty($validFrom) && $validFrom->isLater($today)) { - $status = $this->_('Future'); - } else if (empty($validFrom) && empty($validUntil)) { - $status = $this->_('Future'); - } - } - + $table->tr()->td($token->getSurveyName()) ->td(($engine->getTrackType() == 'T' ? $token->getRoundDescription() : $this->_('Single Survey'))) ->td(strtoupper($token->getTokenId())) - ->td($status); - + ->td($token->getStatus()); + + //Should we display the answers? if (!$token->isCompleted()) { $token = $token->getNextToken(); continue; @@ -291,26 +279,12 @@ $respondentModel = $this->loader->getModels()->getRespondentModel(false); $respondentModel->setFilter(array('gr2o_patient_nr' => $respondentId)); $respondentData = $respondentModel->loadFirst(); + + $this->addSnippet($this->_respondentSnippet, + 'model', $respondentModel, + 'data', $respondentData, + 'respondentId', $respondentId); - if (empty($respondentData)) { - $this->html->p()->b(sprintf($this->_('Unknown respondent %s'), $respondentId)); - return; - } - - $bridge = new MUtil_Model_VerticalTableBridge($respondentModel, array('class' => 'browser')); - $bridge->setRepeater(MUtil_Lazy::repeat(array($respondentData))); - $bridge->th($this->_('Respondent information'), array('colspan' => 4)); - $bridge->setColumnCount(2); - foreach($respondentModel->getItemsOrdered() as $name) { - if ($label = $respondentModel->get($name, 'label')) { - $bridge->addItem($name, $label); - } - } - - $this->html->h2($this->_('Respondent information') . ': ' . $respondentId); - $this->html[] = $bridge->getTable(); - $this->html->hr(); - $tracker = $this->loader->getTracker(); $tracks = $tracker->getRespondentTracks($respondentData['gr2o_id_user'], $respondentData['gr2o_id_organization']); @@ -327,25 +301,22 @@ protected function _render($respondents) { $this->html = new MUtil_Html_Sequence(); - $this->html->h1($this->_('Respondent report')); - - $table = $this->html->table(array('class' => 'browser')); - - $table->th($this->_('Report information'), array('colspan' => 2)); - $table->tr()->th($this->_('Generated by')) - ->td($this->loader->getCurrentUser()->getFullName()); - $table->tr()->th($this->_('Generated on')) - ->td(new Zend_Date()); - $table->tr()->th($this->_('Organization')) - ->td($this->loader->getCurrentUser()->getCurrentOrganization()->getName()); - - $this->html->br(); - + + $this->addSnippet($this->_reportHeader); + + $respondentCount = count($respondents); + $respondentIdx = 0; foreach ($respondents as $respondentId) { + $respondentIdx++; $this->_exportRespondent($respondentId); - - $this->html->div('', array('style' => 'height: 100px')); + + if ($respondentIdx < $respondentCount) { + // Add some whitespace between patients + $this->html->div('', array('style' => 'height: 100px')); + } } + + $this->addSnippet($this->_reportFooter, 'respondents', $respondents); $this->escort->menu->setVisible(false); if ($this->escort instanceof Gems_Project_Layout_MultiLayoutInterface) { Added: trunk/library/classes/Gems/Snippets/Export/ReportFooter.php =================================================================== --- trunk/library/classes/Gems/Snippets/Export/ReportFooter.php (rev 0) +++ trunk/library/classes/Gems/Snippets/Export/ReportFooter.php 2012-06-15 11:42:19 UTC (rev 768) @@ -0,0 +1,60 @@ +<?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. + * + * @package Gems + * @subpackage Snippets + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @version $Id: Sample.php 215 2011-07-12 08:52:54Z michiel $ + */ + +/** + * Footer for html/pdf export of a respondent + * + * @package Gems + * @subpackage Snippets + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @since Class available since version 1.5.5 + */ +class Gems_Snippets_Export_ReportFooter extends MUtil_Snippets_SnippetAbstract +{ + /** + * @var Gems_Loader + */ + public $loader; + + public function getHtmlOutput(Zend_View_Abstract $view) + { + $html = $this->getHtmlSequence(); + + $html->div($this->_('Report generation finished.'), array('class'=> 'centerAlign')); + $html->hr(); + + return $html; + } +} \ No newline at end of file Added: trunk/library/classes/Gems/Snippets/Export/ReportHeader.php =================================================================== --- trunk/library/classes/Gems/Snippets/Export/ReportHeader.php (rev 0) +++ trunk/library/classes/Gems/Snippets/Export/ReportHeader.php 2012-06-15 11:42:19 UTC (rev 768) @@ -0,0 +1,70 @@ +<?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. + * + * @package Gems + * @subpackage Snippets + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @version $Id: Sample.php 215 2011-07-12 08:52:54Z michiel $ + */ + +/** + * Header for html/pdf export of a respondent + * + * @package Gems + * @subpackage Snippets + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @since Class available since version 1.5.5 + */ +class Gems_Snippets_Export_ReportHeader extends MUtil_Snippets_SnippetAbstract +{ + /** + * @var Gems_Loader + */ + public $loader; + + public function getHtmlOutput(Zend_View_Abstract $view) + { + $html = $this->getHtmlSequence(); + $html->h1($this->_('Respondent report')); + + $table = $html->table(array('class' => 'browser')); + + $table->th($this->_('Report information'), array('colspan' => 2)); + $table->tr()->th($this->_('Generated by')) + ->td($this->loader->getCurrentUser()->getFullName()); + $table->tr()->th($this->_('Generated on')) + ->td(new Zend_Date()); + $table->tr()->th($this->_('Organization')) + ->td($this->loader->getCurrentUser()->getCurrentOrganization()->getName()); + + $html->br(); + + return $html; + } +} \ No newline at end of file Added: trunk/library/classes/Gems/Snippets/Export/RespondentSnippet.php =================================================================== --- trunk/library/classes/Gems/Snippets/Export/RespondentSnippet.php (rev 0) +++ trunk/library/classes/Gems/Snippets/Export/RespondentSnippet.php 2012-06-15 11:42:19 UTC (rev 768) @@ -0,0 +1,96 @@ +<?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. + * + * @package Gems + * @subpackage Snippets + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @version $Id: Sample.php 215 2011-07-12 08:52:54Z michiel $ + */ + +/** + * Show info about the respondent during html/pdf export + * + * @package Gems + * @subpackage Snippets + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @since Class available since version 1.5.5 + */ +class Gems_Snippets_Export_RespondentSnippet extends MUtil_Snippets_SnippetAbstract +{ + /** + * The data for the current respondentId + * + * @var array + */ + public $data; + + /** + * @var Gems_Model_RespondentModel + */ + public $model; + + /** + * The respondent we are looking at + * + * @var int + */ + public $respondentId; + + public function getHtmlOutput(Zend_View_Abstract $view) + { + parent::getHtmlOutput($view); + + $respondentModel = $this->model; + $respondentData = $this->data; + $respondentId = $this->respondentId; + + $html = $this->getHtmlSequence(); + if (empty($this->data)) { + $html->p()->b(sprintf($this->_('Unknown respondent %s'), $respondentId)); + return $html; + } + + $bridge = new MUtil_Model_VerticalTableBridge($respondentModel, array('class' => 'browser')); + $bridge->setRepeater(MUtil_Lazy::repeat(array($respondentData))); + $bridge->th($this->_('Respondent information'), array('colspan' => 4)); + $bridge->setColumnCount(2); + foreach($respondentModel->getItemsOrdered() as $name) { + if ($label = $respondentModel->get($name, 'label')) { + $bridge->addItem($name, $label); + } + } + + $html->h2($this->_('Respondent information') . ': ' . $respondentId); + $html[] = $bridge->getTable(); + $html->hr(); + + return $html; + } + +} \ No newline at end of file Modified: trunk/library/classes/Gems/Tracker/Token.php =================================================================== --- trunk/library/classes/Gems/Tracker/Token.php 2012-06-15 10:30:24 UTC (rev 767) +++ trunk/library/classes/Gems/Tracker/Token.php 2012-06-15 11:42:19 UTC (rev 768) @@ -125,6 +125,12 @@ /** * + * @var Zend_Translate_Adapter + */ + public $translate; + + /** + * * @var Gems_Util */ protected $util; @@ -936,6 +942,34 @@ } /** + * Returns a string that tells if the token is open, completed or any other + * status you might like. This will not be interpreted by the tracker it is + * for display purposes only + */ + public function getStatus() + { + $today = new Zend_Date(); + $status = $this->translate->_('Open'); + + if ($this->isCompleted()) { + $status = $this->translate->_('Completed'); + } else { + $validFrom = $this->getValidFrom(); + $validUntil = $this->getValidUntil(); + + if (!empty($validUntil) && $validUntil->isEarlier($today)) { + $status = $this->translate->_('Missed'); + } else if (!empty($validFrom) && $validFrom->isLater($today)) { + $status = $this->translate->_('Future'); + } else if (empty($validFrom) && empty($validUntil)) { + $status = $this->translate->_('Future'); + } + } + + return $status; + } + + /** * * @return Gems_Tracker_Survey */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2012-06-15 11:47:44
|
Revision: 769 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=769&view=rev Author: mennodekker Date: 2012-06-15 11:47:36 +0000 (Fri, 15 Jun 2012) Log Message: ----------- Add 'Snippet' to the names Modified Paths: -------------- trunk/library/classes/Gems/Default/RespondentExportAction.php Added Paths: ----------- trunk/library/classes/Gems/Snippets/Export/ReportFooterSnippet.php trunk/library/classes/Gems/Snippets/Export/ReportHeaderSnippet.php Removed Paths: ------------- trunk/library/classes/Gems/Snippets/Export/ReportFooter.php trunk/library/classes/Gems/Snippets/Export/ReportHeader.php Modified: trunk/library/classes/Gems/Default/RespondentExportAction.php =================================================================== --- trunk/library/classes/Gems/Default/RespondentExportAction.php 2012-06-15 11:42:19 UTC (rev 768) +++ trunk/library/classes/Gems/Default/RespondentExportAction.php 2012-06-15 11:47:36 UTC (rev 769) @@ -48,8 +48,8 @@ protected $_wkhtmltopdfLocation = ""; - protected $_reportFooter = 'Export_ReportFooter'; - protected $_reportHeader = 'Export_ReportHeader'; + protected $_reportFooter = 'Export_ReportFooterSnippet'; + protected $_reportHeader = 'Export_ReportHeaderSnippet'; protected $_respondentSnippet = 'Export_RespondentSnippet'; protected $_groupedSurveySnippet = 'TrackAnswersModelSnippet'; Deleted: trunk/library/classes/Gems/Snippets/Export/ReportFooter.php =================================================================== --- trunk/library/classes/Gems/Snippets/Export/ReportFooter.php 2012-06-15 11:42:19 UTC (rev 768) +++ trunk/library/classes/Gems/Snippets/Export/ReportFooter.php 2012-06-15 11:47:36 UTC (rev 769) @@ -1,60 +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. - * - * @package Gems - * @subpackage Snippets - * @copyright Copyright (c) 2011 Erasmus MC - * @license New BSD License - * @version $Id: Sample.php 215 2011-07-12 08:52:54Z michiel $ - */ - -/** - * Footer for html/pdf export of a respondent - * - * @package Gems - * @subpackage Snippets - * @copyright Copyright (c) 2011 Erasmus MC - * @license New BSD License - * @since Class available since version 1.5.5 - */ -class Gems_Snippets_Export_ReportFooter extends MUtil_Snippets_SnippetAbstract -{ - /** - * @var Gems_Loader - */ - public $loader; - - public function getHtmlOutput(Zend_View_Abstract $view) - { - $html = $this->getHtmlSequence(); - - $html->div($this->_('Report generation finished.'), array('class'=> 'centerAlign')); - $html->hr(); - - return $html; - } -} \ No newline at end of file Copied: trunk/library/classes/Gems/Snippets/Export/ReportFooterSnippet.php (from rev 768, trunk/library/classes/Gems/Snippets/Export/ReportFooter.php) =================================================================== --- trunk/library/classes/Gems/Snippets/Export/ReportFooterSnippet.php (rev 0) +++ trunk/library/classes/Gems/Snippets/Export/ReportFooterSnippet.php 2012-06-15 11:47:36 UTC (rev 769) @@ -0,0 +1,60 @@ +<?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. + * + * @package Gems + * @subpackage Snippets + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @version $Id: Sample.php 215 2011-07-12 08:52:54Z michiel $ + */ + +/** + * Footer for html/pdf export of a respondent + * + * @package Gems + * @subpackage Snippets + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @since Class available since version 1.5.5 + */ +class Gems_Snippets_Export_ReportFooterSnippet extends MUtil_Snippets_SnippetAbstract +{ + /** + * @var Gems_Loader + */ + public $loader; + + public function getHtmlOutput(Zend_View_Abstract $view) + { + $html = $this->getHtmlSequence(); + + $html->div($this->_('Report generation finished.'), array('class'=> 'centerAlign')); + $html->hr(); + + return $html; + } +} \ No newline at end of file Deleted: trunk/library/classes/Gems/Snippets/Export/ReportHeader.php =================================================================== --- trunk/library/classes/Gems/Snippets/Export/ReportHeader.php 2012-06-15 11:42:19 UTC (rev 768) +++ trunk/library/classes/Gems/Snippets/Export/ReportHeader.php 2012-06-15 11:47:36 UTC (rev 769) @@ -1,70 +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. - * - * @package Gems - * @subpackage Snippets - * @copyright Copyright (c) 2011 Erasmus MC - * @license New BSD License - * @version $Id: Sample.php 215 2011-07-12 08:52:54Z michiel $ - */ - -/** - * Header for html/pdf export of a respondent - * - * @package Gems - * @subpackage Snippets - * @copyright Copyright (c) 2011 Erasmus MC - * @license New BSD License - * @since Class available since version 1.5.5 - */ -class Gems_Snippets_Export_ReportHeader extends MUtil_Snippets_SnippetAbstract -{ - /** - * @var Gems_Loader - */ - public $loader; - - public function getHtmlOutput(Zend_View_Abstract $view) - { - $html = $this->getHtmlSequence(); - $html->h1($this->_('Respondent report')); - - $table = $html->table(array('class' => 'browser')); - - $table->th($this->_('Report information'), array('colspan' => 2)); - $table->tr()->th($this->_('Generated by')) - ->td($this->loader->getCurrentUser()->getFullName()); - $table->tr()->th($this->_('Generated on')) - ->td(new Zend_Date()); - $table->tr()->th($this->_('Organization')) - ->td($this->loader->getCurrentUser()->getCurrentOrganization()->getName()); - - $html->br(); - - return $html; - } -} \ No newline at end of file Copied: trunk/library/classes/Gems/Snippets/Export/ReportHeaderSnippet.php (from rev 768, trunk/library/classes/Gems/Snippets/Export/ReportHeader.php) =================================================================== --- trunk/library/classes/Gems/Snippets/Export/ReportHeaderSnippet.php (rev 0) +++ trunk/library/classes/Gems/Snippets/Export/ReportHeaderSnippet.php 2012-06-15 11:47:36 UTC (rev 769) @@ -0,0 +1,70 @@ +<?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. + * + * @package Gems + * @subpackage Snippets + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @version $Id: Sample.php 215 2011-07-12 08:52:54Z michiel $ + */ + +/** + * Header for html/pdf export of a respondent + * + * @package Gems + * @subpackage Snippets + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @since Class available since version 1.5.5 + */ +class Gems_Snippets_Export_ReportHeaderSnippet extends MUtil_Snippets_SnippetAbstract +{ + /** + * @var Gems_Loader + */ + public $loader; + + public function getHtmlOutput(Zend_View_Abstract $view) + { + $html = $this->getHtmlSequence(); + $html->h1($this->_('Respondent report')); + + $table = $html->table(array('class' => 'browser')); + + $table->th($this->_('Report information'), array('colspan' => 2)); + $table->tr()->th($this->_('Generated by')) + ->td($this->loader->getCurrentUser()->getFullName()); + $table->tr()->th($this->_('Generated on')) + ->td(new Zend_Date()); + $table->tr()->th($this->_('Organization')) + ->td($this->loader->getCurrentUser()->getCurrentOrganization()->getName()); + + $html->br(); + + return $html; + } +} \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2012-06-21 09:38:34
|
Revision: 774 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=774&view=rev Author: mennodekker Date: 2012-06-21 09:38:22 +0000 (Thu, 21 Jun 2012) Log Message: ----------- Moved RespondentExport to a separate class -> solves menu jump and not allowed error when pr.respondet.export-html given Modified Paths: -------------- trunk/library/classes/Gems/Default/RespondentAction.php trunk/library/classes/Gems/Default/RespondentExportAction.php trunk/library/classes/Gems/Loader.php Added Paths: ----------- trunk/library/classes/Gems/Export/RespondentExport.php Modified: trunk/library/classes/Gems/Default/RespondentAction.php =================================================================== --- trunk/library/classes/Gems/Default/RespondentAction.php 2012-06-20 16:59:53 UTC (rev 773) +++ trunk/library/classes/Gems/Default/RespondentAction.php 2012-06-21 09:38:22 UTC (rev 774) @@ -52,12 +52,48 @@ 'RespondentTokenTabsSnippet', 'RespondentTokenSnippet', ); + + public $exportSnippets = array('RespondentDetailsSnippet'); public $filterStandard = array('grc_success' => 1); public $sortKey = array('gr2o_opened' => SORT_DESC); public $useTabbedForms = true; + + /** + * Constructs the form + * + * @param Gems_Export_RespondentExport $export + * @return Gems_Form_TableForm + */ + protected function _getExportForm($export) + { + $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'); + if (!empty($export->_wkhtmltopdfLocation)) { + $outputFormats['pdf'] = 'PDF'; + $element->setValue('pdf'); + } + $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; + } /** * Adds columns from the model to the bridge that creates the browse table. @@ -422,6 +458,38 @@ public function exportAction() { - $this->_reroute(array('controller' => 'respondent-export', 'action' => 'index')); + //First show the respondent snippet + $model = $this->getModel(); + $data = $model->applyRequest($this->getRequest(), true)->loadFirst(); + + if (! isset($data['grs_id_user'])) { + $this->addMessage(sprintf($this->_('Unknown %s requested'), $this->getTopic())); + $this->_reroute(array('action' => 'index')); + } + + $params['model'] = $model; + $params['baseUrl'] = array(MUtil_Model::REQUEST_ID => $this->_getParam(MUtil_Model::REQUEST_ID)); + $params['buttons'] = $this->createMenuLinks(); + $params['onclick'] = $this->findAllowedMenuItem('edit'); + if ($params['onclick']) { + $params['onclick'] = $params['onclick']->toHRefAttribute($this->getRequest()); + } + $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) $this->getRequest()->getParam('id'), $this->getRequest()->getParam('group'), $this->getRequest()->getParam('format')); + } } } Modified: trunk/library/classes/Gems/Default/RespondentExportAction.php =================================================================== --- trunk/library/classes/Gems/Default/RespondentExportAction.php 2012-06-20 16:59:53 UTC (rev 773) +++ trunk/library/classes/Gems/Default/RespondentExportAction.php 2012-06-21 09:38:22 UTC (rev 774) @@ -44,32 +44,15 @@ */ class Gems_Default_RespondentExportAction extends Gems_Controller_Action { - public $useHtmlView = true; - - protected $_wkhtmltopdfLocation = ""; - - protected $_reportFooter = 'Export_ReportFooterSnippet'; - protected $_reportHeader = 'Export_ReportHeaderSnippet'; - protected $_respondentSnippet = 'Export_RespondentSnippet'; + public $useHtmlView = true; - protected $_groupedSurveySnippet = 'TrackAnswersModelSnippet'; - protected $_singleSurveySnippet = 'AnswerModelSnippet'; - - public function init() - { - parent::init(); - - if (isset($this->project->export) && isset($this->project->export['wkhtmltopdf'])) { - $this->_wkhtmltopdfLocation = $this->project->export['wkhtmltopdf']; - } - } - /** * Constructs the form * + * @param Gems_Export_RespondentExport $export * @return Gems_Form_TableForm - */ - protected function _getForm() + */ + protected function _getForm($export) { $form = new Gems_Form_TableForm(); $form->setAttrib('target', '_blank'); @@ -92,7 +75,7 @@ $element = new Zend_Form_Element_Select('format'); $element->setLabel($this->_('Output format')); $outputFormats = array('html' => 'HTML'); - if (!empty($this->_wkhtmltopdfLocation)) { + if (!empty($export->_wkhtmltopdfLocation)) { $outputFormats['pdf'] = 'PDF'; $element->setValue('pdf'); } @@ -107,264 +90,11 @@ return $form; } - /** - * Calls 'wkhtmltopdf' to convert HTML to PDF - * - * @param string $content The HTML source - * @return string The converted PDF file - * @throws Exception - */ - protected function _convertToPdf($content) - { - $tempInputFilename = GEMS_ROOT_DIR . '/var/tmp/export-' . md5(time() . rand()) . '.html'; - $tempOutputFilename = GEMS_ROOT_DIR . '/var/tmp/export-' . md5(time() . rand()) . '.pdf'; - - file_put_contents($tempInputFilename, $content); - - if (!file_exists($tempInputFilename)) { - throw new Exception("Unable to create temporary file '{$tempInputFilename}'"); - } - - $lastLine = exec(escapeshellarg($this->_wkhtmltopdfLocation) . ' ' . escapeshellarg($tempInputFilename) - . ' ' . escapeshellarg($tempOutputFilename), $outputLines, $return); - - if ($return > 0) { - @unlink($tempInputFilename); - @unlink($tempOutputFilename); - - throw new Exception(sprintf($this->_('Unable to run PDF conversion: "%s"'), $lastLine)); - } - - $pdfContents = file_get_contents($tempOutputFilename); - - @unlink($tempInputFilename); - @unlink($tempOutputFilename); - - return $pdfContents; - } - - /** - * Returns true when this token should be displayed - * - * @param Gems_Tracker_Token $token - * @return boolean - */ - public function _displayToken($token) - { - if ($token->isCompleted()) { - return true; - } - - return false; - } - - /** - * Determines if this particular token should be included - * in the report - * - * @param Gems_Tracker_Token $token - * @return boolean This dummy implementation always returns true - */ - protected function _isTokenInFilter(Gems_Tracker_Token $token) - { - return true; - } - - /** - * Exports all the tokens of a single track, grouped by round - * - * @param Gems_Tracker_RespondentTrack $track - */ - protected function _exportTrackTokens(Gems_Tracker_RespondentTrack $track) - { - $groupSurveys = $this->getRequest()->getParam('group'); - $token = $track->getFirstToken(); - $engine = $track->getTrackEngine(); - $surveys = array(); - - $table = $this->html->table(array('class' => 'browser')); - $table->th($this->_('Survey')) - ->th($this->_('Round')) - ->th($this->_('Token')) - ->th($this->_('Status')); - $this->html->br(); - - while ($token) { - //Should this token be in the list? - if (!$this->_isTokenInFilter($token)) { - $token = $token->getNextToken(); - continue; - } - - $table->tr()->td($token->getSurveyName()) - ->td(($engine->getTrackType() == 'T' ? $token->getRoundDescription() : $this->_('Single Survey'))) - ->td(strtoupper($token->getTokenId())) - ->td($token->getStatus()); - - //Should we display the answers? - if (!$this->_displayToken($token)) { - $token = $token->getNextToken(); - continue; - } - - if ($engine->getTrackType() == 'S' || !$groupSurveys) { - $this->html->span()->b($token->getSurveyName() . ($token->getRoundDescription() ? ' (' . $token->getRoundDescription() . ')' : '')); - $this->addSnippet($this->_singleSurveySnippet, 'token', $token, 'tokenId', $token->getTokenId(), - 'showHeaders', false, 'showButtons', false, 'showSelected', false, 'showTakeButton', false); - - $this->html->br(); - } else { - if (!isset($surveys[$token->getSurveyId()])) { - $surveys[$token->getSurveyId()] = true; - - $this->html->span()->b($token->getSurveyName()); - $this->addSnippet($this->_groupedSurveySnippet, 'token', $token, 'tokenId', $token->getTokenId(), - 'showHeaders', false, 'showButtons', false, 'showSelected', false, 'showTakeButton', false); - - $this->html->br(); - } - } - - $token = $token->getNextToken(); - } - } - - /** - * Exports a single track - * - * @param Gems_Tracker_RespondentTrack $track - */ - protected function _exportTrack(Gems_Tracker_RespondentTrack $track) - { - if ($track->getReceptionCode() != GemsEscort::RECEPTION_OK) { - return; - } - - $trackModel = $this->loader->getTracker()->getRespondentTrackModel(); - $trackModel->resetOrder(); - $trackModel->set('gtr_track_name', 'label', $this->_('Track')); - $trackModel->set('gr2t_track_info', 'label', $this->_('Description'), - 'description', $this->_('Enter the particulars concerning the assignment to this respondent.')); - $trackModel->set('assigned_by', 'label', $this->_('Assigned by')); - $trackModel->set('gr2t_start_date', 'label', $this->_('Start'), - 'formatFunction', $this->util->getTranslated()->formatDate, - 'default', MUtil_Date::format(new Zend_Date(), 'dd-MM-yyyy')); - $trackModel->set('gr2t_reception_code'); - $trackModel->set('gr2t_comment', 'label', $this->_('Comment')); - $trackModel->setFilter(array('gr2t_id_respondent_track' => $track->getRespondentTrackId())); - $trackData = $trackModel->loadFirst(); - - $this->html->h3($this->_('Track') . ' ' . $trackData['gtr_track_name']); - - $bridge = new MUtil_Model_VerticalTableBridge($trackModel, array('class' => 'browser')); - $bridge->setRepeater(MUtil_Lazy::repeat(array($trackData))); - $bridge->th($this->_('Track information'), array('colspan' => 2)); - $bridge->setColumnCount(1); - foreach($trackModel->getItemsOrdered() as $name) { - if ($label = $trackModel->get($name, 'label')) { - $bridge->addItem($name, $label); - } - } - - $table = $bridge->getTable(); - - foreach ($track->getFieldData() as $field => $value) { - if (is_int($field)) { - continue; - } - - $table->tr()->th($field)->td($value); - } - - $this->html[] = $table; - $this->html->br(); - - $this->_exportTrackTokens($track); - - $this->html->hr(); - } - - /** - * Exports a single respondent - * - * @param string $respondentId - */ - protected function _exportRespondent($respondentId) - { - $respondentModel = $this->loader->getModels()->getRespondentModel(false); - $respondentModel->setFilter(array('gr2o_patient_nr' => $respondentId)); - $respondentData = $respondentModel->loadFirst(); - - $this->addSnippet($this->_respondentSnippet, - 'model', $respondentModel, - 'data', $respondentData, - 'respondentId', $respondentId); - - $tracker = $this->loader->getTracker(); - $tracks = $tracker->getRespondentTracks($respondentData['gr2o_id_user'], $respondentData['gr2o_id_organization']); - - foreach ($tracks as $trackId => $track) { - $this->_exportTrack($track); - } - } - - /** - * Renders the entire report (including layout) - * - * @param string[] $respondentId - */ - protected function _render($respondents) - { - $this->html = new MUtil_Html_Sequence(); - - $this->addSnippet($this->_reportHeader); - - $respondentCount = count($respondents); - $respondentIdx = 0; - foreach ($respondents as $respondentId) { - $respondentIdx++; - $this->_exportRespondent($respondentId); - - if ($respondentIdx < $respondentCount) { - // Add some whitespace between patients - $this->html->div('', array('style' => 'height: 100px')); - } - } - - $this->addSnippet($this->_reportFooter, 'respondents', $respondents); - - $this->escort->menu->setVisible(false); - if ($this->escort instanceof Gems_Project_Layout_MultiLayoutInterface) { - $this->escort->layoutSwitch(); - } - $this->escort->postDispatch($this->getRequest()); - - $this->_helper->layout()->disableLayout(); - $this->_helper->viewRenderer->setNoRender(true); - - $this->view->layout()->content = $this->html->render($this->view); - - $content = $this->view->layout->render(); - - if ($this->getRequest()->getParam('format') == 'pdf') { - $content = $this->_convertToPdf($content); - $filename = 'respondent-export-' . strtolower($respondentId) . '.pdf'; - - header('Content-Type: application/x-download'); - header('Content-Length: '.strlen($content)); - header('Content-Disposition: inline; filename="'.$filename.'"'); - header('Cache-Control: private, max-age=0, must-revalidate'); - header('Pragma: public'); - } - - echo $content; - - $this->escort->menu->setVisible(true); - } - public function indexAction() { - $form = $this->_getForm(); + $export = $this->loader->getRespondentExport($this); + + $form = $this->_getForm($export); $this->html->h2($this->_('Export respondent')); $div = $this->html->div(array('id' => 'mainform')); $div[] = $form; @@ -377,7 +107,7 @@ $respondents = explode(',', $request->getParam('id')); $respondents = array_map('trim', $respondents); - $this->_render($respondents); + $export->render($respondents, $this->getRequest()->getParam('group'), $this->getRequest()->getParam('format')); } } } \ No newline at end of file Added: trunk/library/classes/Gems/Export/RespondentExport.php =================================================================== --- trunk/library/classes/Gems/Export/RespondentExport.php (rev 0) +++ trunk/library/classes/Gems/Export/RespondentExport.php 2012-06-21 09:38:22 UTC (rev 774) @@ -0,0 +1,342 @@ +<?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. + * + * @package Gems + * @subpackage Export + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @version $Id: Sample.php 215 2011-07-12 08:52:54Z michiel $ + */ + +/** + * Handles export of all tracks/surveys for a respondent + * + * @package Gems + * @subpackage Export + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @since Class available since version 1.5.5 + */ +class Gems_Export_RespondentExport extends Gems_Registry_TargetAbstract +{ + public $_wkhtmltopdfLocation = ""; + + protected $_reportFooter = 'Export_ReportFooterSnippet'; + protected $_reportHeader = 'Export_ReportHeaderSnippet'; + protected $_respondentSnippet = 'Export_RespondentSnippet'; + + protected $_groupedSurveySnippet = 'TrackAnswersModelSnippet'; + protected $_singleSurveySnippet = 'AnswerModelSnippet'; + + public $escort; + public $project; + private $html; + public $loader; + /** + * @var Zend_Translate_Adapter + */ + public $translate; + + public $util; + + public $view; + + public function _($messageid, $locale = null) + { + return $this->translate->_($messageid, $locale); + } + + public function afterRegistry() + { + parent::afterRegistry(); + + // Load the pdf class from the project settings if available + if (isset($this->project->export) && isset($this->project->export['wkhtmltopdf'])) { + $this->_wkhtmltopdfLocation = $this->project->export['wkhtmltopdf']; + } + } + + /** + * Calls 'wkhtmltopdf' to convert HTML to PDF + * + * @param string $content The HTML source + * @return string The converted PDF file + * @throws Exception + */ + protected function _convertToPdf($content) + { + $tempInputFilename = GEMS_ROOT_DIR . '/var/tmp/export-' . md5(time() . rand()) . '.html'; + $tempOutputFilename = GEMS_ROOT_DIR . '/var/tmp/export-' . md5(time() . rand()) . '.pdf'; + + file_put_contents($tempInputFilename, $content); + + if (!file_exists($tempInputFilename)) { + throw new Exception("Unable to create temporary file '{$tempInputFilename}'"); + } + + $lastLine = exec(escapeshellarg($this->_wkhtmltopdfLocation) . ' ' . escapeshellarg($tempInputFilename) + . ' ' . escapeshellarg($tempOutputFilename), $outputLines, $return); + + if ($return > 0) { + @unlink($tempInputFilename); + @unlink($tempOutputFilename); + + throw new Exception(sprintf($this->_('Unable to run PDF conversion: "%s"'), $lastLine)); + } + + $pdfContents = file_get_contents($tempOutputFilename); + + @unlink($tempInputFilename); + @unlink($tempOutputFilename); + + return $pdfContents; + } + + /** + * Returns true when this token should be displayed + * + * @param Gems_Tracker_Token $token + * @return boolean + */ + public function _displayToken($token) + { + if ($token->isCompleted()) { + return true; + } + + return false; + } + + /** + * Determines if this particular token should be included + * in the report + * + * @param Gems_Tracker_Token $token + * @return boolean This dummy implementation always returns true + */ + protected function _isTokenInFilter(Gems_Tracker_Token $token) + { + return true; + } + + /** + * Exports all the tokens of a single track, grouped by round + * + * @param Gems_Tracker_RespondentTrack $track + */ + protected function _exportTrackTokens(Gems_Tracker_RespondentTrack $track) + { + $groupSurveys = $this->_group; + $token = $track->getFirstToken(); + $engine = $track->getTrackEngine(); + $surveys = array(); + + $table = $this->html->table(array('class' => 'browser')); + $table->th($this->_('Survey')) + ->th($this->_('Round')) + ->th($this->_('Token')) + ->th($this->_('Status')); + $this->html->br(); + + while ($token) { + //Should this token be in the list? + if (!$this->_isTokenInFilter($token)) { + $token = $token->getNextToken(); + continue; + } + + $table->tr()->td($token->getSurveyName()) + ->td(($engine->getTrackType() == 'T' ? $token->getRoundDescription() : $this->_('Single Survey'))) + ->td(strtoupper($token->getTokenId())) + ->td($token->getStatus()); + + //Should we display the answers? + if (!$this->_displayToken($token)) { + $token = $token->getNextToken(); + continue; + } + + if ($engine->getTrackType() == 'S' || !$groupSurveys) { + $this->html->span()->b($token->getSurveyName() . ($token->getRoundDescription() ? ' (' . $token->getRoundDescription() . ')' : '')); + $this->html->snippet($this->_singleSurveySnippet, 'token', $token, 'tokenId', $token->getTokenId(), + 'showHeaders', false, 'showButtons', false, 'showSelected', false, 'showTakeButton', false); + + $this->html->br(); + } else { + if (!isset($surveys[$token->getSurveyId()])) { + $surveys[$token->getSurveyId()] = true; + + $this->html->span()->b($token->getSurveyName()); + $this->html->snippet($this->_groupedSurveySnippet, 'token', $token, 'tokenId', $token->getTokenId(), + 'showHeaders', false, 'showButtons', false, 'showSelected', false, 'showTakeButton', false); + + $this->html->br(); + } + } + + $token = $token->getNextToken(); + } + } + + /** + * Exports a single track + * + * @param Gems_Tracker_RespondentTrack $track + */ + protected function _exportTrack(Gems_Tracker_RespondentTrack $track) + { + if ($track->getReceptionCode() != GemsEscort::RECEPTION_OK) { + return; + } + + $trackModel = $this->loader->getTracker()->getRespondentTrackModel(); + $trackModel->resetOrder(); + $trackModel->set('gtr_track_name', 'label', $this->_('Track')); + $trackModel->set('gr2t_track_info', 'label', $this->_('Description'), + 'description', $this->_('Enter the particulars concerning the assignment to this respondent.')); + $trackModel->set('assigned_by', 'label', $this->_('Assigned by')); + $trackModel->set('gr2t_start_date', 'label', $this->_('Start'), + 'formatFunction', $this->util->getTranslated()->formatDate, + 'default', MUtil_Date::format(new Zend_Date(), 'dd-MM-yyyy')); + $trackModel->set('gr2t_reception_code'); + $trackModel->set('gr2t_comment', 'label', $this->_('Comment')); + $trackModel->setFilter(array('gr2t_id_respondent_track' => $track->getRespondentTrackId())); + $trackData = $trackModel->loadFirst(); + + $this->html->h3($this->_('Track') . ' ' . $trackData['gtr_track_name']); + + $bridge = new MUtil_Model_VerticalTableBridge($trackModel, array('class' => 'browser')); + $bridge->setRepeater(MUtil_Lazy::repeat(array($trackData))); + $bridge->th($this->_('Track information'), array('colspan' => 2)); + $bridge->setColumnCount(1); + foreach($trackModel->getItemsOrdered() as $name) { + if ($label = $trackModel->get($name, 'label')) { + $bridge->addItem($name, $label); + } + } + + $table = $bridge->getTable(); + + foreach ($track->getFieldData() as $field => $value) { + if (is_int($field)) { + continue; + } + + $table->tr()->th($field)->td($value); + } + + $this->html[] = $table; + $this->html->br(); + + $this->_exportTrackTokens($track); + + $this->html->hr(); + } + + /** + * Exports a single respondent + * + * @param string $respondentId + */ + protected function _exportRespondent($respondentId) + { + $respondentModel = $this->loader->getModels()->getRespondentModel(false); + $respondentModel->setFilter(array('gr2o_patient_nr' => $respondentId)); + $respondentData = $respondentModel->loadFirst(); + + $this->html->snippet($this->_respondentSnippet, + 'model', $respondentModel, + 'data', $respondentData, + 'respondentId', $respondentId); + + $tracker = $this->loader->getTracker(); + $tracks = $tracker->getRespondentTracks($respondentData['gr2o_id_user'], $respondentData['gr2o_id_organization']); + + foreach ($tracks as $trackId => $track) { + $this->_exportTrack($track); + } + } + + /** + * Renders the entire report (including layout) + * + * @param array|string[] $respondentId + * @param boolean $group Group same surveys or not + * @param string $format html|pdf, the output format to use + */ + public function render($respondents, $group = true, $format = 'html') + { + $this->_group = $group; + $this->_format = $format; + $this->html = new MUtil_Html_Sequence(); + + $this->html->snippet($this->_reportHeader); + + $respondentCount = count($respondents); + $respondentIdx = 0; + foreach ($respondents as $respondentId) { + $respondentIdx++; + $this->_exportRespondent($respondentId); + + if ($respondentIdx < $respondentCount) { + // Add some whitespace between patients + $this->html->div('', array('style' => 'height: 100px')); + } + } + + $this->html->snippet($this->_reportFooter, 'respondents', $respondents); + + $this->escort->menu->setVisible(false); + if ($this->escort instanceof Gems_Project_Layout_MultiLayoutInterface) { + $this->escort->layoutSwitch(); + } + $this->escort->postDispatch(Zend_Controller_Front::getInstance()->getRequest()); + + Zend_Controller_Action_HelperBroker::getExistingHelper('layout')->disableLayout(); + Zend_Controller_Action_HelperBroker::getExistingHelper('viewRenderer')->setNoRender(true); + + $this->view->layout()->content = $this->html->render($this->view); + + $content = $this->view->layout->render(); + + if ($this->_format == 'pdf') { + $content = $this->_convertToPdf($content); + $filename = 'respondent-export-' . strtolower($respondentId) . '.pdf'; + + header('Content-Type: application/x-download'); + header('Content-Length: '.strlen($content)); + header('Content-Disposition: inline; filename="'.$filename.'"'); + header('Cache-Control: private, max-age=0, must-revalidate'); + header('Pragma: public'); + } + + echo $content; + + $this->escort->menu->setVisible(true); + } + +} \ No newline at end of file Modified: trunk/library/classes/Gems/Loader.php =================================================================== --- trunk/library/classes/Gems/Loader.php 2012-06-20 16:59:53 UTC (rev 773) +++ trunk/library/classes/Gems/Loader.php 2012-06-21 09:38:22 UTC (rev 774) @@ -1,298 +1,317 @@ -<?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. - * - * - * @package Gems - * @subpackage Loader - * @author Matijs de Jong <mj...@ma...> - * @copyright Copyright (c) 2011 Erasmus MC - * @license New BSD License - * @version $Id$ - */ - -/** - * - * @package Gems - * @subpackage Loader - * @copyright Copyright (c) 2011 Erasmus MC - * @license New BSD License - * @since Class available since version 1.4 - */ -class Gems_Loader extends Gems_Loader_LoaderAbstract -{ - /** - * - * @var Gems_Events - */ - protected $events; - - /** - * - * @var Gems_Export - */ - protected $export; - - /** - * - * @var Gems_Model - */ - protected $models; - - /** - * - * @var Gems_Pdf - */ - protected $pdf; - - /** - * - * @var Gems_Roles - */ - protected $roles; - - /** - * - * @var Gems_Selector - */ - protected $selector; - - /** - * - * @var Gems_Snippets_SnippetLoader - */ - protected $snippetLoader; - - /** - * - * @var Gems_Tracker - */ - protected $tracker; - - /** - * - * @var Gems_Upgrades - */ - protected $upgrades; - - /** - * - * @var Gems_User_UserLoader - */ - protected $userLoader; - - /** - * - * @var Gems_Util - */ - protected $util; - - /** - * - * @var Gems_Versions - */ - protected $versions; - - /** - * Load project specific menu or general Gems menu otherwise - * - * @param GemsEscort $escort - * @return Gems_Menu - */ - public function createMenu(GemsEscort $escort) - { - return $this->_loadClass('Menu', true, func_get_args()); - } - - /** - * - * @return Gems_User_User - */ - public function getCurrentUser() - { - $loader = $this->getUserLoader(); - - return $loader->getCurrentUser(); - } - - /** - * - * @return gems_Events - */ - public function getEvents() - { - return $this->_getClass('events'); - } - - /** - * - * @return Gems_Export - */ - public function getExport() - { - return $this->_getClass('export'); - } - - /** - * - * @return Gems_Model - */ - public function getModels() - { - return $this->_getClass('models', 'model'); - } - - /** - * Returns an organization object, initiated from the database. - * - * @param int $organizationId Optional, uses current user when empty - * @return Gems_User_Organization - */ - public function getOrganization($organizationId = null) - { - $loader = $this->getUserLoader(); - - return $loader->getOrganization($organizationId); - } - - /** - * - * @return Gems_Pdf - */ - public function getPdf() - { - return $this->_getClass('pdf'); - } - - /** - * - * @param GemsEscort $escort - * @return Gems_Roles - */ - public function getRoles(GemsEscort $escort) - { - return $this->_getClass('roles', null, array($escort)); - } - - /** - * - * @return Gems_Selector - */ - public function getSelector() - { - return $this->_getClass('selector'); - } - - /** - * - * @return Gems_Snippets_SnippetLoader - */ - public function getSnippetLoader($container) - { - $class = $this->_getClass('snippetLoader', 'Snippets_SnippetLoader'); - - //now add the calling class as a container - $class->addRegistryContainer($container); - return $class; - } - - /** - * - * @return Gems_Task_TaskAbstract - */ - public function getTask($name) { - return $this->_loadClass('Task_' . ucfirst($name), true); - } - - /** - * - * @param type $id - * @return Gems_Task_TaskRunnerBatch - */ - public function getTaskRunnerBatch($id) - { - return $this->_loadClass('Task_TaskRunnerBatch', true, array($id)); - } - - /** - * - * @return Gems_Tracker_TrackerInterface - */ - public function getTracker() - { - return $this->_getClass('tracker'); - } - - /** - * - * @return Gems_Upgrades - */ - public function getUpgrades() - { - return $this->_getClass('upgrades'); - } - - /** - * - * @param string $login_name - * @param int $organization - * @return Gems_User_User - */ - public function getUser($login_name, $organization) - { - $loader = $this->getUserLoader(); - - return $loader->getUser($login_name, $organization); - } - - /** - * - * @return Gems_User_UserLoader - */ - public function getUserLoader() - { - return $this->_getClass('userLoader', 'User_UserLoader'); - } - - /** - * - * @return Gems_Util - */ - public function getUtil() - { - return $this->_getClass('util'); - } - - /** - * - * @return Gems_Versions - */ - public function getVersions() - { - return $this->_getClass('versions'); - } +<?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. + * + * + * @package Gems + * @subpackage Loader + * @author Matijs de Jong <mj...@ma...> + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @version $Id$ + */ + +/** + * + * @package Gems + * @subpackage Loader + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @since Class available since version 1.4 + */ +class Gems_Loader extends Gems_Loader_LoaderAbstract +{ + /** + * + * @var Gems_Events + */ + protected $events; + + /** + * + * @var Gems_Export + */ + protected $export; + + /** + * + * @var Gems_Model + */ + protected $models; + + /** + * + * @var Gems_Pdf + */ + protected $pdf; + + /** + * + * @var Gems_Export_RespondentExport + */ + protected $respondentexport; + + /** + * + * @var Gems_Roles + */ + protected $roles; + + /** + * + * @var Gems_Selector + */ + protected $selector; + + /** + * + * @var Gems_Snippets_SnippetLoader + */ + protected $snippetLoader; + + /** + * + * @var Gems_Tracker + */ + protected $tracker; + + /** + * + * @var Gems_Upgrades + */ + protected $upgrades; + + /** + * + * @var Gems_User_UserLoader + */ + protected $userLoader; + + /** + * + * @var Gems_Util + */ + protected $util; + + /** + * + * @var Gems_Versions + */ + protected $versions; + + /** + * Load project specific menu or general Gems menu otherwise + * + * @param GemsEscort $escort + * @return Gems_Menu + */ + public function createMenu(GemsEscort $escort) + { + return $this->_loadClass('Menu', true, func_get_args()); + } + + /** + * + * @return Gems_User_User + */ + public function getCurrentUser() + { + $loader = $this->getUserLoader(); + + return $loader->getCurrentUser(); + } + + /** + * + * @return gems_Events + */ + public function getEvents() + { + return $this->_getClass('events'); + } + + /** + * + * @return Gems_Export + */ + public function getExport() + { + return $this->_getClass('export'); + } + + /** + * + * @return Gems_Model + */ + public function getModels() + { + return $this->_getClass('models', 'model'); + } + + /** + * Returns an organization object, initiated from the database. + * + * @param int $organizationId Optional, uses current user when empty + * @return Gems_User_Organization + */ + public function getOrganization($organizationId = null) + { + $loader = $this->getUserLoader(); + + return $loader->getOrganization($organizationId); + } + + /** + * + * @return Gems_Pdf + */ + public function getPdf() + { + return $this->_getClass('pdf'); + } + + /** + * + * @return Gems_Export_RespondentExport + */ + public function getRespondentExport($container) + { + $this->addRegistryContainer($container, 'tmp_export'); + $class = $this->_getClass('respondentexport', 'Export_RespondentExport'); + $this->removeRegistryContainer('tmp_export'); + + return $class; + } + + /** + * + * @param GemsEscort $escort + * @return Gems_Roles + */ + public function getRoles(GemsEscort $escort) + { + return $this->_getClass('roles', null, array($escort)); + } + + /** + * + * @return Gems_Selector + */ + public function getSelector() + { + return $this->_getClass('selector'); + } + + /** + * + * @return Gems_Snippets_SnippetLoader + */ + public function getSnippetLoader($container) + { + $class = $this->_getClass('snippetLoader', 'Snippets_SnippetLoader'); + + //now add the calling class as a container + $class->addRegistryContainer($container); + return $class; + } + + /** + * + * @return Gems_Task_TaskAbstract + */ + public function getTask($name) { + return $this->_loadClass('Task_' . ucfirst($name), true); + } + + /** + * + * @param type $id + * @return Gems_Task_TaskRunnerBatch + */ + public function getTaskRunnerBatch($id) + { + return $this->_loadClass('Task_TaskRunnerBatch', true, array($id)); + } + + /** + * + * @return Gems_Tracker_TrackerInterface + */ + public function getTracker() + { + return $this->_getClass('tracker'); + } + + /** + * + * @return Gems_Upgrades + */ + public function getUpgrades() + { + return $this->_getClass('upgrades'); + } + + /** + * + * @param string $login_name + * @param int $organization + * @return Gems_User_User + */ + public function getUser($login_name, $organization) + { + $loader = $this->getUserLoader(); + + return $loader->getUser($login_name, $organization); + } + + /** + * + * @return Gems_User_UserLoader + */ + public function getUserLoader() + { + return $this->_getClass('userLoader', 'User_UserLoader'); + } + + /** + * + * @return Gems_Util + */ + public function getUtil() + { + return $this->_getClass('util'); + } + + /** + * + * @return Gems_Versions + */ + public function getVersions() + { + return $this->_getClass('versions'); + } } \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2012-06-21 12:21:38
|
Revision: 778 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=778&view=rev Author: mennodekker Date: 2012-06-21 12:21:32 +0000 (Thu, 21 Jun 2012) Log Message: ----------- org comes from id2 Some docs on Export for code completion Modified Paths: -------------- trunk/library/classes/Gems/Default/RespondentAction.php trunk/library/classes/Gems/Export/RespondentExport.php Modified: trunk/library/classes/Gems/Default/RespondentAction.php =================================================================== --- trunk/library/classes/Gems/Default/RespondentAction.php 2012-06-21 12:10:37 UTC (rev 777) +++ trunk/library/classes/Gems/Default/RespondentAction.php 2012-06-21 12:21:32 UTC (rev 778) @@ -364,7 +364,7 @@ return $this->_getParam(MUtil_Model::REQUEST_ID, $this->_getParam(MUtil_Model::REQUEST_ID1, $default)); case 'gr2o_id_organization': - return $this->_getParam(MUtil_Model::REQUEST_ID1, $default ? $default : $this->loader->getCurrentUser()->getCurrentOrganizationId()); + return $this->_getParam(MUtil_Model::REQUEST_ID2, $default ? $default : $this->loader->getCurrentUser()->getCurrentOrganizationId()); case 'gto_id_token': return null; Modified: trunk/library/classes/Gems/Export/RespondentExport.php =================================================================== --- trunk/library/classes/Gems/Export/RespondentExport.php 2012-06-21 12:10:37 UTC (rev 777) +++ trunk/library/classes/Gems/Export/RespondentExport.php 2012-06-21 12:21:32 UTC (rev 778) @@ -52,15 +52,35 @@ protected $_groupedSurveySnippet = 'TrackAnswersModelSnippet'; protected $_singleSurveySnippet = 'AnswerModelSnippet'; + /** + * + * @var GemsEscort + */ public $escort; - public $project; + private $html; + + /** + * + * @var Gems_Loader + */ public $loader; + /** + * + * @var Gems_Project_ProjectSettings + */ + public $project; + + /** * @var Zend_Translate_Adapter */ public $translate; + /** + * + * @var Gems_Util + */ public $util; public $view; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2012-06-26 09:22:55
|
Revision: 786 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=786&view=rev Author: mennodekker Date: 2012-06-26 09:22:49 +0000 (Tue, 26 Jun 2012) Log Message: ----------- improved display of tableforms in print Modified Paths: -------------- trunk/library/classes/Gems/Form/TableForm.php trunk/library/classes/Gems/Tracker/SurveyModel.php Modified: trunk/library/classes/Gems/Form/TableForm.php =================================================================== --- trunk/library/classes/Gems/Form/TableForm.php 2012-06-26 09:22:13 UTC (rev 785) +++ trunk/library/classes/Gems/Form/TableForm.php 2012-06-26 09:22:49 UTC (rev 786) @@ -225,11 +225,16 @@ if ($this->loadDefaultDecoratorsIsDisabled()) { return $this; } + + $class = $this->getAttrib('class'); + if (empty($class)) { + $class = 'formTable'; + } $decorators = $this->getDecorators(); if (empty($decorators)) { $this->addDecorator('FormElements') - ->addDecorator(array('table' => 'HtmlTag'), array('tag' => 'table', 'class'=>'formTable')) + ->addDecorator(array('table' => 'HtmlTag'), array('tag' => 'table', 'class'=>$class)) ->addDecorator(array('tab' => 'HtmlTag'), array('tag' => 'div', 'class' => 'displayGroup')) ->addDecorator('Form'); } Modified: trunk/library/classes/Gems/Tracker/SurveyModel.php =================================================================== --- trunk/library/classes/Gems/Tracker/SurveyModel.php 2012-06-26 09:22:13 UTC (rev 785) +++ trunk/library/classes/Gems/Tracker/SurveyModel.php 2012-06-26 09:22:49 UTC (rev 786) @@ -133,7 +133,8 @@ */ public function loadFirst($filter = true, $sort = true) { - return reset($this->addAnswers(array(parent::loadFirst($filter, $sort)))); + $result = $this->addAnswers(array(parent::loadFirst($filter, $sort))); + return reset($result); } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2012-06-27 11:59:27
|
Revision: 792 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=792&view=rev Author: matijsdejong Date: 2012-06-27 11:59:17 +0000 (Wed, 27 Jun 2012) Log Message: ----------- Cron job now continues trying to send e-mails even after an error was encountered. Modified Paths: -------------- trunk/library/classes/Gems/Default/CronAction.php trunk/library/classes/Gems/Email/TemplateMailer.php Modified: trunk/library/classes/Gems/Default/CronAction.php =================================================================== --- trunk/library/classes/Gems/Default/CronAction.php 2012-06-27 11:34:34 UTC (rev 791) +++ trunk/library/classes/Gems/Default/CronAction.php 2012-06-27 11:59:17 UTC (rev 792) @@ -162,7 +162,8 @@ $model = $this->loader->getTracker()->getTokenModel(); $mailer = new Gems_Email_TemplateMailer($this->escort); - + $mailer->continueOnError = true; + // $mailer->setDefaultTransport(new MUtil_Mail_Transport_EchoLog()); $jobs = $this->db->fetchAll("SELECT * FROM gems__mail_jobs WHERE gmj_active = 1"); Modified: trunk/library/classes/Gems/Email/TemplateMailer.php =================================================================== --- trunk/library/classes/Gems/Email/TemplateMailer.php 2012-06-27 11:34:34 UTC (rev 791) +++ trunk/library/classes/Gems/Email/TemplateMailer.php 2012-06-27 11:59:17 UTC (rev 792) @@ -49,7 +49,14 @@ const MAIL_TLS = 2; /** + * Should the mailer continue sending mails, even when it encounters errors? * + * @var boolean + */ + public $continueOnError = false; + + /** + * * @var Zend_Mail_Transport */ protected $defaultTransport = null; @@ -59,6 +66,11 @@ */ protected $escort; + /** + * Feedback messages for this action. + * + * @var array of string + */ protected $messages = array(); private $_changeDate; @@ -238,6 +250,7 @@ $send = array(); $scount = 0; $ucount = 0; + $result = true; foreach ($tokensData as $tokenData) { // Should this token be mailed? @@ -249,11 +262,15 @@ if ($message = $this->processMail($tokenData)) { $this->addMessage($this->escort->_('Mail failed to send.')); $this->addMessage($message); - return false; + $result = true; + if (! $this->continueOnError) { + break; + } + } else { + $send[$tokenData['grs_email']] = true; + $scount++; + $ucount++; } - $send[$tokenData['grs_email']] = true; - $scount++; - $ucount++; } elseif ($updateAll) { $this->updateToken($tokenData); @@ -266,7 +283,7 @@ $this->addMessage(sprintf($this->escort->_('Sent %d e-mails, updated %d tokens.'), $scount, $ucount)); } - return true; + return $result; } /** @@ -335,12 +352,12 @@ MUtil_Echo::r($to, $to_name); MUtil_Echo::r($from, $from_name); } - + if (!$this->bounceCheck()) { $validate = new Zend_Validate_EmailAddress(); - + if (!$validate->isValid($to)) { - return "Invalid e-mail address {$to}"; + return sprintf($this->escort->_("Invalid e-mail address '%s'."), $to); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |