From: <gem...@li...> - 2011-12-16 10:11:45
|
Revision: 363 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=363&view=rev Author: mennodekker Date: 2011-12-16 10:11:39 +0000 (Fri, 16 Dec 2011) Log Message: ----------- Fix to tabforms: hidden values now go to the subform again as validators (like dbunique) need to have all the needed values in their own subform ( $context ) Make sure that needed hiddens are in the right tab! Modified Paths: -------------- trunk/library/classes/Gems/Form/TableForm.php trunk/library/classes/Gems/TabForm.php Modified: trunk/library/classes/Gems/Form/TableForm.php =================================================================== --- trunk/library/classes/Gems/Form/TableForm.php 2011-12-15 17:21:17 UTC (rev 362) +++ trunk/library/classes/Gems/Form/TableForm.php 2011-12-16 10:11:39 UTC (rev 363) @@ -218,9 +218,9 @@ $element->setDecorators($decorators); if ($element instanceof Zend_Form_Element_Hidden) { - //Add 1000 to the order to place them last and fix some layout problems - $order = $element->getOrder(); - $element->setOrder($order+1000); + //Make row hidden so it takes no height + $decorator = $element->getDecorator('row'); + $decorator->setOption('style', 'display:none;'); } else { $decorator = $element->getDecorator('row'); Modified: trunk/library/classes/Gems/TabForm.php =================================================================== --- trunk/library/classes/Gems/TabForm.php 2011-12-15 17:21:17 UTC (rev 362) +++ trunk/library/classes/Gems/TabForm.php 2011-12-16 10:11:39 UTC (rev 363) @@ -57,7 +57,7 @@ */ public function addElement($element, $name = null, $options = null) { - if ($this->currentTab && !($element instanceof Zend_Form_Element_Hidden)) { + if ($this->currentTab) { return $this->currentTab->addElement($element, $name, $options); } else { parent::addElement($element, $name, $options); @@ -166,6 +166,19 @@ } /** + * Retrieve a named tab (subform) and set the active tab to this one + * + * @param type $name + * @return Gems_Form_TabSubForm + */ + public function getTab($name) + { + $tab = $this->getSubForm($name); + $this->currentTab = $tab; + return $tab; + } + + /** * Create tabs from MUtil_Form_Element_Tab elements * * All elements following an element of type MUtil_Form_Element_Tab will be in tabs @@ -374,7 +387,6 @@ $values = parent::getValues($suppressArrayNotation); foreach ($this->getSubForms() as $key => $subForm) { - $values[$key]; $values = $this->_array_replace_recursive($values, $values[$key]); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2011-12-16 12:37:17
|
Revision: 365 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=365&view=rev Author: mennodekker Date: 2011-12-16 12:37:11 +0000 (Fri, 16 Dec 2011) Log Message: ----------- minor fixes Modified Paths: -------------- trunk/library/classes/Gems/AccessLog.php trunk/library/classes/Gems/Default/IndexAction.php Modified: trunk/library/classes/Gems/AccessLog.php =================================================================== --- trunk/library/classes/Gems/AccessLog.php 2011-12-16 11:07:19 UTC (rev 364) +++ trunk/library/classes/Gems/AccessLog.php 2011-12-16 12:37:11 UTC (rev 365) @@ -194,7 +194,7 @@ $values['glua_by'] = $this->_userInfo->user_id ? $this->_userInfo->user_id : 0; $values['glua_organization'] = $this->_userInfo->user_organization_id ? $this->_userInfo->user_organization_id : 0; $values['glua_action'] = $this->getActionId($action); - $values['glua_role'] = $this->_userInfo->user_role; + $values['glua_role'] = $this->_userInfo->user_role ? $this->_userInfo->user_role : '--not set--' ; $values['glua_created'] = new Zend_Db_Expr('CURRENT_TIMESTAMP'); if ($request instanceof Zend_Controller_Request_Http) { Modified: trunk/library/classes/Gems/Default/IndexAction.php =================================================================== --- trunk/library/classes/Gems/Default/IndexAction.php 2011-12-16 11:07:19 UTC (rev 364) +++ trunk/library/classes/Gems/Default/IndexAction.php 2011-12-16 12:37:11 UTC (rev 365) @@ -406,7 +406,7 @@ $this->addMessage(sprintf($this->_('Good bye: %s.'), $user->getFullName())); $user->unsetAsCurrentUser(); - Zend_Session::regenerateId(); + Zend_Session::destroy(); $this->_reroute(array('action' => 'index'), true); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2011-12-19 09:37:04
|
Revision: 371 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=371&view=rev Author: mennodekker Date: 2011-12-19 09:36:58 +0000 (Mon, 19 Dec 2011) Log Message: ----------- Doc fixes & created Generic snippet Modified Paths: -------------- trunk/library/classes/Gems/Default/SurveyMaintenanceAction.php trunk/library/classes/Gems/Snippets/ModelTabFormSnippetGeneric.php Modified: trunk/library/classes/Gems/Default/SurveyMaintenanceAction.php =================================================================== --- trunk/library/classes/Gems/Default/SurveyMaintenanceAction.php 2011-12-19 09:27:19 UTC (rev 370) +++ trunk/library/classes/Gems/Default/SurveyMaintenanceAction.php 2011-12-19 09:36:58 UTC (rev 371) @@ -124,7 +124,6 @@ $bridge->addSelect( 'gsu_result_field', 'label', $this->_('Result field'), 'multiOptions', $surveyFields); $bridge->addSelect( 'gsu_beforeanswering_event', 'label', $this->_('Before answering'), 'multiOptions', $this->loader->getEvents()->listSurveyBeforeAnsweringEvents()); $bridge->addSelect( 'gsu_completed_event', 'label', $this->_('After completion'), 'multiOptions', $this->loader->getEvents()->listSurveyCompletionEvents()); - // TODO: gsu_completed_event $bridge->addFile( 'new_pdf', 'label', $this->_('Upload new PDF'), 'accept', 'application/pdf', Modified: trunk/library/classes/Gems/Snippets/ModelTabFormSnippetGeneric.php =================================================================== --- trunk/library/classes/Gems/Snippets/ModelTabFormSnippetGeneric.php 2011-12-19 09:27:19 UTC (rev 370) +++ trunk/library/classes/Gems/Snippets/ModelTabFormSnippetGeneric.php 2011-12-19 09:36:58 UTC (rev 371) @@ -25,8 +25,6 @@ * (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 Snippets * @copyright Copyright (c) 2011 Erasmus MC @@ -35,16 +33,19 @@ */ /** - * Short description for ModelTabFormSnippetGeneric + * Displays an edit form using tabs based on the model the model set through the $model snippet parameter. * - * Long description for class ModelTabFormSnippetGeneric (if any)... + * If you want to use this class "as is" use the 'Generic_ModelTabFormSnippet' snippet. * + * This class is not in the standard snippet loading directories and does not follow + * their naming conventions, but exists only to make it simple to extend this class + * for a specific implementation. + * * @package Gems * @subpackage Snippets * @copyright Copyright (c) 2011 Erasmus MC * @license New BSD License - * @since Class available since version 1.0 - * @deprecated Class deprecated since version 2.0 + * @since Class available since version 1.5 */ class Gems_Snippets_ModelTabFormSnippetGeneric extends Gems_Snippets_ModelFormSnippetGeneric { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2011-12-19 12:39:24
|
Revision: 373 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=373&view=rev Author: mennodekker Date: 2011-12-19 12:39:13 +0000 (Mon, 19 Dec 2011) Log Message: ----------- Moved AccessLogActions from session to cache Modified Paths: -------------- trunk/library/classes/Gems/AccessLog.php trunk/library/classes/Gems/Default/LogMaintenanceAction.php trunk/library/classes/Gems/Util/ReceptionCode.php trunk/library/classes/Gems/Util.php Added Paths: ----------- trunk/library/classes/Gems/Util/AccessLogActions.php Modified: trunk/library/classes/Gems/AccessLog.php =================================================================== --- trunk/library/classes/Gems/AccessLog.php 2011-12-19 10:21:13 UTC (rev 372) +++ trunk/library/classes/Gems/AccessLog.php 2011-12-19 12:39:13 UTC (rev 373) @@ -4,7 +4,7 @@ /** * 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 @@ -15,7 +15,7 @@ * * 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 @@ -56,7 +56,7 @@ * Convenience calls to the log method: * * When you try to call 'log' + anything it will be interpreted as a call to the log - * method where the part following log is the action and the first argument is the + * method where the part following log is the action and the first argument is the * respondentId. When you want to utilize the full power of the logging system, use * the log method directly. * @@ -86,12 +86,12 @@ $this->_userInfo = GemsEscort::getInstance()->session; $this->loadActions(); } - + /** * Return an instance of the Gems_AccesLog class - * + * * @param Zend_Db_Adapter_Abstract $db - * @return Gems_AccessLog + * @return Gems_AccessLog */ public static function getLog(Zend_Db_Adapter_Abstract $db = null) { @@ -107,58 +107,55 @@ protected function getActionId($action) { - if (! array_key_exists($action, $this->_sessionStore->actions)) { + if (! array_key_exists($action, $this->_actions)) { //Check if a refresh fixes the problem $this->loadActions(true); - if (! array_key_exists($action, $this->_sessionStore->actions)) { + if (! array_key_exists($action, $this->_actions)) { $values['glac_name'] = $action; $values['glac_change'] = preg_match('/(save|add|store|delete|remove|create)/', $action); - - /* + + /* * For 1.3 release the default behaviour is to disable logging for all actions, * so we get an opt-in per action - */ + */ $values['glac_log'] = 0; - + /* * Later on, we can set some rules like below to disable logging for * actions like the autofilter */ //$values['glac_log'] = !substr_count($action, '.autofilter'); $values['glac_created'] = new Zend_Db_Expr('CURRENT_TIMESTAMP'); - + $this->_db->insert('gems__log_actions', $values); $this->loadActions(true); } } - return $this->_sessionStore->actions[$action]['id']; + return $this->_actions[$action]['id']; } /** * Load the actions into memory, use optional parameter to enforce refreshing - * - * @param type $reset + * + * @param type $reset */ public function loadActions($reset = false) { //When project escort doesn't implement the log interface, we disable logging and don't load actions - if (GemsEscort::getInstance() instanceof Gems_Project_Log_LogRespondentAccessInterface && - ($reset || (! isset($this->_sessionStore->actions)))) { - - $actions = array(); - - try { - $actionRows = $this->_db->fetchAll('SELECT glac_name, glac_id_action, glac_log FROM gems__log_actions ORDER BY glac_name'); - foreach($actionRows as $actionRow) { - $actions[$actionRow['glac_name']]['id'] = $actionRow['glac_id_action']; - $actions[$actionRow['glac_name']]['log'] = $actionRow['glac_log']; - } - } catch (Exception $e) { - } - - $this->_sessionStore->actions = $actions; + if (GemsEscort::getInstance() instanceof Gems_Project_Log_LogRespondentAccessInterface && + ($reset || (! isset($this->_actions)))) { + + $actions = GemsEscort::getInstance()->getUtil()->getAccessLogActions(); + if ($reset) { + $actions->invalidateCache(); + //Now unset to force a reload + unset(GemsEscort::getInstance()->getUtil()->accessLogActions); + $actions = GemsEscort::getInstance()->getUtil()->getAccessLogActions(); + } + + $this->_actions = $actions->getAllData(); } } @@ -176,14 +173,14 @@ { try { //When project escort doesn't implement the log interface, we disable logging - if (!(GemsEscort::getInstance() instanceof Gems_Project_Log_LogRespondentAccessInterface) + if (!(GemsEscort::getInstance() instanceof Gems_Project_Log_LogRespondentAccessInterface) || (!isset($this->_userInfo->user_id) && $force === false ) ) { return $this; } - /* + /* * For backward compatibility, get the request from the frontcontroller when it - * is not supplied in the + * is not supplied in the */ if (!($request instanceof Zend_Controller_Request_Abstract)) { $request = Zend_Controller_Front::getInstance()->getRequest(); @@ -202,12 +199,12 @@ } else { $values['glua_remote_ip'] = ''; } - - /* - * Now we know for sure that the action is in the sessionstore, check if we + + /* + * Now we know for sure that the action is in the list, check if we * need to log this action */ - if (!($this->_sessionStore->actions[$action]['log']) && !$force) return $this; + if (!($this->_actions[$action]['log']) && !$force) return $this; if (isset($this->_sessionStore->glua_action)) { //If we don't force a logentry, check if it is a duplicate @@ -239,5 +236,5 @@ MUtil_Echo::r(GemsEscort::getInstance()->translate->_('Database needs to be updated!')); return $this; } - } + } } \ No newline at end of file Modified: trunk/library/classes/Gems/Default/LogMaintenanceAction.php =================================================================== --- trunk/library/classes/Gems/Default/LogMaintenanceAction.php 2011-12-19 10:21:13 UTC (rev 372) +++ trunk/library/classes/Gems/Default/LogMaintenanceAction.php 2011-12-19 12:39:13 UTC (rev 373) @@ -55,9 +55,10 @@ return $model; } - public function getAfterSaveRoute($data) { - Gems_AccessLog::getLog()->loadActions(true); - return parent::getAfterSaveRoute($data); + public function afterSave(array $data, $isNew) + { + $this->loader->getUtil()->getAccessLogActions()->invalidateCache(); + return parent::afterSave($data, $isNew); } public function getAutoSearchElements(MUtil_Model_ModelAbstract $model, array $data) { Added: trunk/library/classes/Gems/Util/AccessLogActions.php =================================================================== --- trunk/library/classes/Gems/Util/AccessLogActions.php (rev 0) +++ trunk/library/classes/Gems/Util/AccessLogActions.php 2011-12-19 12:39:13 UTC (rev 373) @@ -0,0 +1,80 @@ +<?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 Util + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @version $Id: ReceptionCode.php 370 2011-12-19 09:27:19Z mennodekker $ + */ + +/** + * Utility function for caching Gems_AccessLog Actions table. + * + * @package Gems + * @subpackage Util + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @since Class available since version 1.5 + */ +class Gems_Util_AccessLogActions extends Gems_Registry_CachedArrayTargetAbstract +{ + /** + * Variable to add tags to the cache for cleanup. + * + * @var array + */ + protected $_cacheTags = array('accesslog_actions'); + + /** + * + * @var Zend_Db_Adapter_Abstract + */ + protected $db; + + /** + * Returns the complete record. + * + * @return array + */ + public function getAllData() + { + return $this->_data; + } + + /** + * Load the data when the cache is empty. + * + * @param mixed $id + * @return array The array of data values + */ + protected function loadData($id) + { + return $this->db->fetchAssoc('SELECT glac_name, glac_id_action AS id, glac_log AS log FROM gems__log_actions ORDER BY glac_name'); + } +} Modified: trunk/library/classes/Gems/Util/ReceptionCode.php =================================================================== --- trunk/library/classes/Gems/Util/ReceptionCode.php 2011-12-19 10:21:13 UTC (rev 372) +++ trunk/library/classes/Gems/Util/ReceptionCode.php 2011-12-19 12:39:13 UTC (rev 373) @@ -1,5 +1,4 @@ <?php - /** * Copyright (c) 2011, Erasmus MC * All rights reserved. @@ -28,7 +27,7 @@ * * * @package Gems - * @subpackage Ytil + * @subpackage Util * @author Matijs de Jong <mj...@ma...> * @copyright Copyright (c) 2011 Erasmus MC * @license New BSD License Modified: trunk/library/classes/Gems/Util.php =================================================================== --- trunk/library/classes/Gems/Util.php 2011-12-19 10:21:13 UTC (rev 372) +++ trunk/library/classes/Gems/Util.php 2011-12-19 12:39:13 UTC (rev 373) @@ -101,7 +101,18 @@ */ protected $translated; + /** + * Returns the AccessLogActions + * + * @param string $code + * @return Gems_Util_AccessLogActions + */ + public function getAccessLogActions() + { + return $this->_getClass('accessLogActions', null, array('AccessLogActions')); + } + public function getConsentRejected() { if (isset($this->project->concentRejected)) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2011-12-19 15:01:08
|
Revision: 374 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=374&view=rev Author: mennodekker Date: 2011-12-19 15:00:59 +0000 (Mon, 19 Dec 2011) Log Message: ----------- All overview screens (period, token, patient) now show organization dropdown when more than one is allowed - removing pr.plan.choose-org Modified Paths: -------------- trunk/library/classes/Gems/Default/TokenPlanAction.php trunk/library/classes/Gems/Menu.php Modified: trunk/library/classes/Gems/Default/TokenPlanAction.php =================================================================== --- trunk/library/classes/Gems/Default/TokenPlanAction.php 2011-12-19 12:39:13 UTC (rev 373) +++ trunk/library/classes/Gems/Default/TokenPlanAction.php 2011-12-19 15:00:59 UTC (rev 374) @@ -340,10 +340,13 @@ ORDER BY ggp_name"; $elements[] = $this->_createSelectElement('gsu_id_primary_group', $sql, $this->_('(all fillers)')); - if (($this->escort instanceof Gems_Project_Organization_MultiOrganizationInterface) && - $this->escort->hasPrivilege('pr.plan.choose-org')){ - // Select organisation - $options = $this->util->getDbLookup()->getOrganizationsWithRespondents(); + // Select organisation + if (($this->escort instanceof Gems_Project_Organization_MultiOrganizationInterface)) { + $availableOrganizations = $this->util->getDbLookup()->getOrganizationsWithRespondents(); + $allowedOrganizations = $this->loader->getCurrentUser()->getAllowedOrganizations(); + + $options = array_intersect($availableOrganizations, $allowedOrganizations); + $elements[] = $this->_createSelectElement('gto_id_organization', $options); } Modified: trunk/library/classes/Gems/Menu.php =================================================================== --- trunk/library/classes/Gems/Menu.php 2011-12-19 12:39:13 UTC (rev 373) +++ trunk/library/classes/Gems/Menu.php 2011-12-19 15:00:59 UTC (rev 374) @@ -551,7 +551,7 @@ $this->addContactPage($this->_('Contact')); // Privileges not associated with menu item - $this->addHiddenPrivilige('pr.plan.choose-org'); + //$this->addHiddenPrivilige('pr.plan.choose-org'); $this->addHiddenPrivilige('pr.plan.mail-as-application'); $this->addHiddenPrivilige('pr.respondent.result'); $this->addHiddenPrivilige('pr.respondent.who'); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2011-12-19 15:56:17
|
Revision: 375 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=375&view=rev Author: mennodekker Date: 2011-12-19 15:56:11 +0000 (Mon, 19 Dec 2011) Log Message: ----------- Allow the menu parameter filter to be an array of allowed options StaffAction now takes all allowed organizations into account Modified Paths: -------------- trunk/library/classes/Gems/Default/StaffAction.php trunk/library/classes/Gems/Menu/MenuAbstract.php trunk/library/classes/Gems/Menu/SubMenuItem.php Modified: trunk/library/classes/Gems/Default/StaffAction.php =================================================================== --- trunk/library/classes/Gems/Default/StaffAction.php 2011-12-19 15:00:59 UTC (rev 374) +++ trunk/library/classes/Gems/Default/StaffAction.php 2011-12-19 15:56:11 UTC (rev 375) @@ -204,7 +204,7 @@ $model->set('gsf_email', 'label', $this->_('E-Mail'), 'itemDisplay', 'MUtil_Html_AElement::ifmail'); if ($detailed || $this->escort->hasPrivilege('pr.staff.see.all')) { - $this->menu->getParameterSource()->offsetSet('gsf_id_organization', $this->escort->getCurrentOrganization()); + //$this->menu->getParameterSource()->offsetSet('gsf_id_organization', $this->escort->getCurrentOrganization()); $model->set('gsf_id_organization', 'label', $this->_('Organization'), 'multiOptions', $this->util->getDbLookup()->getOrganizations(), Modified: trunk/library/classes/Gems/Menu/MenuAbstract.php =================================================================== --- trunk/library/classes/Gems/Menu/MenuAbstract.php 2011-12-19 15:00:59 UTC (rev 374) +++ trunk/library/classes/Gems/Menu/MenuAbstract.php 2011-12-19 15:56:11 UTC (rev 375) @@ -385,8 +385,8 @@ $editPage = $page->addEditAction(); $delPage = $page->addDeleteAction(); if (! $this->escort->hasPrivilege('pr.staff.edit.all')) { - $editPage->setParameterFilter('gsf_id_organization', $this->escort->getCurrentOrganization()); - $delPage->setParameterFilter('gsf_id_organization', $this->escort->getCurrentOrganization()); + $editPage->setParameterFilter('gsf_id_organization', array_keys($this->escort->loader->getCurrentUser()->getAllowedOrganizations())); + $delPage->setParameterFilter('gsf_id_organization', array_keys($this->escort->loader->getCurrentUser()->getAllowedOrganizations())); } return $page; Modified: trunk/library/classes/Gems/Menu/SubMenuItem.php =================================================================== --- trunk/library/classes/Gems/Menu/SubMenuItem.php 2011-12-19 15:00:59 UTC (rev 374) +++ trunk/library/classes/Gems/Menu/SubMenuItem.php 2011-12-19 15:56:11 UTC (rev 375) @@ -96,6 +96,14 @@ { if ($this->_parameterFilter) { foreach ($this->_parameterFilter as $name => $testValue) { + //Transform single value to array for uniform processing + if (!is_array($testValue)) { + $testArray = array(); + $testArray[] = $testValue; + } else { + $testArray = $testValue; + } + $paramValue = $source->getMenuParameter($name); if ($paramValue instanceof MUtil_Lazy_LazyInterface) { @@ -103,7 +111,8 @@ $paramValue = MUtil_Lazy::rise($paramValue); } else { - $newCondition = MUtil_Lazy::comp($testValue, '==', $paramValue); + $newCondition = new MUtil_Lazy_Call('in_array', array($paramValue, $testArray)); + //$newCondition = MUtil_Lazy::comp($testValue, '==', $paramValue); if ($condition instanceof MUtil_Lazy_LazyInterface) { $condition = $condition->if($newCondition); } else { @@ -113,13 +122,22 @@ } } - if ($testValue !== $paramValue) { - if (Gems_Menu::$verbose) { - // Mutil_Echo::backtrace(); - MUtil_Echo::r($name . ' => ' . $testValue . ' !== ' . $paramValue, $this->get('label') . ' (' . $this->get('controller') . '/' . $this->get('action') . ')'); + + foreach($testArray as $currentTestValue) { + if ($currentTestValue == $paramValue) { + if (Gems_Menu::$verbose) { + // Mutil_Echo::backtrace(); + MUtil_Echo::r($name . ' => ' . $currentTestValue . ' == ' . $paramValue, $this->get('label') . ' (' . $this->get('controller') . '/' . $this->get('action') . ')'); + } + return; + } else { + if (Gems_Menu::$verbose) { + // Mutil_Echo::backtrace(); + MUtil_Echo::r($name . ' => ' . $currentTestValue . ' !== ' . $paramValue, $this->get('label') . ' (' . $this->get('controller') . '/' . $this->get('action') . ')'); + } } - return true; } + return true; } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2011-12-20 10:51:38
|
Revision: 376 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=376&view=rev Author: mennodekker Date: 2011-12-20 10:51:27 +0000 (Tue, 20 Dec 2011) Log Message: ----------- StaffAction now should work right with multiple allowed organizations, sometimes the 'new' option doesn't work right when pr.staff.see.all without pr.staff.edit.all Modified Paths: -------------- trunk/library/classes/Gems/Default/StaffAction.php trunk/library/classes/Gems/Menu/MenuAbstract.php Modified: trunk/library/classes/Gems/Default/StaffAction.php =================================================================== --- trunk/library/classes/Gems/Default/StaffAction.php 2011-12-19 15:56:11 UTC (rev 375) +++ trunk/library/classes/Gems/Default/StaffAction.php 2011-12-20 10:51:27 UTC (rev 376) @@ -1,5 +1,4 @@ <?php - /** * Copyright (c) 2011, Erasmus MC * All rights reserved. @@ -175,8 +174,12 @@ $sql = "SELECT ggp_id_group,ggp_role FROM gems__groups WHERE ggp_id_group = " . (int) $data['gsf_id_primary_group']; $groups = $this->db->fetchPairs($sql); + if (!isset($data['gsf_id_organization']) || empty($data['gsf_id_organization'])) { + $data['gsf_id_organization'] = $this->menu->getParameterSource()->getMenuParameter('gsf_id_organization', $this->loader->getCurrentUser()->getCurrentOrganizationId()); + } + if (! ($this->escort->hasPrivilege('pr.staff.edit.all') || - $data['gsf_id_organization'] == $this->escort->getCurrentOrganization())) { + array_key_exists($data['gsf_id_organization'], $this->loader->getCurrentUser()->getAllowedOrganizations()))) { throw new Zend_Exception($this->_('You are not allowed to edit this staff member.')); } } @@ -203,19 +206,25 @@ 'column_expression', "CONCAT(COALESCE(CONCAT(gsf_last_name, ', '), '-, '), COALESCE(CONCAT(gsf_first_name, ' '), ''), COALESCE(gsf_surname_prefix, ''))"); $model->set('gsf_email', 'label', $this->_('E-Mail'), 'itemDisplay', 'MUtil_Html_AElement::ifmail'); - if ($detailed || $this->escort->hasPrivilege('pr.staff.see.all')) { - //$this->menu->getParameterSource()->offsetSet('gsf_id_organization', $this->escort->getCurrentOrganization()); - - $model->set('gsf_id_organization', 'label', $this->_('Organization'), - 'multiOptions', $this->util->getDbLookup()->getOrganizations(), - 'default', $this->escort->getCurrentOrganization()); + $availableOrganizations = $this->util->getDbLookup()->getOrganizations(); + if ($this->escort->hasPrivilege('pr.staff.see.all')) { + // Select organization + $options = array('' => $this->_('(all organizations)')) + $availableOrganizations; + } else { + $allowedOrganizations = $this->loader->getCurrentUser()->getAllowedOrganizations(); + $options = array_intersect($availableOrganizations, $allowedOrganizations); } + $model->set('gsf_id_organization', 'label', $this->_('Organization'), 'multiOptions', $options); $model->set('gsf_id_primary_group', 'label', $this->_('Primary function'), 'multiOptions', MUtil_Lazy::call($this->util->getDbLookup()->getStaffGroups)); $model->set('gsf_gender', 'label', $this->_('Gender'), 'multiOptions', $this->util->getTranslated()->getGenders()); if ($detailed) { - $model->set('gul_user_class', 'default', $this->defaultStaffDefinition); + //Now try to load the current organization and find out if it has a default user definition + //otherwise use the defaultStaffDefinition + $org = $this->loader->getOrganization($this->menu->getParameterSource()->getMenuParameter('gsf_id_organization', $this->loader->getCurrentUser()->getCurrentOrganizationId())); + $orgDef = $org->get('gor_user_class', $this->defaultStaffDefinition); + $model->set('gul_user_class', 'default', $orgDef); $model->set('gsf_iso_lang', 'label', $this->_('Language'), 'multiOptions', $this->util->getLocalized()->getLanguages()); $model->set('gul_can_login', 'label', $this->_('Can login'), 'multiOptions', $this->util->getTranslated()->getYesNo()); $model->set('gsf_logout_on_survey', 'label', $this->_('Logout on survey'), 'multiOptions', $this->util->getTranslated()->getYesNo()); @@ -230,9 +239,16 @@ { $elements = parent::getAutoSearchElements($model, $data); + $availableOrganizations = $this->util->getDbLookup()->getOrganizations(); if ($this->escort->hasPrivilege('pr.staff.see.all')) { // Select organization - $options = array('' => $this->_('(all organizations)')) + $this->getModel()->get('gsf_id_organization', 'multiOptions'); + $options = array('' => $this->_('(all organizations)')) + $availableOrganizations; + } else { + $allowedOrganizations = $this->loader->getCurrentUser()->getAllowedOrganizations(); + $options = array_intersect($availableOrganizations, $allowedOrganizations); + } + + if (count($options)>1) { $select = new Zend_Form_Element_Select('gsf_id_organization', array('multiOptions' => $options)); // Position as second element @@ -244,22 +260,20 @@ } /** - * Additional data filter statements for the user input. + * Returns the default search values for this class instance. * - * User input that has the same name as a model field is automatically - * used as a filter, but if the name is different processing is needed. - * That processing should happen here. + * Used to specify the filter when no values have been entered by the user. * - * @param array $data The current user input - * @return array New filter statements + * @return array */ - protected function getDataFilter(array $data) + public function getDefaultSearchData() { - $filter = parent::getDataFilter($data); + $filter = parent::getDefaultSearchData(); - if (! $this->escort->hasPrivilege('pr.staff.see.all')) { - $filter['gsf_id_organization'] = $this->escort->getCurrentOrganization(); + if (!isset($filter['gsf_id_organization']) || empty($filter['gsf_id_organization'])) { + $filter['gsf_id_organization'] = $this->loader->getCurrentUser()->getCurrentOrganizationId(); } + return $filter; } @@ -295,4 +309,20 @@ { return $this->_('Staff'); } + + public function init() + { + parent::init(); + + //Make sure the menu always has the gsd_id_organization parameter + $orgId = $this->getRequest()->getParam('gsf_id_organization'); + + if (is_null($orgId)) { + //Get the selected gsf_id_organization used in the index + $dataIdx = $this->getCachedRequestData(true, 'index', true); + $orgId = isset($dataIdx['gsf_id_organization']) ? $dataIdx['gsf_id_organization'] : $this->loader->getCurrentUser()->getCurrentOrganizationId(); + } + + $this->menu->getParameterSource()->offsetSet('gsf_id_organization', $orgId); + } } Modified: trunk/library/classes/Gems/Menu/MenuAbstract.php =================================================================== --- trunk/library/classes/Gems/Menu/MenuAbstract.php 2011-12-19 15:56:11 UTC (rev 375) +++ trunk/library/classes/Gems/Menu/MenuAbstract.php 2011-12-20 10:51:27 UTC (rev 376) @@ -380,13 +380,15 @@ { $page = $this->addPage($label, 'pr.staff', 'staff', 'index', $other); $page->addAutofilterAction(); - $page->addCreateAction(); + $createPage = $page->addCreateAction(); $page->addShowAction(); $editPage = $page->addEditAction(); $delPage = $page->addDeleteAction(); if (! $this->escort->hasPrivilege('pr.staff.edit.all')) { - $editPage->setParameterFilter('gsf_id_organization', array_keys($this->escort->loader->getCurrentUser()->getAllowedOrganizations())); - $delPage->setParameterFilter('gsf_id_organization', array_keys($this->escort->loader->getCurrentUser()->getAllowedOrganizations())); + $filter = array_keys($this->escort->loader->getCurrentUser()->getAllowedOrganizations()); + $createPage->setParameterFilter('gsf_id_organization', $filter); + $editPage->setParameterFilter('gsf_id_organization', $filter); + $delPage->setParameterFilter('gsf_id_organization', $filter); } return $page; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2011-12-22 17:07:27
|
Revision: 388 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=388&view=rev Author: matijsdejong Date: 2011-12-22 17:07:21 +0000 (Thu, 22 Dec 2011) Log Message: ----------- Extra documentation in MenuAbstract.php ProjectSettings.php %s in salt is not required UserLoader.php $currentUser is not always initialized. Modified Paths: -------------- trunk/library/classes/Gems/Menu/MenuAbstract.php trunk/library/classes/Gems/Project/ProjectSettings.php trunk/library/classes/Gems/User/UserLoader.php Modified: trunk/library/classes/Gems/Menu/MenuAbstract.php =================================================================== --- trunk/library/classes/Gems/Menu/MenuAbstract.php 2011-12-22 15:41:40 UTC (rev 387) +++ trunk/library/classes/Gems/Menu/MenuAbstract.php 2011-12-22 17:07:21 UTC (rev 388) @@ -263,8 +263,8 @@ /** * Add a page to the menu * - * @param string $label The label to display for the menu item - * @param string $privilege The privilege for the item + * @param string $label The label to display for the menu item, null for access without display + * @param string $privilege The privilege for the item, null is always, 'pr.islogin' must be logged in, 'pr.nologin' only when not logged in. * @param string $controller What controller to use * @param string $action The name of the action * @param array $other Array of extra options for this item, e.g. 'visible', 'allowed', 'class', 'icon', 'target', 'type', 'button_only' Modified: trunk/library/classes/Gems/Project/ProjectSettings.php =================================================================== --- trunk/library/classes/Gems/Project/ProjectSettings.php 2011-12-22 15:41:40 UTC (rev 387) +++ trunk/library/classes/Gems/Project/ProjectSettings.php 2011-12-22 17:07:21 UTC (rev 388) @@ -166,10 +166,6 @@ throw new Gems_Exception_Coding($error); } - if (strpos($this->offsetGet('salt'), '%s') === false) { - throw new Gems_Exception_Coding("Required project setting 'salt' must contain '%s'."); - } - $superPassword = $this->getSuperAdminPassword(); if ((APPLICATION_ENV === 'production') && $this->getSuperAdminName() && $superPassword) { if (strlen($superPassword) < $this->minimumSuperPasswordLength) { Modified: trunk/library/classes/Gems/User/UserLoader.php =================================================================== --- trunk/library/classes/Gems/User/UserLoader.php 2011-12-22 15:41:40 UTC (rev 387) +++ trunk/library/classes/Gems/User/UserLoader.php 2011-12-22 17:07:21 UTC (rev 388) @@ -1,4 +1,5 @@ <?php + /** * Copyright (c) 2011, Erasmus MC * All rights reserved. @@ -155,7 +156,7 @@ self::USER_STAFF => $this->translate->_('Db storage'), 'RadiusUser' => $this->translate->_('Radius storage') ); - + return $definitions; } @@ -191,7 +192,7 @@ static $organizations = array(); if (null === $organizationId) { - $organizationId = intval(self::$currentUser->getCurrentOrganizationId()); + $organizationId = intval(self::getCurrentUser()->getCurrentOrganizationId()); } if (! isset($organizations[$organizationId])) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2012-01-06 14:02:59
|
Revision: 402 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=402&view=rev Author: mennodekker Date: 2012-01-06 14:02:50 +0000 (Fri, 06 Jan 2012) Log Message: ----------- Fixed parameterCollector to not return empty values and updated doc/debug Modified Paths: -------------- trunk/library/classes/Gems/Menu/ParameterCollector.php trunk/library/classes/Gems/Menu/SubMenuItem.php trunk/library/classes/Gems/Menu.php Modified: trunk/library/classes/Gems/Menu/ParameterCollector.php =================================================================== --- trunk/library/classes/Gems/Menu/ParameterCollector.php 2012-01-06 14:01:17 UTC (rev 401) +++ trunk/library/classes/Gems/Menu/ParameterCollector.php 2012-01-06 14:02:50 UTC (rev 402) @@ -81,7 +81,7 @@ */ public function getMenuParameter($name, $altname = null) { - if (array_key_exists($name, $this->values)) { + if (array_key_exists($name, $this->values) && ! empty($this->values[$name])) { return $this->values[$name]; } @@ -89,7 +89,7 @@ foreach ($this->sources as $source) { if ($source instanceof Zend_Controller_Request_Abstract) { $value = $source->getParam($name, null); - if (null === $value) { + if (null === $value || empty($value)) { $value = $source->getParam($altname, $this->values[$name]); } $this->values[$name] = $value; @@ -106,7 +106,7 @@ $this->values[$name] = $source[$name]; } } - if (null !== $this->values[$name]) { + if (null !== $this->values[$name] && ! empty($this->values[$name])) { break; } } Modified: trunk/library/classes/Gems/Menu/SubMenuItem.php =================================================================== --- trunk/library/classes/Gems/Menu/SubMenuItem.php 2012-01-06 14:01:17 UTC (rev 401) +++ trunk/library/classes/Gems/Menu/SubMenuItem.php 2012-01-06 14:02:50 UTC (rev 402) @@ -153,7 +153,9 @@ if ($this->_parameters && is_array($this->_parameters)) { foreach ($this->_parameters as $param => $name) { $parameters[$param] = $source->getMenuParameter($name, $param); - // MUtil_Echo::r($param . '/' . $name . ' => ' . $value, $this->get('label')); + if (Gems_Menu::$verbose) { + MUtil_Echo::r($param . '/' . $name . ' => ' . $parameters[$param], $this->get('label')); + } } } Modified: trunk/library/classes/Gems/Menu.php =================================================================== --- trunk/library/classes/Gems/Menu.php 2012-01-06 14:01:17 UTC (rev 401) +++ trunk/library/classes/Gems/Menu.php 2012-01-06 14:02:50 UTC (rev 402) @@ -451,7 +451,7 @@ /** * - * @return Gems_Menu_MenuAbstract + * @return Gems_Menu_SubMenuItem */ public function getCurrentParent() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2012-01-24 13:45:30
|
Revision: 419 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=419&view=rev Author: mennodekker Date: 2012-01-24 13:45:19 +0000 (Tue, 24 Jan 2012) Log Message: ----------- Fixed inconsistency with token->getReceptionCode and added __toString to ReceptionCode object for backward compatibility Modified Paths: -------------- trunk/library/classes/Gems/Tracker/Token.php trunk/library/classes/Gems/Util/ReceptionCode.php Modified: trunk/library/classes/Gems/Tracker/Token.php =================================================================== --- trunk/library/classes/Gems/Tracker/Token.php 2012-01-24 11:49:23 UTC (rev 418) +++ trunk/library/classes/Gems/Tracker/Token.php 2012-01-24 13:45:19 UTC (rev 419) @@ -670,12 +670,13 @@ } /** + * Return the Gems_Util_ReceptionCode object * - * @return string reception code + * @return Gems_Util_ReceptionCode reception code */ public function getReceptionCode() { - return $this->_gemsData['gto_reception_code']; + return $this->util->getReceptionCode($this->_gemsData['gto_reception_code']); } /** Modified: trunk/library/classes/Gems/Util/ReceptionCode.php =================================================================== --- trunk/library/classes/Gems/Util/ReceptionCode.php 2012-01-24 11:49:23 UTC (rev 418) +++ trunk/library/classes/Gems/Util/ReceptionCode.php 2012-01-24 13:45:19 UTC (rev 419) @@ -59,6 +59,16 @@ protected $db; /** + * Compatibility mode, for use with logical operators returns this->getCode() + * + * @return string + */ + public function __toString() + { + return $this->getCode(); + } + + /** * Returns the complete record. * * @return array This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2012-02-20 14:13:27
|
Revision: 502 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=502&view=rev Author: mennodekker Date: 2012-02-20 14:13:20 +0000 (Mon, 20 Feb 2012) Log Message: ----------- Updated docblocks Added keywords Modified Paths: -------------- trunk/library/classes/Gems/Controller/Action/Helper/BatchRunner.php trunk/library/classes/Gems/Event/TrackCompletedEventInterface.php trunk/library/classes/Gems/Task/CheckTokenCompletion.php trunk/library/classes/Gems/Task/CheckTrackTokens.php trunk/library/classes/Gems/Task/ProcessTokenCompletion.php trunk/library/classes/Gems/Task/TaskAbstract.php trunk/library/classes/Gems/Task/TaskInterface.php trunk/library/classes/Gems/Task/TaskRunnerBatch.php trunk/library/classes/Gems/Tracker.php trunk/library/classes/Gems/User/RadiusUserDefinition.php trunk/library/classes/Gems/Util/AccessLogActions.php Property Changed: ---------------- trunk/library/classes/Gems/Controller/Action/Helper/BatchRunner.php trunk/library/classes/Gems/Event/TrackCompletedEventInterface.php trunk/library/classes/Gems/Task/CheckTokenCompletion.php trunk/library/classes/Gems/Task/CheckTrackTokens.php trunk/library/classes/Gems/Task/ProcessTokenCompletion.php trunk/library/classes/Gems/Task/TaskAbstract.php trunk/library/classes/Gems/Task/TaskInterface.php trunk/library/classes/Gems/Task/TaskRunnerBatch.php trunk/library/classes/Gems/Tracker/Batch/ProcessTokensBatch.php trunk/library/classes/Gems/Tracker/Batch/RefreshTokenAttributesBatch.php trunk/library/classes/Gems/Tracker/Batch/SynchronizeSourcesBatch.php trunk/library/classes/Gems/Tracker/Snippets/EditTrackEngineSnippetGeneric.php trunk/library/classes/Gems/User/RadiusUserDefinition.php trunk/library/classes/Gems/Util/AccessLogActions.php Modified: trunk/library/classes/Gems/Controller/Action/Helper/BatchRunner.php =================================================================== --- trunk/library/classes/Gems/Controller/Action/Helper/BatchRunner.php 2012-02-20 12:19:38 UTC (rev 501) +++ trunk/library/classes/Gems/Controller/Action/Helper/BatchRunner.php 2012-02-20 14:13:20 UTC (rev 502) @@ -32,7 +32,7 @@ * @subpackage * @copyright Copyright (c) 2011 Erasmus MC * @license New BSD License - * @version $Id: Sample.php 215 2011-07-12 08:52:54Z michiel $ + * @version $Id$ */ /** Property changes on: trunk/library/classes/Gems/Controller/Action/Helper/BatchRunner.php ___________________________________________________________________ Added: svn:keywords + Id Rev Revision Date Author Modified: trunk/library/classes/Gems/Event/TrackCompletedEventInterface.php =================================================================== --- trunk/library/classes/Gems/Event/TrackCompletedEventInterface.php 2012-02-20 12:19:38 UTC (rev 501) +++ trunk/library/classes/Gems/Event/TrackCompletedEventInterface.php 2012-02-20 14:13:20 UTC (rev 502) @@ -29,7 +29,7 @@ * @subpackage Event * @copyright Copyright (c) 2011 Erasmus MC * @license New BSD License - * @version $Id: Sample.php 215 2011-07-12 08:52:54Z michiel $ + * @version $Id$ */ /** Property changes on: trunk/library/classes/Gems/Event/TrackCompletedEventInterface.php ___________________________________________________________________ Added: svn:keywords + Id Rev Revision Date Author Modified: trunk/library/classes/Gems/Task/CheckTokenCompletion.php =================================================================== --- trunk/library/classes/Gems/Task/CheckTokenCompletion.php 2012-02-20 12:19:38 UTC (rev 501) +++ trunk/library/classes/Gems/Task/CheckTokenCompletion.php 2012-02-20 14:13:20 UTC (rev 502) @@ -24,27 +24,25 @@ * 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 + * @subpackage Task * @copyright Copyright (c) 2011 Erasmus MC * @license New BSD License - * @version $Id: Sample.php 215 2011-07-12 08:52:54Z michiel $ + * @version $Id$ */ /** - * Short description for ProcessTokens + * Check token completion in a batch job * - * Long description for class ProcessTokens (if any)... + * This task handles the token completion check, adding tasks to the queue + * when needed. * * @package Gems - * @subpackage Sample + * @subpackage Task * @copyright Copyright (c) 2011 Erasmus MC * @license New BSD License - * @since Class available since version 1.0 - * @deprecated Class deprecated since version 2.0 + * @since Class available since version 1.6 */ class Gems_Task_CheckTokenCompletion extends Gems_Task_TaskAbstract { Property changes on: trunk/library/classes/Gems/Task/CheckTokenCompletion.php ___________________________________________________________________ Added: svn:keywords + Id Rev Revision Date Author Modified: trunk/library/classes/Gems/Task/CheckTrackTokens.php =================================================================== --- trunk/library/classes/Gems/Task/CheckTrackTokens.php 2012-02-20 12:19:38 UTC (rev 501) +++ trunk/library/classes/Gems/Task/CheckTrackTokens.php 2012-02-20 14:13:20 UTC (rev 502) @@ -25,27 +25,22 @@ * 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 + * @subpackage Task * @copyright Copyright (c) 2011 Erasmus MC * @license New BSD License - * @version $Id: Sample.php 215 2011-07-12 08:52:54Z michiel $ + * @version $Id$ */ /** - * Short description for CheckTrackTokens + * Checks a respondentTrack for changes, mostly started by Gems_Task_ProcessTokenCompletion * - * Long description for class CheckTrackTokens (if any)... - * * @package Gems - * @subpackage Sample + * @subpackage Task * @copyright Copyright (c) 2011 Erasmus MC * @license New BSD License - * @since Class available since version 1.0 - * @deprecated Class deprecated since version 2.0 + * @since Class available since version 1.6 */ class Gems_Task_CheckTrackTokens extends Gems_Task_TaskAbstract { Property changes on: trunk/library/classes/Gems/Task/CheckTrackTokens.php ___________________________________________________________________ Added: svn:keywords + Id Rev Revision Date Author Modified: trunk/library/classes/Gems/Task/ProcessTokenCompletion.php =================================================================== --- trunk/library/classes/Gems/Task/ProcessTokenCompletion.php 2012-02-20 12:19:38 UTC (rev 501) +++ trunk/library/classes/Gems/Task/ProcessTokenCompletion.php 2012-02-20 14:13:20 UTC (rev 502) @@ -25,27 +25,22 @@ * 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 + * @subpackage Task * @copyright Copyright (c) 2011 Erasmus MC * @license New BSD License - * @version $Id: Sample.php 215 2011-07-12 08:52:54Z michiel $ + * @version $Id$ */ /** - * Short description for ProcessTokenCompletion + * Handles completion of a token, mostly started by Gems_Task_CheckTokenCompletion * - * Long description for class ProcessTokenCompletion (if any)... - * * @package Gems - * @subpackage Sample + * @subpackage Task * @copyright Copyright (c) 2011 Erasmus MC * @license New BSD License - * @since Class available since version 1.0 - * @deprecated Class deprecated since version 2.0 + * @since Class available since version 1.6 */ class Gems_Task_ProcessTokenCompletion extends Gems_Task_TaskAbstract { @@ -54,7 +49,6 @@ */ public $tracker; - public function execute($tokenData = null, $userId = null) { $this->tracker = $this->loader->getTracker(); Property changes on: trunk/library/classes/Gems/Task/ProcessTokenCompletion.php ___________________________________________________________________ Added: svn:keywords + Id Rev Revision Date Author Modified: trunk/library/classes/Gems/Task/TaskAbstract.php =================================================================== --- trunk/library/classes/Gems/Task/TaskAbstract.php 2012-02-20 12:19:38 UTC (rev 501) +++ trunk/library/classes/Gems/Task/TaskAbstract.php 2012-02-20 14:13:20 UTC (rev 502) @@ -25,27 +25,24 @@ * 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 + * @subpackage Task * @copyright Copyright (c) 2011 Erasmus MC * @license New BSD License - * @version $Id: Sample.php 215 2011-07-12 08:52:54Z michiel $ + * @version $Id$ */ /** - * Short description for TaskAbstract + * Abstract class for easier implementation of the Gems_Task for usage with + * Gems_Task_TaskRunnerBatch providing some convenience methods to loading and + * translation. * - * Long description for class TaskAbstract (if any)... - * * @package Gems - * @subpackage Sample + * @subpackage Task * @copyright Copyright (c) 2011 Erasmus MC * @license New BSD License - * @since Class available since version 1.0 - * @deprecated Class deprecated since version 2.0 + * @since Class available since version 1.6 */ abstract class Gems_Task_TaskAbstract extends MUtil_Registry_TargetAbstract implements Gems_Task_TaskInterface { @@ -55,11 +52,6 @@ protected $_batch; /** - * @var array - */ - protected $_params; - - /** * @var Gems_Loader */ public $loader; @@ -73,4 +65,12 @@ { $this->_batch = $batch; } + + /** + * Should handle execution of the task, taking as much (optional) parameters as needed + * + * The parameters should be optional and failing to provide them should be handled by + * the task + */ + abstract public function execute(); } \ No newline at end of file Property changes on: trunk/library/classes/Gems/Task/TaskAbstract.php ___________________________________________________________________ Added: svn:keywords + Id Rev Revision Date Author Modified: trunk/library/classes/Gems/Task/TaskInterface.php =================================================================== --- trunk/library/classes/Gems/Task/TaskInterface.php 2012-02-20 12:19:38 UTC (rev 501) +++ trunk/library/classes/Gems/Task/TaskInterface.php 2012-02-20 14:13:20 UTC (rev 502) @@ -26,30 +26,37 @@ * (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 + * @subpackage Task * @copyright Copyright (c) 2011 Erasmus MC * @license New BSD License - * @version $Id: Sample.php 215 2011-07-12 08:52:54Z michiel $ + * @version $Id$ */ /** - * Short description for TaskAbstract + * Describes the interface for a Gems_Task * - * Long description for class TaskAbstract (if any)... - * * @package Gems - * @subpackage Sample + * @subpackage Task * @copyright Copyright (c) 2011 Erasmus MC * @license New BSD License - * @since Class available since version 1.0 - * @deprecated Class deprecated since version 2.0 + * @since Class available since version 1.6 */ interface Gems_Task_TaskInterface { + /** + * Should handle execution of the task, taking as much (optional) parameters as needed + * + * The parameters should be optional and failing to provide them should be handled by + * the task + */ public function execute(); - + + /** + * Sets the batch this task belongs to + * + * This method will be called from the Gems_Task_TaskRunnerBatch upon execution of the + * task. It allows the task to communicate with the batch queue. + */ public function setBatch(Gems_Task_TaskRunnerBatch $batch); } \ No newline at end of file Property changes on: trunk/library/classes/Gems/Task/TaskInterface.php ___________________________________________________________________ Added: svn:keywords + Id Rev Revision Date Author Modified: trunk/library/classes/Gems/Task/TaskRunnerBatch.php =================================================================== --- trunk/library/classes/Gems/Task/TaskRunnerBatch.php 2012-02-20 12:19:38 UTC (rev 501) +++ trunk/library/classes/Gems/Task/TaskRunnerBatch.php 2012-02-20 14:13:20 UTC (rev 502) @@ -25,27 +25,27 @@ * 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 + * @subpackage Task * @copyright Copyright (c) 2011 Erasmus MC * @license New BSD License - * @version $Id: Sample.php 215 2011-07-12 08:52:54Z michiel $ + * @version $Id$ */ /** - * Short description for TaskRunnerBatch + * Handles running tasks independent on the kind of task * - * Long description for class TaskRunnerBatch (if any)... + * Continues on the MUtil_Batch_BatchAbstract, exposing some methods to allow the task + * to interact with the batch queue. * + * Tasks added to the queue should be loadable via Gems_Loader and implement the Gems_Task_TaskInterface + * * @package Gems - * @subpackage Sample + * @subpackage Task * @copyright Copyright (c) 2011 Erasmus MC * @license New BSD License - * @since Class available since version 1.0 - * @deprecated Class deprecated since version 2.0 + * @since Class available since version 1.6 */ class Gems_Task_TaskRunnerBatch extends MUtil_Batch_BatchAbstract { Property changes on: trunk/library/classes/Gems/Task/TaskRunnerBatch.php ___________________________________________________________________ Added: svn:keywords + Id Rev Revision Date Author Property changes on: trunk/library/classes/Gems/Tracker/Batch/ProcessTokensBatch.php ___________________________________________________________________ Added: svn:keywords + Id Rev Revision Date Author Property changes on: trunk/library/classes/Gems/Tracker/Batch/RefreshTokenAttributesBatch.php ___________________________________________________________________ Added: svn:keywords + Id Rev Revision Date Author Property changes on: trunk/library/classes/Gems/Tracker/Batch/SynchronizeSourcesBatch.php ___________________________________________________________________ Added: svn:keywords + Id Rev Revision Date Author Property changes on: trunk/library/classes/Gems/Tracker/Snippets/EditTrackEngineSnippetGeneric.php ___________________________________________________________________ Added: svn:keywords + Id Rev Revision Date Author Modified: trunk/library/classes/Gems/Tracker.php =================================================================== --- trunk/library/classes/Gems/Tracker.php 2012-02-20 12:19:38 UTC (rev 501) +++ trunk/library/classes/Gems/Tracker.php 2012-02-20 14:13:20 UTC (rev 502) @@ -841,13 +841,15 @@ * @param string $batch_id A unique identifier for the current batch * @param Gems_Tracker_Token_TokenSelect Select statements selecting tokens * @param int $userId Id of the user who takes the action (for logging) - * @return Gems_Tracker_Batch_ProcessTokensBatch A batch to process the changes + * @return Gems_Task_TaskRunnerBatch A batch to process the changes */ protected function processTokensBatch($batch_id, Gems_Tracker_Token_TokenSelect $tokenSelect, $userId) { $where = implode(' ', $tokenSelect->getSelect()->getPart(Zend_Db_Select::WHERE)); $batch = $this->loader->getTaskRunnerBatch($batch_id); + //Now set the step duration + $batch->minimalStepDurationMs = 3000; if (! $batch->isLoaded()) { $statement = $tokenSelect->getSelect()->query(); @@ -859,18 +861,6 @@ } } - /* - $batch = $this->_loadClass('Batch_ProcessTokensBatch', true, array($batch_id)); - - 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()) { - $batch->addToken($tokenData['gto_id_token'], $userId); - } - } - */ - return $batch; } @@ -917,7 +907,7 @@ * @param string $batch_id A unique identifier for the current batch * @param int $userId Id of the user who takes the action (for logging) * @param string $cond - * @return Gems_Tracker_Batch_ProcessTokensBatch A batch to process the changes + * @return Gems_Task_TaskRunnerBatch A batch to process the changes */ public function recalculateTokensBatch($batch_id, $userId = null, $cond = null) { Modified: trunk/library/classes/Gems/User/RadiusUserDefinition.php =================================================================== --- trunk/library/classes/Gems/User/RadiusUserDefinition.php 2012-02-20 12:19:38 UTC (rev 501) +++ trunk/library/classes/Gems/User/RadiusUserDefinition.php 2012-02-20 14:13:20 UTC (rev 502) @@ -29,7 +29,7 @@ * @subpackage User * @copyright Copyright (c) 2011 Erasmus MC * @license New BSD License - * @version $Id: RadiusUserDefinition.php 228 2011-12-21 09:39:34Z 175780 $ + * @version $Id$ */ /** Property changes on: trunk/library/classes/Gems/User/RadiusUserDefinition.php ___________________________________________________________________ Added: svn:keywords + Id Rev Revision Date Author Modified: trunk/library/classes/Gems/Util/AccessLogActions.php =================================================================== --- trunk/library/classes/Gems/Util/AccessLogActions.php 2012-02-20 12:19:38 UTC (rev 501) +++ trunk/library/classes/Gems/Util/AccessLogActions.php 2012-02-20 14:13:20 UTC (rev 502) @@ -30,7 +30,7 @@ * @subpackage Util * @copyright Copyright (c) 2011 Erasmus MC * @license New BSD License - * @version $Id: ReceptionCode.php 370 2011-12-19 09:27:19Z mennodekker $ + * @version $Id$ */ /** Property changes on: trunk/library/classes/Gems/Util/AccessLogActions.php ___________________________________________________________________ Added: svn:keywords + Id Rev Revision Date Author This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2012-02-23 12:27:00
|
Revision: 512 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=512&view=rev Author: matijsdejong Date: 2012-02-23 12:26:49 +0000 (Thu, 23 Feb 2012) Log Message: ----------- Added respondent creation and initial password to core Modified Paths: -------------- trunk/library/classes/Gems/Project/ProjectSettings.php trunk/library/classes/Gems/User/UserLoader.php Modified: trunk/library/classes/Gems/Project/ProjectSettings.php =================================================================== --- trunk/library/classes/Gems/Project/ProjectSettings.php 2012-02-23 10:52:42 UTC (rev 511) +++ trunk/library/classes/Gems/Project/ProjectSettings.php 2012-02-23 12:26:49 UTC (rev 512) @@ -242,7 +242,22 @@ return -1; } + /** + * Returns the initial password specified for users - if any. + * + * @return String + */ + public function getInitialPassword() + { + if (isset($this['password']['initialPassword'])) { + return $this['password']['initialPassword']; + } else { + return null; + } + } + + /** * Returns the public name of this project. * @return string */ @@ -341,4 +356,14 @@ return md5($salted, false); } + + /** + * True if an initial password was specified for users. + * + * @return boolean + */ + public function hasInitialPassword() + { + return isset($this['password']['initialPassword']); + } } Modified: trunk/library/classes/Gems/User/UserLoader.php =================================================================== --- trunk/library/classes/Gems/User/UserLoader.php 2012-02-23 10:52:42 UTC (rev 511) +++ trunk/library/classes/Gems/User/UserLoader.php 2012-02-23 12:26:49 UTC (rev 512) @@ -132,6 +132,33 @@ } /** + * Returns a user object, that may be empty if no user exist. + * + * @param string $login_name + * @param int $organization + * @param string $userClassName + * @param int $userId The person creating the user. + * @return Gems_User_User Newly created + */ + public function createUser($login_name, $organization, $userClassName, $userId) + { + $now = new Zend_Db_Expr('CURRENT_TIMESTAMP'); + + $values['gul_login'] = $login_name; + $values['gul_id_organization'] = $organization; + $values['gul_user_class'] = $userClassName; + $values['gul_can_login'] = 1; + $values['gul_changed'] = $now; + $values['gul_changed_by'] = $userId; + $values['gul_created'] = $now; + $values['gul_created_by'] = $userId; + + $this->db->insert('gems__user_logins', $values); + + return $this->getUser($login_name, $organization); + } + + /** * Get userclass / description array of available UserDefinitions for respondents * * @return array @@ -216,7 +243,7 @@ * Returns a user object, that may be empty if no user exist. * * @param string $login_name - * @param int $organization + * @param int $currentOrganization * @return Gems_User_User But ! ->isActive when the user does not exist */ public function getUser($login_name, $currentOrganization) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2012-02-29 15:17:44
|
Revision: 518 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=518&view=rev Author: mennodekker Date: 2012-02-29 15:17:37 +0000 (Wed, 29 Feb 2012) Log Message: ----------- Started on porting to upgrade system to be able to run tasks, CreateNewTables should still be split into smaller tasks Modified Paths: -------------- trunk/library/classes/Gems/Default/UpgradeAction.php trunk/library/classes/Gems/Task/TaskRunnerBatch.php trunk/library/classes/Gems/Upgrades.php trunk/library/classes/Gems/UpgradesAbstract.php Added Paths: ----------- trunk/library/classes/Gems/Task/CleanCache.php trunk/library/classes/Gems/Task/CreateNewTables.php trunk/library/classes/Gems/Task/Echo.php trunk/library/classes/Gems/Task/ExecutePatch.php Modified: trunk/library/classes/Gems/Default/UpgradeAction.php =================================================================== --- trunk/library/classes/Gems/Default/UpgradeAction.php 2012-02-29 09:56:41 UTC (rev 517) +++ trunk/library/classes/Gems/Default/UpgradeAction.php 2012-02-29 15:17:37 UTC (rev 518) @@ -84,16 +84,16 @@ $this->html->h3(sprintf($this->_('Upgrading %s'), $context)); - $this->_upgrades->execute($context, $to, $from); - $messages = $this->_upgrades->getMessages(); - foreach($messages as $message) { - $this->html->p($message); + $batch = $this->loader->getTaskRunnerBatch('upgrade' . $context); + $batch->minimalStepDurationMs = 0; + + if (!$batch->isLoaded()) { + $this->_upgrades->setBatch($batch); + $this->_upgrades->execute($context, $to, $from); } - if ($menuItem = $this->menu->find(array('controller' => $this->_getParam('controller'), 'action' => 'show', 'allowed' => true))) { - $this->html->br(); - $this->html[] = $menuItem->toActionLinkLower($this->getRequest(), array('id'=>$context), $this->_('Back')); - } + $title = $this->_('Performing upgrade'); + $this->_helper->BatchRunner($batch, $title); } /** Added: trunk/library/classes/Gems/Task/CleanCache.php =================================================================== --- trunk/library/classes/Gems/Task/CleanCache.php (rev 0) +++ trunk/library/classes/Gems/Task/CleanCache.php 2012-02-29 15:17:37 UTC (rev 518) @@ -0,0 +1,61 @@ +<?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 Task + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @version $Id: CheckTokenCompletion.php 502 2012-02-20 14:13:20Z mennodekker $ + */ + +/** + * Cleans the cache during a batch job + * + * Normally when performing certain upgrades you need to clean the cache. When you use + * this task you can schedule this too. Normally using ->setTask('CleanCache', 'clean') + * will be sufficient as we only need to run the cache cleaning once. for immidiate cache + * cleaning, for example when the next task depends on it, perform the actions below + * in your own task. + * + * @package Gems + * @subpackage Task + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @since Class available since version 1.6 + */ +class Gems_Task_CleanCache extends Gems_Task_TaskAbstract +{ + public function execute($text = null) + { + $cache = GemsEscort::getInstance()->cache; + + if ($cache instanceof Zend_Cache_Core) { + $cache->clean(); + $this->_batch->addMessage($this->translate->_('Cache cleaned')); + } + } +} Added: trunk/library/classes/Gems/Task/CreateNewTables.php =================================================================== --- trunk/library/classes/Gems/Task/CreateNewTables.php (rev 0) +++ trunk/library/classes/Gems/Task/CreateNewTables.php 2012-02-29 15:17:37 UTC (rev 518) @@ -0,0 +1,112 @@ +<?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 Task + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @version $Id: CheckTokenCompletion.php 502 2012-02-20 14:13:20Z mennodekker $ + */ + +/** + * Execute a certain patchlevel + * + * Cleans the cache when patches where executed + * + * @package Gems + * @subpackage Task + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @since Class available since version 1.6 + */ +class Gems_Task_CreateNewTables extends Gems_Task_TaskAbstract +{ + /** + * @var Zend_Db_Adapter_Abstract + */ + public $db; + + /** + * @var Gems_Model_DbaModel + */ + public $dbaModel; + + /** + * @var GemsEscort + */ + public $escort; + + /** + * @var Gems_Project_ProjectSettings + */ + public $project; + + public function execute() + { + //Now create all new tables + $todo = $this->dbaModel->load(array('state'=> Gems_Model_DbaModel::STATE_DEFINED)); + $i = 1; + $oCount = count($todo); + $results = array(); + foreach($todo as $tableData) { + $result = $this->dbaModel->runScript($tableData); + $results = array_merge($results, $result); + $results[] = sprintf($this->translate->_('Finished %s creation script for object %d of %d'), $this->translate->_(strtolower($tableData['type'])), $i, $oCount) . '<br/>'; + $i++; + } + + foreach ($results as $result) + { + $this->_batch->addMessage($result); + } + + if (count($results)>0) { + //Perform a clean cache only when needed + $this->_batch->setTask('CleanCache', 'cleancache'); //If already scheduled, don't reschedule + } + } + + /** + * Now we have the requests answered, add the DatabasePatcher as it needs the db object + * + * @return boolean + */ + public function checkRegistryRequestsAnswers() { + $this->escort = GemsEscort::getInstance(); + + //Load the dbaModel + $paths = $this->escort->getDatabasePaths(); + $model = new Gems_Model_DbaModel($this->db, array_values($paths)); + $model->setLocations(array_keys($paths)); + if ($this->project->databaseFileEncoding) { + $model->setFileEncoding($this->project->databaseFileEncoding); + } + $this->dbaModel = $model; + + return true; + } +} \ No newline at end of file Added: trunk/library/classes/Gems/Task/Echo.php =================================================================== --- trunk/library/classes/Gems/Task/Echo.php (rev 0) +++ trunk/library/classes/Gems/Task/Echo.php 2012-02-29 15:17:37 UTC (rev 518) @@ -0,0 +1,50 @@ +<?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 Task + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @version $Id: CheckTokenCompletion.php 502 2012-02-20 14:13:20Z mennodekker $ + */ + +/** + * Just echo a string during a batch job + * + * @package Gems + * @subpackage Task + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @since Class available since version 1.6 + */ +class Gems_Task_Echo extends Gems_Task_TaskAbstract +{ + public function execute($text = null) + { + $this->_batch->addMessage($text); + } +} \ No newline at end of file Added: trunk/library/classes/Gems/Task/ExecutePatch.php =================================================================== --- trunk/library/classes/Gems/Task/ExecutePatch.php (rev 0) +++ trunk/library/classes/Gems/Task/ExecutePatch.php 2012-02-29 15:17:37 UTC (rev 518) @@ -0,0 +1,92 @@ +<?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 Task + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @version $Id: CheckTokenCompletion.php 502 2012-02-20 14:13:20Z mennodekker $ + */ + +/** + * Execute a certain patchlevel + * + * Cleans the cache when patches where executed + * + * @package Gems + * @subpackage Task + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @since Class available since version 1.6 + */ +class Gems_Task_ExecutePatch extends Gems_Task_TaskAbstract +{ + /** + * @var Zend_Db_Adapter_Abstract + */ + public $db; + + /** + * @var GemsEscort + */ + public $escort; + + /** + * + * @var Gems_Util_DatabasePatcher + */ + public $patcher; + + public function execute($patchLevel = null, $ignoreCompleted = true, $ignoreExecuted = false) + { + $this->_batch->addMessage(sprintf($this->translate->_('Executing patchlevel %d'), $patchLevel)); + $result = $this->patcher->executePatch($patchLevel, $ignoreCompleted, $ignoreExecuted); + $this->_batch->addMessage($this->translate->_(sprintf('Executed %s patches', $result))); + + if ($result>0) { + //Perform a clean cache only when needed + $this->_batch->setTask('CleanCache', 'cleancache'); //If already scheduled, don't reschedule + } + } + + /** + * Now we have the requests answered, add the DatabasePatcher as it needs the db object + * + * @return boolean + */ + public function checkRegistryRequestsAnswers() { + $this->escort = GemsEscort::getInstance(); + + //As an upgrade almost always includes executing db patches, make a DatabasePatcher object available + $this->patcher = new Gems_Util_DatabasePatcher($this->db, 'patches.sql', $this->escort->getDatabasePaths()); + + //Now load all patches, and save the resulting changed patches for later (not used yet) + $changed = $this->patcher->uploadPatches($this->loader->getVersions()->getBuild()); + + return true; + } +} \ No newline at end of file Modified: trunk/library/classes/Gems/Task/TaskRunnerBatch.php =================================================================== --- trunk/library/classes/Gems/Task/TaskRunnerBatch.php 2012-02-29 09:56:41 UTC (rev 517) +++ trunk/library/classes/Gems/Task/TaskRunnerBatch.php 2012-02-29 15:17:37 UTC (rev 518) @@ -103,8 +103,12 @@ { $params = array_slice(func_get_args(), 1); $taskClass = $this->loader->getTask($task); - $taskClass->setBatch($this); - call_user_func_array(array($taskClass, 'execute'), $params[0]); + if ($taskClass instanceof Gems_Task_TaskInterface) { + $taskClass->setBatch($this); + call_user_func_array(array($taskClass, 'execute'), $params[0]); + } else { + throw new Gems_Exception(sprintf('ERROR: Task by name %s not found', $task)); + } } /** Modified: trunk/library/classes/Gems/Upgrades.php =================================================================== --- trunk/library/classes/Gems/Upgrades.php 2012-02-29 09:56:41 UTC (rev 517) +++ trunk/library/classes/Gems/Upgrades.php 2012-02-29 15:17:37 UTC (rev 518) @@ -67,18 +67,11 @@ */ public function Upgrade143to15() { - $this->addMessage(sprintf($this->_('Executing patchlevel %d'),42)); - $this->patcher->executePatch(42); - $this->addMessage(sprintf($this->_('Executing patchlevel %d'),43)); - $this->patcher->executePatch(43); + $this->_batch->addTask('ExecutePatch', 42); + $this->_batch->addTask('ExecutePatch', 43); - $this->invalidateCache(); + $this->_batch->addTask('CreateNewTables'); - $this->addMessage($this->_('Creating new tables')); - $this->createNewTables(); - - $this->invalidateCache(); - $this->addMessage($this->_('Syncing surveys for all sources')); //Now sync the db sources to allow limesurvey source to add a field to the tokentable $model = new MUtil_Model_TableModel('gems__sources'); @@ -106,11 +99,8 @@ */ public function Upgrade15to151() { - $this->addMessage(sprintf($this->_('Executing patchlevel %d'),44)); - $this->patcher->executePatch(44); - - $this->invalidateCache(); - + $this->_batch->addTask('ExecutePatch', 44); + return true; } } \ No newline at end of file Modified: trunk/library/classes/Gems/UpgradesAbstract.php =================================================================== --- trunk/library/classes/Gems/UpgradesAbstract.php 2012-02-29 09:56:41 UTC (rev 517) +++ trunk/library/classes/Gems/UpgradesAbstract.php 2012-02-29 15:17:37 UTC (rev 518) @@ -54,6 +54,11 @@ protected $upgradeFile; /** + * @var Gems_Task_TaskRunnerBatch + */ + protected $_batch; + + /** * @var Zend_Config_Ini */ protected $_info; @@ -426,6 +431,16 @@ } /** + * Set the batch to use + * + * @param Gems_Task_TaskRunnerBatch $batch + */ + public function setBatch($batch) + { + $this->_batch = $batch; + } + + /** * Change the active context * * Usefull when adding upgrades in the construct to save typing This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2012-02-29 15:44:14
|
Revision: 519 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=519&view=rev Author: mennodekker Date: 2012-02-29 15:44:03 +0000 (Wed, 29 Feb 2012) Log Message: ----------- CreateNewTables split into smaller tasks and a little cleanup on messages Modified Paths: -------------- trunk/library/classes/Gems/Default/UpgradeAction.php trunk/library/classes/Gems/Task/CreateNewTables.php trunk/library/classes/Gems/Task/ExecutePatch.php Added Paths: ----------- trunk/library/classes/Gems/Task/CreateNewTable.php Modified: trunk/library/classes/Gems/Default/UpgradeAction.php =================================================================== --- trunk/library/classes/Gems/Default/UpgradeAction.php 2012-02-29 15:17:37 UTC (rev 518) +++ trunk/library/classes/Gems/Default/UpgradeAction.php 2012-02-29 15:44:03 UTC (rev 519) @@ -82,17 +82,15 @@ $from = $this->getRequest()->getParam('from'); $to = $this->getRequest()->getParam('to'); - $this->html->h3(sprintf($this->_('Upgrading %s'), $context)); - $batch = $this->loader->getTaskRunnerBatch('upgrade' . $context); - $batch->minimalStepDurationMs = 0; + $batch->minimalStepDurationMs = 0; //One step at a time, can be higher to improve speed if (!$batch->isLoaded()) { $this->_upgrades->setBatch($batch); $this->_upgrades->execute($context, $to, $from); } - $title = $this->_('Performing upgrade'); + $title = sprintf($this->_('Upgrading %s'), $context); $this->_helper->BatchRunner($batch, $title); } Added: trunk/library/classes/Gems/Task/CreateNewTable.php =================================================================== --- trunk/library/classes/Gems/Task/CreateNewTable.php (rev 0) +++ trunk/library/classes/Gems/Task/CreateNewTable.php 2012-02-29 15:44:03 UTC (rev 519) @@ -0,0 +1,104 @@ +<?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 Task + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @version $Id: CheckTokenCompletion.php 502 2012-02-20 14:13:20Z mennodekker $ + */ + +/** + * Create a single new table + * + * Cleans the cache when a new tables was created + * + * @package Gems + * @subpackage Task + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @since Class available since version 1.6 + */ +class Gems_Task_CreateNewTable extends Gems_Task_TaskAbstract +{ + /** + * @var Zend_Db_Adapter_Abstract + */ + public $db; + + /** + * @var Gems_Model_DbaModel + */ + public $dbaModel; + + /** + * @var GemsEscort + */ + public $escort; + + /** + * @var Gems_Project_ProjectSettings + */ + public $project; + + public function execute($tableData = array()) + { + $this->_batch->addToCounter('createTableStep'); + + $result = $this->dbaModel->runScript($tableData); + $result[] = sprintf($this->translate->_('Finished %s creation script for object %d of %d'), $this->translate->_(strtolower($tableData['type'])), $this->_batch->getCounter('createTableStep'), $this->_batch->getCounter('NewTableCount')) . '<br/>'; + + if (count($result)>0) { + foreach ($result as $result) + { + $this->_batch->addMessage($result); + } + //Perform a clean cache only when needed + $this->_batch->setTask('CleanCache', 'cleancache'); //If already scheduled, don't reschedule + } + } + + /** + * Now we have the requests answered, add the DatabasePatcher as it needs the db object + * + * @return boolean + */ + public function checkRegistryRequestsAnswers() { + $this->escort = GemsEscort::getInstance(); + + //Load the dbaModel + $paths = $this->escort->getDatabasePaths(); + $model = new Gems_Model_DbaModel($this->db, array_values($paths)); + $model->setLocations(array_keys($paths)); + if ($this->project->databaseFileEncoding) { + $model->setFileEncoding($this->project->databaseFileEncoding); + } + $this->dbaModel = $model; + + return true; + } +} \ No newline at end of file Modified: trunk/library/classes/Gems/Task/CreateNewTables.php =================================================================== --- trunk/library/classes/Gems/Task/CreateNewTables.php 2012-02-29 15:17:37 UTC (rev 518) +++ trunk/library/classes/Gems/Task/CreateNewTables.php 2012-02-29 15:44:03 UTC (rev 519) @@ -33,10 +33,8 @@ */ /** - * Execute a certain patchlevel + * Schedules creation of new tables * - * Cleans the cache when patches where executed - * * @package Gems * @subpackage Task * @copyright Copyright (c) 2011 Erasmus MC @@ -69,25 +67,11 @@ { //Now create all new tables $todo = $this->dbaModel->load(array('state'=> Gems_Model_DbaModel::STATE_DEFINED)); - $i = 1; - $oCount = count($todo); - $results = array(); + foreach($todo as $tableData) { - $result = $this->dbaModel->runScript($tableData); - $results = array_merge($results, $result); - $results[] = sprintf($this->translate->_('Finished %s creation script for object %d of %d'), $this->translate->_(strtolower($tableData['type'])), $i, $oCount) . '<br/>'; - $i++; + $this->_batch->addToCounter('NewTableCount'); + $this->_batch->setTask('CreateNewTable', 'create-tbl-' . $tableData['name'], $tableData); } - - foreach ($results as $result) - { - $this->_batch->addMessage($result); - } - - if (count($results)>0) { - //Perform a clean cache only when needed - $this->_batch->setTask('CleanCache', 'cleancache'); //If already scheduled, don't reschedule - } } /** Modified: trunk/library/classes/Gems/Task/ExecutePatch.php =================================================================== --- trunk/library/classes/Gems/Task/ExecutePatch.php 2012-02-29 15:17:37 UTC (rev 518) +++ trunk/library/classes/Gems/Task/ExecutePatch.php 2012-02-29 15:44:03 UTC (rev 519) @@ -65,7 +65,7 @@ { $this->_batch->addMessage(sprintf($this->translate->_('Executing patchlevel %d'), $patchLevel)); $result = $this->patcher->executePatch($patchLevel, $ignoreCompleted, $ignoreExecuted); - $this->_batch->addMessage($this->translate->_(sprintf('Executed %s patches', $result))); + $this->_batch->addMessage($this->translate->_(sprintf('%d patch(es) executed.', $result))); if ($result>0) { //Perform a clean cache only when needed This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2012-03-01 09:22:50
|
Revision: 520 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=520&view=rev Author: mennodekker Date: 2012-03-01 09:22:39 +0000 (Thu, 01 Mar 2012) Log Message: ----------- Added final upgrade step to be a task Modified Paths: -------------- trunk/library/classes/Gems/Upgrades.php Added Paths: ----------- trunk/library/classes/Gems/Task/SourceSyncSurveys.php Added: trunk/library/classes/Gems/Task/SourceSyncSurveys.php =================================================================== --- trunk/library/classes/Gems/Task/SourceSyncSurveys.php (rev 0) +++ trunk/library/classes/Gems/Task/SourceSyncSurveys.php 2012-03-01 09:22:39 UTC (rev 520) @@ -0,0 +1,61 @@ +<?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 Task + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @version $Id: Sample.php 215 2011-07-12 08:52:54Z michiel $ + */ + +/** + * Executes the syncSurveys method for a given sourceId + * + * @package Gems + * @subpackage Task + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @since Class available since version 1.6 + */ +class Gems_Task_SourceSyncSurveys +{ + /** + * @var Gems_Tracker + */ + public $tracker; + + public function execute($id = null) + { + $source = $tracker->getSource($id); + + if ($messages = $source->synchronizeSurveys($this->loader->getCurrentUser()->getUserId())) { + foreach ($messages as $message) { + $this->_batch->addMessage($message); + } + } + } +} \ No newline at end of file Modified: trunk/library/classes/Gems/Upgrades.php =================================================================== --- trunk/library/classes/Gems/Upgrades.php 2012-02-29 15:44:03 UTC (rev 519) +++ trunk/library/classes/Gems/Upgrades.php 2012-03-01 09:22:39 UTC (rev 520) @@ -73,6 +73,7 @@ $this->_batch->addTask('CreateNewTables'); $this->addMessage($this->_('Syncing surveys for all sources')); + //Now sync the db sources to allow limesurvey source to add a field to the tokentable $model = new MUtil_Model_TableModel('gems__sources'); $data = $model->load(false); @@ -80,13 +81,7 @@ $tracker = $this->loader->getTracker(); foreach ($data as $row) { - $source = $tracker->getSource($row['gso_id_source']); - - if ($messages = $source->synchronizeSurveys($this->loader->getCurrentUser()->getUserId())) { - foreach ($messages as $message) { - $this->addMessage($message); - } - } + $this->_batch->addTask('SourceSyncSurveys', $row['gso_id_source']); } $this->invalidateCache(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2012-03-01 13:22:46
|
Revision: 526 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=526&view=rev Author: mennodekker Date: 2012-03-01 13:22:33 +0000 (Thu, 01 Mar 2012) Log Message: ----------- Moving to a better directory structure + some cleanup. TODO: replace the two remaining Tracker\Batch classess with tasks Modified Paths: -------------- trunk/library/classes/Gems/Task/Db/CreateNewTable.php trunk/library/classes/Gems/Task/Db/CreateNewTables.php trunk/library/classes/Gems/Tracker/TrackerInterface.php trunk/library/classes/Gems/Tracker.php trunk/library/classes/Gems/Upgrades.php Added Paths: ----------- trunk/library/classes/Gems/Task/Db/ExecutePatch.php trunk/library/classes/Gems/Task/Tracker/ trunk/library/classes/Gems/Task/Tracker/CheckTokenCompletion.php trunk/library/classes/Gems/Task/Tracker/CheckTrackTokens.php trunk/library/classes/Gems/Task/Tracker/ProcessTokenCompletion.php trunk/library/classes/Gems/Task/Tracker/SourceSyncSurveys.php Removed Paths: ------------- trunk/library/classes/Gems/Task/CheckTokenCompletion.php trunk/library/classes/Gems/Task/CheckTrackTokens.php trunk/library/classes/Gems/Task/ExecutePatch.php trunk/library/classes/Gems/Task/ProcessTokenCompletion.php trunk/library/classes/Gems/Task/SourceSyncSurveys.php trunk/library/classes/Gems/Tracker/Batch/ProcessTokensBatch.php Deleted: trunk/library/classes/Gems/Task/CheckTokenCompletion.php =================================================================== --- trunk/library/classes/Gems/Task/CheckTokenCompletion.php 2012-03-01 12:08:30 UTC (rev 525) +++ trunk/library/classes/Gems/Task/CheckTokenCompletion.php 2012-03-01 13:22:33 UTC (rev 526) @@ -1,83 +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 Task - * @copyright Copyright (c) 2011 Erasmus MC - * @license New BSD License - * @version $Id$ - */ - -/** - * Check token completion in a batch job - * - * This task handles the token completion check, adding tasks to the queue - * when needed. - * - * @package Gems - * @subpackage Task - * @copyright Copyright (c) 2011 Erasmus MC - * @license New BSD License - * @since Class available since version 1.6 - */ -class Gems_Task_CheckTokenCompletion extends Gems_Task_TaskAbstract -{ - /** - * @var Gems_Tracker - */ - public $tracker; - - public function execute($tokenData = null, $userId = null) - { - $this->tracker = $this->loader->getTracker(); - $this->_batch->addToCounter('checkedTokens'); - $token = $this->tracker->getToken($tokenData); - - if ($result = $token->checkTokenCompletion($userId)) { - if ($result & Gems_Tracker_Token::COMPLETION_DATACHANGE) { - $this->_batch->addToCounter('resultDataChanges'); - } - if ($result & Gems_Tracker_Token::COMPLETION_EVENTCHANGE) { - $this->_batch->addToCounter('surveyCompletionChanges'); - } - } - - if ($token->isCompleted()) { - $this->_batch->setTask('processTokenCompletion', 'tokproc-' . $token->getTokenId(), $tokenData, $userId); - } - - if ($this->_batch->getCounter('surveyCompletionChanges')) { - $this->_batch->setMessage('surveyCompletionChanges', sprintf($this->translate->_('Answers changed by survey completion event for %d tokens.'), $this->_batch->getCounter('surveyCompletionChanges'))); - } - - if ($this->_batch->getCounter('resultDataChanges')) { - $this->_batch->setMessage('resultDataChanges', sprintf($this->translate->_('Results and timing changed for %d tokens.'), $this->_batch->getCounter('resultDataChanges'))); - } - - $this->_batch->setMessage('checkedTokens', sprintf($this->translate->_('Checked %d tokens.'), $this->_batch->getCounter('checkedTokens'))); - } -} \ No newline at end of file Deleted: trunk/library/classes/Gems/Task/CheckTrackTokens.php =================================================================== --- trunk/library/classes/Gems/Task/CheckTrackTokens.php 2012-03-01 12:08:30 UTC (rev 525) +++ trunk/library/classes/Gems/Task/CheckTrackTokens.php 2012-03-01 13:22:33 UTC (rev 526) @@ -1,69 +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 Task - * @copyright Copyright (c) 2011 Erasmus MC - * @license New BSD License - * @version $Id$ - */ - -/** - * Checks a respondentTrack for changes, mostly started by Gems_Task_ProcessTokenCompletion - * - * @package Gems - * @subpackage Task - * @copyright Copyright (c) 2011 Erasmus MC - * @license New BSD License - * @since Class available since version 1.6 - */ -class Gems_Task_CheckTrackTokens extends Gems_Task_TaskAbstract -{ - /** - * @var Gems_Tracker - */ - public $tracker; - - public function execute($respTrackData = null, $userId = null) - { - $this->tracker = $this->loader->getTracker(); - $respTrack = $this->tracker->getRespondentTrack($respTrackData); - $this->_batch->addToCounter('checkedRespondentTracks'); - - if ($result = $respTrack->checkTrackTokens($userId)) { - $this->_batch->addToCounter('tokenDateCauses'); - $this->_batch->addToCounter('tokenDateChanges', $result); - } - - if ($this->_batch->getCounter('tokenDateChanges')) { - $this->_batch->setMessage('tokenDateChanges', sprintf($this->translate->_('%2$d token date changes in %1$d tracks.'), $this->_batch->getCounter('tokenDateCauses'), $this->_batch->getCounter('tokenDateChanges'))); - } - - $this->_batch->setMessage('checkedRespondentTracks', sprintf($this->translate->_('Checked %d tracks.'), $this->_batch->getCounter('checkedRespondentTracks'))); - } -} \ No newline at end of file Modified: trunk/library/classes/Gems/Task/Db/CreateNewTable.php =================================================================== --- trunk/library/classes/Gems/Task/Db/CreateNewTable.php 2012-03-01 12:08:30 UTC (rev 525) +++ trunk/library/classes/Gems/Task/Db/CreateNewTable.php 2012-03-01 13:22:33 UTC (rev 526) @@ -26,7 +26,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * @package Gems - * @subpackage Task + * @subpackage Task_Db * @copyright Copyright (c) 2011 Erasmus MC * @license New BSD License * @version $Id: CheckTokenCompletion.php 502 2012-02-20 14:13:20Z mennodekker $ @@ -38,7 +38,7 @@ * Cleans the cache when a new tables was created * * @package Gems - * @subpackage Task + * @subpackage Task_Db * @copyright Copyright (c) 2011 Erasmus MC * @license New BSD License * @since Class available since version 1.6 Modified: trunk/library/classes/Gems/Task/Db/CreateNewTables.php =================================================================== --- trunk/library/classes/Gems/Task/Db/CreateNewTables.php 2012-03-01 12:08:30 UTC (rev 525) +++ trunk/library/classes/Gems/Task/Db/CreateNewTables.php 2012-03-01 13:22:33 UTC (rev 526) @@ -26,7 +26,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * @package Gems - * @subpackage Task + * @subpackage Task_Db * @copyright Copyright (c) 2011 Erasmus MC * @license New BSD License * @version $Id: CheckTokenCompletion.php 502 2012-02-20 14:13:20Z mennodekker $ @@ -36,7 +36,7 @@ * Schedules creation of new tables * * @package Gems - * @subpackage Task + * @subpackage Task_Db * @copyright Copyright (c) 2011 Erasmus MC * @license New BSD License * @since Class available since version 1.6 Added: trunk/library/classes/Gems/Task/Db/ExecutePatch.php =================================================================== --- trunk/library/classes/Gems/Task/Db/ExecutePatch.php (rev 0) +++ trunk/library/classes/Gems/Task/Db/ExecutePatch.php 2012-03-01 13:22:33 UTC (rev 526) @@ -0,0 +1,92 @@ +<?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 Task_Db + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @version $Id: CheckTokenCompletion.php 502 2012-02-20 14:13:20Z mennodekker $ + */ + +/** + * Execute a certain patchlevel + * + * Cleans the cache when patches where executed + * + * @package Gems + * @subpackage Task_Db + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @since Class available since version 1.6 + */ +class Gems_Task_Db_ExecutePatch extends Gems_Task_TaskAbstract +{ + /** + * @var Zend_Db_Adapter_Abstract + */ + public $db; + + /** + * @var GemsEscort + */ + public $escort; + + /** + * + * @var Gems_Util_DatabasePatcher + */ + public $patcher; + + public function execute($patchLevel = null, $ignoreCompleted = true, $ignoreExecuted = false) + { + $this->_batch->addMessage(sprintf($this->translate->_('Executing patchlevel %d'), $patchLevel)); + $result = $this->patcher->executePatch($patchLevel, $ignoreCompleted, $ignoreExecuted); + $this->_batch->addMessage(sprintf($this->translate->_('%d patch(es) executed.'), $result)); + + if ($result>0) { + //Perform a clean cache only when needed + $this->_batch->setTask('CleanCache', 'cleancache'); //If already scheduled, don't reschedule + } + } + + /** + * Now we have the requests answered, add the DatabasePatcher as it needs the db object + * + * @return boolean + */ + public function checkRegistryRequestsAnswers() { + $this->escort = GemsEscort::getInstance(); + + //As an upgrade almost always includes executing db patches, make a DatabasePatcher object available + $this->patcher = new Gems_Util_DatabasePatcher($this->db, 'patches.sql', $this->escort->getDatabasePaths()); + + //Now load all patches, and save the resulting changed patches for later (not used yet) + $changed = $this->patcher->uploadPatches($this->loader->getVersions()->getBuild()); + + return true; + } +} \ No newline at end of file Deleted: trunk/library/classes/Gems/Task/ExecutePatch.php =================================================================== --- trunk/library/classes/Gems/Task/ExecutePatch.php 2012-03-01 12:08:30 UTC (rev 525) +++ trunk/library/classes/Gems/Task/ExecutePatch.php 2012-03-01 13:22:33 UTC (rev 526) @@ -1,92 +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 Task - * @copyright Copyright (c) 2011 Erasmus MC - * @license New BSD License - * @version $Id: CheckTokenCompletion.php 502 2012-02-20 14:13:20Z mennodekker $ - */ - -/** - * Execute a certain patchlevel - * - * Cleans the cache when patches where executed - * - * @package Gems - * @subpackage Task - * @copyright Copyright (c) 2011 Erasmus MC - * @license New BSD License - * @since Class available since version 1.6 - */ -class Gems_Task_ExecutePatch extends Gems_Task_TaskAbstract -{ - /** - * @var Zend_Db_Adapter_Abstract - */ - public $db; - - /** - * @var GemsEscort - */ - public $escort; - - /** - * - * @var Gems_Util_DatabasePatcher - */ - public $patcher; - - public function execute($patchLevel = null, $ignoreCompleted = true, $ignoreExecuted = false) - { - $this->_batch->addMessage(sprintf($this->translate->_('Executing patchlevel %d'), $patchLevel)); - $result = $this->patcher->executePatch($patchLevel, $ignoreCompleted, $ignoreExecuted); - $this->_batch->addMessage($this->translate->_(sprintf('%d patch(es) executed.', $result))); - - if ($result>0) { - //Perform a clean cache only when needed - $this->_batch->setTask('CleanCache', 'cleancache'); //If already scheduled, don't reschedule - } - } - - /** - * Now we have the requests answered, add the DatabasePatcher as it needs the db object - * - * @return boolean - */ - public function checkRegistryRequestsAnswers() { - $this->escort = GemsEscort::getInstance(); - - //As an upgrade almost always includes executing db patches, make a DatabasePatcher object available - $this->patcher = new Gems_Util_DatabasePatcher($this->db, 'patches.sql', $this->escort->getDatabasePaths()); - - //Now load all patches, and save the resulting changed patches for later (not used yet) - $changed = $this->patcher->uploadPatches($this->loader->getVersions()->getBuild()); - - return true; - } -} \ No newline at end of file Deleted: trunk/library/classes/Gems/Task/ProcessTokenCompletion.php =================================================================== --- trunk/library/classes/Gems/Task/ProcessTokenCompletion.php 2012-03-01 12:08:30 UTC (rev 525) +++ trunk/library/classes/Gems/Task/ProcessTokenCompletion.php 2012-03-01 13:22:33 UTC (rev 526) @@ -1,73 +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 Task - * @copyright Copyright (c) 2011 Erasmus MC - * @license New BSD License - * @version $Id$ - */ - -/** - * Handles completion of a token, mostly started by Gems_Task_CheckTokenCompletion - * - * @package Gems - * @subpackage Task - * @copyright Copyright (c) 2011 Erasmus MC - * @license New BSD License - * @since Class available since version 1.6 - */ -class Gems_Task_ProcessTokenCompletion extends Gems_Task_TaskAbstract -{ - /** - * @var Gems_Tracker - */ - public $tracker; - - public function execute($tokenData = null, $userId = null) - { - $this->tracker = $this->loader->getTracker(); - $token = $this->tracker->getToken($tokenData); - - if ($token->isCompleted()) { - $respTrack = $token->getRespondentTrack(); - - if ($result = $respTrack->handleRoundCompletion($token, $userId)) { - $this->_batch->addToCounter('roundCompletionCauses'); - $this->_batch->addToCounter('roundCompletionChanges', $result); - } - - $trackId = $respTrack->getRespondentTrackId(); - $this->_batch->setTask('checkTrackTokens', 'chktrck-' . $trackId, $trackId, $userId); - } - - if ($this->_batch->getCounter('roundCompletionChanges')) { - $this->_batch->setMessage('roundCompletionChanges', sprintf($this->translate->_('%d token round completion events caused changed to %d tokens.'), $this->_batch->getCounter('roundCompletionCauses'), $this->_batch->getCounter('roundCompletionChanges'))); - } - } -} \ No newline at end of file Deleted: trunk/library/classes/Gems/Task/SourceSyncSurveys.php =================================================================== --- trunk/library/classes/Gems/Task/SourceSyncSurveys.php 2012-03-01 12:08:30 UTC (rev 525) +++ trunk/library/classes/Gems/Task/SourceSyncSurveys.php 2012-03-01 13:22:33 UTC (rev 526) @@ -1,56 +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 Task - * @copyright Copyright (c) 2011 Erasmus MC - * @license New BSD License - * @version $Id: Sample.php 215 2011-07-12 08:52:54Z michiel $ - */ - -/** - * Executes the syncSurveys method for a given sourceId - * - * @package Gems - * @subpackage Task - * @copyright Copyright (c) 2011 Erasmus MC - * @license New BSD License - * @since Class available since version 1.6 - */ -class Gems_Task_SourceSyncSurveys extends Gems_Task_TaskAbstract -{ - public function execute($id = null) - { - $source = $this->loader->getTracker()->getSource($id); - - if ($messages = $source->synchronizeSurveys($this->loader->getCurrentUser()->getUserId())) { - foreach ($messages as $message) { - $this->_batch->addMessage($message); - } - } - } -} \ No newline at end of file Added: trunk/library/classes/Gems/Task/Tracker/CheckTokenCompletion.php =================================================================== --- trunk/library/classes/Gems/Task/Tracker/CheckTokenCompletion.php (rev 0) +++ trunk/library/classes/Gems/Task/Tracker/CheckTokenCompletion.php 2012-03-01 13:22:33 UTC (rev 526) @@ -0,0 +1,83 @@ +<?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 TaskTracker + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @version $Id: CheckTokenCompletion.php 502 2012-02-20 14:13:20Z mennodekker $ + */ + +/** + * Check token completion in a batch job + * + * This task handles the token completion check, adding tasks to the queue + * when needed. + * + * @package Gems + * @subpackage Task_Tracker + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @since Class available since version 1.6 + */ +class Gems_Task_Tracker_CheckTokenCompletion extends Gems_Task_TaskAbstract +{ + /** + * @var Gems_Tracker + */ + public $tracker; + + public function execute($tokenData = null, $userId = null) + { + $this->tracker = $this->loader->getTracker(); + $this->_batch->addToCounter('checkedTokens'); + $token = $this->tracker->getToken($tokenData); + + if ($result = $token->checkTokenCompletion($userId)) { + if ($result & Gems_Tracker_Token::COMPLETION_DATACHANGE) { + $this->_batch->addToCounter('resultDataChanges'); + } + if ($result & Gems_Tracker_Token::COMPLETION_EVENTCHANGE) { + $this->_batch->addToCounter('surveyCompletionChanges'); + } + } + + if ($token->isCompleted()) { + $this->_batch->setTask('Tracker_ProcessTokenCompletion', 'tokproc-' . $token->getTokenId(), $tokenData, $userId); + } + + if ($this->_batch->getCounter('surveyCompletionChanges')) { + $this->_batch->setMessage('surveyCompletionChanges', sprintf($this->translate->_('Answers changed by survey completion event for %d tokens.'), $this->_batch->getCounter('surveyCompletionChanges'))); + } + + if ($this->_batch->getCounter('resultDataChanges')) { + $this->_batch->setMessage('resultDataChanges', sprintf($this->translate->_('Results and timing changed for %d tokens.'), $this->_batch->getCounter('resultDataChanges'))); + } + + $this->_batch->setMessage('checkedTokens', sprintf($this->translate->_('Checked %d tokens.'), $this->_batch->getCounter('checkedTokens'))); + } +} \ No newline at end of file Added: trunk/library/classes/Gems/Task/Tracker/CheckTrackTokens.php =================================================================== --- trunk/library/classes/Gems/Task/Tracker/CheckTrackTokens.php (rev 0) +++ trunk/library/classes/Gems/Task/Tracker/CheckTrackTokens.php 2012-03-01 13:22:33 UTC (rev 526) @@ -0,0 +1,69 @@ +<?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 Task_Tracker + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @version $Id: CheckTrackTokens.php 502 2012-02-20 14:13:20Z mennodekker $ + */ + +/** + * Checks a respondentTrack for changes, mostly started by Gems_Task_ProcessTokenCompletion + * + * @package Gems + * @subpackage Task_Tracker + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @since Class available since version 1.6 + */ +class Gems_Task_Tracker_CheckTrackTokens extends Gems_Task_TaskAbstract +{ + /** + * @var Gems_Tracker + */ + public $tracker; + + public function execute($respTrackData = null, $userId = null) + { + $this->tracker = $this->loader->getTracker(); + $respTrack = $this->tracker->getRespondentTrack($respTrackData); + $this->_batch->addToCounter('checkedRespondentTracks'); + + if ($result = $respTrack->checkTrackTokens($userId)) { + $this->_batch->addToCounter('tokenDateCauses'); + $this->_batch->addToCounter('tokenDateChanges', $result); + } + + if ($this->_batch->getCounter('tokenDateChanges')) { + $this->_batch->setMessage('tokenDateChanges', sprintf($this->translate->_('%2$d token date changes in %1$d tracks.'), $this->_batch->getCounter('tokenDateCauses'), $this->_batch->getCounter('tokenDateChanges'))); + } + + $this->_batch->setMessage('checkedRespondentTracks', sprintf($this->translate->_('Checked %d tracks.'), $this->_batch->getCounter('checkedRespondentTracks'))); + } +} \ No newline at end of file Added: trunk/library/classes/Gems/Task/Tracker/ProcessTokenCompletion.php =================================================================== --- trunk/library/classes/Gems/Task/Tracker/ProcessTokenCompletion.php (rev 0) +++ trunk/library/classes/Gems/Task/Tracker/ProcessTokenCompletion.php 2012-03-01 13:22:33 UTC (rev 526) @@ -0,0 +1,73 @@ +<?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 Task_Tracker + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @version $Id: ProcessTokenCompletion.php 502 2012-02-20 14:13:20Z mennodekker $ + */ + +/** + * Handles completion of a token, mostly started by Gems_Task_CheckTokenCompletion + * + * @package Gems + * @subpackage Task_Tracker + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @since Class available since version 1.6 + */ +class Gems_Task_Tracker_ProcessTokenCompletion extends Gems_Task_TaskAbstract +{ + /** + * @var Gems_Tracker + */ + public $tracker; + + public function execute($tokenData = null, $userId = null) + { + $this->tracker = $this->loader->getTracker(); + $token = $this->tracker->getToken($tokenData); + + if ($token->isCompleted()) { + $respTrack = $token->getRespondentTrack(); + + if ($result = $respTrack->handleRoundCompletion($token, $userId)) { + $this->_batch->addToCounter('roundCompletionCauses'); + $this->_batch->addToCounter('roundCompletionChanges', $result); + } + + $trackId = $respTrack->getRespondentTrackId(); + $this->_batch->setTask('Tracker_CheckTrackTokens', 'chktrck-' . $trackId, $trackId, $userId); + } + + if ($this->_batch->getCounter('roundCompletionChanges')) { + $this->_batch->setMessage('roundCompletionChanges', sprintf($this->translate->_('%d token round completion events caused changed to %d tokens.'), $this->_batch->getCounter('roundCompletionCauses'), $this->_batch->getCounter('roundCompletionChanges'))); + } + } +} \ No newline at end of file Added: trunk/library/classes/Gems/Task/Tracker/SourceSyncSurveys.php =================================================================== --- trunk/library/classes/Gems/Task/Tracker/SourceSyncSurveys.php (rev 0) +++ trunk/library/classes/Gems/Task/Tracker/SourceSyncSurveys.php 2012-03-01 13:22:33 UTC (rev 526) @@ -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 Task_Tracker + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @version $Id: Sample.php 215 2011-07-12 08:52:54Z michiel $ + */ + +/** + * Executes the syncSurveys method for a given sourceId + * + * @package Gems + * @subpackage Task_Tracker + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @since Class available since version 1.6 + */ +class Gems_Task_Tracker_SourceSyncSurveys extends Gems_Task_TaskAbstract +{ + public function execute($id = null, $userId = null) + { + $source = $this->loader->getTracker()->getSource($id); + + if (is_null($userId)) { + $userId = $this->loader->getCurrentUser()->getUserId(); + } + + if ($messages = $source->synchronizeSurveys($userId)) { + foreach ($messages as $message) { + $this->_batch->addMessage($message); + } + } + } +} \ No newline at end of file Deleted: trunk/library/classes/Gems/Tracker/Batch/ProcessTokensBatch.php =================================================================== --- trunk/library/classes/Gems/Tracker/Batch/ProcessTokensBatch.php 2012-03-01 12:08:30 UTC (rev 525) +++ trunk/library/classes/Gems/Tracker/Batch/ProcessTokensBatch.php 2012-03-01 13:22:33 UTC (rev 526) @@ -1,248 +0,0 @@ -<?php - -/** - * Copyright (c) 2012, Erasmus MC - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of Erasmus MC nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * - * @package Gems - * @subpackage Tracker - * @author Matijs de Jong <mj...@ma...> - * @copyright Copyright (c) 2012 Erasmus MC - * @license New BSD License - * @version $Id$ - */ - -/** - * - * - * @package Gems - * @subpackage Tracker - * @copyright Copyright (c) 2012 Erasmus MC - * @license New BSD License - * @since Class available since version 1.5 - */ -class Gems_Tracker_Batch_ProcessTokensBatch extends MUtil_Batch_BatchAbstract -{ - /** - * - * @var Gems_Tracker - */ - protected $tracker; - - /** - * - * @var Zend_Translate - */ - protected $translate; - - /** - * Set a little higher, to reduce the effect of the server response time and application startup - */ - public $minimalStepDurationMs = 3000; - - /** - * Add the check of a single token to the batch. - * - * @param mixed $tokenData Array or token id - * @param int $userId Gems user id - * @return Gems_Tracker_Batch_ProcessTokensBatch (Continuation pattern) - */ - public function addToken($tokenData, $userId) - { - if (is_array($tokenData)) { - if (!isset($tokenData['gto_id_token'])) { - throw new Gems_Exception_Coding('$tokenData array should atleast have a key "gto_id_token" containing the requested token'); - } - $tokenId = $tokenData['gto_id_token']; - } else { - $tokenId = $tokenData; - } - - // MUtil_Echo::track($tokenData); - $this->setStep('checkTokenCompletion', 'tokchk-' . $tokenId, $tokenId, $userId); - $this->addToCounter('tokens'); - - return $this; - } - - /** - * Check a single track for the effects of token completion. - * - * @param mixed $respTrackData Data array or a respondent track id - * @param int $userId Gems user id - */ - protected function checkTrackTokens($respTrackData, $userId) - { - $respTrack = $this->tracker->getRespondentTrack($respTrackData); - - if ($result = $respTrack->checkTrackTokens($userId)) { - $this->addToCounter('tokenDateCauses'); - $this->addToCounter('tokenDateChanges', $result); - } - } - - /** - * Check for token completion and adds the processTokenCompletion - * command when the token is indeed completed. - * - * NOTE: The reasons to add the extra commands in this process are - * (1) that we are not sure in advance for which tokens we should - * process and (2) the processing commands should be executed - * AFTER all tokens have been checked for completion. - * - * @param mixed $tokenData Array or token id - * @param int $userId Gems user id - */ - protected function checkTokenCompletion($tokenData, $userId) - { - $this->addToCounter('checkedTokens'); - $token = $this->tracker->getToken($tokenData); - - if ($result = $token->checkTokenCompletion($userId)) { - if ($result & Gems_Tracker_Token::COMPLETION_DATACHANGE) { - $this->addToCounter('resultDataChanges'); - } - if ($result & Gems_Tracker_Token::COMPLETION_EVENTCHANGE) { - $this->addToCounter('surveyCompletionChanges'); - } - } - - if ($token->isCompleted()) { - $this->setStep('processTokenCompletion', 'tokproc-' . $token->getTokenId(), $tokenData, $userId); - } - } - - /** - * Returns a description of what was changed during this batch. - * - * @return array Of message strings - */ - public function getCounterMessages() - { - if ($this->getCounter('checkedRespondentTracks')) { - $messages[] = sprintf($this->translate->_('Checked %d tracks.'), $this->getCounter('checkedRespondentTracks')); - } - if ($this->getCounter('checkedTokens') || (! $this->getCounter('checkedRespondentTracks'))) { - $messages[] = sprintf($this->translate->_('Checked %d tokens.'), $this->getCounter('checkedTokens')); - } - - if ($this->hasChanged()) { - if ($this->getCounter('surveyCompletionChanges')) { - $messages[] = sprintf($this->translate->_('Answers changed by survey completion event for %d tokens.'), $this->getCounter('surveyCompletionChanges')); - } - if ($this->getCounter('resultDataChanges')) { - $messages[] = sprintf($this->translate->_('Results and timing changed for %d tokens.'), $this->getCounter('resultDataChanges')); - } - if ($this->getCounter('roundCompletionChanges')) { - $messages[] = sprintf($this->translate->_('%d token round completion events caused changed to %d tokens.'), $this->getCounter('roundCompletionCauses'), $this->getCounter('roundCompletionChanges')); - } - if ($this->getCounter('tokenDateChanges')) { - $messages[] = sprintf($this->translate->_('%2$d token date changes in %1$d tracks.'), $this->getCounter('tokenDateCauses'), $this->getCounter('tokenDateChanges')); - } - if ($this->getCounter('roundChangeUpdates')) { - $messages[] = sprintf($this->translate->_('Round changes propagated to %d tokens.'), $this->getCounter('roundChangeUpdates')); - } - if ($this->getCounter('deletedTokens')) { - $messages[] = sprintf($this->translate->_('%d tokens deleted by round changes.'), $this->getCounter('deletedTokens')); - } - if ($this->getCounter('createdTokens')) { - $messages[] = sprintf($this->translate->_('%d tokens created to by round changes.'), $this->getCounter('createdTokens')); - } - } else { - $messages[] = $this->translate->_('No tokens were changed.'); - } - - return $messages; - } - - /** - * String of messages from the batch - * - * Do not forget to reset() the batch if you're done with it after - * displaying the report. - * - * @param boolean $reset When true the batch is reset afterwards - * @return array - */ - public function getMessages($reset = false) - { - return array_merge($this->getCounterMessages(), parent::getMessages($reset)); - } - - /** - * The number of tokens to check - * - * @return int - */ - public function getTokenCount() - { - return $this->getCounter('tokens'); - } - - /** - * True when the batch changed anything. - * - * @return boolean - */ - public function hasChanged() - { - return $this->getCounter('resultDataChanges') || - $this->getCounter('surveyCompletionChanges') || - $this->getCounter('roundCompletionChanges') || - $this->getCounter('tokenDateCauses') || - $this->getCounter('roundChangeUpdates') || - $this->getCounter('createdTokens'); - } - - /** - * Processes token completion and adds the checkTrackTokens - * command when the token is indeed completed. - * - * NOTE: The reasons we add the checkTrackTokens command are - * that (1) we do not know in advance which tracks to check - * and (2) the tracks should be checked AFTER all tokens have - * been processed. - * - * @param mixed $tokenData Array or token id - * @param int $userId Gems user id - */ - protected function processTokenCompletion($tokenData, $userId) - { - $token = $this->tracker->getToken($tokenData); - - if ($token->isCompleted()) { - $respTrack = $token->getRespondentTrack(); - - if ($result = $respTrack->handleRoundCompletion($token, $userId)) { - $this->addToCounter('roundCompletionCauses'); - $this->addToCounter('roundCompletionChanges', $result); - } - - $trackId = $respTrack->getRespondentTrackId(); - $this->setStep('checkTrackTokens', 'chktrck-' . $trackId, $trackId, $userId); - } - } -} Modified: trunk/library/classes/Gems/Tracker/TrackerInterface.php =================================================================== --- trunk/library/classes/Gems/Tracker/TrackerInterface.php 2012-03-01 12:08:30 UTC (rev 525) +++ trunk/library/classes/Gems/Tracker/TrackerInterface.php 2012-03-01 13:22:33 UTC (rev 526) @@ -298,7 +298,7 @@ * @param string $batch_id A unique identifier for the current batch * @param int $userId Id of the user who takes the action (for logging) * @param string $cond - * @return Gems_Tracker_Batch_ProcessTokensBatch A batch to process the changes + * @return Gems_Task_TaskRunnerBatch A batch to process the changes */ public function recalculateTokensBatch($batch_id, $userId = null, $cond = null); @@ -307,7 +307,7 @@ * * @param string $batch_id A unique identifier for the current batch * @param string $cond An optional where statement - * @return Gems_Tracker_Batch_ProcessTokensBatch A batch to process the changes + * @return Gems_Task_TaskRunnerBatch A batch to process the changes */ public function refreshTokenAttributesBatch($batch_id, $cond = null); } Modified: trunk/library/classes/Gems/Tracker.php =================================================================== --- trunk/library/classes/Gems/Tracker.php 2012-03-01 12:08:30 UTC (rev 525) +++ trunk/library/classes/Gems/Tracker.php 2012-03-01 13:22:33 UTC (rev 526) @@ -856,7 +856,7 @@ //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('checkTokenCompletion', 'tokchk-' . $tokenId, $tokenId, $userId); + $batch->setTask('Tracker_CheckTokenCompletion', 'tokchk-' . $tokenId, $tokenId, $userId); $batch->addToCounter('tokens'); } } @@ -933,7 +933,7 @@ * * @param string $batch_id A unique identifier for the current batch * @param string $cond An optional where statement - * @return Gems_Tracker_Batch_ProcessTokensBatch A batch to process the changes + * @return Gems_Tracker_Batch_RefreshTokenAttributesBatch A batch to process the changes */ public function refreshTokenAttributesBatch($batch_id, $cond = null) { Modified: trunk/library/classes/Gems/Upgrades.php =================================================================== --- trunk/library/classes/Gems/Upgrades.php 2012-03-01 12:08:30 UTC (rev 525) +++ trunk/library/classes/Gems/Upgrades.php 2012-03-01 13:22:33 UTC (rev 526) @@ -67,20 +67,19 @@ */ public function Upgrade143to15() { - $this->_batch->addTask('ExecutePatch', 42); - $this->_batch->addTask('ExecutePatch', 43); + $this->_batch->addTask('Db_ExecutePatch', 42); + $this->_batch->addTask('Db_ExecutePatch', 43); $this->_batch->addTask('Db_CreateNewTables'); $this->_batch->addTask('Echo', $this->_('Syncing surveys for all sources')); - //Now sync the db sources to allow limesurvey source to add a field to the tokentable $model = new MUtil_Model_TableModel('gems__sources'); $data = $model->load(false); foreach ($data as $row) { - $this->_batch->addTask('SourceSyncSurveys', $row['gso_id_source']); + $this->_batch->addTask('Tracker_SourceSyncSurveys', $row['gso_id_source']); } return true; @@ -91,7 +90,7 @@ */ public function Upgrade15to151() { - $this->_batch->addTask('ExecutePatch', 44); + $this->_batch->addTask('Db_ExecutePatch', 44); return true; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2012-03-01 13:46:54
|
Revision: 527 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=527&view=rev Author: mennodekker Date: 2012-03-01 13:46:43 +0000 (Thu, 01 Mar 2012) Log Message: ----------- Ported RefreshTokenAttributesBatch to the Task system Modified Paths: -------------- trunk/library/classes/Gems/Tracker.php Added Paths: ----------- trunk/library/classes/Gems/Task/Tracker/RefreshTokenAttributes.php Removed Paths: ------------- trunk/library/classes/Gems/Tracker/Batch/RefreshTokenAttributesBatch.php Added: trunk/library/classes/Gems/Task/Tracker/RefreshTokenAttributes.php =================================================================== --- trunk/library/classes/Gems/Task/Tracker/RefreshTokenAttributes.php (rev 0) +++ trunk/library/classes/Gems/Task/Tracker/RefreshTokenAttributes.php 2012-03-01 13:46:43 UTC (rev 527) @@ -0,0 +1,69 @@ +<?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 Task_Tracker + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @version $Id: ProcessTokenCompletion.php 502 2012-02-20 14:13:20Z mennodekker $ + */ + +/** + * Refresh the attributes of the token + * + * @package Gems + * @subpackage Task_Tracker + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @since Class available since version 1.6 + */ +class Gems_Task_Tracker_RefreshTokenAttributes extends Gems_Task_TaskAbstract +{ + /** + * @var Gems_Tracker + */ + public $tracker; + + public function execute($tokenId = null) + { + $this->tracker = $this->loader->getTracker(); + $token = $this->tracker->getToken($tokenId); + + $checked = $this->_batch->addToCounter('ta-checkedTokens'); + if ($token->inSource()) { + $survey = $token->getSurvey(); + if ($survey->copyTokenToSource($token, '')) { + $this->_batch->addToCounter('ta-changedTokens'); + } + } + + $cTokens = $this->_batch->getCounter('ta-changedTokens'); + + $this->_batch->setMessage('ta-check', sprintf($this->translate->plural('%d token out of %d tokens changed.', '%d tokens out of %d tokens changed.', $cTokens), $cTokens, $checked)); + } +} \ No newline at end of file Deleted: trunk/library/classes/Gems/Tracker/Batch/RefreshTokenAttributesBatch.php =================================================================== --- trunk/library/classes/Gems/Tracker/Batch/RefreshTokenAttributesBatch.php 2012-03-01 13:22:33 UTC (rev 526) +++ trunk/library/classes/Gems/Tracker/Batch/RefreshTokenAttributesBatch.php 2012-03-01 13:46:43 UTC (rev 527) @@ -1,133 +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 <COPYRIGHT HOLDER> BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * - * @package Gems - * @subpackage Tracker - * @author Matijs de Jong <mj...@ma...> - * @copyright Copyright (c) 2011 Erasmus MC - * @license New BSD License - * @version $Id$ - */ - -/** - * Refresh the attributes of all tokens - * - * @package Gems - * @subpackage Tracker - * @copyright Copyright (c) 2011 Erasmus MC - * @license New BSD License - * @since Class available since version 1.5 - */ -class Gems_Tracker_Batch_RefreshTokenAttributesBatch extends MUtil_Batch_BatchAbstract -{ - /** - * - * @var Gems_Tracker - */ - protected $tracker; - - /** - * - * @var Zend_Translate - */ - protected $translate; - - /** - * Add a token check step to the batch - * - * @param string $tokenId A token id - * @return Gems_Tracker_Batch_UpdateAttributesBatch (Continuation pattern) - */ - public function addToken($tokenId) - { - $this->addStep('updateAttributes', $tokenId); - - return $this; - } - - /** - * Add token check steps to the batch - * - * @param array $tokenIds An array of token ids - * @return Gems_Tracker_Batch_UpdateAttributesBatch (Continuation pattern) - */ - public function addTokens(array $tokenIds) - { - foreach ($tokenIds as $tokenId) { - $this->addStep('updateAttributes', $tokenId); - } - - return $this; - } - - /** - * String of messages from the batch - * - * Do not forget to reset() the batch if you're done with it after - * displaying the report. - * - * @param boolean $reset When true the batch is reset afterwards - * @return array - */ - public function getMessages($reset = false) - { - - $cAll = $this->count(); - $cTokens = $this->getCounter('changedTokens'); - - $messages = parent::getMessages($reset); - - array_unshift($messages, sprintf($this->translate->_('Checked %d token.'), $cAll)); - if ($cTokens == 0) { - $messages[] = $this->translate->_('No attributes were updated.'); - } else { - $messages[] = sprintf($this->translate->plural('%d token changed.', '%d tokens changed.', $cTokens), $cTokens); - } - - return $messages; - } - - /** - * Update the attributes of a token, if the token is - * already in the source. - * - * @param string $tokenId A token id - */ - protected function updateAttributes($tokenId) - { - $token = $this->tracker->getToken($tokenId); - - if ($token->inSource()) { - $survey = $token->getSurvey(); - if ($survey->copyTokenToSource($token, '')) { - $this->addToCounter('changedTokens'); - } - } - } -} Modified: trunk/library/classes/Gems/Tracker.php =================================================================== --- trunk/library/classes/Gems/Tracker.php 2012-03-01 13:22:33 UTC (rev 526) +++ trunk/library/classes/Gems/Tracker.php 2012-03-01 13:46:43 UTC (rev 527) @@ -933,11 +933,11 @@ * * @param string $batch_id A unique identifier for the current batch * @param string $cond An optional where statement - * @return Gems_Tracker_Batch_RefreshTokenAttributesBatch A batch to process the changes + * @return Gems_Task_TaskRunnerBatch A batch to process the changes */ public function refreshTokenAttributesBatch($batch_id, $cond = null) { - $batch = $this->_loadClass('Batch_RefreshTokenAttributesBatch', true, array($batch_id)); + $batch = $this->loader->getTaskRunnerBatch($batch_id); if (! $batch->isLoaded()) { $tokenSelect = $this->getTokenSelect(array('gto_id_token')); @@ -954,7 +954,9 @@ ->forWhere($cond); } - $batch->addTokens($this->db->fetchCol($tokenSelect->getSelect())); + foreach ($this->db->fetchCol($tokenSelect->getSelect()) as $token) { + $batch->addTask('Tracker_RefreshTokenAttributes', $token); + } } self::$verbose = true; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2012-03-01 14:06:33
|
Revision: 528 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=528&view=rev Author: mennodekker Date: 2012-03-01 14:06:23 +0000 (Thu, 01 Mar 2012) Log Message: ----------- docblock fixes Modified Paths: -------------- trunk/library/classes/Gems/Controller/Action/Helper/BatchRunner.php trunk/library/classes/Gems/Task/CleanCache.php trunk/library/classes/Gems/Task/Db/CreateNewTable.php trunk/library/classes/Gems/Task/Db/CreateNewTables.php trunk/library/classes/Gems/Task/Db/ExecutePatch.php trunk/library/classes/Gems/Task/Echo.php trunk/library/classes/Gems/Task/TaskAbstract.php trunk/library/classes/Gems/Task/TaskInterface.php trunk/library/classes/Gems/Task/TaskRunnerBatch.php trunk/library/classes/Gems/Task/Tracker/CheckTokenCompletion.php trunk/library/classes/Gems/Task/Tracker/CheckTrackTokens.php trunk/library/classes/Gems/Task/Tracker/ProcessTokenCompletion.php trunk/library/classes/Gems/Task/Tracker/RefreshTokenAttributes.php trunk/library/classes/Gems/Task/Tracker/SourceSyncSurveys.php Property Changed: ---------------- trunk/library/classes/Gems/Task/CleanCache.php trunk/library/classes/Gems/Task/Db/CreateNewTable.php trunk/library/classes/Gems/Task/Db/CreateNewTables.php trunk/library/classes/Gems/Task/Db/ExecutePatch.php trunk/library/classes/Gems/Task/Echo.php trunk/library/classes/Gems/Task/Tracker/CheckTokenCompletion.php trunk/library/classes/Gems/Task/Tracker/CheckTrackTokens.php trunk/library/classes/Gems/Task/Tracker/ProcessTokenCompletion.php trunk/library/classes/Gems/Task/Tracker/RefreshTokenAttributes.php trunk/library/classes/Gems/Task/Tracker/SourceSyncSurveys.php Modified: trunk/library/classes/Gems/Controller/Action/Helper/BatchRunner.php =================================================================== --- trunk/library/classes/Gems/Controller/Action/Helper/BatchRunner.php 2012-03-01 13:46:43 UTC (rev 527) +++ trunk/library/classes/Gems/Controller/Action/Helper/BatchRunner.php 2012-03-01 14:06:23 UTC (rev 528) @@ -25,27 +25,24 @@ * 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 + * @subpackage Controller_Action_Helper * @copyright Copyright (c) 2011 Erasmus MC * @license New BSD License * @version $Id$ */ /** - * Short description for BatchRunner + * This helper provides an easy method for running tasks in batch. * - * Long description for class BatchRunner (if any)... + * Just provide the batch and the title to use and you will be fine. * * @package Gems - * @subpackage Sample + * @subpackage Controller_Action_Helper * @copyright Copyright (c) 2011 Erasmus MC * @license New BSD License - * @since Class available since version 1.0 - * @deprecated Class deprecated since version 2.0 + * @since Class available since version 1.5.2 */ class Gems_Controller_Action_Helper_BatchRunner extends Zend_Controller_Action_Helper_Abstract { Modified: trunk/library/classes/Gems/Task/CleanCache.php =================================================================== --- trunk/library/classes/Gems/Task/CleanCache.php 2012-03-01 13:46:43 UTC (rev 527) +++ trunk/library/classes/Gems/Task/CleanCache.php 2012-03-01 14:06:23 UTC (rev 528) @@ -29,7 +29,7 @@ * @subpackage Task * @copyright Copyright (c) 2011 Erasmus MC * @license New BSD License - * @version $Id: CheckTokenCompletion.php 502 2012-02-20 14:13:20Z mennodekker $ + * @version $Id$ */ /** @@ -45,7 +45,7 @@ * @subpackage Task * @copyright Copyright (c) 2011 Erasmus MC * @license New BSD License - * @since Class available since version 1.6 + * @since Class available since version 1.5.2 */ class Gems_Task_CleanCache extends Gems_Task_TaskAbstract { Property changes on: trunk/library/classes/Gems/Task/CleanCache.php ___________________________________________________________________ Added: svn:keywords + Id Rev Revision Date Author Modified: trunk/library/classes/Gems/Task/Db/CreateNewTable.php =================================================================== --- trunk/library/classes/Gems/Task/Db/CreateNewTable.php 2012-03-01 13:46:43 UTC (rev 527) +++ trunk/library/classes/Gems/Task/Db/CreateNewTable.php 2012-03-01 14:06:23 UTC (rev 528) @@ -29,7 +29,7 @@ * @subpackage Task_Db * @copyright Copyright (c) 2011 Erasmus MC * @license New BSD License - * @version $Id: CheckTokenCompletion.php 502 2012-02-20 14:13:20Z mennodekker $ + * @version $Id$ */ /** @@ -41,7 +41,7 @@ * @subpackage Task_Db * @copyright Copyright (c) 2011 Erasmus MC * @license New BSD License - * @since Class available since version 1.6 + * @since Class available since version 1.5.2 */ class Gems_Task_Db_CreateNewTable extends Gems_Task_TaskAbstract { Property changes on: trunk/library/classes/Gems/Task/Db/CreateNewTable.php ___________________________________________________________________ Added: svn:keywords + Id Rev Revision Date Author Modified: trunk/library/classes/Gems/Task/Db/CreateNewTables.php =================================================================== --- trunk/library/classes/Gems/Task/Db/CreateNewTables.php 2012-03-01 13:46:43 UTC (rev 527) +++ trunk/library/classes/Gems/Task/Db/CreateNewTables.php 2012-03-01 14:06:23 UTC (rev 528) @@ -29,7 +29,7 @@ * @subpackage Task_Db * @copyright Copyright (c) 2011 Erasmus MC * @license New BSD License - * @version $Id: CheckTokenCompletion.php 502 2012-02-20 14:13:20Z mennodekker $ + * @version $Id$ */ /** @@ -39,7 +39,7 @@ * @subpackage Task_Db * @copyright Copyright (c) 2011 Erasmus MC * @license New BSD License - * @since Class available since version 1.6 + * @since Class available since version 1.5.2 */ class Gems_Task_Db_CreateNewTables extends Gems_Task_TaskAbstract { Property changes on: trunk/library/classes/Gems/Task/Db/CreateNewTables.php ___________________________________________________________________ Added: svn:keywords + Id Rev Revision Date Author Modified: trunk/library/classes/Gems/Task/Db/ExecutePatch.php =================================================================== --- trunk/library/classes/Gems/Task/Db/ExecutePatch.php 2012-03-01 13:46:43 UTC (rev 527) +++ trunk/library/classes/Gems/Task/Db/ExecutePatch.php 2012-03-01 14:06:23 UTC (rev 528) @@ -29,7 +29,7 @@ * @subpackage Task_Db * @copyright Copyright (c) 2011 Erasmus MC * @license New BSD License - * @version $Id: CheckTokenCompletion.php 502 2012-02-20 14:13:20Z mennodekker $ + * @version $Id$ */ /** @@ -41,7 +41,7 @@ * @subpackage Task_Db * @copyright Copyright (c) 2011 Erasmus MC * @license New BSD License - * @since Class available since version 1.6 + * @since Class available since version 1.5.2 */ class Gems_Task_Db_ExecutePatch extends Gems_Task_TaskAbstract { Property changes on: trunk/library/classes/Gems/Task/Db/ExecutePatch.php ___________________________________________________________________ Added: svn:keywords + Id Rev Revision Date Author Modified: trunk/library/classes/Gems/Task/Echo.php =================================================================== --- trunk/library/classes/Gems/Task/Echo.php 2012-03-01 13:46:43 UTC (rev 527) +++ trunk/library/classes/Gems/Task/Echo.php 2012-03-01 14:06:23 UTC (rev 528) @@ -29,7 +29,7 @@ * @subpackage Task * @copyright Copyright (c) 2011 Erasmus MC * @license New BSD License - * @version $Id: CheckTokenCompletion.php 502 2012-02-20 14:13:20Z mennodekker $ + * @version $Id$ */ /** @@ -39,7 +39,7 @@ * @subpackage Task * @copyright Copyright (c) 2011 Erasmus MC * @license New BSD License - * @since Class available since version 1.6 + * @since Class available since version 1.5.2 */ class Gems_Task_Echo extends Gems_Task_TaskAbstract { Property changes on: trunk/library/classes/Gems/Task/Echo.php ___________________________________________________________________ Added: svn:keywords + Id Rev Revision Date Author Modified: trunk/library/classes/Gems/Task/TaskAbstract.php =================================================================== --- trunk/library/classes/Gems/Task/TaskAbstract.php 2012-03-01 13:46:43 UTC (rev 527) +++ trunk/library/classes/Gems/Task/TaskAbstract.php 2012-03-01 14:06:23 UTC (rev 528) @@ -42,7 +42,7 @@ * @subpackage Task * @copyright Copyright (c) 2011 Erasmus MC * @license New BSD License - * @since Class available since version 1.6 + * @since Class available since version 1.5.2 */ abstract class Gems_Task_TaskAbstract extends MUtil_Registry_TargetAbstract implements Gems_Task_TaskInterface { @@ -61,6 +61,14 @@ */ public $translate; + /** + * Sets the batch this task belongs to + * + * This method will be called from the Gems_Task_TaskRunnerBatch upon execution of the + * task. It allows the task to communicate with the batch queue. + * + * @param Gems_Task_TaskRunnerBatch $batch + */ public function setBatch(Gems_Task_TaskRunnerBatch $batch) { $this->_batch = $batch; Modified: trunk/library/classes/Gems/Task/TaskInterface.php =================================================================== --- trunk/library/classes/Gems/Task/TaskInterface.php 2012-03-01 13:46:43 UTC (rev 527) +++ trunk/library/classes/Gems/Task/TaskInterface.php 2012-03-01 14:06:23 UTC (rev 528) @@ -40,7 +40,7 @@ * @subpackage Task * @copyright Copyright (c) 2011 Erasmus MC * @license New BSD License - * @since Class available since version 1.6 + * @since Class available since version 1.5.2 */ interface Gems_Task_TaskInterface { @@ -57,6 +57,8 @@ * * This method will be called from the Gems_Task_TaskRunnerBatch upon execution of the * task. It allows the task to communicate with the batch queue. + * + * @param Gems_Task_TaskRunnerBatch $batch */ public function setBatch(Gems_Task_TaskRunnerBatch $batch); } \ No newline at end of file Modified: trunk/library/classes/Gems/Task/TaskRunnerBatch.php =================================================================== --- trunk/library/classes/Gems/Task/TaskRunnerBatch.php 2012-03-01 13:46:43 UTC (rev 527) +++ trunk/library/classes/Gems/Task/TaskRunnerBatch.php 2012-03-01 14:06:23 UTC (rev 528) @@ -45,7 +45,7 @@ * @subpackage Task * @copyright Copyright (c) 2011 Erasmus MC * @license New BSD License - * @since Class available since version 1.6 + * @since Class available since version 1.5.2 */ class Gems_Task_TaskRunnerBatch extends MUtil_Batch_BatchAbstract { Modified: trunk/library/classes/Gems/Task/Tracker/CheckTokenCompletion.php =================================================================== --- trunk/library/classes/Gems/Task/Tracker/CheckTokenCompletion.php 2012-03-01 13:46:43 UTC (rev 527) +++ trunk/library/classes/Gems/Task/Tracker/CheckTokenCompletion.php 2012-03-01 14:06:23 UTC (rev 528) @@ -29,7 +29,7 @@ * @subpackage TaskTracker * @copyright Copyright (c) 2011 Erasmus MC * @license New BSD License - * @version $Id: CheckTokenCompletion.php 502 2012-02-20 14:13:20Z mennodekker $ + * @version $Id$ */ /** @@ -42,7 +42,7 @@ * @subpackage Task_Tracker * @copyright Copyright (c) 2011 Erasmus MC * @license New BSD License - * @since Class available since version 1.6 + * @since Class available since version 1.5.2 */ class Gems_Task_Tracker_CheckTokenCompletion extends Gems_Task_TaskAbstract { Property changes on: trunk/library/classes/Gems/Task/Tracker/CheckTokenCompletion.php ___________________________________________________________________ Added: svn:keywords + Id Rev Revision Date Author Modified: trunk/library/classes/Gems/Task/Tracker/CheckTrackTokens.php =================================================================== --- trunk/library/classes/Gems/Task/Tracker/CheckTrackTokens.php 2012-03-01 13:46:43 UTC (rev 527) +++ trunk/library/classes/Gems/Task/Tracker/CheckTrackTokens.php 2012-03-01 14:06:23 UTC (rev 528) @@ -30,7 +30,7 @@ * @subpackage Task_Tracker * @copyright Copyright (c) 2011 Erasmus MC * @license New BSD License - * @version $Id: CheckTrackTokens.php 502 2012-02-20 14:13:20Z mennodekker $ + * @version $Id$ */ /** @@ -40,7 +40,7 @@ * @subpackage Task_Tracker * @copyright Copyright (c) 2011 Erasmus MC * @license New BSD License - * @since Class available since version 1.6 + * @since Class available since version 1.5.2 */ class Gems_Task_Tracker_CheckTrackTokens extends Gems_Task_TaskAbstract { Property changes on: trunk/library/classes/Gems/Task/Tracker/CheckTrackTokens.php ___________________________________________________________________ Added: svn:keywords + Id Rev Revision Date Author Modified: trunk/library/classes/Gems/Task/Tracker/ProcessTokenCompletion.php =================================================================== --- trunk/library/classes/Gems/Task/Tracker/ProcessTokenCompletion.php 2012-03-01 13:46:43 UTC (rev 527) +++ trunk/library/classes/Gems/Task/Tracker/ProcessTokenCompletion.php 2012-03-01 14:06:23 UTC (rev 528) @@ -30,7 +30,7 @@ * @subpackage Task_Tracker * @copyright Copyright (c) 2011 Erasmus MC * @license New BSD License - * @version $Id: ProcessTokenCompletion.php 502 2012-02-20 14:13:20Z mennodekker $ + * @version $Id$ */ /** @@ -40,7 +40,7 @@ * @subpackage Task_Tracker * @copyright Copyright (c) 2011 Erasmus MC * @license New BSD License - * @since Class available since version 1.6 + * @since Class available since version 1.5.2 */ class Gems_Task_Tracker_ProcessTokenCompletion extends Gems_Task_TaskAbstract { Property changes on: trunk/library/classes/Gems/Task/Tracker/ProcessTokenCompletion.php ___________________________________________________________________ Added: svn:keywords + Id Rev Revision Date Author Modified: trunk/library/classes/Gems/Task/Tracker/RefreshTokenAttributes.php =================================================================== --- trunk/library/classes/Gems/Task/Tracker/RefreshTokenAttributes.php 2012-03-01 13:46:43 UTC (rev 527) +++ trunk/library/classes/Gems/Task/Tracker/RefreshTokenAttributes.php 2012-03-01 14:06:23 UTC (rev 528) @@ -30,7 +30,7 @@ * @subpackage Task_Tracker * @copyright Copyright (c) 2011 Erasmus MC * @license New BSD License - * @version $Id: ProcessTokenCompletion.php 502 2012-02-20 14:13:20Z mennodekker $ + * @version $Id$ */ /** @@ -40,7 +40,7 @@ * @subpackage Task_Tracker * @copyright Copyright (c) 2011 Erasmus MC * @license New BSD License - * @since Class available since version 1.6 + * @since Class available since version 1.5.2 */ class Gems_Task_Tracker_RefreshTokenAttributes extends Gems_Task_TaskAbstract { Property changes on: trunk/library/classes/Gems/Task/Tracker/RefreshTokenAttributes.php ___________________________________________________________________ Added: svn:keywords + Id Rev Revision Date Author Modified: trunk/library/classes/Gems/Task/Tracker/SourceSyncSurveys.php =================================================================== --- trunk/library/classes/Gems/Task/Tracker/SourceSyncSurveys.php 2012-03-01 13:46:43 UTC (rev 527) +++ trunk/library/classes/Gems/Task/Tracker/SourceSyncSurveys.php 2012-03-01 14:06:23 UTC (rev 528) @@ -29,7 +29,7 @@ * @subpackage Task_Tracker * @copyright Copyright (c) 2011 Erasmus MC * @license New BSD License - * @version $Id: Sample.php 215 2011-07-12 08:52:54Z michiel $ + * @version $Id$ */ /** @@ -39,7 +39,7 @@ * @subpackage Task_Tracker * @copyright Copyright (c) 2011 Erasmus MC * @license New BSD License - * @since Class available since version 1.6 + * @since Class available since version 1.5.2 */ class Gems_Task_Tracker_SourceSyncSurveys extends Gems_Task_TaskAbstract { Property changes on: trunk/library/classes/Gems/Task/Tracker/SourceSyncSurveys.php ___________________________________________________________________ Added: svn:keywords + Id Rev Revision Date Author This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2012-03-09 08:28:35
|
Revision: 540 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=540&view=rev Author: mennodekker Date: 2012-03-09 08:28:26 +0000 (Fri, 09 Mar 2012) Log Message: ----------- Fixed incrementing login delay while still in delay period Added configurable default consent Modified Paths: -------------- trunk/library/classes/Gems/Auth.php trunk/library/classes/Gems/Default/RespondentAction.php trunk/library/classes/Gems/Model.php Modified: trunk/library/classes/Gems/Auth.php =================================================================== --- trunk/library/classes/Gems/Auth.php 2012-03-08 16:20:56 UTC (rev 539) +++ trunk/library/classes/Gems/Auth.php 2012-03-09 08:28:26 UTC (rev 540) @@ -110,6 +110,7 @@ public function authenticate(Zend_Auth_Adapter_Interface $adapter, array $formValues = null) { try { + $remaining = 0; $login_name = $formValues['userlogin']; $organization = $formValues['organization']; $sql = "SELECT gula_failed_logins, gula_last_failed FROM gems__user_login_attempts WHERE gula_login = ? AND gula_id_organization = ?"; @@ -159,10 +160,10 @@ $values['gula_last_failed'] = null; } else { if ($values['gula_failed_logins']) { - // MUtil_Echo::track($result->getCode(), self::ERROR_PASSWORD_DELAY); // Only increment when we have no password delay as the right password - // will not be accepted when we are in the delay. - if ($result->getCode() <> self::ERROR_PASSWORD_DELAY) { + // will not be accepted when we are in the delay. Can not check on the error + // code as it will be set to 'uncategorized' => -4 + if ($remaining>0) { $values['gula_failed_logins'] += 1; $values['gula_last_failed'] = new Zend_Db_Expr('CURRENT_TIMESTAMP'); } Modified: trunk/library/classes/Gems/Default/RespondentAction.php =================================================================== --- trunk/library/classes/Gems/Default/RespondentAction.php 2012-03-08 16:20:56 UTC (rev 539) +++ trunk/library/classes/Gems/Default/RespondentAction.php 2012-03-09 08:28:26 UTC (rev 540) @@ -391,7 +391,9 @@ $data = $model->applyRequest($this->getRequest(), true)->loadFirst(); } - if ($data['gr2o_consent'] == $model->get('gr2o_consent', 'default')) { + //Check if we have the 'Unknown' consent, and present a warning. The project default consent is + //normally 'Unknown' but this can be overruled in project.ini so checking for default is not right + if ($data['gr2o_consent'] == 'Unknown') { $url = $this->view->url(array('controller' => 'respondent', 'action' => 'edit', 'id' => $data['gr2o_patient_nr'])) . '#tabContainer-frag-3'; $this->addMessage(MUtil_Html::create()->a($url, $this->_('Please settle the informed consent form for this respondent.'))); } Modified: trunk/library/classes/Gems/Model.php =================================================================== --- trunk/library/classes/Gems/Model.php 2012-03-08 16:20:56 UTC (rev 539) +++ trunk/library/classes/Gems/Model.php 2012-03-09 08:28:26 UTC (rev 540) @@ -204,7 +204,7 @@ $model->setIfExists('gr2o_patient_nr', 'label', $this->translate->_('Respondent nr')); $model->setIfExists('gr2o_opened', 'label', $this->translate->_('Opened'), 'formatFunction', $translated->formatDateTime); - $model->setIfExists('gr2o_consent', 'label', $this->translate->_('Consent'), 'multiOptions', MUtil_Lazy::call($this->util->getDbLookup()->getUserConsents)); + $model->setIfExists('gr2o_consent', 'label', $this->translate->_('Consent'), 'multiOptions', MUtil_Lazy::call($this->util->getDbLookup()->getUserConsents), 'default', $this->util->getDefaultConsent()); $model->setIfExists('grs_email', 'label', $this->translate->_('E-Mail')); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2012-03-16 12:32:59
|
Revision: 553 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=553&view=rev Author: matijsdejong Date: 2012-03-16 12:32:50 +0000 (Fri, 16 Mar 2012) Log Message: ----------- Added password report option Modified Paths: -------------- trunk/library/classes/Gems/Default/OptionAction.php trunk/library/classes/Gems/User/PasswordChecker.php trunk/library/classes/Gems/User/User.php trunk/library/classes/Gems/User/UserLoader.php trunk/library/classes/Gems/User/UserNewPasswordValidator.php Modified: trunk/library/classes/Gems/Default/OptionAction.php =================================================================== --- trunk/library/classes/Gems/Default/OptionAction.php 2012-03-15 14:59:14 UTC (rev 552) +++ trunk/library/classes/Gems/Default/OptionAction.php 2012-03-16 12:32:50 UTC (rev 553) @@ -87,6 +87,7 @@ if ($user->isPasswordResetRequired()) { $this->menu->setVisible(false); + } elseif ($user->hasPassword()) { // Field current password // @@ -123,11 +124,24 @@ $element->addValidator(new MUtil_Validate_IsConfirmed('new_password', $this->_('New password'))); $form->addElement($element); - $element = new Zend_Form_Element_Submit('submit'); - $element->setAttrib('class', 'button'); - $element->setLabel($this->_('Save')); - $form->addElement($element); + // Show password info + if ($info = $user->reportPasswordWeakness()) { + foreach ($info as &$line) { + $line .= ','; + } + $line[strlen($line) - 1] = '.'; + $element = new MUtil_Form_Element_Html('rules'); + $element->setLabel($this->_('Password rules')); + $element->div($this->_('A password:'))->ul($info); + $form->addElement($element); + + $element = new Zend_Form_Element_Submit('submit'); + $element->setAttrib('class', 'button'); + $element->setLabel($this->_('Save')); + $form->addElement($element); + } + /**************** * Process form * ****************/ Modified: trunk/library/classes/Gems/User/PasswordChecker.php =================================================================== --- trunk/library/classes/Gems/User/PasswordChecker.php 2012-03-15 14:59:14 UTC (rev 552) +++ trunk/library/classes/Gems/User/PasswordChecker.php 2012-03-16 12:32:50 UTC (rev 553) @@ -92,7 +92,7 @@ $results = array(); if ($len && (preg_match_all('/[A-Z]/', $password, $results) < $len)) { $this->_addError(sprintf( - $this->translate->plural('A password should contain at least one uppercase character.', 'A password should contain at least %d uppercase characters.', $len), + $this->translate->plural('should contain at least one uppercase character', 'should contain at least %d uppercase characters', $len), $len)); } } @@ -109,7 +109,7 @@ $results = array(); if ($len && (preg_match_all('/[a-z]/', $password, $results) < $len)) { $this->_addError(sprintf( - $this->translate->plural('A password should contain at least one lowercase character.', 'A password should contain at least %d lowercase characters.', $len), + $this->translate->plural('should contain at least one lowercase character', 'should contain at least %d lowercase characters', $len), $len)); } } @@ -124,7 +124,7 @@ { $len = intval($parameter); if ($len && (strlen($password) < $len)) { - $this->_addError(sprintf($this->translate->_('A password should be at least %d characters long.'), $len)); + $this->_addError(sprintf($this->translate->_('should be at least %d characters long'), $len)); } } @@ -138,12 +138,14 @@ { $len = intval($parameter); if ($len) { - $results = array(); - $count = preg_match_all('/[A-Za-z]/', $password, $results); - if (strlen($password) - $count < $len) { + $results = array(); // Not used but required + $count = strlen($password) - preg_match_all('/[A-Za-z]/', $password, $results); + if (($len > 0) && ($count < $len)) { $this->_addError(sprintf( - $this->translate->plural('A password should contain at least one not alphabetic character.', 'A password should contain at least %d not alphabetic characters.', $len), + $this->translate->plural('should contain at least one non alphabetic character', 'should contain at least %d non alphabetic characters', $len), $len)); + } elseif (($len < 0) && (($count > 0) || (null === $password))) { + $this->_addError($this->translate->_('should not contain non alphabetic characters')); } } } @@ -158,12 +160,14 @@ { $len = intval($parameter); if ($len) { - $results = array(); - $count = preg_match_all('/[A-Za-z]/', $password, $results); - if (strlen($password) - $count < $len) { + $results = array(); // Not used but required + $count = strlen($password) - preg_match_all('/[0-9A-Za-z]/', $password, $results); + if (($len > 0) && ($count < $len)) { $this->_addError(sprintf( - $this->translate->plural('A password should contain at least one not alphanumeric character.', 'A password should contain at least %d not alphanumeric characters.', $len), + $this->translate->plural('should contain at least one non alphanumeric character', 'should contain at least %d non alphanumeric characters', $len), $len)); + } elseif (($len < 0) && (($count > 0) || (null === $password))) { + $this->_addError($this->translate->_('should not contain non alphanumeric characters')); } } } @@ -180,8 +184,8 @@ if ($on) { $lpwd = strtolower($password); - if (false !== strpos($lpwd, strtolower($this->user->getLoginName()))) { - $this->_addError($this->translate->_('A password should not contain the login name.')); + if ((false !== strpos($lpwd, strtolower($this->user->getLoginName()))) || (null === $password)) { + $this->_addError(sprintf($this->translate->_('should not contain your login name "%s"'), $this->user->getLoginName())); } } } @@ -195,18 +199,24 @@ protected function numCount($parameter, $password) { $len = intval($parameter); - $results = array(); - if ($len && (preg_match_all('/[0-9]/', $password, $results) < $len)) { - $this->_addError(sprintf( - $this->translate->plural('A password should contain at least one number.', 'A password should contain at least %d numbers.', $len), - $len)); + if ($len) { + $results = array(); // Not used but required + $count = preg_match_all('/[0-9]/', $password, $results); + if (($len > 0) && ($count < $len)) { + $this->_addError(sprintf( + $this->translate->plural('should contain at least one number', 'should contain at least %d numbers', $len), + $len)); + } elseif (($len < 0) && (($count > 0) || (null === $password))) { + $this->_addError($this->translate->_('may not contain numbers')); + } } } /** * Check for password weakness. * - * @param string $password + * @param Gems_User_User $user + * @param string $password Or null when you want a report on all the rules for this password. * @param array $codes An array of code names that identify rules that should be used only for those codes. * @return mixed String or array of strings containing warning messages */ Modified: trunk/library/classes/Gems/User/User.php =================================================================== --- trunk/library/classes/Gems/User/User.php 2012-03-15 14:59:14 UTC (rev 552) +++ trunk/library/classes/Gems/User/User.php 2012-03-16 12:32:50 UTC (rev 553) @@ -730,10 +730,10 @@ /** * Check for password weakness. * - * @param string $password + * @param string $password Or null when you want a report on all the rules for this password. * @return mixed String or array of strings containing warning messages or nothing */ - public function reportPasswordWeakness($password) + public function reportPasswordWeakness($password = null) { if ($this->canSetPassword()) { $checker = $this->userLoader->getPasswordChecker(); Modified: trunk/library/classes/Gems/User/UserLoader.php =================================================================== --- trunk/library/classes/Gems/User/UserLoader.php 2012-03-15 14:59:14 UTC (rev 552) +++ trunk/library/classes/Gems/User/UserLoader.php 2012-03-16 12:32:50 UTC (rev 553) @@ -431,13 +431,11 @@ * Check for password weakness. * * @param Gems_User_User $user The user for e.g. name checks - * @param string $password + * @param string $password Or null when you want a report on all the rules for this password. * @return mixed String or array of strings containing warning messages */ - public function reportPasswordWeakness(Gems_User_User $user, $password) + public function reportPasswordWeakness(Gems_User_User $user, $password = null) { - $checker = $this->_getClass('passwordChecker'); - return $user->reportPasswordWeakness($password); } Modified: trunk/library/classes/Gems/User/UserNewPasswordValidator.php =================================================================== --- trunk/library/classes/Gems/User/UserNewPasswordValidator.php 2012-03-15 14:59:14 UTC (rev 552) +++ trunk/library/classes/Gems/User/UserNewPasswordValidator.php 2012-03-16 12:32:50 UTC (rev 553) @@ -84,6 +84,10 @@ { $this->_report = $this->_user->reportPasswordWeakness($value); + foreach ($this->_report as &$report) { + $report = ucfirst($report) . '.'; + } + // MUtil_Echo::track($value, $this->_report); return ! (boolean) $this->_report; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2012-03-21 12:56:08
|
Revision: 556 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=556&view=rev Author: matijsdejong Date: 2012-03-21 12:55:59 +0000 (Wed, 21 Mar 2012) Log Message: ----------- Separation for Link & Element Modified Paths: -------------- trunk/library/classes/Gems/Default/IndexAction.php trunk/library/classes/Gems/User/Form/LoginForm.php Modified: trunk/library/classes/Gems/Default/IndexAction.php =================================================================== --- trunk/library/classes/Gems/Default/IndexAction.php 2012-03-19 18:34:45 UTC (rev 555) +++ trunk/library/classes/Gems/Default/IndexAction.php 2012-03-21 12:55:59 UTC (rev 556) @@ -141,7 +141,7 @@ * * @param boolean $showToken Optional, show 'Ask token' button, $this->showTokenButton is used when not specified * @param boolean $showPasswordLost Optional, show 'Lost password' button, $this->showPasswordLostButton is used when not specified - * @return Gems_Form + * @return Gems_User_Form_LoginForm */ protected function _getLoginForm($showToken = null, $showPasswordLost = null) { Modified: trunk/library/classes/Gems/User/Form/LoginForm.php =================================================================== --- trunk/library/classes/Gems/User/Form/LoginForm.php 2012-03-19 18:34:45 UTC (rev 555) +++ trunk/library/classes/Gems/User/Form/LoginForm.php 2012-03-21 12:55:59 UTC (rev 556) @@ -213,7 +213,7 @@ // Reset password $element = new MUtil_Form_Element_Html($this->_lostPasswordFieldName); // $element->br(); - $element->a(array('controller' => 'index', 'action' => 'resetpassword'), $this->translate->_('Lost password'), array('class' => 'actionlink')); + $element->setValue($this->getLostPasswordLink()); $this->addElement($element); } @@ -222,6 +222,16 @@ } /** + * Returns/sets a link to the reset password page + * + * @return MUtil_Html_AElement + */ + public function getLostPasswordLink() + { + return new MUtil_Html_AElement(array('controller' => 'index', 'action' => 'resetpassword'), $this->translate->_('Lost password'), array('class' => 'actionlink')); + } + + /** * Returns/sets an element for determining / selecting the organization. * * @return Zend_Form_Element_Xhtml This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2012-03-22 17:05:29
|
Revision: 563 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=563&view=rev Author: matijsdejong Date: 2012-03-22 17:05:18 +0000 (Thu, 22 Mar 2012) Log Message: ----------- Moved IP check from Gems_Auth() to User->authenticate() isAllowedIp() is no longer static, allowing per project overloading Modified Paths: -------------- trunk/library/classes/Gems/Auth.php trunk/library/classes/Gems/User/User.php trunk/library/classes/Gems/Util.php Modified: trunk/library/classes/Gems/Auth.php =================================================================== --- trunk/library/classes/Gems/Auth.php 2012-03-22 16:35:44 UTC (rev 562) +++ trunk/library/classes/Gems/Auth.php 2012-03-22 17:05:18 UTC (rev 563) @@ -54,7 +54,6 @@ */ const ERROR_DATABASE_NOT_INSTALLED = -11; const ERROR_PASSWORD_DELAY = -12; - const ERROR_INVALID_IP = -13; /** * @var array Message templates @@ -62,7 +61,6 @@ protected $_messageTemplates = array( self::ERROR_DATABASE_NOT_INSTALLED => 'Installation not complete! Login is not yet possible!', self::ERROR_PASSWORD_DELAY => 'Your account is temporarily blocked, please wait %s seconds', - self::ERROR_INVALID_IP => 'You are not allowed to login from this location.' ); /** @@ -147,12 +145,7 @@ // We only forward to auth adapter when we have no timeout to prevent hammering the auth system if (! isset($result) ) { - // Check if the client IP address is within allowed IP ranges - if (isset($formValues['allowed_ip_ranges']) && !Gems_Util::isAllowedIP($_SERVER['REMOTE_ADDR'], $formValues['allowed_ip_ranges'])) { - $result = $this->_error(self::ERROR_INVALID_IP); - } else { - $result = parent::authenticate($adapter); - } + $result = parent::authenticate($adapter); } if ($result->isValid()) { Modified: trunk/library/classes/Gems/User/User.php =================================================================== --- trunk/library/classes/Gems/User/User.php 2012-03-22 16:35:44 UTC (rev 562) +++ trunk/library/classes/Gems/User/User.php 2012-03-22 17:05:18 UTC (rev 563) @@ -251,9 +251,13 @@ */ public function authenticate($formValues) { + // Check if the client IP address is within allowed IP ranges + if (! $this->util->isAllowedIP($_SERVER['REMOTE_ADDR'], $this->getAllowedIPRanges())) { + return new Zend_Auth_Result(Zend_Auth_Result::FAILURE_UNCATEGORIZED, $this->getLoginName(), array($this->translate->_('You are not allowed to login from this location.'))); + } + $auth = Gems_Auth::getInstance(); - $formValues['allowed_ip_ranges'] = $this->getAllowedIPRanges(); $formValues['organization'] = $this->getBaseOrganizationId(); $formValues['userlogin'] = $this->getLoginName(); Modified: trunk/library/classes/Gems/Util.php =================================================================== --- trunk/library/classes/Gems/Util.php 2012-03-22 16:35:44 UTC (rev 562) +++ trunk/library/classes/Gems/Util.php 2012-03-22 17:05:18 UTC (rev 563) @@ -193,7 +193,7 @@ * Get the default user consent * * This is de consent description from gems__consents, not the consentCODE - * + * * @return string */ public function getDefaultConsent() @@ -306,7 +306,7 @@ * @param string $ipRanges * @return bool */ - public static function isAllowedIP($ip, $ipRanges = "") + public function isAllowedIP($ip, $ipRanges = "") { if (!strlen($ipRanges)) { return true; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2012-03-27 15:07:33
|
Revision: 566 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=566&view=rev Author: matijsdejong Date: 2012-03-27 15:07:22 +0000 (Tue, 27 Mar 2012) Log Message: ----------- Fix for handling when user is in database but does not exist Modified Paths: -------------- trunk/library/classes/Gems/Model/RespondentModel.php trunk/library/classes/Gems/User/UserLoader.php Modified: trunk/library/classes/Gems/Model/RespondentModel.php =================================================================== --- trunk/library/classes/Gems/Model/RespondentModel.php 2012-03-23 18:30:36 UTC (rev 565) +++ trunk/library/classes/Gems/Model/RespondentModel.php 2012-03-27 15:07:22 UTC (rev 566) @@ -123,7 +123,7 @@ public function addLoginCheck() { $this->addLeftTable('gems__user_logins', array('gr2o_patient_nr' => 'gul_login', 'gr2o_id_organization' => 'gul_id_organization'), 'gul'); - $this->addColumn('CASE WHEN gul_id_user IS NULL THEN 0 ELSE 1 END', 'has_login'); + $this->addColumn("CASE WHEN gul_id_user IS NULL OR gul_user_class = 'NoLogin' OR gul_can_login = 0 THEN 0 ELSE 1 END", 'has_login'); return $this; } Modified: trunk/library/classes/Gems/User/UserLoader.php =================================================================== --- trunk/library/classes/Gems/User/UserLoader.php 2012-03-23 18:30:36 UTC (rev 565) +++ trunk/library/classes/Gems/User/UserLoader.php 2012-03-27 15:07:22 UTC (rev 566) @@ -156,17 +156,31 @@ { $now = new Zend_Db_Expr('CURRENT_TIMESTAMP'); - $values['gul_login'] = $login_name; - $values['gul_id_organization'] = $organization; - $values['gul_user_class'] = $userClassName; - $values['gul_can_login'] = 1; - $values['gul_changed'] = $now; - $values['gul_changed_by'] = $userId; - $values['gul_created'] = $now; - $values['gul_created_by'] = $userId; + $values['gul_user_class'] = $userClassName; + $values['gul_can_login'] = 1; + $values['gul_changed'] = $now; + $values['gul_changed_by'] = $userId; - $this->db->insert('gems__user_logins', $values); + $select = $this->db->select(); + $select->from('gems__user_logins', array('gul_id_user')) + ->where('gul_login = ?', $login_name) + ->where('gul_id_organization = ?', $organization) + ->limit(1); + // Update class definition if it already exists + if ($login_id = $this->db->fetchOne($select)) { + $where = implode(' ', $select->getPart(Zend_Db_Select::WHERE)); + $this->db->update('gems__user_logins', $values); + + } else { + $values['gul_login'] = $login_name; + $values['gul_id_organization'] = $organization; + $values['gul_created'] = $now; + $values['gul_created_by'] = $userId; + + $this->db->insert('gems__user_logins', $values); + } + return $this->getUser($login_name, $organization); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2012-03-28 19:38:30
|
Revision: 571 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=571&view=rev Author: michieltcs Date: 2012-03-28 19:38:24 +0000 (Wed, 28 Mar 2012) Log Message: ----------- Uncomment/fix/use getActiveSurveys() Modified Paths: -------------- trunk/library/classes/Gems/Tracker/Snippets/EditRoundSnippetAbstract.php trunk/library/classes/Gems/Util/TrackData.php Modified: trunk/library/classes/Gems/Tracker/Snippets/EditRoundSnippetAbstract.php =================================================================== --- trunk/library/classes/Gems/Tracker/Snippets/EditRoundSnippetAbstract.php 2012-03-28 12:15:34 UTC (rev 570) +++ trunk/library/classes/Gems/Tracker/Snippets/EditRoundSnippetAbstract.php 2012-03-28 19:38:24 UTC (rev 571) @@ -182,7 +182,7 @@ } // Check the survey name - $surveys = $this->util->getTrackData()->getAllSurveys(); + $surveys = $this->util->getTrackData()->getActiveSurveys(); 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 12:15:34 UTC (rev 570) +++ trunk/library/classes/Gems/Util/TrackData.php 2012-03-28 19:38:24 UTC (rev 571) @@ -82,20 +82,24 @@ 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 $surveys; + static $activeSurveys; - 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'); + 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'); } - return $surveys; - } // */ + 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-28 19:45:47
|
Revision: 572 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=572&view=rev Author: michieltcs Date: 2012-03-28 19:45:36 +0000 (Wed, 28 Mar 2012) Log Message: ----------- Also add getActiveSurveysAndDescriptions() Modified Paths: -------------- trunk/library/classes/Gems/Tracker/Engine/TrackEngineAbstract.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:38:24 UTC (rev 571) +++ trunk/library/classes/Gems/Tracker/Engine/TrackEngineAbstract.php 2012-03-28 19:45:36 UTC (rev 572) @@ -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()->getAllSurveysAndDescriptions()); + $model->set('gro_id_survey', 'label', $this->_('Survey'), 'multiOptions', $this->util->getTrackData()->getActiveSurveysAndDescriptions()); $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/Util/TrackData.php =================================================================== --- trunk/library/classes/Gems/Util/TrackData.php 2012-03-28 19:38:24 UTC (rev 571) +++ trunk/library/classes/Gems/Util/TrackData.php 2012-03-28 19:45:36 UTC (rev 572) @@ -102,7 +102,25 @@ /** * 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 + * * @staticvar array $surveys * @return array */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |