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...> - 2011-10-31 09:46:37
|
Revision: 155 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=155&view=rev Author: matijsdejong Date: 2011-10-31 09:46:30 +0000 (Mon, 31 Oct 2011) Log Message: ----------- Fix for ticket #32: fieldmap cache crashes with the language 'nl-informal'. AddTrackSnippet can now handle organization switches correctly. Made it easier to write your own AnswerModel. Small fixes for #31 Modified Paths: -------------- trunk/library/classes/Gems/Default/IndexAction.php trunk/library/classes/Gems/Tracker/Source/LimeSurvey1m9FieldMap.php trunk/library/configs/db/patches.sql trunk/library/snippets/AddTracksSnippet.php trunk/library/snippets/AnswerModelSnippet.php trunk/library/snippets/TrackAnswersModelSnippet.php Added Paths: ----------- trunk/library/classes/Gems/Tracker/Snippets/AnswerModelSnippetGeneric.php Modified: trunk/library/classes/Gems/Default/IndexAction.php =================================================================== --- trunk/library/classes/Gems/Default/IndexAction.php 2011-10-31 09:13:59 UTC (rev 154) +++ trunk/library/classes/Gems/Default/IndexAction.php 2011-10-31 09:46:30 UTC (rev 155) @@ -209,9 +209,9 @@ $adapter->setIdentity($userid); $adapter->setCredential(md5($_POST['password'], false)); $result = $auth->authenticate($adapter, $_POST['userlogin']); - MUtil_Echo::track('old autho'); + // MUtil_Echo::track('old autho'); } else { - MUtil_Echo::track('new autho'); + // MUtil_Echo::track('new autho'); } if (!$result->isValid()) { Added: trunk/library/classes/Gems/Tracker/Snippets/AnswerModelSnippetGeneric.php =================================================================== --- trunk/library/classes/Gems/Tracker/Snippets/AnswerModelSnippetGeneric.php (rev 0) +++ trunk/library/classes/Gems/Tracker/Snippets/AnswerModelSnippetGeneric.php 2011-10-31 09:46:30 UTC (rev 155) @@ -0,0 +1,229 @@ +<?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 Tracker + * @author Matijs de Jong <mj...@ma...> + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @version $Id: AnswerModelSnippet.php 28 2011-09-16 06:24:15Z mennodekker $ + */ + +/** + * Displays answers to a survey. + * + * @package Gems + * @subpackage Tracker + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @since Class available since version 1.5 + */ +class Gems_Tracker_Snippets_AnswerModelSnippetGeneric extends Gems_Snippets_ModelTableSnippetAbstract +{ + /** + * Set a fixed model sort. + * + * Leading _ means not overwritten by sources. + * + * @var array + */ + protected $_fixedSort = array('gto_round_order' => SORT_ASC); + + /** + * Shortfix to add class attribute + * + * @var string + */ + protected $class = 'browser'; + + /** + * + * @var string Format used for displaying dates. + */ + protected $dateFormat = Zend_Date::DATE_MEDIUM; + + /** + * Required + * + * @var Gems_Loader + */ + protected $loader; + + /** + * Required + * + * @var Zend_Locale + */ + protected $locale; + + /** + * Optional: $request or $tokenData must be set + * + * The display data of the token shown + * + * @var Gems_Tracker_Token + */ + protected $token; + + /** + * Required: id of the selected token to show + * + * @var string + */ + protected $tokenId; + + /** + * Adds columns from the model to the bridge that creates the browse table. + * + * Overrule this function to add different columns to the browse table, without + * having to recode the core table building code. + * + * @param MUtil_Model_TableBridge $bridge + * @param MUtil_Model_ModelAbstract $model + * @return void + */ + protected function addBrowseTableColumns(MUtil_Model_TableBridge $bridge, MUtil_Model_ModelAbstract $model) + { + $br = MUtil_Html::create('br'); + $selectedClass = MUtil_Lazy::iff(MUtil_Lazy::comp($bridge->gto_id_token, '==', $this->tokenId), 'selectedColumn', null); + + $bridge->th($this->_('Status')); + $td = $bridge->tdh(MUtil_Lazy::first($bridge->grc_description, $this->_('OK'))); + $td->appendAttrib('class', $selectedClass); + + $bridge->th($this->_('Question')); + $td = $bridge->tdh( + $bridge->gto_round_description, + MUtil_Lazy::iif($bridge->gto_round_description, $br), + MUtil_Lazy::iif($bridge->gto_completion_time, $bridge->gto_completion_time, $bridge->gto_valid_from) + ); + $td->appendAttrib('class', $selectedClass); + $td->appendAttrib('class', $bridge->row_class); + + foreach($model->getItemsOrdered() as $name) { + if ($label = $model->get($name, 'label')) { + $bridge->thd($label, array('class' => $model->get($name, 'thClass'))); + $td = $bridge->td($bridge->$name); + + $td->appendAttrib('class', 'answer'); + $td->appendAttrib('class', $selectedClass); + $td->appendAttrib('class', $bridge->row_class); + } + } + + $bridge->th($this->_('Token')); + $td = $bridge->tdh($bridge->gto_id_token->strtoupper()); + $td->appendAttrib('class', $selectedClass); + $td->appendAttrib('class', $bridge->row_class); + } + + /** + * Creates the model + * + * @return MUtil_Model_ModelAbstract + */ + protected function createModel() + { + $model = $this->token->getSurveyAnswerModel($this->locale->getLanguage()); + + $model->set('gto_valid_from', 'dateFormat', $this->dateFormat); + $model->set('gto_completion_time', 'dateFormat', $this->dateFormat); + + return $model; + } + + + /** + * Create the snippets content + * + * This is a stub function either override getHtmlOutput() or override render() + * + * @param Zend_View_Abstract $view Just in case it is needed here + * @return MUtil_Html_HtmlInterface Something that can be rendered + */ + public function getHtmlOutput(Zend_View_Abstract $view) + { + $htmlDiv = MUtil_Html::create()->div(); + + if ($this->tokenId) { + if ($this->token->exists) { + $htmlDiv->h3(sprintf($this->_('%s answers for patient number %s'), $this->token->getSurveyName(), $this->token->getPatientNumber())); + + $htmlDiv->pInfo(sprintf( + $this->_('Answers for token %s, patient number %s: %s.'), + strtoupper($this->tokenId), + $this->token->getPatientNumber(), + $this->token->getRespondentName())) + ->appendAttrib('class', 'noprint'); + + $table = parent::getHtmlOutput($view); + $table->setPivot(true, 2, 1); + + $this->applyHtmlAttributes($table); + $htmlDiv[] = $table; + + } else { + $htmlDiv->ul(sprintf($this->_('Token %s not found.'), $this->tokenId), array('class' => 'errors')); + } + + } else { + $htmlDiv->ul($this->_('No token specified.'), array('class' => 'errors')); + } + + $buttonDiv = $htmlDiv->buttonDiv(); + $buttonDiv->actionLink(array(), $this->_('Close'), array('onclick' => 'window.close();')); + $buttonDiv->actionLink(array(), $this->_('Print'), array('onclick' => 'window.print();')); + return $htmlDiv; + } + + /** + * The place to check if the data set in the snippet is valid + * to generate the snippet. + * + * When invalid data should result in an error, you can throw it + * here but you can also perform the check in the + * checkRegistryRequestsAnswers() function from the + * {@see MUtil_Registry_TargetInterface}. + * + * @return boolean + */ + public function hasHtmlOutput() + { + if (! $this->tokenId) { + if (isset($this->token)) { + $this->tokenId = $this->token->getTokenId(); + } + } elseif (! $this->token) { + $this->token = $this->loader->getTracker()->getToken($this->tokenId); + } + + // Output always true, returns an error message as html when anything is wrong + return true; + } +} Modified: trunk/library/classes/Gems/Tracker/Source/LimeSurvey1m9FieldMap.php =================================================================== --- trunk/library/classes/Gems/Tracker/Source/LimeSurvey1m9FieldMap.php 2011-10-31 09:13:59 UTC (rev 154) +++ trunk/library/classes/Gems/Tracker/Source/LimeSurvey1m9FieldMap.php 2011-10-31 09:46:30 UTC (rev 155) @@ -204,9 +204,10 @@ protected function _getMap() { - $cacheId = 'lsFieldMap'.$this->sourceSurveyId.$this->language; + $cacheId = 'lsFieldMap'.$this->sourceSurveyId.strtr($this->language, '-.', '__'); + $this->_fieldMap = $this->cache->load($cacheId); - if( ($this->_fieldMap = $this->cache->load($cacheId)) === false ) { + if (false === $this->_fieldMap) { $gTable = $this->_getGroupsTableName(); $qTable = $this->_getQuestionsTableName(); @@ -344,7 +345,6 @@ $this->cache->save($this->_fieldMap, $cacheId); } - return $this->_fieldMap; } Modified: trunk/library/configs/db/patches.sql =================================================================== --- trunk/library/configs/db/patches.sql 2011-10-31 09:13:59 UTC (rev 154) +++ trunk/library/configs/db/patches.sql 2011-10-31 09:46:30 UTC (rev 155) @@ -228,4 +228,8 @@ ALTER TABLE `gems__staff` CHANGE `gsf_id_user` `gsf_id_user` BIGINT( 20 ) UNSIGNED NOT NULL; -ALTER TABLE `gems__staff` DROP INDEX `gsf_login`; \ No newline at end of file +ALTER TABLE `gems__staff` DROP INDEX `gsf_login`; + +ALTER TABLE `gems__staff` CHANGE `gsf_login` `gsf_login` VARCHAR( 20 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + CHANGE `gsf_password` `gsf_password` VARCHAR( 32 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + CHANGE `gsf_id_organization` `gsf_id_organization` BIGINT( 20 ) NULL DEFAULT NULL; Modified: trunk/library/snippets/AddTracksSnippet.php =================================================================== --- trunk/library/snippets/AddTracksSnippet.php 2011-10-31 09:13:59 UTC (rev 154) +++ trunk/library/snippets/AddTracksSnippet.php 2011-10-31 09:46:30 UTC (rev 155) @@ -103,10 +103,11 @@ throw new exception('Invalid track type requested.'); } - $trackTypeTime = $trackType . '_time'; + $trackTypeCache = $trackType . '_' . $this->session->user_style; + $trackTypeTime = $trackType . '_time'; - if (isset($this->session->$trackType, $this->session->$trackTypeTime) && (time() < $this->session->$trackTypeTime)) { - $tracks = $this->session->$trackType; + if (isset($this->session->$trackTypeCache, $this->session->$trackTypeTime) && (time() < $this->session->$trackTypeTime)) { + $tracks = $this->session->$trackTypeCache; } else { $organization_id = $this->escort->getCurrentOrganization(); switch ($trackType) { @@ -153,8 +154,8 @@ } $tracks = $this->db->fetchPairs($sql); - $this->session->$trackType = $tracks; - $this->session->$trackTypeTime = time() + 600; + $this->session->$trackTypeCache = $tracks; + $this->session->$trackTypeTime = time() + 600; } $div = MUtil_Html::create()->div(array('class' => 'toolbox')); Modified: trunk/library/snippets/AnswerModelSnippet.php =================================================================== --- trunk/library/snippets/AnswerModelSnippet.php 2011-10-31 09:13:59 UTC (rev 154) +++ trunk/library/snippets/AnswerModelSnippet.php 2011-10-31 09:46:30 UTC (rev 155) @@ -44,186 +44,5 @@ * @license New BSD License * @since Class available since version 1.4 */ -class AnswerModelSnippet extends Gems_Snippets_ModelTableSnippetAbstract -{ - /** - * Set a fixed model sort. - * - * Leading _ means not overwritten by sources. - * - * @var array - */ - protected $_fixedSort = array('gto_round_order' => SORT_ASC); - - /** - * Shortfix to add class attribute - * - * @var string - */ - protected $class = 'browser'; - - /** - * - * @var string Format used for displaying dates. - */ - protected $dateFormat = Zend_Date::DATE_MEDIUM; - - /** - * Required - * - * @var Gems_Loader - */ - protected $loader; - - /** - * Required - * - * @var Zend_Locale - */ - protected $locale; - - /** - * Optional: $request or $tokenData must be set - * - * The display data of the token shown - * - * @var Gems_Tracker_Token - */ - protected $token; - - /** - * Required: id of the selected token to show - * - * @var string - */ - protected $tokenId; - - /** - * Adds columns from the model to the bridge that creates the browse table. - * - * Overrule this function to add different columns to the browse table, without - * having to recode the core table building code. - * - * @param MUtil_Model_TableBridge $bridge - * @param MUtil_Model_ModelAbstract $model - * @return void - */ - protected function addBrowseTableColumns(MUtil_Model_TableBridge $bridge, MUtil_Model_ModelAbstract $model) - { - $br = MUtil_Html::create('br'); - $selectedClass = MUtil_Lazy::iff(MUtil_Lazy::comp($bridge->gto_id_token, '==', $this->tokenId), 'selectedColumn', null); - - $bridge->th($this->_('Status')); - $td = $bridge->tdh(MUtil_Lazy::first($bridge->grc_description, $this->_('OK'))); - $td->appendAttrib('class', $selectedClass); - - $bridge->th($this->_('Question')); - $td = $bridge->tdh( - $bridge->gto_round_description, - MUtil_Lazy::iif($bridge->gto_round_description, $br), - MUtil_Lazy::iif($bridge->gto_completion_time, $bridge->gto_completion_time, $bridge->gto_valid_from) - ); - $td->appendAttrib('class', $selectedClass); - $td->appendAttrib('class', $bridge->row_class); - - foreach($model->getItemsOrdered() as $name) { - if ($label = $model->get($name, 'label')) { - $bridge->thd($label, array('class' => $model->get($name, 'thClass'))); - $td = $bridge->td($bridge->$name); - - $td->appendAttrib('class', 'answer'); - $td->appendAttrib('class', $selectedClass); - $td->appendAttrib('class', $bridge->row_class); - } - } - - $bridge->th($this->_('Token')); - $td = $bridge->tdh($bridge->gto_id_token->strtoupper()); - $td->appendAttrib('class', $selectedClass); - $td->appendAttrib('class', $bridge->row_class); - } - - /** - * Creates the model - * - * @return MUtil_Model_ModelAbstract - */ - protected function createModel() - { - $model = $this->token->getSurveyAnswerModel($this->locale->getLanguage()); - - $model->set('gto_valid_from', 'dateFormat', $this->dateFormat); - $model->set('gto_completion_time', 'dateFormat', $this->dateFormat); - - return $model; - } - - - /** - * Create the snippets content - * - * This is a stub function either override getHtmlOutput() or override render() - * - * @param Zend_View_Abstract $view Just in case it is needed here - * @return MUtil_Html_HtmlInterface Something that can be rendered - */ - public function getHtmlOutput(Zend_View_Abstract $view) - { - $htmlDiv = MUtil_Html::create()->div(); - - if ($this->tokenId) { - if ($this->token->exists) { - $htmlDiv->h3(sprintf($this->_('%s answers for patient number %s'), $this->token->getSurveyName(), $this->token->getPatientNumber())); - - $htmlDiv->pInfo(sprintf( - $this->_('Answers for token %s, patient number %s: %s.'), - strtoupper($this->tokenId), - $this->token->getPatientNumber(), - $this->token->getRespondentName())) - ->appendAttrib('class', 'noprint'); - - $table = parent::getHtmlOutput($view); - $table->setPivot(true, 2, 1); - - $this->applyHtmlAttributes($table); - $htmlDiv[] = $table; - - } else { - $htmlDiv->ul(sprintf($this->_('Token %s not found.'), $this->tokenId), array('class' => 'errors')); - } - - } else { - $htmlDiv->ul($this->_('No token specified.'), array('class' => 'errors')); - } - - $buttonDiv = $htmlDiv->buttonDiv(); - $buttonDiv->actionLink(array(), $this->_('Close'), array('onclick' => 'window.close();')); - $buttonDiv->actionLink(array(), $this->_('Print'), array('onclick' => 'window.print();')); - return $htmlDiv; - } - - /** - * The place to check if the data set in the snippet is valid - * to generate the snippet. - * - * When invalid data should result in an error, you can throw it - * here but you can also perform the check in the - * checkRegistryRequestsAnswers() function from the - * {@see MUtil_Registry_TargetInterface}. - * - * @return boolean - */ - public function hasHtmlOutput() - { - if (! $this->tokenId) { - if (isset($this->token)) { - $this->tokenId = $this->token->getTokenId(); - } - } elseif (! $this->token) { - $this->token = $this->loader->getTracker()->getToken($this->tokenId); - } - - // Output always true, returns an error message as html when anything is wrong - return true; - } -} +class AnswerModelSnippet extends Gems_Tracker_Snippets_AnswerModelSnippetGeneric +{ } Modified: trunk/library/snippets/TrackAnswersModelSnippet.php =================================================================== --- trunk/library/snippets/TrackAnswersModelSnippet.php 2011-10-31 09:13:59 UTC (rev 154) +++ trunk/library/snippets/TrackAnswersModelSnippet.php 2011-10-31 09:46:30 UTC (rev 155) @@ -36,8 +36,6 @@ * @version $Id$ */ -include_once(dirname(__FILE__) . '/AnswerModelSnippet.php'); - /** * Class description of TrackAnswersModelSnippet * @@ -47,7 +45,7 @@ * @license New BSD License * @since Class available since version 1.4 */ -class TrackAnswersModelSnippet extends AnswerModelSnippet +class TrackAnswersModelSnippet extends Gems_Tracker_Snippets_AnswerModelSnippetGeneric { /** * Overrule to implement snippet specific filtering and sorting. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2011-10-31 09:14:05
|
Revision: 154 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=154&view=rev Author: matijsdejong Date: 2011-10-31 09:13:59 +0000 (Mon, 31 Oct 2011) Log Message: ----------- Fix for ticket #32: fieldmap cache crashes with the language 'nl-informal'. Modified Paths: -------------- branches/newUser/classes/Gems/Tracker/Source/LimeSurvey1m9FieldMap.php Modified: branches/newUser/classes/Gems/Tracker/Source/LimeSurvey1m9FieldMap.php =================================================================== --- branches/newUser/classes/Gems/Tracker/Source/LimeSurvey1m9FieldMap.php 2011-10-28 12:36:57 UTC (rev 153) +++ branches/newUser/classes/Gems/Tracker/Source/LimeSurvey1m9FieldMap.php 2011-10-31 09:13:59 UTC (rev 154) @@ -204,9 +204,10 @@ protected function _getMap() { - $cacheId = 'lsFieldMap'.$this->sourceSurveyId.$this->language; + $cacheId = 'lsFieldMap'.$this->sourceSurveyId.strtr($this->language, '-.', '__'); + $this->_fieldMap = $this->cache->load($cacheId); - if( ($this->_fieldMap = $this->cache->load($cacheId)) === false ) { + if (false === $this->_fieldMap) { $gTable = $this->_getGroupsTableName(); $qTable = $this->_getQuestionsTableName(); @@ -344,7 +345,6 @@ $this->cache->save($this->_fieldMap, $cacheId); } - return $this->_fieldMap; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2011-10-28 12:37:03
|
Revision: 153 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=153&view=rev Author: matijsdejong Date: 2011-10-28 12:36:57 +0000 (Fri, 28 Oct 2011) Log Message: ----------- AddTrackSnippet can now handle organization switches correctly. Made it easier to write your own AnswerModel. Modified Paths: -------------- branches/newUser/snippets/AddTracksSnippet.php branches/newUser/snippets/AnswerModelSnippet.php branches/newUser/snippets/TrackAnswersModelSnippet.php Added Paths: ----------- branches/newUser/classes/Gems/Tracker/Snippets/AnswerModelSnippetGeneric.php Added: branches/newUser/classes/Gems/Tracker/Snippets/AnswerModelSnippetGeneric.php =================================================================== --- branches/newUser/classes/Gems/Tracker/Snippets/AnswerModelSnippetGeneric.php (rev 0) +++ branches/newUser/classes/Gems/Tracker/Snippets/AnswerModelSnippetGeneric.php 2011-10-28 12:36:57 UTC (rev 153) @@ -0,0 +1,229 @@ +<?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 Tracker + * @author Matijs de Jong <mj...@ma...> + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @version $Id: AnswerModelSnippet.php 28 2011-09-16 06:24:15Z mennodekker $ + */ + +/** + * Displays answers to a survey. + * + * @package Gems + * @subpackage Tracker + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @since Class available since version 1.5 + */ +class Gems_Tracker_Snippets_AnswerModelSnippetGeneric extends Gems_Snippets_ModelTableSnippetAbstract +{ + /** + * Set a fixed model sort. + * + * Leading _ means not overwritten by sources. + * + * @var array + */ + protected $_fixedSort = array('gto_round_order' => SORT_ASC); + + /** + * Shortfix to add class attribute + * + * @var string + */ + protected $class = 'browser'; + + /** + * + * @var string Format used for displaying dates. + */ + protected $dateFormat = Zend_Date::DATE_MEDIUM; + + /** + * Required + * + * @var Gems_Loader + */ + protected $loader; + + /** + * Required + * + * @var Zend_Locale + */ + protected $locale; + + /** + * Optional: $request or $tokenData must be set + * + * The display data of the token shown + * + * @var Gems_Tracker_Token + */ + protected $token; + + /** + * Required: id of the selected token to show + * + * @var string + */ + protected $tokenId; + + /** + * Adds columns from the model to the bridge that creates the browse table. + * + * Overrule this function to add different columns to the browse table, without + * having to recode the core table building code. + * + * @param MUtil_Model_TableBridge $bridge + * @param MUtil_Model_ModelAbstract $model + * @return void + */ + protected function addBrowseTableColumns(MUtil_Model_TableBridge $bridge, MUtil_Model_ModelAbstract $model) + { + $br = MUtil_Html::create('br'); + $selectedClass = MUtil_Lazy::iff(MUtil_Lazy::comp($bridge->gto_id_token, '==', $this->tokenId), 'selectedColumn', null); + + $bridge->th($this->_('Status')); + $td = $bridge->tdh(MUtil_Lazy::first($bridge->grc_description, $this->_('OK'))); + $td->appendAttrib('class', $selectedClass); + + $bridge->th($this->_('Question')); + $td = $bridge->tdh( + $bridge->gto_round_description, + MUtil_Lazy::iif($bridge->gto_round_description, $br), + MUtil_Lazy::iif($bridge->gto_completion_time, $bridge->gto_completion_time, $bridge->gto_valid_from) + ); + $td->appendAttrib('class', $selectedClass); + $td->appendAttrib('class', $bridge->row_class); + + foreach($model->getItemsOrdered() as $name) { + if ($label = $model->get($name, 'label')) { + $bridge->thd($label, array('class' => $model->get($name, 'thClass'))); + $td = $bridge->td($bridge->$name); + + $td->appendAttrib('class', 'answer'); + $td->appendAttrib('class', $selectedClass); + $td->appendAttrib('class', $bridge->row_class); + } + } + + $bridge->th($this->_('Token')); + $td = $bridge->tdh($bridge->gto_id_token->strtoupper()); + $td->appendAttrib('class', $selectedClass); + $td->appendAttrib('class', $bridge->row_class); + } + + /** + * Creates the model + * + * @return MUtil_Model_ModelAbstract + */ + protected function createModel() + { + $model = $this->token->getSurveyAnswerModel($this->locale->getLanguage()); + + $model->set('gto_valid_from', 'dateFormat', $this->dateFormat); + $model->set('gto_completion_time', 'dateFormat', $this->dateFormat); + + return $model; + } + + + /** + * Create the snippets content + * + * This is a stub function either override getHtmlOutput() or override render() + * + * @param Zend_View_Abstract $view Just in case it is needed here + * @return MUtil_Html_HtmlInterface Something that can be rendered + */ + public function getHtmlOutput(Zend_View_Abstract $view) + { + $htmlDiv = MUtil_Html::create()->div(); + + if ($this->tokenId) { + if ($this->token->exists) { + $htmlDiv->h3(sprintf($this->_('%s answers for patient number %s'), $this->token->getSurveyName(), $this->token->getPatientNumber())); + + $htmlDiv->pInfo(sprintf( + $this->_('Answers for token %s, patient number %s: %s.'), + strtoupper($this->tokenId), + $this->token->getPatientNumber(), + $this->token->getRespondentName())) + ->appendAttrib('class', 'noprint'); + + $table = parent::getHtmlOutput($view); + $table->setPivot(true, 2, 1); + + $this->applyHtmlAttributes($table); + $htmlDiv[] = $table; + + } else { + $htmlDiv->ul(sprintf($this->_('Token %s not found.'), $this->tokenId), array('class' => 'errors')); + } + + } else { + $htmlDiv->ul($this->_('No token specified.'), array('class' => 'errors')); + } + + $buttonDiv = $htmlDiv->buttonDiv(); + $buttonDiv->actionLink(array(), $this->_('Close'), array('onclick' => 'window.close();')); + $buttonDiv->actionLink(array(), $this->_('Print'), array('onclick' => 'window.print();')); + return $htmlDiv; + } + + /** + * The place to check if the data set in the snippet is valid + * to generate the snippet. + * + * When invalid data should result in an error, you can throw it + * here but you can also perform the check in the + * checkRegistryRequestsAnswers() function from the + * {@see MUtil_Registry_TargetInterface}. + * + * @return boolean + */ + public function hasHtmlOutput() + { + if (! $this->tokenId) { + if (isset($this->token)) { + $this->tokenId = $this->token->getTokenId(); + } + } elseif (! $this->token) { + $this->token = $this->loader->getTracker()->getToken($this->tokenId); + } + + // Output always true, returns an error message as html when anything is wrong + return true; + } +} Modified: branches/newUser/snippets/AddTracksSnippet.php =================================================================== --- branches/newUser/snippets/AddTracksSnippet.php 2011-10-28 10:54:42 UTC (rev 152) +++ branches/newUser/snippets/AddTracksSnippet.php 2011-10-28 12:36:57 UTC (rev 153) @@ -103,10 +103,11 @@ throw new exception('Invalid track type requested.'); } - $trackTypeTime = $trackType . '_time'; + $trackTypeCache = $trackType . '_' . $this->session->user_style; + $trackTypeTime = $trackType . '_time'; - if (isset($this->session->$trackType, $this->session->$trackTypeTime) && (time() < $this->session->$trackTypeTime)) { - $tracks = $this->session->$trackType; + if (isset($this->session->$trackTypeCache, $this->session->$trackTypeTime) && (time() < $this->session->$trackTypeTime)) { + $tracks = $this->session->$trackTypeCache; } else { $organization_id = $this->escort->getCurrentOrganization(); switch ($trackType) { @@ -153,8 +154,8 @@ } $tracks = $this->db->fetchPairs($sql); - $this->session->$trackType = $tracks; - $this->session->$trackTypeTime = time() + 600; + $this->session->$trackTypeCache = $tracks; + $this->session->$trackTypeTime = time() + 600; } $div = MUtil_Html::create()->div(array('class' => 'toolbox')); Modified: branches/newUser/snippets/AnswerModelSnippet.php =================================================================== --- branches/newUser/snippets/AnswerModelSnippet.php 2011-10-28 10:54:42 UTC (rev 152) +++ branches/newUser/snippets/AnswerModelSnippet.php 2011-10-28 12:36:57 UTC (rev 153) @@ -44,186 +44,5 @@ * @license New BSD License * @since Class available since version 1.4 */ -class AnswerModelSnippet extends Gems_Snippets_ModelTableSnippetAbstract -{ - /** - * Set a fixed model sort. - * - * Leading _ means not overwritten by sources. - * - * @var array - */ - protected $_fixedSort = array('gto_round_order' => SORT_ASC); - - /** - * Shortfix to add class attribute - * - * @var string - */ - protected $class = 'browser'; - - /** - * - * @var string Format used for displaying dates. - */ - protected $dateFormat = Zend_Date::DATE_MEDIUM; - - /** - * Required - * - * @var Gems_Loader - */ - protected $loader; - - /** - * Required - * - * @var Zend_Locale - */ - protected $locale; - - /** - * Optional: $request or $tokenData must be set - * - * The display data of the token shown - * - * @var Gems_Tracker_Token - */ - protected $token; - - /** - * Required: id of the selected token to show - * - * @var string - */ - protected $tokenId; - - /** - * Adds columns from the model to the bridge that creates the browse table. - * - * Overrule this function to add different columns to the browse table, without - * having to recode the core table building code. - * - * @param MUtil_Model_TableBridge $bridge - * @param MUtil_Model_ModelAbstract $model - * @return void - */ - protected function addBrowseTableColumns(MUtil_Model_TableBridge $bridge, MUtil_Model_ModelAbstract $model) - { - $br = MUtil_Html::create('br'); - $selectedClass = MUtil_Lazy::iff(MUtil_Lazy::comp($bridge->gto_id_token, '==', $this->tokenId), 'selectedColumn', null); - - $bridge->th($this->_('Status')); - $td = $bridge->tdh(MUtil_Lazy::first($bridge->grc_description, $this->_('OK'))); - $td->appendAttrib('class', $selectedClass); - - $bridge->th($this->_('Question')); - $td = $bridge->tdh( - $bridge->gto_round_description, - MUtil_Lazy::iif($bridge->gto_round_description, $br), - MUtil_Lazy::iif($bridge->gto_completion_time, $bridge->gto_completion_time, $bridge->gto_valid_from) - ); - $td->appendAttrib('class', $selectedClass); - $td->appendAttrib('class', $bridge->row_class); - - foreach($model->getItemsOrdered() as $name) { - if ($label = $model->get($name, 'label')) { - $bridge->thd($label, array('class' => $model->get($name, 'thClass'))); - $td = $bridge->td($bridge->$name); - - $td->appendAttrib('class', 'answer'); - $td->appendAttrib('class', $selectedClass); - $td->appendAttrib('class', $bridge->row_class); - } - } - - $bridge->th($this->_('Token')); - $td = $bridge->tdh($bridge->gto_id_token->strtoupper()); - $td->appendAttrib('class', $selectedClass); - $td->appendAttrib('class', $bridge->row_class); - } - - /** - * Creates the model - * - * @return MUtil_Model_ModelAbstract - */ - protected function createModel() - { - $model = $this->token->getSurveyAnswerModel($this->locale->getLanguage()); - - $model->set('gto_valid_from', 'dateFormat', $this->dateFormat); - $model->set('gto_completion_time', 'dateFormat', $this->dateFormat); - - return $model; - } - - - /** - * Create the snippets content - * - * This is a stub function either override getHtmlOutput() or override render() - * - * @param Zend_View_Abstract $view Just in case it is needed here - * @return MUtil_Html_HtmlInterface Something that can be rendered - */ - public function getHtmlOutput(Zend_View_Abstract $view) - { - $htmlDiv = MUtil_Html::create()->div(); - - if ($this->tokenId) { - if ($this->token->exists) { - $htmlDiv->h3(sprintf($this->_('%s answers for patient number %s'), $this->token->getSurveyName(), $this->token->getPatientNumber())); - - $htmlDiv->pInfo(sprintf( - $this->_('Answers for token %s, patient number %s: %s.'), - strtoupper($this->tokenId), - $this->token->getPatientNumber(), - $this->token->getRespondentName())) - ->appendAttrib('class', 'noprint'); - - $table = parent::getHtmlOutput($view); - $table->setPivot(true, 2, 1); - - $this->applyHtmlAttributes($table); - $htmlDiv[] = $table; - - } else { - $htmlDiv->ul(sprintf($this->_('Token %s not found.'), $this->tokenId), array('class' => 'errors')); - } - - } else { - $htmlDiv->ul($this->_('No token specified.'), array('class' => 'errors')); - } - - $buttonDiv = $htmlDiv->buttonDiv(); - $buttonDiv->actionLink(array(), $this->_('Close'), array('onclick' => 'window.close();')); - $buttonDiv->actionLink(array(), $this->_('Print'), array('onclick' => 'window.print();')); - return $htmlDiv; - } - - /** - * The place to check if the data set in the snippet is valid - * to generate the snippet. - * - * When invalid data should result in an error, you can throw it - * here but you can also perform the check in the - * checkRegistryRequestsAnswers() function from the - * {@see MUtil_Registry_TargetInterface}. - * - * @return boolean - */ - public function hasHtmlOutput() - { - if (! $this->tokenId) { - if (isset($this->token)) { - $this->tokenId = $this->token->getTokenId(); - } - } elseif (! $this->token) { - $this->token = $this->loader->getTracker()->getToken($this->tokenId); - } - - // Output always true, returns an error message as html when anything is wrong - return true; - } -} +class AnswerModelSnippet extends Gems_Tracker_Snippets_AnswerModelSnippetGeneric +{ } Modified: branches/newUser/snippets/TrackAnswersModelSnippet.php =================================================================== --- branches/newUser/snippets/TrackAnswersModelSnippet.php 2011-10-28 10:54:42 UTC (rev 152) +++ branches/newUser/snippets/TrackAnswersModelSnippet.php 2011-10-28 12:36:57 UTC (rev 153) @@ -36,8 +36,6 @@ * @version $Id$ */ -include_once(dirname(__FILE__) . '/AnswerModelSnippet.php'); - /** * Class description of TrackAnswersModelSnippet * @@ -47,7 +45,7 @@ * @license New BSD License * @since Class available since version 1.4 */ -class TrackAnswersModelSnippet extends AnswerModelSnippet +class TrackAnswersModelSnippet extends Gems_Tracker_Snippets_AnswerModelSnippetGeneric { /** * Overrule to implement snippet specific filtering and sorting. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2011-10-28 10:54:48
|
Revision: 152 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=152&view=rev Author: matijsdejong Date: 2011-10-28 10:54:42 +0000 (Fri, 28 Oct 2011) Log Message: ----------- Fixes for #31 Modified Paths: -------------- branches/newUser/classes/Gems/Default/IndexAction.php branches/newUser/configs/db/patches.sql Modified: branches/newUser/classes/Gems/Default/IndexAction.php =================================================================== --- branches/newUser/classes/Gems/Default/IndexAction.php 2011-10-27 16:21:42 UTC (rev 151) +++ branches/newUser/classes/Gems/Default/IndexAction.php 2011-10-28 10:54:42 UTC (rev 152) @@ -209,9 +209,9 @@ $adapter->setIdentity($userid); $adapter->setCredential(md5($_POST['password'], false)); $result = $auth->authenticate($adapter, $_POST['userlogin']); - MUtil_Echo::track('old autho'); + // MUtil_Echo::track('old autho'); } else { - MUtil_Echo::track('new autho'); + // MUtil_Echo::track('new autho'); } if (!$result->isValid()) { Modified: branches/newUser/configs/db/patches.sql =================================================================== --- branches/newUser/configs/db/patches.sql 2011-10-27 16:21:42 UTC (rev 151) +++ branches/newUser/configs/db/patches.sql 2011-10-28 10:54:42 UTC (rev 152) @@ -228,4 +228,8 @@ ALTER TABLE `gems__staff` CHANGE `gsf_id_user` `gsf_id_user` BIGINT( 20 ) UNSIGNED NOT NULL; -ALTER TABLE `gems__staff` DROP INDEX `gsf_login`; \ No newline at end of file +ALTER TABLE `gems__staff` DROP INDEX `gsf_login`; + +ALTER TABLE `gems__staff` CHANGE `gsf_login` `gsf_login` VARCHAR( 20 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + CHANGE `gsf_password` `gsf_password` VARCHAR( 32 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + CHANGE `gsf_id_organization` `gsf_id_organization` BIGINT( 20 ) NULL DEFAULT NULL; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2011-10-27 16:21:56
|
Revision: 151 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=151&view=rev Author: matijsdejong Date: 2011-10-27 16:21:42 +0000 (Thu, 27 Oct 2011) Log Message: ----------- First step for #31: login info moved from gems__staff to gems__users.10.sql Temp fix for moving to new password situation while retaining the older versions. DeleteValues moved up to DatabaseModelAbstract. setModelParameters() added to menu for 2 parameter menu items. Modified Paths: -------------- trunk/library/changelog.txt trunk/library/classes/Gems/Auth.php trunk/library/classes/Gems/Cookies.php trunk/library/classes/Gems/Default/CronAction.php trunk/library/classes/Gems/Default/IndexAction.php trunk/library/classes/Gems/Default/OptionAction.php trunk/library/classes/Gems/Default/RespondentAction.php trunk/library/classes/Gems/Default/StaffAction.php trunk/library/classes/Gems/Default/TokenPlanAction.php trunk/library/classes/Gems/Loader/LoaderAbstract.php trunk/library/classes/Gems/Loader.php trunk/library/classes/Gems/Menu/MenuAbstract.php trunk/library/classes/Gems/Menu/SubMenuItem.php trunk/library/classes/Gems/Util/DbLookup.php trunk/library/classes/Gems/Validate/GemsPasswordUsername.php trunk/library/classes/GemsEscort.php trunk/library/classes/MUtil/Model/DatabaseModelAbstract.php trunk/library/classes/MUtil/Model/JoinModel.php trunk/library/classes/MUtil/Model/ModelAbstract.php trunk/library/classes/MUtil/Model/TableBridgeAbstract.php trunk/library/classes/MUtil/Model/TableModel.php trunk/library/configs/db/patches.sql trunk/library/configs/db/tables/gems__staff.20.sql trunk/library/controllers/StaffController.php trunk/library/languages/default-nl.mo trunk/library/languages/default-nl.po Added Paths: ----------- trunk/library/classes/Gems/Model/UserModel.php trunk/library/classes/Gems/User/ trunk/library/classes/Gems/User/DatabaseUserAbstract.php trunk/library/classes/Gems/User/NoLoginUser.php trunk/library/classes/Gems/User/ProjectSuperUser.php trunk/library/classes/Gems/User/RespondentUser.php trunk/library/classes/Gems/User/StaffUser.php trunk/library/classes/Gems/User/UserAbstract.php trunk/library/classes/Gems/User/UserInterface.php trunk/library/classes/Gems/User/UserLoader.php trunk/library/configs/db/tables/gems__users.10.sql Removed Paths: ------------- trunk/library/classes/Gems/User/DatabaseUserAbstract.php trunk/library/classes/Gems/User/NoLoginUser.php trunk/library/classes/Gems/User/ProjectSuperUser.php trunk/library/classes/Gems/User/RespondentUser.php trunk/library/classes/Gems/User/StaffUser.php trunk/library/classes/Gems/User/UserAbstract.php trunk/library/classes/Gems/User/UserInterface.php trunk/library/classes/Gems/User/UserLoader.php Property Changed: ---------------- trunk/library/ Property changes on: trunk/library ___________________________________________________________________ Added: svn:mergeinfo + /branches/newUser:113-150 Modified: trunk/library/changelog.txt =================================================================== --- trunk/library/changelog.txt 2011-10-27 15:55:57 UTC (rev 150) +++ trunk/library/changelog.txt 2011-10-27 16:21:42 UTC (rev 151) @@ -1,5 +1,7 @@ Important changes from 1.4.3 => 1.5 ============================================================ +The table gems__staff is split into gems__staff and gems__user with all login data in gems__users +Passwords should be set with a project.ini->salt MailController is now called MailTemplateController EmailController is now called CronController (with stub for compatibility) Modified: trunk/library/classes/Gems/Auth.php =================================================================== --- trunk/library/classes/Gems/Auth.php 2011-10-27 15:55:57 UTC (rev 150) +++ trunk/library/classes/Gems/Auth.php 2011-10-27 16:21:42 UTC (rev 151) @@ -98,8 +98,8 @@ * Lookup last failed login and number of failed logins */ try { - $sql = "SELECT gsf_failed_logins, UNIX_TIMESTAMP(gsf_last_failed) - AS gsf_last_failed FROM gems__staff WHERE gsf_login = ?"; + $sql = "SELECT gsu_failed_logins, UNIX_TIMESTAMP(gsu_last_failed) + AS gsu_last_failed FROM gems__users WHERE gsu_login = ?"; $results = $this->db->fetchRow($sql, array($username)); } catch (Zend_Db_Exception $zde) { //If we need to apply a db patch, just use a default value @@ -107,10 +107,10 @@ MUtil_Echo::r(GemsEscort::getInstance()->translate->_('Please update the database')); } - $delay = pow($results['gsf_failed_logins'], $this->_delayFactor); - $remaining = ($results['gsf_last_failed'] + $delay) - time(); + $delay = pow($results['gsu_failed_logins'], $this->_delayFactor); + $remaining = ($results['gsu_last_failed'] + $delay) - time(); - if ($results['gsf_failed_logins'] > 0 && $remaining > 0) { + if ($results['gsu_failed_logins'] > 0 && $remaining > 0) { //$this->_obscureValue = false; $result = $this->_error(self::ERROR_PASSWORD_DELAY, ceil($remaining / 60)); } Modified: trunk/library/classes/Gems/Cookies.php =================================================================== --- trunk/library/classes/Gems/Cookies.php 2011-10-27 15:55:57 UTC (rev 150) +++ trunk/library/classes/Gems/Cookies.php 2011-10-27 16:21:42 UTC (rev 151) @@ -1,63 +1,86 @@ <?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 $Id$ + +/** + * 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 Cookies + * @author Matijs de Jong <mj...@ma...> * @copyright Copyright (c) 2011 Erasmus MC * @license New BSD License + * @version $Id$ */ /** * Static Gems cookie utilities - * - * @author Matijs de Jong + * * @package Gems * @subpackage Cookies * @copyright Copyright (c) 2011 Erasmus MC * @license New BSD License + * @since Class available since version 1.0 */ class Gems_Cookies { const LOCALE_COOKIE = 'gems_locale'; - public static function get(Zend_Controller_Request_Abstract $request, $name) + /** + * Get a specific cookie from the request. + * + * @param Zend_Controller_Request_Abstract $request + * @param string $name + * @param mixed $default + * @return mixed Cookie value + */ + public static function get(Zend_Controller_Request_Abstract $request, $name, $default = null) { - return $request->getCookie($name); + return $request->getCookie($name, $default); } + /** + * Get the current locale from the cookie. + * + * @param Zend_Controller_Request_Abstract $request + * @return string The current locale + */ public static function getLocale(Zend_Controller_Request_Abstract $request) { return self::get($request, self::LOCALE_COOKIE); } + /** + * Store this cookie in a generic save method that works for both sub-directory + * installations and own url installations. + * + * @param string $name Name of the cookie + * @param mixed $value Value to set + * @param int $days Number of days to keep this cookie + * @param string $basepath The folder of the domain, if any. + * @return boolean True if the cookie was stored. + */ public static function set($name, $value, $days = 30, $basepath = '/') { // Gems uses the empty string when the base path is '/' @@ -69,6 +92,13 @@ return setcookie($name, $value, time() + ($days * 86400), $basepath); } + /** + * Store the locale in a cookie. + * + * @param string $locale Locale to store + * @param string $basepath The folder of the domain, if any. + * @return boolean True if the cookie was stored. + */ public static function setLocale($locale, $basepath = '/') { // Set the cookie for 30 days Modified: trunk/library/classes/Gems/Default/CronAction.php =================================================================== --- trunk/library/classes/Gems/Default/CronAction.php 2011-10-27 15:55:57 UTC (rev 150) +++ trunk/library/classes/Gems/Default/CronAction.php 2011-10-27 16:21:42 UTC (rev 151) @@ -125,7 +125,7 @@ */ protected function getUserLogin($userId) { - return $this->db->fetchOne("SELECT gsf_login FROM gems__staff WHERE gsf_id_user = ?", $userId); + return $this->db->fetchOne("SELECT gsu_login FROM gems__users WHERE gsu_id_user = ?", $userId); } public function indexAction() Modified: trunk/library/classes/Gems/Default/IndexAction.php =================================================================== --- trunk/library/classes/Gems/Default/IndexAction.php 2011-10-27 15:55:57 UTC (rev 150) +++ trunk/library/classes/Gems/Default/IndexAction.php 2011-10-27 16:21:42 UTC (rev 151) @@ -74,7 +74,7 @@ * @return Zend_Auth_Adapter_Interface */ protected function _getAuthAdapter($formValues) { - $adapter = new Zend_Auth_Adapter_DbTable($this->db, 'gems__staff', 'gsf_login', 'gsf_password'); + $adapter = new Zend_Auth_Adapter_DbTable($this->db, 'gems__users', 'gsu_login', 'gsu_password'); $adapter->setIdentity($formValues['userlogin']); $adapter->setCredential($this->escort->passwordHash(null, $formValues['password'], false)); return $adapter; @@ -97,6 +97,21 @@ $form->setMethod('post'); $form->setDescription(sprintf($this->_('Login to %s application'), $this->project->name)); + if ($this->escort instanceof Gems_Project_Organization_SingleOrganizationInterface) { + $element = new Zend_Form_Element_Hidden('organization'); + $element->setValue($this->escort->getRespondentOrganization()); + } else { + $element = new Zend_Form_Element_Select('organization'); + $element->setLabel($this->_('Organization')); + $element->setMultiOptions($this->util->getDbLookup()->getOrganizations()); + $element->setRequired(true); + + if (! $this->_request->isPost()) { + $element->setValue($this->escort->getCurrentOrganization()); + } + } + $form->addElement($element); + // Veld inlognaam $element = new Zend_Form_Element_Text('userlogin'); $element->setLabel($this->_('Username')); @@ -135,7 +150,7 @@ return $form; } - // Dummy: always rerouted by Gems + // Dummy: always rerouted by GemsEscort public function indexAction() { } public function loginAction() @@ -152,11 +167,17 @@ $this->_reroute(array('controller' => 'respondent', 'action'=>'index')); } } + // MUtil_Echo::track(get_class($this->loader->getUser('super', null))); $form = $this->_getLoginForm(); if ($this->_request->isPost()) { if ($form->isValid($_POST, false)) { + /* + if ($user = $this->loader->getUser($_POST['userlogin'], $_POST['organization'])) { + + } // */ + if (isset($this->project->admin) && $this->project->admin['user'] == $_POST['userlogin'] && $this->project->admin['pwd'] == $_POST['password']) { $this->session->user_id = 2000; $this->session->user_name = $_POST['userlogin']; @@ -180,6 +201,19 @@ $adapter = $this->_getAuthAdapter($form->getValues()); $auth = Gems_Auth::getInstance(); $result = $auth->authenticate($adapter, $_POST['userlogin']); + + // Allow login using old password. + if ((! $result->isValid()) && ($userid = $this->db->fetchOne("SELECT gsu_id_user FROM gems__users WHERE gsu_active = 1 AND gsu_password IS NULL AND gsu_login = ?", $_POST['userlogin']))) { + + $adapter = new Zend_Auth_Adapter_DbTable($this->db, 'gems__staff', 'gsf_id_user', 'gsf_password'); + $adapter->setIdentity($userid); + $adapter->setCredential(md5($_POST['password'], false)); + $result = $auth->authenticate($adapter, $_POST['userlogin']); + MUtil_Echo::track('old autho'); + } else { + MUtil_Echo::track('new autho'); + } + if (!$result->isValid()) { // Invalid credentials $errors = $result->getMessages(); @@ -295,19 +329,19 @@ } if ($this->_request->isPost() && $form->isValid($_POST)) { - $sql = $this->db->quoteInto("SELECT gsf_id_user,gsf_email,gsf_reset_key,DATEDIFF(NOW(), gsf_reset_req) AS gsf_days FROM gems__staff WHERE gsf_login = ?", $_POST['userlogin']); + $sql = $this->db->quoteInto("SELECT gsu_id_user, gsf_email, gsu_reset_key, DATEDIFF(NOW(), gsu_reset_requested) AS gsf_days FROM gems__users INNER JOIN gems__staff ON gsu_id_user = gsf_id_user WHERE gsu_login = ?", $_POST['userlogin']); $result = $this->db->fetchRow($sql); if (empty($result) || empty($result['gsf_email'])) { $this->addMessage($this->_('No such user found or no e-mail address known')); - } else if (!empty($result['gsf_reset_key']) && $result['gsf_days'] < 1) { + } else if (!empty($result['gsu_reset_key']) && $result['gsf_days'] < 1) { $this->addMessage($this->_('Reset e-mail already sent, please try again after 24 hours')); } else { $email = $result['gsf_email']; $key = md5(time() . $email); $url = $this->util->getCurrentURI('index/resetpassword/key/' . $key); - $this->db->update('gems__staff', array('gsf_reset_key' => $key, 'gsf_reset_req' => new Zend_Db_Expr('NOW()')), 'gsf_id_user = ' . $result['gsf_id_user']); + $this->db->update('gems__users', array('gsu_reset_key' => $key, 'gsu_reset_requested' => new Zend_Db_Expr('NOW()')), 'gsu_id_user = ' . $result['gsu_id_user']); $mail->setSubject('Password reset requested'); $mail->setBodyText('To reset your password, please click this link: ' . $url); @@ -323,7 +357,7 @@ } } } else if ($key = $this->_request->getParam('key')) { - $sql = $this->db->quoteInto("SELECT gsf_id_user,gsf_email FROM gems__staff WHERE gsf_reset_key = ?", $key); + $sql = $this->db->quoteInto("SELECT gsu_id_user, gsf_email FROM gems__users INNER JOIN gems__staff ON gsu_id_user = gsf_id_user WHERE gsu_reset_key = ?", $key); $result = $this->db->fetchRow($sql); if (!empty($result)) { @@ -339,7 +373,7 @@ try { $mail->send(); $this->addMessage($this->_('An e-mail was sent containing your new password')); - $this->db->update('gems__staff', array('gsf_reset_key' => new Zend_Db_Expr('NULL'), 'gsf_reset_req' => new Zend_Db_Expr('NULL'), 'gsf_password' => $passwordHash), 'gsf_id_user = ' . $result['gsf_id_user']); + $this->db->update('gems__users', array('gsu_reset_key' => new Zend_Db_Expr('NULL'), 'gsu_reset_requested' => new Zend_Db_Expr('NULL'), 'gsu_password' => $passwordHash), 'gsu_id_user = ' . $result['gsu_id_user']); $this->_reroute(array('action' => 'index'), true); } catch (Exception $e) { $this->addMessage($this->_('Unable to send e-mail')); Modified: trunk/library/classes/Gems/Default/OptionAction.php =================================================================== --- trunk/library/classes/Gems/Default/OptionAction.php 2011-10-27 15:55:57 UTC (rev 150) +++ trunk/library/classes/Gems/Default/OptionAction.php 2011-10-27 16:21:42 UTC (rev 151) @@ -61,8 +61,10 @@ */ protected function addFormElements(MUtil_Model_FormBridge $bridge, MUtil_Model_ModelAbstract $model, array $data, $new = false) { + $bridge->addHidden( 'gsu_id_user'); + $bridge->addHidden( 'gsu_id_organization'); $bridge->addHidden( 'gsf_id_user'); - $bridge->addExhibitor('gsf_login', array('size' => 15, 'minlength' => 4)); + $bridge->addExhibitor('gsu_login', array('size' => 15, 'minlength' => 4)); $bridge->addText( 'gsf_first_name'); $bridge->addText( 'gsf_surname_prefix'); $bridge->addText( 'gsf_last_name'); @@ -71,12 +73,11 @@ $bridge->addRadio( 'gsf_gender', 'separator', ''); $bridge->addSelect( 'gsf_iso_lang', array('label' => $this->_('Language'), 'multiOptions' => $this->util->getLocalized()->getLanguages())); - $bridge->addCheckbox( 'gsf_logout_on_survey', 'label', $this->_('Logout on survey'), 'description', $this->_('If checked you will logoff after answering a survey.')); } public function afterSave(array $data, $isNew) { - $this->escort->loadLoginInfo($data['gsf_login']); + $this->escort->loadLoginInfo($data['gsu_login']); } public function changePasswordAction() @@ -86,15 +87,18 @@ *************/ $form = $this->createForm(); - // Veld current password - $element = new Zend_Form_Element_Password('old_password'); - $element->setLabel($this->_('Current password')); - $element->setAttrib('size', 10); - $element->setAttrib('maxlength', 20); - $element->setRenderPassword(true); - $element->setRequired(true); - $element->addValidator(new Gems_Validate_GemsPasswordUsername($this->session->user_login, 'old_password', $this->db)); - $form->addElement($element); + $sql = "SELECT CASE WHEN gsu_password IS NULL THEN 0 ELSE 1 END FROM gems__users WHERE gsu_id_user = ? AND gsu_id_organization = ?"; + if ($this->db->fetchOne($sql, array($this->session->user_id, $this->session->user_organization_id))) { + // Veld current password + $element = new Zend_Form_Element_Password('old_password'); + $element->setLabel($this->_('Current password')); + $element->setAttrib('size', 10); + $element->setAttrib('maxlength', 20); + $element->setRenderPassword(true); + $element->setRequired(true); + $element->addValidator(new Gems_Validate_GemsPasswordUsername($this->session->user_login, 'old_password', $this->db)); + $form->addElement($element); + } // Veld new password $element = new Zend_Form_Element_Password('new_password'); @@ -127,8 +131,9 @@ ****************/ if ($this->_request->isPost() && $form->isValid($_POST)) { - $data['gsf_id_user'] = $this->session->user_id; - $data['gsf_password'] = $this->escort->passwordHash(null,$_POST['new_password']); + $data['gsu_id_user'] = $this->session->user_id; + $data['gsu_id_organization'] = $this->session->user_organization_id; + $data['gsu_password'] = $this->escort->passwordHash(null, $_POST['new_password']); $this->getModel()->save($data); @@ -180,10 +185,10 @@ */ public function createModel($detailed, $action) { - $model = new MUtil_Model_TableModel('gems__staff'); - $model->canCreate = false; + $model = new Gems_Model_UserModel('staff', 'gems__staff', array('gsu_id_user' => 'gsf_id_user'), 'gsf'); + $model->copyKeys(); - $model->set('gsf_login', 'label', $this->_('Login Name')); + $model->set('gsu_login', 'label', $this->_('Login Name')); $model->set('gsf_email', 'label', $this->_('E-Mail')); $model->set('gsf_first_name', 'label', $this->_('First name')); $model->set('gsf_surname_prefix', 'label', $this->_('Surname prefix'), 'description', 'de, van der, \'t, etc...'); @@ -191,14 +196,12 @@ $model->set('gsf_gender', 'label', $this->_('Gender'), 'multiOptions', $this->util->getTranslated()->getGenders()); - Gems_Model::setChangeFieldsByPrefix($model, 'gsf'); - return $model; } public function editAction() { - $this->getModel()->setFilter(array('gsf_id_user' => $this->session->user_id)); + $this->getModel()->setFilter(array('gsu_id_user' => $this->session->user_id)); if ($form = $this->processForm()) { $this->html->h3(sprintf($this->_('Options'), $this->getTopic())); Modified: trunk/library/classes/Gems/Default/RespondentAction.php =================================================================== --- trunk/library/classes/Gems/Default/RespondentAction.php 2011-10-27 15:55:57 UTC (rev 150) +++ trunk/library/classes/Gems/Default/RespondentAction.php 2011-10-27 16:21:42 UTC (rev 151) @@ -326,8 +326,8 @@ $values = $this->db->fetchPairs(" SELECT gsf_id_user, CONCAT(gsf_last_name, ', ', COALESCE(CONCAT(gsf_first_name, ' '), ''), COALESCE(gsf_surname_prefix, '')) AS name - FROM gems__staff INNER JOIN gems__groups ON gsf_id_primary_group = ggp_id_group - WHERE gsf_active=1 AND gsf_id_organization = ? AND ggp_role = 'physician' + FROM (gems__users INNER JOIN gems__staff ON gsu_id_user = gsf_id_user) INNER JOIN gems__groups ON gsf_id_primary_group = ggp_id_group + WHERE gsu_active=1 AND gsu_id_organization = ? AND ggp_role = 'physician' ORDER BY 2", $organizationId); $session->physicians = $values; Modified: trunk/library/classes/Gems/Default/StaffAction.php =================================================================== --- trunk/library/classes/Gems/Default/StaffAction.php 2011-10-27 15:55:57 UTC (rev 150) +++ trunk/library/classes/Gems/Default/StaffAction.php 2011-10-27 16:21:42 UTC (rev 151) @@ -44,7 +44,7 @@ */ class Gems_Default_StaffAction extends Gems_Controller_BrowseEditAction { - public $filterStandard = array('gsf_active' => 1); + public $filterStandard = array('gsu_active' => 1); public $sortKey = array('name' => SORT_ASC); protected $_instanceId; @@ -96,18 +96,28 @@ if ($new) { $model->set('gsf_id_primary_group', 'default', $dbLookup->getDefaultGroup()); } else { - $model->set('gsf_password', 'description', $this->_('Enter only when changing')); - $model->setSaveWhenNotNull('gsf_password'); + $model->set('gsu_password', 'description', $this->_('Enter only when changing')); + $model->setSaveWhenNotNull('gsu_password'); } - $model->setOnSave('gsf_password', array($this->escort, 'passwordHash')); + $model->setOnSave('gsu_password', array($this->escort, 'passwordHash')); $ucfirst = new Zend_Filter_Callback('ucfirst'); - $bridge->addHidden( 'gsf_id_user'); - $bridge->addText( 'gsf_login', 'size', 15, 'minlength', 4, - 'validator', $model->createUniqueValidator('gsf_login')); + $bridge->addHidden( 'gsu_id_user'); + $bridge->addHidden( 'gsf_id_user'); // Needed for e-mail validation + $bridge->addHidden( 'gsu_user_class'); + $bridge->addText( 'gsu_login', 'size', 15, 'minlength', 4, + 'validator', $model->createUniqueValidator('gsu_login')); - $bridge->addPassword('gsf_password', + // Can the organization be changed? + if ($this->escort->hasPrivilege('pr.staff.edit.all')) { + $bridge->addHiddenMulti($model->getKeyCopyName('gsu_id_organization')); + $bridge->addSelect('gsu_id_organization'); + } else { + $bridge->addExhibitor('gsu_id_organization'); + } + + $bridge->addPassword('gsu_password', 'label', $this->_('Password'), 'minlength', $this->project->passwords['MinimumLength'], // 'renderPassword', true, @@ -123,11 +133,6 @@ $bridge->addFilter( 'gsf_last_name', $ucfirst); $bridge->addText( 'gsf_email', array('size' => 30))->addValidator('SimpleEmail')->addValidator($model->createUniqueValidator('gsf_email')); - if ($this->escort->hasPrivilege('pr.staff.edit.all')) { - $bridge->addSelect('gsf_id_organization'); - } else { - $bridge->addExhibitor('gsf_id_organization'); - } $bridge->addSelect('gsf_id_primary_group'); $bridge->addCheckbox('gsf_logout_on_survey', 'description', $this->_('If checked the user will logoff when answering a survey.')); @@ -136,15 +141,15 @@ public function afterFormLoad(array &$data, $isNew) { - if (array_key_exists('gsf_login', $data)) { - $this->_instanceId = $data['gsf_login']; + if (array_key_exists('gsu_login', $data)) { + $this->_instanceId = $data['gsu_login']; } $sql = "SELECT ggp_id_group,ggp_role FROM gems__groups WHERE ggp_id_group = " . (int) $data['gsf_id_primary_group']; $groups = $this->db->fetchPairs($sql); if (! ($this->escort->hasPrivilege('pr.staff.edit.all') || - $data['gsf_id_organization'] == $this->escort->getCurrentOrganization())) { + $data['gsu_id_organization'] == $this->escort->getCurrentOrganization())) { throw new Zend_Exception($this->_('You are not allowed to edit this staff member.')); } } @@ -164,18 +169,21 @@ { // MUtil_Model::$verbose = true; - $model = new MUtil_Model_TableModel('gems__staff'); + $model = new Gems_Model_UserModel('staff', 'gems__staff', array('gsu_id_user' => 'gsf_id_user'), 'gsf'); + if ($detailed) { + $model->copyKeys(); + } //$model->resetOrder(); - $model->set('gsf_login', 'label', $this->_('Login')); + $model->set('gsu_login', 'label', $this->_('Login')); $model->set('name', 'label', $this->_('Name'), 'column_expression', "CONCAT(COALESCE(CONCAT(gsf_last_name, ', '), '-, '), COALESCE(CONCAT(gsf_first_name, ' '), ''), COALESCE(gsf_surname_prefix, ''))"); $model->set('gsf_email', 'label', $this->_('E-Mail'), 'itemDisplay', 'MUtil_Html_AElement::ifmail'); if ($detailed || $this->escort->hasPrivilege('pr.staff.see.all')) { - $this->menu->getParameterSource()->offsetSet('gsf_id_organization', $this->escort->getCurrentOrganization()); + $this->menu->getParameterSource()->offsetSet('gsu_id_organization', $this->escort->getCurrentOrganization()); - $model->set('gsf_id_organization', 'label', $this->_('Organization'), + $model->set('gsu_id_organization', 'label', $this->_('Organization'), 'multiOptions', $this->util->getDbLookup()->getOrganizations(), 'default', $this->escort->getCurrentOrganization()); } @@ -184,14 +192,13 @@ $model->set('gsf_gender', 'label', $this->_('Gender'), 'multiOptions', $this->util->getTranslated()->getGenders()); if ($detailed) { + $model->set('gsu_user_class', 'default', 'StaffUser'); $model->set('gsf_iso_lang', 'label', $this->_('Language'), 'multiOptions', $this->util->getLocalized()->getLanguages()); $model->set('gsf_logout_on_survey', 'label', $this->_('Logout on survey'), 'multiOptions', $this->util->getTranslated()->getYesNo()); } - $model->setDeleteValues('gsf_active', 0); + $model->setDeleteValues('gsu_active', 0); - Gems_Model::setChangeFieldsByPrefix($model, 'gsf'); - return $model; } @@ -201,8 +208,8 @@ if ($this->escort->hasPrivilege('pr.staff.see.all')) { // Select organization - $options = array('' => $this->_('(all organizations)')) + $this->getModel()->get('gsf_id_organization', 'multiOptions'); - $select = new Zend_Form_Element_Select('gsf_id_organization', array('multiOptions' => $options)); + $options = array('' => $this->_('(all organizations)')) + $this->getModel()->get('gsu_id_organization', 'multiOptions'); + $select = new Zend_Form_Element_Select('gsu_id_organization', array('multiOptions' => $options)); // Position as second element $search = array_shift($elements); @@ -227,7 +234,7 @@ $filter = parent::getDataFilter($data); if (! $this->escort->hasPrivilege('pr.staff.see.all')) { - $filter['gsf_id_organization'] = $this->escort->getCurrentOrganization(); + $filter['gsu_id_organization'] = $this->escort->getCurrentOrganization(); } return $filter; } @@ -257,8 +264,8 @@ // Model filter has now been set. $data = $this->getModel()->loadFirst(); - $this->_setParam('gsf_id_organization', $data['gsf_id_organization']); - $this->menu->getParameterSource()->offsetSet('gsf_id_organization', $data['gsf_id_organization']); + $this->_setParam('gsu_id_organization', $data['gsu_id_organization']); + $this->menu->getParameterSource()->offsetSet('gsu_id_organization', $data['gsu_id_organization']); } return parent::getShowTable($columns, $filter, $sort); } Modified: trunk/library/classes/Gems/Default/TokenPlanAction.php =================================================================== --- trunk/library/classes/Gems/Default/TokenPlanAction.php 2011-10-27 15:55:57 UTC (rev 150) +++ trunk/library/classes/Gems/Default/TokenPlanAction.php 2011-10-27 16:21:42 UTC (rev 151) @@ -351,9 +351,9 @@ COALESCE(gems__staff.gsf_first_name, ''), COALESCE(CONCAT(' ', gems__staff.gsf_surname_prefix), '') ) AS gsf_name - FROM gems__staff INNER JOIN gems__respondent2track ON gsf_id_user = gr2t_created_by + FROM (gems__users INNER JOIN gems__staff ON gsu_id_user = gsf_id_user) INNER JOIN gems__respondent2track ON gsu_id_user = gr2t_created_by WHERE gr2t_id_organization = $orgId AND - gsf_active = 1 AND + gsu_active = 1 AND gr2t_active = 1"; $elements[] = $this->_createSelectElement('gr2t_created_by', $sql, $this->_('(all staff)')); Modified: trunk/library/classes/Gems/Loader/LoaderAbstract.php =================================================================== --- trunk/library/classes/Gems/Loader/LoaderAbstract.php 2011-10-27 15:55:57 UTC (rev 150) +++ trunk/library/classes/Gems/Loader/LoaderAbstract.php 2011-10-27 16:21:42 UTC (rev 151) @@ -154,7 +154,7 @@ { // echo '_loadClassPath: ' . $this->cascade . '-' . $classname . '-' . ($create ? 1 : 0) . "<br/>\n"; // debug_print_backtrace(); - // MUtil_Echo::r($filepath, $classname, $this->cascade); + // MUtil_Echo::track($filepath, $classname, $this->cascade); if (file_exists($filepath)) { if (! class_exists($classname)) { Modified: trunk/library/classes/Gems/Loader.php =================================================================== --- trunk/library/classes/Gems/Loader.php 2011-10-27 15:55:57 UTC (rev 150) +++ trunk/library/classes/Gems/Loader.php 2011-10-27 16:21:42 UTC (rev 151) @@ -90,6 +90,12 @@ /** * + * @var Gems_User_UserLoader + */ + protected $userLoader; + + /** + * * @var Gems_Util */ protected $util; @@ -177,6 +183,28 @@ /** * + * @param string $login_name + * @param int $organization Only used when more than one organization uses this $login_name + * @return Gems_User_UserAbstract + */ + public function getUser($login_name, $organization) + { + $loader = $this->getUserLoader(); + + return $loader->getUser($login_name, $organization); + } + + /** + * + * @return Gems_User_UserLoader + */ + protected function getUserLoader() + { + return $this->_getClass('userLoader', 'User_UserLoader'); + } + + /** + * * @return Gems_Util */ public function getUtil() Modified: trunk/library/classes/Gems/Menu/MenuAbstract.php =================================================================== --- trunk/library/classes/Gems/Menu/MenuAbstract.php 2011-10-27 15:55:57 UTC (rev 150) +++ trunk/library/classes/Gems/Menu/MenuAbstract.php 2011-10-27 16:21:42 UTC (rev 151) @@ -381,13 +381,12 @@ $page = $this->addPage($label, 'pr.staff', 'staff', 'index', $other); $page->addAutofilterAction(); $page->addCreateAction(); - $page->addShowAction(); - if ($this->escort->hasPrivilege('pr.staff.edit.all')) { - $page->addEditAction(); - $page->addDeleteAction(); - } else { - $page->addEditAction()->setParameterFilter('gsf_id_organization', $this->escort->getCurrentOrganization()); - $page->addDeleteAction()->setParameterFilter('gsf_id_organization', $this->escort->getCurrentOrganization()); + $page->addShowAction()->setModelParameters(2); + $editPage = $page->addEditAction()->setModelParameters(2); + $delPage = $page->addDeleteAction()->setModelParameters(2); + if (! $this->escort->hasPrivilege('pr.staff.edit.all')) { + $editPage->setParameterFilter('gsu_id_organization', $this->escort->getCurrentOrganization()); + $delPage->setParameterFilter('gsu_id_organization', $this->escort->getCurrentOrganization()); } return $page; Modified: trunk/library/classes/Gems/Menu/SubMenuItem.php =================================================================== --- trunk/library/classes/Gems/Menu/SubMenuItem.php 2011-10-27 15:55:57 UTC (rev 150) +++ trunk/library/classes/Gems/Menu/SubMenuItem.php 2011-10-27 16:21:42 UTC (rev 151) @@ -417,7 +417,7 @@ } $menu = $this->addAction($label, $privilege, 'delete', $other); - $menu->addParameters(MUtil_Model::REQUEST_ID); + $menu->setModelParameters(1); return $menu; } @@ -436,7 +436,7 @@ } $menu = $this->addAction($label, $privilege, 'edit', $other); - $menu->addParameters(MUtil_Model::REQUEST_ID); + $menu->setModelParameters(1); return $menu; } @@ -475,6 +475,17 @@ return $this; } + /** + * Add required parameters - shown in the url - for this + * menu item. + * + * Numeric array keys are changed into the same string as the + * array value. + * + * @param mixed $arrayOrKey1 MUtil_Ra::pairs named array + * @param mixed $key2 + * @return Gems_Menu_SubMenuItem (continuation pattern) + */ public function addNamedParameters($arrayOrKey1 = null, $altName1 = null) { $params = MUtil_Ra::pairs(func_get_args()); @@ -483,16 +494,8 @@ $this->_parameters = new MUtil_Lazy_ArrayWrap(); } foreach ($params as $param => $name) { - if (! $name) { - if (is_int($param)) { - throw new Zend_Exception('Invalid integer required parameter key with empty name.'); - } else { - $name = $param; - } - } else { - if (is_int($param)) { - $param = $name; - } + if (is_int($param)) { + $param = $name; } $this->_requiredParameters[$param] = $name; $this->_parameters[$param] = MUtil_Lazy::L($name); @@ -546,7 +549,7 @@ } $menu = $this->addAction($label, $privilege, 'show', $other); - $menu->addParameters(MUtil_Model::REQUEST_ID); + $menu->setModelParameters(1); return $menu; } @@ -755,6 +758,41 @@ return $this; } + /** + * Defines the number of named parameters using the model naming + * convention: id=x or id1=x id2=y + * + * @see setNamedParamenters() + * + * @param int $idCount The number of parameters to define + * @return Gems_Menu_SubMenuItem (continuation pattern) + */ + public function setModelParameters($idCount) + { + $params = array(); + if (1 == $idCount) { + $params[MUtil_Model::REQUEST_ID] = MUtil_Model::REQUEST_ID; + } else { + for ($i = 1; $i <= $idCount; $i++) { + $params[MUtil_Model::REQUEST_ID . $i] = MUtil_Model::REQUEST_ID . $i; + } + } + $this->setNamedParameters($params); + + return $this; + } + + /** + * Set the required parameters - shown in the url - for this + * menu item. + * + * Numeric array keys are changed into the same string as the + * array value. + * + * @param mixed $arrayOrKey1 MUtil_Ra::pairs named array + * @param mixed $key2 + * @return Gems_Menu_SubMenuItem (continuation pattern) + */ public function setNamedParameters($arrayOrKey1 = null, $key2 = null) { $params = MUtil_Ra::pairs(func_get_args()); Copied: trunk/library/classes/Gems/Model/UserModel.php (from rev 150, branches/newUser/classes/Gems/Model/UserModel.php) =================================================================== --- trunk/library/classes/Gems/Model/UserModel.php (rev 0) +++ trunk/library/classes/Gems/Model/UserModel.php 2011-10-27 16:21:42 UTC (rev 151) @@ -0,0 +1,119 @@ +<?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 Model + * @author Matijs de Jong <mj...@ma...> + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @version $Id: Sample.php 203 2011-07-07 12:51:32Z matijs $ + */ + +/** + * + * + * @package Gems + * @subpackage Model + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @since Class available since version 1.4.4 + */ +class Gems_Model_UserModel extends Gems_Model_JoinModel +{ + /** + * The length of a user id. + * + * @var int + */ + protected $userIdLen = 8; + + /** + * Create a model that joins two or more tables + * + * @param string $name The name of the model + * @param string $secondTable The optional second base table for the model + * @param array $joinFields Array of source->dest primary keys for this join + * @param string $fieldPrefix Prefix to use for change fields (date/userid) + * @param bool $saveable Will changes to this table be saved + */ + public function __construct($name, $secondTable = null, array $joinFields = null, $fieldPrefix = null, $saveable = null) + { + parent::__construct($name, 'gems__users', (null === $saveable ? $fieldPrefix : $saveable)); + + if ($fieldPrefix) { + Gems_Model::setChangeFieldsByPrefix($this, 'gsu'); + } + + if ($secondTable) { + $this->addTable($secondTable, $joinFields, $fieldPrefix, $saveable); + } + } + + /** + * Finds a random unique user id. + * + * @return int + */ + protected function _createUserId() + { + $db = $this->getAdapter(); + + $max = $this->userIdLen; + + do { + $out = mt_rand(1, 9); + for ($i = 1; $i < $this->userIdLen; $i++) { + $out .= mt_rand(0, 9); + } + // Make it a number + $out = intval($out); + + } while ($db->fetchOne('SELECT gsu_id_user FROM gems__users WHERE gsu_id_user = ?', $out)); + + return $out; + } + + /** + * Save a single model item. + * + * @param array $newValues The values to store for a single model item. + * @param array $filter If the filter contains old key values these are used + * to decide on update versus insert. + * @return array The values as they are after saving (they may change). + */ + public function save(array $newValues, array $filter = null, array $saveTables = null) + { + if (! (isset($newValues['gsu_id_user']) && $newValues['gsu_id_user'])) { + // Load a new user id if needed + $newValues['gsu_id_user'] = $this->_createUserId(); + } + + return parent::save($newValues, $filter, $saveTables); + } +} Property changes on: trunk/library/classes/Gems/User ___________________________________________________________________ Added: bugtraq:url + http://survey.erasmusmc.nl/support/mantis/view.php?id=%BUGID% Added: bugtraq:number + true Added: bugtraq:logregex + #(\d+) Deleted: trunk/library/classes/Gems/User/DatabaseUserAbstract.php =================================================================== --- branches/newUser/classes/Gems/User/DatabaseUserAbstract.php 2011-10-27 15:55:57 UTC (rev 150) +++ trunk/library/classes/Gems/User/DatabaseUserAbstract.php 2011-10-27 16:21:42 UTC (rev 151) @@ -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 User - * @author Matijs de Jong <mj...@ma...> - * @copyright Copyright (c) 2011 Erasmus MC - * @license New BSD License - * @version $Id: Sample.php 203 2011-07-07 12:51:32Z matijs $ - */ - -/** - * - * - * @package Gems - * @subpackage User - * @copyright Copyright (c) 2011 Erasmus MC - * @license New BSD License - * @since Class available since version 1.4.4 - */ -class Gems_User_DatabaseUserAbstract extends Gems_User_UserAbstract -{ - /** - * - * @var Zend_Db_Adapter_Abstract - */ - protected $db; - - /** - * Simple used name => database field - * @var array - */ - protected $fieldMappings = array(); - - /** - * Creates the initial feed SQL select statement - * - * @return Zend_Db_Select - */ - abstract public function getSqlSelect(); - - /** - * Intialize the values for this user. - * - * Skipped when the user is the active user and is stored in the session. - * - * @param string $login_name - * @param int $organization Only used when more than one organization uses this $login_name - * @return boolean False when the object could not load. - */ - protected function initVariables($login_name, $organization) - { - $select = $this->getSqlSelect(); - - $userIds = $select->query()->fetchAll(); - } -} Copied: trunk/library/classes/Gems/User/DatabaseUserAbstract.php (from rev 150, branches/newUser/classes/Gems/User/DatabaseUserAbstract.php) =================================================================== --- trunk/library/classes/Gems/User/DatabaseUserAbstract.php (rev 0) +++ trunk/library/classes/Gems/User/DatabaseUserAbstract.php 2011-10-27 16:21:42 UTC (rev 151) @@ -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 User + * @author Matijs de Jong <mj...@ma...> + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @version $Id: Sample.php 203 2011-07-07 12:51:32Z matijs $ + */ + +/** + * + * + * @package Gems + * @subpackage User + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @since Class available since version 1.4.4 + */ +class Gems_User_DatabaseUserAbstract extends Gems_User_UserAbstract +{ + /** + * + * @var Zend_Db_Adapter_Abstract + */ + protected $db; + + /** + * Simple used name => database field + * @var array + */ + protected $fieldMappings = array(); + + /** + * Creates the initial feed SQL select statement + * + * @return Zend_Db_Select + */ + abstract public function getSqlSelect(); + + /** + * Intialize the values for this user. + * + * Skipped when the user is the active user and is stored in the session. + * + * @param string $login_name + * @param int $organization Only used when more than one organization uses this $login_name + * @return boolean False when the object could not load. + */ + protected function initVariables($login_name, $organization) + { + $select = $this->getSqlSelect(); + + $userIds = $select->query()->fetchAll(); + } +} Deleted: trunk/library/classes/Gems/User/NoLoginUser.php =================================================================== --- branches/newUser/classes/Gems/User/NoLoginUser.php 2011-10-27 15:55:57 UTC (rev 150) +++ trunk/library/classes/Gems/User/NoLoginUser.php 2011-10-27 16:21:42 UTC (rev 151) @@ -1,81 +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 User - * @author Matijs de Jong <mj...@ma...> - * @copyright Copyright (c) 2011 Erasmus MC - * @license New BSD License - * @version $Id: Sample.php 203 2011-07-07 12:51:32Z matijs $ - */ - -/** - * - * - * @package Gems - * @subpackage User - * @copyright Copyright (c) 2011 Erasmus MC - * @license New BSD License - * @since Class available since version 1.4.4 - */ -class Gems_User_NoLoginUser extends Gems_User_UserAbstract -{ - /** - * - * @var Gems_Util_Translated - */ - protected $translated; - - /** - * Check that the password is correct for this user. - * - * @param string $password Unencrypted password - * @return boolean - */ - public function checkPassword($password) - { - return false; - } - - /** - * Intialize the values for this user. - * - * Skipped when the user is the active user and is stored in the session. - * - * @param string $login_name - * @param int $organization Only used when more than one organization uses this $login_name - * @return boolean False when the object could not load. - */ - protected function initVariables($login_name, $organization) - { - $this->setRole('nologin'); - return true; - } - -} Copied: trunk/library/classes/Gems/User/NoLoginUser.php (from rev 150, branches/newUser/classes/Gems/User/NoLoginUser.php) =================================================================== --- trunk/library/classes/Gems/User/NoLoginUser.php (rev 0) +++ trunk/library/classes/Gems/User/NoLoginUser.php 2011-10-27 16:21:42 UTC (rev 151) @@ -0,0 +1,81 @@ +<?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 User + * @author Matijs de Jong <mj...@ma...> + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @version $Id: Sample.php 203 2011-07-07 12:51:32Z matijs $ + */ + +/** + * + * + * @package Gems + * @subpackage User + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @since Class available since version 1.4.4 + */ +class Gems_User_NoLoginUser extends Gems_User_UserAbstract +{ + /** + * + * @var Gems_Util_Translated + */ + protected $translated; + + /** + * Check that the password is correct for this user. + * + * @param string $password Unencrypted password + * @return boolean + */ + public function checkPassword($password) + { + return false; + } + + /** + * Intialize the values for this user. + * + * Skipped when the user is the active user and is stored in the session. + * + * @param string $login_name + * @param int $organization Only used when more than one organization uses this $login_name + * @return boolean False when the object could not load. + */ + protected function initVariables($login_name, $organization) + { + $this->setRole('nologin'); + return true; + } + +} Deleted: trunk/library/classes/Gems/User/ProjectSuperUser.php =================================================================== --- branches/newUser/classes/Gems/User/ProjectSuperUser.php 2011-10-27 15:55:57 UTC (rev 150) +++ trunk/library/classes/Gems/User/ProjectSuperUser.php 2011-10-27 16:21:42 UTC (rev 151) @@ -1,113 +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 F... [truncated message content] |
From: <gem...@li...> - 2011-10-27 15:56:03
|
Revision: 150 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=150&view=rev Author: matijsdejong Date: 2011-10-27 15:55:57 +0000 (Thu, 27 Oct 2011) Log Message: ----------- Last change merged Modified Paths: -------------- branches/newUser/classes/Gems/Tracker/Source/LimeSurvey1m9FieldMap.php Property Changed: ---------------- branches/newUser/ Property changes on: branches/newUser ___________________________________________________________________ Modified: svn:mergeinfo - /trunk/library:114-122,125-139,142-144 + /trunk/library:114-122,125-139,142-144,147 Modified: branches/newUser/classes/Gems/Tracker/Source/LimeSurvey1m9FieldMap.php =================================================================== --- branches/newUser/classes/Gems/Tracker/Source/LimeSurvey1m9FieldMap.php 2011-10-27 15:49:44 UTC (rev 149) +++ branches/newUser/classes/Gems/Tracker/Source/LimeSurvey1m9FieldMap.php 2011-10-27 15:55:57 UTC (rev 150) @@ -59,6 +59,11 @@ protected $_titlesMap; /** + * @var Zend_Cache_Core + */ + protected $cache; + + /** * The language of this fieldmap * * @var string @@ -108,6 +113,7 @@ $this->lsDb = $lsDb; $this->translate = $translate; $this->tablePrefix = $tablePrefix; + $this->cache = GemsEscort::getInstance()->cache; //Load the cache from escort } /** @@ -198,7 +204,9 @@ protected function _getMap() { - if (! $this->_fieldMap) { + $cacheId = 'lsFieldMap'.$this->sourceSurveyId.$this->language; + + if( ($this->_fieldMap = $this->cache->load($cacheId)) === false ) { $gTable = $this->_getGroupsTableName(); $qTable = $this->_getQuestionsTableName(); @@ -333,9 +341,10 @@ } } $this->_fieldMap = $map; - // MUtil_Echo::track($this->_fieldMap); + $this->cache->save($this->_fieldMap, $cacheId); } + return $this->_fieldMap; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2011-10-27 15:49:55
|
Revision: 149 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=149&view=rev Author: matijsdejong Date: 2011-10-27 15:49:44 +0000 (Thu, 27 Oct 2011) Log Message: ----------- Some final fixes for creating staff users and deleting items Modified Paths: -------------- branches/newUser/classes/Gems/Default/StaffAction.php branches/newUser/classes/MUtil/Model/JoinModel.php branches/newUser/configs/db/patches.sql Modified: branches/newUser/classes/Gems/Default/StaffAction.php =================================================================== --- branches/newUser/classes/Gems/Default/StaffAction.php 2011-10-27 15:37:58 UTC (rev 148) +++ branches/newUser/classes/Gems/Default/StaffAction.php 2011-10-27 15:49:44 UTC (rev 149) @@ -105,6 +105,7 @@ $bridge->addHidden( 'gsu_id_user'); $bridge->addHidden( 'gsf_id_user'); // Needed for e-mail validation + $bridge->addHidden( 'gsu_user_class'); $bridge->addText( 'gsu_login', 'size', 15, 'minlength', 4, 'validator', $model->createUniqueValidator('gsu_login')); @@ -191,6 +192,7 @@ $model->set('gsf_gender', 'label', $this->_('Gender'), 'multiOptions', $this->util->getTranslated()->getGenders()); if ($detailed) { + $model->set('gsu_user_class', 'default', 'StaffUser'); $model->set('gsf_iso_lang', 'label', $this->_('Language'), 'multiOptions', $this->util->getLocalized()->getLanguages()); $model->set('gsf_logout_on_survey', 'label', $this->_('Logout on survey'), 'multiOptions', $this->util->getTranslated()->getYesNo()); } Modified: branches/newUser/classes/MUtil/Model/JoinModel.php =================================================================== --- branches/newUser/classes/MUtil/Model/JoinModel.php 2011-10-27 15:37:58 UTC (rev 148) +++ branches/newUser/classes/MUtil/Model/JoinModel.php 2011-10-27 15:49:44 UTC (rev 149) @@ -175,8 +175,7 @@ $filter = $this->_checkFilterUsed($filter); if ($this->_deleteValues) { - MUtil_Echo::track($filter); - $changed = $this->save($this->_deleteValues, $filter, $saveTables); + $changed = $this->save($this->_deleteValues + $filter, $filter, $saveTables); } else { $changed = 0; foreach ($saveTables as $table_name) { Modified: branches/newUser/configs/db/patches.sql =================================================================== --- branches/newUser/configs/db/patches.sql 2011-10-27 15:37:58 UTC (rev 148) +++ branches/newUser/configs/db/patches.sql 2011-10-27 15:49:44 UTC (rev 149) @@ -227,3 +227,5 @@ FROM gems__staff; ALTER TABLE `gems__staff` CHANGE `gsf_id_user` `gsf_id_user` BIGINT( 20 ) UNSIGNED NOT NULL; + +ALTER TABLE `gems__staff` DROP INDEX `gsf_login`; \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2011-10-27 15:38:05
|
Revision: 148 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=148&view=rev Author: matijsdejong Date: 2011-10-27 15:37:58 +0000 (Thu, 27 Oct 2011) Log Message: ----------- For #31: gems__staff split into gems__users Temp fix for moving to new password situation while retaining the older versions. DeleteValues moved up to DatabaseModelAbstract. setModelParameters() added to menu for 2 parameter menu items. Modified Paths: -------------- branches/newUser/classes/Gems/Auth.php branches/newUser/classes/Gems/Default/CronAction.php branches/newUser/classes/Gems/Default/IndexAction.php branches/newUser/classes/Gems/Default/OptionAction.php branches/newUser/classes/Gems/Default/RespondentAction.php branches/newUser/classes/Gems/Default/StaffAction.php branches/newUser/classes/Gems/Default/TokenPlanAction.php branches/newUser/classes/Gems/Menu/MenuAbstract.php branches/newUser/classes/Gems/Menu/SubMenuItem.php branches/newUser/classes/Gems/Model/UserModel.php branches/newUser/classes/Gems/User/RespondentUser.php branches/newUser/classes/Gems/User/StaffUser.php branches/newUser/classes/Gems/Util/DbLookup.php branches/newUser/classes/Gems/Validate/GemsPasswordUsername.php branches/newUser/classes/GemsEscort.php branches/newUser/classes/MUtil/Model/DatabaseModelAbstract.php branches/newUser/classes/MUtil/Model/JoinModel.php branches/newUser/classes/MUtil/Model/ModelAbstract.php branches/newUser/classes/MUtil/Model/TableBridgeAbstract.php branches/newUser/classes/MUtil/Model/TableModel.php branches/newUser/configs/db/patches.sql branches/newUser/configs/db/tables/gems__staff.20.sql branches/newUser/configs/db/tables/gems__users.10.sql branches/newUser/controllers/StaffController.php Modified: branches/newUser/classes/Gems/Auth.php =================================================================== --- branches/newUser/classes/Gems/Auth.php 2011-10-27 13:29:59 UTC (rev 147) +++ branches/newUser/classes/Gems/Auth.php 2011-10-27 15:37:58 UTC (rev 148) @@ -98,8 +98,8 @@ * Lookup last failed login and number of failed logins */ try { - $sql = "SELECT gsf_failed_logins, UNIX_TIMESTAMP(gsf_last_failed) - AS gsf_last_failed FROM gems__staff WHERE gsf_login = ?"; + $sql = "SELECT gsu_failed_logins, UNIX_TIMESTAMP(gsu_last_failed) + AS gsu_last_failed FROM gems__users WHERE gsu_login = ?"; $results = $this->db->fetchRow($sql, array($username)); } catch (Zend_Db_Exception $zde) { //If we need to apply a db patch, just use a default value @@ -107,10 +107,10 @@ MUtil_Echo::r(GemsEscort::getInstance()->translate->_('Please update the database')); } - $delay = pow($results['gsf_failed_logins'], $this->_delayFactor); - $remaining = ($results['gsf_last_failed'] + $delay) - time(); + $delay = pow($results['gsu_failed_logins'], $this->_delayFactor); + $remaining = ($results['gsu_last_failed'] + $delay) - time(); - if ($results['gsf_failed_logins'] > 0 && $remaining > 0) { + if ($results['gsu_failed_logins'] > 0 && $remaining > 0) { //$this->_obscureValue = false; $result = $this->_error(self::ERROR_PASSWORD_DELAY, ceil($remaining / 60)); } Modified: branches/newUser/classes/Gems/Default/CronAction.php =================================================================== --- branches/newUser/classes/Gems/Default/CronAction.php 2011-10-27 13:29:59 UTC (rev 147) +++ branches/newUser/classes/Gems/Default/CronAction.php 2011-10-27 15:37:58 UTC (rev 148) @@ -125,7 +125,7 @@ */ protected function getUserLogin($userId) { - return $this->db->fetchOne("SELECT gsf_login FROM gems__staff WHERE gsf_id_user = ?", $userId); + return $this->db->fetchOne("SELECT gsu_login FROM gems__users WHERE gsu_id_user = ?", $userId); } public function indexAction() Modified: branches/newUser/classes/Gems/Default/IndexAction.php =================================================================== --- branches/newUser/classes/Gems/Default/IndexAction.php 2011-10-27 13:29:59 UTC (rev 147) +++ branches/newUser/classes/Gems/Default/IndexAction.php 2011-10-27 15:37:58 UTC (rev 148) @@ -74,7 +74,7 @@ * @return Zend_Auth_Adapter_Interface */ protected function _getAuthAdapter($formValues) { - $adapter = new Zend_Auth_Adapter_DbTable($this->db, 'gems__staff', 'gsf_login', 'gsf_password'); + $adapter = new Zend_Auth_Adapter_DbTable($this->db, 'gems__users', 'gsu_login', 'gsu_password'); $adapter->setIdentity($formValues['userlogin']); $adapter->setCredential($this->escort->passwordHash(null, $formValues['password'], false)); return $adapter; @@ -201,6 +201,19 @@ $adapter = $this->_getAuthAdapter($form->getValues()); $auth = Gems_Auth::getInstance(); $result = $auth->authenticate($adapter, $_POST['userlogin']); + + // Allow login using old password. + if ((! $result->isValid()) && ($userid = $this->db->fetchOne("SELECT gsu_id_user FROM gems__users WHERE gsu_active = 1 AND gsu_password IS NULL AND gsu_login = ?", $_POST['userlogin']))) { + + $adapter = new Zend_Auth_Adapter_DbTable($this->db, 'gems__staff', 'gsf_id_user', 'gsf_password'); + $adapter->setIdentity($userid); + $adapter->setCredential(md5($_POST['password'], false)); + $result = $auth->authenticate($adapter, $_POST['userlogin']); + MUtil_Echo::track('old autho'); + } else { + MUtil_Echo::track('new autho'); + } + if (!$result->isValid()) { // Invalid credentials $errors = $result->getMessages(); @@ -316,19 +329,19 @@ } if ($this->_request->isPost() && $form->isValid($_POST)) { - $sql = $this->db->quoteInto("SELECT gsf_id_user,gsf_email,gsf_reset_key,DATEDIFF(NOW(), gsf_reset_req) AS gsf_days FROM gems__staff WHERE gsf_login = ?", $_POST['userlogin']); + $sql = $this->db->quoteInto("SELECT gsu_id_user, gsf_email, gsu_reset_key, DATEDIFF(NOW(), gsu_reset_requested) AS gsf_days FROM gems__users INNER JOIN gems__staff ON gsu_id_user = gsf_id_user WHERE gsu_login = ?", $_POST['userlogin']); $result = $this->db->fetchRow($sql); if (empty($result) || empty($result['gsf_email'])) { $this->addMessage($this->_('No such user found or no e-mail address known')); - } else if (!empty($result['gsf_reset_key']) && $result['gsf_days'] < 1) { + } else if (!empty($result['gsu_reset_key']) && $result['gsf_days'] < 1) { $this->addMessage($this->_('Reset e-mail already sent, please try again after 24 hours')); } else { $email = $result['gsf_email']; $key = md5(time() . $email); $url = $this->util->getCurrentURI('index/resetpassword/key/' . $key); - $this->db->update('gems__staff', array('gsf_reset_key' => $key, 'gsf_reset_req' => new Zend_Db_Expr('NOW()')), 'gsf_id_user = ' . $result['gsf_id_user']); + $this->db->update('gems__users', array('gsu_reset_key' => $key, 'gsu_reset_requested' => new Zend_Db_Expr('NOW()')), 'gsu_id_user = ' . $result['gsu_id_user']); $mail->setSubject('Password reset requested'); $mail->setBodyText('To reset your password, please click this link: ' . $url); @@ -344,7 +357,7 @@ } } } else if ($key = $this->_request->getParam('key')) { - $sql = $this->db->quoteInto("SELECT gsf_id_user,gsf_email FROM gems__staff WHERE gsf_reset_key = ?", $key); + $sql = $this->db->quoteInto("SELECT gsu_id_user, gsf_email FROM gems__users INNER JOIN gems__staff ON gsu_id_user = gsf_id_user WHERE gsu_reset_key = ?", $key); $result = $this->db->fetchRow($sql); if (!empty($result)) { @@ -360,7 +373,7 @@ try { $mail->send(); $this->addMessage($this->_('An e-mail was sent containing your new password')); - $this->db->update('gems__staff', array('gsf_reset_key' => new Zend_Db_Expr('NULL'), 'gsf_reset_req' => new Zend_Db_Expr('NULL'), 'gsf_password' => $passwordHash), 'gsf_id_user = ' . $result['gsf_id_user']); + $this->db->update('gems__users', array('gsu_reset_key' => new Zend_Db_Expr('NULL'), 'gsu_reset_requested' => new Zend_Db_Expr('NULL'), 'gsu_password' => $passwordHash), 'gsu_id_user = ' . $result['gsu_id_user']); $this->_reroute(array('action' => 'index'), true); } catch (Exception $e) { $this->addMessage($this->_('Unable to send e-mail')); Modified: branches/newUser/classes/Gems/Default/OptionAction.php =================================================================== --- branches/newUser/classes/Gems/Default/OptionAction.php 2011-10-27 13:29:59 UTC (rev 147) +++ branches/newUser/classes/Gems/Default/OptionAction.php 2011-10-27 15:37:58 UTC (rev 148) @@ -61,8 +61,10 @@ */ protected function addFormElements(MUtil_Model_FormBridge $bridge, MUtil_Model_ModelAbstract $model, array $data, $new = false) { + $bridge->addHidden( 'gsu_id_user'); + $bridge->addHidden( 'gsu_id_organization'); $bridge->addHidden( 'gsf_id_user'); - $bridge->addExhibitor('gsf_login', array('size' => 15, 'minlength' => 4)); + $bridge->addExhibitor('gsu_login', array('size' => 15, 'minlength' => 4)); $bridge->addText( 'gsf_first_name'); $bridge->addText( 'gsf_surname_prefix'); $bridge->addText( 'gsf_last_name'); @@ -71,12 +73,11 @@ $bridge->addRadio( 'gsf_gender', 'separator', ''); $bridge->addSelect( 'gsf_iso_lang', array('label' => $this->_('Language'), 'multiOptions' => $this->util->getLocalized()->getLanguages())); - $bridge->addCheckbox( 'gsf_logout_on_survey', 'label', $this->_('Logout on survey'), 'description', $this->_('If checked you will logoff after answering a survey.')); } public function afterSave(array $data, $isNew) { - $this->escort->loadLoginInfo($data['gsf_login']); + $this->escort->loadLoginInfo($data['gsu_login']); } public function changePasswordAction() @@ -86,15 +87,18 @@ *************/ $form = $this->createForm(); - // Veld current password - $element = new Zend_Form_Element_Password('old_password'); - $element->setLabel($this->_('Current password')); - $element->setAttrib('size', 10); - $element->setAttrib('maxlength', 20); - $element->setRenderPassword(true); - $element->setRequired(true); - $element->addValidator(new Gems_Validate_GemsPasswordUsername($this->session->user_login, 'old_password', $this->db)); - $form->addElement($element); + $sql = "SELECT CASE WHEN gsu_password IS NULL THEN 0 ELSE 1 END FROM gems__users WHERE gsu_id_user = ? AND gsu_id_organization = ?"; + if ($this->db->fetchOne($sql, array($this->session->user_id, $this->session->user_organization_id))) { + // Veld current password + $element = new Zend_Form_Element_Password('old_password'); + $element->setLabel($this->_('Current password')); + $element->setAttrib('size', 10); + $element->setAttrib('maxlength', 20); + $element->setRenderPassword(true); + $element->setRequired(true); + $element->addValidator(new Gems_Validate_GemsPasswordUsername($this->session->user_login, 'old_password', $this->db)); + $form->addElement($element); + } // Veld new password $element = new Zend_Form_Element_Password('new_password'); @@ -127,8 +131,9 @@ ****************/ if ($this->_request->isPost() && $form->isValid($_POST)) { - $data['gsf_id_user'] = $this->session->user_id; - $data['gsf_password'] = $this->escort->passwordHash(null,$_POST['new_password']); + $data['gsu_id_user'] = $this->session->user_id; + $data['gsu_id_organization'] = $this->session->user_organization_id; + $data['gsu_password'] = $this->escort->passwordHash(null, $_POST['new_password']); $this->getModel()->save($data); @@ -180,10 +185,10 @@ */ public function createModel($detailed, $action) { - $model = new MUtil_Model_TableModel('gems__staff'); - $model->canCreate = false; + $model = new Gems_Model_UserModel('staff', 'gems__staff', array('gsu_id_user' => 'gsf_id_user'), 'gsf'); + $model->copyKeys(); - $model->set('gsf_login', 'label', $this->_('Login Name')); + $model->set('gsu_login', 'label', $this->_('Login Name')); $model->set('gsf_email', 'label', $this->_('E-Mail')); $model->set('gsf_first_name', 'label', $this->_('First name')); $model->set('gsf_surname_prefix', 'label', $this->_('Surname prefix'), 'description', 'de, van der, \'t, etc...'); @@ -191,14 +196,12 @@ $model->set('gsf_gender', 'label', $this->_('Gender'), 'multiOptions', $this->util->getTranslated()->getGenders()); - Gems_Model::setChangeFieldsByPrefix($model, 'gsf'); - return $model; } public function editAction() { - $this->getModel()->setFilter(array('gsf_id_user' => $this->session->user_id)); + $this->getModel()->setFilter(array('gsu_id_user' => $this->session->user_id)); if ($form = $this->processForm()) { $this->html->h3(sprintf($this->_('Options'), $this->getTopic())); Modified: branches/newUser/classes/Gems/Default/RespondentAction.php =================================================================== --- branches/newUser/classes/Gems/Default/RespondentAction.php 2011-10-27 13:29:59 UTC (rev 147) +++ branches/newUser/classes/Gems/Default/RespondentAction.php 2011-10-27 15:37:58 UTC (rev 148) @@ -326,8 +326,8 @@ $values = $this->db->fetchPairs(" SELECT gsf_id_user, CONCAT(gsf_last_name, ', ', COALESCE(CONCAT(gsf_first_name, ' '), ''), COALESCE(gsf_surname_prefix, '')) AS name - FROM gems__staff INNER JOIN gems__groups ON gsf_id_primary_group = ggp_id_group - WHERE gsf_active=1 AND gsf_id_organization = ? AND ggp_role = 'physician' + FROM (gems__users INNER JOIN gems__staff ON gsu_id_user = gsf_id_user) INNER JOIN gems__groups ON gsf_id_primary_group = ggp_id_group + WHERE gsu_active=1 AND gsu_id_organization = ? AND ggp_role = 'physician' ORDER BY 2", $organizationId); $session->physicians = $values; Modified: branches/newUser/classes/Gems/Default/StaffAction.php =================================================================== --- branches/newUser/classes/Gems/Default/StaffAction.php 2011-10-27 13:29:59 UTC (rev 147) +++ branches/newUser/classes/Gems/Default/StaffAction.php 2011-10-27 15:37:58 UTC (rev 148) @@ -44,7 +44,7 @@ */ class Gems_Default_StaffAction extends Gems_Controller_BrowseEditAction { - public $filterStandard = array('gsf_active' => 1); + public $filterStandard = array('gsu_active' => 1); public $sortKey = array('name' => SORT_ASC); protected $_instanceId; @@ -96,18 +96,27 @@ if ($new) { $model->set('gsf_id_primary_group', 'default', $dbLookup->getDefaultGroup()); } else { - $model->set('gsf_password', 'description', $this->_('Enter only when changing')); - $model->setSaveWhenNotNull('gsf_password'); + $model->set('gsu_password', 'description', $this->_('Enter only when changing')); + $model->setSaveWhenNotNull('gsu_password'); } - $model->setOnSave('gsf_password', array($this->escort, 'passwordHash')); + $model->setOnSave('gsu_password', array($this->escort, 'passwordHash')); $ucfirst = new Zend_Filter_Callback('ucfirst'); - $bridge->addHidden( 'gsf_id_user'); - $bridge->addText( 'gsf_login', 'size', 15, 'minlength', 4, - 'validator', $model->createUniqueValidator('gsf_login')); + $bridge->addHidden( 'gsu_id_user'); + $bridge->addHidden( 'gsf_id_user'); // Needed for e-mail validation + $bridge->addText( 'gsu_login', 'size', 15, 'minlength', 4, + 'validator', $model->createUniqueValidator('gsu_login')); - $bridge->addPassword('gsf_password', + // Can the organization be changed? + if ($this->escort->hasPrivilege('pr.staff.edit.all')) { + $bridge->addHiddenMulti($model->getKeyCopyName('gsu_id_organization')); + $bridge->addSelect('gsu_id_organization'); + } else { + $bridge->addExhibitor('gsu_id_organization'); + } + + $bridge->addPassword('gsu_password', 'label', $this->_('Password'), 'minlength', $this->project->passwords['MinimumLength'], // 'renderPassword', true, @@ -123,11 +132,6 @@ $bridge->addFilter( 'gsf_last_name', $ucfirst); $bridge->addText( 'gsf_email', array('size' => 30))->addValidator('SimpleEmail')->addValidator($model->createUniqueValidator('gsf_email')); - if ($this->escort->hasPrivilege('pr.staff.edit.all')) { - $bridge->addSelect('gsf_id_organization'); - } else { - $bridge->addExhibitor('gsf_id_organization'); - } $bridge->addSelect('gsf_id_primary_group'); $bridge->addCheckbox('gsf_logout_on_survey', 'description', $this->_('If checked the user will logoff when answering a survey.')); @@ -136,15 +140,15 @@ public function afterFormLoad(array &$data, $isNew) { - if (array_key_exists('gsf_login', $data)) { - $this->_instanceId = $data['gsf_login']; + if (array_key_exists('gsu_login', $data)) { + $this->_instanceId = $data['gsu_login']; } $sql = "SELECT ggp_id_group,ggp_role FROM gems__groups WHERE ggp_id_group = " . (int) $data['gsf_id_primary_group']; $groups = $this->db->fetchPairs($sql); if (! ($this->escort->hasPrivilege('pr.staff.edit.all') || - $data['gsf_id_organization'] == $this->escort->getCurrentOrganization())) { + $data['gsu_id_organization'] == $this->escort->getCurrentOrganization())) { throw new Zend_Exception($this->_('You are not allowed to edit this staff member.')); } } @@ -164,18 +168,21 @@ { // MUtil_Model::$verbose = true; - $model = new MUtil_Model_TableModel('gems__staff'); + $model = new Gems_Model_UserModel('staff', 'gems__staff', array('gsu_id_user' => 'gsf_id_user'), 'gsf'); + if ($detailed) { + $model->copyKeys(); + } //$model->resetOrder(); - $model->set('gsf_login', 'label', $this->_('Login')); + $model->set('gsu_login', 'label', $this->_('Login')); $model->set('name', 'label', $this->_('Name'), 'column_expression', "CONCAT(COALESCE(CONCAT(gsf_last_name, ', '), '-, '), COALESCE(CONCAT(gsf_first_name, ' '), ''), COALESCE(gsf_surname_prefix, ''))"); $model->set('gsf_email', 'label', $this->_('E-Mail'), 'itemDisplay', 'MUtil_Html_AElement::ifmail'); if ($detailed || $this->escort->hasPrivilege('pr.staff.see.all')) { - $this->menu->getParameterSource()->offsetSet('gsf_id_organization', $this->escort->getCurrentOrganization()); + $this->menu->getParameterSource()->offsetSet('gsu_id_organization', $this->escort->getCurrentOrganization()); - $model->set('gsf_id_organization', 'label', $this->_('Organization'), + $model->set('gsu_id_organization', 'label', $this->_('Organization'), 'multiOptions', $this->util->getDbLookup()->getOrganizations(), 'default', $this->escort->getCurrentOrganization()); } @@ -188,10 +195,8 @@ $model->set('gsf_logout_on_survey', 'label', $this->_('Logout on survey'), 'multiOptions', $this->util->getTranslated()->getYesNo()); } - $model->setDeleteValues('gsf_active', 0); + $model->setDeleteValues('gsu_active', 0); - Gems_Model::setChangeFieldsByPrefix($model, 'gsf'); - return $model; } @@ -201,8 +206,8 @@ if ($this->escort->hasPrivilege('pr.staff.see.all')) { // Select organization - $options = array('' => $this->_('(all organizations)')) + $this->getModel()->get('gsf_id_organization', 'multiOptions'); - $select = new Zend_Form_Element_Select('gsf_id_organization', array('multiOptions' => $options)); + $options = array('' => $this->_('(all organizations)')) + $this->getModel()->get('gsu_id_organization', 'multiOptions'); + $select = new Zend_Form_Element_Select('gsu_id_organization', array('multiOptions' => $options)); // Position as second element $search = array_shift($elements); @@ -227,7 +232,7 @@ $filter = parent::getDataFilter($data); if (! $this->escort->hasPrivilege('pr.staff.see.all')) { - $filter['gsf_id_organization'] = $this->escort->getCurrentOrganization(); + $filter['gsu_id_organization'] = $this->escort->getCurrentOrganization(); } return $filter; } @@ -257,8 +262,8 @@ // Model filter has now been set. $data = $this->getModel()->loadFirst(); - $this->_setParam('gsf_id_organization', $data['gsf_id_organization']); - $this->menu->getParameterSource()->offsetSet('gsf_id_organization', $data['gsf_id_organization']); + $this->_setParam('gsu_id_organization', $data['gsu_id_organization']); + $this->menu->getParameterSource()->offsetSet('gsu_id_organization', $data['gsu_id_organization']); } return parent::getShowTable($columns, $filter, $sort); } Modified: branches/newUser/classes/Gems/Default/TokenPlanAction.php =================================================================== --- branches/newUser/classes/Gems/Default/TokenPlanAction.php 2011-10-27 13:29:59 UTC (rev 147) +++ branches/newUser/classes/Gems/Default/TokenPlanAction.php 2011-10-27 15:37:58 UTC (rev 148) @@ -351,9 +351,9 @@ COALESCE(gems__staff.gsf_first_name, ''), COALESCE(CONCAT(' ', gems__staff.gsf_surname_prefix), '') ) AS gsf_name - FROM gems__staff INNER JOIN gems__respondent2track ON gsf_id_user = gr2t_created_by + FROM (gems__users INNER JOIN gems__staff ON gsu_id_user = gsf_id_user) INNER JOIN gems__respondent2track ON gsu_id_user = gr2t_created_by WHERE gr2t_id_organization = $orgId AND - gsf_active = 1 AND + gsu_active = 1 AND gr2t_active = 1"; $elements[] = $this->_createSelectElement('gr2t_created_by', $sql, $this->_('(all staff)')); Modified: branches/newUser/classes/Gems/Menu/MenuAbstract.php =================================================================== --- branches/newUser/classes/Gems/Menu/MenuAbstract.php 2011-10-27 13:29:59 UTC (rev 147) +++ branches/newUser/classes/Gems/Menu/MenuAbstract.php 2011-10-27 15:37:58 UTC (rev 148) @@ -381,13 +381,12 @@ $page = $this->addPage($label, 'pr.staff', 'staff', 'index', $other); $page->addAutofilterAction(); $page->addCreateAction(); - $page->addShowAction(); - if ($this->escort->hasPrivilege('pr.staff.edit.all')) { - $page->addEditAction(); - $page->addDeleteAction(); - } else { - $page->addEditAction()->setParameterFilter('gsf_id_organization', $this->escort->getCurrentOrganization()); - $page->addDeleteAction()->setParameterFilter('gsf_id_organization', $this->escort->getCurrentOrganization()); + $page->addShowAction()->setModelParameters(2); + $editPage = $page->addEditAction()->setModelParameters(2); + $delPage = $page->addDeleteAction()->setModelParameters(2); + if (! $this->escort->hasPrivilege('pr.staff.edit.all')) { + $editPage->setParameterFilter('gsu_id_organization', $this->escort->getCurrentOrganization()); + $delPage->setParameterFilter('gsu_id_organization', $this->escort->getCurrentOrganization()); } return $page; Modified: branches/newUser/classes/Gems/Menu/SubMenuItem.php =================================================================== --- branches/newUser/classes/Gems/Menu/SubMenuItem.php 2011-10-27 13:29:59 UTC (rev 147) +++ branches/newUser/classes/Gems/Menu/SubMenuItem.php 2011-10-27 15:37:58 UTC (rev 148) @@ -417,7 +417,7 @@ } $menu = $this->addAction($label, $privilege, 'delete', $other); - $menu->addParameters(MUtil_Model::REQUEST_ID); + $menu->setModelParameters(1); return $menu; } @@ -436,7 +436,7 @@ } $menu = $this->addAction($label, $privilege, 'edit', $other); - $menu->addParameters(MUtil_Model::REQUEST_ID); + $menu->setModelParameters(1); return $menu; } @@ -475,6 +475,17 @@ return $this; } + /** + * Add required parameters - shown in the url - for this + * menu item. + * + * Numeric array keys are changed into the same string as the + * array value. + * + * @param mixed $arrayOrKey1 MUtil_Ra::pairs named array + * @param mixed $key2 + * @return Gems_Menu_SubMenuItem (continuation pattern) + */ public function addNamedParameters($arrayOrKey1 = null, $altName1 = null) { $params = MUtil_Ra::pairs(func_get_args()); @@ -483,16 +494,8 @@ $this->_parameters = new MUtil_Lazy_ArrayWrap(); } foreach ($params as $param => $name) { - if (! $name) { - if (is_int($param)) { - throw new Zend_Exception('Invalid integer required parameter key with empty name.'); - } else { - $name = $param; - } - } else { - if (is_int($param)) { - $param = $name; - } + if (is_int($param)) { + $param = $name; } $this->_requiredParameters[$param] = $name; $this->_parameters[$param] = MUtil_Lazy::L($name); @@ -546,7 +549,7 @@ } $menu = $this->addAction($label, $privilege, 'show', $other); - $menu->addParameters(MUtil_Model::REQUEST_ID); + $menu->setModelParameters(1); return $menu; } @@ -755,6 +758,41 @@ return $this; } + /** + * Defines the number of named parameters using the model naming + * convention: id=x or id1=x id2=y + * + * @see setNamedParamenters() + * + * @param int $idCount The number of parameters to define + * @return Gems_Menu_SubMenuItem (continuation pattern) + */ + public function setModelParameters($idCount) + { + $params = array(); + if (1 == $idCount) { + $params[MUtil_Model::REQUEST_ID] = MUtil_Model::REQUEST_ID; + } else { + for ($i = 1; $i <= $idCount; $i++) { + $params[MUtil_Model::REQUEST_ID . $i] = MUtil_Model::REQUEST_ID . $i; + } + } + $this->setNamedParameters($params); + + return $this; + } + + /** + * Set the required parameters - shown in the url - for this + * menu item. + * + * Numeric array keys are changed into the same string as the + * array value. + * + * @param mixed $arrayOrKey1 MUtil_Ra::pairs named array + * @param mixed $key2 + * @return Gems_Menu_SubMenuItem (continuation pattern) + */ public function setNamedParameters($arrayOrKey1 = null, $key2 = null) { $params = MUtil_Ra::pairs(func_get_args()); Modified: branches/newUser/classes/Gems/Model/UserModel.php =================================================================== --- branches/newUser/classes/Gems/Model/UserModel.php 2011-10-27 13:29:59 UTC (rev 147) +++ branches/newUser/classes/Gems/Model/UserModel.php 2011-10-27 15:37:58 UTC (rev 148) @@ -82,6 +82,8 @@ */ protected function _createUserId() { + $db = $this->getAdapter(); + $max = $this->userIdLen; do { @@ -92,7 +94,7 @@ // Make it a number $out = intval($out); - } while ($this->db->fetchOne('SELECT gsu_id_user FROM gems__users WHERE gsu_id_user = ?', $out)); + } while ($db->fetchOne('SELECT gsu_id_user FROM gems__users WHERE gsu_id_user = ?', $out)); return $out; } @@ -112,6 +114,6 @@ $newValues['gsu_id_user'] = $this->_createUserId(); } - parent::save($newValues, $filter, $saveTables); + return parent::save($newValues, $filter, $saveTables); } } Modified: branches/newUser/classes/Gems/User/RespondentUser.php =================================================================== --- branches/newUser/classes/Gems/User/RespondentUser.php 2011-10-27 13:29:59 UTC (rev 147) +++ branches/newUser/classes/Gems/User/RespondentUser.php 2011-10-27 15:37:58 UTC (rev 148) @@ -38,6 +38,18 @@ /** * * +-- PATCH: New user login structure +INSERT INTO gems__users (gsu_id_user, gsu_login, gsu_id_organization, gsu_user_class, gsu_active, + gsu_password, gsu_failed_logins, gsu_last_failed, gsu_reset_key, gsu_reset_requested, gsu_reset_required, + gsu_changed, gsu_changed_by, gsu_created, gsu_created_by) + SELECT grs_id_user, gr2o_patient_nr, gr2o_id_organization, 'RespondentUser', CASE WHEN gr2o_reception_code = 'OK' THEN 1 ELSE 0 END, + NULL, 0, NULL, NULL, NULL, 0, + gr2o_changed, gr2o_changed_by, gr2o_created, gr2o_created_by + FROM gems__respondents INNER JOIN gems__respondent2org ON grs_id_user = gr2o_id_user + INNER JOIN gems__organizations ON gr2o_id_organization = gor_id_organization + WHERE gor_name = 'HCU / Xpert Clinic'; + + * * @package Gems * @subpackage User * @copyright Copyright (c) 2011 Erasmus MC Modified: branches/newUser/classes/Gems/User/StaffUser.php =================================================================== --- branches/newUser/classes/Gems/User/StaffUser.php 2011-10-27 13:29:59 UTC (rev 147) +++ branches/newUser/classes/Gems/User/StaffUser.php 2011-10-27 15:37:58 UTC (rev 148) @@ -57,11 +57,11 @@ $select->from('gems__users') ->join('gems__staff', 'gsu_login = gsf_id_user') ->join('gems__groups', 'gsf_id_primary_group = ggp_id_group') - ->join('gems__organizations', 'gsf_id_organization = gor_id_organization') + ->join('gems__organizations', 'gsu_id_organization = gor_id_organization') ->where('ggp_group_active = 1') ->where('gor_active = 1') - ->where('gsf_active = 1') - ->where('gsf_login = ?', $this->getLoginName()) + ->where('gsu_active = 1') + ->where('gsu_login = ?', $this->getLoginName()) ->limit(1); return $select; Modified: branches/newUser/classes/Gems/Util/DbLookup.php =================================================================== --- branches/newUser/classes/Gems/Util/DbLookup.php 2011-10-27 13:29:59 UTC (rev 147) +++ branches/newUser/classes/Gems/Util/DbLookup.php 2011-10-27 15:37:58 UTC (rev 148) @@ -105,7 +105,7 @@ if (! $data) { $data = $this->db->fetchPairs("SELECT gsf_id_user, CONCAT(COALESCE(gsf_last_name, '-'), ', ', COALESCE(gsf_first_name, ''), COALESCE(CONCAT(' ', gsf_surname_prefix), '')) - FROM gems__staff WHERE gsf_active = 1 ORDER BY gsf_last_name, gsf_first_name, gsf_surname_prefix"); + FROM gems__users INNER JOIN gems__staff ON gsu_id_user = gsf_id_user WHERE gsu_active = 1 ORDER BY gsf_last_name, gsf_first_name, gsf_surname_prefix"); } return $data; Modified: branches/newUser/classes/Gems/Validate/GemsPasswordUsername.php =================================================================== --- branches/newUser/classes/Gems/Validate/GemsPasswordUsername.php 2011-10-27 13:29:59 UTC (rev 147) +++ branches/newUser/classes/Gems/Validate/GemsPasswordUsername.php 2011-10-27 15:37:58 UTC (rev 148) @@ -86,7 +86,7 @@ */ public function __construct($usernameField, $passwordField, Zend_Db_Adapter_Abstract $adapter = null, $delayFactor = null) { - parent::__construct('gems__staff', 'gsf_login', null, $adapter); + parent::__construct('gems__users', 'gsu_login', null, $adapter); $this->_usernameField = $usernameField; $this->_passwordField = $passwordField; @@ -137,7 +137,7 @@ } } - $condition = $this->_adapter->quoteIdentifier('gsf_password') . ' = ?'; + $condition = $this->_adapter->quoteIdentifier('gsu_password') . ' = ?'; $this->_exclude = $this->_adapter->quoteInto($condition, md5($password)); try { @@ -145,8 +145,8 @@ * Lookup last failed login and number of failed logins */ try { - $sql = "SELECT gsf_failed_logins, UNIX_TIMESTAMP(gsf_last_failed) - AS gsf_last_failed FROM {$this->_table} WHERE gsf_login = ?"; + $sql = "SELECT gsu_failed_logins, UNIX_TIMESTAMP(gsu_last_failed) + AS gsu_last_failed FROM {$this->_table} WHERE gsu_login = ?"; $results = $this->_adapter->fetchRow($sql, array($username)); } catch (Zend_Db_Exception $zde) { //If we need to apply a db patch, just use a default value @@ -154,10 +154,10 @@ MUtil_Echo::r(GemsEscort::getInstance()->translate->_('Please update the database')); } - $delay = pow($results['gsf_failed_logins'], $this->_delayFactor); - $remaining = ($results['gsf_last_failed'] + $delay) - time(); + $delay = pow($results['gsu_failed_logins'], $this->_delayFactor); + $remaining = ($results['gsu_last_failed'] + $delay) - time(); - if ($results['gsf_failed_logins'] > 0 && $remaining > 0) { + if ($results['gsu_failed_logins'] > 0 && $remaining > 0) { $this->_obscureValue = false; $this->_error(self::ERROR_PASSWORD_DELAY, ceil($remaining / 60)); return false; Modified: branches/newUser/classes/GemsEscort.php =================================================================== --- branches/newUser/classes/GemsEscort.php 2011-10-27 13:29:59 UTC (rev 147) +++ branches/newUser/classes/GemsEscort.php 2011-10-27 15:37:58 UTC (rev 148) @@ -927,7 +927,7 @@ * Reset number of failed logins */ try { - $sql = "UPDATE gems__staff SET gsf_failed_logins = 0, gsf_last_failed = NULL WHERE gsf_login = ?"; + $sql = "UPDATE gems__users SET gsu_failed_logins = 0, gsu_last_failed = NULL WHERE gsu_login = ?"; $this->db->query($sql, array($_POST['userlogin'])); } catch (Exception $e) { // swallow exception @@ -941,7 +941,7 @@ */ try { if (isset($_POST['userlogin'])) { - $sql = "UPDATE gems__staff SET gsf_failed_logins = gsf_failed_logins + 1, gsf_last_failed = NOW() WHERE gsf_login = ?"; + $sql = "UPDATE gems__users SET gsu_failed_logins = gsu_failed_logins + 1, gsu_last_failed = NOW() WHERE gsu_login = ?"; $this->db->query($sql, array($_POST['userlogin'])); } } catch (Exception $e) { @@ -1097,12 +1097,7 @@ //If user is current user, read from session $allowedOrganizations = $this->session->allowedOrgs; } else { - //Here we read all allowed orgs for the user - $model = new MUtil_Model_TableModel('gems__organizations'); - $data = $model->load(); - foreach ($data as $org) { - $allowedOrganizations[$org['gor_id_organization']] = $org['gor_name']; - } + $allowedOrganizations = $this->db->fetchPairs("SELECT gor_id_organization, gor_name FROM gems__organizations WHERE gor_active = 1 ORDER BY gor_name"); } return $allowedOrganizations; @@ -1309,22 +1304,24 @@ * compatibility */ $select = new Zend_Db_Select($this->db); - $select->from('gems__staff', array('user_id'=>'gsf_id_user', - 'user_login'=>'gsf_login', - //don't expose the password hash - //'user_password'=>'gsf_password', - 'user_email'=>'gsf_email', - 'user_group'=>'gsf_id_primary_group', - 'user_locale'=>'gsf_iso_lang', - 'user_logout'=>'gsf_logout_on_survey')) + $select->from('gems__users', array('user_id' => 'gsu_id_user', + 'user_login' => 'gsu_login', + //don't expose the password hash + //'user_password'=>'gsu_password', + )) + ->join('gems__staff', 'gsu_id_user = gsf_id_user', array( + 'user_email'=>'gsf_email', + 'user_group'=>'gsf_id_primary_group', + 'user_locale'=>'gsf_iso_lang', + 'user_logout'=>'gsf_logout_on_survey')) ->columns(array('user_name'=>"(concat(coalesce(concat(`gems__staff`.`gsf_first_name`,_utf8' '),_utf8''),coalesce(concat(`gems__staff`.`gsf_surname_prefix`,_utf8' '),_utf8''),coalesce(`gems__staff`.`gsf_last_name`,_utf8'')))")) ->join('gems__groups', 'gsf_id_primary_group = ggp_id_group', array('user_role'=>'ggp_role')) - ->join('gems__organizations', 'gsf_id_organization = gor_id_organization', + ->join('gems__organizations', 'gsu_id_organization = gor_id_organization', array('user_organization_id'=>'gor_id_organization', 'user_organization_name'=>'gor_name')) ->where('ggp_group_active = ?', 1) ->where('gor_active = ?', 1) - ->where('gsf_active = ?', 1) - ->where('gsf_login = ?', $userName) + ->where('gsu_active = ?', 1) + ->where('gsu_login = ?', $userName) ->limit(1); //For a multi-layout project we need to select the appropriate style too @@ -1348,7 +1345,11 @@ public function passwordHash($name, $value, $new) { - return md5($value, false); + if (isset($this->project->salt)) { + return md5($this->project->salt . $value, false); + } else { + return md5($value, false); + } } /** Modified: branches/newUser/classes/MUtil/Model/DatabaseModelAbstract.php =================================================================== --- branches/newUser/classes/MUtil/Model/DatabaseModelAbstract.php 2011-10-27 13:29:59 UTC (rev 147) +++ branches/newUser/classes/MUtil/Model/DatabaseModelAbstract.php 2011-10-27 15:37:58 UTC (rev 148) @@ -60,6 +60,11 @@ // If there exists a table containing two fields that map to these, shoot the table designer!!! /** + * @var array When specified delete() updates the selected rows with these values, instead of physically deleting the rows. + */ + protected $_deleteValues; + + /** * Child classes may technically be able or not able to add extra rows, * but the data model or specific circumstances may require a specific * instance of that class to deviate from the default. @@ -501,6 +506,21 @@ return $this; } + /** + * Adding DeleteValues means delete() updates the selected rows with these values, instead of physically deleting the rows. + * + * @param string|array $arrayOrField1 MUtil_Ra::pairs() arguments + * @param mxied $value1 + * @param string $field2 + * @param mixed $key2 + * @return MUtil_Model_TableModel + */ + public function addDeleteValues($arrayOrField1 = null, $value1 = null, $field2 = null, $key2 = null) + { + $args = MUtil_Ra::pairs(func_get_args()); + $this->_deleteValues = $args + $this->_deleteValues; + return $this; + } /** * Makes a copy for each key item in the model using $this->getKeyCopyName() @@ -521,7 +541,6 @@ return $this; } - /** * Creates a validator that checks that this value is used in no other * row in the table of the $name field, except that row itself. @@ -600,11 +619,12 @@ return $this->canCreate; } - public function getKeyCopier() - { - return $this->keyCopier; - } - + /** + * Returns the key copy name for a field. + * + * @param string $name + * @return string + */ public function getKeyCopyName($name) { return sprintf($this->keyCopier, $name); @@ -722,6 +742,22 @@ return $this; } + /** + * Setting DeleteValues means delete() updates the selected rows with these values, instead of physically deleting the rows. + * + * @param string|array $arrayOrField1 MUtil_Ra::pairs() arguments + * @param mxied $value1 + * @param string $field2 + * @param mixed $key2 + * @return MUtil_Model_TableModel + */ + public function setDeleteValues($arrayOrField1 = null, $value1 = null, $field2 = null, $key2 = null) + { + $args = MUtil_Ra::pairs(func_get_args()); + $this->_deleteValues = $args; + return $this; + } + public function setKeysToTable($keysOrTableName) { if (is_string($keysOrTableName)) { Modified: branches/newUser/classes/MUtil/Model/JoinModel.php =================================================================== --- branches/newUser/classes/MUtil/Model/JoinModel.php 2011-10-27 13:29:59 UTC (rev 147) +++ branches/newUser/classes/MUtil/Model/JoinModel.php 2011-10-27 15:37:58 UTC (rev 148) @@ -174,39 +174,44 @@ } $filter = $this->_checkFilterUsed($filter); - $changed = 0; - foreach ($saveTables as $table_name) { - $table_filter = array(); - $delete = true; + if ($this->_deleteValues) { + MUtil_Echo::track($filter); + $changed = $this->save($this->_deleteValues, $filter, $saveTables); + } else { + $changed = 0; + foreach ($saveTables as $table_name) { + $table_filter = array(); + $delete = true; - // Find per table key filters - foreach ($this->_getKeysFor($table_name) as $key) { - if (isset($filter[$key])) { - $table_filter[$key] = $filter[$key]; - } else { - // If key values are missing, do not delete. - $delete = false; - foreach ($this->_joinFields as $source => $target) { - $found = null; + // Find per table key filters + foreach ($this->_getKeysFor($table_name) as $key) { + if (isset($filter[$key])) { + $table_filter[$key] = $filter[$key]; + } else { + // If key values are missing, do not delete. + $delete = false; + foreach ($this->_joinFields as $source => $target) { + $found = null; - if ($source === $key) { - $found = $target; - } elseif ($target == $key) { - $found = $source; + if ($source === $key) { + $found = $target; + } elseif ($target == $key) { + $found = $source; + } + if ($found && isset($filter[$found])) { + /// Found after all. + $delete = true; + $table_filter[$key] = $filter[$found]; + break; + } } - if ($found && isset($filter[$found])) { - /// Found after all. - $delete = true; - $table_filter[$key] = $filter[$found]; - break; - } } } - } - // MUtil_Echo::r($table_filter, $table_name); - if ($delete && $table_filter) { - $changed = max($changed, $this->_deleteTableData($this->_tables[$table_name], $table_filter)); + // MUtil_Echo::r($table_filter, $table_name); + if ($delete && $table_filter) { + $changed = max($changed, $this->_deleteTableData($this->_tables[$table_name], $table_filter)); + } } } @@ -239,6 +244,8 @@ * @param array $newValues The values to store for a single model item. * @param array $filter If the filter contains old key values these are used * to decide on update versus insert. + * @param array $saveTables Optional array containing the table names to save, + * otherwise the tables set to save at model level will be saved. * @return array The values as they are after saving (they may change). */ public function save(array $newValues, array $filter = null, array $saveTables = null) Modified: branches/newUser/classes/MUtil/Model/ModelAbstract.php =================================================================== --- branches/newUser/classes/MUtil/Model/ModelAbstract.php 2011-10-27 13:29:59 UTC (rev 147) +++ branches/newUser/classes/MUtil/Model/ModelAbstract.php 2011-10-27 15:37:58 UTC (rev 148) @@ -543,13 +543,22 @@ return $href; } + /** + * Returns an array containing the currently defined keys for this + * model. + * + * When no keys are defined, the keys are derived from the model. + * + * @param boolean $reset If true, derives the key from the model. + * @return array + */ public function getKeys($reset = false) { if ((! $this->_keys) || $reset) { $keys = array(); foreach ($this->_model as $name => $info) { if (isset($info['key']) && $info['key']) { - $keys[$name] = $name; + $keys[] = $name; } } $this->setKeys($keys); @@ -1025,12 +1034,29 @@ return false; } + /** + * Sets the keys, processing the array key. + * + * When an array key is numeric MUtil_Model::REQUEST_ID is used. + * When there is more than one key a increasing number is added to + * MUtil_Model::REQUEST_ID starting with 1. + * + * String key names ar eleft as is. + * + * @param array $keys + * @return MUtil_Model_ModelAbstract (continuation pattern) + */ public function setKeys(array $keys) { $this->_keys = array(); if (count($keys) == 1) { - $this->_keys[MUtil_Model::REQUEST_ID] = reset($keys); + $name = reset($keys); + if (is_numeric(key($keys))) { + $this->_keys[MUtil_Model::REQUEST_ID] = $name; + } else { + $this->_keys[key($keys)] = $name; + } } else { $i = 1; foreach ($keys as $idx => $name) { @@ -1081,15 +1107,6 @@ return $this; } - /* appears to be not implemented or at least not functionale so removing - public function setOnLoad($name, $callableOrConstant) - - { - $this->set($name, self::SAVE_TRANSFORMER, $callableOrConstant); - return $this; - } - */ - public function setOnSave($name, $callableOrConstant) { $this->set($name, self::SAVE_TRANSFORMER, $callableOrConstant); Modified: branches/newUser/classes/MUtil/Model/TableBridgeAbstract.php =================================================================== --- branches/newUser/classes/MUtil/Model/TableBridgeAbstract.php 2011-10-27 13:29:59 UTC (rev 147) +++ branches/newUser/classes/MUtil/Model/TableBridgeAbstract.php 2011-10-27 15:37:58 UTC (rev 148) @@ -1,33 +1,33 @@ <?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 @@ -39,7 +39,7 @@ protected $model; protected $modelKeys; protected $repeater; - + /** * The actual table * @@ -231,9 +231,9 @@ /** * Set the model to use in the tablebridge - * + * * @param MUtil_Model_ModelAbstract $model - * @return MUtil_Model_TableBridgeAbstract + * @return MUtil_Model_TableBridgeAbstract */ public function setModel(MUtil_Model_ModelAbstract $model) { Modified: branches/newUser/classes/MUtil/Model/TableModel.php =================================================================== --- branches/newUser/classes/MUtil/Model/TableModel.php 2011-10-27 13:29:59 UTC (rev 147) +++ branches/newUser/classes/MUtil/Model/TableModel.php 2011-10-27 15:37:58 UTC (rev 148) @@ -47,11 +47,6 @@ class MUtil_Model_TableModel extends MUtil_Model_DatabaseModelAbstract { /** - * @var array When specified delete() updates the selected rows with these values, instead of physically deleting the rows. - */ - protected $_deleteValues; - - /** * * @var Zend_Db_Table_Abstract */ @@ -73,22 +68,6 @@ } /** - * Adding DeleteValues means delete() updates the selected rows with these values, instead of physically deleting the rows. - * - * @param string|array $arrayOrField1 MUtil_Ra::pairs() arguments - * @param mxied $value1 - * @param string $field2 - * @param mixed $key2 - * @return MUtil_Model_TableModel - */ - public function addDeleteValues($arrayOrField1 = null, $value1 = null, $field2 = null, $key2 = null) - { - $args = MUtil_Ra::pairs(func_get_args()); - $this->_deleteValues = $args + $this->_deleteValues; - return $this; - } - - /** * Delete items from the model * * @param mixed $filter True to use the stored filter, array to specify a different filter @@ -113,16 +92,6 @@ } /** - * Returns the DeleteValues used to update selected rows on delete. - * - * @return array|null - */ - public function getDeleteValues() - { - return $this->_deleteValues; - } - - /** * Returns a Zend_Db_Table_Select object to work with * * @return Zend_Db_Table_Select @@ -138,26 +107,18 @@ } } + /** + * Save a single model item. + * + * @param array $newValues The values to store for a single model item. + * @param array $filter If the filter contains old key values these are used + * to decide on update versus insert. + * @return array The values as they are after saving (they may change). + */ public function save(array $newValues, array $filter = null) { // $this->_saveTableData returns the new row values, including any automatic changes. // add $newValues to throw nothing away. return $this->_saveTableData($this->_table, $newValues, $filter) + $newValues; } - - /** - * Setting DeleteValues means delete() updates the selected rows with these values, instead of physically deleting the rows. - * - * @param string|array $arrayOrField1 MUtil_Ra::pairs() arguments - * @param mxied $value1 - * @param string $field2 - * @param mixed $key2 - * @return MUtil_Model_TableModel - */ - public function setDeleteValues($arrayOrField1 = null, $value1 = null, $field2 = null, $key2 = null) - { - $args = MUtil_Ra::pairs(func_get_args()); - $this->_deleteValues = $args; - return $this; - } } Modified: branches/newUser/configs/db/patches.sql =================================================================== --- branches/newUser/configs/db/patches.sql 2011-10-27 13:29:59 UTC (rev 147) +++ branches/newUser/configs/db/patches.sql 2011-10-27 15:37:58 UTC (rev 148) @@ -221,9 +221,9 @@ INSERT INTO gems__users (gsu_id_user, gsu_login, gsu_id_organization, gsu_user_class, gsu_active, gsu_password, gsu_failed_logins, gsu_last_failed, gsu_reset_key, gsu_reset_requested, gsu_reset_required, gsu_changed, gsu_changed_by, gsu_created, gsu_created_by) - SELECT grs_id_user, gr2o_patient_nr, gr2o_id_organization, 'RespondentUser', CASE WHEN gr2o_reception_code = 'OK' THEN 1 ELSE 0 END, - NULL, 0, NULL, NULL, NULL, 0, - gr2o_changed, gr2o_changed_by, gr2o_created, gr2o_created_by - FROM gems__respondents INNER JOIN gems__respondent2org ON grs_id_user = gr2o_id_user - INNER JOIN gems__organizations ON gr2o_id_organization = gor_id_organization - WHERE gor_name = 'HCU / Xpert Clinic'; + SELECT gsf_id_user, gsf_login, gsf_id_organization, 'StaffUser', gsf_active, + NULL, gsf_failed_logins, gsf_last_failed, gsf_reset_key, 0, 1, + gsf_changed, gsf_changed_by, gsf_created, gsf_created_by + FROM gems__staff; + +ALTER TABLE `gems__staff` CHANGE `gsf_id_user` `gsf_id_user` BIGINT( 20 ) UNSIGNED NOT NULL; Modified: branches/newUser/configs/db/tables/gems__staff.20.sql =================================================================== --- branches/newUser/configs/db/tables/gems__staff.20.sql 2011-10-27 13:29:59 UTC (rev 147) +++ branches/newUser/configs/db/tables/gems__staff.20.sql 2011-10-27 15:37:58 UTC (rev 148) @@ -2,20 +2,23 @@ -- Table containing the project staff -- CREATE TABLE if not exists gems__staff ( - gsf_id_user bigint unsigned not null auto_increment, + gsf_id_user bigint unsigned not null references gems__users (gsu_id_user), + -- depreciated gsf_login varchar(20) CHARACTER SET 'utf8' COLLATE 'utf8_general_ci' not null unique key, gsf_password varchar(32) CHARACTER SET 'utf8' COLLATE 'utf8_general_ci' not null, - gsf_active boolean not null default 1, gsf_failed_logins int(11) unsigned not null default 0, gsf_last_failed timestamp null, + gsf_id_organization bigint not null + references gems__organizations (gor_id_organization), + -- end depreciated + + gsf_id_primary_group bigint unsigned references gems__groups (ggp_id_group), - gsf_id_organization bigint not null - references gems__organizations (gor_id_organization), gsf_iso_lang char(2) CHARACTER SET 'utf8' COLLATE 'utf8_general_ci' not null default 'nl' references gems__languages (gml_iso_lang), gsf_logout_on_survey boolean not null default 0, Modified: branches/newUser/configs/db/tables/gems__users.10.sql =================================================================== --- branches/newUser/configs/db/tables/gems__users.10.sql 2011-10-27 13:29:59 UTC (rev 147) +++ branches/newUser/configs/db/tables/gems__users.10.sql 2011-10-27 15:37:58 UTC (rev 148) @@ -3,9 +3,9 @@ -- CREATE TABLE if not exists gems__users ( gsu_id_user bigint unsigned not null, + gsu_id_organization bigint not null references gems__organizations (gor_id_organization), gsu_login varchar(30) CHARACTER SET 'utf8' COLLATE 'utf8_general_ci' not null, - gsu_id_o... [truncated message content] |
From: <gem...@li...> - 2011-10-27 13:30:08
|
Revision: 147 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=147&view=rev Author: mennodekker Date: 2011-10-27 13:29:59 +0000 (Thu, 27 Oct 2011) Log Message: ----------- Added caching to LS fieldmap Modified Paths: -------------- trunk/library/classes/Gems/Tracker/Source/LimeSurvey1m9FieldMap.php Modified: trunk/library/classes/Gems/Tracker/Source/LimeSurvey1m9FieldMap.php =================================================================== --- trunk/library/classes/Gems/Tracker/Source/LimeSurvey1m9FieldMap.php 2011-10-27 09:03:59 UTC (rev 146) +++ trunk/library/classes/Gems/Tracker/Source/LimeSurvey1m9FieldMap.php 2011-10-27 13:29:59 UTC (rev 147) @@ -59,6 +59,11 @@ protected $_titlesMap; /** + * @var Zend_Cache_Core + */ + protected $cache; + + /** * The language of this fieldmap * * @var string @@ -108,6 +113,7 @@ $this->lsDb = $lsDb; $this->translate = $translate; $this->tablePrefix = $tablePrefix; + $this->cache = GemsEscort::getInstance()->cache; //Load the cache from escort } /** @@ -198,7 +204,9 @@ protected function _getMap() { - if (! $this->_fieldMap) { + $cacheId = 'lsFieldMap'.$this->sourceSurveyId.$this->language; + + if( ($this->_fieldMap = $this->cache->load($cacheId)) === false ) { $gTable = $this->_getGroupsTableName(); $qTable = $this->_getQuestionsTableName(); @@ -333,9 +341,10 @@ } } $this->_fieldMap = $map; - // MUtil_Echo::track($this->_fieldMap); + $this->cache->save($this->_fieldMap, $cacheId); } + return $this->_fieldMap; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2011-10-27 09:04:05
|
Revision: 146 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=146&view=rev Author: matijsdejong Date: 2011-10-27 09:03:59 +0000 (Thu, 27 Oct 2011) Log Message: ----------- Merged changes 142-144 Modified Paths: -------------- branches/newUser/classes/Gems/Default/ConsentAction.php branches/newUser/classes/Gems/Default/ProjectInformationAction.php branches/newUser/classes/Gems/Default/ReceptionAction.php branches/newUser/classes/Gems/Default/RoleAction.php branches/newUser/classes/Gems/Menu/MenuAbstract.php branches/newUser/classes/Gems/Roles.php branches/newUser/classes/GemsEscort.php Property Changed: ---------------- branches/newUser/ Property changes on: branches/newUser ___________________________________________________________________ Modified: svn:mergeinfo - /trunk/library:114-122,125-139 + /trunk/library:114-122,125-139,142-144 Modified: branches/newUser/classes/Gems/Default/ConsentAction.php =================================================================== --- branches/newUser/classes/Gems/Default/ConsentAction.php 2011-10-26 17:18:45 UTC (rev 145) +++ branches/newUser/classes/Gems/Default/ConsentAction.php 2011-10-27 09:03:59 UTC (rev 146) @@ -1,35 +1,35 @@ <?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 @@ -38,22 +38,24 @@ */ /** - * + * * @author Matijs de Jong * @package Gems * @subpackage Default */ class Gems_Default_ConsentAction extends Gems_Controller_BrowseEditAction { + public $menuIndexIncludeLevel = 1; + public $sortKey = array('gco_order' => SORT_ASC); - /** - * 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 - * parameter was added, because the most common use of action is a split between detailed + /** + * 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 + * parameter was added, because the most common use of action is a split between detailed * and summarized actions. - * + * * @param boolean $detailed True when the current action is not in $summarizedActions. * @param string $action The current action. * @return MUtil_Model_ModelAbstract Modified: branches/newUser/classes/Gems/Default/ProjectInformationAction.php =================================================================== --- branches/newUser/classes/Gems/Default/ProjectInformationAction.php 2011-10-26 17:18:45 UTC (rev 145) +++ branches/newUser/classes/Gems/Default/ProjectInformationAction.php 2011-10-27 09:03:59 UTC (rev 146) @@ -153,7 +153,8 @@ $request = $this->getRequest(); $buttonList = $this->menu->getMenuList(); $buttonList->addParameterSources($request) - ->addByController($request->getControllerName(), 'maintenance', $label); + ->addByController($request->getControllerName(), 'maintenance', $label) + ->addByController($request->getControllerName(), 'cacheclean'); // $this->html->buttonDiv($buttonList); @@ -180,6 +181,15 @@ $this->_reroute(array($request->getActionKey() => 'index')); } + public function cachecleanAction() + { + $this->escort->cache->clean(); + $this->addMessage($this->_('Cache cleaned')); + // Redirect + $request = $this->getRequest(); + $this->_reroute(array($request->getActionKey() => 'index')); + } + public function phpAction() { $this->html->h2($this->_('Server PHP Info')); Modified: branches/newUser/classes/Gems/Default/ReceptionAction.php =================================================================== --- branches/newUser/classes/Gems/Default/ReceptionAction.php 2011-10-26 17:18:45 UTC (rev 145) +++ branches/newUser/classes/Gems/Default/ReceptionAction.php 2011-10-27 09:03:59 UTC (rev 146) @@ -46,6 +46,8 @@ */ class Gems_Default_ReceptionAction extends Gems_Controller_BrowseEditAction { + public $menuIndexIncludeLevel = 1; + public $sortKey = array('grc_id_reception_code' => SORT_ASC); public function addFormElements(MUtil_Model_FormBridge $bridge, MUtil_Model_ModelAbstract $model, array $data, $new = false) Modified: branches/newUser/classes/Gems/Default/RoleAction.php =================================================================== --- branches/newUser/classes/Gems/Default/RoleAction.php 2011-10-26 17:18:45 UTC (rev 145) +++ branches/newUser/classes/Gems/Default/RoleAction.php 2011-10-27 09:03:59 UTC (rev 146) @@ -46,6 +46,11 @@ */ class Gems_Default_RoleAction extends Gems_Controller_BrowseEditAction { + /** + * @var GemsEscort + */ + public $escort; + protected function _showTable($caption, $data, $nested = false) { $table = MUtil_Html_TableElement::createArray($data, $caption, $nested); @@ -107,6 +112,21 @@ } /** + * As the ACL might have to be updated, rebuild the acl + * + * @param array $data + * @param type $isNew + * @return type + */ + public function afterSave(array $data, $isNew) + { + $roles = $this->loader->getRoles($this->escort); + $roles->build(); + + return true; + } + + /** * Check the disabled (=inherited) privileges * * @param Gems_Form $form Modified: branches/newUser/classes/Gems/Menu/MenuAbstract.php =================================================================== --- branches/newUser/classes/Gems/Menu/MenuAbstract.php 2011-10-26 17:18:45 UTC (rev 145) +++ branches/newUser/classes/Gems/Menu/MenuAbstract.php 2011-10-27 09:03:59 UTC (rev 146) @@ -316,6 +316,7 @@ $page->addAction($this->_('Project'), null, 'project'); $page->addAction($this->_('Session'), null, 'session'); $page->addButtonOnly($this->_('Maintenance mode'), 'pr.maintenance', 'project-information', 'maintenance'); + $page->addButtonOnly($this->_('Clean cache'), 'pr.maintenance', 'project-information', 'cacheclean'); return $page; } Modified: branches/newUser/classes/Gems/Roles.php =================================================================== --- branches/newUser/classes/Gems/Roles.php 2011-10-26 17:18:45 UTC (rev 145) +++ branches/newUser/classes/Gems/Roles.php 2011-10-27 09:03:59 UTC (rev 146) @@ -241,13 +241,16 @@ private function save() { if ($this->_cache instanceof Zend_Cache_Core) { if (!$this->_cache->save($this->_acl, $this->_cacheid, array(), null)) - echo "MISLUKT!"; + throw new Gems_Exception('Failed to save acl to cache'); } } public function setCache($cache) { - if ($cache instanceof Zend_Cache_Core) + if ($cache instanceof Zend_Cache_Core) { $this->_cache = $cache; - } + } elseif ($cache instanceof GemsEscort) { + $this->_cache = $cache->cache; + } + } } \ No newline at end of file Modified: branches/newUser/classes/GemsEscort.php =================================================================== --- branches/newUser/classes/GemsEscort.php 2011-10-26 17:18:45 UTC (rev 145) +++ branches/newUser/classes/GemsEscort.php 2011-10-27 09:03:59 UTC (rev 146) @@ -138,6 +138,36 @@ } /** + * Create a default file cache for the Translate and DB adapters to speed up execution + * + * @return Zend_Cache_Core + */ + protected function _initCache() + { + $exists = false; + $cacheDir = GEMS_ROOT_DIR . "/var/cache/"; + if (!file_exists($cacheDir)) { + if (mkdir($cacheDir, 0777, true)) { + $exists = true; + } + } else { + $exists = true; + } + + if ($exists) { + $cacheFrontendOptions = array('automatic_serialization' => true); + $cacheBackendOptions = array('cache_dir' => $cacheDir); + + $cache = Zend_Cache::factory('Core', 'File', $cacheFrontendOptions, $cacheBackendOptions); + + Zend_Db_Table_Abstract::setDefaultMetadataCache($cache); + Zend_Translate::setCache($cache); + } + + return $cache; + } + + /** * Initialize the logger * * @return Gems_Log This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2011-10-26 17:18:52
|
Revision: 145 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=145&view=rev Author: matijsdejong Date: 2011-10-26 17:18:45 +0000 (Wed, 26 Oct 2011) Log Message: ----------- Further with respondent login #31 Modified Paths: -------------- branches/newUser/classes/Gems/Loader.php branches/newUser/classes/Gems/User/DatabaseUserAbstract.php branches/newUser/classes/Gems/User/NoLoginUser.php branches/newUser/classes/Gems/User/UserAbstract.php branches/newUser/classes/Gems/User/UserLoader.php Added Paths: ----------- branches/newUser/classes/Gems/User/RespondentUser.php branches/newUser/classes/Gems/User/StaffUser.php Modified: branches/newUser/classes/Gems/Loader.php =================================================================== --- branches/newUser/classes/Gems/Loader.php 2011-10-26 12:51:28 UTC (rev 144) +++ branches/newUser/classes/Gems/Loader.php 2011-10-26 17:18:45 UTC (rev 145) @@ -185,7 +185,7 @@ * * @param string $login_name * @param int $organization Only used when more than one organization uses this $login_name - * @return Gems_User_UserInterface + * @return Gems_User_UserAbstract */ public function getUser($login_name, $organization) { Modified: branches/newUser/classes/Gems/User/DatabaseUserAbstract.php =================================================================== --- branches/newUser/classes/Gems/User/DatabaseUserAbstract.php 2011-10-26 12:51:28 UTC (rev 144) +++ branches/newUser/classes/Gems/User/DatabaseUserAbstract.php 2011-10-26 17:18:45 UTC (rev 145) @@ -46,20 +46,26 @@ */ class Gems_User_DatabaseUserAbstract extends Gems_User_UserAbstract { - protected $columnMappings = array( - 'user_id'=>'gsf_id_user', - 'user_login'=>'gsf_login', - //don't expose the password hash - //'user_password'=>'gsf_password', - 'user_email'=>'gsf_email', - 'user_group'=>'gsf_id_primary_group', - 'user_locale'=>'gsf_iso_lang', - 'user_logout'=>'gsf_logout_on_survey', - ); + /** + * + * @var Zend_Db_Adapter_Abstract + */ + protected $db; - abstract function getSqlStatement(); + /** + * Simple used name => database field + * @var array + */ + protected $fieldMappings = array(); /** + * Creates the initial feed SQL select statement + * + * @return Zend_Db_Select + */ + abstract public function getSqlSelect(); + + /** * Intialize the values for this user. * * Skipped when the user is the active user and is stored in the session. @@ -70,6 +76,8 @@ */ protected function initVariables($login_name, $organization) { + $select = $this->getSqlSelect(); + $userIds = $select->query()->fetchAll(); } } Modified: branches/newUser/classes/Gems/User/NoLoginUser.php =================================================================== --- branches/newUser/classes/Gems/User/NoLoginUser.php 2011-10-26 12:51:28 UTC (rev 144) +++ branches/newUser/classes/Gems/User/NoLoginUser.php 2011-10-26 17:18:45 UTC (rev 145) @@ -53,16 +53,6 @@ protected $translated; /** - * Adapted constructor. This class hazs nu user name. - * - * @param int $organization Only used when more than one organization uses this $login_name - */ - public function __construct($organization) - { - parent::__construct(null, $organization); - } - - /** * Check that the password is correct for this user. * * @param string $password Unencrypted password Added: branches/newUser/classes/Gems/User/RespondentUser.php =================================================================== --- branches/newUser/classes/Gems/User/RespondentUser.php (rev 0) +++ branches/newUser/classes/Gems/User/RespondentUser.php 2011-10-26 17:18:45 UTC (rev 145) @@ -0,0 +1,59 @@ +<?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 User + * @author Matijs de Jong <mj...@ma...> + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @version $Id: Sample.php 203 2011-07-07 12:51:32Z matijs $ + */ + +/** + * + * + * @package Gems + * @subpackage User + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @since Class available since version 1.4.4 + */ +class Gems_User_RespondentUser extends Gems_User_DatabaseUserAbstract +{ + /** + * Creates the initial feed SQL select statement + * + * @return Zend_Db_Select + */ + public function getSqlSelect() + { + $this->db->select(); + } + +} Added: branches/newUser/classes/Gems/User/StaffUser.php =================================================================== --- branches/newUser/classes/Gems/User/StaffUser.php (rev 0) +++ branches/newUser/classes/Gems/User/StaffUser.php 2011-10-26 17:18:45 UTC (rev 145) @@ -0,0 +1,71 @@ +<?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 User + * @author Matijs de Jong <mj...@ma...> + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @version $Id: Sample.php 203 2011-07-07 12:51:32Z matijs $ + */ + +/** + * + * + * @package Gems + * @subpackage User + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @since Class available since version 1.4.4 + */ +class Gems_User_StaffUser extends Gems_User_DatabaseUserAbstract +{ + /** + * Creates the initial feed SQL select statement + * + * @return Zend_Db_Select + */ + public function getSqlSelect() + { + $select = new Zend_Db_Select($this->db); + $select->from('gems__users') + ->join('gems__staff', 'gsu_login = gsf_id_user') + ->join('gems__groups', 'gsf_id_primary_group = ggp_id_group') + ->join('gems__organizations', 'gsf_id_organization = gor_id_organization') + ->where('ggp_group_active = 1') + ->where('gor_active = 1') + ->where('gsf_active = 1') + ->where('gsf_login = ?', $this->getLoginName()) + ->limit(1); + + return $select; + } + + +} Modified: branches/newUser/classes/Gems/User/UserAbstract.php =================================================================== --- branches/newUser/classes/Gems/User/UserAbstract.php 2011-10-26 12:51:28 UTC (rev 144) +++ branches/newUser/classes/Gems/User/UserAbstract.php 2011-10-26 17:18:45 UTC (rev 145) @@ -46,6 +46,9 @@ */ abstract class Gems_User_UserAbstract extends Gems_Registry_TargetAbstract implements Gems_User_UserInterface { + const SESSION_CLASS_NAME = '__className'; + const SESSION_LOGIN_NAME = '__loginName'; + const SESSION_ORGANIZATION_ID = '__organizationId'; /** * * @var string @@ -115,20 +118,23 @@ */ private function _getVariableStore() { - $loginName = 'loginName'; - $organizationId = 'organizationId'; - if (! $this->_vars) { $sessionStore = self::_getSessionStore(); - if (isset($sessionStore->$loginName, $sessionStore->$organizationId) && ($sessionStore->$loginName == $this->_login_name) && ($sessionStore->$organizationId == $this->_organization_id)) { + if ($sessionStore->__isset(self::SESSION_CLASS_NAME) && + ($sessionStore->__get(self::SESSION_CLASS_NAME) == get_class($this)) && + $sessionStore->__isset(self::SESSION_LOGIN_NAME) && + ($sessionStore->__get(self::SESSION_LOGIN_NAME) == $this->_login_name) && + $sessionStore->__isset(self::SESSION_ORGANIZATION_ID) && + ($sessionStore->__get(self::SESSION_ORGANIZATION_ID) == $this->_organization_id)) { + $this->_vars = $sessionStore; - $this->_vars->__set($loginName, $this->_login_name); - $this->_vars->__set($organizationId, $this->_organization_id); + } else { $this->_vars = new ArrayObject(array(), ArrayObject::ARRAY_AS_PROPS); - $this->_vars->offsetSet($loginName, $this->_login_name); - $this->_vars->offsetSet($organizationId, $this->_organization_id); + $this->_vars->offsetSet(self::SESSION_CLASS_NAME, get_class($this)); + $this->_vars->offsetSet(self::SESSION_LOGIN_NAME, $this->_login_name); + $this->_vars->offsetSet(self::SESSION_ORGANIZATION_ID, $this->_organization_id); } } @@ -154,7 +160,34 @@ } /** + * Returns the current user from the session store or false if there is no user. * + * Use Gems_User_UserLoader->getCurrentUser() when you always want to have a user object returned. + * + * @see Gems_User_UserLoader->getCurrentUser() + * + * @staticvar Gems_User_UserAbstract $currentUser + * @return Gems_User_UserAbstract or false if there is no current user. + */ + public static function getCurrentUser() + { + static $currentUser; + + if (null === $currentUser) { + $store = self::_getSessionStore(); + + if ($className = $store->__get(self::SESSION_CLASS_NAME)) { + $currentUser = new $className($store->__get(self::SESSION_LOGIN_NAME), $store->__get(self::SESSION_ORGANIZATION_ID)); + } else { + $currentUser = false; + } + } + + return $currentUser; + } + + /** + * * @return string */ protected function getLoginName() Modified: branches/newUser/classes/Gems/User/UserLoader.php =================================================================== --- branches/newUser/classes/Gems/User/UserLoader.php 2011-10-26 12:51:28 UTC (rev 144) +++ branches/newUser/classes/Gems/User/UserLoader.php 2011-10-26 17:18:45 UTC (rev 145) @@ -62,9 +62,29 @@ /** * + */ + public function getCurrentUser() + { + static $currentUser; + + if (! $currentUser) { + $currentUser = Gems_User_UserAbstract::getCurrentUser(); + + if (! $currentUser) { + $currentUser = $this->_loadClass('NoLoginUser', true, array(null, null)); + + $currentUser->setAsCurrentUser(); + } + } + + return $currentUser; + } + + /** + * * @param string $login_name * @param int $organization Only used when more than one organization uses this $login_name - * @return Gems_User_UserInterface + * @return Gems_User_UserAbstract */ public function getUser($login_name, $organization) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2011-10-26 12:51:35
|
Revision: 144 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=144&view=rev Author: mennodekker Date: 2011-10-26 12:51:28 +0000 (Wed, 26 Oct 2011) Log Message: ----------- activated cache in Gems_Roles, and forced a rebuild of the acl on save in the RoleAction Modified Paths: -------------- trunk/library/classes/Gems/Default/RoleAction.php trunk/library/classes/Gems/Roles.php Modified: trunk/library/classes/Gems/Default/RoleAction.php =================================================================== --- trunk/library/classes/Gems/Default/RoleAction.php 2011-10-26 11:58:13 UTC (rev 143) +++ trunk/library/classes/Gems/Default/RoleAction.php 2011-10-26 12:51:28 UTC (rev 144) @@ -46,6 +46,11 @@ */ class Gems_Default_RoleAction extends Gems_Controller_BrowseEditAction { + /** + * @var GemsEscort + */ + public $escort; + protected function _showTable($caption, $data, $nested = false) { $table = MUtil_Html_TableElement::createArray($data, $caption, $nested); @@ -107,6 +112,21 @@ } /** + * As the ACL might have to be updated, rebuild the acl + * + * @param array $data + * @param type $isNew + * @return type + */ + public function afterSave(array $data, $isNew) + { + $roles = $this->loader->getRoles($this->escort); + $roles->build(); + + return true; + } + + /** * Check the disabled (=inherited) privileges * * @param Gems_Form $form Modified: trunk/library/classes/Gems/Roles.php =================================================================== --- trunk/library/classes/Gems/Roles.php 2011-10-26 11:58:13 UTC (rev 143) +++ trunk/library/classes/Gems/Roles.php 2011-10-26 12:51:28 UTC (rev 144) @@ -241,13 +241,16 @@ private function save() { if ($this->_cache instanceof Zend_Cache_Core) { if (!$this->_cache->save($this->_acl, $this->_cacheid, array(), null)) - echo "MISLUKT!"; + throw new Gems_Exception('Failed to save acl to cache'); } } public function setCache($cache) { - if ($cache instanceof Zend_Cache_Core) + if ($cache instanceof Zend_Cache_Core) { $this->_cache = $cache; - } + } elseif ($cache instanceof GemsEscort) { + $this->_cache = $cache->cache; + } + } } \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2011-10-26 11:58:22
|
Revision: 143 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=143&view=rev Author: mennodekker Date: 2011-10-26 11:58:13 +0000 (Wed, 26 Oct 2011) Log Message: ----------- Fixed #30: Speedup of execution by using a cache, can probably be improved further by using APC instead of file, there is a new switch in project info to clean the cache using the privilege used to toggle maintenance mode Modified Paths: -------------- trunk/library/classes/Gems/Default/ProjectInformationAction.php trunk/library/classes/Gems/Menu/MenuAbstract.php trunk/library/classes/GemsEscort.php Modified: trunk/library/classes/Gems/Default/ProjectInformationAction.php =================================================================== --- trunk/library/classes/Gems/Default/ProjectInformationAction.php 2011-10-26 11:22:46 UTC (rev 142) +++ trunk/library/classes/Gems/Default/ProjectInformationAction.php 2011-10-26 11:58:13 UTC (rev 143) @@ -153,7 +153,8 @@ $request = $this->getRequest(); $buttonList = $this->menu->getMenuList(); $buttonList->addParameterSources($request) - ->addByController($request->getControllerName(), 'maintenance', $label); + ->addByController($request->getControllerName(), 'maintenance', $label) + ->addByController($request->getControllerName(), 'cacheclean'); // $this->html->buttonDiv($buttonList); @@ -180,6 +181,15 @@ $this->_reroute(array($request->getActionKey() => 'index')); } + public function cachecleanAction() + { + $this->escort->cache->clean(); + $this->addMessage($this->_('Cache cleaned')); + // Redirect + $request = $this->getRequest(); + $this->_reroute(array($request->getActionKey() => 'index')); + } + public function phpAction() { $this->html->h2($this->_('Server PHP Info')); Modified: trunk/library/classes/Gems/Menu/MenuAbstract.php =================================================================== --- trunk/library/classes/Gems/Menu/MenuAbstract.php 2011-10-26 11:22:46 UTC (rev 142) +++ trunk/library/classes/Gems/Menu/MenuAbstract.php 2011-10-26 11:58:13 UTC (rev 143) @@ -316,6 +316,7 @@ $page->addAction($this->_('Project'), null, 'project'); $page->addAction($this->_('Session'), null, 'session'); $page->addButtonOnly($this->_('Maintenance mode'), 'pr.maintenance', 'project-information', 'maintenance'); + $page->addButtonOnly($this->_('Clean cache'), 'pr.maintenance', 'project-information', 'cacheclean'); return $page; } Modified: trunk/library/classes/GemsEscort.php =================================================================== --- trunk/library/classes/GemsEscort.php 2011-10-26 11:22:46 UTC (rev 142) +++ trunk/library/classes/GemsEscort.php 2011-10-26 11:58:13 UTC (rev 143) @@ -138,6 +138,36 @@ } /** + * Create a default file cache for the Translate and DB adapters to speed up execution + * + * @return Zend_Cache_Core + */ + protected function _initCache() + { + $exists = false; + $cacheDir = GEMS_ROOT_DIR . "/var/cache/"; + if (!file_exists($cacheDir)) { + if (mkdir($cacheDir, 0777, true)) { + $exists = true; + } + } else { + $exists = true; + } + + if ($exists) { + $cacheFrontendOptions = array('automatic_serialization' => true); + $cacheBackendOptions = array('cache_dir' => $cacheDir); + + $cache = Zend_Cache::factory('Core', 'File', $cacheFrontendOptions, $cacheBackendOptions); + + Zend_Db_Table_Abstract::setDefaultMetadataCache($cache); + Zend_Translate::setCache($cache); + } + + return $cache; + } + + /** * Initialize the logger * * @return Gems_Log This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2011-10-26 11:22:53
|
Revision: 142 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=142&view=rev Author: mennodekker Date: 2011-10-26 11:22:46 +0000 (Wed, 26 Oct 2011) Log Message: ----------- cleanup of action buttons to only include the ones we need Modified Paths: -------------- trunk/library/classes/Gems/Default/ConsentAction.php trunk/library/classes/Gems/Default/ReceptionAction.php Modified: trunk/library/classes/Gems/Default/ConsentAction.php =================================================================== --- trunk/library/classes/Gems/Default/ConsentAction.php 2011-10-25 16:59:48 UTC (rev 141) +++ trunk/library/classes/Gems/Default/ConsentAction.php 2011-10-26 11:22:46 UTC (rev 142) @@ -1,35 +1,35 @@ <?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 @@ -38,22 +38,24 @@ */ /** - * + * * @author Matijs de Jong * @package Gems * @subpackage Default */ class Gems_Default_ConsentAction extends Gems_Controller_BrowseEditAction { + public $menuIndexIncludeLevel = 1; + public $sortKey = array('gco_order' => SORT_ASC); - /** - * 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 - * parameter was added, because the most common use of action is a split between detailed + /** + * 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 + * parameter was added, because the most common use of action is a split between detailed * and summarized actions. - * + * * @param boolean $detailed True when the current action is not in $summarizedActions. * @param string $action The current action. * @return MUtil_Model_ModelAbstract Modified: trunk/library/classes/Gems/Default/ReceptionAction.php =================================================================== --- trunk/library/classes/Gems/Default/ReceptionAction.php 2011-10-25 16:59:48 UTC (rev 141) +++ trunk/library/classes/Gems/Default/ReceptionAction.php 2011-10-26 11:22:46 UTC (rev 142) @@ -46,6 +46,8 @@ */ class Gems_Default_ReceptionAction extends Gems_Controller_BrowseEditAction { + public $menuIndexIncludeLevel = 1; + public $sortKey = array('grc_id_reception_code' => SORT_ASC); public function addFormElements(MUtil_Model_FormBridge $bridge, MUtil_Model_ModelAbstract $model, array $data, $new = false) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2011-10-25 16:59:54
|
Revision: 141 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=141&view=rev Author: matijsdejong Date: 2011-10-25 16:59:48 +0000 (Tue, 25 Oct 2011) Log Message: ----------- More philosophy on users Modified Paths: -------------- branches/newUser/classes/Gems/User/ProjectSuperUser.php branches/newUser/classes/Gems/User/UserAbstract.php Added Paths: ----------- branches/newUser/classes/Gems/User/DatabaseUserAbstract.php branches/newUser/classes/Gems/User/NoLoginUser.php Added: branches/newUser/classes/Gems/User/DatabaseUserAbstract.php =================================================================== --- branches/newUser/classes/Gems/User/DatabaseUserAbstract.php (rev 0) +++ branches/newUser/classes/Gems/User/DatabaseUserAbstract.php 2011-10-25 16:59:48 UTC (rev 141) @@ -0,0 +1,75 @@ +<?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 User + * @author Matijs de Jong <mj...@ma...> + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @version $Id: Sample.php 203 2011-07-07 12:51:32Z matijs $ + */ + +/** + * + * + * @package Gems + * @subpackage User + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @since Class available since version 1.4.4 + */ +class Gems_User_DatabaseUserAbstract extends Gems_User_UserAbstract +{ + protected $columnMappings = array( + 'user_id'=>'gsf_id_user', + 'user_login'=>'gsf_login', + //don't expose the password hash + //'user_password'=>'gsf_password', + 'user_email'=>'gsf_email', + 'user_group'=>'gsf_id_primary_group', + 'user_locale'=>'gsf_iso_lang', + 'user_logout'=>'gsf_logout_on_survey', + ); + + abstract function getSqlStatement(); + + /** + * Intialize the values for this user. + * + * Skipped when the user is the active user and is stored in the session. + * + * @param string $login_name + * @param int $organization Only used when more than one organization uses this $login_name + * @return boolean False when the object could not load. + */ + protected function initVariables($login_name, $organization) + { + + } +} Copied: branches/newUser/classes/Gems/User/NoLoginUser.php (from rev 139, branches/newUser/classes/Gems/User/ProjectSuperUser.php) =================================================================== --- branches/newUser/classes/Gems/User/NoLoginUser.php (rev 0) +++ branches/newUser/classes/Gems/User/NoLoginUser.php 2011-10-25 16:59:48 UTC (rev 141) @@ -0,0 +1,91 @@ +<?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 User + * @author Matijs de Jong <mj...@ma...> + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @version $Id: Sample.php 203 2011-07-07 12:51:32Z matijs $ + */ + +/** + * + * + * @package Gems + * @subpackage User + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @since Class available since version 1.4.4 + */ +class Gems_User_NoLoginUser extends Gems_User_UserAbstract +{ + /** + * + * @var Gems_Util_Translated + */ + protected $translated; + + /** + * Adapted constructor. This class hazs nu user name. + * + * @param int $organization Only used when more than one organization uses this $login_name + */ + public function __construct($organization) + { + parent::__construct(null, $organization); + } + + /** + * Check that the password is correct for this user. + * + * @param string $password Unencrypted password + * @return boolean + */ + public function checkPassword($password) + { + return false; + } + + /** + * Intialize the values for this user. + * + * Skipped when the user is the active user and is stored in the session. + * + * @param string $login_name + * @param int $organization Only used when more than one organization uses this $login_name + * @return boolean False when the object could not load. + */ + protected function initVariables($login_name, $organization) + { + $this->setRole('nologin'); + return true; + } + +} Modified: branches/newUser/classes/Gems/User/ProjectSuperUser.php =================================================================== --- branches/newUser/classes/Gems/User/ProjectSuperUser.php 2011-10-25 15:58:01 UTC (rev 140) +++ branches/newUser/classes/Gems/User/ProjectSuperUser.php 2011-10-25 16:59:48 UTC (rev 141) @@ -28,7 +28,7 @@ * * * @package Gems - * @subpackage + * @subpackage User * @author Matijs de Jong <mj...@ma...> * @copyright Copyright (c) 2011 Erasmus MC * @license New BSD License @@ -39,7 +39,7 @@ * * * @package Gems - * @subpackage + * @subpackage User * @copyright Copyright (c) 2011 Erasmus MC * @license New BSD License * @since Class available since version 1.4.4 @@ -49,14 +49,7 @@ const MIN_PASSWORD_LENGTH = 10; /** - * The role of this user. * - * @var string - */ - protected $_role = 'super'; - - /** - * * @var ArrayObject */ protected $project; @@ -113,7 +106,7 @@ */ protected function initVariables($login_name, $organization) { - $this->setRole('super'); + $this->setRole('super'); // sublime superior master diety ? return true; } Modified: branches/newUser/classes/Gems/User/UserAbstract.php =================================================================== --- branches/newUser/classes/Gems/User/UserAbstract.php 2011-10-25 15:58:01 UTC (rev 140) +++ branches/newUser/classes/Gems/User/UserAbstract.php 2011-10-25 16:59:48 UTC (rev 141) @@ -80,6 +80,7 @@ protected $session; /** + * Creates this class for the current user. * * @param string $login_name * @param int $organization Only used when more than one organization uses this $login_name @@ -242,13 +243,24 @@ // Clean up what is there now. $this->_vars->unsetAll(); - $this->session->unsetAll(); foreach ($oldStore as $name => $value) { $this->_vars->__set($name, $value); - $this->session->__set($name, $value); } + // Copy to session + // $this->session->unsetAll(); +// $this->session->user_id; + $this->session->user_login = $this->getLoginName(); +// $this->session->user_email; +// $this->session->user_group; +// $this->session->user_style; +// $this->session->user_locale; +// $this->session->user_logout; +// $this->session->user_name; + $this->session->user_role = $this->getRole(); + $this->session->user_organization_id = $this->getOrganizationId(); +// $this->session->user_organization_name; } return $this; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2011-10-25 15:58:11
|
Revision: 140 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=140&view=rev Author: matijsdejong Date: 2011-10-25 15:58:01 +0000 (Tue, 25 Oct 2011) Log Message: ----------- Brought up to date with revisions up to 139 Modified Paths: -------------- branches/newUser/changelog.txt branches/newUser/classes/Gems/Controller/ModelSnippetActionAbstract.php branches/newUser/classes/Gems/Default/DatabaseAction.php branches/newUser/classes/Gems/Default/IndexAction.php branches/newUser/classes/Gems/Default/MailLogAction.php branches/newUser/classes/Gems/Default/ProjectInformationAction.php branches/newUser/classes/Gems/Default/RoleAction.php branches/newUser/classes/Gems/Default/StaffAction.php branches/newUser/classes/Gems/Email/EmailFormAbstract.php branches/newUser/classes/Gems/Email/MultiMailForm.php branches/newUser/classes/Gems/Email/TemplateMailer.php branches/newUser/classes/Gems/Menu/MenuAbstract.php branches/newUser/classes/Gems/Menu.php branches/newUser/classes/Gems/Roles.php branches/newUser/classes/Gems/Snippets/ModelFormSnippetAbstract.php branches/newUser/classes/Gems/Snippets/ModelTableSnippetAbstract.php branches/newUser/classes/Gems/Tracker/Engine/StepEngineAbstract.php branches/newUser/classes/Gems/Tracker/Source/LimeSurvey1m9FieldMap.php branches/newUser/classes/Gems/Util/DbLookup.php branches/newUser/classes/Gems/Util/Translated.php branches/newUser/classes/Gems/Util.php branches/newUser/classes/GemsEscort.php branches/newUser/classes/MUtil/Controller/ModelSnippetActionAbstract.php branches/newUser/classes/MUtil/Snippets/ModelFormSnippetAbstract.php branches/newUser/classes/MUtil/Snippets/ModelVerticalTableSnippetAbstract.php branches/newUser/classes/MUtil/Snippets/Standard/ModelVerticalTableSnippet.php branches/newUser/configs/db/patches.sql branches/newUser/configs/db/tables/gems__mail_jobs.300.sql branches/newUser/controllers/EmailController.php branches/newUser/languages/default-en.mo branches/newUser/languages/default-en.po branches/newUser/languages/default-nl.mo branches/newUser/languages/default-nl.po branches/newUser/snippets/Generic/ModelItemTableSnippet.php branches/newUser/snippets/Mail/Log/MailLogBrowseSnippet.php Added Paths: ----------- branches/newUser/classes/Gems/Default/CronAction.php branches/newUser/classes/Gems/Default/MailJobAction.php branches/newUser/classes/Gems/Default/MailTemplateAction.php branches/newUser/classes/Gems/Snippets/ModelFormSnippetGeneric.php branches/newUser/classes/Gems/Snippets/ModelItemTableSnippetAbstract.php branches/newUser/classes/Gems/Snippets/ModelItemTableSnippetGeneric.php branches/newUser/classes/Gems/Snippets/ModelItemYesNoDeleteSnippetAbstract.php branches/newUser/classes/Gems/Snippets/ModelItemYesNoDeleteSnippetGeneric.php branches/newUser/classes/Gems/Util/LockFile.php branches/newUser/classes/MUtil/Mail/ branches/newUser/classes/MUtil/Mail/Transport/ branches/newUser/classes/MUtil/Mail/Transport/EchoLog.php branches/newUser/classes/MUtil/Snippets/ModelYesNoDeleteSnippetAbstract.php branches/newUser/classes/MUtil/Snippets/Standard/ModelYesNoDeleteSnippet.php branches/newUser/controllers/CronController.php branches/newUser/controllers/MailJobController.php branches/newUser/controllers/MailTemplateController.php branches/newUser/snippets/Generic/ModelFormSnippet.php branches/newUser/snippets/Generic/ModelItemYesNoDeleteSnippet.php Removed Paths: ------------- branches/newUser/classes/Gems/Default/EmailAction.php branches/newUser/classes/Gems/Default/MailAction.php branches/newUser/classes/MUtil/Mail/Transport/ branches/newUser/classes/MUtil/Mail/Transport/EchoLog.php branches/newUser/controllers/MailController.php Property Changed: ---------------- branches/newUser/ Property changes on: branches/newUser ___________________________________________________________________ Modified: svn:mergeinfo - /trunk/library:114-122 + /trunk/library:114-122,125-139 Modified: branches/newUser/changelog.txt =================================================================== --- branches/newUser/changelog.txt 2011-10-25 15:34:11 UTC (rev 139) +++ branches/newUser/changelog.txt 2011-10-25 15:58:01 UTC (rev 140) @@ -1,3 +1,8 @@ +Important changes from 1.4.3 => 1.5 +============================================================ +MailController is now called MailTemplateController +EmailController is now called CronController (with stub for compatibility) + Important changes from 1.4.2 => 1.4.3 ============================================================ * gtr_organisations renamed to gtr_organizations Modified: branches/newUser/classes/Gems/Controller/ModelSnippetActionAbstract.php =================================================================== --- branches/newUser/classes/Gems/Controller/ModelSnippetActionAbstract.php 2011-10-25 15:34:11 UTC (rev 139) +++ branches/newUser/classes/Gems/Controller/ModelSnippetActionAbstract.php 2011-10-25 15:58:01 UTC (rev 140) @@ -26,7 +26,6 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * Short description of file * * @package Gems * @subpackage Controller @@ -37,10 +36,8 @@ */ /** - * Short description for class + * Class contains Gems specific adaptations to parent class. * - * Long description for class (if any)... - * * @package Gems * @subpackage Controller * @copyright Copyright (c) 2011 Erasmus MC @@ -50,12 +47,6 @@ abstract class Gems_Controller_ModelSnippetActionAbstract extends MUtil_Controller_ModelSnippetActionAbstract { /** - * - * @var GemsEscort - */ - public $escort; - - /** * The parameters used for the autofilter action. * * @var array Mixed key => value array for snippet initialization @@ -74,6 +65,32 @@ protected $autofilterSnippets = 'Generic_ModelTableSnippet'; /** + * The snippets used for the create and edit actions. + * + * @var mixed String or array of snippets name + */ + protected $createEditSnippets = 'Generic_ModelFormSnippet'; + + /** + * The snippets used for the delete action. + * + * @var mixed String or array of snippets name + */ + protected $deleteSnippets = 'Generic_ModelItemYesNoDeleteSnippet'; + + /** + * + * @var GemsEscort + */ + public $escort; + + /** + * + * @var Gems_Menu + */ + public $menu; + + /** * The snippets used for the index action, before those in autofilter * * @var mixed String or array of snippets name Copied: branches/newUser/classes/Gems/Default/CronAction.php (from rev 139, trunk/library/classes/Gems/Default/CronAction.php) =================================================================== --- branches/newUser/classes/Gems/Default/CronAction.php (rev 0) +++ branches/newUser/classes/Gems/Default/CronAction.php 2011-10-25 15:58:01 UTC (rev 140) @@ -0,0 +1,252 @@ +<?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 Michiel Rook <mi...@to...> + * @package Gems + * @subpackage Default + */ + +/** + * Performs bulk-mail action, can be called from a cronjob + * + * @author Michiel Rook <mi...@to...> + * @package Gems + * @subpackage Default + */ +class Gems_Default_CronAction extends MUtil_Controller_Action +{ + /** + * + * @var Zend_Db_Adapter_Abstract + */ + public $db; + + /** + * Standard filter that must be true for every token query. + * + * @var array + */ + protected $defaultFilter = array( + 'can_email' => 1, + 'gtr_active' => 1, + 'gsu_active' => 1, + 'grc_success' => 1, + 'gto_completion_time' => NULL, + 'gto_valid_from <= CURRENT_DATE', + '(gto_valid_until IS NULL OR gto_valid_until >= CURRENT_TIMESTAMP)' + ); + + /** + * + * @var GemsEscort + */ + public $escort; + + /** + * + * @var Gems_Menu + */ + public $menu; + + /** + * + * @var Zend_Session_Namespace + */ + public $session; + + /** + * Set to true in child class for automatic creation of $this->html. + * + * Otherwise call $this->initHtml() + * + * @var boolean $useHtmlView + */ + public $useHtmlView = true; + + /** + * + * @var Gems_Util + */ + public $util; + + /** + * Action that switches the cron job lock on or off. + */ + public function cronLockAction() + { + // Switch lock + $this->util->getCronJobLock()->reverse(); + + // Redirect + $request = $this->getRequest(); + $this->_reroute($this->menu->getCurrentParent()->toRouteUrl()); + } + + /** + * Loads an e-mail template + * + * @param integer|null $templateId + */ + protected function getTemplate($templateId) + { + return $this->db->fetchRow('SELECT * FROM gems__mail_templates WHERE gmt_id_message = ?', $templateId); + } + + /** + * Returns the login name belonging to this user. + * + * @param int $userId + * @return string + */ + protected function getUserLogin($userId) + { + return $this->db->fetchOne("SELECT gsf_login FROM gems__staff WHERE gsf_id_user = ?", $userId); + } + + public function indexAction() + { + $this->initHtml(); + + if ($this->util->getCronJobLock()->isLocked()) { + $this->html->append($this->_('Cron jobs turned off.')); + } else { + $this->mailJob(); + } + } + + public function mailJob() + { + // Test: update `gems__tokens` set `gto_mail_sent_date` = null where `gto_mail_sent_date` > '2011-10-23' + + $currentUser = isset($this->session->user_login) ? $this->session->user_login : null; + + $model = $this->loader->getTracker()->getTokenModel(); + $mailer = new Gems_Email_TemplateMailer($this->escort); + // $mailer->setDefaultTransport(new MUtil_Mail_Transport_EchoLog()); + + $jobs = $this->db->fetchAll("SELECT * FROM gems__mail_jobs WHERE gmj_active = 1"); + + if ($jobs) { + foreach ($jobs as $job) { + $this->escort->loadLoginInfo($this->getUserLogin($job['gmj_id_user_as'])); + + // Set up filter + $filter = $this->defaultFilter; + if ($job['gmj_filter_mode'] == 'R') { + $filter[] = 'gto_mail_sent_date <= DATE_SUB(CURRENT_DATE, INTERVAL ' . $job['gmj_filter_days_between'] . ' DAY)'; + } else { + $filter['gto_mail_sent_date'] = NULL; + } + if ($job['gmj_id_organization']) { + $filter['gto_id_organization'] = $job['gmj_id_organization']; + } + if ($job['gmj_id_track']) { + $filter['gto_id_track'] = $job['gmj_id_track']; + } + if ($job['gmj_id_survey']) { + $filter['gto_id_survey'] = $job['gmj_id_survey']; + } + + $tokensData = $model->load($filter); + + if (count($tokensData)) { + $mailer->setMethod($job['gmj_process_method']); + if ($job['gmj_from_method'] == 'F') { + $mailer->setFrom($job['gmj_from_fixed']); + } else { + $mailer->setFrom($job['gmj_from_method']); + } + + $templateData = $this->getTemplate($job['gmj_id_message']); + $mailer->setSubject($templateData['gmt_subject']); + $mailer->setBody($templateData['gmt_body']); + + $mailer->setTokens(MUtil_Ra::column('gto_id_token', $tokensData)); + $mailer->process($tokensData); + } + + Gems_Auth::getInstance()->clearIdentity(); + $this->escort->session->unsetAll(); + } + } + + $msg = $mailer->getMessages(); + if (! $msg) { + $msg[] = $this->_('No mails sent'); + } + + $this->html->append($msg); + + if ($currentUser) { + $this->escort->loadLoginInfo($currentUser); + } else { + $this->escort->afterLogout(); + } + + /* + if (isset($this->project->email['automatic'])) { + $batches = $this->project->email['automatic']; + $numBatches = count($batches['mode']); + + for ($i = 0; $i < $numBatches; $i++) { + $this->_organizationId = $batches['organization'][$i]; + + if (isset($batches['days'][$i])) { + $this->_intervalDays = $batches['days'][$i]; + } + + $this->escort->loadLoginInfo($batches['user'][$i]); + + $model->setFilter($this->getFilter($batches['mode'][$i])); + + $tokensData = $model->load(); + + if (count($tokensData)) { + $tokens = array(); + + foreach ($tokensData as $tokenData) { + $tokens[] = $tokenData['gto_id_token']; + } + + $templateData = $this->getTemplate($batches['template'][$i]); + $mailer->setSubject($templateData['gmt_subject']); + $mailer->setBody($templateData['gmt_body']); + $mailer->setMethod($batches['method'][$i]); + $mailer->setFrom($batches['from'][$i]); + $mailer->setTokens($tokens); + + $mailer->process($tokensData); + } + + Gems_Auth::getInstance()->clearIdentity(); + $this->escort->session->unsetAll(); + } + } + // */ + } +} \ No newline at end of file Modified: branches/newUser/classes/Gems/Default/DatabaseAction.php =================================================================== --- branches/newUser/classes/Gems/Default/DatabaseAction.php 2011-10-25 15:34:11 UTC (rev 139) +++ branches/newUser/classes/Gems/Default/DatabaseAction.php 2011-10-25 15:58:01 UTC (rev 140) @@ -93,6 +93,18 @@ } /** + * Set the parameters needed by the menu. + * + * @param array $data The current model item + */ + private function _setMenuParameters(array $data) + { + $source = $this->menu->getParameterSource(); + $source['script'] = $data['script'] ? true : false; + $source['exists'] = $data['exists'] ? true : false; + } + + /** * Adds elements from the model to the bridge that creates the form. * * Overrule this function to add different elements to the browse table, without @@ -180,6 +192,8 @@ $model = $this->getModel(); $data = $model->applyRequest($this->getRequest())->loadFirst(); + $this->_setMenuParameters($data); + if (! ($data && isset($data['exists']) && $data['exists'])) { $this->addMessage($this->_('This database object does not exist. You cannot delete it.')); $this->html->buttonDiv($this->createMenuLinks(1)); @@ -438,6 +452,8 @@ $model = $this->getModel(); $data = $model->loadFirst(); + $this->_setMenuParameters($data); + if (! ($data && isset($data['exists'], $data['script']) && ($data['exists'] || $data['script']))) { $this->addMessage($this->_('This database object does not exist. You cannot create it.')); $this->html->buttonDiv($this->createMenuLinks(1)); @@ -580,9 +596,9 @@ $model = $this->getModel(); $data = $model->loadFirst(); - $source = $this->menu->getParameterSource(); - $source['script'] = $data['script']; - $source['exists'] = $data['exists']; + if ($data) { + $this->_setMenuParameters($data); + } parent::showAction(); } @@ -592,6 +608,8 @@ $model = $this->getModel(); $data = $model->loadFirst(); + $this->_setMenuParameters($data); + if (! ($data && isset($data['exists']) && $data['exists'])) { $this->addMessage($this->_('This database object does not exist. You cannot view it.')); $this->html->buttonDiv($this->createMenuLinks(1)); Deleted: branches/newUser/classes/Gems/Default/EmailAction.php =================================================================== --- branches/newUser/classes/Gems/Default/EmailAction.php 2011-10-25 15:34:11 UTC (rev 139) +++ branches/newUser/classes/Gems/Default/EmailAction.php 2011-10-25 15:58:01 UTC (rev 140) @@ -1,135 +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. - * - * @author Michiel Rook <mi...@to...> - * @package Gems - * @subpackage Default - */ - -/** - * Performs bulk-mail action, can be called from a cronjob - * - * @author Michiel Rook <mi...@to...> - * @package Gems - * @subpackage Default - */ -class Gems_Default_EmailAction extends Gems_Default_TokenPlanAction -{ - private $_organizationId = null; - private $_intervalDays = 7; - - /** - * Constructs - * @param strings $mode Either 'notmailed' or 'reminder' - */ - protected function getFilter($mode = null) - { - $filter = array( - 'can_email' => 1, - 'gto_id_organization' => $this->_organizationId, - 'gtr_active' => 1, - 'gsu_active' => 1, - 'grc_success' => 1, - 'gto_completion_time' => NULL, - '`gto_valid_from` >= DATE_ADD(CURRENT_DATE, INTERVAL -4 WEEK)', - '`gto_valid_from` <= DATE_ADD(CURRENT_DATE, INTERVAL 2 WEEK)', - '(gto_valid_until IS NULL OR gto_valid_until >= CURRENT_TIMESTAMP)' - ); - - if (isset($mode) && $mode == 'reminder') { - $filter[] = 'gto_mail_sent_date <= DATE_SUB(CURRENT_DATE, INTERVAL ' . $this->_intervalDays . ' DAY)'; - } else { - $filter['gto_mail_sent_date'] = NULL; - } - - return $filter; - } - - /** - * Loads an e-mail template - * @param integer|null $templateId - */ - protected function getTemplate($templateId) - { - $model = new MUtil_Model_TableModel('gems__mail_templates'); - - return $model->loadFirst(array('gmt_id_message' => $templateId)); - } - - public function indexAction() - { - $this->initHtml(); - - $model = $this->loader->getTracker()->getTokenModel(); - $model->setCreate(false); - - $mailer = new Gems_Email_TemplateMailer($this->escort); - - if (isset($this->project->email['automatic'])) { - $batches = $this->project->email['automatic']; - $numBatches = count($batches['mode']); - - for ($i = 0; $i < $numBatches; $i++) { - $this->_organizationId = $batches['organization'][$i]; - - if (isset($batches['days'][$i])) { - $this->_intervalDays = $batches['days'][$i]; - } - - $this->escort->loadLoginInfo($batches['user'][$i]); - - $model->setFilter($this->getFilter($batches['mode'][$i])); - - $tokensData = $model->load(); - - if (count($tokensData)) { - $tokens = array(); - - foreach ($tokensData as $tokenData) { - $tokens[] = $tokenData['gto_id_token']; - } - - $templateData = $this->getTemplate($batches['template'][$i]); - $mailer->setSubject($templateData['gmt_subject']); - $mailer->setBody($templateData['gmt_body']); - $mailer->setMethod($batches['method'][$i]); - $mailer->setFrom($batches['from'][$i]); - $mailer->setTokens($tokens); - - $mailer->process($tokensData); - } - - Gems_Auth::getInstance()->clearIdentity(); - $this->escort->session->unsetAll(); - } - } - - $this->html->append($mailer->getMessages()); - - } -} \ No newline at end of file Modified: branches/newUser/classes/Gems/Default/IndexAction.php =================================================================== --- branches/newUser/classes/Gems/Default/IndexAction.php 2011-10-25 15:34:11 UTC (rev 139) +++ branches/newUser/classes/Gems/Default/IndexAction.php 2011-10-25 15:58:01 UTC (rev 140) @@ -61,6 +61,11 @@ public $escort; /** + * @var Gems_Menu + */ + public $menu; + + /** * Extension point, use different auth adapter if needed depending on the provided formValues * * This could be an organization passed in the login-form or something else. @@ -150,8 +155,17 @@ public function loginAction() { + /** + * If already logged in, try to redirect to the first allowed and visible menu item + * if that fails, try to reroute to respondent/index + */ if (isset($this->session->user_id)) { - $this->_reroute(array('controller' => 'respondent')); + if ($menuItem = $this->menu->findFirst(array('allowed' => true, 'visible' => true))) { + $redirector = Zend_Controller_Action_HelperBroker::getStaticHelper('redirector'); + $redirector->gotoRoute($menuItem->toRouteUrl($this->getRequest())); + } else { + $this->_reroute(array('controller' => 'respondent', 'action'=>'index')); + } } // MUtil_Echo::track(get_class($this->loader->getUser('super', null))); @@ -168,10 +182,10 @@ $this->session->user_id = 2000; $this->session->user_name = $_POST['userlogin']; $this->session->user_group = 800; - $this->session->user_role = 'super'; + $this->session->user_role = 'master'; $this->session->user_organization_id = 70; $this->session->user_organization_name = 'SUPER ADMIN'; - $this->session->user_style = 'pulse'; + $this->session->user_style = 'gems'; //Als er nog geen tabellen zijn, moet dit ingesteld worden //@@TODO Nog kijken hoe beter op te lossen (met try op tabel ofzo) $this->session->allowedOrgs = array($this->session->user_organization_id=>$this->session->user_organization_name); Deleted: branches/newUser/classes/Gems/Default/MailAction.php =================================================================== --- branches/newUser/classes/Gems/Default/MailAction.php 2011-10-25 15:34:11 UTC (rev 139) +++ branches/newUser/classes/Gems/Default/MailAction.php 2011-10-25 15:58:01 UTC (rev 140) @@ -1,130 +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 Default - * @author Matijs de Jong <mj...@ma...> - * @copyright Copyright (c) 2011 Erasmus MC - * @license New BSD License - * @version $Id$ - */ - -/** - * - * @package Gems - * @subpackage Default - * @copyright Copyright (c) 2011 Erasmus MC - * @license New BSD License - * @since Class available since version 1.1 - */ -class Gems_Default_MailAction extends Gems_Controller_BrowseEditAction -{ - /** - * 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 - * parameter was added, because the most common use of action is a split between detailed - * and summarized actions. - * - * @param boolean $detailed True when the current action is not in $summarizedActions. - * @param string $action The current action. - * $return MUtil_Model_ModelAbstract - */ - public function createModel($detailed, $action) - { - $model = new MUtil_Model_TableModel('gems__mail_templates'); - $model->set('gmt_subject', 'label', $this->_('Subject')); - - if ($detailed) { - $model->set('gmt_body', - 'label', $this->_('Message'), - 'itemDisplay', array('Gems_Email_EmailFormAbstract', 'displayMailText')); - } - - return $model; - } - - public function getAutoSearchElements(MUtil_Model_ModelAbstract $model, array $data) - { - $elements = parent::getAutoSearchElements($model, $data); - $options = array('' => $this->_('(all organizations)')) + $this->util->getDbLookup()->getOrganizations(); - - $elements[] = new Zend_Form_Element_Select('org_id', array('multiOptions' => $options)); - - return $elements; - } - - protected function getDataFilter(array $data) - { - if (isset($data['org_id']) && $data['org_id']) { - $organizationId = intval($data['org_id']); - return array("LOCATE('|$organizationId|', gmt_organizations) > 0"); - } - - return parent::getDataFilter($data); - } - - public function getTopic($count = 1) - { - return $this->plural('email template', 'email templates', $count); - } - - public function getTopicTitle() - { - return $this->_('Email templates'); - } - - protected function processForm($saveLabel = null, $data = null) - { - $model = $this->getModel(); - $isNew = ! $model->applyRequest($this->getRequest())->hasFilter(); - $form = new Gems_Email_MailTemplateForm($this->escort); - - $wasSaved = $form->processRequest($this->_request); - - if ($form->hasMessages()) { - $this->addMessage($form->getMessages()); - } - - if ($wasSaved) { - $this->addMessage(sprintf($this->_('%2$u %1$s saved'), $this->getTopic($wasSaved), $wasSaved)); - $this->afterSaveRoute($form->getValues()); - - } else { - $table = new MUtil_Html_TableElement(array('class' => 'formTable')); - $table->setAsFormLayout($form, true, true); - $table['tbody'][0][0]->class = 'label'; // Is only one row with formLayout, so all in output fields get class. - if ($links = $this->createMenuLinks(10)) { - $table->tf(); // Add empty cell, no label - $linksCell = $table->tf($links); - } - - return $form; - } - } -} Copied: branches/newUser/classes/Gems/Default/MailJobAction.php (from rev 139, trunk/library/classes/Gems/Default/MailJobAction.php) =================================================================== --- branches/newUser/classes/Gems/Default/MailJobAction.php (rev 0) +++ branches/newUser/classes/Gems/Default/MailJobAction.php 2011-10-25 15:58:01 UTC (rev 140) @@ -0,0 +1,212 @@ +<?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 Default + * @author Matijs de Jong <mj...@ma...> + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @version $Id: Sample.php 203 2011-07-07 12:51:32Z matijs $ + */ + +/** + * + * + * @package Gems + * @subpackage Default + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @since Class available since version 1.4.4 + */ +class Gems_Default_MailJobAction extends Gems_Controller_ModelSnippetActionAbstract +{ + /** + * + * @var ArrayObject + */ + 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() + { + $this->createEditParameters['formTitle'] = $this->_('New automatic mail job...'); + + parent::createAction(); + } + + /** + * 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 + * parameter was added, because the most common use of action is a split between detailed + * and summarized actions. + * + * @param boolean $detailed True when the current action is not in $summarizedActions. + * @param string $action The current action. + * @return MUtil_Model_ModelAbstract + */ + protected function createModel($detailed, $action) + { + $dbLookup = $this->util->getDbLookup(); + $dbTracks = $this->util->getTrackData(); + $translated = $this->util->getTranslated(); + $empty = $translated->getEmptyDropdownArray(); + $unselected = array('' => ''); + + $model = new MUtil_Model_TableModel('gems__mail_jobs'); + + Gems_Model::setChangeFieldsByPrefix($model, 'gmj'); + + $model->set('gmj_id_message', 'label', $this->_('Template'), 'multiOptions', $unselected + $dbLookup->getMailTemplates()); + $model->set('gmj_id_user_as', 'label', $this->_('By staff member'), + 'multiOptions', $unselected + $dbLookup->getActiveStaff(), 'default', $this->escort->getCurrentUserId(), + 'description', $this->_('Used for logging and possibly from address.')); + $model->set('gmj_active', 'label', $this->_('Active'), + 'multiOptions', $translated->getYesNo(), 'elementClass', 'Checkbox', 'required', true, + 'description', $this->_('Job is only run when active.')); + + $fromMethods = $unselected + $this->getBulkMailFromOptions(); + $model->set('gmj_from_method', 'label', $this->_('From address used'), 'multiOptions', $fromMethods); + if ($detailed) { + $model->set('gmj_from_fixed', 'label', $this->_('From other'), + 'description', sprintf($this->_("Only when '%s' is '%s'."), $model->get('gmj_from_method', 'label'), end($fromMethods))); + } + $model->set('gmj_process_method', 'label', $this->_('Processing Method'), 'multiOptions', $unselected + $translated->getBulkMailProcessOptions()); + $model->set('gmj_filter_mode', 'label', $this->_('Filter for'), 'multiOptions', $unselected + $this->getBulkMailFilterOptions()); + $model->set('gmj_filter_days_between', 'label', $this->_('Days between reminders'), 'validators[]', 'Digits'); + + if ($detailed) { + $model->set('gmj_id_organization', 'label', $this->_('Organization'), 'multiOptions', $empty + $dbLookup->getOrganizations()); + $model->set('gmj_id_track', 'label', $this->_('Track'), 'multiOptions', $empty + $dbTracks->getAllTracks()); + $model->set('gmj_id_survey', 'label', $this->_('Survey'), 'multiOptions', $empty + $dbTracks->getAllSurveys()); + } + + return $model; + } + + /** + * Action for showing a delete item page + */ + public function deleteAction() + { + $this->deleteParameters['deleteQuestion'] = $this->_('Do you want to delete this mail job?'); + $this->deleteParameters['displayTitle'] = $this->deleteParameters['deleteQuestion']; + + parent::deleteAction(); + } + + /** + * Action for showing a edit item page + */ + public function editAction() + { + $this->createEditParameters['formTitle'] = $this->_('Edit automatic mail job'); + + parent::editAction(); + } + + /** + * The types of mail filters + * + * @return array + */ + protected function getBulkMailFilterOptions() + { + return array( + 'N' => $this->_('First mail'), + 'R' => $this->_('Reminder'), + ); + } + + /** + * Options for from address use. + * + * @return array + */ + protected function getBulkMailFromOptions() + { + $results['O'] = $this->_('Use organizational from address'); + + if (isset($project->email['site']) && $project->email['site']) { + $results['S'] = sprintf($this->_('Use site %s address'), $project->email['site']); + } + + $results['U'] = $this->_("Use the 'By staff member' address"); + $results['F'] = $this->_('Other'); + + return $results; + } + + /** + * Action for showing a browse page + */ + public function indexAction() + { + $this->html->h3($this->_('Automatic mail jobs')); + + $lock = $this->util->getCronJobLock(); + if ($lock->isLocked()) { + $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'))) { + $menuItem->set('label', $this->_('Turn Automatic Mail Jobs ON')); + } + } + + parent::indexAction(); + + $this->html->pInfo($this->_('With automatic mail jobs and a cron job on the server, mails can be sent without manual user action.')); + } + + /** + * Action for showing an item page + */ + public function showAction() + { + $this->showParameters['displayTitle'] = $this->_('Automatic mail job details'); + + parent::showAction(); + } +} Modified: branches/newUser/classes/Gems/Default/MailLogAction.php =================================================================== --- branches/newUser/classes/Gems/Default/MailLogAction.php 2011-10-25 15:34:11 UTC (rev 139) +++ branches/newUser/classes/Gems/Default/MailLogAction.php 2011-10-25 15:58:01 UTC (rev 140) @@ -137,7 +137,7 @@ */ public function showAction() { - $this->html->h3($this->_('Show Mail Activity Log item')); + $this->showParameters['displayTitle'] = $this->_('Show Mail Activity Log item'); // MUtil_Echo::track($this->indexParameters); parent::showAction(); Copied: branches/newUser/classes/Gems/Default/MailTemplateAction.php (from rev 139, trunk/library/classes/Gems/Default/MailTemplateAction.php) =================================================================== --- branches/newUser/classes/Gems/Default/MailTemplateAction.php (rev 0) +++ branches/newUser/classes/Gems/Default/MailTemplateAction.php 2011-10-25 15:58:01 UTC (rev 140) @@ -0,0 +1,130 @@ +<?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 Default + * @author Matijs de Jong <mj...@ma...> + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @version $Id$ + */ + +/** + * + * @package Gems + * @subpackage Default + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @since Class available since version 1.1 + */ +class Gems_Default_MailTemplateAction extends Gems_Controller_BrowseEditAction +{ + /** + * 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 + * parameter was added, because the most common use of action is a split between detailed + * and summarized actions. + * + * @param boolean $detailed True when the current action is not in $summarizedActions. + * @param string $action The current action. + * $return MUtil_Model_ModelAbstract + */ + public function createModel($detailed, $action) + { + $model = new MUtil_Model_TableModel('gems__mail_templates'); + $model->set('gmt_subject', 'label', $this->_('Subject')); + + if ($detailed) { + $model->set('gmt_body', + 'label', $this->_('Message'), + 'itemDisplay', array('Gems_Email_EmailFormAbstract', 'displayMailText')); + } + + return $model; + } + + public function getAutoSearchElements(MUtil_Model_ModelAbstract $model, array $data) + { + $elements = parent::getAutoSearchElements($model, $data); + $options = array('' => $this->_('(all organizations)')) + $this->util->getDbLookup()->getOrganizations(); + + $elements[] = new Zend_Form_Element_Select('org_id', array('multiOptions' => $options)); + + return $elements; + } + + protected function getDataFilter(array $data) + { + if (isset($data['org_id']) && $data['org_id']) { + $organizationId = intval($data['org_id']); + return array("LOCATE('|$organizationId|', gmt_organizations) > 0"); + } + + return parent::getDataFilter($data); + } + + public function getTopic($count = 1) + { + return $this->plural('email template', 'email templates', $count); + } + + public function getTopicTitle() + { + return $this->_('Email templates'); + } + + protected function processForm($saveLabel = null, $data = null) + { + $model = $this->getModel(); + $isNew = ! $model->applyRequest($this->getRequest())->hasFilter(); + $form = new Gems_Email_MailTemplateForm($this->escort); + + $wasSaved = $form->processRequest($this->_request); + + if ($form->hasMessages()) { + $this->addMessage($form->getMessages()); + } + + if ($wasSaved) { + $this->addMessage(sprintf($this->_('%2$u %1$s saved'), $this->getTopic($wasSaved), $wasSaved)); + $this->afterSaveRoute($form->getValues()); + + } else { + $table = new MUtil_Html_TableElement(array('class' => 'formTable')); + $table->setAsFormLayout($form, true, true); + $table['tbody'][0][0]->class = 'label'; // Is only one row with formLayout, so all in output fields get class. + if ($links = $this->createMenuLinks(10)) { + $table->tf(); // Add empty cell, no label + $linksCell = $table->tf($links); + } + + return $form; + } + } +} Modified: branches/newUser/classes/Gems/Default/ProjectInformationAction.php =================================================================== --- branches/newUser/classes/Gems/Default/ProjectInformationAction.php 2011-10-25 15:34:11 UTC (rev 139) +++ branches/newUser/classes/Gems/Default/ProjectInformationAction.php 2011-10-25 15:58:01 UTC (rev 140) @@ -144,7 +144,8 @@ $data[$this->_('Server OS')] = php_uname('s'); $data[$this->_('Time on server')] = date('r'); - if (file_exists($this->escort->getMaintenanceLockFilename())) { + $lock = $this->util->getMaintenanceLock(); + if ($lock->isLocked()) { $label = $this->_('Turn Maintenance Mode OFF'); } else { $label = $this->_('Turn Maintenance Mode ON'); @@ -161,14 +162,13 @@ $this->html->buttonDiv($buttonList); } + /** + * Action that switches the maintenance lock on or off. + */ public function maintenanceAction() { - $lockFile = $this->escort->getMaintenanceLockFilename(); - if (file_exists($lockFile)) { - unlink($lockFile); - } else { - touch($lockFile); - } + // Switch lock + $this->util->getMaintenanceLock()->reverse(); // Dump the existing maintenance mode messages. $this->escort->getMessenger()->clearCurrentMessages(); Modified: branches/newUser/classes/Gems/Default/RoleAction.php =================================================================== --- branches/newUser/classes/Gems/Default/RoleAction.php 2011-10-25 15:34:11 UTC (rev 139) +++ branches/newUser/classes/Gems/Default/RoleAction.php 2011-10-25 15:58:01 UTC (rev 140) @@ -120,7 +120,7 @@ $disabled = $checkbox->getAttrib('disable'); if ($disabled) { - $values = array_merge($values, $disabled); + $values = array_merge((array) $values, $disabled); } $checkbox->setValue($values); return $form; @@ -139,10 +139,23 @@ $data['grl_parents'] = implode(',', $data['grl_parents']); } + //Always add nologin privilege to 'nologin' role + if (isset($data['grl_name']) && $data['grl_name'] == 'nologin') { + $data['grl_privileges'][] = 'pr.nologin'; + } elseif (isset($data['grl_name']) && $data['grl_name'] !== 'nologin') { + //Assign islogin to all other roles + $data['grl_privileges'][] = 'pr.islogin'; + } + if (isset($data['grl_privileges'])) { $data['grl_privileges'] = implode(',', $data['grl_privileges']); } + if(isset($data['grl_name']) && $data['grl_name'] == 'master') { + $form->getElement('grl_name')->setErrors(array($this->_('Illegal name'))); + return false; + } + return true; } @@ -171,6 +184,20 @@ return $model; } + public function editAction() + { + $model = $this->getModel(); + $data = $model->loadFirst(); + + //If we try to edit master, add an error message and reroute + if (isset($data['grl_name']) && $data['grl_name']=='master') { + $this->addMessage($this->_('Editing `master` is not allowed')); + $this->_reroute(array('action'=>'index'), true); + } + + parent::editAction(); + } + public function formatLongLine($line) { if (strlen($line) > 50) { @@ -195,6 +222,10 @@ $privileges = $this->menu->getUsedPrivileges(); asort($privileges); + //don't allow to edit the pr.nologin and pr.islogin privilege + unset($privileges['pr.nologin']); + unset($privileges['pr.islogin']); + return $privileges; } Modified: branches/newUser/classes/Gems/Default/StaffAction.php =================================================================== --- branches/newUser/classes/Gems/Default/StaffAction.php 2011-10-25 15:34:11 UTC (rev 139) +++ branches/newUser/classes/Gems/Default/StaffAction.php 2011-10-25 15:58:01 UTC (rev 140) @@ -92,7 +92,7 @@ { $dbLookup = $this->util->getDbLookup(); - $model->set('gsf_id_primary_group', 'multiOptions', MUtil_Lazy::call($dbLookup->getActiveStaffGroups)); + $model->set('gsf_id_primary_group', 'multiOptions', MUtil_Lazy::call($dbLookup->getAllowedStaffGroups)); if ($new) { $model->set('gsf_id_primary_group', 'default', $dbLookup->getDefaultGroup()); } else { @@ -125,11 +125,10 @@ if ($this->escort->hasPrivilege('pr.staff.edit.all')) { $bridge->addSelect('gsf_id_organization'); - $bridge->addSelect('gsf_id_primary_group'); } else { $bridge->addExhibitor('gsf_id_organization'); - $bridge->addSelect( 'gsf_id_primary_group', 'multiOptions', $dbLookup->getAllowedStaffGroups()); } + $bridge->addSelect('gsf_id_primary_group'); $bridge->addCheckbox('gsf_logout_on_survey', 'description', $this->_('If checked the user will logoff when answering a survey.')); $bridge->addSelect('gsf_iso_lang'); Modified: branches/newUser/classes/Gems/Email/EmailFormAbstract.php =================================================================== --- branches/newUser/classes/Gems/Email/EmailFormAbstract.php 2011-10-25 15:34:11 UTC (rev 139) +++ branches/newUser/classes/Gems/Email/EmailFormAbstract.php 2011-10-25 15:58:01 UTC (rev 140) @@ -345,7 +345,7 @@ $options = $this->model->get($name, 'maxlength', 'required'); $options['label'] = $this->escort->_('Subject'); - $options['size'] = $options['maxlength']; + $options['size'] = min(array($options['maxlength'], 80)); return new Zend_Form_Element_Text($name, $options); } Modified: branches/newUser/classes/Gems/Email/MultiMailForm.php =================================================================== --- branches/newUser/classes/Gems/Email/MultiMailForm.php 2011-10-25 15:34:11 UTC (rev 139) +++ branches/newUser/classes/Gems/Email/MultiMailForm.php 2011-10-25 15:58:01 UTC (rev 140) @@ -1,31 +1,31 @@ <?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. + * * @version $Id$ * @package Gems * @subpackage Email @@ -69,15 +69,11 @@ protected function createMethodElement() { - $options = array( - 'M' => $this->escort->_('Send multiple mails per respondent, one for each checked token.'), - 'O' => $this->escort->_('Send one mail per respondent, mark all checked tokens as send.'), - 'A' => $this->escort->_('Send one mail per respondent, mark only mailed tokens as send.'), - ); + $options = $this->escort->getUtil()->getTranslated()->getBulkMailProcessOptions(); return new Zend_Form_Element_Radio('multi_method', array( 'label' => $this->escort->_('Method'), - 'multiOptions' => $options, + 'multiOptions' => $options, 'required' => true, )); } @@ -138,11 +134,11 @@ $title = null; } - return $this->_createMultiOption($tokenData, - $this->mailer->getTokenName($tokenData), - $tokenData['grs_email'], - $tokenData['survey_short'], - $title, + return $this->_createMultiOption($tokenData, + $this->mailer->getTokenName($tokenData), + $tokenData['grs_email'], + $tokenData['survey_short'], + $title, $menuFind); } @@ -202,7 +198,7 @@ $this->tokensData = $tokensData; $this->setTokenData(reset($tokensData)); - + return $this; } } Modified: branches/newUser/classes/Gems/Email/TemplateMailer.php =================================================================== --- branches/newUser/classes/Gems/Email/TemplateMailer.php 2011-10-25 15:34:11 UTC (rev 139) +++ branches/newUser/classes/Gems/Email/TemplateMailer.php 2011-10-25 15:58:01 UTC (rev 140) @@ -49,6 +49,12 @@ const MAIL_TLS = 2; /** + * + * @var Zend_Mail_Transport + */ + protected $defaultTransport = null; + + /** * @var GemsEscort $escort */ protected $escort; @@ -161,7 +167,7 @@ $mailServers[$from] = new Zend_Mail_Transport_Smtp($serverData['gms_server'], $options); } else { - $mailServers[$from] = null; + $mailServers[$from] = $this->defaultTransport; } } @@ -317,7 +323,7 @@ * @param string $from * @param string $from_name * @param array $tokenData - * @return boolean|string + * @return boolean|string String = error message from protocol. */ public function sendMail($to, $to_name, $from, $from_name, array $tokenData) { @@ -368,23 +374,39 @@ /** * Sets the body of the mail * @param string $body + * @return Gems_Email_TemplateMailer (continuation pattern) */ public function setBody($body) { $this->_body = $body; + return $this; } /** + * Set a different default transport protocol. + * + * @param Zend_Mail_Transport_Abstract $transport + * @return Gems_Email_TemplateMailer (continuation pattern) + */ + public function setDefaultTransport(Zend_Mail_Transport_Abstract $transport) + { + $this->defaultTransport = $transport; + return $this; + } + + /** * Sets sender (regular e-mail address) or one of: * 'O' - Uses the contact information of the selected organization * 'S' - Uses the site-wide contact information * 'U' - Uses the contact information of the currently logged in user * * @param string $from + * @return Gems_Email_TemplateMailer (continuation pattern) */ public function setFrom($from) { $this->_from = $from; + return $this; } /** @@ -394,15 +416,18 @@ * 'A' - Send one mail per respondent, mark only mailed tokens as send. * * @param string $method + * @return Gems_Email_TemplateMailer (continuation pattern) */ public function setMethod($method) { $this->_method = $method; + return $this; } /** * Sets the subject of the mail * @param string $subject + * @return Gems_Email_TemplateMailer (continuation pattern) */ public function setSubject($subject) { @@ -412,7 +437,6 @@ public function setTemplateId($templatedId) { $this->_templateId = $templatedId; - return $this; } @@ -438,22 +462,27 @@ } /** - * Sets a list of tokens + * Sets the li... [truncated message content] |
From: <gem...@li...> - 2011-10-25 15:34:17
|
Revision: 139 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=139&view=rev Author: michieltcs Date: 2011-10-25 15:34:11 +0000 (Tue, 25 Oct 2011) Log Message: ----------- Pass correct argument Modified Paths: -------------- trunk/library/classes/Gems/Util.php Modified: trunk/library/classes/Gems/Util.php =================================================================== --- trunk/library/classes/Gems/Util.php 2011-10-25 14:38:56 UTC (rev 138) +++ trunk/library/classes/Gems/Util.php 2011-10-25 15:34:11 UTC (rev 139) @@ -184,7 +184,7 @@ */ public function getMaintenanceLock() { - return $this->_loadClass('lockFile', null, array(GEMS_ROOT_DIR . '/var/settings/lock.txt')); + return $this->_loadClass('lockFile', true, array(GEMS_ROOT_DIR . '/var/settings/lock.txt')); } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2011-10-25 14:39:03
|
Revision: 138 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=138&view=rev Author: matijsdejong Date: 2011-10-25 14:38:56 +0000 (Tue, 25 Oct 2011) Log Message: ----------- Locks now set using LockFile object. #29 closed, mail jobs can be set on or off. Modified Paths: -------------- trunk/new_project/application/configs/project.ini Property Changed: ---------------- trunk/ Property changes on: trunk ___________________________________________________________________ Added: svn:ignore + nbproject Modified: trunk/new_project/application/configs/project.ini =================================================================== --- trunk/new_project/application/configs/project.ini 2011-10-25 14:32:10 UTC (rev 137) +++ trunk/new_project/application/configs/project.ini 2011-10-25 14:38:56 UTC (rev 138) @@ -70,26 +70,12 @@ ; testing without altering respondent e-mail ; addresses. ; site = Supply a general site FROM address. -; automatic = A series of settings for automatic e-mail sending -; organization = ID of the organization sending this batch -; user = Username to fake a login -; from = O/S/U or an actual e-mail address -; method = M/A/U -; mode = notmailed/reminder -; days = number of days between reminders -; template = ID of the template to use for the mail ;------------------------------------------------------- ; email.bcc = email.block = 0 email.bounce = 0 ; email.site = -;email.automatic.organization[] = 70 -;email.automatic.user[] = tester -;email.automatic.from[] = O -;email.automatic.method[] = M -;email.automatic.mode[] = notmailed -;email.automatic.template[] = 20 ;------------------------------------------------------- ; LAYOUT SECTION This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2011-10-25 14:32:21
|
Revision: 137 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=137&view=rev Author: matijsdejong Date: 2011-10-25 14:32:10 +0000 (Tue, 25 Oct 2011) Log Message: ----------- Locks now set using LockFile object. #29 closed, mail jobs can be set on or off. Modified Paths: -------------- trunk/library/classes/Gems/Controller/ModelSnippetActionAbstract.php trunk/library/classes/Gems/Default/CronAction.php trunk/library/classes/Gems/Default/MailJobAction.php trunk/library/classes/Gems/Default/ProjectInformationAction.php trunk/library/classes/Gems/Menu/MenuAbstract.php trunk/library/classes/Gems/Util.php trunk/library/classes/GemsEscort.php Added Paths: ----------- trunk/library/classes/Gems/Util/LockFile.php Modified: trunk/library/classes/Gems/Controller/ModelSnippetActionAbstract.php =================================================================== --- trunk/library/classes/Gems/Controller/ModelSnippetActionAbstract.php 2011-10-25 12:17:39 UTC (rev 136) +++ trunk/library/classes/Gems/Controller/ModelSnippetActionAbstract.php 2011-10-25 14:32:10 UTC (rev 137) @@ -85,6 +85,12 @@ public $escort; /** + * + * @var Gems_Menu + */ + public $menu; + + /** * The snippets used for the index action, before those in autofilter * * @var mixed String or array of snippets name Modified: trunk/library/classes/Gems/Default/CronAction.php =================================================================== --- trunk/library/classes/Gems/Default/CronAction.php 2011-10-25 12:17:39 UTC (rev 136) +++ trunk/library/classes/Gems/Default/CronAction.php 2011-10-25 14:32:10 UTC (rev 137) @@ -69,6 +69,12 @@ /** * + * @var Gems_Menu + */ + public $menu; + + /** + * * @var Zend_Session_Namespace */ public $session; @@ -83,6 +89,25 @@ public $useHtmlView = true; /** + * + * @var Gems_Util + */ + public $util; + + /** + * Action that switches the cron job lock on or off. + */ + public function cronLockAction() + { + // Switch lock + $this->util->getCronJobLock()->reverse(); + + // Redirect + $request = $this->getRequest(); + $this->_reroute($this->menu->getCurrentParent()->toRouteUrl()); + } + + /** * Loads an e-mail template * * @param integer|null $templateId @@ -106,7 +131,12 @@ public function indexAction() { $this->initHtml(); - $this->mailJob(); + + if ($this->util->getCronJobLock()->isLocked()) { + $this->html->append($this->_('Cron jobs turned off.')); + } else { + $this->mailJob(); + } } public function mailJob() @@ -165,8 +195,13 @@ } } - $this->html->append($mailer->getMessages()); + $msg = $mailer->getMessages(); + if (! $msg) { + $msg[] = $this->_('No mails sent'); + } + $this->html->append($msg); + if ($currentUser) { $this->escort->loadLoginInfo($currentUser); } else { Modified: trunk/library/classes/Gems/Default/MailJobAction.php =================================================================== --- trunk/library/classes/Gems/Default/MailJobAction.php 2011-10-25 12:17:39 UTC (rev 136) +++ trunk/library/classes/Gems/Default/MailJobAction.php 2011-10-25 14:32:10 UTC (rev 137) @@ -185,6 +185,16 @@ { $this->html->h3($this->_('Automatic mail jobs')); + $lock = $this->util->getCronJobLock(); + if ($lock->isLocked()) { + $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'))) { + $menuItem->set('label', $this->_('Turn Automatic Mail Jobs ON')); + } + } + parent::indexAction(); $this->html->pInfo($this->_('With automatic mail jobs and a cron job on the server, mails can be sent without manual user action.')); Modified: trunk/library/classes/Gems/Default/ProjectInformationAction.php =================================================================== --- trunk/library/classes/Gems/Default/ProjectInformationAction.php 2011-10-25 12:17:39 UTC (rev 136) +++ trunk/library/classes/Gems/Default/ProjectInformationAction.php 2011-10-25 14:32:10 UTC (rev 137) @@ -144,7 +144,8 @@ $data[$this->_('Server OS')] = php_uname('s'); $data[$this->_('Time on server')] = date('r'); - if (file_exists($this->escort->getMaintenanceLockFilename())) { + $lock = $this->util->getMaintenanceLock(); + if ($lock->isLocked()) { $label = $this->_('Turn Maintenance Mode OFF'); } else { $label = $this->_('Turn Maintenance Mode ON'); @@ -161,14 +162,13 @@ $this->html->buttonDiv($buttonList); } + /** + * Action that switches the maintenance lock on or off. + */ public function maintenanceAction() { - $lockFile = $this->escort->getMaintenanceLockFilename(); - if (file_exists($lockFile)) { - unlink($lockFile); - } else { - touch($lockFile); - } + // Switch lock + $this->util->getMaintenanceLock()->reverse(); // Dump the existing maintenance mode messages. $this->escort->getMessenger()->clearCurrentMessages(); Modified: trunk/library/classes/Gems/Menu/MenuAbstract.php =================================================================== --- trunk/library/classes/Gems/Menu/MenuAbstract.php 2011-10-25 12:17:39 UTC (rev 136) +++ trunk/library/classes/Gems/Menu/MenuAbstract.php 2011-10-25 14:32:10 UTC (rev 137) @@ -199,6 +199,23 @@ return $page; } + /** + * Add a menu item that is never added to the navigation tree and only shows up as a button. + * + * @param string $label + * @param string $privilege + * @param string $controller + * @param string $action + * @param array $other + * @return Gems_Menu_SubMenuItem + */ + public function addButtonOnly($label, $privilege, $controller, $action = 'index', array $other = array()) + { + $other['button_only'] = true; + + return $this->addPage($label, $privilege, $controller, $action, $other); + } + public function addContainer($label, $privilege = null, array $other = array()) { $other['label'] = $label; @@ -210,13 +227,6 @@ return $this->add($other); } - public function addButtonOnly($label, $privilege, $controller, $action = 'index', array $other = array()) - { - $other['button_only'] = true; - - return $this->addPage($label, $privilege, $controller, $action, $other); - } - /** * Add a Mail menu tree to the menu * @@ -237,6 +247,8 @@ // MAIL JOB CONTROLLER $page = $setup->addBrowsePage($this->_('Automatic mail'), 'pr.mail.job', 'mail-job'); + $page->addButtonOnly($this->_('Turn Automatic Mail Jobs OFF'), 'pr.mail.job', 'cron', 'cron-lock'); + $page->addPage($this->_('Run'), null, 'cron', 'index'); // MAIL SERVER CONTROLLER $page = $setup->addBrowsePage($this->_('Servers'), 'pr.mail.server', 'mail-server'); Added: trunk/library/classes/Gems/Util/LockFile.php =================================================================== --- trunk/library/classes/Gems/Util/LockFile.php (rev 0) +++ trunk/library/classes/Gems/Util/LockFile.php 2011-10-25 14:32:10 UTC (rev 137) @@ -0,0 +1,124 @@ +<?php + +/** + * Copyright (c) 2011, Erasmus MC + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Erasmus MC nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * + * @package Gems + * @subpackage Util + * @author Matijs de Jong <mj...@ma...> + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @version $Id: Sample.php 203 2011-07-07 12:51:32Z matijs $ + */ + +/** + * A simple file based locking mechanism. + * + * @package Gems + * @subpackage Util + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @since Class available since version 1.4.4 + */ +class Gems_Util_LockFile +{ + /** + * + * @var string + */ + protected $lockFileName; + + /** + * + * @param string $lockFileName The name of the lockfile + */ + public function __construct($lockFileName) + { + $this->lockFileName = $lockFileName; + } + + /** + * Last time the lock was set. + * + * @return MUtil_Date or null when not locked. + */ + public function getLockTime() + { + if ($this->isLocked()) { + return new MUtil_Date(filectime($this->lockFileName)); + } + } + + /** + * Returns true if this lock exists. + * + * @return boolean + */ + public function isLocked() + { + return file_exists($this->lockFileName); + } + + /** + * Lock this file and updates lock time. + * + * @return Gems_Util_LockFile (continuation pattern) + */ + public function lock() + { + touch($this->lockFileName); + return $this; + } + + /** + * Switches from lock to unlocked state. + * + * @return Gems_Util_LockFile (continuation pattern) + */ + public function reverse() + { + if ($this->isLocked()) { + $this->unlock(); + } else { + $this->lock(); + } + return $this; + } + + /** + * Unlocks this lock file by deleting it + * + * @return Gems_Util_LockFile (continuation pattern) + */ + public function unlock() + { + if ($this->isLocked()) { + unlink($this->lockFileName); + } + return $this; + } +} Modified: trunk/library/classes/Gems/Util.php =================================================================== --- trunk/library/classes/Gems/Util.php 2011-10-25 12:17:39 UTC (rev 136) +++ trunk/library/classes/Gems/Util.php 2011-10-25 14:32:10 UTC (rev 137) @@ -1,6 +1,5 @@ <?php - /** * Copyright (c) 2011, Erasmus MC * All rights reserved. @@ -117,6 +116,16 @@ return array_combine($consentTypes, $consentTypes); } + /** + * Returns the cron job lock + * + * @return Gems_Util_LockFile + */ + public function getCronJobLock() + { + return $this->_loadClass('lockFile', true, array(GEMS_ROOT_DIR . '/var/settings/cron_lock.txt')); + } + public function getCurrentURI($subpath = '') { static $uri; @@ -169,7 +178,17 @@ } /** + * Returns the maintenance lock * + * @return Gems_Util_LockFile + */ + public function getMaintenanceLock() + { + return $this->_loadClass('lockFile', null, array(GEMS_ROOT_DIR . '/var/settings/lock.txt')); + } + + /** + * * @param string $sourceAction The action to get the cache from if not the current one. * @param boolean $readonly Optional, tell the cache not to store any new values * @return Gems_Util_RequestCache Modified: trunk/library/classes/GemsEscort.php =================================================================== --- trunk/library/classes/GemsEscort.php 2011-10-25 12:17:39 UTC (rev 136) +++ trunk/library/classes/GemsEscort.php 2011-10-25 14:32:10 UTC (rev 137) @@ -1133,15 +1133,6 @@ } /** - * - * @return string Name of the file that performs the maintenance lock - */ - public function getMaintenanceLockFilename() - { - return GEMS_ROOT_DIR . '/var/settings/lock.txt'; - } - - /** * Retrieve the GemsEscort object * * @return GemsEscort @@ -1532,7 +1523,7 @@ * Check if we are in maintenance mode or not. This is triggeren by a file in the var/settings * directory with the name lock.txt */ - if (file_exists($this->getMaintenanceLockFilename())) { + if ($this->getUtil()->getMaintenanceLock()->isLocked()) { if ($this->session->user_id && $this->session->user_role !== 'master') { //Still allow logoff so we can relogin as master if (!('index' == $request->getControllerName() && 'logoff' == $request->getActionName())) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2011-10-25 12:17:46
|
Revision: 136 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=136&view=rev Author: mennodekker Date: 2011-10-25 12:17:39 +0000 (Tue, 25 Oct 2011) Log Message: ----------- project.ini login gets role 'master' with all privileges, existing 'super' user can be edited again. It is now a choice if one wants to create a group that has the master role or not. when there is no such group the right can not be assigned to staff. When decided so, the elevation of rights can be done by updating the role in the session to 'master'. Also removed obsolete methods as project Roles are not allowed since the introduction of db-storage. Modified Paths: -------------- trunk/library/classes/Gems/Default/IndexAction.php trunk/library/classes/Gems/Default/RoleAction.php trunk/library/classes/Gems/Default/StaffAction.php trunk/library/classes/Gems/Roles.php trunk/library/classes/Gems/Util/DbLookup.php trunk/library/classes/GemsEscort.php Modified: trunk/library/classes/Gems/Default/IndexAction.php =================================================================== --- trunk/library/classes/Gems/Default/IndexAction.php 2011-10-25 11:59:29 UTC (rev 135) +++ trunk/library/classes/Gems/Default/IndexAction.php 2011-10-25 12:17:39 UTC (rev 136) @@ -161,10 +161,10 @@ $this->session->user_id = 2000; $this->session->user_name = $_POST['userlogin']; $this->session->user_group = 800; - $this->session->user_role = 'super'; + $this->session->user_role = 'master'; $this->session->user_organization_id = 70; $this->session->user_organization_name = 'SUPER ADMIN'; - $this->session->user_style = 'pulse'; + $this->session->user_style = 'gems'; //Als er nog geen tabellen zijn, moet dit ingesteld worden //@@TODO Nog kijken hoe beter op te lossen (met try op tabel ofzo) $this->session->allowedOrgs = array($this->session->user_organization_id=>$this->session->user_organization_name); Modified: trunk/library/classes/Gems/Default/RoleAction.php =================================================================== --- trunk/library/classes/Gems/Default/RoleAction.php 2011-10-25 11:59:29 UTC (rev 135) +++ trunk/library/classes/Gems/Default/RoleAction.php 2011-10-25 12:17:39 UTC (rev 136) @@ -120,7 +120,7 @@ $disabled = $checkbox->getAttrib('disable'); if ($disabled) { - $values = array_merge($values, $disabled); + $values = array_merge((array) $values, $disabled); } $checkbox->setValue($values); return $form; @@ -151,6 +151,11 @@ $data['grl_privileges'] = implode(',', $data['grl_privileges']); } + if(isset($data['grl_name']) && $data['grl_name'] == 'master') { + $form->getElement('grl_name')->setErrors(array($this->_('Illegal name'))); + return false; + } + return true; } @@ -184,9 +189,9 @@ $model = $this->getModel(); $data = $model->loadFirst(); - //If we try to edit super, add an error message and reroute - if (isset($data['grl_name']) && $data['grl_name']=='super') { - $this->addMessage($this->_('Editing `super` is not allowed')); + //If we try to edit master, add an error message and reroute + if (isset($data['grl_name']) && $data['grl_name']=='master') { + $this->addMessage($this->_('Editing `master` is not allowed')); $this->_reroute(array('action'=>'index'), true); } Modified: trunk/library/classes/Gems/Default/StaffAction.php =================================================================== --- trunk/library/classes/Gems/Default/StaffAction.php 2011-10-25 11:59:29 UTC (rev 135) +++ trunk/library/classes/Gems/Default/StaffAction.php 2011-10-25 12:17:39 UTC (rev 136) @@ -92,7 +92,7 @@ { $dbLookup = $this->util->getDbLookup(); - $model->set('gsf_id_primary_group', 'multiOptions', MUtil_Lazy::call($dbLookup->getActiveStaffGroups)); + $model->set('gsf_id_primary_group', 'multiOptions', MUtil_Lazy::call($dbLookup->getAllowedStaffGroups)); if ($new) { $model->set('gsf_id_primary_group', 'default', $dbLookup->getDefaultGroup()); } else { @@ -125,11 +125,10 @@ if ($this->escort->hasPrivilege('pr.staff.edit.all')) { $bridge->addSelect('gsf_id_organization'); - $bridge->addSelect('gsf_id_primary_group'); } else { $bridge->addExhibitor('gsf_id_organization'); - $bridge->addSelect( 'gsf_id_primary_group', 'multiOptions', $dbLookup->getAllowedStaffGroups()); } + $bridge->addSelect('gsf_id_primary_group'); $bridge->addCheckbox('gsf_logout_on_survey', 'description', $this->_('If checked the user will logoff when answering a survey.')); $bridge->addSelect('gsf_iso_lang'); Modified: trunk/library/classes/Gems/Roles.php =================================================================== --- trunk/library/classes/Gems/Roles.php 2011-10-25 11:59:29 UTC (rev 135) +++ trunk/library/classes/Gems/Roles.php 2011-10-25 12:17:39 UTC (rev 136) @@ -1,6 +1,4 @@ <?php - - /** * Copyright (c) 2011, Erasmus MC * All rights reserved. @@ -26,27 +24,29 @@ * 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 Roles + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @version $Id$ */ /** - * This is the generic Roles class to be extended by the project + * This is the generic Roles class * - * It loads the ACL in four stages: + * It loads the ACL in two stages when there is no db present, otherwise it just loads from the db: * * 1. $this->loadDefaultRoles() * 2. $this->loadDefaultPrivileges() * Normally you should not touch this to make upgrading easier * - * 3. $this->loadProjectRoles() - * 4. $this->loadProjectPrivileges() - * This is where you can revoke or add privileges and/or add your own roles. * - * - * @version $Id$ - * @author user - * @filesource - * @package Gems + * @package Gems * @subpackage Roles + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @version $Id$ */ class Gems_Roles { @@ -134,15 +134,15 @@ //Voeg standaard rollen en privileges in $this->loadDefaultRoles(); $this->loadDefaultPrivileges(); - - //Voeg project rollen em privileges in - $this->loadProjectRoles(); - $this->loadProjectPrivileges(); } - //Now allow super admin all access, except for the actions that have the nologin privilege (->the login action) - // $this->_acl->allow('super'); - // $this->_acl->deny('super', null, 'pr.nologin'); + //Now allow 'master' all access, except for the actions that have the nologin privilege (->the login action) + if (!$this->_acl->hasRole('master')) { + //Add role if not already present + $this->_acl->addRole('master'); + } + $this->_acl->allow('master'); + $this->_acl->deny('master', null, 'pr.nologin'); } public function load() { @@ -222,98 +222,22 @@ } public function loadDefaultPrivileges() { + /** + * Only add the nologin role, as the others should come from the database when it is initialized + */ $this->addPrivilege('nologin', 'pr.contact.bugs', 'pr.contact.support', 'pr.nologin' - ) - ->addPrivilege('guest', - 'pr.ask', - 'pr.contact.bugs', 'pr.contact.support', - 'pr.islogin', - 'pr.respondent' - ) - // ->allow('respondent', null, array('islogin')) - ->addPrivilege('staff', - 'pr.option.edit', 'pr.option.password', - 'pr.plan', 'pr.plan.overview', 'pr.plan.token', - 'pr.project', 'pr.project.questions', - 'pr.respondent.create', 'pr.respondent.edit', - 'pr.respondent.who', //Who filled out the survey instead of just the role - 'pr.setup', - 'pr.staff', - 'pr.survey', 'pr.survey.create', - 'pr.token', 'pr.token.answers', 'pr.token.delete', 'pr.token.edit', 'pr.token.mail', 'pr.token.print', - 'pr.track', 'pr.track.create', 'pr.track.delete', 'pr.track.edit' - ) - ->addPrivilege('researcher', - 'pr.invitation', - 'pr.result', - 'pr.islogin' - ) - // ->allow('security', null, array()) - ->addPrivilege('admin', - 'pr.consent', 'pr.consent.create', 'pr.consent.edit', - 'pr.group', - 'pr.role', - 'pr.mail', 'pr.mail.create', 'pr.mail.delete', 'pr.mail.edit', - 'pr.organization', 'pr.organization-switch', - 'pr.plan.overview.excel', 'pr.plan.respondent', 'pr.plan.respondent.excel', 'pr.plan.token.excel', - 'pr.project-information', - 'pr.reception', 'pr.reception.create', 'pr.reception.edit', - 'pr.respondent.choose-org', 'pr.respondent.delete', - 'pr.respondent.result', //Show the result of the survey in the overview - 'pr.source', - 'pr.staff.create', 'pr.staff.delete', 'pr.staff.edit', - 'pr.survey-maintenance', - 'pr.track-maintenance', - 'pr.token.mail.freetext' - ) - ->addPrivilege('super', - 'pr.consent.delete', - 'pr.country', 'pr.country.create', 'pr.country.delete', 'pr.country.edit', - 'pr.database', 'pr.database.create', 'pr.database.delete', 'pr.database.edit', 'pr.database.execute', 'pr.database.patches', - 'pr.group.create', 'pr.group.edit', - 'pr.role.create', 'pr.role.edit', - 'pr.language', - 'pr.organization.create', 'pr.organization.edit', - 'pr.plan.choose-org', 'pr.plan.mail-as-application', - 'pr.reception.delete', - 'pr.source.create', 'pr.source.edit', - 'pr.staff.edit.all', - 'pr.survey-maintenance.edit', - 'pr.track-maintenance.create', 'pr.track-maintenance.edit' - ); - - /* * *************************************** - * UNASSIGNED RIGHTS (by default) - * - * 'pr.group.delete' - * 'pr.organization.delete' - * 'pr.source.delete' - * 'pr.track-maintenance.delete' - * *************************************** */ + ); } public function loadDefaultRoles() { - $this->addRole(new Zend_Acl_Role('nologin')) - ->addRole(new Zend_Acl_Role('guest')) - ->addRole(new Zend_Acl_Role('respondent'), 'guest') - ->addRole(new Zend_Acl_Role('staff'), 'guest') - ->addRole(new Zend_Acl_Role('physician'), 'staff') - ->addRole(new Zend_Acl_Role('researcher')) - ->addRole(new Zend_Acl_Role('security'), 'guest') - ->addRole(new Zend_Acl_Role('admin'), array('staff', 'researcher', 'security')) - ->addRole(new Zend_Acl_Role('super'), 'admin'); + /** + * Only add the nologin role, as the others should come from the database when it is initialized + */ + $this->addRole(new Zend_Acl_Role('nologin')); } - public function loadProjectPrivileges() { - - } - - public function loadProjectRoles() { - - } - private function save() { if ($this->_cache instanceof Zend_Cache_Core) { if (!$this->_cache->save($this->_acl, $this->_cacheid, array(), null)) Modified: trunk/library/classes/Gems/Util/DbLookup.php =================================================================== --- trunk/library/classes/Gems/Util/DbLookup.php 2011-10-25 11:59:29 UTC (rev 135) +++ trunk/library/classes/Gems/Util/DbLookup.php 2011-10-25 12:17:39 UTC (rev 136) @@ -131,7 +131,7 @@ public function getAllowedStaffGroups() { $groups = $this->getActiveStaffGroups(); - if ($this->session->user_role === 'super') { + if ($this->session->user_role === 'master') { return $groups; } else { Modified: trunk/library/classes/GemsEscort.php =================================================================== --- trunk/library/classes/GemsEscort.php 2011-10-25 11:59:29 UTC (rev 135) +++ trunk/library/classes/GemsEscort.php 2011-10-25 12:17:39 UTC (rev 136) @@ -1533,8 +1533,8 @@ * directory with the name lock.txt */ if (file_exists($this->getMaintenanceLockFilename())) { - if ($this->session->user_id && $this->session->user_role !== 'super') { - //Still allow logoff so we can relogin as super + if ($this->session->user_id && $this->session->user_role !== 'master') { + //Still allow logoff so we can relogin as master if (!('index' == $request->getControllerName() && 'logoff' == $request->getActionName())) { $this->setError( $this->_('Please check back later.'), This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2011-10-25 11:59:39
|
Revision: 135 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=135&view=rev Author: matijsdejong Date: 2011-10-25 11:59:29 +0000 (Tue, 25 Oct 2011) Log Message: ----------- Updated translations Modified Paths: -------------- trunk/library/languages/default-en.mo trunk/library/languages/default-en.po trunk/library/languages/default-nl.mo trunk/library/languages/default-nl.po Modified: trunk/library/languages/default-en.mo =================================================================== (Binary files differ) Modified: trunk/library/languages/default-en.po =================================================================== --- trunk/library/languages/default-en.po 2011-10-24 17:16:04 UTC (rev 134) +++ trunk/library/languages/default-en.po 2011-10-25 11:59:29 UTC (rev 135) @@ -2,9 +2,9 @@ msgstr "" "Project-Id-Version: Pulse EN\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2011-10-24 13:32+0100\n" +"POT-Creation-Date: 2011-10-25 13:52+0100\n" "PO-Revision-Date: \n" -"Last-Translator: Menno Dekker <men...@er...>\n" +"Last-Translator: Matijs de Jong <mj...@ma...>\n" "Language-Team: Erasmus MGZ <mat...@ma...>\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -477,7 +477,7 @@ msgid "Cancel" msgstr "Cancel" -#: classes/Gems/Controller/ModelSnippetActionAbstract.php:168 +#: classes/Gems/Controller/ModelSnippetActionAbstract.php:175 msgid "No data found." msgstr "No data found." @@ -950,7 +950,7 @@ msgstr "Export data" #: classes/Gems/Default/ExportAction.php:155 -#: classes/Gems/Default/MailJobAction.php:121 +#: classes/Gems/Default/MailJobAction.php:122 msgid "Survey" msgstr "Survey" @@ -960,7 +960,7 @@ msgstr "%s records found." #: classes/Gems/Default/ExportAction.php:174 -#: classes/Gems/Default/MailJobAction.php:119 +#: classes/Gems/Default/MailJobAction.php:120 msgid "Organization" msgstr "Organization" @@ -1199,43 +1199,55 @@ msgid "Filter for" msgstr "Filter for" -#: classes/Gems/Default/MailJobAction.php:132 +#: classes/Gems/Default/MailJobAction.php:117 +msgid "Days between reminders" +msgstr "Days between reminders" + +#: classes/Gems/Default/MailJobAction.php:133 +msgid "Do you want to delete this mail job?" +msgstr "Do you want to delete this mail job?" + +#: classes/Gems/Default/MailJobAction.php:144 msgid "Edit automatic mail job" msgstr "Edit automatic mail job" -#: classes/Gems/Default/MailJobAction.php:145 +#: classes/Gems/Default/MailJobAction.php:157 msgid "First mail" msgstr "First mail" -#: classes/Gems/Default/MailJobAction.php:146 +#: classes/Gems/Default/MailJobAction.php:158 msgid "Reminder" msgstr "Reminder" -#: classes/Gems/Default/MailJobAction.php:157 +#: classes/Gems/Default/MailJobAction.php:169 msgid "Use organizational from address" msgstr "Use organizational from address" -#: classes/Gems/Default/MailJobAction.php:160 +#: classes/Gems/Default/MailJobAction.php:172 #, php-format msgid "Use site %s address" msgstr "Use site %s address" -#: classes/Gems/Default/MailJobAction.php:163 +#: classes/Gems/Default/MailJobAction.php:175 msgid "Use the 'By staff member' address" msgstr "Use the 'By staff member' address" -#: classes/Gems/Default/MailJobAction.php:164 +#: classes/Gems/Default/MailJobAction.php:176 msgid "Other" msgstr "Other" -#: classes/Gems/Default/MailJobAction.php:174 +#: classes/Gems/Default/MailJobAction.php:186 msgid "Automatic mail jobs" msgstr "Automatic mail jobs" -#: classes/Gems/Default/MailJobAction.php:178 +#: classes/Gems/Default/MailJobAction.php:190 msgid "With automatic mail jobs and a cron job on the server, mails can be sent without manual user action." msgstr "With automatic mail jobs and a cron job on the server, mails can be sent without manual user action." +#: classes/Gems/Default/MailJobAction.php:198 +msgid "Automatic mail job details" +msgstr "Automatic mail job details" + #: classes/Gems/Default/MailLogAction.php:107 msgid "Date sent" msgstr "Date sent" @@ -2527,12 +2539,12 @@ msgstr "Last contact" #: classes/Gems/Email/OneMailForm.php:131 -#: classes/Gems/Email/TemplateMailer.php:211 +#: classes/Gems/Email/TemplateMailer.php:217 msgid "The sending of emails was blocked for this installation." msgstr "The sending of emails was blocked for this installation." #: classes/Gems/Email/OneMailForm.php:140 -#: classes/Gems/Email/TemplateMailer.php:244 +#: classes/Gems/Email/TemplateMailer.php:250 msgid "Mail failed to send." msgstr "Mail failed to send." @@ -2541,7 +2553,7 @@ msgid "Sent email to %s." msgstr "Sent email to %s." -#: classes/Gems/Email/TemplateMailer.php:260 +#: classes/Gems/Email/TemplateMailer.php:266 #, php-format msgid "Sent %d e-mails, updated %d tokens." msgstr "Sent %d e-mails, updated %d tokens." @@ -3115,12 +3127,10 @@ msgstr "Decrease" #: classes/Gems/Tracker/Source/LimeSurvey1m9FieldMap.php:151 -#: classes/Gems/Util/Translated.php:201 msgid "Female" msgstr "Female" #: classes/Gems/Tracker/Source/LimeSurvey1m9FieldMap.php:152 -#: classes/Gems/Util/Translated.php:201 msgid "Male" msgstr "Male" @@ -3332,6 +3342,10 @@ msgid "Input error! Changes to %s not saved!" msgstr "Input error! Changes to %s not saved!" +#: classes/MUtil/Snippets/ModelYesNoDeleteSnippetAbstract.php:108 +msgid "Do you really want to delete this item?" +msgstr "Do you really want to delete this item?" + #: languages/FakeTranslations.php:40 msgid "Value is required and can't be empty" msgstr "Value is required and can't be empty" @@ -3487,24 +3501,19 @@ msgstr "Track deleted." #: snippets/DeleteSingleSurveyInSourceTokenSnippet.php:177 -#: snippets/DeleteSingleSurveyNotUsedTokenSnippet.php:143 -#: snippets/DeleteTrackTokenSnippet.php:187 msgid "Edit token" msgstr "Edit token" #: snippets/DeleteSingleSurveyInSourceTokenSnippet.php:225 -#: snippets/DeleteTrackTokenSnippet.php:236 #, php-format msgid "Redo of token %s." msgstr "Redo of token %s." #: snippets/DeleteSingleSurveyInSourceTokenSnippet.php:228 -#: snippets/DeleteTrackTokenSnippet.php:239 msgid "Old comment:" msgstr "Old comment:" #: snippets/DeleteSingleSurveyInSourceTokenSnippet.php:249 -#: snippets/DeleteTrackTokenSnippet.php:260 #, php-format msgid "Created replacement token %2$s for token %1$s." msgstr "Created replacement token %2$s for token %1$s." @@ -3519,6 +3528,7 @@ msgstr "Deleted token %s for survey %s." #: snippets/DeleteTrackTokenSnippet.php:277 +#: snippets/EditTrackTokenSnippet.php:174 #, php-format msgid "%d token changed by recalculation." msgid_plural "%d tokens changed by recalculation." @@ -3530,6 +3540,7 @@ msgstr "Lists choices changed." #: snippets/EditSingleSurveyTokenSnippet.php:132 +#: snippets/ShowSingleSurveyTokenSnippet.php:150 msgid "Show survey" msgstr "Show survey" @@ -3585,7 +3596,6 @@ msgstr "Selected surveys" #: snippets/ShowSingleSurveyTokenSnippet.php:76 -#: snippets/ShowTrackTokenSnippet.php:77 msgid "Actions" msgstr "Actions" @@ -3636,9 +3646,8 @@ msgid "This track can be assigned since %s." msgstr "This track can be assigned since %s." -#: views/scripts/index/login.phtml:12 -msgid "The Pulse software was made possible thanks to support from " -msgstr "The Pulse software was made possible thanks to support from " +#~ msgid "The Pulse software was made possible thanks to support from " +#~ msgstr "The Pulse software was made possible thanks to support from " #~ msgid "Activity" #~ msgstr "Activity" Modified: trunk/library/languages/default-nl.mo =================================================================== (Binary files differ) Modified: trunk/library/languages/default-nl.po =================================================================== --- trunk/library/languages/default-nl.po 2011-10-24 17:16:04 UTC (rev 134) +++ trunk/library/languages/default-nl.po 2011-10-25 11:59:29 UTC (rev 135) @@ -2,9 +2,9 @@ msgstr "" "Project-Id-Version: Pulse NL\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2011-10-24 13:33+0100\n" +"POT-Creation-Date: 2011-10-25 13:52+0100\n" "PO-Revision-Date: \n" -"Last-Translator: Menno Dekker <men...@er...>\n" +"Last-Translator: Matijs de Jong <mj...@ma...>\n" "Language-Team: Erasmus MGZ <mat...@ma...>\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -388,7 +388,7 @@ #: classes/Gems/Controller/BrowseEditAction.php:344 #, php-format msgid "New %s..." -msgstr "Nieuwe %s..." +msgstr "Nieuw %s..." #: classes/Gems/Controller/BrowseEditAction.php:376 #, php-format @@ -477,7 +477,7 @@ msgid "Cancel" msgstr "Annuleren" -#: classes/Gems/Controller/ModelSnippetActionAbstract.php:168 +#: classes/Gems/Controller/ModelSnippetActionAbstract.php:175 msgid "No data found." msgstr "Geen gegevens gevonden." @@ -950,7 +950,7 @@ msgstr "Exporteer gegevens" #: classes/Gems/Default/ExportAction.php:155 -#: classes/Gems/Default/MailJobAction.php:121 +#: classes/Gems/Default/MailJobAction.php:122 msgid "Survey" msgstr "Vragenlijst" @@ -960,7 +960,7 @@ msgstr "%s records gevonden." #: classes/Gems/Default/ExportAction.php:174 -#: classes/Gems/Default/MailJobAction.php:119 +#: classes/Gems/Default/MailJobAction.php:120 msgid "Organization" msgstr "Organisatie" @@ -1155,11 +1155,11 @@ #: classes/Gems/Default/MailJobAction.php:63 msgid "No automatic mail jobs found..." -msgstr "" +msgstr "Geen automatische mail opdrachten gevonden.." #: classes/Gems/Default/MailJobAction.php:73 msgid "New automatic mail job..." -msgstr "" +msgstr "Nieuwe automatische mail opdracht..." #: classes/Gems/Default/MailJobAction.php:101 #: classes/Gems/Default/MailLogAction.php:116 @@ -1167,78 +1167,87 @@ msgstr "Sjabloon" #: classes/Gems/Default/MailJobAction.php:102 -#, fuzzy msgid "By staff member" -msgstr "medewerker" +msgstr "Door medewerke" #: classes/Gems/Default/MailJobAction.php:104 msgid "Used for logging and possibly from address." -msgstr "" +msgstr "Gebruikt voor activiteiten log en eventueel voor vanaf adres." #: classes/Gems/Default/MailJobAction.php:107 msgid "Job is only run when active." -msgstr "" +msgstr "Een opdracht wordt alleen uitgevoerd als deze actief is." #: classes/Gems/Default/MailJobAction.php:110 -#, fuzzy msgid "From address used" -msgstr "Adres van" +msgstr "Gebruikte vanaf adres" #: classes/Gems/Default/MailJobAction.php:112 msgid "From other" -msgstr "" +msgstr "Vanaf overig" #: classes/Gems/Default/MailJobAction.php:113 #, php-format msgid "Only when '%s' is '%s'." -msgstr "" +msgstr "Aleen als '%s' is '%s'." #: classes/Gems/Default/MailJobAction.php:115 msgid "Processing Method" -msgstr "" +msgstr "Verwerkings methode" #: classes/Gems/Default/MailJobAction.php:116 msgid "Filter for" -msgstr "" +msgstr "Selecteer op" -#: classes/Gems/Default/MailJobAction.php:132 +#: classes/Gems/Default/MailJobAction.php:117 +msgid "Days between reminders" +msgstr "Aantal dagen tussen herinneringen" + +#: classes/Gems/Default/MailJobAction.php:133 +msgid "Do you want to delete this mail job?" +msgstr "Weet je zeker dat deze automatische mail opdracht verwijderd moet worden?" + +#: classes/Gems/Default/MailJobAction.php:144 msgid "Edit automatic mail job" -msgstr "" +msgstr "Automatische mail opdracht bewerken" -#: classes/Gems/Default/MailJobAction.php:145 -#, fuzzy +#: classes/Gems/Default/MailJobAction.php:157 msgid "First mail" -msgstr "Voornaam" +msgstr "Eerste mail" -#: classes/Gems/Default/MailJobAction.php:146 +#: classes/Gems/Default/MailJobAction.php:158 msgid "Reminder" msgstr "Herinnering" -#: classes/Gems/Default/MailJobAction.php:157 +#: classes/Gems/Default/MailJobAction.php:169 msgid "Use organizational from address" -msgstr "" +msgstr "Gebruik vanaf adres van organisatie" -#: classes/Gems/Default/MailJobAction.php:160 +#: classes/Gems/Default/MailJobAction.php:172 #, php-format msgid "Use site %s address" -msgstr "" +msgstr "Gebruik %s adres van de site" -#: classes/Gems/Default/MailJobAction.php:163 +#: classes/Gems/Default/MailJobAction.php:175 msgid "Use the 'By staff member' address" -msgstr "" +msgstr "Gebruik 'Door medewerker' adres" -#: classes/Gems/Default/MailJobAction.php:164 +#: classes/Gems/Default/MailJobAction.php:176 msgid "Other" msgstr "Overige" -#: classes/Gems/Default/MailJobAction.php:174 +#: classes/Gems/Default/MailJobAction.php:186 msgid "Automatic mail jobs" -msgstr "" +msgstr "Automatische mail opdrachten " -#: classes/Gems/Default/MailJobAction.php:178 +#: classes/Gems/Default/MailJobAction.php:190 msgid "With automatic mail jobs and a cron job on the server, mails can be sent without manual user action." -msgstr "" +msgstr "Met automatische mail opdrachten en een cron opdracht op de server, kunnen mails verstuurd worden zonder dat een gebruiker actie hoeft te ondernemen." +#: classes/Gems/Default/MailJobAction.php:198 +msgid "Automatic mail job details" +msgstr "Automatische mail opdracht details" + #: classes/Gems/Default/MailLogAction.php:107 msgid "Date sent" msgstr "Verzend datum" @@ -2530,12 +2539,12 @@ msgstr "Contactdatum" #: classes/Gems/Email/OneMailForm.php:131 -#: classes/Gems/Email/TemplateMailer.php:211 +#: classes/Gems/Email/TemplateMailer.php:217 msgid "The sending of emails was blocked for this installation." msgstr "Het versturen van emails is geblokkeerd in deze installatie." #: classes/Gems/Email/OneMailForm.php:140 -#: classes/Gems/Email/TemplateMailer.php:244 +#: classes/Gems/Email/TemplateMailer.php:250 msgid "Mail failed to send." msgstr "Mail sturen mislukt." @@ -2544,7 +2553,7 @@ msgid "Sent email to %s." msgstr "Email naar %s verzonden." -#: classes/Gems/Email/TemplateMailer.php:260 +#: classes/Gems/Email/TemplateMailer.php:266 #, php-format msgid "Sent %d e-mails, updated %d tokens." msgstr "%d emails verzonden en %d kenmerken bijgewerkt." @@ -2583,7 +2592,7 @@ #: classes/Gems/Menu/MenuAbstract.php:239 msgid "Automatic mail" -msgstr "" +msgstr "Automatische mail" #: classes/Gems/Menu/MenuAbstract.php:242 msgid "Servers" @@ -3118,12 +3127,10 @@ msgstr "Afnemend" #: classes/Gems/Tracker/Source/LimeSurvey1m9FieldMap.php:151 -#: classes/Gems/Util/Translated.php:201 msgid "Female" msgstr "Vrouw" #: classes/Gems/Tracker/Source/LimeSurvey1m9FieldMap.php:152 -#: classes/Gems/Util/Translated.php:201 msgid "Male" msgstr "Man" @@ -3335,6 +3342,10 @@ msgid "Input error! Changes to %s not saved!" msgstr "Invoer fout! Veranderingen aan %s niet opgeslagen!" +#: classes/MUtil/Snippets/ModelYesNoDeleteSnippetAbstract.php:108 +msgid "Do you really want to delete this item?" +msgstr "Weet je zeker dat dit item verwijderd moet worden?" + #: languages/FakeTranslations.php:40 msgid "Value is required and can't be empty" msgstr "Verplicht veld mag niet leeg zijn" @@ -3490,24 +3501,19 @@ msgstr "Traject verwijderd." #: snippets/DeleteSingleSurveyInSourceTokenSnippet.php:177 -#: snippets/DeleteSingleSurveyNotUsedTokenSnippet.php:143 -#: snippets/DeleteTrackTokenSnippet.php:187 msgid "Edit token" msgstr "Kenmerk bewerken" #: snippets/DeleteSingleSurveyInSourceTokenSnippet.php:225 -#: snippets/DeleteTrackTokenSnippet.php:236 #, php-format msgid "Redo of token %s." msgstr "Herkansing voor kenmerk %s." #: snippets/DeleteSingleSurveyInSourceTokenSnippet.php:228 -#: snippets/DeleteTrackTokenSnippet.php:239 msgid "Old comment:" msgstr "Oude opmerkingen" #: snippets/DeleteSingleSurveyInSourceTokenSnippet.php:249 -#: snippets/DeleteTrackTokenSnippet.php:260 #, php-format msgid "Created replacement token %2$s for token %1$s." msgstr "Kenmerk %s is vervangen door het nieuwe kenmerk %s." @@ -3522,6 +3528,7 @@ msgstr "Kenmerk %s voor vragenlijsten %s is verwijderd." #: snippets/DeleteTrackTokenSnippet.php:277 +#: snippets/EditTrackTokenSnippet.php:174 #, php-format msgid "%d token changed by recalculation." msgid_plural "%d tokens changed by recalculation." @@ -3533,6 +3540,7 @@ msgstr "Keuzelijst is veranderd." #: snippets/EditSingleSurveyTokenSnippet.php:132 +#: snippets/ShowSingleSurveyTokenSnippet.php:150 msgid "Show survey" msgstr "Toon vragenlijst" @@ -3588,7 +3596,6 @@ msgstr "Geselecteerde vragenlijsten" #: snippets/ShowSingleSurveyTokenSnippet.php:76 -#: snippets/ShowTrackTokenSnippet.php:77 msgid "Actions" msgstr "Acties" @@ -3639,9 +3646,8 @@ msgid "This track can be assigned since %s." msgstr "Dit traject kan sinds %s aan een patiënt toegewezen worden." -#: views/scripts/index/login.phtml:12 -msgid "The Pulse software was made possible thanks to support from " -msgstr "De PULSE software is mede mogelijk gemaakt met steun van " +#~ msgid "The Pulse software was made possible thanks to support from " +#~ msgstr "De PULSE software is mede mogelijk gemaakt met steun van " #~ msgid "Activity" #~ msgstr "Activiteit" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2011-10-24 17:16:16
|
Revision: 134 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=134&view=rev Author: matijsdejong Date: 2011-10-24 17:16:04 +0000 (Mon, 24 Oct 2011) Log Message: ----------- #29 seems finished, test it further tomorrow and add some nice on/off options to the auto mail. Bug fix in DbLookup.php Reset super role to standard method. Modified Paths: -------------- trunk/library/changelog.txt trunk/library/classes/Gems/Default/MailJobAction.php trunk/library/classes/Gems/Email/TemplateMailer.php trunk/library/classes/Gems/Menu.php trunk/library/classes/Gems/Roles.php trunk/library/classes/Gems/Util/DbLookup.php trunk/library/configs/db/tables/gems__mail_jobs.300.sql trunk/library/controllers/EmailController.php Added Paths: ----------- trunk/library/classes/Gems/Default/CronAction.php trunk/library/classes/MUtil/Mail/ trunk/library/classes/MUtil/Mail/Transport/ trunk/library/classes/MUtil/Mail/Transport/EchoLog.php trunk/library/controllers/CronController.php Removed Paths: ------------- trunk/library/classes/Gems/Default/EmailAction.php Modified: trunk/library/changelog.txt =================================================================== --- trunk/library/changelog.txt 2011-10-24 12:06:15 UTC (rev 133) +++ trunk/library/changelog.txt 2011-10-24 17:16:04 UTC (rev 134) @@ -1,6 +1,7 @@ Important changes from 1.4.3 => 1.5 ============================================================ -MailController is now claaed MailTemplateController +MailController is now called MailTemplateController +EmailController is now called CronController (with stub for compatibility) Important changes from 1.4.2 => 1.4.3 ============================================================ Copied: trunk/library/classes/Gems/Default/CronAction.php (from rev 133, trunk/library/classes/Gems/Default/EmailAction.php) =================================================================== --- trunk/library/classes/Gems/Default/CronAction.php (rev 0) +++ trunk/library/classes/Gems/Default/CronAction.php 2011-10-24 17:16:04 UTC (rev 134) @@ -0,0 +1,217 @@ +<?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 Michiel Rook <mi...@to...> + * @package Gems + * @subpackage Default + */ + +/** + * Performs bulk-mail action, can be called from a cronjob + * + * @author Michiel Rook <mi...@to...> + * @package Gems + * @subpackage Default + */ +class Gems_Default_CronAction extends MUtil_Controller_Action +{ + /** + * + * @var Zend_Db_Adapter_Abstract + */ + public $db; + + /** + * Standard filter that must be true for every token query. + * + * @var array + */ + protected $defaultFilter = array( + 'can_email' => 1, + 'gtr_active' => 1, + 'gsu_active' => 1, + 'grc_success' => 1, + 'gto_completion_time' => NULL, + 'gto_valid_from <= CURRENT_DATE', + '(gto_valid_until IS NULL OR gto_valid_until >= CURRENT_TIMESTAMP)' + ); + + /** + * + * @var GemsEscort + */ + public $escort; + + /** + * + * @var Zend_Session_Namespace + */ + public $session; + + /** + * Set to true in child class for automatic creation of $this->html. + * + * Otherwise call $this->initHtml() + * + * @var boolean $useHtmlView + */ + public $useHtmlView = true; + + /** + * Loads an e-mail template + * + * @param integer|null $templateId + */ + protected function getTemplate($templateId) + { + return $this->db->fetchRow('SELECT * FROM gems__mail_templates WHERE gmt_id_message = ?', $templateId); + } + + /** + * Returns the login name belonging to this user. + * + * @param int $userId + * @return string + */ + protected function getUserLogin($userId) + { + return $this->db->fetchOne("SELECT gsf_login FROM gems__staff WHERE gsf_id_user = ?", $userId); + } + + public function indexAction() + { + $this->initHtml(); + $this->mailJob(); + } + + public function mailJob() + { + // Test: update `gems__tokens` set `gto_mail_sent_date` = null where `gto_mail_sent_date` > '2011-10-23' + + $currentUser = isset($this->session->user_login) ? $this->session->user_login : null; + + $model = $this->loader->getTracker()->getTokenModel(); + $mailer = new Gems_Email_TemplateMailer($this->escort); + // $mailer->setDefaultTransport(new MUtil_Mail_Transport_EchoLog()); + + $jobs = $this->db->fetchAll("SELECT * FROM gems__mail_jobs WHERE gmj_active = 1"); + + if ($jobs) { + foreach ($jobs as $job) { + $this->escort->loadLoginInfo($this->getUserLogin($job['gmj_id_user_as'])); + + // Set up filter + $filter = $this->defaultFilter; + if ($job['gmj_filter_mode'] == 'R') { + $filter[] = 'gto_mail_sent_date <= DATE_SUB(CURRENT_DATE, INTERVAL ' . $job['gmj_filter_days_between'] . ' DAY)'; + } else { + $filter['gto_mail_sent_date'] = NULL; + } + if ($job['gmj_id_organization']) { + $filter['gto_id_organization'] = $job['gmj_id_organization']; + } + if ($job['gmj_id_track']) { + $filter['gto_id_track'] = $job['gmj_id_track']; + } + if ($job['gmj_id_survey']) { + $filter['gto_id_survey'] = $job['gmj_id_survey']; + } + + $tokensData = $model->load($filter); + + if (count($tokensData)) { + $mailer->setMethod($job['gmj_process_method']); + if ($job['gmj_from_method'] == 'F') { + $mailer->setFrom($job['gmj_from_fixed']); + } else { + $mailer->setFrom($job['gmj_from_method']); + } + + $templateData = $this->getTemplate($job['gmj_id_message']); + $mailer->setSubject($templateData['gmt_subject']); + $mailer->setBody($templateData['gmt_body']); + + $mailer->setTokens(MUtil_Ra::column('gto_id_token', $tokensData)); + $mailer->process($tokensData); + } + + Gems_Auth::getInstance()->clearIdentity(); + $this->escort->session->unsetAll(); + } + } + + $this->html->append($mailer->getMessages()); + + if ($currentUser) { + $this->escort->loadLoginInfo($currentUser); + } else { + $this->escort->afterLogout(); + } + + /* + if (isset($this->project->email['automatic'])) { + $batches = $this->project->email['automatic']; + $numBatches = count($batches['mode']); + + for ($i = 0; $i < $numBatches; $i++) { + $this->_organizationId = $batches['organization'][$i]; + + if (isset($batches['days'][$i])) { + $this->_intervalDays = $batches['days'][$i]; + } + + $this->escort->loadLoginInfo($batches['user'][$i]); + + $model->setFilter($this->getFilter($batches['mode'][$i])); + + $tokensData = $model->load(); + + if (count($tokensData)) { + $tokens = array(); + + foreach ($tokensData as $tokenData) { + $tokens[] = $tokenData['gto_id_token']; + } + + $templateData = $this->getTemplate($batches['template'][$i]); + $mailer->setSubject($templateData['gmt_subject']); + $mailer->setBody($templateData['gmt_body']); + $mailer->setMethod($batches['method'][$i]); + $mailer->setFrom($batches['from'][$i]); + $mailer->setTokens($tokens); + + $mailer->process($tokensData); + } + + Gems_Auth::getInstance()->clearIdentity(); + $this->escort->session->unsetAll(); + } + } + // */ + } +} \ No newline at end of file Deleted: trunk/library/classes/Gems/Default/EmailAction.php =================================================================== --- trunk/library/classes/Gems/Default/EmailAction.php 2011-10-24 12:06:15 UTC (rev 133) +++ trunk/library/classes/Gems/Default/EmailAction.php 2011-10-24 17:16:04 UTC (rev 134) @@ -1,135 +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. - * - * @author Michiel Rook <mi...@to...> - * @package Gems - * @subpackage Default - */ - -/** - * Performs bulk-mail action, can be called from a cronjob - * - * @author Michiel Rook <mi...@to...> - * @package Gems - * @subpackage Default - */ -class Gems_Default_EmailAction extends Gems_Default_TokenPlanAction -{ - private $_organizationId = null; - private $_intervalDays = 7; - - /** - * Constructs - * @param strings $mode Either 'notmailed' or 'reminder' - */ - protected function getFilter($mode = null) - { - $filter = array( - 'can_email' => 1, - 'gto_id_organization' => $this->_organizationId, - 'gtr_active' => 1, - 'gsu_active' => 1, - 'grc_success' => 1, - 'gto_completion_time' => NULL, - '`gto_valid_from` >= DATE_ADD(CURRENT_DATE, INTERVAL -4 WEEK)', - '`gto_valid_from` <= DATE_ADD(CURRENT_DATE, INTERVAL 2 WEEK)', - '(gto_valid_until IS NULL OR gto_valid_until >= CURRENT_TIMESTAMP)' - ); - - if (isset($mode) && $mode == 'reminder') { - $filter[] = 'gto_mail_sent_date <= DATE_SUB(CURRENT_DATE, INTERVAL ' . $this->_intervalDays . ' DAY)'; - } else { - $filter['gto_mail_sent_date'] = NULL; - } - - return $filter; - } - - /** - * Loads an e-mail template - * @param integer|null $templateId - */ - protected function getTemplate($templateId) - { - $model = new MUtil_Model_TableModel('gems__mail_templates'); - - return $model->loadFirst(array('gmt_id_message' => $templateId)); - } - - public function indexAction() - { - $this->initHtml(); - - $model = $this->loader->getTracker()->getTokenModel(); - $model->setCreate(false); - - $mailer = new Gems_Email_TemplateMailer($this->escort); - - if (isset($this->project->email['automatic'])) { - $batches = $this->project->email['automatic']; - $numBatches = count($batches['mode']); - - for ($i = 0; $i < $numBatches; $i++) { - $this->_organizationId = $batches['organization'][$i]; - - if (isset($batches['days'][$i])) { - $this->_intervalDays = $batches['days'][$i]; - } - - $this->escort->loadLoginInfo($batches['user'][$i]); - - $model->setFilter($this->getFilter($batches['mode'][$i])); - - $tokensData = $model->load(); - - if (count($tokensData)) { - $tokens = array(); - - foreach ($tokensData as $tokenData) { - $tokens[] = $tokenData['gto_id_token']; - } - - $templateData = $this->getTemplate($batches['template'][$i]); - $mailer->setSubject($templateData['gmt_subject']); - $mailer->setBody($templateData['gmt_body']); - $mailer->setMethod($batches['method'][$i]); - $mailer->setFrom($batches['from'][$i]); - $mailer->setTokens($tokens); - - $mailer->process($tokensData); - } - - Gems_Auth::getInstance()->clearIdentity(); - $this->escort->session->unsetAll(); - } - } - - $this->html->append($mailer->getMessages()); - - } -} \ No newline at end of file Modified: trunk/library/classes/Gems/Default/MailJobAction.php =================================================================== --- trunk/library/classes/Gems/Default/MailJobAction.php 2011-10-24 12:06:15 UTC (rev 133) +++ trunk/library/classes/Gems/Default/MailJobAction.php 2011-10-24 17:16:04 UTC (rev 134) @@ -98,27 +98,28 @@ Gems_Model::setChangeFieldsByPrefix($model, 'gmj'); - $model->set('gmj_id_message', 'label', $this->_('Template'), 'multiOptions', $unselected + $dbLookup->getMailTemplates()); - $model->set('gmj_id_user_as', 'label', $this->_('By staff member'), + $model->set('gmj_id_message', 'label', $this->_('Template'), 'multiOptions', $unselected + $dbLookup->getMailTemplates()); + $model->set('gmj_id_user_as', 'label', $this->_('By staff member'), 'multiOptions', $unselected + $dbLookup->getActiveStaff(), 'default', $this->escort->getCurrentUserId(), 'description', $this->_('Used for logging and possibly from address.')); - $model->set('gmj_active', 'label', $this->_('Active'), + $model->set('gmj_active', 'label', $this->_('Active'), 'multiOptions', $translated->getYesNo(), 'elementClass', 'Checkbox', 'required', true, 'description', $this->_('Job is only run when active.')); $fromMethods = $unselected + $this->getBulkMailFromOptions(); - $model->set('gmj_from_method', 'label', $this->_('From address used'), 'multiOptions', $fromMethods); + $model->set('gmj_from_method', 'label', $this->_('From address used'), 'multiOptions', $fromMethods); if ($detailed) { - $model->set('gmj_from_fixed', 'label', $this->_('From other'), + $model->set('gmj_from_fixed', 'label', $this->_('From other'), 'description', sprintf($this->_("Only when '%s' is '%s'."), $model->get('gmj_from_method', 'label'), end($fromMethods))); } - $model->set('gmj_process_method', 'label', $this->_('Processing Method'), 'multiOptions', $unselected + $translated->getBulkMailProcessOptions()); - $model->set('gmj_filter_mode', 'label', $this->_('Filter for'), 'multiOptions', $unselected + $this->getBulkMailFilterOptions()); + $model->set('gmj_process_method', 'label', $this->_('Processing Method'), 'multiOptions', $unselected + $translated->getBulkMailProcessOptions()); + $model->set('gmj_filter_mode', 'label', $this->_('Filter for'), 'multiOptions', $unselected + $this->getBulkMailFilterOptions()); + $model->set('gmj_filter_days_between', 'label', $this->_('Days between reminders'), 'validators[]', 'Digits'); if ($detailed) { $model->set('gmj_id_organization', 'label', $this->_('Organization'), 'multiOptions', $empty + $dbLookup->getOrganizations()); $model->set('gmj_id_track', 'label', $this->_('Track'), 'multiOptions', $empty + $dbTracks->getAllTracks()); - $model->set('gsu_id_survey', 'label', $this->_('Survey'), 'multiOptions', $empty + $dbTracks->getAllSurveys()); + $model->set('gmj_id_survey', 'label', $this->_('Survey'), 'multiOptions', $empty + $dbTracks->getAllSurveys()); } return $model; Modified: trunk/library/classes/Gems/Email/TemplateMailer.php =================================================================== --- trunk/library/classes/Gems/Email/TemplateMailer.php 2011-10-24 12:06:15 UTC (rev 133) +++ trunk/library/classes/Gems/Email/TemplateMailer.php 2011-10-24 17:16:04 UTC (rev 134) @@ -49,6 +49,12 @@ const MAIL_TLS = 2; /** + * + * @var Zend_Mail_Transport + */ + protected $defaultTransport = null; + + /** * @var GemsEscort $escort */ protected $escort; @@ -161,7 +167,7 @@ $mailServers[$from] = new Zend_Mail_Transport_Smtp($serverData['gms_server'], $options); } else { - $mailServers[$from] = null; + $mailServers[$from] = $this->defaultTransport; } } @@ -317,7 +323,7 @@ * @param string $from * @param string $from_name * @param array $tokenData - * @return boolean|string + * @return boolean|string String = error message from protocol. */ public function sendMail($to, $to_name, $from, $from_name, array $tokenData) { @@ -368,23 +374,39 @@ /** * Sets the body of the mail * @param string $body + * @return Gems_Email_TemplateMailer (continuation pattern) */ public function setBody($body) { $this->_body = $body; + return $this; } /** + * Set a different default transport protocol. + * + * @param Zend_Mail_Transport_Abstract $transport + * @return Gems_Email_TemplateMailer (continuation pattern) + */ + public function setDefaultTransport(Zend_Mail_Transport_Abstract $transport) + { + $this->defaultTransport = $transport; + return $this; + } + + /** * Sets sender (regular e-mail address) or one of: * 'O' - Uses the contact information of the selected organization * 'S' - Uses the site-wide contact information * 'U' - Uses the contact information of the currently logged in user * * @param string $from + * @return Gems_Email_TemplateMailer (continuation pattern) */ public function setFrom($from) { $this->_from = $from; + return $this; } /** @@ -394,15 +416,18 @@ * 'A' - Send one mail per respondent, mark only mailed tokens as send. * * @param string $method + * @return Gems_Email_TemplateMailer (continuation pattern) */ public function setMethod($method) { $this->_method = $method; + return $this; } /** * Sets the subject of the mail * @param string $subject + * @return Gems_Email_TemplateMailer (continuation pattern) */ public function setSubject($subject) { @@ -412,7 +437,6 @@ public function setTemplateId($templatedId) { $this->_templateId = $templatedId; - return $this; } @@ -438,22 +462,27 @@ } /** - * Sets a list of tokens + * Sets the list of tokens that will be mailed. + * * @param string[] $tokens + * @return Gems_Email_TemplateMailer (continuation pattern) */ public function setTokens(array $tokens) { $this->_tokens = $tokens; + return $this; } /** * Sets verbose (noisy) operation * * @param boolean $verbose + * @return Gems_Email_TemplateMailer (continuation pattern) */ public function setVerbose($verbose) { $this->_verbose = $verbose; + return $this; } /** Modified: trunk/library/classes/Gems/Menu.php =================================================================== --- trunk/library/classes/Gems/Menu.php 2011-10-24 12:06:15 UTC (rev 133) +++ trunk/library/classes/Gems/Menu.php 2011-10-24 17:16:04 UTC (rev 134) @@ -551,6 +551,7 @@ $this->addButtonOnly($this->_('Changelog'), 'pr.project-information.changelog', 'project-information','changelog'); // Special page for automated e-mail cronjob + $this->addPage(null, null, 'cron', 'index'); $this->addPage(null, null, 'email', 'index'); } Modified: trunk/library/classes/Gems/Roles.php =================================================================== --- trunk/library/classes/Gems/Roles.php 2011-10-24 12:06:15 UTC (rev 133) +++ trunk/library/classes/Gems/Roles.php 2011-10-24 17:16:04 UTC (rev 134) @@ -113,7 +113,9 @@ return self::$_instanceOfSelf; } -//Reset de ACL en bouw opnieuw op + /** + * Reset de ACL en bouw opnieuw op + */ private function initAcl() { $this->_acl = new MUtil_Acl(); if (get_class(self::$_instanceOfSelf)!=='Gems_Roles') { @@ -139,8 +141,8 @@ } //Now allow super admin all access, except for the actions that have the nologin privilege (->the login action) - $this->_acl->allow('super'); - $this->_acl->deny('super', null, 'pr.nologin'); + // $this->_acl->allow('super'); + // $this->_acl->deny('super', null, 'pr.nologin'); } public function load() { Modified: trunk/library/classes/Gems/Util/DbLookup.php =================================================================== --- trunk/library/classes/Gems/Util/DbLookup.php 2011-10-24 12:06:15 UTC (rev 133) +++ trunk/library/classes/Gems/Util/DbLookup.php 2011-10-24 17:16:04 UTC (rev 134) @@ -243,7 +243,7 @@ if (! $data) { $data = $this->db->fetchPairs("SELECT gsf_id_user, CONCAT(COALESCE(gsf_last_name, '-'), ', ', COALESCE(gsf_first_name, ''), COALESCE(CONCAT(' ', gsf_surname_prefix), '')) - FROM gems__staff WHERE ORDER BY gsf_last_name, gsf_first_name, gsf_surname_prefix"); + FROM gems__staff ORDER BY gsf_last_name, gsf_first_name, gsf_surname_prefix"); } return $data; Property changes on: trunk/library/classes/MUtil/Mail ___________________________________________________________________ Added: bugtraq:url + http://survey.erasmusmc.nl/support/mantis/view.php?id=%BUGID% Added: bugtraq:number + true Added: bugtraq:logregex + #(\d+) Property changes on: trunk/library/classes/MUtil/Mail/Transport ___________________________________________________________________ Added: bugtraq:url + http://survey.erasmusmc.nl/support/mantis/view.php?id=%BUGID% Added: bugtraq:number + true Added: bugtraq:logregex + #(\d+) Added: trunk/library/classes/MUtil/Mail/Transport/EchoLog.php =================================================================== --- trunk/library/classes/MUtil/Mail/Transport/EchoLog.php (rev 0) +++ trunk/library/classes/MUtil/Mail/Transport/EchoLog.php 2011-10-24 17:16:04 UTC (rev 134) @@ -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 Mail + * @author Matijs de Jong <mj...@ma...> + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @version $Id: Sample.php 203 2011-07-07 12:51:32Z matijs $ + */ + +/** + * Zend Mail transport adapter that does not send the mail, but just echo's the output. + * + * @package MUtil + * @subpackage Mail + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @since Class available since version 1.4.4 + */ +class MUtil_Mail_Transport_EchoLog extends Zend_Mail_Transport_Abstract +{ + /** + * Send an email independent from the used transport + * + * The requisite information for the email will be found in the following + * properties: + * + * - {@link $recipients} - list of recipients (string) + * - {@link $header} - message header + * - {@link $body} - message body + */ + protected function _sendMail() + { + MUtil_Echo::r(reset($this->_headers['Subject']), reset($this->_headers['From']) . '=>' . reset($this->_headers['To'])); + } +} \ No newline at end of file Modified: trunk/library/configs/db/tables/gems__mail_jobs.300.sql =================================================================== --- trunk/library/configs/db/tables/gems__mail_jobs.300.sql 2011-10-24 12:06:15 UTC (rev 133) +++ trunk/library/configs/db/tables/gems__mail_jobs.300.sql 2011-10-24 17:16:04 UTC (rev 134) @@ -25,11 +25,12 @@ -- N => notmailed -- R => reminder gmj_filter_mode varchar(1) CHARACTER SET 'utf8' COLLATE 'utf8_general_ci' not null, + gmj_filter_days_between int unsigned not null default 7, -- Optional filters gmj_id_organization bigint unsigned null references gems__organizations (gor_id_organization), gmj_id_track int unsigned null references gems__tracks (gtr_id_track), - gsu_id_survey int unsigned null references gems__surveys (gsu_id_survey), + gmj_id_survey int unsigned null references gems__surveys (gsu_id_survey), gmj_changed timestamp not null default current_timestamp on update current_timestamp, gmj_changed_by bigint unsigned not null, Copied: trunk/library/controllers/CronController.php (from rev 133, trunk/library/controllers/EmailController.php) =================================================================== --- trunk/library/controllers/CronController.php (rev 0) +++ trunk/library/controllers/CronController.php 2011-10-24 17:16:04 UTC (rev 134) @@ -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 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 Default + * @author Michiel Rook <mi...@to...> + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @version $Id$ + */ + +/** + * This action performs automatic timed actions on the server. + * + * @package Gems + * @subpackage Default + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @since Class available since version 1.4.4 + */ +class CronController extends Gems_Default_CronAction +{ } \ No newline at end of file Modified: trunk/library/controllers/EmailController.php =================================================================== --- trunk/library/controllers/EmailController.php 2011-10-24 12:06:15 UTC (rev 133) +++ trunk/library/controllers/EmailController.php 2011-10-24 17:16:04 UTC (rev 134) @@ -25,11 +25,26 @@ * 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 Michiel Rook <mi...@to...> - * @package controllers + * + * + * @deprecated Since 1.5, use CronController + * @package Gems + * @subpackage Default + * @author Michiel Rook <mi...@to...> + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @version $Id$ */ -class EmailController extends Gems_Default_EmailAction -{ -} \ No newline at end of file +/** + * This action performs automatic timed actions on the server. + * + * @deprecated Since 1.5, use CronController + * @package Gems + * @subpackage Default + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @since Class available since version 1.4.4 + */ +class EmailController extends Gems_Default_CronAction +{ } \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2011-10-24 12:26:50
|
Revision: 133 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=133&view=rev Author: matijsdejong Date: 2011-10-24 12:06:15 +0000 (Mon, 24 Oct 2011) Log Message: ----------- Fix for difference between active staff and staff members who ever did something. Modified Paths: -------------- trunk/library/classes/Gems/Default/MailJobAction.php trunk/library/classes/Gems/Util/DbLookup.php Modified: trunk/library/classes/Gems/Default/MailJobAction.php =================================================================== --- trunk/library/classes/Gems/Default/MailJobAction.php 2011-10-24 11:58:01 UTC (rev 132) +++ trunk/library/classes/Gems/Default/MailJobAction.php 2011-10-24 12:06:15 UTC (rev 133) @@ -100,7 +100,7 @@ $model->set('gmj_id_message', 'label', $this->_('Template'), 'multiOptions', $unselected + $dbLookup->getMailTemplates()); $model->set('gmj_id_user_as', 'label', $this->_('By staff member'), - 'multiOptions', $unselected + $dbLookup->getStaff(), 'default', $this->escort->getCurrentUserId(), + 'multiOptions', $unselected + $dbLookup->getActiveStaff(), 'default', $this->escort->getCurrentUserId(), 'description', $this->_('Used for logging and possibly from address.')); $model->set('gmj_active', 'label', $this->_('Active'), 'multiOptions', $translated->getYesNo(), 'elementClass', 'Checkbox', 'required', true, Modified: trunk/library/classes/Gems/Util/DbLookup.php =================================================================== --- trunk/library/classes/Gems/Util/DbLookup.php 2011-10-24 11:58:01 UTC (rev 132) +++ trunk/library/classes/Gems/Util/DbLookup.php 2011-10-24 12:06:15 UTC (rev 133) @@ -93,6 +93,24 @@ return $organizations; } + /** + * Return key/value pairs of all active staff members + * + * @staticvar array $data + * @return array + */ + public function getActiveStaff() + { + static $data; + + if (! $data) { + $data = $this->db->fetchPairs("SELECT gsf_id_user, CONCAT(COALESCE(gsf_last_name, '-'), ', ', COALESCE(gsf_first_name, ''), COALESCE(CONCAT(' ', gsf_surname_prefix), '')) + FROM gems__staff WHERE gsf_active = 1 ORDER BY gsf_last_name, gsf_first_name, gsf_surname_prefix"); + } + + return $data; + } + public function getActiveStaffGroups() { static $groups; @@ -214,7 +232,7 @@ } /** - * Return key/value pairs of all active staff members + * Return key/value pairs of all staff members, currently active or not * * @staticvar array $data * @return array @@ -225,7 +243,7 @@ if (! $data) { $data = $this->db->fetchPairs("SELECT gsf_id_user, CONCAT(COALESCE(gsf_last_name, '-'), ', ', COALESCE(gsf_first_name, ''), COALESCE(CONCAT(' ', gsf_surname_prefix), '')) - FROM gems__staff WHERE gsf_active = 1 ORDER BY gsf_last_name, gsf_first_name, gsf_surname_prefix"); + FROM gems__staff WHERE ORDER BY gsf_last_name, gsf_first_name, gsf_surname_prefix"); } return $data; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2011-10-24 11:58:08
|
Revision: 132 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=132&view=rev Author: matijsdejong Date: 2011-10-24 11:58:01 +0000 (Mon, 24 Oct 2011) Log Message: ----------- Completed first complete version of snippet based BrowseEditAction replacement. #10 is done. 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/MUtil/Controller/ModelSnippetActionAbstract.php trunk/library/classes/MUtil/Snippets/ModelVerticalTableSnippetAbstract.php trunk/library/classes/MUtil/Snippets/Standard/ModelVerticalTableSnippet.php trunk/library/snippets/Generic/ModelItemTableSnippet.php Added Paths: ----------- trunk/library/classes/Gems/Snippets/ModelItemTableSnippetAbstract.php trunk/library/classes/Gems/Snippets/ModelItemTableSnippetGeneric.php trunk/library/classes/Gems/Snippets/ModelItemYesNoDeleteSnippetAbstract.php trunk/library/classes/Gems/Snippets/ModelItemYesNoDeleteSnippetGeneric.php trunk/library/classes/MUtil/Snippets/ModelYesNoDeleteSnippetAbstract.php trunk/library/classes/MUtil/Snippets/Standard/ModelYesNoDeleteSnippet.php trunk/library/snippets/Generic/ModelItemYesNoDeleteSnippet.php Modified: trunk/library/classes/Gems/Controller/ModelSnippetActionAbstract.php =================================================================== --- trunk/library/classes/Gems/Controller/ModelSnippetActionAbstract.php 2011-10-24 11:45:14 UTC (rev 131) +++ trunk/library/classes/Gems/Controller/ModelSnippetActionAbstract.php 2011-10-24 11:58:01 UTC (rev 132) @@ -72,7 +72,14 @@ protected $createEditSnippets = 'Generic_ModelFormSnippet'; /** + * The snippets used for the delete action. * + * @var mixed String or array of snippets name + */ + protected $deleteSnippets = 'Generic_ModelItemYesNoDeleteSnippet'; + + /** + * * @var GemsEscort */ public $escort; Modified: trunk/library/classes/Gems/Default/MailJobAction.php =================================================================== --- trunk/library/classes/Gems/Default/MailJobAction.php 2011-10-24 11:45:14 UTC (rev 131) +++ trunk/library/classes/Gems/Default/MailJobAction.php 2011-10-24 11:58:01 UTC (rev 132) @@ -125,12 +125,23 @@ } /** + * Action for showing a delete item page + */ + public function deleteAction() + { + $this->deleteParameters['deleteQuestion'] = $this->_('Do you want to delete this mail job?'); + $this->deleteParameters['displayTitle'] = $this->deleteParameters['deleteQuestion']; + + parent::deleteAction(); + } + + /** * Action for showing a edit item page */ public function editAction() { $this->createEditParameters['formTitle'] = $this->_('Edit automatic mail job'); - + parent::editAction(); } @@ -177,4 +188,14 @@ $this->html->pInfo($this->_('With automatic mail jobs and a cron job on the server, mails can be sent without manual user action.')); } + + /** + * Action for showing an item page + */ + public function showAction() + { + $this->showParameters['displayTitle'] = $this->_('Automatic mail job details'); + + parent::showAction(); + } } Modified: trunk/library/classes/Gems/Default/MailLogAction.php =================================================================== --- trunk/library/classes/Gems/Default/MailLogAction.php 2011-10-24 11:45:14 UTC (rev 131) +++ trunk/library/classes/Gems/Default/MailLogAction.php 2011-10-24 11:58:01 UTC (rev 132) @@ -137,7 +137,7 @@ */ public function showAction() { - $this->html->h3($this->_('Show Mail Activity Log item')); + $this->showParameters['displayTitle'] = $this->_('Show Mail Activity Log item'); // MUtil_Echo::track($this->indexParameters); parent::showAction(); Copied: trunk/library/classes/Gems/Snippets/ModelItemTableSnippetAbstract.php (from rev 127, trunk/library/snippets/Generic/ModelItemTableSnippet.php) =================================================================== --- trunk/library/classes/Gems/Snippets/ModelItemTableSnippetAbstract.php (rev 0) +++ trunk/library/classes/Gems/Snippets/ModelItemTableSnippetAbstract.php 2011-10-24 11:58:01 UTC (rev 132) @@ -0,0 +1,186 @@ +<?php + +/** + * Copyright (c) 2011, Erasmus MC + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Erasmus MC nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * + * @package Gems + * @subpackage Snippets + * @author Matijs de Jong <mj...@ma...> + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @version $Id$ + */ + +/** + * Displays each fields of a single item in a model in a row in a Html table + * the model set through the $model snippet parameter. + * + * @package Gems + * @subpackage Snippets + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @since Class available since version 1.2 + */ +abstract class Gems_Snippets_ModelItemTableSnippetAbstract extends MUtil_Snippets_ModelVerticalTableSnippetAbstract +{ + /** + * Shortfix to add class attribute + * + * @var string + */ + protected $class = 'displayer'; + + /** + * Optional title to display at the head of this page. + * + * @var string Optional + */ + protected $displayTitle; + + /** + * Required + * + * @var Gems_Loader + */ + protected $loader; + + /** + * Required + * + * @var Gems_Menu + */ + protected $menu; + + /** + * Required + * + * @var Zend_Controller_Request_Abstract + */ + protected $request; + + /** + * Adds rows from the model to the bridge that creates the browse table. + * + * Overrule this function to add different columns to the browse table, without + * having to recode the core table building code. + * + * @param MUtil_Model_TableBridge $bridge + * @param MUtil_Model_ModelAbstract $model + * @return void + */ + protected function addShowTableRows(MUtil_Model_VerticalTableBridge $bridge, MUtil_Model_ModelAbstract $model) + { + if ($menuItem = $this->getEditMenuItem()) { + // Add click to edit + $bridge->tbody()->onclick = array('location.href=\'', $menuItem->toHRefAttribute($this->request), '\';'); + } + + parent::addShowTableRows($bridge, $model); + } + + /** + * Finds a specific active menu item + * + * @param string $controller + * @param string $action + * @return Gems_Menu_SubMenuItem + */ + protected function findMenuItem($controller, $action = 'index') + { + return $this->menu->find(array('controller' => $controller, 'action' => $action, 'allowed' => true)); + } + + /** + * Returns an edit menu item, if access is allowed by privileges + * + * @return Gems_Menu_SubMenuItem + */ + protected function getEditMenuItem() + { + return $this->findMenuItem($this->request->getControllerName(), 'edit'); + } + + /** + * Create the snippets content + * + * This is a stub function either override getHtmlOutput() or override render() + * + * @param Zend_View_Abstract $view Just in case it is needed here + * @return MUtil_Html_HtmlInterface Something that can be rendered + */ + public function getHtmlOutput(Zend_View_Abstract $view) + { + if ($table = parent::getHtmlOutput($view)) { + if ($title = $this->getTitle()) { + $htmlDiv = MUtil_Html::div(); + + $htmlDiv->h3($title); + + $this->applyHtmlAttributes($table); + + $htmlDiv[] = $table; + + return $htmlDiv; + } else { + return $table; + } + } + } + + /** + * An optional title for the head of the page. + * + * @return string + */ + protected function getTitle() + { + return $this->displayTitle; + } + + /** + * Set the footer of the browse table. + * + * Overrule this function to set the header differently, without + * having to recode the core table building code. + * + * @param MUtil_Model_TableBridge $bridge + * @param MUtil_Model_ModelAbstract $model + * @return void + */ + protected function setShowTableFooter(MUtil_Model_VerticalTableBridge $bridge, MUtil_Model_ModelAbstract $model) + { + $controller = $this->request->getControllerName(); + + $menuList = $this->menu->getMenuList(); + $menuList->addParameterSources($bridge) + ->addByController($controller, 'index', $this->_('Cancel')) + ->addByController($controller, 'edit') + ->addByController($controller, 'delete'); + + $bridge->tfrow($menuList, array('class' => 'centerAlign')); + } +} Copied: trunk/library/classes/Gems/Snippets/ModelItemTableSnippetGeneric.php (from rev 127, trunk/library/classes/Gems/Snippets/ModelFormSnippetGeneric.php) =================================================================== --- trunk/library/classes/Gems/Snippets/ModelItemTableSnippetGeneric.php (rev 0) +++ trunk/library/classes/Gems/Snippets/ModelItemTableSnippetGeneric.php 2011-10-24 11:58:01 UTC (rev 132) @@ -0,0 +1,71 @@ +<?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 Snippets + * @author Matijs de Jong <mj...@ma...> + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @version $Id$ + */ + +/** + * Displays each fields of a single item in a model in a row in a Html table + * the model set through the $model snippet parameter. + * + * If you want to use this class "as is" use the 'Generic_ModelItemTableSnippet' snippet. + * + * This class is not in the standard snippet loading directories and does not follow + * their naming conventions, but exists only to make it simple to extend this class + * for a specific implementation. + * + * @package MUtil + * @subpackage Snippets + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @since Class available since version 1.4.4 + */ +class Gems_Snippets_ModelItemTableSnippetGeneric extends Gems_Snippets_ModelItemTableSnippetAbstract +{ + /** + * + * @var MUtil_Model_ModelAbstract + */ + protected $model; + + /** + * Creates the model + * + * @return MUtil_Model_ModelAbstract + */ + protected function createModel() + { + return $this->model; + } +} Copied: trunk/library/classes/Gems/Snippets/ModelItemYesNoDeleteSnippetAbstract.php (from rev 127, trunk/library/snippets/Generic/ModelItemTableSnippet.php) =================================================================== --- trunk/library/classes/Gems/Snippets/ModelItemYesNoDeleteSnippetAbstract.php (rev 0) +++ trunk/library/classes/Gems/Snippets/ModelItemYesNoDeleteSnippetAbstract.php 2011-10-24 11:58:01 UTC (rev 132) @@ -0,0 +1,185 @@ +<?php + +/** + * Copyright (c) 2011, Erasmus MC + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Erasmus MC nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * + * @package Gems + * @subpackage Snippets + * @author Matijs de Jong <mj...@ma...> + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @version $Id$ + */ + +/** + * Ask Yes/No conformation for deletion and deletes item when confirmed. + * + * Can be used for other uses than delete by overriding performAction(). + * + * @package Gems + * @subpackage Snippets + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @since Class available since version 1.4.4 + */ +abstract class Gems_Snippets_ModelItemYesNoDeleteSnippetAbstract extends MUtil_Snippets_ModelYesNoDeleteSnippetAbstract +{ + /** + * Shortfix to add class attribute + * + * @var string + */ + protected $class = 'displayer'; + + /** + * Optional title to display at the head of this page. + * + * @var string Optional + */ + protected $displayTitle; + + /** + * Required + * + * @var Gems_Loader + */ + protected $loader; + + /** + * Required + * + * @var Gems_Menu + */ + protected $menu; + + /** + * Required + * + * @var Zend_Controller_Request_Abstract + */ + protected $request; + + /** + * Adds rows from the model to the bridge that creates the browse table. + * + * Overrule this function to add different columns to the browse table, without + * having to recode the core table building code. + * + * @param MUtil_Model_TableBridge $bridge + * @param MUtil_Model_ModelAbstract $model + * @return void + */ + protected function addShowTableRows(MUtil_Model_VerticalTableBridge $bridge, MUtil_Model_ModelAbstract $model) + { + if ($menuItem = $this->getEditMenuItem()) { + // Add click to edit + $bridge->tbody()->onclick = array('location.href=\'', $menuItem->toHRefAttribute($this->request), '\';'); + } + + parent::addShowTableRows($bridge, $model); + } + + /** + * Finds a specific active menu item + * + * @param string $controller + * @param string $action + * @return Gems_Menu_SubMenuItem + */ + protected function findMenuItem($controller, $action = 'index') + { + return $this->menu->find(array('controller' => $controller, 'action' => $action, 'allowed' => true)); + } + + /** + * Returns an edit menu item, if access is allowed by privileges + * + * @return Gems_Menu_SubMenuItem + */ + protected function getEditMenuItem() + { + return $this->findMenuItem($this->request->getControllerName(), 'edit'); + } + + /** + * Create the snippets content + * + * This is a stub function either override getHtmlOutput() or override render() + * + * @param Zend_View_Abstract $view Just in case it is needed here + * @return MUtil_Html_HtmlInterface Something that can be rendered + */ + public function getHtmlOutput(Zend_View_Abstract $view) + { + if ($table = parent::getHtmlOutput($view)) { + if ($title = $this->getTitle()) { + $htmlDiv = MUtil_Html::div(); + + $htmlDiv->h3($title); + + $this->applyHtmlAttributes($table); + + $htmlDiv[] = $table; + + return $htmlDiv; + } else { + return $table; + } + } + } + + /** + * An optional title for the head of the page. + * + * @return string + */ + protected function getTitle() + { + return $this->displayTitle; + } + + /** + * Set the footer of the browse table. + * + * Overrule this function to set the header differently, without + * having to recode the core table building code. + * + * @param MUtil_Model_TableBridge $bridge + * @param MUtil_Model_ModelAbstract $model + * @return void + */ + protected function setShowTableFooter(MUtil_Model_VerticalTableBridge $bridge, MUtil_Model_ModelAbstract $model) + { + $footer = $bridge->tfrow(); + + $footer[] = $this->getQuestion(); + $footer[] = ' '; + $footer->actionLink(array($this->confirmParameter => 1), $this->_('Yes')); + $footer[] = ' '; + $footer->actionLink(array($this->request->getActionKey() => $this->abortAction), $this->_('No')); + } +} Copied: trunk/library/classes/Gems/Snippets/ModelItemYesNoDeleteSnippetGeneric.php (from rev 127, trunk/library/classes/Gems/Snippets/ModelFormSnippetGeneric.php) =================================================================== --- trunk/library/classes/Gems/Snippets/ModelItemYesNoDeleteSnippetGeneric.php (rev 0) +++ trunk/library/classes/Gems/Snippets/ModelItemYesNoDeleteSnippetGeneric.php 2011-10-24 11:58:01 UTC (rev 132) @@ -0,0 +1,72 @@ +<?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 Snippets + * @author Matijs de Jong <mj...@ma...> + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @version $Id$ + */ + +/** + * Ask Yes/No conformation for deletion and deletes item when confirmed. + * + * Can be used for other uses than delete by overriding performAction(). + * + * If you want to use this class "as is" use the 'Generic_ModelItemYesNoDeleteSnippet' snippet. + * + * This class is not in the standard snippet loading directories and does not follow + * their naming conventions, but exists only to make it simple to extend this class + * for a specific implementation. + * + * @package MUtil + * @subpackage Snippets + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @since Class available since version 1.4.4 + */ +class Gems_Snippets_ModelItemYesNoDeleteSnippetGeneric extends Gems_Snippets_ModelItemYesNoDeleteSnippetAbstract +{ + /** + * + * @var MUtil_Model_ModelAbstract + */ + protected $model; + + /** + * Creates the model + * + * @return MUtil_Model_ModelAbstract + */ + protected function createModel() + { + return $this->model; + } +} Modified: trunk/library/classes/MUtil/Controller/ModelSnippetActionAbstract.php =================================================================== --- trunk/library/classes/MUtil/Controller/ModelSnippetActionAbstract.php 2011-10-24 11:45:14 UTC (rev 131) +++ trunk/library/classes/MUtil/Controller/ModelSnippetActionAbstract.php 2011-10-24 11:58:01 UTC (rev 132) @@ -86,6 +86,20 @@ protected $createEditSnippets = 'ModelFormSnippet'; /** + * The parameters used for the delete action. + * + * @var array Mixed key => value array for snippet initialization + */ + protected $deleteParameters = array(); + + /** + * The snippets used for the delete action. + * + * @var mixed String or array of snippets name + */ + protected $deleteSnippets = 'ModelYesNoDeleteSnippet'; + + /** * The parameters used for the index action minus those in autofilter. * * @var array Mixed key => value array for snippet initialization @@ -211,6 +225,19 @@ } /** + * 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 Modified: trunk/library/classes/MUtil/Snippets/ModelVerticalTableSnippetAbstract.php =================================================================== --- trunk/library/classes/MUtil/Snippets/ModelVerticalTableSnippetAbstract.php 2011-10-24 11:45:14 UTC (rev 131) +++ trunk/library/classes/MUtil/Snippets/ModelVerticalTableSnippetAbstract.php 2011-10-24 11:58:01 UTC (rev 132) @@ -142,8 +142,36 @@ $bridge = new $this->bridgeClass($model); $bridge->setColumnCount($this->bridgeColumns); + $this->setShowTableHeader($bridge, $model); + $this->setShowTableFooter($bridge, $model); $this->addShowTableRows($bridge, $model); return $bridge->getTable(); } + + /** + * Set the footer of the browse table. + * + * Overrule this function to set the header differently, without + * having to recode the core table building code. + * + * @param MUtil_Model_TableBridge $bridge + * @param MUtil_Model_ModelAbstract $model + * @return void + */ + protected function setShowTableFooter(MUtil_Model_VerticalTableBridge $bridge, MUtil_Model_ModelAbstract $model) + { } + + /** + * Set the header of the browse table. + * + * Overrule this function to set the header differently, without + * having to recode the core table building code. + * + * @param MUtil_Model_TableBridge $bridge + * @param MUtil_Model_ModelAbstract $model + * @return void + */ + protected function setShowTableHeader(MUtil_Model_VerticalTableBridge $bridge, MUtil_Model_ModelAbstract $model) + { } } Added: trunk/library/classes/MUtil/Snippets/ModelYesNoDeleteSnippetAbstract.php =================================================================== --- trunk/library/classes/MUtil/Snippets/ModelYesNoDeleteSnippetAbstract.php (rev 0) +++ trunk/library/classes/MUtil/Snippets/ModelYesNoDeleteSnippetAbstract.php 2011-10-24 11:58:01 UTC (rev 132) @@ -0,0 +1,196 @@ +<?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 Snippets + * @author Matijs de Jong <mj...@ma...> + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @version $Id: Sample.php 203 2011-07-07 12:51:32Z matijs $ + */ + +/** + * Ask Yes/No conformation for deletion and deletes item when confirmed. + * + * Can be used for other uses than delete by overriding performAction(). + * + * @package MUtil + * @subpackage Snippets + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @since Class available since version 1.4.4 + */ +abstract class MUtil_Snippets_ModelYesNoDeleteSnippetAbstract extends MUtil_Snippets_ModelVerticalTableSnippetAbstract +{ + /** + * The action to go to when the user clicks 'No'. + * + * If you want to change to another controller you'll have to code it. + * + * @var string + */ + protected $abortAction = 'show'; + + /** + * @see Zend_Controller_Action_Helper_Redirector + * + * @var mixed Nothing or either an array or a string that is acceptable for Redector->gotoRoute() + */ + protected $afterSaveRouteUrl; + + /** + * The request parameter used to store the confirmation + * + * @var string Required + */ + protected $confirmParameter = 'confirmed'; + + /** + * The action to go to when the user clicks 'Yes' and the data is deleted. + * + * If you want to change to another controller you'll have to code it. + * + * @var string + */ + protected $deleteAction = 'index'; + + /** + * The question to as the user. + * + * @var sting Optional + */ + protected $deleteQuestion; + + /** + * Variable to either keep or throw away the request data + * not specified in the route. + * + * @var boolean True then the route is reset + */ + public $resetRoute = true; + + /** + * The delete question. + * + * @return string + */ + protected function getQuestion() + { + if ($this->deleteQuestion) { + return $this->deleteQuestion; + } else { + return $this->_('Do you really want to delete this item?'); + } + } + + /** + * When hasHtmlOutput() is false a snippet user should check + * for a redirectRoute. + * + * When hasHtmlOutput() is true this functions should not be called. + * + * @see Zend_Controller_Action_Helper_Redirector + * + * @return mixed Nothing or either an array or a string that is acceptable for Redector->gotoRoute() + */ + public function getRedirectRoute() + { + return $this->afterSaveRouteUrl; + } + + /** + * The place to check if the data set in the snippet is valid + * to generate the snippet. + * + * When invalid data should result in an error, you can throw it + * here but you can also perform the check in the + * checkRegistryRequestsAnswers() function from the + * {@see MUtil_Registry_TargetInterface}. + * + * @return boolean + */ + public function hasHtmlOutput() + { + if ($this->request->getParam($this->confirmParameter)) { + $this->performAction(); + + return (boolean) $this->getRedirectRoute(); + + } else { + return parent::hasHtmlOutput(); + } + } + + /** + * Overrule this function if you want to perform a different + * action than deleting when the user choose 'yes'. + */ + protected function performAction() + { + $model = $this->getModel(); + // MUtil_Echo::track($model->getFilter()); + $model->delete(); + + $this->setAfterDeleteRoute(); + } + + /** + * Set what to do when the form is 'finished'. + * + * @return MUtil_Snippets_ModelFormSnippetAbstract (continuation pattern) + */ + protected function setAfterDeleteRoute() + { + // Default is just go to the index + if ($this->deleteAction && ($this->request->getActionName() !== $this->deleteAction)) { + $this->afterSaveRouteUrl = array($this->request->getControllerKey() => $this->request->getControllerName(), $this->request->getActionKey() => $this->deleteAction); + } + } + + /** + * Set the footer of the browse table. + * + * Overrule this function to set the header differently, without + * having to recode the core table building code. + * + * @param MUtil_Model_TableBridge $bridge + * @param MUtil_Model_ModelAbstract $model + * @return void + */ + protected function setShowTableFooter(MUtil_Model_VerticalTableBridge $bridge, MUtil_Model_ModelAbstract $model) + { + $footer = $bridge->tfrow(); + + $footer[] = $this->getQuestion(); + $footer[] = ' '; + $footer->a(array($this->confirmParameter => 1), $this->_('Yes')); + $footer[] = ' '; + $footer->a(array($this->request->getActionKey() => $this->abortAction), $this->_('No')); + } +} Modified: trunk/library/classes/MUtil/Snippets/Standard/ModelVerticalTableSnippet.php =================================================================== --- trunk/library/classes/MUtil/Snippets/Standard/ModelVerticalTableSnippet.php 2011-10-24 11:45:14 UTC (rev 131) +++ trunk/library/classes/MUtil/Snippets/Standard/ModelVerticalTableSnippet.php 2011-10-24 11:58:01 UTC (rev 132) @@ -4,7 +4,7 @@ /** * Copyright (c) 2011, Erasmus MC * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright @@ -15,7 +15,7 @@ * * Neither the name of Erasmus MC nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE @@ -26,8 +26,8 @@ * 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 Snippets * @author Matijs de Jong <mj...@ma...> @@ -37,7 +37,7 @@ */ /** - * Displays each fields of a single item in a model in a row in a Html table + * Displays each field of a single item in a model in a row in a Html table * the model set through the $model snippet parameter. * * @package MUtil Added: trunk/library/classes/MUtil/Snippets/Standard/ModelYesNoDeleteSnippet.php =================================================================== --- trunk/library/classes/MUtil/Snippets/Standard/ModelYesNoDeleteSnippet.php (rev 0) +++ trunk/library/classes/MUtil/Snippets/Standard/ModelYesNoDeleteSnippet.php 2011-10-24 11:58:01 UTC (rev 132) @@ -0,0 +1,68 @@ +<?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 Snippets + * @author Matijs de Jong <mj...@ma...> + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @version $Id: Sample.php 203 2011-07-07 12:51:32Z matijs $ + */ + +/** + * Ask conformation for deletion and deletes item when confirmed. + * + * The model is set through the $model snippet parameter. + * + * @package MUtil + * @subpackage Snippets + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @since Class available since version 1.4.4 + */ +class ModelYesNoDeleteSnippet extends MUtil_Snippets_ModelYesNoDeleteSnippetAbstract +{ + /** + * + * @var MUtil_Model_ModelAbstract + */ + protected $model; + + /** + * Creates the model + * + * @return MUtil_Model_ModelAbstract + */ + protected function createModel() + { + return $this->model; + } + + +} Modified: trunk/library/snippets/Generic/ModelItemTableSnippet.php =================================================================== --- trunk/library/snippets/Generic/ModelItemTableSnippet.php 2011-10-24 11:45:14 UTC (rev 131) +++ trunk/library/snippets/Generic/ModelItemTableSnippet.php 2011-10-24 11:58:01 UTC (rev 132) @@ -39,116 +39,11 @@ * Displays each fields of a single item in a model in a row in a Html table * the model set through the $model snippet parameter. * - * @package MUtil - * @subpackage Gems + * @package Gems + * @subpackage Snippets * @copyright Copyright (c) 2011 Erasmus MC * @license New BSD License - * @since Class available since version 1.2 + * @since Class available since version 1.4.4 */ -class Generic_ModelItemTableSnippet extends MUtil_Snippets_ModelVerticalTableSnippetAbstract -{ - /** - * The PHP class used to create the VerticalTableBridge. - * - * Must be instanceof MUtil_Model_VerticalTableBridge. - * - * @var string Class name - */ - // protected $bridgeClass = 'Gems_Model_ThreeColumnTableBridge'; - - /** - * Shortfix to add class attribute - * - * @var string - */ - protected $class = 'displayer'; - - /** - * Required - * - * @var Gems_Loader - */ - protected $loader; - - /** - * Required - * - * @var Gems_Menu - */ - protected $menu; - - /** - * - * @var MUtil_Model_ModelAbstract - */ - protected $model; - - /** - * Required - * - * @var Zend_Controller_Request_Abstract - */ - protected $request; - - /** - * Adds rows from the model to the bridge that creates the browse table. - * - * Overrule this function to add different columns to the browse table, without - * having to recode the core table building code. - * - * @param MUtil_Model_TableBridge $bridge - * @param MUtil_Model_ModelAbstract $model - * @return void - */ - protected function addShowTableRows(MUtil_Model_VerticalTableBridge $bridge, MUtil_Model_ModelAbstract $model) - { - if ($menuItem = $this->getEditMenuItem()) { - // Add click to edit - $bridge->tbody()->onclick = array('location.href=\'', $menuItem->toHRefAttribute($this->request), '\';'); - } - - parent::addShowTableRows($bridge, $model); - - $controller = $this->request->getControllerName(); - - $menuList = $this->menu->getMenuList(); - $menuList->addParameterSources($bridge) - ->addByController($controller, 'index', $this->_('Cancel')) - ->addByController($controller, 'edit') - ->addByController($controller, 'delete'); - - $bridge->tfrow($menuList, array('class' => 'centerAlign')); - } - - /** - * Creates the model - * - * @return MUtil_Model_ModelAbstract - */ - protected function createModel() - { - return $this->model; - } - - /** - * Finds a specific active menu item - * - * @param string $controller - * @param string $action - * @return Gems_Menu_SubMenuItem - */ - protected function findMenuItem($controller, $action = 'index') - { - return $this->menu->find(array('controller' => $controller, 'action' => $action, 'allowed' => true)); - } - - /** - * Returns an edit menu item, if access is allowed by privileges - * - * @return Gems_Menu_SubMenuItem - */ - protected function getEditMenuItem() - { - return $this->findMenuItem($this->request->getControllerName(), 'edit'); - } -} +class Generic_ModelItemTableSnippet extends Gems_Snippets_ModelItemTableSnippetGeneric +{ } Copied: trunk/library/snippets/Generic/ModelItemYesNoDeleteSnippet.php (from rev 127, trunk/library/snippets/Generic/ModelItemTableSnippet.php) =================================================================== --- trunk/library/snippets/Generic/ModelItemYesNoDeleteSnippet.php (rev 0) +++ trunk/library/snippets/Generic/ModelItemYesNoDeleteSnippet.php 2011-10-24 11:58:01 UTC (rev 132) @@ -0,0 +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. + * + * + * @package Gems + * @subpackage Snippets + * @author Matijs de Jong <mj...@ma...> + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @version $Id$ + */ + +/** + * Displays each fields of a single item in a model in a row in a Html table + * the model set through the $model snippet parameter. + * + * @package Gems + * @subpackage Snippets + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @since Class available since version 1.4.4 + */ +class Generic_ModelItemYesNoDeleteSnippet extends Gems_Snippets_ModelItemYesNoDeleteSnippetGeneric +{ } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2011-10-24 11:53:41
|
Revision: 131 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=131&view=rev Author: mennodekker Date: 2011-10-24 11:45:14 +0000 (Mon, 24 Oct 2011) Log Message: ----------- Fixed size of email template 'subject' field to a maximum of 80 so display doesn't run off screen Modified Paths: -------------- trunk/library/classes/Gems/Email/EmailFormAbstract.php Modified: trunk/library/classes/Gems/Email/EmailFormAbstract.php =================================================================== --- trunk/library/classes/Gems/Email/EmailFormAbstract.php 2011-10-24 11:35:15 UTC (rev 130) +++ trunk/library/classes/Gems/Email/EmailFormAbstract.php 2011-10-24 11:45:14 UTC (rev 131) @@ -345,7 +345,7 @@ $options = $this->model->get($name, 'maxlength', 'required'); $options['label'] = $this->escort->_('Subject'); - $options['size'] = $options['maxlength']; + $options['size'] = min(array($options['maxlength'], 80)); return new Zend_Form_Element_Text($name, $options); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |