You can subscribe to this list here.
2011 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(84) |
Oct
(70) |
Nov
(164) |
Dec
(71) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2012 |
Jan
(52) |
Feb
(77) |
Mar
(70) |
Apr
(58) |
May
(81) |
Jun
(74) |
Jul
(87) |
Aug
(30) |
Sep
(45) |
Oct
(37) |
Nov
(51) |
Dec
(31) |
2013 |
Jan
(47) |
Feb
(29) |
Mar
(40) |
Apr
(33) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <gem...@li...> - 2012-03-01 15:35:11
|
Revision: 530 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=530&view=rev Author: mennodekker Date: 2012-03-01 15:35:00 +0000 (Thu, 01 Mar 2012) Log Message: ----------- Fixed validation error for respondents in tabform view -> hidden fields need to be in the same tab for validation to work (see rev[363]) Modified Paths: -------------- trunk/library/classes/Gems/Default/RespondentAction.php Modified: trunk/library/classes/Gems/Default/RespondentAction.php =================================================================== --- trunk/library/classes/Gems/Default/RespondentAction.php 2012-03-01 15:21:51 UTC (rev 529) +++ trunk/library/classes/Gems/Default/RespondentAction.php 2012-03-01 15:35:00 UTC (rev 530) @@ -124,11 +124,13 @@ $ucfirst = new Zend_Filter_Callback('ucfirst'); + $bridge->addTab( 'caption1')->h4($this->_('Identification')); + //Add the hidden fields after the tab, so validation will work. They need to be in the + //same tab where they are needed $bridge->addHidden( 'grs_id_user'); $bridge->addHidden( 'gr2o_id_organization'); $bridge->addHidden( $model->getKeyCopyName('gr2o_patient_nr')); - $bridge->addTab( 'caption1')->h4($this->_('Identification')); $bridge->addText( 'grs_ssn', 'label', $this->_('SSN'), 'size', 10, 'maxlength', 12) ->addValidator( new MUtil_Validate_Dutch_Burgerservicenummer()) ->addValidator( $model->createUniqueValidator('grs_ssn')) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2012-03-01 15:21:58
|
Revision: 529 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=529&view=rev Author: matijsdejong Date: 2012-03-01 15:21:51 +0000 (Thu, 01 Mar 2012) Log Message: ----------- First round in simplifying ModelSnippetActionAbstract Plus bugfix in DatabaseModelAbstract.php for certain filter cases Modified Paths: -------------- trunk/library/classes/Gems/Controller/ModelSnippetActionAbstract.php trunk/library/classes/Gems/Default/MailJobAction.php trunk/library/classes/Gems/Default/MailLogAction.php trunk/library/classes/Gems/Default/OrganizationAction.php trunk/library/classes/MUtil/Controller/ModelSnippetActionAbstract.php trunk/library/classes/MUtil/Model/DatabaseModelAbstract.php Modified: trunk/library/classes/Gems/Controller/ModelSnippetActionAbstract.php =================================================================== --- trunk/library/classes/Gems/Controller/ModelSnippetActionAbstract.php 2012-03-01 14:06:23 UTC (rev 528) +++ trunk/library/classes/Gems/Controller/ModelSnippetActionAbstract.php 2012-03-01 15:21:51 UTC (rev 529) @@ -47,14 +47,16 @@ abstract class Gems_Controller_ModelSnippetActionAbstract extends MUtil_Controller_ModelSnippetActionAbstract { /** - * The parameters used for the autofilter action. + * Gems only parameters used for the autofilter action. Can be overruled + * by setting $this->autofilterParameters * * @var array Mixed key => value array for snippet initialization */ - protected $autofilterParameters = array( + private $_autofilterExtraParameters = array( 'browse' => true, 'containingId' => 'autofilter_target', 'keyboard' => true, + 'onEmpty' => 'getOnEmpty', ); /** @@ -118,6 +120,21 @@ public $util; /** + * The automatically filtered result + * + * @param $resetMvc When true only the filtered resulsts + */ + public function autofilterAction($resetMvc = true) + { + // Already done when this value is false + if ($resetMvc) { + $this->autofilterParameters = $this->autofilterParameters + $this->_autofilterExtraParameters; + } + + return parent::autofilterAction($resetMvc); + } + + /** * Outputs the model to excel, applying all filters and searches needed * * When you want to change the output, there are two places to check: @@ -224,6 +241,16 @@ } /** + * Returns the on empty texts for the autofilter snippets + * + * @return string + */ + public function getOnEmpty() + { + return $this->_('Nothing found...'); + } + + /** * Returns the current html/head/title for this page. * * If the title is an array the seperator concatenates the parts. @@ -249,6 +276,16 @@ } /** + * Action for showing a browse page + */ + public function indexAction() + { + $this->autofilterParameters = $this->autofilterParameters + $this->_autofilterExtraParameters; + + return parent::indexAction(); + } + + /** * Intializes the html component. * * @param boolean $reset Throws away any existing html output when true Modified: trunk/library/classes/Gems/Default/MailJobAction.php =================================================================== --- trunk/library/classes/Gems/Default/MailJobAction.php 2012-03-01 14:06:23 UTC (rev 528) +++ trunk/library/classes/Gems/Default/MailJobAction.php 2012-03-01 15:21:51 UTC (rev 529) @@ -53,18 +53,6 @@ public $project; /** - * The automatically filtered result - * - * @param $resetMvc When true only the filtered resulsts - */ - public function autofilterAction($resetMvc = true) - { - $this->autofilterParameters['onEmpty'] = $this->_('No automatic mail jobs found...'); - - parent::autofilterAction($resetMvc); - } - - /** * Action for showing a create new item page */ public function createAction() @@ -178,6 +166,16 @@ } /** + * Returns the on empty texts for the autofilter snippets + * + * @return string + */ + public function getOnEmpty() + { + return $this->_('No automatic mail jobs found...'); + } + + /** * Action for showing a browse page */ public function indexAction() Modified: trunk/library/classes/Gems/Default/MailLogAction.php =================================================================== --- trunk/library/classes/Gems/Default/MailLogAction.php 2012-03-01 14:06:23 UTC (rev 528) +++ trunk/library/classes/Gems/Default/MailLogAction.php 2012-03-01 15:21:51 UTC (rev 529) @@ -48,6 +48,21 @@ class Gems_Default_MailLogAction extends Gems_Controller_ModelSnippetActionAbstract { /** + * The parameters used for the autofilter action. + * + * When the value is a function name of that object, then that functions is executed + * with the array key as single parameter and the return value is set as the used value + * - unless the key is an integer in which case the code is executed but the return value + * is not stored. + * + * @var array Mixed key => value array for snippet initialization + */ + protected $autofilterParameters = array( + 'extraFilter' => 'getExtraFilter', + 'extraSort' => array('grco_created' => SORT_DESC), + ); + + /** * The snippets used for the autofilter action. * * @var mixed String or array of snippets name @@ -55,19 +70,6 @@ protected $autofilterSnippets = 'Mail_Log_MailLogBrowseSnippet'; /** - * The automatically filtered result - */ - public function autofilterAction($resetMvc = true) - { - $filter = array('grco_organization' => $this->escort->getCurrentOrganization()); - - $this->autofilterParameters['extraFilter'] = $filter; - $this->autofilterParameters['extraSort'] = array('grco_created' => SORT_DESC); - - return parent::autofilterAction($resetMvc); - } - - /** * Creates a model for getModel(). Called only for each new $action. * * The parameters allow you to easily adapt the model to the current action. The $detailed @@ -122,6 +124,26 @@ } /** + * Returns an extra filter for this action + * + * @return array + */ + protected function getExtraFilter() + { + return array('grco_organization' => $this->escort->getCurrentOrganization()); + } + + /** + * Returns the on empty texts for the autofilter snippets + * + * @return string + */ + public function getOnEmpty() + { + return $this->_('No mail activity found...'); + } + + /** * Action for showing a browse page */ public function indexAction() Modified: trunk/library/classes/Gems/Default/OrganizationAction.php =================================================================== --- trunk/library/classes/Gems/Default/OrganizationAction.php 2012-03-01 14:06:23 UTC (rev 528) +++ trunk/library/classes/Gems/Default/OrganizationAction.php 2012-03-01 15:21:51 UTC (rev 529) @@ -207,6 +207,16 @@ } /** + * Returns the on empty texts for the autofilter snippets + * + * @return string + */ + public function getOnEmpty() + { + return $this->_('No organization found...'); + } + + /** * Action for showing a browse page */ public function indexAction() Modified: trunk/library/classes/MUtil/Controller/ModelSnippetActionAbstract.php =================================================================== --- trunk/library/classes/MUtil/Controller/ModelSnippetActionAbstract.php 2012-03-01 14:06:23 UTC (rev 528) +++ trunk/library/classes/MUtil/Controller/ModelSnippetActionAbstract.php 2012-03-01 15:21:51 UTC (rev 529) @@ -49,6 +49,52 @@ abstract class MUtil_Controller_ModelSnippetActionAbstract extends MUtil_Controller_Action { /** + * Default parameters for createAction, can be overruled by $this->createParameters + * or $this->createEditParameters values with the same key. + * + * When the value is a function name of that object, then that functions is executed + * with the array key as single parameter and the return value is set as the used value + * - unless the key is an integer in which case the code is executed but the return value + * is not stored. + * + * @var array + */ + private $_defaultCreateParameters = array( + 'createData' => true, + ); + + /** + * Default parameters for editAction, can be overruled by $this->editParameters + * or $this->createEditParameters values with the same key. + * + * When the value is a function name of that object, then that functions is executed + * with the array key as single parameter and the return value is set as the used value + * - unless the key is an integer in which case the code is executed but the return value + * is not stored. + * + * @var array + */ + private $_defaultEditParameters = array( + 'createData' => false, + ); + + /** + * Default parameters for all actions, unless overruled by values with the same key at + * the action level + * + * When the value is a function name of that object, then that functions is executed + * with the array key as single parameter and the return value is set as the used value + * - unless the key is an integer in which case the code is executed but the return value + * is not stored. + * + * @var array + */ + private $_defaultParameters = array( + 'model' => 'getModel', + 'request' => 'getRequest', + ); + + /** * Created in createModel(). * * Always retrieve using $this->getModel(). @@ -60,6 +106,11 @@ /** * The parameters used for the autofilter action. * + * When the value is a function name of that object, then that functions is executed + * with the array key as single parameter and the return value is set as the used value + * - unless the key is an integer in which case the code is executed but the return value + * is not stored. + * * @var array Mixed key => value array for snippet initialization */ protected $autofilterParameters = array(); @@ -74,11 +125,30 @@ /** * The parameters used for the create and edit actions. * + * When the value is a function name of that object, then that functions is executed + * with the array key as single parameter and the return value is set as the used value + * - unless the key is an integer in which case the code is executed but the return value + * is not stored. + * * @var array Mixed key => value array for snippet initialization */ protected $createEditParameters = array(); /** + * The parameters used for the edit actions, overrules any values in + * $this->createEditParameters. + * + * + * When the value is a function name of that object, then that functions is executed + * with the array key as single parameter and the return value is set as the used value + * - unless the key is an integer in which case the code is executed but the return value + * is not stored. + * + * @var array Mixed key => value array for snippet initialization + */ + protected $createParameters = array(); + + /** * The snippets used for the create and edit actions. * * @var mixed String or array of snippets name @@ -88,6 +158,11 @@ /** * The parameters used for the delete action. * + * When the value is a function name of that object, then that functions is executed + * with the array key as single parameter and the return value is set as the used value + * - unless the key is an integer in which case the code is executed but the return value + * is not stored. + * * @var array Mixed key => value array for snippet initialization */ protected $deleteParameters = array(); @@ -100,8 +175,26 @@ protected $deleteSnippets = 'ModelYesNoDeleteSnippet'; /** + * The parameters used for the edit actions, overrules any values in + * $this->createEditParameters. + * + * When the value is a function name of that object, then that functions is executed + * with the array key as single parameter and the return value is set as the used value + * - unless the key is an integer in which case the code is executed but the return value + * is not stored. + * + * @var array Mixed key => value array for snippet initialization + */ + protected $editParameters = array(); + + /** * The parameters used for the index action minus those in autofilter. * + * When the value is a function name of that object, then that functions is executed + * with the array key as single parameter and the return value is set as the used value + * - unless the key is an integer in which case the code is executed but the return value + * is not stored. + * * @var array Mixed key => value array for snippet initialization */ protected $indexParameters = array(); @@ -123,6 +216,11 @@ /** * The parameters used for the show action * + * When the value is a function name of that object, then that functions is executed + * with the array key as single parameter and the return value is set as the used value + * - unless the key is an integer in which case the code is executed but the return value + * is not stored. + * * @var array Mixed key => value array for snippet initialization */ protected $showParameters = array(); @@ -165,6 +263,29 @@ } /** + * + * @param array $input + * @return array + */ + protected function _processParameters(array $input) + { + $output = array(); + + foreach ($input + $this->_defaultParameters as $key => $value) { + if (is_string($value) && method_exists($this, $value)) { + $value = $this->$value($key); + + if (is_integer($key) || ($value === null)) { + continue; + } + } + $output[$key] = $value; + } + + return $output; + } + + /** * Set the action key in request * * Use this when an action is a Ajax action for retrieving @@ -197,10 +318,9 @@ } if ($this->autofilterSnippets) { - $this->autofilterParameters['model'] = $this->getModel(); - $this->autofilterParameters['request'] = $this->getRequest(); + $params = $this->_processParameters($this->autofilterParameters); - $this->addSnippets($this->autofilterSnippets, $this->autofilterParameters); + $this->addSnippets($this->autofilterSnippets, $params); } if ($resetMvc && MUtil_Echo::hasOutput()) { @@ -216,28 +336,13 @@ public function createAction() { if ($this->createEditSnippets) { - $this->createEditParameters['createData'] = true; - $this->createEditParameters['model'] = $this->getModel(); - $this->createEditParameters['request'] = $this->getRequest(); + $params = $this->_processParameters($this->createParameters + $this->createEditParameters + $this->_defaultCreateParameters); - $this->addSnippets($this->createEditSnippets, $this->createEditParameters); + $this->addSnippets($this->createEditSnippets, $params); } } /** - * Action for showing a delete item page - */ - public function deleteAction() - { - if ($this->deleteSnippets) { - $this->deleteParameters['model'] = $this->getModel(); - $this->deleteParameters['request'] = $this->getRequest(); - - $this->addSnippets($this->deleteSnippets, $this->deleteParameters); - } - } - - /** * Creates a model for getModel(). Called only for each new $action. * * The parameters allow you to easily adapt the model to the current action. The $detailed @@ -251,16 +356,26 @@ abstract protected function createModel($detailed, $action); /** + * Action for showing a delete item page + */ + public function deleteAction() + { + if ($this->deleteSnippets) { + $params = $this->_processParameters($this->deleteParameters); + + $this->addSnippets($this->deleteSnippets, $params); + } + } + + /** * Action for showing a edit item page */ public function editAction() { if ($this->createEditSnippets) { - $this->createEditParameters['createData'] = false; - $this->createEditParameters['model'] = $this->getModel(); - $this->createEditParameters['request'] = $this->getRequest(); + $params = $this->_processParameters($this->editParameters + $this->createEditParameters + $this->_defaultEditParameters); - $this->addSnippets($this->createEditSnippets, $this->createEditParameters); + $this->addSnippets($this->createEditSnippets, $params); } } @@ -293,27 +408,23 @@ return $this->_model; } - /** * Action for showing a browse page */ public function indexAction() { if ($this->indexStartSnippets || $this->indexStopSnippets) { - $this->indexParameters = $this->indexParameters + $this->autofilterParameters; + $params = $this->_processParameters($this->indexParameters + $this->autofilterParameters); - $this->indexParameters['model'] = $this->getModel(); - $this->indexParameters['request'] = $this->getRequest(); - if ($this->indexStartSnippets) { - $this->addSnippets($this->indexStartSnippets, $this->indexParameters); + $this->addSnippets($this->indexStartSnippets, $params); } } $this->autofilterAction(false); if ($this->indexStopSnippets) { - $this->addSnippets($this->indexStopSnippets, $this->indexParameters); + $this->addSnippets($this->indexStopSnippets, $params); } } @@ -323,10 +434,9 @@ public function showAction() { if ($this->showSnippets) { - $this->showParameters['model'] = $this->getModel(); - $this->showParameters['request'] = $this->getRequest(); + $params = $this->_processParameters($this->showParameters); - $this->addSnippets($this->showSnippets, $this->showParameters); + $this->addSnippets($this->showSnippets, $params); } } } Modified: trunk/library/classes/MUtil/Model/DatabaseModelAbstract.php =================================================================== --- trunk/library/classes/MUtil/Model/DatabaseModelAbstract.php 2012-03-01 14:06:23 UTC (rev 528) +++ trunk/library/classes/MUtil/Model/DatabaseModelAbstract.php 2012-03-01 15:21:51 UTC (rev 529) @@ -722,7 +722,15 @@ $wheres[] = $sqlField . ' LIKE \'%' . $search . '%\''; } } - $filter[] = implode(' ' . Zend_Db_Select::SQL_OR . ' ', $wheres); + + if ($wheres) { + $filter[] = implode(' ' . Zend_Db_Select::SQL_OR . ' ', $wheres); + } else { + // When all fields are multiOption fields that do not result in a + // filter, then there is no existing filter and the result set + // should always be empty. + $filter[] = '1=0'; + } } } } 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-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 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 12:08:39
|
Revision: 525 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=525&view=rev Author: mennodekker Date: 2012-03-01 12:08:30 +0000 (Thu, 01 Mar 2012) Log Message: ----------- Moving to a better directory structure Modified Paths: -------------- trunk/library/classes/Gems/Upgrades.php Added Paths: ----------- trunk/library/classes/Gems/Task/Db/ trunk/library/classes/Gems/Task/Db/CreateNewTable.php trunk/library/classes/Gems/Task/Db/CreateNewTables.php Removed Paths: ------------- trunk/library/classes/Gems/Task/CreateNewTable.php trunk/library/classes/Gems/Task/CreateNewTables.php Deleted: trunk/library/classes/Gems/Task/CreateNewTable.php =================================================================== --- trunk/library/classes/Gems/Task/CreateNewTable.php 2012-03-01 12:05:22 UTC (rev 524) +++ trunk/library/classes/Gems/Task/CreateNewTable.php 2012-03-01 12:08:30 UTC (rev 525) @@ -1,104 +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 $ - */ - -/** - * 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 Deleted: trunk/library/classes/Gems/Task/CreateNewTables.php =================================================================== --- trunk/library/classes/Gems/Task/CreateNewTables.php 2012-03-01 12:05:22 UTC (rev 524) +++ trunk/library/classes/Gems/Task/CreateNewTables.php 2012-03-01 12:08:30 UTC (rev 525) @@ -1,96 +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 $ - */ - -/** - * Schedules creation of new tables - * - * @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)); - - foreach($todo as $tableData) { - $this->_batch->addToCounter('NewTableCount'); - $this->_batch->setTask('CreateNewTable', 'create-tbl-' . $tableData['name'], $tableData); - } - } - - /** - * 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/Db/CreateNewTable.php =================================================================== --- trunk/library/classes/Gems/Task/Db/CreateNewTable.php (rev 0) +++ trunk/library/classes/Gems/Task/Db/CreateNewTable.php 2012-03-01 12:08:30 UTC (rev 525) @@ -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_Db_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 Added: trunk/library/classes/Gems/Task/Db/CreateNewTables.php =================================================================== --- trunk/library/classes/Gems/Task/Db/CreateNewTables.php (rev 0) +++ trunk/library/classes/Gems/Task/Db/CreateNewTables.php 2012-03-01 12:08:30 UTC (rev 525) @@ -0,0 +1,96 @@ +<?php +/** + * Copyright (c) 2011, Erasmus MC + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Erasmus MC nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * @package Gems + * @subpackage Task + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @version $Id: CheckTokenCompletion.php 502 2012-02-20 14:13:20Z mennodekker $ + */ + +/** + * Schedules creation of new tables + * + * @package Gems + * @subpackage Task + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @since Class available since version 1.6 + */ +class Gems_Task_Db_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)); + + foreach($todo as $tableData) { + $this->_batch->addToCounter('NewTableCount'); + $this->_batch->setTask('Db_CreateNewTable', 'create-tbl-' . $tableData['name'], $tableData); + } + } + + /** + * 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/Upgrades.php =================================================================== --- trunk/library/classes/Gems/Upgrades.php 2012-03-01 12:05:22 UTC (rev 524) +++ trunk/library/classes/Gems/Upgrades.php 2012-03-01 12:08:30 UTC (rev 525) @@ -70,7 +70,7 @@ $this->_batch->addTask('ExecutePatch', 42); $this->_batch->addTask('ExecutePatch', 43); - $this->_batch->addTask('CreateNewTables'); + $this->_batch->addTask('Db_CreateNewTables'); $this->_batch->addTask('Echo', $this->_('Syncing surveys for all sources')); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2012-03-01 12:05:34
|
Revision: 524 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=524&view=rev Author: mennodekker Date: 2012-03-01 12:05:22 +0000 (Thu, 01 Mar 2012) Log Message: ----------- Fixing loader problem where no new task was created after the first one + some cleanup Modified Paths: -------------- trunk/library/classes/Gems/Loader.php trunk/library/classes/Gems/Task/TaskRunnerBatch.php trunk/library/classes/Gems/Upgrades.php trunk/library/classes/Gems/UpgradesAbstract.php Modified: trunk/library/classes/Gems/Loader.php =================================================================== --- trunk/library/classes/Gems/Loader.php 2012-03-01 10:53:11 UTC (rev 523) +++ trunk/library/classes/Gems/Loader.php 2012-03-01 12:05:22 UTC (rev 524) @@ -206,7 +206,7 @@ * @return Gems_Task_TaskAbstract */ public function getTask($name) { - return $this->_getClass('task', 'Task_' . ucfirst($name)); + return $this->_loadClass('Task_' . ucfirst($name), true); } /** Modified: trunk/library/classes/Gems/Task/TaskRunnerBatch.php =================================================================== --- trunk/library/classes/Gems/Task/TaskRunnerBatch.php 2012-03-01 10:53:11 UTC (rev 523) +++ trunk/library/classes/Gems/Task/TaskRunnerBatch.php 2012-03-01 12:05:22 UTC (rev 524) @@ -71,6 +71,7 @@ public function addMessage($text) { parent::addMessage($text); + return $this; } /** @@ -120,7 +121,8 @@ */ public function setMessage($id, $text) { - return parent::setMessage($id, $text); + parent::setMessage($id, $text); + return $this; } /** Modified: trunk/library/classes/Gems/Upgrades.php =================================================================== --- trunk/library/classes/Gems/Upgrades.php 2012-03-01 10:53:11 UTC (rev 523) +++ trunk/library/classes/Gems/Upgrades.php 2012-03-01 12:05:22 UTC (rev 524) @@ -72,20 +72,17 @@ $this->_batch->addTask('CreateNewTables'); - $this->addMessage($this->_('Syncing surveys for all sources')); + $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); - $tracker = $this->loader->getTracker(); - foreach ($data as $row) { $this->_batch->addTask('SourceSyncSurveys', $row['gso_id_source']); } - $this->invalidateCache(); - return true; } Modified: trunk/library/classes/Gems/UpgradesAbstract.php =================================================================== --- trunk/library/classes/Gems/UpgradesAbstract.php 2012-03-01 10:53:11 UTC (rev 523) +++ trunk/library/classes/Gems/UpgradesAbstract.php 2012-03-01 12:05:22 UTC (rev 524) @@ -69,11 +69,6 @@ public $db; /** - * @var Gems_Model_DbaModel - */ - public $dbaModel; - - /** * @var GemsEscort */ public $escort; @@ -84,12 +79,6 @@ public $loader; /** - * - * @var Gems_Util_DatabasePatcher - */ - public $patcher; - - /** * @var Gems_Project_ProjectSettings */ public $project; @@ -130,33 +119,10 @@ */ protected function addMessage($message) { - $this->_messages[] = $message; + $this->_batch->addMessage($message); } - /** - * Now we have the requests answered, add the DatabasePatcher as it needs the db object - * - * @return boolean - */ - public function checkRegistryRequestsAnswers() { - //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()); - - //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; - } - - /** + /** * Reset the message stack */ protected function clearMessages() @@ -165,29 +131,6 @@ } /** - * Create all new tables according to the dba model - */ - protected function createNewTables() - { - //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->_('Finished %s creation script for object %d of %d'), $this->_(strtolower($tableData['type'])), $i, $oCount) . '<br/>'; - $i++; - } - - foreach ($results as $result) - { - $this->addMessage($result); - } - } - - /** * Execute upgrades for the given $context * * When no $to or $from are given, the given $context will be upgraded from the current level @@ -226,7 +169,6 @@ $this->addMessage(sprintf($this->_('Trying upgrade for %s to level %s: %s'), $context, $level, $this->_upgradeStack[$context][$level]['info'])); if (call_user_func($upgrade['upgrade'])) { $success = $level; - $this->addMessage('OK'); } else { $this->addMessage('FAILED'); break; @@ -373,19 +315,6 @@ } /** - * Convenience method for cleaning the cache as this is often needed during - * upgrades - */ - public function invalidateCache() - { - $cache = $this->escort->cache; - if ($cache instanceof Zend_Cache_Core) { - $cache->clean(); - $this->addMessage($this->_('Cache cleaned')); - } - } - - /** * Register an upgrade in the stack, it can be executed by using $this->execute * * Index and context are optional and will be generated when omitted. For the This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2012-03-01 10:53:22
|
Revision: 523 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=523&view=rev Author: mennodekker Date: 2012-03-01 10:53:11 +0000 (Thu, 01 Mar 2012) Log Message: ----------- Report back after first step so we know something is happening Modified Paths: -------------- trunk/library/classes/MUtil/Batch/BatchAbstract.php Modified: trunk/library/classes/MUtil/Batch/BatchAbstract.php =================================================================== --- trunk/library/classes/MUtil/Batch/BatchAbstract.php 2012-03-01 09:36:15 UTC (rev 522) +++ trunk/library/classes/MUtil/Batch/BatchAbstract.php 2012-03-01 10:53:11 UTC (rev 523) @@ -571,7 +571,7 @@ // error_log('Rep: ' . $reportRun); while ($this->step()) { // error_log('Cur: ' . microtime(true) . ' report is '. (microtime(true) > $reportRun ? 'true' : 'false')); - if (microtime(true) > $reportRun) { + if ($this->_session->processed == 1 || microtime(true) > $reportRun) { // Communicate progress $bar->update($this->getProgressPercentage(), $this->getLastMessage()); 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:36:24
|
Revision: 522 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=522&view=rev Author: mennodekker Date: 2012-03-01 09:36:15 +0000 (Thu, 01 Mar 2012) Log Message: ----------- As testing is done, increase the minimal step again to improve speed Modified Paths: -------------- trunk/library/classes/Gems/Default/UpgradeAction.php Modified: trunk/library/classes/Gems/Default/UpgradeAction.php =================================================================== --- trunk/library/classes/Gems/Default/UpgradeAction.php 2012-03-01 09:30:23 UTC (rev 521) +++ trunk/library/classes/Gems/Default/UpgradeAction.php 2012-03-01 09:36:15 UTC (rev 522) @@ -83,7 +83,7 @@ $to = $this->getRequest()->getParam('to'); $batch = $this->loader->getTaskRunnerBatch('upgrade' . $context); - $batch->minimalStepDurationMs = 0; //One step at a time, can be higher to improve speed + $batch->minimalStepDurationMs = 3000; // 3 seconds max before sending feedback if (!$batch->isLoaded()) { $this->_upgrades->setBatch($batch); 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:30:34
|
Revision: 521 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=521&view=rev Author: mennodekker Date: 2012-03-01 09:30:23 +0000 (Thu, 01 Mar 2012) Log Message: ----------- Whoops... Modified Paths: -------------- trunk/library/classes/Gems/Task/SourceSyncSurveys.php Modified: trunk/library/classes/Gems/Task/SourceSyncSurveys.php =================================================================== --- trunk/library/classes/Gems/Task/SourceSyncSurveys.php 2012-03-01 09:22:39 UTC (rev 520) +++ trunk/library/classes/Gems/Task/SourceSyncSurveys.php 2012-03-01 09:30:23 UTC (rev 521) @@ -41,16 +41,11 @@ * @license New BSD License * @since Class available since version 1.6 */ -class Gems_Task_SourceSyncSurveys +class Gems_Task_SourceSyncSurveys extends Gems_Task_TaskAbstract { - /** - * @var Gems_Tracker - */ - public $tracker; - public function execute($id = null) { - $source = $tracker->getSource($id); + $source = $this->loader->getTracker()->getSource($id); if ($messages = $source->synchronizeSurveys($this->loader->getCurrentUser()->getUserId())) { foreach ($messages as $message) { 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-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-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 09:56:50
|
Revision: 517 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=517&view=rev Author: mennodekker Date: 2012-02-29 09:56:41 +0000 (Wed, 29 Feb 2012) Log Message: ----------- Removed duplicate 'remove' option for sources Modified Paths: -------------- trunk/library/classes/Gems/Menu/MenuAbstract.php Modified: trunk/library/classes/Gems/Menu/MenuAbstract.php =================================================================== --- trunk/library/classes/Gems/Menu/MenuAbstract.php 2012-02-28 16:36:56 UTC (rev 516) +++ trunk/library/classes/Gems/Menu/MenuAbstract.php 2012-02-29 09:56:41 UTC (rev 517) @@ -412,7 +412,6 @@ // SURVEY SOURCES CONTROLLER $page = $setup->addBrowsePage($this->_('Survey Sources'), 'pr.source', 'source'); - $page->addDeleteAction(); $page->addAction($this->_('Check status'), null, 'ping')->addParameters(MUtil_Model::REQUEST_ID); $page->addAction($this->_('Synchronize surveys'), 'pr.source.synchronize', 'synchronize')->addParameters(MUtil_Model::REQUEST_ID); $page->addAction($this->_('Check answers'), 'pr.source.check-answers', 'check')->addParameters(MUtil_Model::REQUEST_ID); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2012-02-28 16:37:05
|
Revision: 516 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=516&view=rev Author: matijsdejong Date: 2012-02-28 16:36:56 +0000 (Tue, 28 Feb 2012) Log Message: ----------- Solved encoding problem in url's Added IFrame element Modified Paths: -------------- trunk/library/classes/MUtil/Html/AElement.php trunk/library/classes/MUtil/Html/Creator.php trunk/library/classes/MUtil/Html/UrlArrayAttribute.php Added Paths: ----------- trunk/library/classes/MUtil/Html/IFrame.php Modified: trunk/library/classes/MUtil/Html/AElement.php =================================================================== --- trunk/library/classes/MUtil/Html/AElement.php 2012-02-23 15:40:31 UTC (rev 515) +++ trunk/library/classes/MUtil/Html/AElement.php 2012-02-28 16:36:56 UTC (rev 516) @@ -36,7 +36,7 @@ */ /** - * Class for A/link element. Assumes first passed argument is the href attribute, + * Class for A link element. Assumes first passed argument is the href attribute, * unless specified otherwise. * * @package MUtil @@ -45,7 +45,6 @@ * @license New BSD License * @since Class available since version 1.0 */ - class MUtil_Html_AElement extends MUtil_Html_HtmlElement { public $renderWithoutContent = true; Modified: trunk/library/classes/MUtil/Html/Creator.php =================================================================== --- trunk/library/classes/MUtil/Html/Creator.php 2012-02-23 15:40:31 UTC (rev 515) +++ trunk/library/classes/MUtil/Html/Creator.php 2012-02-28 16:36:56 UTC (rev 516) @@ -91,6 +91,7 @@ 'if' => 'MUtil_Lazy::iff', 'iflink' => 'MUtil_Html_AElement::iflink', 'ifmail' => 'MUtil_Html_AElement::ifmail', + 'iframe' => 'MUtil_Html_IFrameElement::iFrame', 'img' => 'MUtil_Html_ImgElement::img', 'image' => 'MUtil_Html_ImgElement::img', 'input' => 'MUtil_Html_InputRenderer::input', Added: trunk/library/classes/MUtil/Html/IFrame.php =================================================================== --- trunk/library/classes/MUtil/Html/IFrame.php (rev 0) +++ trunk/library/classes/MUtil/Html/IFrame.php 2012-02-28 16:36:56 UTC (rev 516) @@ -0,0 +1,97 @@ +<?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 MUtil + * @subpackage Html + * @author Matijs de Jong <mj...@ma...> + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @version $Id: AElement.php 515 2012-02-23 15:40:31Z matijsdejong $ + */ + +/** + * Class for IFRAME element. Assumes first passed argument is the src attribute, + * unless specified otherwise. Always specifies closing tag. + * + * @package MUtil + * @subpackage Html + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @since Class available since version 1.5.2 + */ +class MUtil_Html_IFrame extends MUtil_Html_HtmlElement +{ + /** + * Some elements, e.g. iframe elements, must always be rendered with a closing + * tag because otherwise some poor browsers get confused. + * + * Overrules $renderWithoutContent: the element is always rendered when + * $renderClosingTag is true. + * + * @see $renderWithoutContent + * + * @var boolean The element is always rendered with a closing tag. + */ + public $renderClosingTag = true; + + /** + * An iframe element. + * + * Any extra parameters are added as either content, attributes or handled + * as special types, if defined as such for this element. + * + * @param mixed $src We assume the first element is src, unless a later element is explicitly specified as such + * @param mixed $arg_array MUtil_Ra::args arguments + */ + public function __construct($src, $arg_array = null) + { + $args = MUtil_Ra::args(func_get_args(), array('src' => 'MUtil_Html_SrcArrayAttribute')); + + if (isset($args['src']) && (! $args['src'] instanceof MUtil_Html_AttributeInterface)) { + $args['src'] = new MUtil_Html_SrcArrayAttribute($args['src']); + } + + parent::__construct('iframe', $args); + } + + /** + * Static helper function to create an iframe element. + * + * Any extra parameters are added as either content, attributes or handled + * as special types, if defined as such for this element. + * + * @param mixed $src We assume the first element is src, unless a later element is explicitly specified as such + * @param mixed $arg_array MUtil_Ra::args arguments + */ + public static function iFrame($src, $arg_array = null) + { + $args = MUtil_Ra::args(func_get_args(), array('src' => 'MUtil_Html_SrcArrayAttribute')); + return new self($args); + } +} Modified: trunk/library/classes/MUtil/Html/UrlArrayAttribute.php =================================================================== --- trunk/library/classes/MUtil/Html/UrlArrayAttribute.php 2012-02-23 15:40:31 UTC (rev 515) +++ trunk/library/classes/MUtil/Html/UrlArrayAttribute.php 2012-02-28 16:36:56 UTC (rev 516) @@ -1,34 +1,34 @@ <?php - -/** - * Copyright (c) 2011, Erasmus MC - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of Erasmus MC nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - + /** + * Copyright (c) 2011, Erasmus MC + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Erasmus MC nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/** * @author Matijs de Jong * @since 1.0 * @version 1.1 @@ -62,7 +62,9 @@ if (is_numeric($key)) { $url_string .= $value; } else { - $url_parameters[$key] = $value; + // Prevent double escaping by using rawurlencode() instead + // of urlencode() that is used by Zend_Controller_Router_Route + $url_parameters[$key] = rawurlencode($value); } } @@ -83,7 +85,7 @@ // Make sure controllor, action, module are specified $url_parameters = self::rerouteUrl($this->getRequest(), $url_parameters); - return $this->getView()->url($url_parameters, null, $this->getRouteReset()); + return $this->getView()->url($url_parameters, null, $this->getRouteReset(), false); } return null; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2012-02-23 15:40:41
|
Revision: 515 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=515&view=rev Author: matijsdejong Date: 2012-02-23 15:40:31 +0000 (Thu, 23 Feb 2012) Log Message: ----------- Added SrcArrayAttribute Added documentation Modified Paths: -------------- trunk/library/classes/Gems/Html.php trunk/library/classes/MUtil/Html/AElement.php trunk/library/classes/MUtil/Html/AttributeAbstract.php trunk/library/classes/MUtil/Html/Creator.php trunk/library/classes/MUtil/Html/HrefArrayAttribute.php trunk/library/classes/MUtil/Html/HtmlElement.php trunk/library/classes/MUtil/Html.php Added Paths: ----------- trunk/library/classes/MUtil/Html/SrcArrayAttribute.php Modified: trunk/library/classes/Gems/Html.php =================================================================== --- trunk/library/classes/Gems/Html.php 2012-02-23 15:00:56 UTC (rev 514) +++ trunk/library/classes/Gems/Html.php 2012-02-23 15:40:31 UTC (rev 515) @@ -1,6 +1,5 @@ <?php - /** * Copyright (c) 2011, Erasmus MC * All rights reserved. Modified: trunk/library/classes/MUtil/Html/AElement.php =================================================================== --- trunk/library/classes/MUtil/Html/AElement.php 2012-02-23 15:00:56 UTC (rev 514) +++ trunk/library/classes/MUtil/Html/AElement.php 2012-02-23 15:40:31 UTC (rev 515) @@ -50,6 +50,15 @@ { public $renderWithoutContent = true; + /** + * An A element, shows the url as content when no other content is available. + * + * Any extra parameters are added as either content, attributes or handled + * as special types, if defined as such for this element. + * + * @param mixed $href We assume the first element contains the href, unless a later element is explicitly specified as such + * @param mixed $arg_array MUtil_Ra::args arguments + */ public function __construct($href, $arg_array = null) { $args = MUtil_Ra::args(func_get_args(), array('href' => 'MUtil_Html_HrefArrayAttribute')); @@ -81,6 +90,15 @@ return parent::_htmlAttribs($attribs); } + /** + * Static helper function to create an A element. + * + * Any extra parameters are added as either content, attributes or handled + * as special types, if defined as such for this element. + * + * @param mixed $href We assume the first element contains the href, unless a later element is explicitly specified as such + * @param mixed $arg_array MUtil_Ra::args arguments + */ public static function a($href, $arg_array = null) { $args = MUtil_Ra::args(func_get_args(), array('href' => 'MUtil_Html_HrefArrayAttribute')); Modified: trunk/library/classes/MUtil/Html/AttributeAbstract.php =================================================================== --- trunk/library/classes/MUtil/Html/AttributeAbstract.php 2012-02-23 15:00:56 UTC (rev 514) +++ trunk/library/classes/MUtil/Html/AttributeAbstract.php 2012-02-23 15:40:31 UTC (rev 515) @@ -46,7 +46,6 @@ * @license New BSD License * @since Class available since version 1.0 */ - abstract class MUtil_Html_AttributeAbstract implements MUtil_Html_AttributeInterface { public $view; Modified: trunk/library/classes/MUtil/Html/Creator.php =================================================================== --- trunk/library/classes/MUtil/Html/Creator.php 2012-02-23 15:00:56 UTC (rev 514) +++ trunk/library/classes/MUtil/Html/Creator.php 2012-02-23 15:40:31 UTC (rev 515) @@ -68,6 +68,7 @@ protected $_initialAttributeFunctions = array( 'href' => 'MUtil_Html_HrefArrayAttribute::hrefAttribute', 'onclick' => 'MUtil_Html_OnClickArrayAttribute::onclickAttribute', + 'src' => 'MUtil_Html_SrcArrayAttribute::srcAttribute', 'style' => 'MUtil_Html_StyleArrayAttribute::styleAttribute', ); Modified: trunk/library/classes/MUtil/Html/HrefArrayAttribute.php =================================================================== --- trunk/library/classes/MUtil/Html/HrefArrayAttribute.php 2012-02-23 15:00:56 UTC (rev 514) +++ trunk/library/classes/MUtil/Html/HrefArrayAttribute.php 2012-02-23 15:40:31 UTC (rev 515) @@ -1,41 +1,53 @@ <?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. - */ - /** - * @author Matijs de Jong - * @since 1.0 - * @version 1.1 - * @package MUtil + * 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 MUtil * @subpackage Html + * @author Matijs de Jong <mj...@ma...> + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @version $Id$ */ +/** + * Href attribute, i.e the name is fixed. + * + * Behaves as parent class otherwise + * + * @see MUtil_Html_UrlArrayAttribute + * + * @package MUtil + * @subpackage Html + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @since Class available since version 1.0 + */ class MUtil_Html_HrefArrayAttribute extends MUtil_Html_UrlArrayAttribute { public function __construct($args_array = null) @@ -48,4 +60,4 @@ { return new self($commands); } -} \ No newline at end of file +} Modified: trunk/library/classes/MUtil/Html/HtmlElement.php =================================================================== --- trunk/library/classes/MUtil/Html/HtmlElement.php 2012-02-23 15:00:56 UTC (rev 514) +++ trunk/library/classes/MUtil/Html/HtmlElement.php 2012-02-23 15:40:31 UTC (rev 515) @@ -569,6 +569,9 @@ /** * Make an element with the specified tag name. * + * Any extra parameters are added as either content, attributes or handled + * as special types, if defined as such for this element. + * * @param string $tagName * @param mixed $arg_array MUtil_Ra::args arguments */ Added: trunk/library/classes/MUtil/Html/SrcArrayAttribute.php =================================================================== --- trunk/library/classes/MUtil/Html/SrcArrayAttribute.php (rev 0) +++ trunk/library/classes/MUtil/Html/SrcArrayAttribute.php 2012-02-23 15:40:31 UTC (rev 515) @@ -0,0 +1,63 @@ +<?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 MUtil + * @subpackage Html + * @author Matijs de Jong <mj...@ma...> + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @version $Id: AttributeAbstract.php 514 2012-02-23 15:00:56Z matijsdejong $ + */ + +/** + * Src attribute, i.e the name is fixed. + * + * Behaves as parent class otherwise + * + * @see MUtil_Html_UrlArrayAttribute + * + * @package MUtil + * @subpackage Html + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @since Class available since version 1.0 + */ +class MUtil_Html_SrcArrayAttribute extends MUtil_Html_UrlArrayAttribute +{ + public function __construct($args_array = null) + { + $args = func_get_args(); + parent::__construct('src', $args); + } + + public static function srcAttribute(array $commands = null) + { + return new self($commands); + } +} Modified: trunk/library/classes/MUtil/Html.php =================================================================== --- trunk/library/classes/MUtil/Html.php 2012-02-23 15:00:56 UTC (rev 514) +++ trunk/library/classes/MUtil/Html.php 2012-02-23 15:40:31 UTC (rev 515) @@ -154,6 +154,11 @@ return self::name2id($element->getName(), $element->getBelongsTo()); } + /** + * Helper function to access the core creator. + * + * @return MUtil_Html_Creator + */ public static function getCreator() { if (! self::$_creator) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2012-02-23 15:01:07
|
Revision: 514 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=514&view=rev Author: matijsdejong Date: 2012-02-23 15:00:56 +0000 (Thu, 23 Feb 2012) Log Message: ----------- MUtl_Html bugfixes / documentation RespondentUserDefinition.php bugfix: user_group not added SubMenuItem.php extra function isAllowed() and extra documentation Modified Paths: -------------- trunk/library/classes/Gems/Menu/SubMenuItem.php trunk/library/classes/Gems/Tracker/Token/TokenSelect.php trunk/library/classes/Gems/User/RespondentUserDefinition.php trunk/library/classes/MUtil/Html/Attribute.php trunk/library/classes/MUtil/Html/AttributeAbstract.php trunk/library/classes/MUtil/Html.php Modified: trunk/library/classes/Gems/Menu/SubMenuItem.php =================================================================== --- trunk/library/classes/Gems/Menu/SubMenuItem.php 2012-02-23 12:27:01 UTC (rev 513) +++ trunk/library/classes/Gems/Menu/SubMenuItem.php 2012-02-23 15:00:56 UTC (rev 514) @@ -725,11 +725,26 @@ } } + /** + * True when allowed + * + * @return boolean + */ + public function isAllowed() + { + return $this->get('allowed', true); + } + public function isTopLevel() { return ! $this->has('controller'); } + /** + * True when visible + * + * @return boolean + */ public function isVisible() { return $this->get('visible', true); Modified: trunk/library/classes/Gems/Tracker/Token/TokenSelect.php =================================================================== --- trunk/library/classes/Gems/Tracker/Token/TokenSelect.php 2012-02-23 12:27:01 UTC (rev 513) +++ trunk/library/classes/Gems/Tracker/Token/TokenSelect.php 2012-02-23 15:00:56 UTC (rev 514) @@ -100,7 +100,7 @@ */ public function andReceptionCodes($fields = '*') { - $this->sql_select->join('gems__reception_codes', + $this->sql_select->join('gems__reception_codes', 'gto_reception_code = grc_id_reception_code', $fields); Modified: trunk/library/classes/Gems/User/RespondentUserDefinition.php =================================================================== --- trunk/library/classes/Gems/User/RespondentUserDefinition.php 2012-02-23 12:27:01 UTC (rev 513) +++ trunk/library/classes/Gems/User/RespondentUserDefinition.php 2012-02-23 15:00:56 UTC (rev 514) @@ -73,11 +73,13 @@ 'user_gender' => 'grs_gender', 'user_locale' => 'grs_iso_lang', )) - ->join('gems__organizations', 'gr2o_id_organization=gor_id_organization', array()) - ->join('gems__groups', 'gor_respondent_group=ggp_id_group', array( - 'user_role'=>'ggp_role', - 'user_allowed_ip_ranges' => 'ggp_allowed_ip_ranges', - )) + ->join('gems__organizations', 'gr2o_id_organization = gor_id_organization', array( + 'user_group' => 'gor_respondent_group', + )) + ->join('gems__groups', 'gor_respondent_group = ggp_id_group', array( + 'user_role' => 'ggp_role', + 'user_allowed_ip_ranges' => 'ggp_allowed_ip_ranges', + )) ->joinLeft('gems__user_passwords', 'gul_id_user = gup_id_user', array( 'user_password_reset' => 'gup_reset_required', )) Modified: trunk/library/classes/MUtil/Html/Attribute.php =================================================================== --- trunk/library/classes/MUtil/Html/Attribute.php 2012-02-23 12:27:01 UTC (rev 513) +++ trunk/library/classes/MUtil/Html/Attribute.php 2012-02-23 15:00:56 UTC (rev 514) @@ -1,41 +1,49 @@ <?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. - */ - /** - * @author Matijs de Jong - * @since 1.0 - * @version 1.1 - * @package MUtil + * 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 MUtil * @subpackage Html + * @author Matijs de Jong <mj...@ma...> + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @version $Id$ */ +/** + * A simple, basic one value attribute + * + * @package MUtil + * @subpackage Html + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @since Class available since version 1.0 + */ + class MUtil_Html_Attribute extends MUtil_Html_AttributeAbstract { private $_value; @@ -58,7 +66,7 @@ public function get() { - return $this->value; + return $this->_value; } public function set($value) Modified: trunk/library/classes/MUtil/Html/AttributeAbstract.php =================================================================== --- trunk/library/classes/MUtil/Html/AttributeAbstract.php 2012-02-23 12:27:01 UTC (rev 513) +++ trunk/library/classes/MUtil/Html/AttributeAbstract.php 2012-02-23 15:00:56 UTC (rev 514) @@ -1,41 +1,52 @@ <?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. - */ - + /** - * @author Matijs de Jong - * @since 1.0 - * @version 1.1 - * @package MUtil + * 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 MUtil * @subpackage Html + * @author Matijs de Jong <mj...@ma...> + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @version $Id$ */ +/** + * Basic class for all attributes, does the rendering and attribute name parts, + * but no value processing. + * + * @package MUtil + * @subpackage Html + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @since Class available since version 1.0 + */ + abstract class MUtil_Html_AttributeAbstract implements MUtil_Html_AttributeInterface { public $view; Modified: trunk/library/classes/MUtil/Html.php =================================================================== --- trunk/library/classes/MUtil/Html.php 2012-02-23 12:27:01 UTC (rev 513) +++ trunk/library/classes/MUtil/Html.php 2012-02-23 15:00:56 UTC (rev 514) @@ -261,7 +261,7 @@ * * @param string $name Snippet name * @param MUtil_Ra::pairs $parameter_value_pairs Optional extra snippets - * @return + * @return MUtil_Snippets_SnippetInterface */ public static function snippet($name, $parameter_value_pairs = null) { @@ -273,7 +273,11 @@ $loader = self::getSnippetLoader(); - return $loader->getSnippet($name, $extraSourceParameters); + $snippet = $loader->getSnippet($name, $extraSourceParameters); + + if ($snippet->hasHtmlOutput()) { + return $snippet; + } } public static function url($arg_array = null) 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:11
|
Revision: 513 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=513&view=rev Author: matijsdejong Date: 2012-02-23 12:27:01 +0000 (Thu, 23 Feb 2012) Log Message: ----------- Added respondent creation and initial password to core Modified Paths: -------------- trunk/new_project/application/configs/project.ini Modified: trunk/new_project/application/configs/project.ini =================================================================== --- trunk/new_project/application/configs/project.ini 2012-02-23 12:26:49 UTC (rev 512) +++ trunk/new_project/application/configs/project.ini 2012-02-23 12:27:01 UTC (rev 513) @@ -10,7 +10,7 @@ ; Put %s somewhere within the salt to mix the value ; in the salt. ;--------------------------------------------------- -salt = +salt = ;---------------------------------------------------------- ; The non database super user @@ -19,7 +19,7 @@ ; and quoted if it contains special characters. ;---------------------------------------------------------- admin.user = superadmin -admin.pwd = +admin.pwd = ;admin.ipRanges = css.gems = gems/css/gems-fixed.css @@ -215,6 +215,15 @@ ; organization.default = 70 ;---------------------------------------------------------------------- +; PASSWORD SECTION +; +; Allows default setting of initial password for new users: +; password.firstPassword = sesame +;---------------------------------------------------------------------- + +;password.initialPassword = sesame + +;---------------------------------------------------------------------- ; PASSWORDS SECTION ; ; The last key must be a function name in your PasswordChecker class. 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-23 10:52:51
|
Revision: 511 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=511&view=rev Author: matijsdejong Date: 2012-02-23 10:52:42 +0000 (Thu, 23 Feb 2012) Log Message: ----------- Added revisions 508 & 510 from tags/1.5.1 Modified Paths: -------------- trunk/library/classes/Gems/Default/DatabaseAction.php trunk/library/classes/Gems/Email/EmailFormAbstract.php trunk/library/classes/Gems/Email/OneMailForm.php Property Changed: ---------------- trunk/ trunk/library/ Property changes on: trunk ___________________________________________________________________ Modified: svn:mergeinfo - /branches/1.5.0-pulse:306-430,467 /branches/1.5.x:426-455,458-472,475-481 /tags/1.5.0beta1:305 /tags/1.5.1:485,489 + /branches/1.5.0-pulse:306-430,467 /branches/1.5.x:426-455,458-472,475-481 /tags/1.5.0beta1:305 /tags/1.5.1:485,489,509-510 Property changes on: trunk/library ___________________________________________________________________ Modified: svn:mergeinfo - /branches/1.5.0-pulse/library:306-344,346,467 /branches/1.5.x/library:426-455,458-472,475-481 /branches/newUser:113-150 /branches/newUser2:175-207 /branches/userloader:259-324 /tags/1.5.0beta1/library:305 /tags/1.5.1/library:485,489 + /branches/1.5.0-pulse/library:306-344,346,467 /branches/1.5.x/library:426-455,458-472,475-481 /branches/newUser:113-150 /branches/newUser2:175-207 /branches/userloader:259-324 /tags/1.5.0beta1/library:305 /tags/1.5.1/library:485,489,509-510 Modified: trunk/library/classes/Gems/Default/DatabaseAction.php =================================================================== --- trunk/library/classes/Gems/Default/DatabaseAction.php 2012-02-23 10:07:53 UTC (rev 510) +++ trunk/library/classes/Gems/Default/DatabaseAction.php 2012-02-23 10:52:42 UTC (rev 511) @@ -243,6 +243,7 @@ $model = $this->getModel(); if ($model->isMeta('action', 'show')) { + $table->tr(); $table->tdh($this->_('Structure')); $table->td($this->getFieldTable($this->_getParam(MUtil_Model::REQUEST_ID))); } Modified: trunk/library/classes/Gems/Email/EmailFormAbstract.php =================================================================== --- trunk/library/classes/Gems/Email/EmailFormAbstract.php 2012-02-23 10:07:53 UTC (rev 510) +++ trunk/library/classes/Gems/Email/EmailFormAbstract.php 2012-02-23 10:52:42 UTC (rev 511) @@ -241,6 +241,7 @@ if ($email = $this->escort->project->email['site']) { $options['S'] = $this->_createMultiOption(array(), $this->escort->project->name, $email); + $valid[] = 'S'; } } @@ -252,6 +253,7 @@ 'required' => true, )); + $element->addValidator('InArray', false, array('haystack' => $valid)); $this->defaultFrom = reset($valid); Modified: trunk/library/classes/Gems/Email/OneMailForm.php =================================================================== --- trunk/library/classes/Gems/Email/OneMailForm.php 2012-02-23 10:07:53 UTC (rev 510) +++ trunk/library/classes/Gems/Email/OneMailForm.php 2012-02-23 10:52:42 UTC (rev 511) @@ -132,6 +132,7 @@ } else { $tokenData = $this->getTokenData(); + $this->mailer->setFrom($this->getValue('from')); $this->mailer->setSubject($this->getValue('gmt_subject')); $this->mailer->setBody($this->getValue('gmt_body')); $this->mailer->setTemplateId($this->getValue('select_subject')); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2012-02-23 10:08:03
|
Revision: 510 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=510&view=rev Author: matijsdejong Date: 2012-02-23 10:07:53 +0000 (Thu, 23 Feb 2012) Log Message: ----------- Display worked incorrectly because of change in VerticalTable Modified Paths: -------------- tags/1.5.1/library/classes/Gems/Default/DatabaseAction.php Modified: tags/1.5.1/library/classes/Gems/Default/DatabaseAction.php =================================================================== --- tags/1.5.1/library/classes/Gems/Default/DatabaseAction.php 2012-02-23 10:00:44 UTC (rev 509) +++ tags/1.5.1/library/classes/Gems/Default/DatabaseAction.php 2012-02-23 10:07:53 UTC (rev 510) @@ -243,6 +243,7 @@ $model = $this->getModel(); if ($model->isMeta('action', 'show')) { + $table->tr(); $table->tdh($this->_('Structure')); $table->td($this->getFieldTable($this->_getParam(MUtil_Model::REQUEST_ID))); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2012-02-23 10:00:55
|
Revision: 509 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=509&view=rev Author: matijsdejong Date: 2012-02-23 10:00:44 +0000 (Thu, 23 Feb 2012) Log Message: ----------- Bugs preventing sending of mail Modified Paths: -------------- tags/1.5.1/library/classes/Gems/Email/EmailFormAbstract.php tags/1.5.1/library/classes/Gems/Email/OneMailForm.php Modified: tags/1.5.1/library/classes/Gems/Email/EmailFormAbstract.php =================================================================== --- tags/1.5.1/library/classes/Gems/Email/EmailFormAbstract.php 2012-02-22 19:20:42 UTC (rev 508) +++ tags/1.5.1/library/classes/Gems/Email/EmailFormAbstract.php 2012-02-23 10:00:44 UTC (rev 509) @@ -241,6 +241,7 @@ if ($email = $this->escort->project->email['site']) { $options['S'] = $this->_createMultiOption(array(), $this->escort->project->name, $email); + $valid[] = 'S'; } } @@ -252,6 +253,7 @@ 'required' => true, )); + $element->addValidator('InArray', false, array('haystack' => $valid)); $this->defaultFrom = reset($valid); Modified: tags/1.5.1/library/classes/Gems/Email/OneMailForm.php =================================================================== --- tags/1.5.1/library/classes/Gems/Email/OneMailForm.php 2012-02-22 19:20:42 UTC (rev 508) +++ tags/1.5.1/library/classes/Gems/Email/OneMailForm.php 2012-02-23 10:00:44 UTC (rev 509) @@ -132,6 +132,7 @@ } else { $tokenData = $this->getTokenData(); + $this->mailer->setFrom($this->getValue('from')); $this->mailer->setSubject($this->getValue('gmt_subject')); $this->mailer->setBody($this->getValue('gmt_body')); $this->mailer->setTemplateId($this->getValue('select_subject')); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2012-02-22 19:20:49
|
Revision: 508 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=508&view=rev Author: matijsdejong Date: 2012-02-22 19:20:42 +0000 (Wed, 22 Feb 2012) Log Message: ----------- Prevented a JavaScript error. Modified Paths: -------------- trunk/library/classes/MUtil/Form/Decorator/AutoFocus.php Modified: trunk/library/classes/MUtil/Form/Decorator/AutoFocus.php =================================================================== --- trunk/library/classes/MUtil/Form/Decorator/AutoFocus.php 2012-02-22 08:27:47 UTC (rev 507) +++ trunk/library/classes/MUtil/Form/Decorator/AutoFocus.php 2012-02-22 19:20:42 UTC (rev 508) @@ -92,7 +92,7 @@ if (($view !== null) && ($focus !== null)) { // Use try {} around e.select as nog all elements have a select() function - $script = "e = document.getElementById('$focus'); if (e) {e.focus(); try { e.select(); } catch (ex) {}}"; + $script = "e = document.getElementById('$focus'); if (e) {e.focus(); try { if (e instanceof HTMLInputElement || e instanceof HTMLTextAreaElement) {e.select();} } catch (ex) {}}"; $view->inlineScript()->appendScript($script); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2012-02-22 08:27:53
|
Revision: 507 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=507&view=rev Author: michieltcs Date: 2012-02-22 08:27:47 +0000 (Wed, 22 Feb 2012) Log Message: ----------- Switch to protected to allow child classes access to _gemsData array Modified Paths: -------------- trunk/library/classes/Gems/Tracker/Token.php Modified: trunk/library/classes/Gems/Tracker/Token.php =================================================================== --- trunk/library/classes/Gems/Tracker/Token.php 2012-02-21 18:06:31 UTC (rev 506) +++ trunk/library/classes/Gems/Tracker/Token.php 2012-02-22 08:27:47 UTC (rev 507) @@ -60,7 +60,7 @@ * * @var array The gems token data */ - private $_gemsData = array(); + protected $_gemsData = array(); /** * @@ -84,7 +84,7 @@ * * @var string The id of the token */ - private $_tokenId; + protected $_tokenId; /** * @@ -171,7 +171,7 @@ /** * Makes sure the respondent data is part of the $this->_gemsData */ - private function _ensureRespondentData() + protected function _ensureRespondentData() { if (! isset($this->_gemsData['grs_id_user'], $this->_gemsData['gr2o_id_user'], $this->_gemsData['gco_code'])) { $sql = "SELECT * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2012-02-21 18:06:41
|
Revision: 506 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=506&view=rev Author: matijsdejong Date: 2012-02-21 18:06:31 +0000 (Tue, 21 Feb 2012) Log Message: ----------- Simplified finding menu items through controller / action SubMenuItems can be sorted in their display order Added functions for respondent login Added renderClosingTag to HtmlElement.php Modified Paths: -------------- trunk/library/classes/Gems/Default/MailJobAction.php trunk/library/classes/Gems/Menu/MenuAbstract.php trunk/library/classes/Gems/Menu.php trunk/library/classes/Gems/Model/RespondentModel.php trunk/library/classes/Gems/User/Organization.php trunk/library/classes/Gems/User/RespondentUserDefinition.php trunk/library/classes/Gems/User/User.php trunk/library/classes/Gems/User/UserDefinitionAbstract.php trunk/library/classes/Gems/User/UserDefinitionInterface.php trunk/library/classes/Gems/User/UserLoader.php trunk/library/classes/GemsEscort.php trunk/library/classes/MUtil/Html/HtmlElement.php Modified: trunk/library/classes/Gems/Default/MailJobAction.php =================================================================== --- trunk/library/classes/Gems/Default/MailJobAction.php 2012-02-21 15:08:06 UTC (rev 505) +++ trunk/library/classes/Gems/Default/MailJobAction.php 2012-02-21 18:06:31 UTC (rev 506) @@ -189,7 +189,7 @@ $this->addMessage(sprintf($this->_('Automatic mails have been turned off since %s.'), $lock->getLockTime())); $request = $this->getRequest(); - if ($menuItem = $this->menu->findFirst(array($request->getControllerKey() => 'cron', $request->getActionKey() => 'cron-lock'))) { + if ($menuItem = $this->menu->findController('cron', 'cron-lock')) { $menuItem->set('label', $this->_('Turn Automatic Mail Jobs ON')); } } Modified: trunk/library/classes/Gems/Menu/MenuAbstract.php =================================================================== --- trunk/library/classes/Gems/Menu/MenuAbstract.php 2012-02-21 15:08:06 UTC (rev 505) +++ trunk/library/classes/Gems/Menu/MenuAbstract.php 2012-02-21 18:06:31 UTC (rev 506) @@ -48,6 +48,10 @@ */ abstract class Gems_Menu_MenuAbstract { + /** + * + * @var GemsEscort + */ public $escort; protected $_subItems; @@ -597,4 +601,37 @@ } return $this; } + + /** + * Sorts the childeren on their order attribute (instead of the order the were added) + * + * @return Gems_Menu_MenuAbstract (continuation pattern) + */ + public function sortByOrder() + { + uasort($this->_subItems, array(__CLASS__, 'sortOrder')); + + return $this; + } + + /** + * uasort() function for sortByOrder() + * + * @see sortByOrder(); + * + * @param self $aItem + * @param self $bItem + * @return int + */ + public static function sortOrder($aItem, $bItem) + { + $a = $aItem->get('order'); + $b = $bItem->get('order'); + + if ($a == $b) { + return 0; + } + + return $a > $b ? 1 : -1; + } } Modified: trunk/library/classes/Gems/Menu.php =================================================================== --- trunk/library/classes/Gems/Menu.php 2012-02-21 15:08:06 UTC (rev 505) +++ trunk/library/classes/Gems/Menu.php 2012-02-21 18:06:31 UTC (rev 506) @@ -417,6 +417,18 @@ } } + /** + * Find a menu item through specifying the controller and action + * + * @param string $controller + * @param string $action + * @return Gems_SubMenuItem + */ + public function findController($controller, $action = 'index') + { + return $this->findItem(array('controller' => $controller, 'action' => $action), false); + } + public function findFirst($request) { $find = $this->request2find($request); Modified: trunk/library/classes/Gems/Model/RespondentModel.php =================================================================== --- trunk/library/classes/Gems/Model/RespondentModel.php 2012-02-21 15:08:06 UTC (rev 505) +++ trunk/library/classes/Gems/Model/RespondentModel.php 2012-02-21 18:06:31 UTC (rev 506) @@ -116,6 +116,19 @@ } /** + * Add the table and field to check for respondent login checks + * + * @return Gems_Model_RespondentModel (continuation pattern) + */ + 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'); + + return $this; + } + + /** * Apply hash function for array_walk_recursive in _checkFilterUsed() * * @see _checkFilterUsed() Modified: trunk/library/classes/Gems/User/Organization.php =================================================================== --- trunk/library/classes/Gems/User/Organization.php 2012-02-21 15:08:06 UTC (rev 505) +++ trunk/library/classes/Gems/User/Organization.php 2012-02-21 18:06:31 UTC (rev 506) @@ -77,6 +77,16 @@ protected $db; /** + * When true respondents of this organization may login + * + * @return boolean + */ + public function allowsRespondentLogin() + { + return (boolean) $this->_get('gor_respondent_group') && $this->canHaveRespondents(); + } + + /** * Set menu parameters from the organization * * @param Gems_Menu_ParameterSource $source @@ -106,10 +116,10 @@ { return (boolean) $this->_get('gor_has_respondents') || $this->_get('gor_add_respondents'); } - + /** * Returns the $key in organizationData when set otherwise the default value - * + * * @param string $key * @param mixed $default * @return mixed Modified: trunk/library/classes/Gems/User/RespondentUserDefinition.php =================================================================== --- trunk/library/classes/Gems/User/RespondentUserDefinition.php 2012-02-21 15:08:06 UTC (rev 505) +++ trunk/library/classes/Gems/User/RespondentUserDefinition.php 2012-02-21 18:06:31 UTC (rev 506) @@ -91,4 +91,16 @@ return $select; } + + /** + * Returns true when users using this definition are staff members. + * + * Used only when the definition does not return a user_staff field. + * + * @return boolean + */ + public function isStaff() + { + return false; + } } \ No newline at end of file Modified: trunk/library/classes/Gems/User/User.php =================================================================== --- trunk/library/classes/Gems/User/User.php 2012-02-21 15:08:06 UTC (rev 505) +++ trunk/library/classes/Gems/User/User.php 2012-02-21 18:06:31 UTC (rev 506) @@ -107,6 +107,12 @@ protected $userLoader; /** + * + * @var Gems_Util + */ + protected $util; + + /** * Creates the class for this user. * * @param mixed $settings Array, Zend_Session_Namespace or ArrayObject for this user. @@ -448,6 +454,38 @@ } /** + * Returns a standard greeting for the current user. + * + * @return int + */ + public function getGreeting() + { + if (! $this->_getVar('user_greeting')) { + $greeting = array(); + $greetings = $this->util->getTranslated()->getGenderGreeting(); + + if (isset($greetings[$this->_getVar('user_gender')])) { + $greeting[] = $greetings[$this->_getVar('user_gender')]; + } + if ($this->_getVar('user_last_name')) { + if ($this->_getVar('user_surname_prefix')) { + $greeting[] = $this->_getVar('user_surname_prefix'); + } + $greeting[] = $this->_getVar('user_last_name'); + } else { + $name = $this->getLoginName(); + $name = substr($name, 0, 3) . str_repeat('*', strlen($name) - 2); + $greeting[] = $name; + } + + $this->_setVar('user_greeting', implode(' ', $greeting)); + } + + return $this->_getVar('user_greeting'); + } + + + /** * Returns the group number of the current user. * * @return int @@ -552,7 +590,7 @@ // Set menu OFF $menu->setVisible(false); - $menuItem = $menu->findFirst(array($request->getControllerKey() => 'option', $request->getActionKey() => 'change-password')); + $menuItem = $menu->findController('option', 'change-password'); // This may not yet be true, but is needed for the redirect. $menuItem->set('allowed', true); $menuItem->set('visible', true); @@ -563,6 +601,8 @@ if ($menuItem) { // Prevent redirecting to the current page. if (! ($menuItem->is('controller', $request->getControllerName()) && $menuItem->is('action', $request->getActionName()))) { + echo $menuItem->get('label') . '<br/>'; + $redirector = Zend_Controller_Action_HelperBroker::getStaticHelper('redirector'); $redirector->gotoRoute($menuItem->toRouteUrl($request), null, true); } @@ -655,6 +695,16 @@ } /** + * Returns true when this user is a staff member. + * + * @return boolean + */ + public function isStaff() + { + return (boolean) $this->_getVar('user_staff'); + } + + /** * Allowes a refresh of the existing list of organizations * for this user. * Modified: trunk/library/classes/Gems/User/UserDefinitionAbstract.php =================================================================== --- trunk/library/classes/Gems/User/UserDefinitionAbstract.php 2012-02-21 15:08:06 UTC (rev 505) +++ trunk/library/classes/Gems/User/UserDefinitionAbstract.php 2012-02-21 18:06:31 UTC (rev 506) @@ -100,6 +100,18 @@ } /** + * Returns true when users using this definition are staff members. + * + * Used only when the definition does not return a user_staff field. + * + * @return boolean + */ + public function isStaff() + { + return true; + } + + /** * Return true if the user has a password. * * @param Gems_User_User $user The user to check Modified: trunk/library/classes/Gems/User/UserDefinitionInterface.php =================================================================== --- trunk/library/classes/Gems/User/UserDefinitionInterface.php 2012-02-21 15:08:06 UTC (rev 505) +++ trunk/library/classes/Gems/User/UserDefinitionInterface.php 2012-02-21 18:06:31 UTC (rev 506) @@ -102,6 +102,15 @@ public function getUserData($login_name, $organization); /** + * Returns true when users using this definition are staff members. + * + * Used only when the definition does not return a user_staff field. + * + * @return boolean + */ + public function isStaff(); + + /** * Return true if the user has a password. * * @param Gems_User_User $user The user to check Modified: trunk/library/classes/Gems/User/UserLoader.php =================================================================== --- trunk/library/classes/Gems/User/UserLoader.php 2012-02-21 15:08:06 UTC (rev 505) +++ trunk/library/classes/Gems/User/UserLoader.php 2012-02-21 18:06:31 UTC (rev 506) @@ -232,6 +232,9 @@ if (! isset($values['user_active'])) { $values['user_active'] = true; } + if (! isset($values['user_staff'])) { + $values['user_staff'] = $definition->isStaff(); + } $values['__user_definition'] = $defName; Modified: trunk/library/classes/GemsEscort.php =================================================================== --- trunk/library/classes/GemsEscort.php 2012-02-21 15:08:06 UTC (rev 505) +++ trunk/library/classes/GemsEscort.php 2012-02-21 18:06:31 UTC (rev 506) @@ -741,10 +741,10 @@ $p = $div->p(); if ($user->isActive()) { $p->append(sprintf($this->_('You are logged in as %s'), $user->getFullName())); - $item = $this->menu->findFirst(array($this->request->getControllerKey() => 'index', $this->request->getActionKey() => 'logoff')); + $item = $this->menu->findController('index', 'logoff'); $p->a($item->toHRefAttribute(), $this->_('Logoff'), array('class' => 'logout')); } else { - $item = $this->menu->findFirst(array($this->request->getControllerKey() => 'index', $this->request->getActionKey() => 'login')); + $item = $this->menu->findController('index', 'login'); $p->a($item->toHRefAttribute(), $this->_('You are not logged in'), array('class' => 'logout')); } $item->set('visible', false); @@ -947,7 +947,7 @@ $div = MUtil_Html::create()->div($args, array('id' => 'version')); $version = $this->loader->getVersions()->getVersion(); if (($this->menu instanceof Gems_Menu) && - ($item = $this->menu->findFirst(array('controller'=>'project-information', 'action'=>'changelog'))->toHRefAttribute())) { + ($item = $this->menu->findController('project-information', 'changelog')->toHRefAttribute())) { $link = MUtil_Html::create()->a($version, $item); } else { $link = $version; Modified: trunk/library/classes/MUtil/Html/HtmlElement.php =================================================================== --- trunk/library/classes/MUtil/Html/HtmlElement.php 2012-02-21 15:08:06 UTC (rev 505) +++ trunk/library/classes/MUtil/Html/HtmlElement.php 2012-02-21 18:06:31 UTC (rev 506) @@ -504,6 +504,19 @@ ); /** + * Some elements, e.g. iframe elements, must always be rendered with a closing + * tag because otherwise some poor browsers get confused. + * + * Overrules $renderWithoutContent: the element is always rendered when + * $renderClosingTag is true. + * + * @see $renderWithoutContent + * + * @var boolean The element is always rendered with a closing tag. + */ + public $renderClosingTag = false; + + /** * Most elements must be rendered even when empty, others should - according to the * xhtml specifications - only be rendered when the element contains some content. * @@ -1071,7 +1084,7 @@ $content = $this->renderContent($view); $has_content = (null !== $content); - if ($has_content || $this->renderWithoutContent) { + if ($has_content || $this->renderWithoutContent || $this->renderClosingTag) { $html = '<' . $this->tagName; @@ -1079,7 +1092,7 @@ $html .= $this->_htmlAttribs($this->_renderAttributes($view)); } - if ($has_content) { + if ($has_content || $this->renderClosingTag) { $html .= '>'; $html .= $content; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |