From: <gem...@li...> - 2012-01-12 17:30:39
|
Revision: 407 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=407&view=rev Author: matijsdejong Date: 2012-01-12 17:30:32 +0000 (Thu, 12 Jan 2012) Log Message: ----------- Added concept of scalar array to MUtil_Ra Moved to special Batch class Modified Paths: -------------- trunk/library/classes/Gems/Default/SourceAction.php trunk/library/classes/Gems/Default/SurveyMaintenanceAction.php trunk/library/classes/Gems/Tracker/TrackerInterface.php trunk/library/classes/Gems/Tracker.php trunk/library/classes/MUtil/Html/HtmlException.php trunk/library/classes/MUtil/Ra.php Added Paths: ----------- trunk/library/classes/Gems/Tracker/Batch/ trunk/library/classes/Gems/Tracker/Batch/ProcessTokensBatch.php trunk/library/classes/Gems/Tracker/Batch/SynchronizeSourceBatch.php trunk/library/classes/MUtil/Batch/ trunk/library/classes/MUtil/Batch/BatchAbstract.php trunk/library/classes/MUtil/Batch/BatchException.php trunk/library/classes/MUtil/Queue/ trunk/library/classes/MUtil/Queue/Adapter/ trunk/library/classes/MUtil/Queue/Adapter/DbPrefixed.php Modified: trunk/library/classes/Gems/Default/SourceAction.php =================================================================== --- trunk/library/classes/Gems/Default/SourceAction.php 2012-01-12 12:00:47 UTC (rev 406) +++ trunk/library/classes/Gems/Default/SourceAction.php 2012-01-12 17:30:32 UTC (rev 407) @@ -244,7 +244,25 @@ $this->html->h3($this->_('Synchronize all sources of surveys')); $this->html->pInfo($this->_('Synchronization will update the status of all surveys imported into this project to the status at the sources.')); /* + $batch = new Gems_Tracker_Batch_SynchronizeSourceBatch(); + // $batch->method = 'Push'; + if (! $batch->isLoaded()) { + foreach ($data as $row) { + $batch->addSource($row['gso_id_source'], $row['gso_source_name']); + } + } + if ($batch->run($this->getRequest())) { + if ($batch->isReady()) { + $this->addMessage($batch->getMessages()); + $this->afterSaveRoute($this->getRequest()); + } + } else { + $this->html[] = $batch->getPanel(); + } + // */ + /* $progress = $this->html->progress('0%'); + $progress->method = 'Push'; // $progress = $this->html->progress(); if ($progress->run($this->getRequest())) { @@ -253,7 +271,7 @@ // ../handlers/add name="CGI-exe" // add attribute responseBufferLimit="1024" - for ($i = 50; $i < 100; $i += 10) { + for ($i = 50; $i < 100; $i += 1) { if ($i < 20) { $text = 'Just beginning'; } else if ($i < 50) { Modified: trunk/library/classes/Gems/Default/SurveyMaintenanceAction.php =================================================================== --- trunk/library/classes/Gems/Default/SurveyMaintenanceAction.php 2012-01-12 12:00:47 UTC (rev 406) +++ trunk/library/classes/Gems/Default/SurveyMaintenanceAction.php 2012-01-12 17:30:32 UTC (rev 407) @@ -268,6 +268,26 @@ $surveyId = $this->_getParam(MUtil_Model::REQUEST_ID); $where = $this->db->quoteInto('gto_id_survey = ?', $surveyId); + /* + $batch = $this->loader->getTracker()->recalculateTokensBatch($this->loader->getCurrentUser()->getUserId(), $where); + + if ($batch->hasStarted($this->getRequest())) { + // TODO + } else { + $this->html->h3( + sprintf($this->_('Checking survey results for the %s survey.'), + $this->db->fetchOne("SELECT gsu_survey_name FROM gems__surveys WHERE gsu_id_survey = ?", $surveyId))); + + if ($batch->isLoaded()) { + $this->html->pInfo(sprintf($this->_('Running check for %s tokens...'), $batch->count())); + $this->html->append($batch->getPanel()); + } else { + $this->html->pInfo($this->_('No tokens to check.')); + } + } + // */ + + //* $this->addMessage(sprintf($this->_( 'Checking survey results for the %s survey.'), $this->db->fetchOne("SELECT gsu_survey_name FROM gems__surveys WHERE gsu_id_survey = ?", $surveyId))); @@ -275,6 +295,8 @@ $this->addMessage($this->loader->getTracker()->recalculateTokens($this->session->user_id, $where)); $this->afterSaveRoute($this->getRequest()); + + // */ } public function checkAllAction() Property changes on: trunk/library/classes/Gems/Tracker/Batch ___________________________________________________________________ Added: bugtraq:url + http://survey.erasmusmc.nl/support/mantis/view.php?id=%BUGID% Added: bugtraq:logregex + #(\d+) Added: trunk/library/classes/Gems/Tracker/Batch/ProcessTokensBatch.php =================================================================== --- trunk/library/classes/Gems/Tracker/Batch/ProcessTokensBatch.php (rev 0) +++ trunk/library/classes/Gems/Tracker/Batch/ProcessTokensBatch.php 2012-01-12 17:30:32 UTC (rev 407) @@ -0,0 +1,122 @@ +<?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$ + */ + +/** + * + * + * @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_ProcessTokensBatch extends MUtil_Batch_BatchAbstract +{ + /** + * + * @var Gems_Tracker + */ + public $tracker; + + public function __construct($where, Gems_Tracker $tracker) + { + parent::__construct(__CLASS__ . '::' . $where); + + $this->tracker = $tracker; + } + + 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->addStep('checkTokenCompletion', 'tokchk-' . $tokenId, $tokenData); + } + + protected function checkTrackTokens($respTrackData, $userId) + { + $respTrack = $this->tracker->getRespondentTrack($respTrackData); + + if ($result = $respTrack->checkTrackTokens($userId)) { + $this->addToCounter('tokenDateCauses'); + $this->addToCounter('tokenDateChanges', $result); + } + } + + 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->addStep('processTokenCompletion', 'tokproc-' . $token->getTokenId(), $tokenData, $userId); + } + } + + 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->addStep('checkTrackTokens', 'chktrck-' . $trackId, $trackId, $userid); + } + } +} Added: trunk/library/classes/Gems/Tracker/Batch/SynchronizeSourceBatch.php =================================================================== --- trunk/library/classes/Gems/Tracker/Batch/SynchronizeSourceBatch.php (rev 0) +++ trunk/library/classes/Gems/Tracker/Batch/SynchronizeSourceBatch.php 2012-01-12 17:30:32 UTC (rev 407) @@ -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 <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$ + */ + +/** + * + * + * @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_SynchronizeSourceBatch extends MUtil_Batch_BatchAbstract +{ + /** + * Construct as standard batch + */ + public function __construct() + { + parent::__construct(__CLASS__); + } + + public function addSource($sourceId, $sourceName) + { + + } +} Modified: trunk/library/classes/Gems/Tracker/TrackerInterface.php =================================================================== --- trunk/library/classes/Gems/Tracker/TrackerInterface.php 2012-01-12 12:00:47 UTC (rev 406) +++ trunk/library/classes/Gems/Tracker/TrackerInterface.php 2012-01-12 17:30:32 UTC (rev 407) @@ -54,7 +54,7 @@ * extension) and TokenValidator. * * Other functions are general utility functions, e.g. checkTrackRounds(), createToken(), - * preocessCompletedTokens() and recalculateTokens(). + * processCompletedTokens() and recalculateTokens(). * * @package Gems * @subpackage Tracker Modified: trunk/library/classes/Gems/Tracker.php =================================================================== --- trunk/library/classes/Gems/Tracker.php 2012-01-12 12:00:47 UTC (rev 406) +++ trunk/library/classes/Gems/Tracker.php 2012-01-12 17:30:32 UTC (rev 407) @@ -48,7 +48,7 @@ * extension) and TokenValidator. * * Other functions are general utility functions, e.g. checkTrackRounds(), createToken(), - * preocessCompletedTokens() and recalculateTokens(). + * processCompletedTokens() and recalculateTokens(). * * @package Gems * @subpackage Tracker @@ -822,6 +822,36 @@ } /** + * Checks the token table to see if there are any answered surveys to be processed + * + * If the survey was started (and the token was forwarded to limesurvey) we need to check + * if is was completed. If so, we might want to check the track the survey is in to enable + * or disable future rounds + * + * Does not reflect changes to tracks or rounds. + * + * @param Gems_Tracker_Token_TokenSelect Select statements selecting tokens + * @param int $userId Id of the user who takes the action (for logging) + * @return Gems_Tracker_Batch_ProcessTokensBatch A batch to process the changes + */ + protected function processTokensBatch(Gems_Tracker_Token_TokenSelect $tokenSelect, $userId) + { + $where = implode(' ', $tokenSelect->getSelect()->getPart(Zend_Db_Select::WHERE)); + + $batch = new Gems_Tracker_Batch_ProcessTokensBatch($where, $this); + + if (! $batch->isLoaded()) { + $tokenRows = $tokenSelect->fetchAll(); + + foreach ($tokenRows as $tokenData) { + $batch->addToken($tokenData, $userId); + } + } + + return $batch; + } + + /** * Recalculates all token dates, timing and results * and outputs text messages. * @@ -849,4 +879,31 @@ return $changes->getMessages($this->translate); } + + /** + * Recalculates all token dates, timing and results + * and outputs text messages. + * + * Does not reflect changes to tracks or rounds. + * + * @param Zend_Translate $t + * @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 + */ + public function recalculateTokensBatch($userId = null, $cond = null) + { + $userId = $this->_checkUserId($userId); + $tokenSelect = $this->getTokenSelect(); + $tokenSelect->andReceptionCodes(); + if ($cond) { + $tokenSelect->forWhere($cond); + } + //Only select surveys that are active in the source (so we can recalculate inactive in Gems) + $tokenSelect->andSurveys(); + $tokenSelect->forWhere('gsu_surveyor_active = 1'); + + self::$verbose = true; + return $this->processTokensBatch($tokenSelect, $userId); + } } Property changes on: trunk/library/classes/MUtil/Batch ___________________________________________________________________ Added: bugtraq:url + http://survey.erasmusmc.nl/support/mantis/view.php?id=%BUGID% Added: bugtraq:logregex + #(\d+) Added: trunk/library/classes/MUtil/Batch/BatchAbstract.php =================================================================== --- trunk/library/classes/MUtil/Batch/BatchAbstract.php (rev 0) +++ trunk/library/classes/MUtil/Batch/BatchAbstract.php 2012-01-12 17:30:32 UTC (rev 407) @@ -0,0 +1,178 @@ +<?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 MUtil + * @subpackage Batch + * @author Matijs de Jong <mj...@ma...> + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @version $Id$ + */ + +/** + * + * + * @package MUtil + * @subpackage Batch + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @since Class available since version 1.5 + */ +abstract class MUtil_Batch_BatchAbstract extends MUtil_Registry_TargetAbstract implements Countable +{ + const PULL = 'Pull'; + const PUSH = 'Push'; + + /** + * + * @var Zend_Session_Namespace + */ + private $_session; + + /** + * + * @param string $name The name of this batch, defaults to classname + */ + public function __construct($name = null) + { + if (null === $name) { + $name = get_class($this); + } + + $this->_initSession($name); + } + + private function _initSession($name) + { + $this->_session = new Zend_Session_Namespace($name); + + if (! isset($this->_session->commands)) { + $this->_session->commands = array(); + $this->_session->counters = array(); + $this->_session->count = 0; + $this->_session->processed = 0; + } + } + + /** + * Add an execution step to the command stack. + * + * @param string $method Name of a method of this object + * @param mixed $id A unique id to prevent double adding of something to do + * @param mixed $param1 Scalar or array with scalars, as many parameters as needed allowed + * @return MUtil_Batch_BatchAbstract + */ + protected function addStep($method, $id, $param1 = null) + { + $params = array_slice(func_get_args(), 2); + + if (! method_exists($this, $method)) { + throw new MUtil_Batch_BatchException("Invalid batch method: '$method'."); + } + if (! MUtil_Ra::isScalar($params)) { + throw new MUtil_Batch_BatchException("Non scalar batch parameter for method: '$method'."); + } + + $command['method'] = $method; + $command['parameters'] = $params; + + $this->_session->commands[$id] = $command; + + return $this; + } + + protected function addToCounter($name, $add = 1) + { + if (! isset($this->session->counters[$name])) { + $this->session->counters[$name] = 0; + } + $this->session->counters[$name] += $add; + + return $this->session->counters[$name]; + } + + /** + * Count the number of commands + * + * @return int The custom count as an integer. + */ + public function count() + { + return count($this->_session->commands); + } + + public function getPanel() + { + return new MUtil_Html_ProgressPanel('0%'); + } + + public function hasStarted(Zend_Controller_Request_Abstract $request) + { + return false; + } + + /** + * Return true after commands all have been ran and there was at least one command to run. + * + * @return boolean + */ + public function isFinished() + { + return (0 == $this->_session->count()) && ($this->_session->processed > 0); + } + + /** + * Return true when at least one command has been loaded. + * + * @return boolean + */ + public function isLoaded() + { + return $this->count() || $this->_session->processed; + } + + public function runAll() + { + while ($this->step()); + + return $this->_session->processed; + } + + public function step() + { + if (isset($this->_session->commands) && $this->_session->commands) { + $command = array_shift($this->_session->commands); + $this->_session->processed++; + + call_user_func_array(array($this, $command['method']), $command['parameters']); + } + + return count($this->_session->commands) > 0; + } +} Added: trunk/library/classes/MUtil/Batch/BatchException.php =================================================================== --- trunk/library/classes/MUtil/Batch/BatchException.php (rev 0) +++ trunk/library/classes/MUtil/Batch/BatchException.php 2012-01-12 17:30:32 UTC (rev 407) @@ -0,0 +1,48 @@ +<?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 MUtil + * @subpackage Batch + * @author Matijs de Jong <mj...@ma...> + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @version $Id$ + */ + +/** + * + * + * @package MUtil + * @subpackage Batch + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @since Class available since version 1.5 + */ +class MUtil_Batch_BatchException extends Zend_Exception +{ } Modified: trunk/library/classes/MUtil/Html/HtmlException.php =================================================================== --- trunk/library/classes/MUtil/Html/HtmlException.php 2012-01-12 12:00:47 UTC (rev 406) +++ trunk/library/classes/MUtil/Html/HtmlException.php 2012-01-12 17:30:32 UTC (rev 407) @@ -1,40 +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$ */ -class MUtil_Html_HtmlException extends Exception +/** + * + * + * @package MUtil + * @subpackage Html + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @since Class available since version 1.0 + */ + +class MUtil_Html_HtmlException extends Zend_Exception { } \ No newline at end of file Property changes on: trunk/library/classes/MUtil/Queue ___________________________________________________________________ Added: bugtraq:url + http://survey.erasmusmc.nl/support/mantis/view.php?id=%BUGID% Added: bugtraq:logregex + #(\d+) Property changes on: trunk/library/classes/MUtil/Queue/Adapter ___________________________________________________________________ Added: bugtraq:url + http://survey.erasmusmc.nl/support/mantis/view.php?id=%BUGID% Added: bugtraq:logregex + #(\d+) Added: trunk/library/classes/MUtil/Queue/Adapter/DbPrefixed.php =================================================================== --- trunk/library/classes/MUtil/Queue/Adapter/DbPrefixed.php (rev 0) +++ trunk/library/classes/MUtil/Queue/Adapter/DbPrefixed.php 2012-01-12 17:30:32 UTC (rev 407) @@ -0,0 +1,67 @@ +<?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 MUtil + * @subpackage Queue + * @author Matijs de Jong <mj...@ma...> + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @version $Id: mjong$ + */ + +/** + * + * + * @package MUtil + * @subpackage Queue + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @since Class available since version 1.5 + */ +class MUtil_Queue_Adapter_DbPrefixed extends Zend_Queue_Adapter_Db +{ + /** + * Constructor + * + * @param array|Zend_Config $options + * @param Zend_Queue|null $queue + * @return void + */ + public function __construct($options, Zend_Queue $queue = null) + { + parent::__construct($options, $queue); + + if (isset($this->_options['prefix'])) { + $prefix = $this->_options['prefix']; + + $this->_queueTable->setOptions(array(Zend_Db_Table_Abstract::NAME => $prefix . $this->_queueTable->info(Zend_Db_Table_Abstract::NAME))); + $this->_messageTable->setOptions(array(Zend_Db_Table_Abstract::NAME => $prefix . $this->_messageTable->info(Zend_Db_Table_Abstract::NAME))); + } + } +} Modified: trunk/library/classes/MUtil/Ra.php =================================================================== --- trunk/library/classes/MUtil/Ra.php 2012-01-12 12:00:47 UTC (rev 406) +++ trunk/library/classes/MUtil/Ra.php 2012-01-12 17:30:32 UTC (rev 407) @@ -404,6 +404,12 @@ return self::$_toArrayConverter; } + /** + * Returns true if the $object either is an array or can be converted to an array. + * + * @param mixed $object + * @return boolean + */ public static function is($object) { if (is_array($object)) { @@ -414,6 +420,33 @@ } /** + * Test whether the value is scalar or an array containing + * scalars or scalar arrays. + * + * @param mixed $value + * @return boolean + */ + public static function isScalar($value) + { + if (null === $value) { + return true; + + } + + if (is_array($value)) { + foreach($value as $sub_value) { + if (! self::isScalar($sub_value)) { + return false; + } + } + return true; + + } + + return is_scalar($value); + } + + /** * A function that transforms an array in the form key1, value1, key2, value2 into array(key1 => value1, key2 => value2). * * When the $args array contains only a single sub array, then this value is assumed to be the return value. This allows This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |