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-11-17 16:19:34
|
Revision: 230 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=230&view=rev Author: matijsdejong Date: 2011-11-17 16:19:26 +0000 (Thu, 17 Nov 2011) Log Message: ----------- Continued with #41 onLoad & getFormatted functionality: - onLoad() functions work - started on Model_Types, made first that works, but not yet generalized Modified Paths: -------------- trunk/library/changelog.txt trunk/library/classes/Gems/Default/OrganizationAction.php trunk/library/classes/Gems/Export/ExportModel.php trunk/library/classes/Gems/Model/DbaModel.php trunk/library/classes/Gems/Tracker/SurveyModel.php trunk/library/classes/MUtil/Lazy/ArrayAccessor.php trunk/library/classes/MUtil/Model/DatabaseModelAbstract.php trunk/library/classes/MUtil/Model/FormBridge.php trunk/library/classes/MUtil/Model/ModelAbstract.php trunk/library/classes/MUtil/Model/ModelTransformerAbstract.php trunk/library/classes/MUtil/Model/SelectModelPaginator.php trunk/library/classes/MUtil/Model/TableBridgeAbstract.php Added Paths: ----------- trunk/library/classes/MUtil/Model/Type/ trunk/library/classes/MUtil/Model/Type/ConcatenatedRow.php Removed Paths: ------------- trunk/library/classes/MUtil/Form/Element/MultiCheckbox.php trunk/library/classes/MUtil/Form/Element/MultiSelect.php trunk/library/classes/MUtil/Model/Save/ Modified: trunk/library/changelog.txt =================================================================== --- trunk/library/changelog.txt 2011-11-17 14:20:41 UTC (rev 229) +++ trunk/library/changelog.txt 2011-11-17 16:19:26 UTC (rev 230) @@ -7,6 +7,7 @@ The gems__respondent.grs_bsn has been renamed to grs_ssn, to make the code more international. MailController is now called MailTemplateController. EmailController is now called CronController (with stub for compatibility). +ModelAbstract now declares an protected _load instead of a public load abstract, for implementation of setOnLoad() functions, check your own Models for overloading load() or loadXX() functions. Important changes from 1.4.2 => 1.4.3 ============================================================ Modified: trunk/library/classes/Gems/Default/OrganizationAction.php =================================================================== --- trunk/library/classes/Gems/Default/OrganizationAction.php 2011-11-17 14:20:41 UTC (rev 229) +++ trunk/library/classes/Gems/Default/OrganizationAction.php 2011-11-17 16:19:26 UTC (rev 230) @@ -149,12 +149,11 @@ $model->set('gor_name', 'validator', $model->createUniqueValidator('gor_name')); $model->set('gor_welcome', 'label', $this->_('Greeting'), 'description', $this->_('For emails and token forward screen.'), 'elementClass', 'Textarea', 'rows', 5); $model->set('gor_signature', 'label', $this->_('Signature'), 'description', $this->_('For emails and token forward screen.'), 'elementClass', 'Textarea', 'rows', 5); - - $model->set('gor_accessible_by', 'label', $this->_('Accessible by'), 'description', $this->_('Checked organizations see this organizations respondents.'), 'elementClass', 'MultiCheckbox', - 'multiOptions', $this->util->getDbLookup()->getOrganizations()); - MUtil_Model_Save_ArraySaver::create($model, 'gor_accessible_by', ':'); - } + $model->set('gor_accessible_by', 'label', $this->_('Accessible by'), 'description', $this->_('Checked organizations see this organizations respondents.'), + 'elementClass', 'MultiCheckbox', 'multiOptions', $this->util->getDbLookup()->getOrganizations()); + $tp = new MUtil_Model_Type_ConcatenatedRow(':', ', '); + $tp->apply($model, 'gor_accessible_by'); if ($this->project->multiLocale) { $model->set('gor_name', 'description', 'ENGLISH please! Use translation file to translate.'); Modified: trunk/library/classes/Gems/Export/ExportModel.php =================================================================== --- trunk/library/classes/Gems/Export/ExportModel.php 2011-11-17 14:20:41 UTC (rev 229) +++ trunk/library/classes/Gems/Export/ExportModel.php 2011-11-17 16:19:26 UTC (rev 230) @@ -54,6 +54,22 @@ parent::__construct('export'); } + /** + * Returns a nested array containing the items requested. + * + * @param mixed $filter True to use the stored filter, array to specify a different filter + * @param mixed $sort True to use the stored sort, array to specify a different sort + * @return array Nested array or false + */ + protected function _load($filter = true, $sort = true) + { + $result = array(); + foreach ($this->getItemsOrdered() as $item) { + $result[0][$item] = $item; + } + return $result; + } + public function delete($filter = true) { return false; @@ -64,15 +80,6 @@ return false; } - public function load($filter = true, $sort = true) - { - $result = array(); - foreach ($this->getItemsOrdered() as $item) { - $result[0][$item] = $item; - } - return $result; - } - public function save(array $newValues, array $filter = null) { return $newValues; Modified: trunk/library/classes/Gems/Model/DbaModel.php =================================================================== --- trunk/library/classes/Gems/Model/DbaModel.php 2011-11-17 14:20:41 UTC (rev 229) +++ trunk/library/classes/Gems/Model/DbaModel.php 2011-11-17 16:19:26 UTC (rev 230) @@ -120,6 +120,28 @@ } } + /** + * Returns a nested array containing the items requested. + * + * @param mixed $filter True to use the stored filter, array to specify a different filter + * @param mixed $sort True to use the stored sort, array to specify a different sort + * @return array Nested array or false + */ + protected function _load($filter = true, $sort = true) + { + $data = $this->_loadAllData(); + + if ($filter) { + $data = $this->_filterData($data, $this->_checkFilterUsed($filter)); + } + + if ($sort) { + $data = $this->_sortData($data, $this->_checkSortUsed($sort)); + } + + return $data; + } + private function _loadAllData() { $tables = $this->db->listTables(); @@ -347,21 +369,6 @@ return true; } - public function load($filter = true, $sort = true) - { - $data = $this->_loadAllData(); - - if ($filter) { - $data = $this->_filterData($data, $this->_checkFilterUsed($filter)); - } - - if ($sort) { - $data = $this->_sortData($data, $this->_checkSortUsed($sort)); - } - - return $data; - } - public function loadTable($tableName) { return $this->loadFirst(array('name' => $tableName), false); Modified: trunk/library/classes/Gems/Tracker/SurveyModel.php =================================================================== --- trunk/library/classes/Gems/Tracker/SurveyModel.php 2011-11-17 14:20:41 UTC (rev 229) +++ trunk/library/classes/Gems/Tracker/SurveyModel.php 2011-11-17 16:19:26 UTC (rev 230) @@ -26,7 +26,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * + * * @package Gems * @subpackage Tracker * @author Matijs de Jong <mj...@ma...> @@ -75,6 +75,18 @@ } /** + * Returns a nested array containing the items requested. + * + * @param mixed $filter True to use the stored filter, array to specify a different filter + * @param mixed $sort True to use the stored sort, array to specify a different sort + * @return array Nested array or false + */ + protected function _load($filter = true, $sort = true) + { + return $this->addAnswers(parent::_load($filter, $sort)); + } + + /** * Returns a nested array containing the items requested, including answers. * * @param array $inputRows Nested rows with Gems token information @@ -113,18 +125,6 @@ } /** - * Returns a nested array containing the items requested. - * - * @param mixed $filter True to use the stored filter, array to specify a different filter - * @param mixed $sort True to use the stored sort, array to specify a different sort - * @return array Nested array or false - */ - public function load($filter = true, $sort = true) - { - return $this->addAnswers(parent::load($filter, $sort)); - } - - /** * Returns an array containing the first requested item. * * @param mixed $filter True to use the stored filter, array to specify a different filter @@ -145,18 +145,7 @@ */ public function loadPaginator($filter = true, $sort = true) { + // Do not use a select paginator for the moment, till we can add addAnswers() return Zend_Paginator::factory($this->load($filter, $sort)); } - - /** - * Returns a MUtil_Lazy_RepeatableInterface for the items in the model - * - * @param mixed $filter True to use the stored filter, array to specify a different filter - * @param mixed $sort True to use the stored sort, array to specify a different sort - * @return MUtil_Lazy_RepeatableInterface - */ - public function loadRepeatable($filter = true, $sort = true) - { - return MUtil_Lazy::repeat($this->load($filter, $sort)); - } } Deleted: trunk/library/classes/MUtil/Form/Element/MultiCheckbox.php =================================================================== --- trunk/library/classes/MUtil/Form/Element/MultiCheckbox.php 2011-11-17 14:20:41 UTC (rev 229) +++ trunk/library/classes/MUtil/Form/Element/MultiCheckbox.php 2011-11-17 16:19:26 UTC (rev 230) @@ -1,143 +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 MUtil - * @subpackage Form - * @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 $ - */ - -/** - * This object allows you to supply a string value when the object expects an - * array value, splitting the string along the valueSeperatorChar. - * - * Return this value as a string is not practical as that breaks the workings - * of all Filters, Validators and Decorators. - * - * @package MUtil - * @subpackage Form - * @copyright Copyright (c) 2011 Erasmus MC - * @license New BSD License - * @since Class available since version 1.5 - */ -class MUtil_Form_Element_MultiCheckbox extends Zend_Form_Element_MultiCheckbox -{ - /** - * En/disables padding the value in separators. The default is true as this - * simplifies search commands (and usually costs only 2 characters). - * - * @var boolean - */ - protected $_valuePad = true; - - /** - * The value seperator enables this control to accept a single string as value - * and split it into an array. - * - * A null seperator means this class behaves as it's parent class and returns an - * array value. - * - * @var string - */ - protected $_valueSeperatorChar = null; - - /** - * En/disables padding the value in separators. The default is true as this - * simplifies search commands (and usually costs only 2 characters). - * - * @return boolean - */ - public function getValuePad() - { - return $this->_valuePad; - } - - /** - * The value seperator enables this control to accept a single string as value - * and split it into an array. - * - * A null seperator means this class behaves as it's parent class and returns an - * array value. - * - * @return string - */ - public function getValueSeperatorChar() - { - return $this->_valueSeperatorChar; - } - - /** - * Set element value - * - * @param mixed $value - * @return MUtil_Form_Element_MultiCheckbox (continuation pattern) - */ - public function setValue($value) - { - if ((null !== $this->_valueSeperatorChar) && (! is_array($value))) { - if ($this->_valuePad) { - $value = trim($value, $this->_valueSeperatorChar); - } - $value = explode($this->_valueSeperatorChar, $value); - } - - return parent::setValue($value); - } - - /** - * En/disables padding the value in separators. The default is true as this - * simplifies search commands (and usually costs only 2 characters). - * - * @param boolean $value - * @return MUtil_Form_Element_MultiCheckbox (continuation pattern) - */ - public function setValuePad($value = true) - { - $this->_valuePad = $value; - return $this; - } - - /** - * The value seperator enables this control to accept a single string as value - * and split it into an array. - * - * A null seperator means this class behaves as it's parent class and returns an - * array value. - * - * @param string $seperator - * @return MUtil_Form_Element_MultiCheckbox (continuation pattern) - */ - public function setValueSeperatorChar($seperator = ' ') - { - $this->_valueSeperatorChar = substr($seperator . ' ', 0, 1); - return $this; - } -} Deleted: trunk/library/classes/MUtil/Form/Element/MultiSelect.php =================================================================== --- trunk/library/classes/MUtil/Form/Element/MultiSelect.php 2011-11-17 14:20:41 UTC (rev 229) +++ trunk/library/classes/MUtil/Form/Element/MultiSelect.php 2011-11-17 16:19:26 UTC (rev 230) @@ -1,143 +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 MUtil - * @subpackage Form - * @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 $ - */ - -/** - * This object allows you to supply a string value when the object expects an - * array value, splitting the string along the valueSeperatorChar. - * - * Return this value as a string is not practical as that breaks the workings - * of all Filters, Validators and Decorators. - * - * @package MUtil - * @subpackage Form - * @copyright Copyright (c) 2011 Erasmus MC - * @license New BSD License - * @since Class available since version 1.5 - */ -class MUtil_Form_Element_MultiSelect extends Zend_Form_Element_MultiSelect -{ - /** - * En/disables padding the value in separators. The default is true as this - * simplifies search commands (and usually costs only 2 characters). - * - * @var boolean - */ - protected $_valuePad = true; - - /** - * The value seperator enables this control to accept a single string as value - * and split it into an array. - * - * A null seperator means this class behaves as it's parent class and returns an - * array value. - * - * @var string - */ - protected $_valueSeperatorChar = null; - - /** - * En/disables padding the value in separators. The default is true as this - * simplifies search commands (and usually costs only 2 characters). - * - * @return boolean - */ - public function getValuePad() - { - return $this->_valuePad; - } - - /** - * The value seperator enables this control to accept a single string as value - * and split it into an array. - * - * A null seperator means this class behaves as it's parent class and returns an - * array value. - * - * @return string - */ - public function getValueSeperatorChar() - { - return $this->_valueSeperatorChar; - } - - /** - * Set element value - * - * @param mixed $value - * @return MUtil_Form_Element_MultiCheckbox (continuation pattern) - */ - public function setValue($value) - { - if ((null !== $this->_valueSeperatorChar) && (! is_array($value))) { - if ($this->_valuePad) { - $value = trim($value, $this->_valueSeperatorChar); - } - $value = explode($this->_valueSeperatorChar, $value); - } - - return parent::setValue($value); - } - - /** - * En/disables padding the value in separators. The default is true as this - * simplifies search commands (and usually costs only 2 characters). - * - * @param boolean $value - * @return MUtil_Form_Element_MultiCheckbox (continuation pattern) - */ - public function setValuePad($value = true) - { - $this->_valuePad = $value; - return $this; - } - - /** - * The value seperator enables this control to accept a single string as value - * and split it into an array. - * - * A null seperator means this class behaves as it's parent class and returns an - * array value. - * - * @param string $seperator - * @return MUtil_Form_Element_MultiCheckbox (continuation pattern) - */ - public function setValueSeperatorChar($seperator = ' ') - { - $this->_valueSeperatorChar = substr($seperator . ' ', 0, 1); - return $this; - } -} Modified: trunk/library/classes/MUtil/Lazy/ArrayAccessor.php =================================================================== --- trunk/library/classes/MUtil/Lazy/ArrayAccessor.php 2011-11-17 14:20:41 UTC (rev 229) +++ trunk/library/classes/MUtil/Lazy/ArrayAccessor.php 2011-11-17 16:19:26 UTC (rev 230) @@ -1,41 +1,49 @@ <?php - -/** - * Copyright (c) 2011, Erasmus MC - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of Erasmus MC nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - /** - * @author Matijs de Jong - * @since 1.0 - * @version 1.1 - * @package MUtil + * Copyright (c) 2011, Erasmus MC + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Erasmus MC nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * + * @package MUtil * @subpackage Lazy + * @author Matijs de Jong <mj...@ma...> + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @version $Id$ */ +/** + * + * @package MUtil + * @subpackage Lazy + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @since Class available since version 1.1 + */ + class MUtil_Lazy_ArrayAccessor extends MUtil_Lazy_LazyAbstract { private $_array; @@ -67,12 +75,22 @@ $offset = $offset->__toValue($stack); } - // MUtil_Echo::r($array, '[' . $offset . ']'); + // MUtil_Echo::track($array, 'offset', $offset); if (null === $offset) { if (isset($array[''])) { return $array['']; } + } elseif (is_array($offset)) { + // When the offset is itself an array, return an + // array of values applied to this offset. + $results = array(); + foreach ($offset as $key => $value) { + if (isset($array[$value])) { + $results[$key] = $array[$value]; + } + } + return $results; } elseif (isset($array[$offset])) { return $array[$offset]; } Modified: trunk/library/classes/MUtil/Model/DatabaseModelAbstract.php =================================================================== --- trunk/library/classes/MUtil/Model/DatabaseModelAbstract.php 2011-11-17 14:20:41 UTC (rev 229) +++ trunk/library/classes/MUtil/Model/DatabaseModelAbstract.php 2011-11-17 16:19:26 UTC (rev 230) @@ -241,7 +241,7 @@ } } - return $this->_filterDataArray($tableData, $isNew); + return $this->_filterDataForSave($tableData, $isNew); } protected function _getKeysFor($table_name) @@ -261,6 +261,18 @@ return $table->info(Zend_Db_Table_Abstract::NAME); } + /** + * Returns a nested array containing the items requested. + * + * @param mixed $filter True to use the stored filter, array to specify a different filter + * @param mixed $sort True to use the stored sort, array to specify a different sort + * @return array Nested array or false + */ + protected function _load($filter = true, $sort = true) + { + return $this->_createSelect($filter, $sort)->query(Zend_Db::FETCH_ASSOC)->fetchAll(); + } + protected function _loadTableMetaData(Zend_Db_Table_Abstract $table) { $table_name = $this->_getTableName($table); @@ -608,7 +620,7 @@ * @param array $context Optional, the other values being saved * @return Zend_Date */ - public function formatSaveDate($value, $isNew = false, $name = null) + public function formatSaveDate($value, $isNew = false, $name = null, array $context = array()) { if ($name && (! ((null === $value) || ($value instanceof Zend_Db_Expr)))) { if ($saveFormat = $this->get($name, 'storageFormat')) { @@ -714,18 +726,6 @@ } /** - * Returns a nested array containing the items requested. - * - * @param mixed $filter True to use the stored filter, array to specify a different filter - * @param mixed $sort True to use the stored sort, array to specify a different sort - * @return array Nested array or false - */ - public function load($filter = true, $sort = true) - { - return $this->_createSelect($filter, $sort)->query(Zend_Db::FETCH_ASSOC)->fetchAll(); - } - - /** * Returns an array containing the first requested item. * * @param mixed $filter True to use the stored filter, array to specify a different filter @@ -737,7 +737,12 @@ $select = $this->_createSelect($filter, $sort); $select->limit(1, 0); - return $select->query(Zend_Db::FETCH_ASSOC)->fetch(); + $data = $select->query(Zend_Db::FETCH_ASSOC)->fetch(); + if (is_array($data)) { + $data = $this->_filterDataAfterLoad($data, false); + } + + return $data; } /** @@ -755,6 +760,26 @@ return new Zend_Paginator($adapter); } + /** + * Helper function for SelectModelPaginator to process + * setOnLoads. + * + * @see MUtil_Model_SelectModelPaginator + * + * @param array $data Nested array + * @return array Nested + */ + public function processAfterLoad(array $data) + { + if ($this->getMeta(parent::LOAD_TRANSFORMER)) { + foreach ($data as $key => $row) { + $data[$key] = $this->_filterDataAfterLoad($row, false); + } + } + + return $data; + } + // abstract public function save(array $newValues); public function setCreate($value = true) Modified: trunk/library/classes/MUtil/Model/FormBridge.php =================================================================== --- trunk/library/classes/MUtil/Model/FormBridge.php 2011-11-17 14:20:41 UTC (rev 229) +++ trunk/library/classes/MUtil/Model/FormBridge.php 2011-11-17 16:19:26 UTC (rev 230) @@ -85,7 +85,7 @@ self::FILE_OPTIONS => array('accept', 'count', 'destination', 'valueDisabled'), self::GROUP_OPTIONS => array('elements', 'legend', 'separator'), self::JQUERY_OPTIONS => array('jQueryParams'), - self::MULTI_OPTIONS => array('disable', 'multiOptions', 'onchange', 'separator', 'size', 'valuePad', 'valueSeperatorChar'), + self::MULTI_OPTIONS => array('disable', 'multiOptions', 'onchange', 'separator', 'size'), self::PASSWORD_OPTIONS => array('repeatLabel'), self::TAB_OPTIONS => array('value'), self::TEXT_OPTIONS => array('maxlength', 'minlength', 'onchange', 'onfocus', 'onselect', 'size'), @@ -538,7 +538,7 @@ $options = $this->_mergeOptions($name, $options, self::DISPLAY_OPTIONS, self::MULTI_OPTIONS); - $element = new MUtil_Form_Element_MultiCheckbox($name, $options); + $element = new Zend_Form_Element_MultiCheckbox($name, $options); return $this->_addToForm($name, $element); } @@ -562,7 +562,7 @@ $options = $this->_mergeOptions($name, $options, self::DISPLAY_OPTIONS, self::MULTI_OPTIONS); - $element = new MUtil_Form_Element_Multiselect($name, $options); + $element = new Zend_Form_Element_Multiselect($name, $options); return $this->_addToForm($name, $element); } Modified: trunk/library/classes/MUtil/Model/ModelAbstract.php =================================================================== --- trunk/library/classes/MUtil/Model/ModelAbstract.php 2011-11-17 14:20:41 UTC (rev 229) +++ trunk/library/classes/MUtil/Model/ModelAbstract.php 2011-11-17 16:19:26 UTC (rev 230) @@ -61,6 +61,7 @@ { const ALIAS_OF = 'alias_of'; const AUTO_SAVE = 'auto_save'; + const LOAD_TRANSFORMER = 'load_transformer'; const SAVE_TRANSFORMER = 'save_transformer'; const SAVE_WHEN_TEST = 'save_when_test'; @@ -132,8 +133,41 @@ } } - protected function _filterDataArray(array $data, $new = false) + /** + * Processes empty strings, filters items that should not be saved + * according to setSaveWhen() and changes values that have a setOnSave() + * function. + * + * @see setOnSave + * @set setSaveWhen + * + * @param array $data The values to save + * @param boolean $new True when it is a new item + * @return array The possibly adapted array of values + */ + protected function _filterDataAfterLoad(array $data, $new = false) { + foreach ($data as $name => $value) { + $data[$name] = $this->getOnLoad($value, $new, $name, $data); + } + + return $data; + } + + /** + * Processes empty strings, filters items that should not be saved + * according to setSaveWhen() and changes values that have a setOnSave() + * function. + * + * @see setOnSave + * @set setSaveWhen + * + * @param array $data The values to save + * @param boolean $new True when it is a new item + * @return array The possibly adapted array of values + */ + protected function _filterDataForSave(array $data, $new = false) + { // MUtil_Echo::r($data, 'preFilter'); foreach ($data as $name => $value) { @@ -142,7 +176,7 @@ $value = null; } - if ($this->isSaveable($name, $value, $new)) { + if ($this->isSaveable($value, $new, $name, $data)) { $filteredData[$name] = $this->getOnSave($value, $new, $name, $data); } } @@ -181,6 +215,15 @@ } } + /** + * Returns a nested array containing the items requested. + * + * @param mixed $filter True to use the stored filter, array to specify a different filter + * @param mixed $sort True to use the stored sort, array to specify a different sort + * @return array Nested array or false + */ + abstract protected function _load($filter = true, $sort = true); + protected function addChanged($add = 1) { $this->_changedCount += $add; @@ -580,6 +623,30 @@ } /** + * Checks for and executes any actions to perform on a value after + * loading the value + * + * @param mixed $value The value being saved + * @param boolean $isNew True when a new item is being saved + * @param string $name The name of the current field + * @param array $context Optional, the other values being saved + * @return mixed The value to save + */ + public function getOnLoad($value, $new, $name, array $context = array()) + { + if ($call = $this->get($name, self::LOAD_TRANSFORMER)) { + + if (is_callable($call)) { + $value = call_user_func($call, $value, $new, $name, $context); + } else { + $value = $call; + } + } + + return $value; + } + + /** * Checks for and executes any actions to perform on a value before * saving the value * @@ -734,12 +801,13 @@ /** * Must the model save field $name with this $value and / or this $new values. * - * @param string $name The name of a field - * @param mixed $value The value being changed - * @param boolean $new True if the item is a new item saved for the first time + * @param mixed $value The value being saved + * @param boolean $isNew True when a new item is being saved + * @param string $name The name of the current field + * @param array $context Optional, the other values being saved * @return boolean True if the data can be saved */ - public function isSaveable($name, $value, $new = false) + public function isSaveable($value, $new, $name, array $context = array()) { if ($test = $this->get($name, self::SAVE_WHEN_TEST)) { @@ -769,20 +837,35 @@ * @param mixed $sort True to use the stored sort, array to specify a different sort * @return array Nested array or false */ - abstract public function load($filter = true, $sort = true); + public function load($filter = true, $sort = true) + { + $data = $this->_load($filter, $sort); + if (is_array($data) && $this->getMeta(self::LOAD_TRANSFORMER)) { + foreach ($data as $key => $row) { + $data[$key] = $this->_filterDataAfterLoad($row, false); + } + } + + return $data; + } + /** * Returns an array containing the first requested item. * - * @param mixed $filter True to use the stored filter, array to specify a different filter + * @param mixed $filter True to use the stored filter, array to specify a different filteloa * @param mixed $sort True to use the stored sort, array to specify a different sort * @return array An array or false */ public function loadFirst($filter = true, $sort = true) { - $data = $this->load($filter, $sort); + $data = $this->_load($filter, $sort); // Return the first row or null. - return reset($data); + $data = reset($data); + if (is_array($data) && $this->getMeta(self::LOAD_TRANSFORMER)) { + $data = $this->_filterDataAfterLoad($data, false); + } + return $data; } /** @@ -801,6 +884,7 @@ $empty[$name] = null; } } + $empty = $this->_filterDataAfterLoad($empty, true); // Return only a single row when no count is specified if (null === $count) { @@ -1118,36 +1202,76 @@ } /** - * Sets a name to automatically determined/changed of value during save. + * Sets a name to automatically change a value after a load. * - * @param string $name + * @param string $name The fieldname * @param mixed $callableOrConstant A constant or a function of this type: callable($value, $isNew = false, $name = null, array $context = array()) * @return MUtil_Model_ModelAbstract (continuation pattern) */ + public function setOnLoad($name, $callableOrConstant) + { + // Make sure we store that there is some OnLoad function. + $this->setMeta(self::LOAD_TRANSFORMER, true); + $this->set($name, self::LOAD_TRANSFORMER, $callableOrConstant); + return $this; + } + + /** + * Sets a name to an automatically determined or changed of value before a save. + * + * @param string $name The fieldname + * @param mixed $callableOrConstant A constant or a function of this type: callable($value, $isNew = false, $name = null, array $context = array()) + * @return MUtil_Model_ModelAbstract (continuation pattern) + */ public function setOnSave($name, $callableOrConstant) { $this->set($name, self::SAVE_TRANSFORMER, $callableOrConstant); return $this; } + /** + * Set this field to be saved whenever there is anything to save at all. + * + * @param string $name The fieldname + * @return MUtil_Model_ModelAbstract (continuation pattern) + */ public function setSaveOnChange($name) { $this->setAutoSave($name); return $this->setSaveWhen($name, true); } + /** + * Set this field to be saved whenever a constant is true or a callable returns true. + * + * @param string $name The fieldname + * @param mixed $callableOrConstant A constant or a function of this type: callable($value, $isNew = false, $name = null, array $context = array()) boolean + * @return MUtil_Model_ModelAbstract (continuation pattern) + */ public function setSaveWhen($name, $callableOrConstant) { $this->set($name, self::SAVE_WHEN_TEST, $callableOrConstant); return $this; } + /** + * Set this field to be saved only when it is a new item. + * + * @param string $name The fieldname + * @return MUtil_Model_ModelAbstract (continuation pattern) + */ public function setSaveWhenNew($name) { $this->setAutoSave($name); return $this->setSaveWhen($name, array(__CLASS__, 'whenNotNew')); } + /** + * Set this field to be saved only when it is not empty. + * + * @param string $name The fieldname + * @return MUtil_Model_ModelAbstract (continuation pattern) + */ public function setSaveWhenNotNull($name) { return $this->setSaveWhen($name, array(__CLASS__, 'whenNotNull')); @@ -1183,12 +1307,35 @@ } } - public static function whenNotNew($name, $value, $new) + /** + * A ModelAbstract->setSaveWhen() function that true when a new item is saved.. + * + * @see setSaveWhen() + * + * @param mixed $value The value being saved + * @param boolean $isNew True when a new item is being saved + * @param string $name The name of the current field + * @param array $context Optional, the other values being saved + * @return boolean + */ + public static function whenNotNew($value, $isNew = false, $name = null, array $context = array()) { return $new; } - public static function whenNotNull($name, $value, $new) + /** + * A ModelAbstract->setSaveWhen() function that true when the value + * is not null. + * + * @see setSaveWhen() + * + * @param mixed $value The value being saved + * @param boolean $isNew True when a new item is being saved + * @param string $name The name of the current field + * @param array $context Optional, the other values being saved + * @return boolean + */ + public static function whenNotNull($value, $isNew = false, $name = null, array $context = array()) { return null !== $value; } Modified: trunk/library/classes/MUtil/Model/ModelTransformerAbstract.php =================================================================== --- trunk/library/classes/MUtil/Model/ModelTransformerAbstract.php 2011-11-17 14:20:41 UTC (rev 229) +++ trunk/library/classes/MUtil/Model/ModelTransformerAbstract.php 2011-11-17 16:19:26 UTC (rev 230) @@ -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 @@ -43,7 +43,7 @@ $paramTypes['sourceModel'] = 'MUtil_Model_ModelAbstract'; $paramTypes['name'] = 'is_string'; - $args = MUtil_Ra::args($args, $paramTypes); + $args = MUtil_Ra::args($args, $paramTypes); if (isset($args['name'])) { $name = $args['name']; @@ -77,6 +77,20 @@ } } + /** + * Returns a nested array containing the items requested. + * + * @param mixed $filter True to use the stored filter, array to specify a different filter + * @param mixed $sort True to use the stored sort, array to specify a different sort + * @return array Nested array or false + */ + protected function _load($filter = true, $sort = true) + { + $data = $this->sourceModel->_load($filter, $sort); + + return $this->transform($data, $filter, $sort); + } + public function delete($filter = true) { throw new Exception('Cannot delete ' . get_class($this) . ' data.'); @@ -134,7 +148,7 @@ } } - public function getSourceModel() + public function getSourceModel() { return $this->sourceModel; } @@ -160,13 +174,6 @@ return false; } - public function load($filter = true, $sort = true) - { - $data = $this->sourceModel->load($filter, $sort); - - return $this->transform($data, $filter, $sort); - } - public function resetOrder() { if ($this->sourceModel) { @@ -206,7 +213,7 @@ return $this; } - public function setSourceModel(MUtil_Model_ModelAbstract $model) + public function setSourceModel(MUtil_Model_ModelAbstract $model) { $this->sourceModel = $model; return $this; Modified: trunk/library/classes/MUtil/Model/SelectModelPaginator.php =================================================================== --- trunk/library/classes/MUtil/Model/SelectModelPaginator.php 2011-11-17 14:20:41 UTC (rev 229) +++ trunk/library/classes/MUtil/Model/SelectModelPaginator.php 2011-11-17 16:19:26 UTC (rev 230) @@ -93,6 +93,12 @@ { $items = $this->_selectAdapter->getItems($offset, $itemCountPerPage); + // MUtil_Echo::track($items); + if ($items && is_array($items)) { + $items = $this->_model->processAfterLoad($items); + } + // MUtil_Echo::track($items); + return $items; } } Modified: trunk/library/classes/MUtil/Model/TableBridgeAbstract.php =================================================================== --- trunk/library/classes/MUtil/Model/TableBridgeAbstract.php 2011-11-17 14:20:41 UTC (rev 229) +++ trunk/library/classes/MUtil/Model/TableBridgeAbstract.php 2011-11-17 16:19:26 UTC (rev 230) @@ -104,6 +104,7 @@ private static function _applyDisplayFunction($item, $function) { + // MUtil_Echo::track($function); if (is_callable($function)) { return call_user_func($function, $item); } @@ -127,7 +128,9 @@ } elseif (is_array($function)) { foreach ($function as $display) { - $item = self::_applyDisplayFunction($item, $display); + if ($display !== null) { + $item = self::_applyDisplayFunction($item, $display); + } } } Property changes on: trunk/library/classes/MUtil/Model/Type ___________________________________________________________________ Added: bugtraq:url + http://survey.erasmusmc.nl/support/mantis/view.php?id=%BUGID% Added: bugtraq:logregex + #(\d+) Added: trunk/library/classes/MUtil/Model/Type/ConcatenatedRow.php =================================================================== --- trunk/library/classes/MUtil/Model/Type/ConcatenatedRow.php (rev 0) +++ trunk/library/classes/MUtil/Model/Type/ConcatenatedRow.php 2011-11-17 16:19:26 UTC (rev 230) @@ -0,0 +1,137 @@ +<?php + +/** + * Copyright (c) 2011, Erasmus MC + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Erasmus MC nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * + * @package MUtil + * @subpackage Model + * @author Matijs de Jong <mj...@ma...> + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @version $Id$ + */ + +/** + * + * + * @package MUtil + * @subpackage Model + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @since Class available since version 1.5 + */ +class MUtil_Model_Type_ConcatenatedRow +{ + protected $displaySeperator = ' '; + + protected $seperatorChar = ' '; + + protected $valuePad = true; + + public function __construct($seperatorChar = ' ', $displaySeperator = ' ', $valuePad = true) + { + $this->seperatorChar = substr($seperatorChar . ' ', 0, 1); + $this->displaySeperator = $displaySeperator; + $this->valuePad = $valuePad; + } + + /** + * If this field is saved as an array value, use + * + * @param MUtil_Model_ModelAbstract $model + * @param string $name The field to set the seperator character + * @return MUtil_Model_Type_ConcatenatedRow (continuation pattern) + */ + public function apply(MUtil_Model_ModelAbstract $model, $name) + { + $model->set($name, 'formatFunction', array($this, 'format')); + $model->setOnLoad($name, array($this, 'loadValue')); + $model->setOnSave($name, array($this, 'saveValue')); + + return $this; + } + + public function format($value) + { + // MUtil_Echo::track($value); + if (is_array($value)) { + return implode($this->displaySeperator, $value); + } else { + return $value; + } + } + + /** + * A ModelAbstract->setOnSave() function that concatenates the + * value if it is an array. + * + * @see Gems_Model_ModelAbstract + * + * @param mixed $value The value being saved + * @param boolean $isNew True when a new item is being saved + * @param string $name The name of the current field + * @param array $context Optional, the other values being saved + * @return array Of the values + */ + public function loadValue($value, $isNew = false, $name = null, array $context = array()) + { + // MUtil_Echo::track($value); + if (! is_array($value)) { + if ($this->valuePad) { + $value = trim($value, $this->seperatorChar); + } + $value = explode($this->seperatorChar, $value); + } + // MUtil_Echo::track($value); + + return $value; + } + + /** + * A ModelAbstract->setOnSave() function that concatenates the + * value if it is an array. + * + * @see Gems_Model_ModelAbstract + * + * @param mixed $value The value being saved + * @param boolean $isNew True when a new item is being saved + * @param string $name The name of the current field + * @param array $context Optional, the other values being saved + * @return string Of the values concatenated + */ + public function saveValue($value, $isNew = false, $name = null, array $context = array()) + { + if (is_array($value)) { + $value = implode($this->seperatorChar, $value); + + if ($this->valuePad) { + $value = $this->seperatorChar . $value . $this->seperatorChar; + } + } + return $value; + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2011-11-17 14:20:50
|
Revision: 229 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=229&view=rev Author: michieltcs Date: 2011-11-17 14:20:41 +0000 (Thu, 17 Nov 2011) Log Message: ----------- Make sure _ensureFieldsData() is called when respondenttrack is refreshed Modified Paths: -------------- trunk/library/classes/Gems/Tracker/RespondentTrack.php Modified: trunk/library/classes/Gems/Tracker/RespondentTrack.php =================================================================== --- trunk/library/classes/Gems/Tracker/RespondentTrack.php 2011-11-17 11:46:04 UTC (rev 228) +++ trunk/library/classes/Gems/Tracker/RespondentTrack.php 2011-11-17 14:20:41 UTC (rev 229) @@ -609,6 +609,8 @@ $this->_respTrackData = $this->db->fetchRow($sql, $this->_respTrackId); } + + $this->_ensureFieldData(true); return $this; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2011-11-17 11:46:14
|
Revision: 228 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=228&view=rev Author: mennodekker Date: 2011-11-17 11:46:04 +0000 (Thu, 17 Nov 2011) Log Message: ----------- Fixing a problem with the order of viewhelpers and moving datepicker display code to viewhelper instead of setview (result: javascript code once instead of twice in some case) Modified Paths: -------------- trunk/library/classes/Gems/Default/ExportAction.php trunk/library/classes/Gems/JQuery/Form/Element/ToggleCheckboxes.php trunk/library/classes/Gems/TabForm.php trunk/library/classes/MUtil/Form.php trunk/library/classes/MUtil/JQuery/Form/Element/DatePicker.php Added Paths: ----------- trunk/library/classes/MUtil/JQuery/View/ trunk/library/classes/MUtil/JQuery/View/Helper/ trunk/library/classes/MUtil/JQuery/View/Helper/DatePicker.php Removed Paths: ------------- trunk/library/classes/MUtil/View/Helper/DatePicker.php Modified: trunk/library/classes/Gems/Default/ExportAction.php =================================================================== --- trunk/library/classes/Gems/Default/ExportAction.php 2011-11-17 10:59:27 UTC (rev 227) +++ trunk/library/classes/Gems/Default/ExportAction.php 2011-11-17 11:46:04 UTC (rev 228) @@ -89,8 +89,6 @@ $div[] = $form; } else { Zend_Layout::resetMvcInstance(); - $this->view->addHelperPath('Gems/JQuery/View/Helper', 'Gems_JQuery_View_Helper'); - $this->view->addHelperPath('ZendX/JQuery/View/Helper', 'ZendX_JQuery_View_Helper'); $this->html->raw($form->render($this->view)); //Now add all onload actions to make the form still work Modified: trunk/library/classes/Gems/JQuery/Form/Element/ToggleCheckboxes.php =================================================================== --- trunk/library/classes/Gems/JQuery/Form/Element/ToggleCheckboxes.php 2011-11-17 10:59:27 UTC (rev 227) +++ trunk/library/classes/Gems/JQuery/Form/Element/ToggleCheckboxes.php 2011-11-17 11:46:04 UTC (rev 228) @@ -79,14 +79,12 @@ */ public function setView(Zend_View_Interface $view = null) { + $element = parent::setView($view); if (null !== $view) { if (false === $view->getPluginLoader('helper')->getPaths('Gems_JQuery_View_Helper')) { $view->addHelperPath('Gems/JQuery/View/Helper', 'Gems_JQuery_View_Helper'); } - if (false === $view->getPluginLoader('helper')->getPaths('ZendX_JQuery_View_Helper')) { - $view->addHelperPath('ZendX/JQuery/View/Helper', 'ZendX_JQuery_View_Helper'); - } } - return parent::setView($view); + return $element; } } \ No newline at end of file Modified: trunk/library/classes/Gems/TabForm.php =================================================================== --- trunk/library/classes/Gems/TabForm.php 2011-11-17 10:59:27 UTC (rev 227) +++ trunk/library/classes/Gems/TabForm.php 2011-11-17 11:46:04 UTC (rev 228) @@ -319,10 +319,12 @@ */ public function setView(Zend_View_Interface $view = null) { $form = parent::setView($view); - ZendX_JQuery::enableView($view); - - if (false === $view->getPluginLoader('helper')->getPaths('Gems_JQuery_View_Helper')) { - $view->addHelperPath('Gems/JQuery/View/Helper', 'Gems_JQuery_View_Helper'); + + if ($view) { + $this->activateJQuery(); + if (false === $view->getPluginLoader('helper')->getPaths('Gems_JQuery_View_Helper')) { + $view->addHelperPath('Gems/JQuery/View/Helper', 'Gems_JQuery_View_Helper'); + } } return $form; Modified: trunk/library/classes/MUtil/Form.php =================================================================== --- trunk/library/classes/MUtil/Form.php 2011-11-17 10:59:27 UTC (rev 227) +++ trunk/library/classes/MUtil/Form.php 2011-11-17 11:46:04 UTC (rev 228) @@ -1,44 +1,44 @@ <?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 + +/** + * 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$ + * @version $Id$ * @package MUtil * @subpackage Acl * @copyright Copyright (c) 2011 Erasmus MC * @license New BSD License - */ + */ /** * @package MUtil * @subpackage Form * @copyright Copyright (c) 2011 Erasmus MC * @license New BSD License - */ + */ class MUtil_Form extends Zend_Form { protected $_displayOrder = array('element', 'errors', 'description'); @@ -96,11 +96,11 @@ return; } } - + + ZendX_JQuery::enableView($view); + if (false === $view->getPluginLoader('helper')->getPaths('MUtil_JQuery_View_Helper')) { $view->addHelperPath('MUtil/JQuery/View/Helper', 'MUtil_JQuery_View_Helper'); - - ZendX_JQuery::enableView($view); } } Modified: trunk/library/classes/MUtil/JQuery/Form/Element/DatePicker.php =================================================================== --- trunk/library/classes/MUtil/JQuery/Form/Element/DatePicker.php 2011-11-17 10:59:27 UTC (rev 227) +++ trunk/library/classes/MUtil/JQuery/Form/Element/DatePicker.php 2011-11-17 11:46:04 UTC (rev 228) @@ -213,26 +213,14 @@ } } - if ($format = $this->getJQueryParam('dateFormat')) { - //* - $js[] = '{'; - $js[] = " var datePick = $('#" . $this->getId() . "');"; - $js[] = ''; - $js[] = " datePick.blur(function() {"; - $js[] = " var dateused;"; - $js[] = " var dateformat = '" . $format . "';"; - // TODO: Why won't this work - // $js[] = " var dateformat = datePick.datepicker('option', 'dateFormat');"; - // $js[] = " alert(dateformat);"; - $js[] = " dateused = datePick.attr('value');"; - $js[] = " dateused = $.datepicker.parseDate(dateformat, dateused);"; - $js[] = " datePick.attr('value', $.datepicker.formatDate(dateformat, dateused));"; - $js[] = " });"; - $js[] = '}'; + $element = parent::setView($view); - $view->inlineScript()->appendScript(implode("\n", $js)); // */ + if (null !== $view) { + if (false === $view->getPluginLoader('helper')->getPaths('MUtil_JQuery_View_Helper')) { + $view->addHelperPath('MUtil/JQuery/View/Helper', 'MUtil_JQuery_View_Helper'); + } } - return parent::setView($view); + return $element; } } Copied: trunk/library/classes/MUtil/JQuery/View/Helper/DatePicker.php (from rev 225, trunk/library/classes/MUtil/View/Helper/DatePicker.php) =================================================================== --- trunk/library/classes/MUtil/JQuery/View/Helper/DatePicker.php (rev 0) +++ trunk/library/classes/MUtil/JQuery/View/Helper/DatePicker.php 2011-11-17 11:46:04 UTC (rev 228) @@ -0,0 +1,78 @@ +<?php + + +/** + * Copyright (c) 2011, Erasmus MC + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Erasmus MC nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * + * @author Matijs de Jong + * @since 1.0 + * @version 1.1 + * @package MUtil + * @subpackage View + */ + +/** + * + * @author Matijs de Jong + * @package MUtil + * @subpackage View + */ +class MUtil_JQuery_View_Helper_DatePicker extends ZendX_JQuery_View_Helper_DatePicker +{ + public function datePicker($id, $value = null, array $params = array(), array $attribs = array()) { + $result = parent::datePicker($id, $value, $params, $attribs); + if (isset($attribs['disabled'])) { + $js = "$('#" . $attribs['id'] . "').datepicker('disable');"; + $this->jquery->addOnLoad($js); + } + + if ($format = $params['dateFormat']) { + //* + $js = array(); + $js[] = '{'; + $js[] = " var datePick = $('#" . $id . "');"; + $js[] = ''; + $js[] = " datePick.blur(function() {"; + $js[] = " var dateused;"; + $js[] = " var dateformat = '" . $format . "';"; + // TODO: Why won't this work + // $js[] = " var dateformat = datePick.datepicker('option', 'dateFormat');"; + // $js[] = " alert(dateformat);"; + $js[] = " dateused = datePick.attr('value');"; + $js[] = " dateused = $.datepicker.parseDate(dateformat, dateused);"; + $js[] = " datePick.attr('value', $.datepicker.formatDate(dateformat, dateused));"; + $js[] = " });"; + $js[] = '}'; + + $this->view->inlineScript()->appendScript(implode("\n", $js)); // */ + } + return $result; + } + +} \ No newline at end of file Deleted: trunk/library/classes/MUtil/View/Helper/DatePicker.php =================================================================== --- trunk/library/classes/MUtil/View/Helper/DatePicker.php 2011-11-17 10:59:27 UTC (rev 227) +++ trunk/library/classes/MUtil/View/Helper/DatePicker.php 2011-11-17 11:46:04 UTC (rev 228) @@ -1,57 +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 Matijs de Jong - * @since 1.0 - * @version 1.1 - * @package MUtil - * @subpackage View - */ - -/** - * - * @author Matijs de Jong - * @package MUtil - * @subpackage View - */ -class MUtil_View_Helper_DatePicker extends ZendX_JQuery_View_Helper_DatePicker -{ - public function datePicker($id, $value = null, array $params = array(), array $attribs = array()) { - $result = parent::datePicker($id, $value, $params, $attribs); - if (isset($attribs['disabled'])) { - $js = "$('#" . $attribs['id'] . "').datepicker('disable');"; - $this->jquery->addOnLoad($js); - } - return $result; - } - -} \ 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-11-17 10:59:37
|
Revision: 227 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=227&view=rev Author: matijsdejong Date: 2011-11-17 10:59:27 +0000 (Thu, 17 Nov 2011) Log Message: ----------- Preparation for #41 onLoad & getFormatted functionality: - onSave() function enters the value first, isNew next, then name and context, - SelectModelPaginator allows (future) interception of onLoad calls. Modified Paths: -------------- trunk/library/classes/Gems/Default/StaffAction.php trunk/library/classes/Gems/Model/RespondentModel.php trunk/library/classes/Gems/Model.php trunk/library/classes/Gems/Project/ProjectSettings.php trunk/library/classes/GemsEscort.php trunk/library/classes/MUtil/Model/DatabaseModelAbstract.php trunk/library/classes/MUtil/Model/ModelAbstract.php trunk/library/classes/MUtil/Model/Save/ArraySaver.php trunk/library/snippets/EditTrackTokenSnippet.php Added Paths: ----------- trunk/library/classes/MUtil/Model/SelectModelPaginator.php Modified: trunk/library/classes/Gems/Default/StaffAction.php =================================================================== --- trunk/library/classes/Gems/Default/StaffAction.php 2011-11-17 08:45:52 UTC (rev 226) +++ trunk/library/classes/Gems/Default/StaffAction.php 2011-11-17 10:59:27 UTC (rev 227) @@ -98,7 +98,7 @@ case Gems_User_UserLoader::USER_STAFF: Gems_Model::addUserPassword($model); $passwordField = 'gup_password'; - $model->setOnSave($passwordField, array($this->project, 'getValueHashForModel')); + $model->setOnSave($passwordField, array($this->project, 'getValueHash')); break; case Gems_User_UserLoader::USER_OLD_STAFF: @@ -268,12 +268,13 @@ /** * Return an old style (< 1.5) hashed version of the input value. * - * @param string $name Optional name, is here for ModelAbstract setOnSave compatibility * @param string $value The value to hash. * @param boolean $new Optional is new, is here for ModelAbstract setOnSave compatibility + * @param string $name Optional name, is here for ModelAbstract setOnSave compatibility + * @param array $context Optional, the other values being saved * @return string The salted hash as a 32-character hexadecimal number. */ - public function getOldPasswordHash($name, $value, $new) + public function getOldPasswordHash($value, $isNew = false, $name = null, array $context = array()) { return md5($value); } Modified: trunk/library/classes/Gems/Model/RespondentModel.php =================================================================== --- trunk/library/classes/Gems/Model/RespondentModel.php 2011-11-17 08:45:52 UTC (rev 226) +++ trunk/library/classes/Gems/Model/RespondentModel.php 2011-11-17 10:59:27 UTC (rev 227) @@ -133,12 +133,13 @@ /** * Return a hashed version of the input value. * - * @param string $name Optional name, is here for ModelAbstract setOnSave compatibility - * @param string $value The value to hash. - * @param boolean $new Optional is new, is here for ModelAbstract setOnSave compatibility + * @param mixed $value The value being saved + * @param boolean $isNew True when a new item is being saved + * @param string $name The name of the current field + * @param array $context Optional, the other values being saved * @return string The salted hash as a 32-character hexadecimal number. */ - public function formatSSN($name, $value, $new = false) + public function formatSSN($value, $isNew = false, $name = null, array $context = array()) { if ($value) { return $this->project->getValueHash($value); Modified: trunk/library/classes/Gems/Model.php =================================================================== --- trunk/library/classes/Gems/Model.php 2011-11-17 08:45:52 UTC (rev 226) +++ trunk/library/classes/Gems/Model.php 2011-11-17 10:59:27 UTC (rev 227) @@ -120,12 +120,15 @@ /** * Create a Gems project wide unique user id * - * @param string $name - * @param mixed $value - * @param boolean $isNew + * @see Gems_Model_ModelAbstract + * + * @param mixed $value The value being saved + * @param boolean $isNew True when a new item is being saved + * @param string $name The name of the current field + * @param array $context Optional, the other values being saved * @return int */ - public function createGemsUserId($name, $value, $isNew) + public function createGemsUserId($value, $isNew = false, $name = null, array $context = array()) { if ($isNew || (null === $value)) { $creationTime = new Zend_Db_Expr('CURRENT_TIMESTAMP'); Modified: trunk/library/classes/Gems/Project/ProjectSettings.php =================================================================== --- trunk/library/classes/Gems/Project/ProjectSettings.php 2011-11-17 08:45:52 UTC (rev 226) +++ trunk/library/classes/Gems/Project/ProjectSettings.php 2011-11-17 10:59:27 UTC (rev 227) @@ -224,17 +224,4 @@ return md5($salted, false); } - - /** - * Returns a salted hash on the - * - * @param string $name Fieldname - * @param string $value The value to hash - * @param string $isNew True when new - * @return string The salted hash as a 32-character hexadecimal number. - */ - public function getValueHashForModel($name, $value, $isNew = false) - { - return $this->getValueHash($value); - } } Modified: trunk/library/classes/GemsEscort.php =================================================================== --- trunk/library/classes/GemsEscort.php 2011-11-17 08:45:52 UTC (rev 226) +++ trunk/library/classes/GemsEscort.php 2011-11-17 10:59:27 UTC (rev 227) @@ -1207,12 +1207,13 @@ * * @deprecated Since 1.5 * - * @param string $name Optional name, is here for ModelAbstract setOnSave compatibility * @param string $value The value to hash. * @param boolean $new Optional is new, is here for ModelAbstract setOnSave compatibility + * @param string $name Optional name, is here for ModelAbstract setOnSave compatibility + * @param array $context Optional, the other values being saved * @return string The salted hash as a 32-character hexadecimal number. */ - public function passwordHash($name, $value, $new) + public function passwordHash($value, $isNew = false, $name = null, array $context = array()) { return $this->project->getValueHash($value); } Modified: trunk/library/classes/MUtil/Model/DatabaseModelAbstract.php =================================================================== --- trunk/library/classes/MUtil/Model/DatabaseModelAbstract.php 2011-11-17 08:45:52 UTC (rev 226) +++ trunk/library/classes/MUtil/Model/DatabaseModelAbstract.php 2011-11-17 10:59:27 UTC (rev 227) @@ -596,14 +596,26 @@ throw new MUtil_Model_ModelException("Cannot create UniqueValue validator as no table was defined for field $name."); } - public function formatSaveDate($name, $value, $new = false) + /** + * A ModelAbstract->setOnSave() function that returns the input + * date as a valid date. + * + * @see Gems_Model_ModelAbstract + * + * @param mixed $value The value being saved + * @param boolean $isNew True when a new item is being saved + * @param string $name The name of the current field + * @param array $context Optional, the other values being saved + * @return Zend_Date + */ + public function formatSaveDate($value, $isNew = false, $name = null) { if ($name && (! ((null === $value) || ($value instanceof Zend_Db_Expr)))) { if ($saveFormat = $this->get($name, 'storageFormat')) { if ($value instanceof Zend_Date) { return $value->toString($saveFormat); - + } else { $displayFormat = $this->get($name, 'dateFormat'); @@ -737,9 +749,10 @@ */ public function loadPaginator($filter = true, $sort = true) { - $select = $this->_createSelect($filter, $sort); + $select = $this->_createSelect($filter, $sort); + $adapter = new MUtil_Model_SelectModelPaginator($select, $this); - return Zend_Paginator::factory($select); + return new Zend_Paginator($adapter); } // abstract public function save(array $newValues); Modified: trunk/library/classes/MUtil/Model/ModelAbstract.php =================================================================== --- trunk/library/classes/MUtil/Model/ModelAbstract.php 2011-11-17 08:45:52 UTC (rev 226) +++ trunk/library/classes/MUtil/Model/ModelAbstract.php 2011-11-17 10:59:27 UTC (rev 227) @@ -143,7 +143,7 @@ } if ($this->isSaveable($name, $value, $new)) { - $filteredData[$name] = $this->getOnSave($name, $value, $new); + $filteredData[$name] = $this->getOnSave($value, $new, $name, $data); } } @@ -579,12 +579,22 @@ return $this->_model_name; } - public function getOnSave($name, $value, $new = false) + /** + * Checks for and executes any actions to perform on a value before + * saving the value + * + * @param mixed $value The value being saved + * @param boolean $isNew True when a new item is being saved + * @param string $name The name of the current field + * @param array $context Optional, the other values being saved + * @return mixed The value to save + */ + public function getOnSave($value, $new, $name, array $context = array()) { if ($call = $this->get($name, self::SAVE_TRANSFORMER)) { if (is_callable($call)) { - $value = call_user_func($call, $name, $value, $new); + $value = call_user_func($call, $value, $new, $name, $context); } else { $value = $call; } @@ -1107,6 +1117,13 @@ return $this; } + /** + * Sets a name to automatically determined/changed of value during save. + * + * @param string $name + * @param mixed $callableOrConstant A constant or a function of this type: callable($value, $isNew = false, $name = null, array $context = array()) + * @return MUtil_Model_ModelAbstract (continuation pattern) + */ public function setOnSave($name, $callableOrConstant) { $this->set($name, self::SAVE_TRANSFORMER, $callableOrConstant); Modified: trunk/library/classes/MUtil/Model/Save/ArraySaver.php =================================================================== --- trunk/library/classes/MUtil/Model/Save/ArraySaver.php 2011-11-17 08:45:52 UTC (rev 226) +++ trunk/library/classes/MUtil/Model/Save/ArraySaver.php 2011-11-17 10:59:27 UTC (rev 227) @@ -75,7 +75,19 @@ return $class; } - public function saveValue($name, $value, $isNew) + /** + * A ModelAbstract->setOnSave() function that concatenates the + * value if it is an array. + * + * @see Gems_Model_ModelAbstract + * + * @param mixed $value The value being saved + * @param boolean $isNew True when a new item is being saved + * @param string $name The name of the current field + * @param array $context Optional, the other values being saved + * @return Zend_Date + */ + public function saveValue($value, $isNew = false, $name = null, array $context = array()) { if (is_array($value)) { $value = implode($this->seperatorChar, $value); Added: trunk/library/classes/MUtil/Model/SelectModelPaginator.php =================================================================== --- trunk/library/classes/MUtil/Model/SelectModelPaginator.php (rev 0) +++ trunk/library/classes/MUtil/Model/SelectModelPaginator.php 2011-11-17 10:59:27 UTC (rev 227) @@ -0,0 +1,98 @@ +<?php + +/** + * Copyright (c) 2011, Erasmus MC + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Erasmus MC nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * + * @package MUtil + * @subpackage Model + * @author Matijs de Jong <mj...@ma...> + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @version $Id$ + */ + +/** + * This class wraps around a select as a paginator, while allowing model->onload + * functions to apply. + * + * @see MUtil_Model_DatabaseModelAbstract + * + * @package MUtil + * @subpackage Model + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @since Class available since version 1.5 + */ +class MUtil_Model_SelectModelPaginator implements Zend_Paginator_Adapter_Interface +{ + /** + * + * @var MUtil_Model_DatabaseModelAbstract + */ + protected $_model; + + /** + * + * @var Zend_Paginator_Adapter_DbSelect + */ + protected $_selectAdapter; + + /** + * + * @param Zend_Db_Select $select + * @param MUtil_Model_ModelAbstract $model + */ + public function __construct(Zend_Db_Select $select, MUtil_Model_DatabaseModelAbstract $model) + { + $this->_selectAdapter = new Zend_Paginator_Adapter_DbSelect($select); + $this->_model = $model; + } + + /** + * Returns the total number of rows in the result set. + * + * @return integer + */ + public function count() + { + return $this->_selectAdapter->count(); + } + + /** + * Returns an array of items for a page. + * + * @param integer $offset Page offset + * @param integer $itemCountPerPage Number of items per page + * @return array + */ + public function getItems($offset, $itemCountPerPage) + { + $items = $this->_selectAdapter->getItems($offset, $itemCountPerPage); + + return $items; + } +} Modified: trunk/library/snippets/EditTrackTokenSnippet.php =================================================================== --- trunk/library/snippets/EditTrackTokenSnippet.php 2011-11-17 08:45:52 UTC (rev 226) +++ trunk/library/snippets/EditTrackTokenSnippet.php 2011-11-17 10:59:27 UTC (rev 227) @@ -160,8 +160,8 @@ if ($this->formData[self::RECALCULATE_FIELD]) { $model = $this->getModel(); // Refresh token with current form data - $updateData['gto_valid_from'] = $model->getOnSave('gto_valid_from', $this->formData['gto_valid_from'], true); - $updateData['gto_valid_until'] = $model->getOnSave('gto_valid_until', $this->formData['gto_valid_until'], true); + $updateData['gto_valid_from'] = $model->getOnSave($this->formData['gto_valid_from'], true, 'gto_valid_from'); + $updateData['gto_valid_until'] = $model->getOnSave($this->formData['gto_valid_until'], true, 'gto_valid_until'); $updateData['gto_comment'] = $this->formData['gto_comment']; $this->token->refresh($updateData); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2011-11-17 08:45:59
|
Revision: 226 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=226&view=rev Author: mennodekker Date: 2011-11-17 08:45:52 +0000 (Thu, 17 Nov 2011) Log Message: ----------- No extra delay when auth fails because of delay Modified Paths: -------------- trunk/library/classes/Gems/Auth.php Modified: trunk/library/classes/Gems/Auth.php =================================================================== --- trunk/library/classes/Gems/Auth.php 2011-11-17 08:17:30 UTC (rev 225) +++ trunk/library/classes/Gems/Auth.php 2011-11-17 08:45:52 UTC (rev 226) @@ -152,11 +152,12 @@ } else { if ($values['gula_failed_logins']) { // MUtil_Echo::track($result->getCode(), self::ERROR_PASSWORD_DELAY); - // Only increment when we have no password delay - // if ($result->getCode() <> self::ERROR_PASSWORD_DELAY) { + // Only increment when we have no password delay as the right password + // will not be accepted when we are in the delay. + if ($result->getCode() <> self::ERROR_PASSWORD_DELAY) { $values['gula_failed_logins'] += 1; $values['gula_last_failed'] = new Zend_Db_Expr('CURRENT_TIMESTAMP'); - // } + } } else { $values['gula_failed_logins'] = 1; $values['gula_last_failed'] = new Zend_Db_Expr('CURRENT_TIMESTAMP'); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2011-11-17 08:17:36
|
Revision: 225 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=225&view=rev Author: michieltcs Date: 2011-11-17 08:17:30 +0000 (Thu, 17 Nov 2011) Log Message: ----------- Add helper method getFields() Modified Paths: -------------- trunk/library/classes/Gems/Tracker/Engine/TrackEngineAbstract.php Modified: trunk/library/classes/Gems/Tracker/Engine/TrackEngineAbstract.php =================================================================== --- trunk/library/classes/Gems/Tracker/Engine/TrackEngineAbstract.php 2011-11-16 18:18:12 UTC (rev 224) +++ trunk/library/classes/Gems/Tracker/Engine/TrackEngineAbstract.php 2011-11-17 08:17:30 UTC (rev 225) @@ -532,6 +532,24 @@ return $elements; } + + /** + * Returns an associative array of the fields in this track + * + * @return string[] + */ + public function getFields() + { + $this->_ensureTrackFields(); + + $fields = array(); + + foreach ($this->_trackFields as $field) { + $fields[$field['gtf_id_field']] = $field['gtf_field_name']; + } + + return $fields; + } /** * Get the round id of the first round This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2011-11-16 18:18:19
|
Revision: 224 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=224&view=rev Author: matijsdejong Date: 2011-11-16 18:18:12 +0000 (Wed, 16 Nov 2011) Log Message: ----------- Obfuscated difference between non-existing user and existing user logon attempts. Modified Paths: -------------- trunk/library/classes/Gems/Auth/Adapter/Callback.php trunk/library/classes/Gems/Auth.php trunk/library/classes/Gems/Default/IndexAction.php trunk/library/classes/Gems/User/NoLoginDefinition.php trunk/library/classes/Gems/User/ProjectUserDefinition.php 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/classes/Gems/Auth/Adapter/Callback.php =================================================================== --- trunk/library/classes/Gems/Auth/Adapter/Callback.php 2011-11-16 17:52:38 UTC (rev 223) +++ trunk/library/classes/Gems/Auth/Adapter/Callback.php 2011-11-16 18:18:12 UTC (rev 224) @@ -2,7 +2,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 @@ -13,7 +13,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 @@ -24,7 +24,7 @@ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * Short description of file * * @package Gems @@ -82,7 +82,7 @@ if ($result === true) { $result = new Zend_Auth_Result(Zend_Auth_Result::SUCCESS, $this->_identity); } else { - $result = new Zend_Auth_Result(Zend_Auth_Result::FAILURE, $this->_identity); + $result = new Zend_Auth_Result(Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID, $this->_identity); } } return $result; Modified: trunk/library/classes/Gems/Auth.php =================================================================== --- trunk/library/classes/Gems/Auth.php 2011-11-16 17:52:38 UTC (rev 223) +++ trunk/library/classes/Gems/Auth.php 2011-11-16 18:18:12 UTC (rev 224) @@ -48,9 +48,12 @@ { /** * Error constants + * + * These must be numeric constants smaller than zero for + * Zend_Auth_Result to work. */ - const ERROR_DATABASE_NOT_INSTALLED = 'notInstalled'; - const ERROR_PASSWORD_DELAY = 'blockedDelay'; + const ERROR_DATABASE_NOT_INSTALLED = -11; + const ERROR_PASSWORD_DELAY = -12; /** * @var array Message templates @@ -71,7 +74,8 @@ */ public $db; - public function __construct($db = null) { + public function __construct($db = null) + { /** * Check for an adapter being defined. if not, fetch the default adapter. */ @@ -86,13 +90,22 @@ } } - private function _error($code, $value1 = null, $value2 = null) { + private function _error($code, $value1 = null, $value2 = null) + { $messages = func_get_args(); array_splice($messages, 0, 1, $this->_messageTemplates[$code]); return new Zend_Auth_Result($code, null, (array) $messages); } - public function authenticate(Zend_Auth_Adapter_Interface $adapter, $formValues) { + /** + * Authenticates against the supplied adapter + * + * @param Zend_Auth_Adapter_Interface $adapter + * @param array $formValues We need information not in the adapter. + * @return Zend_Auth_Result + */ + public function authenticate(Zend_Auth_Adapter_Interface $adapter, array $formValues = null) + { try { $login_name = $formValues['userlogin']; $organization = $formValues['organization']; @@ -105,22 +118,23 @@ $values['gula_id_organization'] = $organization; $values['gula_failed_logins'] = 0; $values['gula_last_failed'] = null; + } elseif ($values['gula_failed_logins'] > 0) { - // Get the datetime - $last = new MUtil_Date($values['gula_last_failed'], Zend_Date::ISO_8601); + // Get the datetime + $last = new MUtil_Date($values['gula_last_failed'], Zend_Date::ISO_8601); - // How long to wait until we can ignore the previous failed attempt - $delay = pow($values['gula_failed_logins'], GemsEscort::getInstance()->project->getAccountDelayFactor()); + // How long to wait until we can ignore the previous failed attempt + $delay = pow($values['gula_failed_logins'], GemsEscort::getInstance()->project->getAccountDelayFactor()); - if (abs($last->diffSeconds()) <= $delay) { - // Response gets slowly slower - $sleepTime = min($values['gula_failed_logins'], 10); - sleep($sleepTime); - $remaining = $delay - abs($last->diffSeconds()) - $sleepTime; - if ($remaining>0) { - $result = $this->_error(self::ERROR_PASSWORD_DELAY, $remaining); - } + if (abs($last->diffSeconds()) <= $delay) { + // Response gets slowly slower + $sleepTime = min($values['gula_failed_logins'], 10); + sleep($sleepTime); + $remaining = $delay - abs($last->diffSeconds()) - $sleepTime; + if ($remaining>0) { + $result = $this->_error(self::ERROR_PASSWORD_DELAY, $remaining); } + } } } catch (Zend_Db_Exception $e) { // Fall through as this does not work if the database upgrade did not run @@ -137,11 +151,12 @@ $values['gula_last_failed'] = null; } else { if ($values['gula_failed_logins']) { + // MUtil_Echo::track($result->getCode(), self::ERROR_PASSWORD_DELAY); // Only increment when we have no password delay - if ($result->getCode() <> self::ERROR_PASSWORD_DELAY) { + // if ($result->getCode() <> self::ERROR_PASSWORD_DELAY) { $values['gula_failed_logins'] += 1; $values['gula_last_failed'] = new Zend_Db_Expr('CURRENT_TIMESTAMP'); - } + // } } else { $values['gula_failed_logins'] = 1; $values['gula_last_failed'] = new Zend_Db_Expr('CURRENT_TIMESTAMP'); @@ -195,7 +210,8 @@ * @param Zend_Auth_Result $result * @return Zend_Auth_Result */ - public function localize($result) { + public function localize($result) + { $translate = GemsEscort::getInstance()->translate; $code = $result->getCode(); $identity = $result->getIdentity(); @@ -210,18 +226,23 @@ */ switch ($code) { case Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID: - $message = $translate->_('Wrong password.'); - break; + // $message = $translate->_('Wrong password.'); + // break; case Zend_Auth_Result::FAILURE_IDENTITY_NOT_FOUND: - $message = $translate->_('Combination of username password not found.'); + $message = $translate->_('Combination of organization, username and password not found.'); break; } - //Now recombine with the others, they will be treated as params - $messages = array_merge((array) $message, (array) $messages); - //Now do a sprintf if we have 1 or more params - if (count($messages)>1) $messages = call_user_func_array('sprintf', $messages); + // Recombine with the others if any, they will be treated as params + if (count($messages)) { + $messages = array_merge((array) $message, (array) $messages); + //Now do a sprintf if we have 1 or more params + $messages = call_user_func_array('sprintf', $messages); + } else { + $messages = array($message); + } + return new Zend_Auth_Result($code, $identity, (array) $messages); } } \ No newline at end of file Modified: trunk/library/classes/Gems/Default/IndexAction.php =================================================================== --- trunk/library/classes/Gems/Default/IndexAction.php 2011-11-16 17:52:38 UTC (rev 223) +++ trunk/library/classes/Gems/Default/IndexAction.php 2011-11-16 18:18:12 UTC (rev 224) @@ -282,46 +282,44 @@ $user = $this->loader->getUser($request->getParam('userlogin'), $request->getParam('organization')); - if ($user->isActive()) { - $formValues = $form->getValues(); - $authResult = $user->authenticate($formValues); + // NO!!! DO not test! Otherwise it is easy to test which users exist. + // if ($user->isActive()) { + $formValues = $form->getValues(); + $authResult = $user->authenticate($formValues); - if ($authResult->isValid()) { + if ($authResult->isValid()) { - $user->setAsCurrentUser(); + $user->setAsCurrentUser(); - $user->afterLogin($form->getValues()); + $user->afterLogin($form->getValues()); - /** - * Fix current locale / organization in cookies - */ - Gems_Cookies::setLocale($user->getLocale(), $this->basepath->getBasePath()); - Gems_Cookies::setOrganization($user->getOrganizationId(), $this->basepath->getBasePath()); + /** + * Fix current locale / organization in cookies + */ + Gems_Cookies::setLocale($user->getLocale(), $this->basepath->getBasePath()); + Gems_Cookies::setOrganization($user->getOrganizationId(), $this->basepath->getBasePath()); - /** - * Ready - */ - $this->addMessage(sprintf($this->_('Login successful, welcome %s.'), $user->getFullName())); + /** + * Ready + */ + $this->addMessage(sprintf($this->_('Login successful, welcome %s.'), $user->getFullName())); - /** - * Log the login - */ - Gems_AccessLog::getLog($this->db)->log("index.login", $this->getRequest(), null, $user->getUserId(), true); + /** + * Log the login + */ + Gems_AccessLog::getLog($this->db)->log("index.login", $this->getRequest(), null, $user->getUserId(), true); - if ($previousRequestParameters = $this->session->previousRequestParameters) { - $this->_reroute(array('controller' => $previousRequestParameters['controller'], 'action' => $previousRequestParameters['action']), false); - } else { - // This reroutes to the first available menu page after login - $this->_reroute(array('controller' => null, 'action' => null), true); - } - return; + if ($previousRequestParameters = $this->session->previousRequestParameters) { + $this->_reroute(array('controller' => $previousRequestParameters['controller'], 'action' => $previousRequestParameters['action']), false); } else { - $errors = $authResult->getMessages(); - $this->addMessage($errors); + // This reroutes to the first available menu page after login + $this->_reroute(array('controller' => null, 'action' => null), true); } + return; + } else { + $errors = $authResult->getMessages(); + $this->addMessage($errors); } - } else { - $errors = $form->getErrors(); } } $this->view->form = $form; Modified: trunk/library/classes/Gems/User/NoLoginDefinition.php =================================================================== --- trunk/library/classes/Gems/User/NoLoginDefinition.php 2011-11-16 17:52:38 UTC (rev 223) +++ trunk/library/classes/Gems/User/NoLoginDefinition.php 2011-11-16 18:18:12 UTC (rev 224) @@ -46,14 +46,14 @@ */ class Gems_User_NoLoginDefinition extends Gems_User_UserDefinitionAbstract { - private function alwaysFalse($params) { - $result = new Zend_Auth_Result(Zend_Auth_Result::FAILURE, $params['userlogin']); + public function alwaysFalse($params) + { return false; } - + public function getAuthAdapter($formValues) { - $adapter = new Gems_Auth_Adapter_Callback(array(get_class(),'alwaysFalse'), $formValues['userlogin'], $formValues); + $adapter = new Gems_Auth_Adapter_Callback(array($this,'alwaysFalse'), $formValues['userlogin'], $formValues); return $adapter; } Modified: trunk/library/classes/Gems/User/ProjectUserDefinition.php =================================================================== --- trunk/library/classes/Gems/User/ProjectUserDefinition.php 2011-11-16 17:52:38 UTC (rev 223) +++ trunk/library/classes/Gems/User/ProjectUserDefinition.php 2011-11-16 18:18:12 UTC (rev 224) @@ -54,7 +54,7 @@ public function getAuthAdapter($formValues) { - $adapter = new Gems_Auth_Adapter_Callback(array($this->project,'checkSuperAdminPassword'), $formValues['userlogin'], $formValues['password']); + $adapter = new Gems_Auth_Adapter_Callback(array($this->project,'checkSuperAdminPassword'), $formValues['userlogin'], array($formValues['password'])); return $adapter; } Modified: trunk/library/languages/default-en.mo =================================================================== (Binary files differ) Modified: trunk/library/languages/default-en.po =================================================================== --- trunk/library/languages/default-en.po 2011-11-16 17:52:38 UTC (rev 223) +++ trunk/library/languages/default-en.po 2011-11-16 18:18:12 UTC (rev 224) @@ -2,7 +2,7 @@ msgstr "" "Project-Id-Version: Pulse EN\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2011-11-16 18:30+0100\n" +"POT-Creation-Date: 2011-11-16 19:09+0100\n" "PO-Revision-Date: \n" "Last-Translator: Matijs de Jong <mj...@ma...>\n" "Language-Team: Erasmus MGZ <mat...@ma...>\n" @@ -77,13 +77,9 @@ msgid "Database needs to be updated!" msgstr "Database needs to be updated!" -#: classes/Gems/Auth.php:225 -msgid "Wrong password." -msgstr "Wrong password." - #: classes/Gems/Auth.php:228 -msgid "Combination of username password not found." -msgstr "Combination of username password not found." +msgid "Combination of organization, username and password not found." +msgstr "Combination of organization, username and password not found." #: classes/Gems/Html.php:154 msgid "<< First" @@ -3784,6 +3780,9 @@ msgid "This track can be assigned since %s." msgstr "This track can be assigned since %s." +#~ msgid "Wrong password." +#~ msgstr "Wrong password." + #~ msgid "Please update the database" #~ msgstr "Please update the database" Modified: trunk/library/languages/default-nl.mo =================================================================== (Binary files differ) Modified: trunk/library/languages/default-nl.po =================================================================== --- trunk/library/languages/default-nl.po 2011-11-16 17:52:38 UTC (rev 223) +++ trunk/library/languages/default-nl.po 2011-11-16 18:18:12 UTC (rev 224) @@ -2,7 +2,7 @@ msgstr "" "Project-Id-Version: Pulse NL\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2011-11-16 18:33+0100\n" +"POT-Creation-Date: 2011-11-16 19:10+0100\n" "PO-Revision-Date: \n" "Last-Translator: Matijs de Jong <mj...@ma...>\n" "Language-Team: Erasmus MGZ <mat...@ma...>\n" @@ -77,13 +77,9 @@ msgid "Database needs to be updated!" msgstr "Database dient ververst te worden!" -#: classes/Gems/Auth.php:225 -msgid "Wrong password." -msgstr "Verkeerd wachtwoord." - #: classes/Gems/Auth.php:228 -msgid "Combination of username password not found." -msgstr "Combinatie gebruikersnaam en wachtwoord niet gevonden." +msgid "Combination of organization, username and password not found." +msgstr "Combinatie van organisatie, gebruikersnaam en wachtwoord niet gevonden." #: classes/Gems/Html.php:154 msgid "<< First" @@ -3784,6 +3780,9 @@ msgid "This track can be assigned since %s." msgstr "Dit traject kan sinds %s aan een patiënt toegewezen worden." +#~ msgid "Wrong password." +#~ msgstr "Verkeerd wachtwoord." + #~ msgid "Please update the database" #~ msgstr "Database moet bijgewerkt worden" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2011-11-16 17:52:48
|
Revision: 223 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=223&view=rev Author: matijsdejong Date: 2011-11-16 17:52:38 +0000 (Wed, 16 Nov 2011) Log Message: ----------- Start on #40: organizations can defer to each other. Input possible. Array values can be saved in a model and read by multi elements. Modified Paths: -------------- trunk/library/classes/Gems/Default/OrganizationAction.php trunk/library/classes/MUtil/Model/FormBridge.php trunk/library/configs/db/patches.sql trunk/library/configs/db/tables/gems__organizations.20.sql trunk/library/languages/default-en.mo trunk/library/languages/default-en.po trunk/library/languages/default-nl.mo trunk/library/languages/default-nl.po Added Paths: ----------- trunk/library/classes/MUtil/Form/Element/MultiCheckbox.php trunk/library/classes/MUtil/Form/Element/MultiSelect.php trunk/library/classes/MUtil/Model/Save/ trunk/library/classes/MUtil/Model/Save/ArraySaver.php Modified: trunk/library/classes/Gems/Default/OrganizationAction.php =================================================================== --- trunk/library/classes/Gems/Default/OrganizationAction.php 2011-11-16 13:19:44 UTC (rev 222) +++ trunk/library/classes/Gems/Default/OrganizationAction.php 2011-11-16 17:52:38 UTC (rev 223) @@ -140,15 +140,20 @@ 'gor_iso_lang', 'label', $this->_('Language'), 'multiOptions', $this->util->getLocalized()->getLanguages(), 'default', 'nl' ); - $model->set( - 'gor_active', 'label', $this->_('Active'), 'elementClass', 'Checkbox', - 'multiOptions', $this->util->getTranslated()->getYesNo() - ); + $yesNo = $this->util->getTranslated()->getYesNo(); + $model->set('gor_active', 'label', $this->_('Active'), 'elementClass', 'Checkbox', 'multiOptions', $yesNo); + $model->set('gor_add_patients', 'label', $this->_('Allow new respondents'), 'elementClass', 'CheckBox', 'multiOptions', $yesNo); + if ($detailed) { $model->set('gor_name', 'validator', $model->createUniqueValidator('gor_name')); $model->set('gor_welcome', 'label', $this->_('Greeting'), 'description', $this->_('For emails and token forward screen.'), 'elementClass', 'Textarea', 'rows', 5); $model->set('gor_signature', 'label', $this->_('Signature'), 'description', $this->_('For emails and token forward screen.'), 'elementClass', 'Textarea', 'rows', 5); + + $model->set('gor_accessible_by', 'label', $this->_('Accessible by'), 'description', $this->_('Checked organizations see this organizations respondents.'), 'elementClass', 'MultiCheckbox', + 'multiOptions', $this->util->getDbLookup()->getOrganizations()); + MUtil_Model_Save_ArraySaver::create($model, 'gor_accessible_by', ':'); + } if ($this->project->multiLocale) { Added: trunk/library/classes/MUtil/Form/Element/MultiCheckbox.php =================================================================== --- trunk/library/classes/MUtil/Form/Element/MultiCheckbox.php (rev 0) +++ trunk/library/classes/MUtil/Form/Element/MultiCheckbox.php 2011-11-16 17:52:38 UTC (rev 223) @@ -0,0 +1,143 @@ +<?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 Form + * @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 $ + */ + +/** + * This object allows you to supply a string value when the object expects an + * array value, splitting the string along the valueSeperatorChar. + * + * Return this value as a string is not practical as that breaks the workings + * of all Filters, Validators and Decorators. + * + * @package MUtil + * @subpackage Form + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @since Class available since version 1.5 + */ +class MUtil_Form_Element_MultiCheckbox extends Zend_Form_Element_MultiCheckbox +{ + /** + * En/disables padding the value in separators. The default is true as this + * simplifies search commands (and usually costs only 2 characters). + * + * @var boolean + */ + protected $_valuePad = true; + + /** + * The value seperator enables this control to accept a single string as value + * and split it into an array. + * + * A null seperator means this class behaves as it's parent class and returns an + * array value. + * + * @var string + */ + protected $_valueSeperatorChar = null; + + /** + * En/disables padding the value in separators. The default is true as this + * simplifies search commands (and usually costs only 2 characters). + * + * @return boolean + */ + public function getValuePad() + { + return $this->_valuePad; + } + + /** + * The value seperator enables this control to accept a single string as value + * and split it into an array. + * + * A null seperator means this class behaves as it's parent class and returns an + * array value. + * + * @return string + */ + public function getValueSeperatorChar() + { + return $this->_valueSeperatorChar; + } + + /** + * Set element value + * + * @param mixed $value + * @return MUtil_Form_Element_MultiCheckbox (continuation pattern) + */ + public function setValue($value) + { + if ((null !== $this->_valueSeperatorChar) && (! is_array($value))) { + if ($this->_valuePad) { + $value = trim($value, $this->_valueSeperatorChar); + } + $value = explode($this->_valueSeperatorChar, $value); + } + + return parent::setValue($value); + } + + /** + * En/disables padding the value in separators. The default is true as this + * simplifies search commands (and usually costs only 2 characters). + * + * @param boolean $value + * @return MUtil_Form_Element_MultiCheckbox (continuation pattern) + */ + public function setValuePad($value = true) + { + $this->_valuePad = $value; + return $this; + } + + /** + * The value seperator enables this control to accept a single string as value + * and split it into an array. + * + * A null seperator means this class behaves as it's parent class and returns an + * array value. + * + * @param string $seperator + * @return MUtil_Form_Element_MultiCheckbox (continuation pattern) + */ + public function setValueSeperatorChar($seperator = ' ') + { + $this->_valueSeperatorChar = substr($seperator . ' ', 0, 1); + return $this; + } +} Added: trunk/library/classes/MUtil/Form/Element/MultiSelect.php =================================================================== --- trunk/library/classes/MUtil/Form/Element/MultiSelect.php (rev 0) +++ trunk/library/classes/MUtil/Form/Element/MultiSelect.php 2011-11-16 17:52:38 UTC (rev 223) @@ -0,0 +1,143 @@ +<?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 Form + * @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 $ + */ + +/** + * This object allows you to supply a string value when the object expects an + * array value, splitting the string along the valueSeperatorChar. + * + * Return this value as a string is not practical as that breaks the workings + * of all Filters, Validators and Decorators. + * + * @package MUtil + * @subpackage Form + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @since Class available since version 1.5 + */ +class MUtil_Form_Element_MultiSelect extends Zend_Form_Element_MultiSelect +{ + /** + * En/disables padding the value in separators. The default is true as this + * simplifies search commands (and usually costs only 2 characters). + * + * @var boolean + */ + protected $_valuePad = true; + + /** + * The value seperator enables this control to accept a single string as value + * and split it into an array. + * + * A null seperator means this class behaves as it's parent class and returns an + * array value. + * + * @var string + */ + protected $_valueSeperatorChar = null; + + /** + * En/disables padding the value in separators. The default is true as this + * simplifies search commands (and usually costs only 2 characters). + * + * @return boolean + */ + public function getValuePad() + { + return $this->_valuePad; + } + + /** + * The value seperator enables this control to accept a single string as value + * and split it into an array. + * + * A null seperator means this class behaves as it's parent class and returns an + * array value. + * + * @return string + */ + public function getValueSeperatorChar() + { + return $this->_valueSeperatorChar; + } + + /** + * Set element value + * + * @param mixed $value + * @return MUtil_Form_Element_MultiCheckbox (continuation pattern) + */ + public function setValue($value) + { + if ((null !== $this->_valueSeperatorChar) && (! is_array($value))) { + if ($this->_valuePad) { + $value = trim($value, $this->_valueSeperatorChar); + } + $value = explode($this->_valueSeperatorChar, $value); + } + + return parent::setValue($value); + } + + /** + * En/disables padding the value in separators. The default is true as this + * simplifies search commands (and usually costs only 2 characters). + * + * @param boolean $value + * @return MUtil_Form_Element_MultiCheckbox (continuation pattern) + */ + public function setValuePad($value = true) + { + $this->_valuePad = $value; + return $this; + } + + /** + * The value seperator enables this control to accept a single string as value + * and split it into an array. + * + * A null seperator means this class behaves as it's parent class and returns an + * array value. + * + * @param string $seperator + * @return MUtil_Form_Element_MultiCheckbox (continuation pattern) + */ + public function setValueSeperatorChar($seperator = ' ') + { + $this->_valueSeperatorChar = substr($seperator . ' ', 0, 1); + return $this; + } +} Modified: trunk/library/classes/MUtil/Model/FormBridge.php =================================================================== --- trunk/library/classes/MUtil/Model/FormBridge.php 2011-11-16 13:19:44 UTC (rev 222) +++ trunk/library/classes/MUtil/Model/FormBridge.php 2011-11-16 17:52:38 UTC (rev 223) @@ -85,7 +85,7 @@ self::FILE_OPTIONS => array('accept', 'count', 'destination', 'valueDisabled'), self::GROUP_OPTIONS => array('elements', 'legend', 'separator'), self::JQUERY_OPTIONS => array('jQueryParams'), - self::MULTI_OPTIONS => array('disable', 'multiOptions', 'onchange', 'separator', 'size'), + self::MULTI_OPTIONS => array('disable', 'multiOptions', 'onchange', 'separator', 'size', 'valuePad', 'valueSeperatorChar'), self::PASSWORD_OPTIONS => array('repeatLabel'), self::TAB_OPTIONS => array('value'), self::TEXT_OPTIONS => array('maxlength', 'minlength', 'onchange', 'onfocus', 'onselect', 'size'), @@ -538,7 +538,7 @@ $options = $this->_mergeOptions($name, $options, self::DISPLAY_OPTIONS, self::MULTI_OPTIONS); - $element = new Zend_Form_Element_MultiCheckbox($name, $options); + $element = new MUtil_Form_Element_MultiCheckbox($name, $options); return $this->_addToForm($name, $element); } @@ -562,7 +562,7 @@ $options = $this->_mergeOptions($name, $options, self::DISPLAY_OPTIONS, self::MULTI_OPTIONS); - $element = new Zend_Form_Element_Multiselect($name, $options); + $element = new MUtil_Form_Element_Multiselect($name, $options); return $this->_addToForm($name, $element); } Property changes on: trunk/library/classes/MUtil/Model/Save ___________________________________________________________________ Added: bugtraq:url + http://survey.erasmusmc.nl/support/mantis/view.php?id=%BUGID% Added: bugtraq:logregex + #(\d+) Added: trunk/library/classes/MUtil/Model/Save/ArraySaver.php =================================================================== --- trunk/library/classes/MUtil/Model/Save/ArraySaver.php (rev 0) +++ trunk/library/classes/MUtil/Model/Save/ArraySaver.php 2011-11-16 17:52:38 UTC (rev 223) @@ -0,0 +1,89 @@ +<?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 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 MUtil + * @subpackage Model + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @since Class available since version 1.5 + */ +class MUtil_Model_Save_ArraySaver +{ + protected $seperatorChar = ' '; + + protected $valuePad = true; + + public function __construct($seperatorChar = ' ', $valuePad = true) + { + $this->seperatorChar = substr($seperatorChar . ' ', 0, 1); + $this->valuePad = $valuePad; + } + + /** + * If this field is saved as an array value, use + * + * @param MUtil_Model_ModelAbstract $model + * @param string $name The field to set the seperator character + * @param string $char + * @param boolean $pad + * @return MUtil_Model_ModelAbstract (continuation pattern) + */ + public static function create(MUtil_Model_ModelAbstract $model, $name, $char = ' ', $pad = true) + { + $class = new self($char, $pad); + + $model->set($name, 'valueSeperatorChar', substr($char . ' ', 0, 1), 'valuePad', $pad); + $model->setOnSave($name, array($class, 'saveValue')); + + return $class; + } + + public function saveValue($name, $value, $isNew) + { + if (is_array($value)) { + $value = implode($this->seperatorChar, $value); + + if ($this->valuePad) { + $value = $this->seperatorChar . $value . $this->seperatorChar; + } + } + return $value; + } +} Modified: trunk/library/configs/db/patches.sql =================================================================== --- trunk/library/configs/db/patches.sql 2011-11-16 13:19:44 UTC (rev 222) +++ trunk/library/configs/db/patches.sql 2011-11-16 17:52:38 UTC (rev 223) @@ -311,3 +311,11 @@ -- PATCH: Change Burger Service Nummer to Social Security Number ALTER TABLE `gems__respondents` CHANGE `grs_bsn` `grs_ssn` VARCHAR( 32 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL; + +-- PATCH: Extending organizations + +ALTER TABLE `gems__organizations` ADD UNIQUE INDEX (`gor_code`); + +ALTER TABLE `gems__organizations` ADD gor_accessible_by text CHARACTER SET 'utf8' COLLATE 'utf8_general_ci' null AFTER gor_task, + ADD gor_has_patients boolean not null default 1 AFTER gor_iso_lang, + ADD gor_add_patients boolean not null default 1 AFTER gor_has_patients; Modified: trunk/library/configs/db/tables/gems__organizations.20.sql =================================================================== --- trunk/library/configs/db/tables/gems__organizations.20.sql 2011-11-16 13:19:44 UTC (rev 222) +++ trunk/library/configs/db/tables/gems__organizations.20.sql 2011-11-16 17:52:38 UTC (rev 223) @@ -3,20 +3,25 @@ gor_id_organization bigint unsigned not null auto_increment, gor_name varchar(50) CHARACTER SET 'utf8' COLLATE 'utf8_general_ci' not null, - gor_code varchar(20) CHARACTER SET 'utf8' COLLATE 'utf8_general_ci', - gor_location varchar(50) CHARACTER SET 'utf8' COLLATE 'utf8_general_ci', - gor_url varchar(127) CHARACTER SET 'utf8' COLLATE 'utf8_general_ci', - gor_task varchar(50) CHARACTER SET 'utf8' COLLATE 'utf8_general_ci', + gor_code varchar(20) CHARACTER SET 'utf8' COLLATE 'utf8_general_ci' null, + gor_location varchar(50) CHARACTER SET 'utf8' COLLATE 'utf8_general_ci' null, + gor_url varchar(127) CHARACTER SET 'utf8' COLLATE 'utf8_general_ci' null, + gor_task varchar(50) CHARACTER SET 'utf8' COLLATE 'utf8_general_ci' null, - gor_contact_name varchar(50) CHARACTER SET 'utf8' COLLATE 'utf8_general_ci', - gor_contact_email varchar(127) CHARACTER SET 'utf8' COLLATE 'utf8_general_ci', - gor_welcome text CHARACTER SET 'utf8' COLLATE 'utf8_general_ci', - gor_signature text CHARACTER SET 'utf8' COLLATE 'utf8_general_ci', + -- A commy separated list of organization numbers that can look at respondents in this organization + gor_accessible_by text CHARACTER SET 'utf8' COLLATE 'utf8_general_ci' null, + gor_contact_name varchar(50) CHARACTER SET 'utf8' COLLATE 'utf8_general_ci' null, + gor_contact_email varchar(127) CHARACTER SET 'utf8' COLLATE 'utf8_general_ci' null, + gor_welcome text CHARACTER SET 'utf8' COLLATE 'utf8_general_ci' null, + gor_signature text CHARACTER SET 'utf8' COLLATE 'utf8_general_ci' null, + gor_style varchar(15) CHARACTER SET 'utf8' COLLATE 'utf8_general_ci' not null default 'gems', gor_iso_lang char(2) CHARACTER SET 'utf8' COLLATE 'utf8_general_ci' not null default 'en' references gems__languages (gml_iso_lang), + gor_has_patients boolean not null default 1, + gor_add_patients boolean not null default 1, gor_active boolean not null default 1, gor_changed timestamp not null default current_timestamp on update current_timestamp, @@ -24,15 +29,9 @@ gor_created timestamp not null, gor_created_by bigint unsigned not null, - PRIMARY KEY(gor_id_organization) + PRIMARY KEY(gor_id_organization), + UNIQUE (gor_code) ) ENGINE=InnoDB AUTO_INCREMENT = 70 CHARACTER SET 'utf8' COLLATE 'utf8_general_ci'; - --- Default group -INSERT ignore INTO gems__organizations - (gor_id_organization, gor_name, gor_location, gor_active, gor_iso_lang, gor_changed, gor_changed_by, gor_created, gor_created_by) - VALUES - (70, 'Erasmus MGZ', 'Rotterdam', 1, 'nl', current_timestamp, 0, current_timestamp, 0); - Modified: trunk/library/languages/default-en.mo =================================================================== (Binary files differ) Modified: trunk/library/languages/default-en.po =================================================================== --- trunk/library/languages/default-en.po 2011-11-16 13:19:44 UTC (rev 222) +++ trunk/library/languages/default-en.po 2011-11-16 17:52:38 UTC (rev 223) @@ -2,7 +2,7 @@ msgstr "" "Project-Id-Version: Pulse EN\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2011-11-03 12:50+0100\n" +"POT-Creation-Date: 2011-11-16 18:30+0100\n" "PO-Revision-Date: \n" "Last-Translator: Matijs de Jong <mj...@ma...>\n" "Language-Team: Erasmus MGZ <mat...@ma...>\n" @@ -18,58 +18,58 @@ "X-Poedit-KeywordsList: plural:1,2\n" "X-Poedit-SearchPath-0: .\n" -#: classes/GemsEscort.php:186 +#: classes/GemsEscort.php:201 #, php-format msgid "Path %s not writable" msgstr "Path %s not writable" -#: classes/GemsEscort.php:860 +#: classes/GemsEscort.php:876 #, php-format msgid "User: %s" msgstr "User: %s" -#: classes/GemsEscort.php:884 +#: classes/GemsEscort.php:900 msgid "version" msgstr "version" -#: classes/GemsEscort.php:1405 +#: classes/GemsEscort.php:1330 msgid "Take note: your session has expired, your inputs where not saved. Please check the input data and try again" msgstr "Take note: your session has expired, your inputs where not saved. Please check the input data and try again" -#: classes/GemsEscort.php:1526 +#: classes/GemsEscort.php:1454 msgid "Please check back later." msgstr "Please check back later." -#: classes/GemsEscort.php:1528 -#: classes/GemsEscort.php:1531 -#: classes/GemsEscort.php:1532 +#: classes/GemsEscort.php:1456 +#: classes/GemsEscort.php:1460 +#: classes/GemsEscort.php:1461 msgid "System is in maintenance mode" msgstr "System is in maintenance mode" -#: classes/GemsEscort.php:1546 +#: classes/GemsEscort.php:1470 msgid "No access to site." msgstr "No access to site." -#: classes/GemsEscort.php:1548 -#: classes/GemsEscort.php:1584 +#: classes/GemsEscort.php:1472 +#: classes/GemsEscort.php:1508 msgid "You have no access to this site." msgstr "You have no access to this site." -#: classes/GemsEscort.php:1564 +#: classes/GemsEscort.php:1488 msgid "No access to page" msgstr "No access to page" -#: classes/GemsEscort.php:1566 +#: classes/GemsEscort.php:1490 #, php-format msgid "Access to this page is not allowed for current role: %s." msgstr "Access to this page is not allowed for current role: %s." -#: classes/GemsEscort.php:1571 -#: classes/GemsEscort.php:1582 +#: classes/GemsEscort.php:1495 +#: classes/GemsEscort.php:1506 msgid "You are no longer logged in." msgstr "You are no longer logged in." -#: classes/GemsEscort.php:1572 +#: classes/GemsEscort.php:1496 msgid "You must login to access this page." msgstr "You must login to access this page." @@ -77,15 +77,11 @@ msgid "Database needs to be updated!" msgstr "Database needs to be updated!" -#: classes/Gems/Auth.php:107 -msgid "Please update the database" -msgstr "Please update the database" - -#: classes/Gems/Auth.php:174 +#: classes/Gems/Auth.php:225 msgid "Wrong password." msgstr "Wrong password." -#: classes/Gems/Auth.php:177 +#: classes/Gems/Auth.php:228 msgid "Combination of username password not found." msgstr "Combination of username password not found." @@ -175,7 +171,7 @@ msgstr "Roles" #: classes/Gems/Menu.php:196 -#: classes/Gems/Menu.php:337 +#: classes/Gems/Menu.php:345 msgid "Assigned" msgstr "Assigned" @@ -203,181 +199,202 @@ msgid "Maintenance" msgstr "Maintenance" -#: classes/Gems/Menu.php:227 +#: classes/Gems/Menu.php:218 +msgid "Upgrade" +msgstr "Upgrade" + +#: classes/Gems/Menu.php:219 +#: classes/Gems/Menu.php:318 +msgid "Show" +msgstr "Show" + +#: classes/Gems/Menu.php:220 +msgid "Execute all" +msgstr "Execute all" + +#: classes/Gems/Menu.php:221 +msgid "Execute this" +msgstr "Execute this" + +#: classes/Gems/Menu.php:222 +msgid "Execute from here" +msgstr "Execute from here" + +#: classes/Gems/Menu.php:223 +msgid "Execute to here" +msgstr "Execute to here" + +#: classes/Gems/Menu.php:235 #, php-format msgid "Stand-alone privilige: %s" msgstr "Stand-alone privilige: %s" -#: classes/Gems/Menu.php:234 +#: classes/Gems/Menu.php:242 msgid "Logon" msgstr "Logon" -#: classes/Gems/Menu.php:235 +#: classes/Gems/Menu.php:243 msgid "Lost password" msgstr "Lost password" -#: classes/Gems/Menu.php:236 +#: classes/Gems/Menu.php:244 msgid "Your account" msgstr "Your account" -#: classes/Gems/Menu.php:237 +#: classes/Gems/Menu.php:245 msgid "Activity overview" msgstr "Activity overview" -#: classes/Gems/Menu.php:238 +#: classes/Gems/Menu.php:246 msgid "Change password" msgstr "Change password" -#: classes/Gems/Menu.php:239 -#: classes/Gems/Menu.php:279 -#: classes/Gems/Menu.php:314 +#: classes/Gems/Menu.php:247 +#: classes/Gems/Menu.php:287 +#: classes/Gems/Menu.php:322 msgid "Token" msgstr "Token" -#: classes/Gems/Menu.php:240 +#: classes/Gems/Menu.php:248 msgid "Logoff" msgstr "Logoff" -#: classes/Gems/Menu.php:275 +#: classes/Gems/Menu.php:283 msgid "Track" msgstr "Track" -#: classes/Gems/Menu.php:282 -#: classes/Gems/Menu.php:302 -#: classes/Gems/Menu.php:333 +#: classes/Gems/Menu.php:290 +#: classes/Gems/Menu.php:310 +#: classes/Gems/Menu.php:341 msgid "Add" msgstr "Add" -#: classes/Gems/Menu.php:286 -#: classes/Gems/Menu.php:369 +#: classes/Gems/Menu.php:294 +#: classes/Gems/Menu.php:377 msgid "Preview" msgstr "Preview" -#: classes/Gems/Menu.php:293 +#: classes/Gems/Menu.php:301 msgid "Tracks" msgstr "Tracks" -#: classes/Gems/Menu.php:306 +#: classes/Gems/Menu.php:314 msgid "Assignments" msgstr "Assignments" -#: classes/Gems/Menu.php:310 -msgid "Show" -msgstr "Show" - -#: classes/Gems/Menu.php:318 +#: classes/Gems/Menu.php:326 msgid "Edit" msgstr "Edit" -#: classes/Gems/Menu.php:322 +#: classes/Gems/Menu.php:330 msgid "Delete" msgstr "Delete" -#: classes/Gems/Menu.php:327 +#: classes/Gems/Menu.php:335 msgid "Surveys" msgstr "Surveys" -#: classes/Gems/Menu.php:359 +#: classes/Gems/Menu.php:367 msgid "Fill in" msgstr "Fill in" -#: classes/Gems/Menu.php:363 +#: classes/Gems/Menu.php:371 msgid "Print PDF" msgstr "Print PDF" -#: classes/Gems/Menu.php:366 +#: classes/Gems/Menu.php:374 msgid "E-Mail now!" msgstr "E-Mail now!" -#: classes/Gems/Menu.php:372 +#: classes/Gems/Menu.php:380 msgid "Answers" msgstr "Answers" -#: classes/Gems/Menu.php:510 +#: classes/Gems/Menu.php:518 msgid "Respondents" msgstr "Patients" -#: classes/Gems/Menu.php:513 +#: classes/Gems/Menu.php:521 msgid "Overview" msgstr "Overview" -#: classes/Gems/Menu.php:520 +#: classes/Gems/Menu.php:528 msgid "Project" msgstr "Project" -#: classes/Gems/Menu.php:523 +#: classes/Gems/Menu.php:531 msgid "Setup" msgstr "Setup" -#: classes/Gems/Menu.php:526 +#: classes/Gems/Menu.php:534 msgid "Mail" msgstr "Mail" -#: classes/Gems/Menu.php:529 +#: classes/Gems/Menu.php:537 msgid "Track Builder" msgstr "Track Builder" -#: classes/Gems/Menu.php:538 +#: classes/Gems/Menu.php:546 msgid "Contact" msgstr "Contact" -#: classes/Gems/Menu.php:551 +#: classes/Gems/Menu.php:559 msgid "Changelog" msgstr "Changelog" -#: classes/Gems/Model.php:106 +#: classes/Gems/Model.php:190 msgid "Respondent nr" msgstr "Patient nr" -#: classes/Gems/Model.php:107 +#: classes/Gems/Model.php:191 msgid "Opened" msgstr "Opened" -#: classes/Gems/Model.php:108 +#: classes/Gems/Model.php:192 msgid "Consent" msgstr "Consent" -#: classes/Gems/Model.php:110 +#: classes/Gems/Model.php:194 msgid "E-Mail" msgstr "E-Mail" -#: classes/Gems/Model.php:115 +#: classes/Gems/Model.php:199 msgid "Gender" msgstr "Gender" -#: classes/Gems/Model.php:116 +#: classes/Gems/Model.php:200 msgid "First name" msgstr "First name" -#: classes/Gems/Model.php:117 +#: classes/Gems/Model.php:201 msgid "Surname prefix" msgstr "Surname prefix" -#: classes/Gems/Model.php:118 +#: classes/Gems/Model.php:202 msgid "Last name" msgstr "Last name" -#: classes/Gems/Model.php:120 +#: classes/Gems/Model.php:204 msgid "Name" msgstr "Name" -#: classes/Gems/Model.php:123 +#: classes/Gems/Model.php:207 msgid "Street" msgstr "Street" -#: classes/Gems/Model.php:124 +#: classes/Gems/Model.php:208 msgid "Zipcode" msgstr "Zipcode" -#: classes/Gems/Model.php:125 +#: classes/Gems/Model.php:209 msgid "City" msgstr "City" -#: classes/Gems/Model.php:127 +#: classes/Gems/Model.php:211 msgid "Phone" msgstr "Phone" -#: classes/Gems/Model.php:129 +#: classes/Gems/Model.php:213 msgid "Birthday" msgstr "Birthday" @@ -385,6 +402,20 @@ msgid "Checks performed" msgstr "Checks performed" +#: classes/Gems/UpgradesAbstract.php:164 +msgid "Already at max. level." +msgstr "Already at max. level." + +#: classes/Gems/UpgradesAbstract.php:171 +#, php-format +msgid "Trying upgrade for %s from level %s to level %s" +msgstr "Trying upgrade for %s from level %s to level %s" + +#: classes/Gems/UpgradesAbstract.php:179 +#, php-format +msgid "Trying upgrade for %s to level %s: %s" +msgstr "Trying upgrade for %s to level %s: %s" + #: classes/Gems/Controller/BrowseEditAction.php:344 #, php-format msgid "New %s..." @@ -473,7 +504,8 @@ msgstr "Unknown %s." #: classes/Gems/Controller/ModelActionAbstract.php:97 -#: classes/Gems/Default/AskAction.php:149 +#: classes/Gems/Default/AskAction.php:150 +#: classes/Gems/Default/DatabaseAction.php:524 msgid "Cancel" msgstr "Cancel" @@ -481,99 +513,99 @@ msgid "No data found." msgstr "No data found." -#: classes/Gems/Default/AskAction.php:127 +#: classes/Gems/Default/AskAction.php:128 #, php-format msgid "Welcome %s," msgstr "Welcome %s," -#: classes/Gems/Default/AskAction.php:130 +#: classes/Gems/Default/AskAction.php:131 #, php-format msgid "Thank you for answering the survey for token %s." msgstr "Thank you for answering the survey for token %s." -#: classes/Gems/Default/AskAction.php:131 +#: classes/Gems/Default/AskAction.php:132 msgid "Please click the button below to answer the next survey." msgstr "Please click the button below to answer the next survey." -#: classes/Gems/Default/AskAction.php:136 +#: classes/Gems/Default/AskAction.php:137 #, php-format msgid "Please click the button below to answer the survey for token %s." msgstr "Please click the button below to answer the survey for token %s." -#: classes/Gems/Default/AskAction.php:140 +#: classes/Gems/Default/AskAction.php:141 #, php-format msgid "Wait one second to open the survey automatically or click on Cancel to stop." msgid_plural "Wait %d seconds to open the survey automatically or click on Cancel to stop." msgstr[0] "Wait one second to open the survey automatically or click on Cancel to stop." msgstr[1] "Wait %d seconds to open the survey automatically or click on Cancel to stop." -#: classes/Gems/Default/AskAction.php:155 +#: classes/Gems/Default/AskAction.php:156 #, php-format msgid "After this survey there is one other survey we would like you to answer." msgid_plural "After this survey there are another %d surveys we would like you to answer." msgstr[0] "After this survey there is one other survey we would like you to answer." msgstr[1] "After this survey there are another %d surveys we would like you to answer." -#: classes/Gems/Default/AskAction.php:165 +#: classes/Gems/Default/AskAction.php:166 #, php-format msgid "The survey for token %s is no longer active." msgstr "The survey for token %s is no longer active." -#: classes/Gems/Default/AskAction.php:169 +#: classes/Gems/Default/AskAction.php:170 #, php-format msgid "The token %s does not exist." msgstr "The token %s does not exist." -#: classes/Gems/Default/AskAction.php:171 +#: classes/Gems/Default/AskAction.php:172 #, php-format msgid "Thank you for answering. At the moment we have no further surveys for you to take." msgstr "Thank you for answering. At the moment we have no further surveys for you to take." -#: classes/Gems/Default/AskAction.php:173 +#: classes/Gems/Default/AskAction.php:174 #, php-format msgid "The survey for token %s has been answered and no further surveys are open." msgstr "The survey for token %s has been answered and no further surveys are open." -#: classes/Gems/Default/AskAction.php:180 +#: classes/Gems/Default/AskAction.php:181 #, php-format msgid "The token %s does not exist (any more)." msgstr "The token %s does not exist (any more)." -#: classes/Gems/Default/AskAction.php:194 +#: classes/Gems/Default/AskAction.php:198 #, php-format msgid "Enter your %s token" msgstr "Enter your %s token" -#: classes/Gems/Default/AskAction.php:199 +#: classes/Gems/Default/AskAction.php:203 #, php-format msgid "Enter tokens as %s." msgstr "Enter tokens as %s." -#: classes/Gems/Default/AskAction.php:209 +#: classes/Gems/Default/AskAction.php:213 msgid "OK" msgstr "OK" -#: classes/Gems/Default/AskAction.php:225 +#: classes/Gems/Default/AskAction.php:229 msgid "Tokens identify a survey that was assigned to you personally." msgstr "Tokens identify a survey that was assigned to you personally." -#: classes/Gems/Default/AskAction.php:225 +#: classes/Gems/Default/AskAction.php:229 msgid "Entering the token and pressing OK will open that survey." msgstr "Entering the token and pressing OK will open that survey." -#: classes/Gems/Default/AskAction.php:229 +#: classes/Gems/Default/AskAction.php:233 msgid "After answering the survey you will be logged off automatically." msgstr "After answering the survey you will be logged off automatically." -#: classes/Gems/Default/AskAction.php:231 +#: classes/Gems/Default/AskAction.php:235 msgid "After answering the survey you will return to the respondent overview screen." msgstr "After answering the survey you will return to the paitent overview screen." -#: classes/Gems/Default/AskAction.php:238 +#: classes/Gems/Default/AskAction.php:242 msgid "A token consists of two groups of four letters and numbers, separated by an optional hyphen. Tokens are case insensitive." msgstr "A token consists of two groups of four letters and numbers, separated by an optional hyphen. Tokens are case insensitive." -#: classes/Gems/Default/AskAction.php:239 +#: classes/Gems/Default/AskAction.php:243 msgid "The number zero and the letter O are treated as the same; the same goes for the number one and the letter L." msgstr "The number zero and the letter O are treated as the same; the same goes for the number one and the letter L." @@ -637,14 +669,18 @@ msgid "Links concerning this web application:" msgstr "Links concerning this web application:" -#: classes/Gems/Default/CronAction.php:136 +#: classes/Gems/Default/CronAction.php:148 msgid "Cron jobs turned off." msgstr "Cron jobs turned off." -#: classes/Gems/Default/CronAction.php:200 -msgid "No mails sent" -msgstr "No mails sent" +#: classes/Gems/Default/CronAction.php:218 +msgid "No mails sent." +msgstr "No mails sent." +#: classes/Gems/Default/CronAction.php:221 +msgid "On this test system all mail will be delivered to the from address." +msgstr "On this test system all mail will be delivered to the from address." + #: classes/Gems/Default/DatabaseAction.php:64 #, php-format msgid "Executed %2$s creation script %1$s:" @@ -781,12 +817,12 @@ msgstr "Database object overview" #: classes/Gems/Default/DatabaseAction.php:316 -#: classes/Gems/Default/DatabaseAction.php:362 +#: classes/Gems/Default/DatabaseAction.php:360 msgid "Level" msgstr "Level" #: classes/Gems/Default/DatabaseAction.php:317 -#: classes/Gems/Default/DatabaseAction.php:363 +#: classes/Gems/Default/DatabaseAction.php:361 msgid "Subtype" msgstr "Subtype" @@ -795,12 +831,12 @@ msgstr "To be executed" #: classes/Gems/Default/DatabaseAction.php:320 -#: classes/Gems/Default/DatabaseAction.php:366 +#: classes/Gems/Default/DatabaseAction.php:364 msgid "Executed" msgstr "Executed" #: classes/Gems/Default/DatabaseAction.php:321 -#: classes/Gems/Default/DatabaseAction.php:367 +#: classes/Gems/Default/DatabaseAction.php:365 msgid "Finished" msgstr "Finished" @@ -837,114 +873,114 @@ msgid "Show patches" msgstr "Show patches" -#: classes/Gems/Default/DatabaseAction.php:356 +#: classes/Gems/Default/DatabaseAction.php:354 #, php-format msgid "%d patch(es) executed." msgstr "%d patch(es) executed." -#: classes/Gems/Default/DatabaseAction.php:361 +#: classes/Gems/Default/DatabaseAction.php:359 msgid "Patch" msgstr "Patch" -#: classes/Gems/Default/DatabaseAction.php:365 +#: classes/Gems/Default/DatabaseAction.php:363 msgid "Query" msgstr "Query" -#: classes/Gems/Default/DatabaseAction.php:368 +#: classes/Gems/Default/DatabaseAction.php:366 msgid "Result" msgstr "Result" -#: classes/Gems/Default/DatabaseAction.php:392 +#: classes/Gems/Default/DatabaseAction.php:390 msgid "Patch maintenance" msgstr "Patch maintenance" -#: classes/Gems/Default/DatabaseAction.php:396 +#: classes/Gems/Default/DatabaseAction.php:394 msgid "Patch overview" msgstr "Patch overview" -#: classes/Gems/Default/DatabaseAction.php:458 +#: classes/Gems/Default/DatabaseAction.php:456 msgid "This database object does not exist. You cannot create it." msgstr "This database object does not exist. You cannot create it." -#: classes/Gems/Default/DatabaseAction.php:464 +#: classes/Gems/Default/DatabaseAction.php:462 msgid "This database object has no script. You cannot execute it." msgstr "This database object has no script. You cannot execute it." -#: classes/Gems/Default/DatabaseAction.php:475 +#: classes/Gems/Default/DatabaseAction.php:473 #, php-format msgid "Run %s" msgstr "Run %s" -#: classes/Gems/Default/DatabaseAction.php:494 +#: classes/Gems/Default/DatabaseAction.php:492 #, php-format msgid "Starting %d object creation scripts." msgstr "Starting %d object creation scripts." -#: classes/Gems/Default/DatabaseAction.php:499 +#: classes/Gems/Default/DatabaseAction.php:497 #, php-format msgid "Finished %s creation script for object %d of %d" msgstr "Finished %s creation script for object %d of %d" -#: classes/Gems/Default/DatabaseAction.php:503 +#: classes/Gems/Default/DatabaseAction.php:501 msgid "All objects exist. Nothing was executed." msgstr "All objects exist. Nothing was executed." -#: classes/Gems/Default/DatabaseAction.php:509 +#: classes/Gems/Default/DatabaseAction.php:507 msgid "Create not-existing database objects" msgstr "Create not-existing database objects" -#: classes/Gems/Default/DatabaseAction.php:511 +#: classes/Gems/Default/DatabaseAction.php:509 #, php-format msgid "One database object does not exist." msgid_plural "These %d database objects do not exist." msgstr[0] "One database object does not exist." msgstr[1] "These %d database objects do not exist." -#: classes/Gems/Default/DatabaseAction.php:512 +#: classes/Gems/Default/DatabaseAction.php:510 msgid "Are you sure you want to create it?" msgid_plural "Are you sure you want to create them all?" msgstr[0] "Are you sure you want to create it?" msgstr[1] "Are you sure you want to create them all?" -#: classes/Gems/Default/DatabaseAction.php:525 +#: classes/Gems/Default/DatabaseAction.php:523 msgid "All database objects exist. There is nothing to create." msgstr "All database objects exist. There is nothing to create." -#: classes/Gems/Default/DatabaseAction.php:538 +#: classes/Gems/Default/DatabaseAction.php:536 msgid "Separate multiple commands with semicolons (;)." msgstr "Separate multiple commands with semicolons (;)." -#: classes/Gems/Default/DatabaseAction.php:545 +#: classes/Gems/Default/DatabaseAction.php:543 msgid "Run" msgstr "Run" -#: classes/Gems/Default/DatabaseAction.php:554 +#: classes/Gems/Default/DatabaseAction.php:552 msgid "raw" msgstr "raw" -#: classes/Gems/Default/DatabaseAction.php:563 +#: classes/Gems/Default/DatabaseAction.php:561 #, php-format msgid "Result set %s." msgstr "Result set %s." -#: classes/Gems/Default/DatabaseAction.php:586 +#: classes/Gems/Default/DatabaseAction.php:584 msgid "Execute raw SQL" msgstr "Execute raw SQL" -#: classes/Gems/Default/DatabaseAction.php:589 +#: classes/Gems/Default/DatabaseAction.php:587 msgid "Result sets" msgstr "Result sets" -#: classes/Gems/Default/DatabaseAction.php:614 +#: classes/Gems/Default/DatabaseAction.php:612 msgid "This database object does not exist. You cannot view it." msgstr "This database object does not exist. You cannot view it." -#: classes/Gems/Default/DatabaseAction.php:619 +#: classes/Gems/Default/DatabaseAction.php:617 #, php-format msgid "The data in table %s" msgstr "The data in table %s" -#: classes/Gems/Default/DatabaseAction.php:620 +#: classes/Gems/Default/DatabaseAction.php:618 #, php-format msgid "Contents of %s %s" msgstr "Contents of %s %s" @@ -968,7 +1004,7 @@ msgstr "%s records found." #: classes/Gems/Default/ExportAction.php:174 -#: classes/Gems/Default/IndexAction.php:105 +#: classes/Gems/Default/IndexAction.php:162 #: classes/Gems/Default/MailJobAction.php:119 msgid "Organization" msgstr "Organization" @@ -996,73 +1032,87 @@ msgid "Administrative groups" msgstr "Administrative groups" -#: classes/Gems/Default/IndexAction.php:98 +#: classes/Gems/Default/IndexAction.php:83 +msgid "Enter your token..." +msgstr "Enter your token..." + +#: classes/Gems/Default/IndexAction.php:124 #, php-format msgid "Login to %s application" msgstr "Login to %s application" -#: classes/Gems/Default/IndexAction.php:117 -#: classes/Gems/Default/IndexAction.php:304 -msgid "Username" -msgstr "Username" +#: classes/Gems/Default/IndexAction.php:128 +msgid "Login" +msgstr "Login" -#: classes/Gems/Default/IndexAction.php:125 -#: classes/Gems/Default/MailServerAction.php:88 +#: classes/Gems/Default/IndexAction.php:145 +msgid "Back to login" +msgstr "Back to login" + +#: classes/Gems/Default/IndexAction.php:183 msgid "Password" msgstr "Password" -#: classes/Gems/Default/IndexAction.php:134 -msgid "Login" -msgstr "Login" +#: classes/Gems/Default/IndexAction.php:198 +#, php-format +msgid "Reset password for %s application" +msgstr "Reset password for %s application" -#: classes/Gems/Default/IndexAction.php:141 -msgid "Enter your token..." -msgstr "Enter your token..." +#: classes/Gems/Default/IndexAction.php:202 +msgid "Reset password" +msgstr "Reset password" -#: classes/Gems/Default/IndexAction.php:196 -#: classes/Gems/Default/IndexAction.php:244 +#: classes/Gems/Default/IndexAction.php:248 +msgid "Username" +msgstr "Username" + +#: classes/Gems/Default/IndexAction.php:305 #, php-format msgid "Login successful, welcome %s." msgstr "Login successful, welcome %s." -#: classes/Gems/Default/IndexAction.php:270 -msgid "Good bye: " -msgstr "Good bye: " - -#: classes/Gems/Default/IndexAction.php:300 +#: classes/Gems/Default/IndexAction.php:335 #, php-format -msgid "Reset password for %s application" -msgstr "Reset password for %s application" +msgid "Good bye: %s." +msgstr "Good bye: %s." -#: classes/Gems/Default/IndexAction.php:312 -msgid "Reset password" -msgstr "Reset password" +#: classes/Gems/Default/IndexAction.php:360 +msgid "Reset accepted, enter your new password." +msgstr "Reset accepted, enter your new password." -#: classes/Gems/Default/IndexAction.php:336 -msgid "No such user found or no e-mail address known" -msgstr "No such user found or no e-mail address known" +#: classes/Gems/Default/IndexAction.php:364 +msgid "This key timed out or does not belong to this user." +msgstr "This key timed out or does not belong to this user." -#: classes/Gems/Default/IndexAction.php:338 -msgid "Reset e-mail already sent, please try again after 24 hours" -msgstr "Reset e-mail already sent, please try again after 24 hours" +#: classes/Gems/Default/IndexAction.php:381 +msgid "Password reset requested" +msgstr "Password reset requested" -#: classes/Gems/Default/IndexAction.php:353 -msgid "Follow the instructions in the e-mail" -msgstr "Follow the instructions in the e-mail" +#: classes/Gems/Default/IndexAction.php:382 +#, php-format +msgid "To reset your password for %s, please click this link: %s" +msgstr "To reset your password for %s, please click this link: %s" -#: classes/Gems/Default/IndexAction.php:355 -#: classes/Gems/Default/IndexAction.php:379 -msgid "Unable to send e-mail" -msgstr "Unable to send e-mail" +#: classes/Gems/Default/IndexAction.php:387 +msgid "We sent you an e-mail with a reset link. Click on the link in the e-mail." +msgstr "We sent you an e-mail with a reset link. Click on the link in the e-mail." -#: classes/Gems/Default/IndexAction.php:375 -msgid "An e-mail was sent containing your new password" -msgstr "An e-mail was sent containing your new password" +#: classes/Gems/Default/IndexAction.php:389 +msgid "Unable to send e-mail." +msgstr "Unable to send e-mail." -#: classes/Gems/Default/IndexAction.php:383 -msgid "Unknown request" -msgstr "Unknown request" +#: classes/Gems/Default/IndexAction.php:394 +msgid "No such user found or no e-mail address known or user cannot be reset." +msgstr "No such user found or no e-mail address known or user cannot be reset." +#: classes/Gems/Default/IndexAction.php:398 +msgid "We received your password reset key." +msgstr "We received your password reset key." + +#: classes/Gems/Default/IndexAction.php:399 +msgid "Please enter the organization and username belonging to this key." +msgstr "Please enter the organization and username belonging to this key." + #: classes/Gems/Default/InvitationAction.php:52 msgid "Invite" msgstr "Invite" @@ -1133,7 +1183,6 @@ msgstr "Action" #: classes/Gems/Default/LogAction.php:165 -#: classes/Gems/Default/MailTemplateAction.php:65 msgid "Message" msgstr "Message" @@ -1171,7 +1220,6 @@ msgstr "New automatic mail job..." #: classes/Gems/Default/MailJobAction.php:100 -#: classes/Gems/Default/MailLogAction.php:116 msgid "Template" msgstr "Template" @@ -1340,10 +1388,16 @@ msgstr "User ID" #: classes/Gems/Default/MailServerAction.php:90 +#: classes/Gems/Default/OptionAction.php:112 +#: classes/Gems/Default/OptionAction.php:117 +#: classes/Gems/Default/SourceAction.php:95 +#: classes/Gems/Default/StaffAction.php:144 msgid "Repeat password" msgstr "Repeat password" #: classes/Gems/Default/MailServerAction.php:91 +#: classes/Gems/Default/SourceAction.php:74 +#: classes/Gems/Default/StaffAction.php:118 msgid "Enter only when changing" msgstr "Enter only when changing the password" @@ -1358,6 +1412,7 @@ msgstr "Email servers" #: classes/Gems/Default/MailTemplateAction.php:75 +#: classes/Gems/Default/StaffAction.php:228 msgid "(all organizations)" msgstr "(all organizations)" @@ -1371,34 +1426,38 @@ msgid "Email templates" msgstr "Email templates" -#: classes/Gems/Default/OptionAction.php:75 -#: classes/Gems/Default/OrganizationAction.php:128 -#: classes/Gems/Default/RespondentAction.php:173 -#: classes/Gems/Default/StaffAction.php:196 -msgid "Language" -msgstr "Language" +#: classes/Gems/Default/OptionAction.php:84 +msgid "You are not allowed to change your password." +msgstr "You are not allowed to change your password." -#: classes/Gems/Default/OptionAction.php:94 +#: classes/Gems/Default/OptionAction.php:96 msgid "Current password" msgstr "Current password" -#: classes/Gems/Default/OptionAction.php:105 -#: classes/Gems/Default/OptionAction.php:121 +#: classes/Gems/Default/OptionAction.php:106 +#: classes/Gems/Default/OptionAction.php:122 msgid "New password" msgstr "New password" -#: classes/Gems/Default/OptionAction.php:146 +#: classes/Gems/Default/OptionAction.php:141 msgid "New password is active." msgstr "New password is active." -#: classes/Gems/Default/OptionAction.php:152 +#: classes/Gems/Default/OptionAction.php:146 msgid "Caps Lock seems to be on!" msgstr "Caps Lock seems to be on!" -#: classes/Gems/Default/OptionAction.php:191 +#: classes/Gems/Default/OptionAction.php:190 msgid "Login Name" msgstr "Login Name" +#: classes/Gems/Default/OptionAction.php:197 +#: classes/Gems/Default/OrganizationAction.php:140 +#: classes/Gems/Default/RespondentAction.php:173 +#: classes/Gems/Default/StaffAction.php:213 +msgid "Language" +msgstr "Language" + #: classes/Gems/Default/OptionAction.php:207 #, php-format msgid "Options" @@ -1426,61 +1485,72 @@ msgid "Item" msgstr "Item" -#: classes/Gems/Default/OrganizationAction.php:93 +#: classes/Gems/Default/OrganizationAction.php:105 msgid "Cookies must be enabled." msgstr "Cookies must be enabled." -#: classes/Gems/Default/OrganizationAction.php:96 +#: classes/Gems/Default/OrganizationAction.php:108 msgid "Invalid organization." msgstr "Invalid organization." -#: classes/Gems/Default/OrganizationAction.php:117 +#: classes/Gems/Default/OrganizationAction.php:129 msgid "Url" msgstr "Url" -#: classes/Gems/Default/OrganizationAction.php:118 +#: classes/Gems/Default/OrganizationAction.php:130 msgid "Task" msgstr "Task" -#: classes/Gems/Default/OrganizationAction.php:119 +#: classes/Gems/Default/OrganizationAction.php:131 msgid "Contact name" msgstr "Contact name" -#: classes/Gems/Default/OrganizationAction.php:120 +#: classes/Gems/Default/OrganizationAction.php:132 msgid "Contact email" msgstr "Contact email" -#: classes/Gems/Default/OrganizationAction.php:123 +#: classes/Gems/Default/OrganizationAction.php:135 msgid "Style" msgstr "Style" -#: classes/Gems/Default/OrganizationAction.php:138 +#: classes/Gems/Default/OrganizationAction.php:145 +msgid "Allow new respondents" +msgstr "Allow new patients" + +#: classes/Gems/Default/OrganizationAction.php:150 msgid "Greeting" msgstr "Greeting" -#: classes/Gems/Default/OrganizationAction.php:138 -#: classes/Gems/Default/OrganizationAction.php:139 +#: classes/Gems/Default/OrganizationAction.php:150 +#: classes/Gems/Default/OrganizationAction.php:151 msgid "For emails and token forward screen." msgstr "For emails and token forward screen." -#: classes/Gems/Default/OrganizationAction.php:139 +#: classes/Gems/Default/OrganizationAction.php:151 msgid "Signature" msgstr "Signature" -#: classes/Gems/Default/OrganizationAction.php:155 +#: classes/Gems/Default/OrganizationAction.php:153 +msgid "Accessible by" +msgstr "Accessible by" + +#: classes/Gems/Default/OrganizationAction.php:153 +msgid "Checked organizations see this organizations respondents." +msgstr "Checked organizations see this organizations patients." + +#: classes/Gems/Default/OrganizationAction.php:172 msgid "organization" msgid_plural "organizations" msgstr[0] "organization" msgstr[1] "organizations" -#: classes/Gems/Default/OrganizationAction.php:160 +#: classes/Gems/Default/OrganizationAction.php:177 msgid "Participating organizations" msgstr "Participating organizations" #: classes/Gems/Default/OverviewPlanAction.php:115 #: classes/Gems/Default/ProjectSurveysAction.php:88 #: classes/Gems/Default/SurveyAction.php:203 -#: classes/Gems/Default/SurveyMaintenanceAction.php:409 msgid "survey" msgid_plural "surveys" msgstr[0] "survey" @@ -1614,14 +1684,12 @@ #: classes/Gems/Default/ProjectSurveysAction.php:69 #: classes/Gems/Default/ProjectTracksAction.php:67 #: classes/Gems/Default/SurveyAction.php:193 -#: classes/Gems/Default/TrackAction.php:329 msgid "From" msgstr "From" #: classes/Gems/Default/ProjectSurveysAction.php:70 #: classes/Gems/Default/ProjectTracksAction.php:68 #: classes/Gems/Default/SurveyAction.php:195 -#: classes/Gems/Default/TrackAction.php:331 msgid "Until" msgstr "Until" @@ -1630,12 +1698,10 @@ msgstr "Active surveys" #: classes/Gems/Default/ProjectTracksAction.php:65 -#: classes/Gems/Default/TrackAction.php:328 msgid "Survey #" msgstr "Survey #" #: classes/Gems/Default/ProjectTracksAction.php:85 -#: classes/Gems/Default/TrackAction.php:451 msgid "track" msgid_plural "tracks" msgstr[0] "track" @@ -1695,7 +1761,7 @@ #: classes/Gems/Default/ReceptionAction.php:94 msgid "This reception code can be assigned to a respondent." -msgstr "This reception code can be assigned to a respondent." +msgstr "This reception code can be assigned to a patient." #: classes/Gems/Default/ReceptionAction.php:95 msgid "For tracks" @@ -1801,8 +1867,6 @@ msgstr "Treatment" #: classes/Gems/Default/RespondentAction.php:230 -#: classes/Gems/Default/TrackAction.php:131 -#: classes/Gems/Default/TrackAction.php:475 msgid "Rejection code" msgstr "Rejection code" @@ -1815,45 +1879,39 @@ msgstr "Patient deleted" #: classes/Gems/Default/RespondentAction.php:291 -#: classes/Gems/Default/TrackAction.php:404 msgid "Choose a reception code to delete." msgstr "Choose a reception code to delete." -#: classes/Gems/Default/RespondentAction.php:355 +#: classes/Gems/Default/RespondentAction.php:335 msgid "respondent" msgid_plural "respondents" msgstr[0] "patient" msgstr[1] "patients" -#: classes/Gems/Default/RespondentAction.php:398 +#: classes/Gems/Default/RespondentAction.php:392 msgid "Please settle the informed consent form for this respondent." msgstr "Please settle the informed consent form for this patient." #: classes/Gems/Default/RespondentPlanAction.php:67 #: classes/Gems/Default/SurveyAction.php:171 -#: classes/Gems/Default/TrackAction.php:296 msgid "Show respondent" msgstr "Show patient" #: classes/Gems/Default/RespondentPlanAction.php:73 -#: classes/Gems/Default/TrackAction.php:265 -#: classes/Gems/Default/TrackAction.php:284 msgid "Show track" msgstr "Show track" #: classes/Gems/Default/RespondentPlanAction.php:136 -#: classes/Gems/Default/TrackAction.php:316 msgid " of " msgstr " of " #: classes/Gems/Default/RespondentPlanAction.php:137 -#: classes/Gems/Default/TrackAction.php:317 msgid "Progress" msgstr "Progress" #: classes/Gems/Default/RespondentPlanAction.php:144 msgid "Respondent planning" -msgstr "Respondent planning" +msgstr "Patient planning" #: classes/Gems/Default/RoleAction.php:175 msgid "Illegal name" @@ -1997,23 +2055,23 @@ msgid "Are you sure you want to synchronize all survey sources?" msgstr "Are you sure you want to synchronize all survey sources?" -#: classes/Gems/Default/StaffAction.php:137 +#: classes/Gems/Default/StaffAction.php:158 msgid "If checked the user will logoff when answering a survey." msgstr "If checked the user will logoff when answering a survey." -#: classes/Gems/Default/StaffAction.php:153 +#: classes/Gems/Default/StaffAction.php:174 msgid "You are not allowed to edit this staff member." msgstr "You are not allowed to edit this staff member." -#: classes/Gems/Default/StaffAction.php:191 +#: classes/Gems/Default/StaffAction.php:208 msgid "Primary function" msgstr "Primary function" -#: classes/Gems/Default/StaffAction.php:197 +#: classes/Gems/Default/StaffAction.php:214 msgid "Logout on survey" msgstr "Logout on survey" -#: classes/Gems/Default/StaffAction.php:275 +#: classes/Gems/Default/StaffAction.php:283 msgid "staff member" msgid_plural "staff members" msgstr[0] "staff member" @@ -2116,42 +2174,42 @@ msgid "Checking survey results for the %s survey." msgstr "Checking survey results for the %s survey." -#: classes/Gems/Default/SurveyMaintenanceAction.php:348 +#: classes/Gems/Default/SurveyMaintenanceAction.php:347 msgid "Source" msgstr "Source" -#: classes/Gems/Default/SurveyMaintenanceAction.php:349 +#: classes/Gems/Default/SurveyMaintenanceAction.php:348 msgid "Status in source" msgstr "Status in source" -#: classes/Gems/Default/SurveyMaintenanceAction.php:353 +#: classes/Gems/Default/SurveyMaintenanceAction.php:352 msgid "Active in source" msgstr "Active in source" -#: classes/Gems/Default/SurveyMaintenanceAction.php:354 +#: classes/Gems/Default/SurveyMaintenanceAction.php:353 #, php-format msgid "Active in %s" msgstr "Active in %s" -#: classes/Gems/Default/SurveyMaintenanceAction.php:361 +#: classes/Gems/Default/SurveyMaintenanceAction.php:360 msgid "Single" msgstr "Single" -#: classes/Gems/Default/SurveyMaintenanceAction.php:394 +#: classes/Gems/Default/SurveyMaintenanceAction.php:393 #, php-format msgid "%d times in track." msgstr "%d times in track." -#: classes/Gems/Default/SurveyMaintenanceAction.php:396 +#: classes/Gems/Default/SurveyMaintenanceAction.php:395 #, php-format msgid "%d times in %d track(s)." msgstr "%d times in %d track(s)." -#: classes/Gems/Default/SurveyMaintenanceAction.php:400 +#: classes/Gems/Default/SurveyMaintenanceAction.php:399 msgid "Not used in track." msgstr "Not used in track." -#: classes/Gems/Default/SurveyMaintenanceAction.php:402 +#: classes/Gems/Default/SurveyMaintenanceAction.php:401 msgid "Not used in tracks." msgstr "Not used in tracks." @@ -2242,22 +2300,22 @@ msgid "(all fillers)" msgstr "(all fillers)" -#: classes/Gems/Default/TokenPlanAction.php:358 +#: classes/Gems/Defaul... [truncated message content] |
From: <gem...@li...> - 2011-11-16 13:19:51
|
Revision: 222 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=222&view=rev Author: matijsdejong Date: 2011-11-16 13:19:44 +0000 (Wed, 16 Nov 2011) Log Message: ----------- On windows servers the PHP session ID was stored for '/' instead of '\'. Many browsers lost the session ID because of this. Modified Paths: -------------- trunk/library/classes/Gems/Default/OrganizationAction.php trunk/library/classes/GemsEscort.php Modified: trunk/library/classes/Gems/Default/OrganizationAction.php =================================================================== --- trunk/library/classes/Gems/Default/OrganizationAction.php 2011-11-15 15:35:22 UTC (rev 221) +++ trunk/library/classes/Gems/Default/OrganizationAction.php 2011-11-16 13:19:44 UTC (rev 222) @@ -26,20 +26,25 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * @author Matijs de Jong - * @since 1.0 - * @version 1.1 - * @package Gems + * + * @package Gems * @subpackage Default + * @author Matijs de Jong <mj...@ma...> + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @version $Id$ */ /** + * Generic controller class for showing and editing organizations * - * @author Matijs de Jong - * @package Gems + * @package Gems * @subpackage Default + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @since Class available since version 1.0 */ -class Gems_Default_OrganizationAction extends Gems_Controller_BrowseEditAction +class Gems_Default_OrganizationAction extends Gems_Controller_BrowseEditAction // Gems_Controller_ModelSnippetActionAbstract { public $autoFilter = false; @@ -92,7 +97,7 @@ } $this->session->requestCache = $requestCache; - if (Gems_Cookies::set('organization', $orgId)) { + if (Gems_Cookies::setOrganization($orgId, $this->basepath->getBasePath())) { $this->getResponse()->setRedirect($url); return; } Modified: trunk/library/classes/GemsEscort.php =================================================================== --- trunk/library/classes/GemsEscort.php 2011-11-15 15:35:22 UTC (rev 221) +++ trunk/library/classes/GemsEscort.php 2011-11-16 13:19:44 UTC (rev 222) @@ -90,12 +90,10 @@ $firebug = $application->getOption('firebug'); $this->_startFirebird = $firebug['log']; - Zend_Session::start( - array( - 'name' => GEMS_PROJECT_NAME_UC . 'SESSID', - 'cookie_path' => dirname($_SERVER['SCRIPT_NAME']) - ) - ); + $sessionOptions['name'] = GEMS_PROJECT_NAME_UC . 'SESSID'; + $sessionOptions['cookie_path'] = strtr(dirname($_SERVER['SCRIPT_NAME']), '\\', '/'); + + Zend_Session::start($sessionOptions); } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2011-11-15 15:35:33
|
Revision: 221 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=221&view=rev Author: mennodekker Date: 2011-11-15 15:35:22 +0000 (Tue, 15 Nov 2011) Log Message: ----------- On update organization, the cache is invalidated Modified Paths: -------------- trunk/library/classes/Gems/Default/OrganizationAction.php trunk/library/classes/Gems/User/Organization.php Modified: trunk/library/classes/Gems/Default/OrganizationAction.php =================================================================== --- trunk/library/classes/Gems/Default/OrganizationAction.php 2011-11-15 14:28:47 UTC (rev 220) +++ trunk/library/classes/Gems/Default/OrganizationAction.php 2011-11-15 15:35:22 UTC (rev 221) @@ -43,6 +43,13 @@ { public $autoFilter = false; + public function afterSave(array $data, $isNew) + { + $org = $this->loader->getOrganization($data['gor_id_organization']); + $org->invalidateCache(); + return parent::afterSave($data, $isNew); + } + public function changeUiAction() { $request = $this->getRequest(); Modified: trunk/library/classes/Gems/User/Organization.php =================================================================== --- trunk/library/classes/Gems/User/Organization.php 2011-11-15 14:28:47 UTC (rev 220) +++ trunk/library/classes/Gems/User/Organization.php 2011-11-15 15:35:22 UTC (rev 221) @@ -116,6 +116,15 @@ } /** + * Get the cacheId for the organization + * + * @return string + */ + private function _getCacheId() { + return GEMS_PROJECT_NAME . '__' . __CLASS__ . '__' . $this->_organizationId; + } + + /** * Should be called after answering the request to allow the Target * to check if all required registry values have been set correctly. * @@ -124,7 +133,7 @@ public function checkRegistryRequestsAnswers() { if ($this->cache) { - $cacheId = GEMS_PROJECT_NAME . '__' . __CLASS__ . '__' . $this->_organizationId; + $cacheId = $this->_getCacheId(); $this->_organizationData = $this->cache->load($cacheId); } else { $cacheId = false; @@ -155,4 +164,11 @@ { return $this->_organizationData['gor_style']; } + + public function invalidateCache() { + if ($this->cache) { + $cacheId = $this->_getCacheId(); + $this->cache->remove($cacheId); + } + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2011-11-15 14:28:53
|
Revision: 220 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=220&view=rev Author: mennodekker Date: 2011-11-15 14:28:47 +0000 (Tue, 15 Nov 2011) Log Message: ----------- Regenerate sessionId on logout Changed organization object to allow ->org_id etc. for easy access to content docblock fix for result of user->authenticate Modified Paths: -------------- trunk/library/classes/Gems/Default/IndexAction.php trunk/library/classes/Gems/User/Organization.php trunk/library/classes/Gems/User/User.php Modified: trunk/library/classes/Gems/Default/IndexAction.php =================================================================== --- trunk/library/classes/Gems/Default/IndexAction.php 2011-11-15 12:38:23 UTC (rev 219) +++ trunk/library/classes/Gems/Default/IndexAction.php 2011-11-15 14:28:47 UTC (rev 220) @@ -336,6 +336,7 @@ $this->addMessage(sprintf($this->_('Good bye: %s.'), $user->getFullName())); $user->unsetAsCurrentUser(); + Zend_Session::regenerateId(); $this->_reroute(array('action' => 'index'), true); } Modified: trunk/library/classes/Gems/User/Organization.php =================================================================== --- trunk/library/classes/Gems/User/Organization.php 2011-11-15 12:38:23 UTC (rev 219) +++ trunk/library/classes/Gems/User/Organization.php 2011-11-15 14:28:47 UTC (rev 220) @@ -97,6 +97,25 @@ } /** + * Returns a callable if a method is called as a variable + * or the value from the organizationData if it exists + * + * @param string $name + * @return Callable + */ + public function __get($name) + { + if (method_exists($this, $name)) { + // Return a callable + return array($this, $name); + } elseif (isset($this->_organizationData[$name])) { + return $this->_organizationData[$name]; + } + + throw new Gems_Exception_Coding("Unknown method '$name' requested as callable."); + } + + /** * Should be called after answering the request to allow the Target * to check if all required registry values have been set correctly. * Modified: trunk/library/classes/Gems/User/User.php =================================================================== --- trunk/library/classes/Gems/User/User.php 2011-11-15 12:38:23 UTC (rev 219) +++ trunk/library/classes/Gems/User/User.php 2011-11-15 14:28:47 UTC (rev 220) @@ -193,7 +193,7 @@ * Authenticate a users credentials using the submitted form * * @param array $formValues the array containing all formvalues from the login form - * @return boolean + * @return Zend_Auth_Result */ public function authenticate($formValues) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2011-11-15 12:38:30
|
Revision: 219 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=219&view=rev Author: matijsdejong Date: 2011-11-15 12:38:23 +0000 (Tue, 15 Nov 2011) Log Message: ----------- Organizations are now stored in cache Modified Paths: -------------- trunk/library/classes/Gems/Loader.php trunk/library/classes/Gems/User/Organization.php trunk/library/classes/Gems/User/UserLoader.php Modified: trunk/library/classes/Gems/Loader.php =================================================================== --- trunk/library/classes/Gems/Loader.php 2011-11-15 11:05:57 UTC (rev 218) +++ trunk/library/classes/Gems/Loader.php 2011-11-15 12:38:23 UTC (rev 219) @@ -1,4 +1,5 @@ <?php + /** * Copyright (c) 2011, Erasmus MC * All rights reserved. Modified: trunk/library/classes/Gems/User/Organization.php =================================================================== --- trunk/library/classes/Gems/User/Organization.php 2011-11-15 11:05:57 UTC (rev 218) +++ trunk/library/classes/Gems/User/Organization.php 2011-11-15 12:38:23 UTC (rev 219) @@ -46,27 +46,90 @@ * @license New BSD License * @since Class available since version 1.5 */ -class Gems_User_Organization +class Gems_User_Organization extends Gems_Registry_TargetAbstract { /** + * The default organization data for 'no organization'. * * @var array */ + protected $_noOrganization = array( + 'gor_id_organization' => 1, + 'gor_name' => 'NO ORGANIZATION', + 'gor_code' => null, + 'gor_style' => null, + 'gor_iso_lang' => 'en', + 'gor_active' => 0, + ); + + /** + * + * @var array + */ protected $_organizationData; /** + * + * @var int + */ + protected $_organizationId; + + /** + * + * @var Zend_Cache_Core + */ + protected $cache; + + /** + * + * @var Zend_Db_Adapter_Abstract + */ + protected $db; + + /** * Creates the organization object. * - * @param array $organizationData + * @param int $organizationId */ - public function __construct(array $organizationData) + public function __construct($organizationId) { - $this->_organizationData = $organizationData; + $this->_organizationId = $organizationId; } /** + * Should be called after answering the request to allow the Target + * to check if all required registry values have been set correctly. + * + * @return boolean False if required are missing. + */ + public function checkRegistryRequestsAnswers() + { + if ($this->cache) { + $cacheId = GEMS_PROJECT_NAME . '__' . __CLASS__ . '__' . $this->_organizationId; + $this->_organizationData = $this->cache->load($cacheId); + } else { + $cacheId = false; + } + + if (! $this->_organizationData) { + $this->_organizationData = $this->db->fetchRow('SELECT * FROM gems__organizations WHERE gor_id_organization = ? LIMIT 1', $this->_organizationId); + + if (! $this->_organizationData) { + $this->_organizationData = $this->_noOrganization; + } + + if ($cacheId) { + $this->cache->save($this->_organizationData, $cacheId); + } + } + + return is_array($this->_organizationData) && parent::checkRegistryRequestsAnswers(); + } + + + /** * Get the style attribute. - * + * * @return string */ public function getStyle() Modified: trunk/library/classes/Gems/User/UserLoader.php =================================================================== --- trunk/library/classes/Gems/User/UserLoader.php 2011-11-15 11:05:57 UTC (rev 218) +++ trunk/library/classes/Gems/User/UserLoader.php 2011-11-15 12:38:23 UTC (rev 219) @@ -55,20 +55,6 @@ const USER_STAFF = 'StaffUser'; /** - * The default organization data for 'no organization'. - * - * @var array - */ - protected static $_noOrganization = array( - 'gor_id_organization' => 1, - 'gor_name' => 'NO ORGANIZATION', - 'gor_code' => null, - 'gor_style' => null, - 'gor_iso_lang' => 'en', - 'gor_active' => 0, - ); - - /** * Allows sub classes of Gems_Loader_LoaderAbstract to specify the subdirectory where to look for. * * @var string $cascade An optional subdirectory where this subclass always loads from. @@ -174,38 +160,17 @@ */ public function getOrganization($organizationId = null) { - if (! self::$organizationStore) { - self::$organizationStore = new Zend_Session_Namespace('gems.' . GEMS_PROJECT_NAME . '.organizations'); - } + static $organizations = array(); if (null === $organizationId) { $organizationId = intval(self::$currentUser->getOrganizationId()); } - if (! self::$organizationStore->__isset($organizationId)) { - - // We are not sure the is a database at this moment - try { - $data = $this->db->fetchRow('SELECT * FROM gems__organizations WHERE gor_id_organization = ? LIMIT 1', $organizationId); - } catch (Zend_Db_Exception $e) { - $data = false; - } - if (! $data) { - // Use default - $data = self::$_noOrganization; - - // But do attempt to get the last added organization. - foreach (self::$organizationStore->getIterator() as $key => $value) { - if ($key !== 0) { - $organizationId = $key; - $data = self::$organizationStore->__get($key); - } - } - } - self::$organizationStore->__set($organizationId, $data); + if (! isset($organizations[$organizationId])) { + $organizations[$organizationId] = $this->_loadClass('Organization', true, array($organizationId)); } - return new Gems_User_Organization(self::$organizationStore->__get($organizationId)); + return $organizations[$organizationId]; } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2011-11-15 11:06:07
|
Revision: 218 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=218&view=rev Author: mennodekker Date: 2011-11-15 11:05:57 +0000 (Tue, 15 Nov 2011) Log Message: ----------- Fixed multiLocale Modified Paths: -------------- trunk/library/classes/Gems/Project/ProjectSettings.php Modified: trunk/library/classes/Gems/Project/ProjectSettings.php =================================================================== --- trunk/library/classes/Gems/Project/ProjectSettings.php 2011-11-15 10:29:43 UTC (rev 217) +++ trunk/library/classes/Gems/Project/ProjectSettings.php 2011-11-15 11:05:57 UTC (rev 218) @@ -143,7 +143,7 @@ $this->offsetSet('name', GEMS_PROJECT_NAME); } - $this->offsetSet('multiLocale', isset($project->locales) && (count($project->locales) > 1)); + $this->offsetSet('multiLocale', $this->offsetExists('locales') && (count($this->offsetGet('locales')) > 1)); } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2011-11-15 10:29:50
|
Revision: 217 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=217&view=rev Author: mennodekker Date: 2011-11-15 10:29:43 +0000 (Tue, 15 Nov 2011) Log Message: ----------- And finally remove the checkpassword, and obsolete validators Modified Paths: -------------- trunk/library/classes/Gems/Default/IndexAction.php trunk/library/classes/Gems/Default/OptionAction.php trunk/library/classes/Gems/User/NoLoginDefinition.php trunk/library/classes/Gems/User/OldStaffUserDefinition.php trunk/library/classes/Gems/User/ProjectUserDefinition.php trunk/library/classes/Gems/User/StaffUserDefinition.php trunk/library/classes/Gems/User/User.php trunk/library/classes/Gems/User/UserDefinitionInterface.php trunk/library/classes/Gems/User/UserLoader.php Removed Paths: ------------- trunk/library/classes/Gems/User/LoginPasswordValidator.php trunk/library/classes/Gems/User/UserPasswordValidator.php Modified: trunk/library/classes/Gems/Default/IndexAction.php =================================================================== --- trunk/library/classes/Gems/Default/IndexAction.php 2011-11-15 09:44:12 UTC (rev 216) +++ trunk/library/classes/Gems/Default/IndexAction.php 2011-11-15 10:29:43 UTC (rev 217) @@ -184,7 +184,6 @@ $element->setAttrib('size', 10); $element->setAttrib('maxlength', 20); $element->setRequired(true); - //$element->addValidator(new Gems_User_LoginPasswordValidator($this->loader->getUserLoader(), 'userlogin', 'organization', $this->translate)); return $element; } Modified: trunk/library/classes/Gems/Default/OptionAction.php =================================================================== --- trunk/library/classes/Gems/Default/OptionAction.php 2011-11-15 09:44:12 UTC (rev 216) +++ trunk/library/classes/Gems/Default/OptionAction.php 2011-11-15 10:29:43 UTC (rev 217) @@ -98,7 +98,6 @@ $element->setAttrib('maxlength', 20); $element->setRenderPassword(true); $element->setRequired(true); - $element->addValidator(new Gems_User_UserPasswordValidator($user, $this->translate)); $form->addElement($element); } @@ -131,16 +130,26 @@ /**************** * Process form * ****************/ - if ($this->_request->isPost() && $form->isValid($_POST)) { - $user->setPassword($_POST['new_password']); + if ($this->_request->isPost()) { + if ($form->isValid($_POST)) { + $authResult = $user->authenticate(array('userlogin' => $user->getLoginName(), + 'password' => $_POST['old_password'], + 'organization' =>$user->getOrganizationId())); + if ($authResult->isValid()) { + $user->setPassword($_POST['new_password']); - $this->addMessage($this->_('New password is active.')); - $this->_reroute(array($this->getRequest()->getActionKey() => 'edit')); + $this->addMessage($this->_('New password is active.')); + $this->_reroute(array($this->getRequest()->getActionKey() => 'edit')); + } else { + if (isset($_POST['old_password'])) { + if ($_POST['old_password'] === strtoupper($_POST['old_password'])) { + $this->addMessage($this->_('Caps Lock seems to be on!')); + } else { + $errors = $authResult->getMessages(); + $this->addMessage($errors); - } else { - if (isset($_POST['old_password'])) { - if ($_POST['old_password'] === strtoupper($_POST['old_password'])) { - $this->addMessage($this->_('Caps Lock seems to be on!')); + } + } } } $form->populate($_POST); Deleted: trunk/library/classes/Gems/User/LoginPasswordValidator.php =================================================================== --- trunk/library/classes/Gems/User/LoginPasswordValidator.php 2011-11-15 09:44:12 UTC (rev 216) +++ trunk/library/classes/Gems/User/LoginPasswordValidator.php 2011-11-15 10:29:43 UTC (rev 217) @@ -1,140 +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.5 - */ -class Gems_User_LoginPasswordValidator implements Zend_Validate_Interface -{ - /** - * Field containing user login - * - * @var string - */ - private $_loginField = 'userlogin'; - - /** - * Field containing organization id. - * - * @var string - */ - private $_organizationField = 'organization'; - - /** - * - * @var Gems_User_UserLoader - */ - private $_userLoader; - - /** - * - * @var Zend_Translate - */ - private $_translate; - - /** - * - * @var boolean - */ - private $_valid = false; - - /** - * - * @param Gems_User_UserLoader $loader - * @param type $loginField Field in form containing login name - * @param string $organizationField Field in form containing organization - * @param Zend_Translate $translate Optional translator - */ - public function __construct(Gems_User_UserLoader $loader, $loginField, $organizationField, Zend_Translate $translate = null) - { - $this->_userLoader = $loader; - $this->_loginField = $loginField; - $this->_organizationField = $organizationField; - $this->_translate = $translate ? $translate : new MUtil_Translate_Adapter_Potemkin(); - } - - /** - * Returns true if and only if $value meets the validation requirements - * - * If $value fails validation, then this method returns false, and - * getMessages() will return an array of messages that explain why the - * validation failed. - * - * @param mixed $value - * @param mixed $content - * @return boolean - * @throws Zend_Validate_Exception If validation of $value is impossible - */ - public function isValid($value, $context = array()) - { - if (isset($context[$this->_loginField], $context[$this->_organizationField])) { - $this->_valid = $this->_userLoader->checkPassword($context[$this->_loginField], $context[$this->_organizationField], $value); - } else { - $this->_valid = false; - } - - return $this->_valid; - } - - /** - * Returns an array of messages that explain why the most recent isValid() - * call returned false. The array keys are validation failure message identifiers, - * and the array values are the corresponding human-readable message strings. - * - * If isValid() was never called or if the most recent isValid() call - * returned true, then this method returns an empty array. - * - * @return array - */ - public function getMessages() - { - if ($this->_valid) { - return array(); - - } else { - return array($this->_translate->_('Combination of username password not found.')); - } - - - } -} Modified: trunk/library/classes/Gems/User/NoLoginDefinition.php =================================================================== --- trunk/library/classes/Gems/User/NoLoginDefinition.php 2011-11-15 09:44:12 UTC (rev 216) +++ trunk/library/classes/Gems/User/NoLoginDefinition.php 2011-11-15 10:29:43 UTC (rev 217) @@ -46,18 +46,16 @@ */ class Gems_User_NoLoginDefinition extends Gems_User_UserDefinitionAbstract { - /** - * Checks the password for the specified $login_name and $organization. - * - * @param string $login_name - * @param int $organization - * @param string $password - * @return boolean True if the password is correct. - */ - public function checkPassword($login_name, $organization, $password) - { + private function alwaysFalse($params) { + $result = new Zend_Auth_Result(Zend_Auth_Result::FAILURE, $params['userlogin']); return false; } + + public function getAuthAdapter($formValues) + { + $adapter = new Gems_Auth_Adapter_Callback(array(get_class(),'alwaysFalse'), $formValues['userlogin'], $formValues); + return $adapter; + } /** * Returns a user object, that may be empty if the user is unknown. @@ -74,15 +72,4 @@ //'user_organization_id' => 0, //REMOVED AS IT BREAKS STORING LAST ORGANIZATION ); } - - public function getAuthAdapter($formValues) - { - $adapter = new Gems_Auth_Adapter_Callback(array(get_class(),'alwaysFalse'), $formValues['userlogin'], $formValues); - return $adapter; - } - - private function alwaysFalse($params) { - $result = new Zend_Auth_Result(Zend_Auth_Result::FAILURE, $params['userlogin']); - return false; - } } Modified: trunk/library/classes/Gems/User/OldStaffUserDefinition.php =================================================================== --- trunk/library/classes/Gems/User/OldStaffUserDefinition.php 2011-11-15 09:44:12 UTC (rev 216) +++ trunk/library/classes/Gems/User/OldStaffUserDefinition.php 2011-11-15 10:29:43 UTC (rev 217) @@ -58,23 +58,22 @@ * @var Gems_Project_ProjectSettings */ protected $project; - + /** - * Checks the password for the specified $login_name and $organization. + * Perform UserDefinition specific post-login logic * - * @param string $login_name - * @param int $organization - * @param string $password - * @return boolean True if the password is correct. + * @param Zend_Auth_Result $authResult + * @return void */ - public function checkPassword($login_name, $organization, $password) + public function afterLogin($authResult, $formValues) { - $pwd_hash = $this->hashPassword($password); + if ($authResult->isValid()) { + $login_name = $formValues['userlogin']; + $organization = $formValues['organization']; + $password = $formValues['password']; + $userData = $this->getUserData($formValues['userlogin'], $formValues['organization']); + $staff_id = $userData['user_id']; - $sql = "SELECT gsf_id_user FROM gems__staff WHERE gsf_active = 1 AND gsf_login = ? AND gsf_id_organization = ? AND gsf_password = ?"; - - if ($staff_id = $this->db->fetchOne($sql, array($login_name, $organization, $pwd_hash))) { - $sql = 'SELECT gul_id_user FROM gems__user_logins WHERE gul_can_login = 1 AND gul_login = ? AND gul_id_organization = ?'; try { @@ -115,10 +114,23 @@ // MUtil_Echo::r($e); } - - return true; } + } + public function getAuthAdapter($formValues) + { + $adapter = new Zend_Auth_Adapter_DbTable(null, 'gems__staff', 'gsf_login', 'gsf_password'); + + $pwd_hash = $this->hashPassword($formValues['password']); + + $select = $adapter->getDbSelect(); + $select->where('gsf_active = 1') + ->where('gsf_id_organization = ?', $formValues['organization']); + + $adapter->setIdentity($formValues['userlogin']) + ->setCredential($pwd_hash); + + return $adapter; } /** @@ -178,78 +190,4 @@ { return md5($password); } - - public function getAuthAdapter($formValues) - { - $adapter = new Zend_Auth_Adapter_DbTable(null, 'gems__staff', 'gsf_login', 'gsf_password'); - - $pwd_hash = $this->hashPassword($formValues['password']); - - $select = $adapter->getDbSelect(); - $select->where('gsf_active = 1') - ->where('gsf_id_organization = ?', $formValues['organization']); - - $adapter->setIdentity($formValues['userlogin']) - ->setCredential($pwd_hash); - - return $adapter; - } - - /** - * Perform UserDefinition specific post-login logic - * - * @param Zend_Auth_Result $authResult - * @return void - */ - public function afterLogin($authResult, $formValues) - { - if ($authResult->isValid()) { - $login_name = $formValues['userlogin']; - $organization = $formValues['organization']; - $password = $formValues['password']; - $userData = $this->getUserData($formValues['userlogin'], $formValues['organization']); - $staff_id = $userData['user_id']; - - $sql = 'SELECT gul_id_user FROM gems__user_logins WHERE gul_can_login = 1 AND gul_login = ? AND gul_id_organization = ?'; - - try { - $user_id = $this->db->fetchOne($sql, array($login_name, $organization)); - - $currentTimestamp = new Zend_Db_Expr('CURRENT_TIMESTAMP'); - - // Move to USER_STAFF - $values['gup_id_user'] = $user_id; - $values['gup_password'] = $this->project->getValueHash($password); - $values['gup_reset_key'] = null; - $values['gup_reset_requested'] = null; - $values['gup_reset_required'] = 0; - $values['gup_changed'] = $currentTimestamp ; - $values['gup_changed_by'] = $staff_id; - $values['gup_created'] = $currentTimestamp ; - $values['gup_created_by'] = $staff_id; - - $this->db->insert('gems__user_passwords', $values); - - // Update user class - $values = array(); - $values['gul_user_class'] = Gems_User_UserLoader::USER_STAFF; - $values['gul_changed'] = $currentTimestamp ; - $values['gul_changed_by'] = $staff_id; - $this->db->update('gems__user_logins', $values, $this->db->quoteInto('gul_id_user = ?', $user_id)); - - // Remove old password - $values = array(); - $values['gsf_password'] = null; - $values['gsf_changed'] = $currentTimestamp ; - $values['gsf_changed_by'] = $user_id; - - $this->db->update('gems__staff', $values, $this->db->quoteInto('gsf_id_user = ?', $staff_id)); - - } catch (Zend_Db_Exception $e) { - // Fall through as this does not work if the database upgrade did not run - // MUtil_Echo::r($e); - - } - } - } -} +} \ No newline at end of file Modified: trunk/library/classes/Gems/User/ProjectUserDefinition.php =================================================================== --- trunk/library/classes/Gems/User/ProjectUserDefinition.php 2011-11-15 09:44:12 UTC (rev 216) +++ trunk/library/classes/Gems/User/ProjectUserDefinition.php 2011-11-15 10:29:43 UTC (rev 217) @@ -52,17 +52,10 @@ */ protected $project; - /** - * Checks the password for the specified $login_name and $organization. - * - * @param string $login_name - * @param int $organization - * @param string $password - * @return boolean True if the password is correct. - */ - public function checkPassword($login_name, $organization, $password) + public function getAuthAdapter($formValues) { - return $this->project->checkSuperAdminPassword($password); + $adapter = new Gems_Auth_Adapter_Callback(array($this->project,'checkSuperAdminPassword'), $formValues['userlogin'], $formValues['password']); + return $adapter; } /** @@ -86,10 +79,4 @@ 'allowedOrgs' => array($organization => 'SUPER ADMIN') ); } - - public function getAuthAdapter($formValues) - { - $adapter = new Gems_Auth_Adapter_Callback(array($this->project,'checkSuperAdminPassword'), $formValues['userlogin'], $formValues['password']); - return $adapter; - } -} +} \ No newline at end of file Modified: trunk/library/classes/Gems/User/StaffUserDefinition.php =================================================================== --- trunk/library/classes/Gems/User/StaffUserDefinition.php 2011-11-15 09:44:12 UTC (rev 216) +++ trunk/library/classes/Gems/User/StaffUserDefinition.php 2011-11-15 10:29:43 UTC (rev 217) @@ -92,29 +92,6 @@ } /** - * Checks the password for the specified $login_name and $organization. - * - * @param string $login_name - * @param int $organization - * @param string $password - * @return boolean True if the password is correct. - */ - public function checkPassword($login_name, $organization, $password) - { - $pwd_hash = $this->hashPassword($password); - - $sql = "SELECT gup_password - FROM gems__user_passwords INNER JOIN gems__user_logins ON gup_id_user = gul_id_user - WHERE gul_can_login = 1 AND gul_login = ? AND gul_id_organization = ?"; - - $db_pwd = $this->db->fetchOne($sql, array($login_name, $organization)); - - // MUtil_Echo::track($password, $pwd_hash, $db_pwd); - - return ($pwd_hash == $db_pwd); - } - - /** * Check whether a reset key is really linked to a user. * * @param Gems_User_User $user The user the key was created for (hopefully). @@ -136,6 +113,23 @@ return false; } + public function getAuthAdapter($formValues) + { + $adapter = new Zend_Auth_Adapter_DbTable($this->db, 'gems__user_passwords', 'gul_login', 'gup_password'); + + $pwd_hash = $this->hashPassword($formValues['password']); + + $select = $adapter->getDbSelect(); + $select->join('gems__user_logins', 'gup_id_user = gul_id_user', array()) + ->where('gul_can_login = 1') + ->where('gul_id_organization = ?', $formValues['organization']); + + $adapter->setIdentity($formValues['userlogin']) + ->setCredential($pwd_hash); + + return $adapter; + } + /** * Return a password reset key * @@ -252,21 +246,4 @@ return $this; } - - public function getAuthAdapter($formValues) - { - $adapter = new Zend_Auth_Adapter_DbTable($this->db, 'gems__user_passwords', 'gul_login', 'gup_password'); - - $pwd_hash = $this->hashPassword($formValues['password']); - - $select = $adapter->getDbSelect(); - $select->join('gems__user_logins', 'gup_id_user = gul_id_user', array()) - ->where('gul_can_login = 1') - ->where('gul_id_organization = ?', $formValues['organization']); - - $adapter->setIdentity($formValues['userlogin']) - ->setCredential($pwd_hash); - - return $adapter; - } -} +} \ No newline at end of file Modified: trunk/library/classes/Gems/User/User.php =================================================================== --- trunk/library/classes/Gems/User/User.php 2011-11-15 09:44:12 UTC (rev 216) +++ trunk/library/classes/Gems/User/User.php 2011-11-15 10:29:43 UTC (rev 217) @@ -227,17 +227,6 @@ } /** - * Checks the password for this user and handle the login security. - * - * @param string $password - * @return boolean True if the password is correct. - */ - public function checkPassword($password) - { - return $this->userLoader->checkPassword($this->getLoginName(), $this->getOrganizationId(), $password); - } - - /** * Check whether a reset key is really linked to this user. * * @param string The key Modified: trunk/library/classes/Gems/User/UserDefinitionInterface.php =================================================================== --- trunk/library/classes/Gems/User/UserDefinitionInterface.php 2011-11-15 09:44:12 UTC (rev 216) +++ trunk/library/classes/Gems/User/UserDefinitionInterface.php 2011-11-15 10:29:43 UTC (rev 217) @@ -69,16 +69,6 @@ public function canSetPassword(Gems_User_User $user = null); /** - * Checks the password for the specified $login_name and $organization. - * - * @param string $login_name - * @param int $organization - * @param string $password - * @return boolean True if the password is correct. - */ - public function checkPassword($login_name, $organization, $password); - - /** * Check whether a reset key is really linked to a user. * * @param Gems_User_User $user The user the key was created for (hopefully). Modified: trunk/library/classes/Gems/User/UserLoader.php =================================================================== --- trunk/library/classes/Gems/User/UserLoader.php 2011-11-15 09:44:12 UTC (rev 216) +++ trunk/library/classes/Gems/User/UserLoader.php 2011-11-15 10:29:43 UTC (rev 217) @@ -114,76 +114,6 @@ protected static $organizationStore; /** - * Checks the password for the specified $login_name and $organization and - * handles the login security. - * - * @param string $login_name - * @param int $organization - * @param string $password - * @return boolean True if the password is correct. - */ - public function checkPassword($login_name, $organization, $password) - { - // MUtil_Echo::track($login_name, $organization, $password); - $defName = $this->getUserClassName($login_name, $organization); - $definition = $this->_getClass($defName); - - $success = $definition->checkPassword($login_name, $organization, $password); - - try { - $sql = "SELECT gula_failed_logins, gula_last_failed FROM gems__user_login_attemps WHERE gula_login = ? AND gula_id_organization = ?"; - $values = $this->db->fetchRow($sql, array($login_name, $organization)); - - if (! $values) { - $values = array(); - $values['gula_login'] = $login_name; - $values['gula_id_organization'] = $organization; - $values['gula_failed_logins'] = 0; - $values['gula_last_failed'] = null; - } - if ($success) { - $values['gula_failed_logins'] = 0; - $values['gula_last_failed'] = null; - } else { - if ($values['gula_failed_logins']) { - // Get the datetime - $last = new MUtil_Date($values['gula_last_failed'], Zend_Date::ISO_8601); - - // How long to wait until we can ignore the previous failed attempt - $delay = pow($values['gula_failed_logins'], $this->project->getAccountDelayFactor()); - - if (abs($last->diffSeconds()) <= $delay) { - // Response gets slowly slower - sleep(min($values['gula_failed_logins'], 10)); - - $values['gula_failed_logins'] += 1; - - } else { - $values['gula_failed_logins'] = 1; - } - } else { - $values['gula_failed_logins'] = 1; - } - $values['gula_failed_logins'] = max($values['gula_failed_logins'], 1); - $values['gula_last_failed'] = new Zend_Db_Expr('CURRENT_TIMESTAMP'); - } - - if (isset($values['gula_login'])) { - $this->db->insert('gems__user_login_attemps', $values); - } else { - $where = $this->db->quoteInto('gula_login = ? AND ', $login_name); - $where .= $this->db->quoteInto('gula_id_organization = ?', $organization); - $this->db->update('gems__user_login_attemps', $values, $where); - } - - } catch (Zend_Db_Exception $e) { - // Fall through as this does not work if the database upgrade did not run - // MUtil_Echo::r($e); - } - return $success; - } - - /** * Should be called after answering the request to allow the Target * to check if all required registry values have been set correctly. * Deleted: trunk/library/classes/Gems/User/UserPasswordValidator.php =================================================================== --- trunk/library/classes/Gems/User/UserPasswordValidator.php 2011-11-15 09:44:12 UTC (rev 216) +++ trunk/library/classes/Gems/User/UserPasswordValidator.php 2011-11-15 10:29:43 UTC (rev 217) @@ -1,118 +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.5 - */ -class Gems_User_UserPasswordValidator implements Zend_Validate_Interface -{ - /** - * - * @var Gems_User_User - */ - private $_user; - - /** - * - * @var Zend_Translate - */ - private $_translate; - - /** - * - * @var boolean - */ - private $_valid = false; - - /** - * - * @param Gems_User_User $user The user to check - * @param Zend_Translate $translate Optional translator - */ - public function __construct(Gems_User_User $user, Zend_Translate $translate = null) - { - $this->_user = $user; - $this->_translate = $translate ? $translate : new MUtil_Translate_Adapter_Potemkin(); - } - - /** - * Returns true if and only if $value meets the validation requirements - * - * If $value fails validation, then this method returns false, and - * getMessages() will return an array of messages that explain why the - * validation failed. - * - * @param mixed $value - * @param mixed $content - * @return boolean - * @throws Zend_Validate_Exception If validation of $value is impossible - */ - public function isValid($value, $context = array()) - { - $this->_valid = $this->_user->checkPassword($value); - - return $this->_valid; - } - - /** - * Returns an array of messages that explain why the most recent isValid() - * call returned false. The array keys are validation failure message identifiers, - * and the array values are the corresponding human-readable message strings. - * - * If isValid() was never called or if the most recent isValid() call - * returned true, then this method returns an empty array. - * - * @return array - */ - public function getMessages() - { - if ($this->_valid) { - return array(); - - } else { - return array($this->_translate->_('Wrong password.')); - } - - - } -} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2011-11-15 09:44:19
|
Revision: 216 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=216&view=rev Author: mennodekker Date: 2011-11-15 09:44:12 +0000 (Tue, 15 Nov 2011) Log Message: ----------- Forgot some variables Modified Paths: -------------- trunk/library/classes/Gems/User/OldStaffUserDefinition.php Modified: trunk/library/classes/Gems/User/OldStaffUserDefinition.php =================================================================== --- trunk/library/classes/Gems/User/OldStaffUserDefinition.php 2011-11-15 09:37:16 UTC (rev 215) +++ trunk/library/classes/Gems/User/OldStaffUserDefinition.php 2011-11-15 09:44:12 UTC (rev 216) @@ -204,6 +204,9 @@ public function afterLogin($authResult, $formValues) { if ($authResult->isValid()) { + $login_name = $formValues['userlogin']; + $organization = $formValues['organization']; + $password = $formValues['password']; $userData = $this->getUserData($formValues['userlogin'], $formValues['organization']); $staff_id = $userData['user_id']; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2011-11-15 09:37:23
|
Revision: 215 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=215&view=rev Author: mennodekker Date: 2011-11-15 09:37:16 +0000 (Tue, 15 Nov 2011) Log Message: ----------- Almost done putting Auth back in, checkpassword still to be removed Modified Paths: -------------- trunk/library/classes/Gems/Auth.php trunk/library/classes/Gems/Default/IndexAction.php trunk/library/classes/Gems/User/NoLoginDefinition.php trunk/library/classes/Gems/User/OldStaffUserDefinition.php trunk/library/classes/Gems/User/ProjectUserDefinition.php trunk/library/classes/Gems/User/StaffUserDefinition.php trunk/library/classes/Gems/User/User.php trunk/library/classes/Gems/User/UserDefinitionInterface.php Added Paths: ----------- trunk/library/classes/Gems/Auth/ trunk/library/classes/Gems/Auth/Adapter/ trunk/library/classes/Gems/Auth/Adapter/Callback.php Added: trunk/library/classes/Gems/Auth/Adapter/Callback.php =================================================================== --- trunk/library/classes/Gems/Auth/Adapter/Callback.php (rev 0) +++ trunk/library/classes/Gems/Auth/Adapter/Callback.php 2011-11-15 09:37:16 UTC (rev 215) @@ -0,0 +1,90 @@ +<?php +/** + * Copyright (c) 2011, Erasmus MC + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Erasmus MC nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * Short description of file + * + * @package Gems + * @subpackage Auth + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @version $Id: Sample.php 215 2011-07-12 08:52:54Z michiel $ + */ + +/** + * Short description for Callback + * + * Long description for class Callback (if any)... + * + * @package Gems + * @subpackage Auth + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @since Class available since version 1.0 + * @deprecated Class deprecated since version 2.0 + */ +class Gems_Auth_Adapter_Callback implements Zend_Auth_Adapter_Interface +{ + private $_callback; + private $_identity; + private $_params; + + /** + * Create an auth adapter from a callback + * + * Ideally the callback should return a Zend_Auth_Result, when not it should + * return true or false and in that case this adapter will wrap the result + * in a Zend_Auth_Result + * + * @param type $callback A valid callback + * @param type $identity The identity to use + * @param type $params Array of parameters needed for the callback + */ + public function __construct($callback, $identity, $params) + { + $this->_callback = $callback; + $this->_identity = $identity; + $this->_params = $params; + } + + /** + * Perform the authenticate attempt + * + * @return Zend_Auth_Result + */ + public function authenticate() + { + $result = call_user_func_array($this->_callback, $this->_params); + if ( !($result instanceof Zend_Auth_Result)) { + if ($result === true) { + $result = new Zend_Auth_Result(Zend_Auth_Result::SUCCESS, $this->_identity); + } else { + $result = new Zend_Auth_Result(Zend_Auth_Result::FAILURE, $this->_identity); + } + } + return $result; + } +} \ No newline at end of file Modified: trunk/library/classes/Gems/Auth.php =================================================================== --- trunk/library/classes/Gems/Auth.php 2011-11-15 08:18:52 UTC (rev 214) +++ trunk/library/classes/Gems/Auth.php 2011-11-15 09:37:16 UTC (rev 215) @@ -57,7 +57,7 @@ */ protected $_messageTemplates = array( self::ERROR_DATABASE_NOT_INSTALLED => 'Installation not complete! Login is not yet possible!', - self::ERROR_PASSWORD_DELAY => 'Your account is temporarily blocked, please wait %s minutes' + self::ERROR_PASSWORD_DELAY => 'Your account is temporarily blocked, please wait %s seconds' ); /** @@ -92,37 +92,76 @@ return new Zend_Auth_Result($code, null, (array) $messages); } - public function authenticate(Zend_Auth_Adapter_Interface $adapter, $username = '') { + public function authenticate(Zend_Auth_Adapter_Interface $adapter, $formValues) { try { - /** - * Lookup last failed login and number of failed logins - */ - try { - $sql = "SELECT gul_failed_logins, UNIX_TIMESTAMP(gul_last_failed) AS gul_last_failed - FROM gems__user_logins WHERE gul_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 - $results = 0; - MUtil_Echo::r(GemsEscort::getInstance()->translate->_('Please update the database')); - } + $login_name = $formValues['userlogin']; + $organization = $formValues['organization']; + $sql = "SELECT gula_failed_logins, gula_last_failed FROM gems__user_login_attemps WHERE gula_login = ? AND gula_id_organization = ?"; + $values = $this->db->fetchRow($sql, array($login_name, $organization)); - $delay = pow($results['gul_failed_logins'], $this->_delayFactor); - $remaining = ($results['gul_last_failed'] + $delay) - time(); + if (! $values) { + $values = array(); + $values['gula_login'] = $login_name; + $values['gula_id_organization'] = $organization; + $values['gula_failed_logins'] = 0; + $values['gula_last_failed'] = null; + } elseif ($values['gula_failed_logins'] > 0) { + // Get the datetime + $last = new MUtil_Date($values['gula_last_failed'], Zend_Date::ISO_8601); - if ($results['gul_failed_logins'] > 0 && $remaining > 0) { - //$this->_obscureValue = false; - $result = $this->_error(self::ERROR_PASSWORD_DELAY, ceil($remaining / 60)); + // How long to wait until we can ignore the previous failed attempt + $delay = pow($values['gula_failed_logins'], GemsEscort::getInstance()->project->getAccountDelayFactor()); + + if (abs($last->diffSeconds()) <= $delay) { + // Response gets slowly slower + $sleepTime = min($values['gula_failed_logins'], 10); + sleep($sleepTime); + $remaining = $delay - abs($last->diffSeconds()) - $sleepTime; + if ($remaining>0) { + $result = $this->_error(self::ERROR_PASSWORD_DELAY, $remaining); + } + } } - } catch (Zend_Db_Exception $zde) { - $result = $this->_error(self::ERROR_DATABASE_NOT_INSTALLED); + } catch (Zend_Db_Exception $e) { + // Fall through as this does not work if the database upgrade did not run + // MUtil_Echo::r($e); } - if (!isset($result)) { - //Ok we are done without errors, now delegate to the Zend_Auth_Adapter + // We only forward to auth adapter when we have no timeout to prevent hammering the auth system + if (! isset($result) ) { $result = parent::authenticate($adapter); } + if ($result->isValid()) { + $values['gula_failed_logins'] = 0; + $values['gula_last_failed'] = null; + } else { + if ($values['gula_failed_logins']) { + // Only increment when we have no password delay + if ($result->getCode() <> self::ERROR_PASSWORD_DELAY) { + $values['gula_failed_logins'] += 1; + $values['gula_last_failed'] = new Zend_Db_Expr('CURRENT_TIMESTAMP'); + } + } else { + $values['gula_failed_logins'] = 1; + $values['gula_last_failed'] = new Zend_Db_Expr('CURRENT_TIMESTAMP'); + } + $values['gula_failed_logins'] = max($values['gula_failed_logins'], 1); + } + + try { + if (isset($values['gula_login'])) { + $this->db->insert('gems__user_login_attemps', $values); + } else { + $where = $this->db->quoteInto('gula_login = ? AND ', $login_name); + $where .= $this->db->quoteInto('gula_id_organization = ?', $organization); + $this->db->update('gems__user_login_attemps', $values, $where); + } + } catch (Zend_Db_Exception $e) { + // Fall through as this does not work if the database upgrade did not run + // MUtil_Echo::r($e); + } + //Now localize $result = $this->localize($result); Modified: trunk/library/classes/Gems/Default/IndexAction.php =================================================================== --- trunk/library/classes/Gems/Default/IndexAction.php 2011-11-15 08:18:52 UTC (rev 214) +++ trunk/library/classes/Gems/Default/IndexAction.php 2011-11-15 09:37:16 UTC (rev 215) @@ -184,7 +184,7 @@ $element->setAttrib('size', 10); $element->setAttrib('maxlength', 20); $element->setRequired(true); - $element->addValidator(new Gems_User_LoginPasswordValidator($this->loader->getUserLoader(), 'userlogin', 'organization', $this->translate)); + //$element->addValidator(new Gems_User_LoginPasswordValidator($this->loader->getUserLoader(), 'userlogin', 'organization', $this->translate)); return $element; } @@ -284,31 +284,42 @@ $user = $this->loader->getUser($request->getParam('userlogin'), $request->getParam('organization')); if ($user->isActive()) { - $user->setAsCurrentUser(); + $formValues = $form->getValues(); + $authResult = $user->authenticate($formValues); - /** - * Fix current locale / organization in cookies - */ - Gems_Cookies::setLocale($user->getLocale(), $this->basepath->getBasePath()); - Gems_Cookies::setOrganization($user->getOrganizationId(), $this->basepath->getBasePath()); + if ($authResult->isValid()) { - /** - * Ready - */ - $this->addMessage(sprintf($this->_('Login successful, welcome %s.'), $user->getFullName())); + $user->setAsCurrentUser(); - /** - * Log the login - */ - Gems_AccessLog::getLog($this->db)->log("index.login", $this->getRequest(), null, $user->getUserId(), true); + $user->afterLogin($form->getValues()); - if ($previousRequestParameters = $this->session->previousRequestParameters) { - $this->_reroute(array('controller' => $previousRequestParameters['controller'], 'action' => $previousRequestParameters['action']), false); + /** + * Fix current locale / organization in cookies + */ + Gems_Cookies::setLocale($user->getLocale(), $this->basepath->getBasePath()); + Gems_Cookies::setOrganization($user->getOrganizationId(), $this->basepath->getBasePath()); + + /** + * Ready + */ + $this->addMessage(sprintf($this->_('Login successful, welcome %s.'), $user->getFullName())); + + /** + * Log the login + */ + Gems_AccessLog::getLog($this->db)->log("index.login", $this->getRequest(), null, $user->getUserId(), true); + + if ($previousRequestParameters = $this->session->previousRequestParameters) { + $this->_reroute(array('controller' => $previousRequestParameters['controller'], 'action' => $previousRequestParameters['action']), false); + } else { + // This reroutes to the first available menu page after login + $this->_reroute(array('controller' => null, 'action' => null), true); + } + return; } else { - // This reroutes to the first available menu page after login - $this->_reroute(array('controller' => null, 'action' => null), true); + $errors = $authResult->getMessages(); + $this->addMessage($errors); } - return; } } else { $errors = $form->getErrors(); Modified: trunk/library/classes/Gems/User/NoLoginDefinition.php =================================================================== --- trunk/library/classes/Gems/User/NoLoginDefinition.php 2011-11-15 08:18:52 UTC (rev 214) +++ trunk/library/classes/Gems/User/NoLoginDefinition.php 2011-11-15 09:37:16 UTC (rev 215) @@ -74,4 +74,15 @@ //'user_organization_id' => 0, //REMOVED AS IT BREAKS STORING LAST ORGANIZATION ); } + + public function getAuthAdapter($formValues) + { + $adapter = new Gems_Auth_Adapter_Callback(array(get_class(),'alwaysFalse'), $formValues['userlogin'], $formValues); + return $adapter; + } + + private function alwaysFalse($params) { + $result = new Zend_Auth_Result(Zend_Auth_Result::FAILURE, $params['userlogin']); + return false; + } } Modified: trunk/library/classes/Gems/User/OldStaffUserDefinition.php =================================================================== --- trunk/library/classes/Gems/User/OldStaffUserDefinition.php 2011-11-15 08:18:52 UTC (rev 214) +++ trunk/library/classes/Gems/User/OldStaffUserDefinition.php 2011-11-15 09:37:16 UTC (rev 215) @@ -178,4 +178,75 @@ { return md5($password); } + + public function getAuthAdapter($formValues) + { + $adapter = new Zend_Auth_Adapter_DbTable(null, 'gems__staff', 'gsf_login', 'gsf_password'); + + $pwd_hash = $this->hashPassword($formValues['password']); + + $select = $adapter->getDbSelect(); + $select->where('gsf_active = 1') + ->where('gsf_id_organization = ?', $formValues['organization']); + + $adapter->setIdentity($formValues['userlogin']) + ->setCredential($pwd_hash); + + return $adapter; + } + + /** + * Perform UserDefinition specific post-login logic + * + * @param Zend_Auth_Result $authResult + * @return void + */ + public function afterLogin($authResult, $formValues) + { + if ($authResult->isValid()) { + $userData = $this->getUserData($formValues['userlogin'], $formValues['organization']); + $staff_id = $userData['user_id']; + + $sql = 'SELECT gul_id_user FROM gems__user_logins WHERE gul_can_login = 1 AND gul_login = ? AND gul_id_organization = ?'; + + try { + $user_id = $this->db->fetchOne($sql, array($login_name, $organization)); + + $currentTimestamp = new Zend_Db_Expr('CURRENT_TIMESTAMP'); + + // Move to USER_STAFF + $values['gup_id_user'] = $user_id; + $values['gup_password'] = $this->project->getValueHash($password); + $values['gup_reset_key'] = null; + $values['gup_reset_requested'] = null; + $values['gup_reset_required'] = 0; + $values['gup_changed'] = $currentTimestamp ; + $values['gup_changed_by'] = $staff_id; + $values['gup_created'] = $currentTimestamp ; + $values['gup_created_by'] = $staff_id; + + $this->db->insert('gems__user_passwords', $values); + + // Update user class + $values = array(); + $values['gul_user_class'] = Gems_User_UserLoader::USER_STAFF; + $values['gul_changed'] = $currentTimestamp ; + $values['gul_changed_by'] = $staff_id; + $this->db->update('gems__user_logins', $values, $this->db->quoteInto('gul_id_user = ?', $user_id)); + + // Remove old password + $values = array(); + $values['gsf_password'] = null; + $values['gsf_changed'] = $currentTimestamp ; + $values['gsf_changed_by'] = $user_id; + + $this->db->update('gems__staff', $values, $this->db->quoteInto('gsf_id_user = ?', $staff_id)); + + } catch (Zend_Db_Exception $e) { + // Fall through as this does not work if the database upgrade did not run + // MUtil_Echo::r($e); + + } + } + } } Modified: trunk/library/classes/Gems/User/ProjectUserDefinition.php =================================================================== --- trunk/library/classes/Gems/User/ProjectUserDefinition.php 2011-11-15 08:18:52 UTC (rev 214) +++ trunk/library/classes/Gems/User/ProjectUserDefinition.php 2011-11-15 09:37:16 UTC (rev 215) @@ -86,4 +86,10 @@ 'allowedOrgs' => array($organization => 'SUPER ADMIN') ); } + + public function getAuthAdapter($formValues) + { + $adapter = new Gems_Auth_Adapter_Callback(array($this->project,'checkSuperAdminPassword'), $formValues['userlogin'], $formValues['password']); + return $adapter; + } } Modified: trunk/library/classes/Gems/User/StaffUserDefinition.php =================================================================== --- trunk/library/classes/Gems/User/StaffUserDefinition.php 2011-11-15 08:18:52 UTC (rev 214) +++ trunk/library/classes/Gems/User/StaffUserDefinition.php 2011-11-15 09:37:16 UTC (rev 215) @@ -252,4 +252,21 @@ return $this; } + + public function getAuthAdapter($formValues) + { + $adapter = new Zend_Auth_Adapter_DbTable($this->db, 'gems__user_passwords', 'gul_login', 'gup_password'); + + $pwd_hash = $this->hashPassword($formValues['password']); + + $select = $adapter->getDbSelect(); + $select->join('gems__user_logins', 'gup_id_user = gul_id_user', array()) + ->where('gul_can_login = 1') + ->where('gul_id_organization = ?', $formValues['organization']); + + $adapter->setIdentity($formValues['userlogin']) + ->setCredential($pwd_hash); + + return $adapter; + } } Modified: trunk/library/classes/Gems/User/User.php =================================================================== --- trunk/library/classes/Gems/User/User.php 2011-11-15 08:18:52 UTC (rev 214) +++ trunk/library/classes/Gems/User/User.php 2011-11-15 09:37:16 UTC (rev 215) @@ -48,6 +48,12 @@ { /** * + * @var Zend_Auth_Result + */ + private $_authResult; + + /** + * * @var ArrayObject or Zend_Session_Namespace */ private $_vars; @@ -173,6 +179,34 @@ } /** + * Perform project specific after login logic here, can also delegate to the user definition + * + * @return void + */ + public function afterLogin($formValues) { + if (is_callable(array($this->definition, 'afterLogin'))) { + $this->definition->afterLogin($this->_authResult, $formValues); + } + } + + /** + * Authenticate a users credentials using the submitted form + * + * @param array $formValues the array containing all formvalues from the login form + * @return boolean + */ + public function authenticate($formValues) + { + $auth = Gems_Auth::getInstance(); + $adapter = $this->definition->getAuthAdapter($formValues); + $authResult = $auth->authenticate($adapter, $formValues); + + $this->_authResult = $authResult; + + return $authResult; + } + + /** * Return true if a password reset key can be created. * * @return boolean Modified: trunk/library/classes/Gems/User/UserDefinitionInterface.php =================================================================== --- trunk/library/classes/Gems/User/UserDefinitionInterface.php 2011-11-15 08:18:52 UTC (rev 214) +++ trunk/library/classes/Gems/User/UserDefinitionInterface.php 2011-11-15 09:37:16 UTC (rev 215) @@ -88,6 +88,13 @@ public function checkPasswordResetKey(Gems_User_User $user, $key); /** + * Returns an initialized Zend_Auth_Adapter_Interface + * + * @return Zend_Auth_Adapter_Interface + */ + public function getAuthAdapter($formValues); + + /** * Return a password reset key * * @param Gems_User_User $user The user to create a key for. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2011-11-15 08:18:58
|
Revision: 214 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=214&view=rev Author: mennodekker Date: 2011-11-15 08:18:52 +0000 (Tue, 15 Nov 2011) Log Message: ----------- No extra call needed to apply a request, can only be forgotten when switching outside Escort Modified Paths: -------------- trunk/library/classes/Gems/User/User.php trunk/library/classes/GemsEscort.php Modified: trunk/library/classes/Gems/User/User.php =================================================================== --- trunk/library/classes/Gems/User/User.php 2011-11-14 17:51:04 UTC (rev 213) +++ trunk/library/classes/Gems/User/User.php 2011-11-15 08:18:52 UTC (rev 214) @@ -173,22 +173,6 @@ } /** - * Applies any setttings coming from the request object, e.g. processing cookies. - * - * @param Zend_Controller_Request_Abstract $request - * @return Gems_User_User (continuation pattern) - */ - public function applyRequest(Zend_Controller_Request_Abstract $request) - { - // MUtil_Echo::track($this->getOrganizationId(), Gems_Cookies::getOrganization($request)); - if (! $this->getOrganizationId()) { - $this->_setVar('user_organization_id', Gems_Cookies::getOrganization($request)); - } - - return $this; - } - - /** * Return true if a password reset key can be created. * * @return boolean @@ -332,7 +316,13 @@ */ public function getOrganizationId() { - return $this->_getVar('user_organization_id'); + $orgId = $this->_getVar('user_organization_id'); + + //If not set, read it from the cookie + if (is_null($orgId)) { + $orgId = Gems_Cookies::getOrganization(Zend_Controller_Front::getInstance()->getRequest()); + } + return $orgId; } /** Modified: trunk/library/classes/GemsEscort.php =================================================================== --- trunk/library/classes/GemsEscort.php 2011-11-14 17:51:04 UTC (rev 213) +++ trunk/library/classes/GemsEscort.php 2011-11-15 08:18:52 UTC (rev 214) @@ -1434,8 +1434,7 @@ public function routeShutdown(Zend_Controller_Request_Abstract $request) { $loader = $this->getLoader(); - $user = $loader->getCurrentUser() - ->applyRequest($request); + $user = $loader->getCurrentUser(); // MUtil_Echo::r($request->getParams(), 'params'); // MUtil_Echo::r($request->getUserParams(), 'userparams'); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2011-11-14 17:51:14
|
Revision: 213 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=213&view=rev Author: matijsdejong Date: 2011-11-14 17:51:04 +0000 (Mon, 14 Nov 2011) Log Message: ----------- Started on independent Organization object for #31 respondent login. User switch is performed on organization cookie instead of style cookie. Added a lot of documentation. Modified Paths: -------------- trunk/library/changelog.txt trunk/library/classes/Gems/Default/IndexAction.php trunk/library/classes/Gems/Loader.php trunk/library/classes/Gems/Project/Layout/MultiLayoutInterface.php trunk/library/classes/Gems/Project/Layout/SingleLayoutInterface.php trunk/library/classes/Gems/Project/Log/LogRespondentAccessInterface.php trunk/library/classes/Gems/Project/Organization/MultiOrganizationInterface.php trunk/library/classes/Gems/Project/Organization/SingleOrganizationInterface.php trunk/library/classes/Gems/Project/Tracks/FixedTracksInterface.php trunk/library/classes/Gems/Project/Tracks/MultiTracksInterface.php trunk/library/classes/Gems/Project/Tracks/SingleTrackInterface.php trunk/library/classes/Gems/Project/Tracks/StandAloneSurveysInterface.php trunk/library/classes/Gems/Project/Tracks/TracksOnlyInterface.php trunk/library/classes/Gems/User/User.php trunk/library/classes/Gems/User/UserLoader.php trunk/library/classes/GemsEscort.php Added Paths: ----------- trunk/library/classes/Gems/User/Organization.php Modified: trunk/library/changelog.txt =================================================================== --- trunk/library/changelog.txt 2011-11-14 15:42:16 UTC (rev 212) +++ trunk/library/changelog.txt 2011-11-14 17:51:04 UTC (rev 213) @@ -2,6 +2,7 @@ ============================================================ Passwords should be set with a project.ini->salt. Salt is now a required project setting! The table gems__staff is split into gems__staff, gems__user_logins with generic login data and gems__users_passwords containing db stored password information. +GemsEscort->afterLogin(), ->afterLogout() and ->loadLoginInfo(0 are now all handled by Gems_User_UserDefinitionInterface objects. The table gems__user_ids provides unique and non-sequential user ids accross gems__staff and gems__respondents. The gems__respondent.grs_bsn has been renamed to grs_ssn, to make the code more international. MailController is now called MailTemplateController. Modified: trunk/library/classes/Gems/Default/IndexAction.php =================================================================== --- trunk/library/classes/Gems/Default/IndexAction.php 2011-11-14 15:42:16 UTC (rev 212) +++ trunk/library/classes/Gems/Default/IndexAction.php 2011-11-14 17:51:04 UTC (rev 213) @@ -164,7 +164,7 @@ $element->setRequired(true); if (! $this->_request->isPost()) { - $element->setValue($this->escort->getCurrentOrganization()); + $element->setValue($this->loader->getCurrentUser()->getOrganizationId()); } } Modified: trunk/library/classes/Gems/Loader.php =================================================================== --- trunk/library/classes/Gems/Loader.php 2011-11-14 15:42:16 UTC (rev 212) +++ trunk/library/classes/Gems/Loader.php 2011-11-14 17:51:04 UTC (rev 213) @@ -160,7 +160,20 @@ } /** + * Returns an organization object, initiated from the database. * + * @param int $organizationId Optional, uses current user when empty + * @return Gems_User_Organization + */ + public function getOrganization($organizationId = null) + { + $loader = $this->getUserLoader(); + + return $loader->getOrganization($organizationId); + } + + /** + * * @return Gems_Pdf */ public function getPdf() Modified: trunk/library/classes/Gems/Project/Layout/MultiLayoutInterface.php =================================================================== --- trunk/library/classes/Gems/Project/Layout/MultiLayoutInterface.php 2011-11-14 15:42:16 UTC (rev 212) +++ trunk/library/classes/Gems/Project/Layout/MultiLayoutInterface.php 2011-11-14 17:51:04 UTC (rev 213) @@ -1,34 +1,41 @@ <?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. + * + * + * @package Gems + * @subpackage Project + * @author Matijs de Jong <mj...@ma...> + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @version $Id$ + */ + +/** * Marker interface for Pulse Projects using only multi layout * * But Gems_Project_Layout_MultiLayoutAbstract implements the functionality to use these functions. @@ -37,14 +44,25 @@ * * @see Gems_Project_Layout_SingleLayoutInterface * - * @author Matijs de Jong <mj...@ma...> - * @since 1.1 - * @version 1.1 - * @package Gems + * @package Gems * @subpackage Project + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @since Class available since version 1.1 */ interface Gems_Project_Layout_MultiLayoutInterface { + /** + * Returns an array with descriptions of the styles that can be used in this project. + * + * @return array styleKey => styleDescription + */ public function getStyles(); - public function layoutSwitch(Zend_Controller_Request_Abstract $request, $settings); + + /** + * Performs the actual switch of the layout + * + * @param Zend_Controller_Request_Abstract $request + */ + public function layoutSwitch(Zend_Controller_Request_Abstract $request); } \ No newline at end of file Modified: trunk/library/classes/Gems/Project/Layout/SingleLayoutInterface.php =================================================================== --- trunk/library/classes/Gems/Project/Layout/SingleLayoutInterface.php 2011-11-14 15:42:16 UTC (rev 212) +++ trunk/library/classes/Gems/Project/Layout/SingleLayoutInterface.php 2011-11-14 17:51:04 UTC (rev 213) @@ -1,43 +1,50 @@ <?php - -/** - * Copyright (c) 2011, Erasmus MC - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of Erasmus MC nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - /** + * 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 Project + * @author Matijs de Jong <mj...@ma...> + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @version $Id$ + */ + +/** * Marker interface for Pulse Projects using only a single layout * * @see Gems_Project_Layout_MultiLayoutInterface * - * @author Matijs de Jong <mj...@ma...> - * @since 1.1 - * @version 1.1 - * @package Gems + * @package Gems * @subpackage Project + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @since Class available since version 1.1 */ interface Gems_Project_Layout_SingleLayoutInterface { Modified: trunk/library/classes/Gems/Project/Log/LogRespondentAccessInterface.php =================================================================== --- trunk/library/classes/Gems/Project/Log/LogRespondentAccessInterface.php 2011-11-14 15:42:16 UTC (rev 212) +++ trunk/library/classes/Gems/Project/Log/LogRespondentAccessInterface.php 2011-11-14 17:51:04 UTC (rev 213) @@ -1,41 +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. - */ - /** + * 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 Project + * @author Matijs de Jong <mj...@ma...> + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @version $Id$ + */ + +/** * Marker interface for Pulse Projects logging access to respondent data and their tokens * - * @author Matijs de Jong <mj...@ma...> - * @since 1.1 - * @version 1.1 - * @package Gems + * @package Gems * @subpackage Project + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @since Class available since version 1.1 */ interface Gems_Project_Log_LogRespondentAccessInterface {} \ No newline at end of file Modified: trunk/library/classes/Gems/Project/Organization/MultiOrganizationInterface.php =================================================================== --- trunk/library/classes/Gems/Project/Organization/MultiOrganizationInterface.php 2011-11-14 15:42:16 UTC (rev 212) +++ trunk/library/classes/Gems/Project/Organization/MultiOrganizationInterface.php 2011-11-14 17:51:04 UTC (rev 213) @@ -1,6 +1,5 @@ <?php - /** * Copyright (c) 2011, Erasmus MC * All rights reserved. @@ -26,6 +25,14 @@ * 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 Project + * @author Matijs de Jong <mj...@ma...> + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @version $Id$ */ /** @@ -40,13 +47,12 @@ * * @see Gems_Project_Organization_SingleOrganizationInterface * - * @author Matijs de Jong <mj...@ma...> - * @since 1.1 - * @version 1.1 - * @package Gems + * @package Gems * @subpackage Project + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @since Class available since version 1.1 */ interface Gems_Project_Organization_MultiOrganizationInterface { - public function getUserOrganization(); } Modified: trunk/library/classes/Gems/Project/Organization/SingleOrganizationInterface.php =================================================================== --- trunk/library/classes/Gems/Project/Organization/SingleOrganizationInterface.php 2011-11-14 15:42:16 UTC (rev 212) +++ trunk/library/classes/Gems/Project/Organization/SingleOrganizationInterface.php 2011-11-14 17:51:04 UTC (rev 213) @@ -1,34 +1,41 @@ <?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. + * + * + * @package Gems + * @subpackage Project + * @author Matijs de Jong <mj...@ma...> + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @version $Id$ + */ + +/** * Marker interface for Pulse Projects having respondents * in only one organization. * @@ -37,11 +44,11 @@ * * @see Gems_Project_Organization_MultiOrganizationInterface * - * @author Matijs de Jong <mj...@ma...> - * @since 1.1 - * @version 1.1 - * @package Gems + * @package Gems * @subpackage Project + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @since Class available since version 1.1 */ interface Gems_Project_Organization_SingleOrganizationInterface { Modified: trunk/library/classes/Gems/Project/Tracks/FixedTracksInterface.php =================================================================== --- trunk/library/classes/Gems/Project/Tracks/FixedTracksInterface.php 2011-11-14 15:42:16 UTC (rev 212) +++ trunk/library/classes/Gems/Project/Tracks/FixedTracksInterface.php 2011-11-14 17:51:04 UTC (rev 213) @@ -1,45 +1,52 @@ <?php - -/** - * Copyright (c) 2011, Erasmus MC - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of Erasmus MC nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - /** + * 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 Project + * @author Matijs de Jong <mj...@ma...> + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @version $Id$ + */ + +/** * Marker interface for Pulse Projects that use tracks that cannot be assigned by the user * (but are assigned by the system instead). * * @see Gems_Project_Tracks_MultiTracksInterface * @see Gems_Project_Tracks_SingleTrackInterface * - * @author Matijs de Jong <mj...@ma...> - * @since 1.1 - * @version 1.1 - * @package Gems + * @package Gems * @subpackage Project + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @since Class available since version 1.1 */ interface Gems_Project_Tracks_FixedTracksInterface { Modified: trunk/library/classes/Gems/Project/Tracks/MultiTracksInterface.php =================================================================== --- trunk/library/classes/Gems/Project/Tracks/MultiTracksInterface.php 2011-11-14 15:42:16 UTC (rev 212) +++ trunk/library/classes/Gems/Project/Tracks/MultiTracksInterface.php 2011-11-14 17:51:04 UTC (rev 213) @@ -1,45 +1,52 @@ <?php - -/** - * Copyright (c) 2011, Erasmus MC - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of Erasmus MC nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - /** + * 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 Project + * @author Matijs de Jong <mj...@ma...> + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @version $Id$ + */ + +/** * Marker interface for Pulse Projects that use tracks that be assigned at will by the user * to respondents. * * @see Gems_Project_Tracks_FixedTracksInterface * @see Gems_Project_Tracks_SingleTrackInterface * - * @author Matijs de Jong <mj...@ma...> - * @since 1.1 - * @version 1.1 - * @package Gems + * @package Gems * @subpackage Project + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @since Class available since version 1.1 */ interface Gems_Project_Tracks_MultiTracksInterface { Modified: trunk/library/classes/Gems/Project/Tracks/SingleTrackInterface.php =================================================================== --- trunk/library/classes/Gems/Project/Tracks/SingleTrackInterface.php 2011-11-14 15:42:16 UTC (rev 212) +++ trunk/library/classes/Gems/Project/Tracks/SingleTrackInterface.php 2011-11-14 17:51:04 UTC (rev 213) @@ -1,33 +1,40 @@ <?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. + * + * + * @package Gems + * @subpackage Project + * @author Matijs de Jong <mj...@ma...> + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @version $Id$ + */ + include_once('Gems/Project/Tracks/TracksOnlyInterface.php'); /** @@ -41,11 +48,11 @@ * @see Gems_Project_Tracks_FixedTracksInterface * @see Gems_Project_Tracks_MultiTracksInterface * - * @author Matijs de Jong <mj...@ma...> - * @since 1.1 - * @version 1.1 - * @package Gems + * @package Gems * @subpackage Project + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @since Class available since version 1.1 */ interface Gems_Project_Tracks_SingleTrackInterface extends Gems_Project_Tracks_TracksOnlyInterface { Modified: trunk/library/classes/Gems/Project/Tracks/StandAloneSurveysInterface.php =================================================================== --- trunk/library/classes/Gems/Project/Tracks/StandAloneSurveysInterface.php 2011-11-14 15:42:16 UTC (rev 212) +++ trunk/library/classes/Gems/Project/Tracks/StandAloneSurveysInterface.php 2011-11-14 17:51:04 UTC (rev 213) @@ -1,44 +1,51 @@ <?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. + * + * + * @package Gems + * @subpackage Project + * @author Matijs de Jong <mj...@ma...> + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @version $Id$ + */ + +/** * Marker interface for Pulse Projects allowing single survey tracks * that are just shells for assinging a single survey. * * @see Gems_Project_Tracks_TracksOnlyInterface * - * @author Matijs de Jong <mj...@ma...> - * @since 1.1 - * @version 1.1 - * @package Gems + * @package Gems * @subpackage Project + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @since Class available since version 1.1 */ interface Gems_Project_Tracks_StandAloneSurveysInterface {} \ No newline at end of file Modified: trunk/library/classes/Gems/Project/Tracks/TracksOnlyInterface.php =================================================================== --- trunk/library/classes/Gems/Project/Tracks/TracksOnlyInterface.php 2011-11-14 15:42:16 UTC (rev 212) +++ trunk/library/classes/Gems/Project/Tracks/TracksOnlyInterface.php 2011-11-14 17:51:04 UTC (rev 213) @@ -1,45 +1,52 @@ <?php - -/** - * Copyright (c) 2011, Erasmus MC - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of Erasmus MC nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - /** + * 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 Project + * @author Matijs de Jong <mj...@ma...> + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @version $Id$ + */ + +/** * Marker interface for Pulse Projects NOT allowing the single survey tracks * allowed by Gems_Project_Tracks_StandAloneSurveysInterface (a nd that are just * shells for assinging a single survey). * * @see Gems_Project_Tracks_StandAloneSurveysInterface * - * @author Matijs de Jong <mj...@ma...> - * @since 1.1 - * @version 1.1 - * @package Gems + * @package Gems * @subpackage Project + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @since Class available since version 1.1 */ interface Gems_Project_Tracks_TracksOnlyInterface {} \ No newline at end of file Added: trunk/library/classes/Gems/User/Organization.php =================================================================== --- trunk/library/classes/Gems/User/Organization.php (rev 0) +++ trunk/library/classes/Gems/User/Organization.php 2011-11-14 17:51:04 UTC (rev 213) @@ -0,0 +1,76 @@ +<?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 $ + */ + +/** + * Contains information on the organization of the current User + * + * @see Gems_Useer_User + * + * @package Gems + * @subpackage User + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @since Class available since version 1.5 + */ +class Gems_User_Organization +{ + /** + * + * @var array + */ + protected $_organizationData; + + /** + * Creates the organization object. + * + * @param array $organizationData + */ + public function __construct(array $organizationData) + { + $this->_organizationData = $organizationData; + } + + /** + * Get the style attribute. + * + * @return string + */ + public function getStyle() + { + return $this->_organizationData['gor_style']; + } +} Modified: trunk/library/classes/Gems/User/User.php =================================================================== --- trunk/library/classes/Gems/User/User.php 2011-11-14 15:42:16 UTC (rev 212) +++ trunk/library/classes/Gems/User/User.php 2011-11-14 17:51:04 UTC (rev 213) @@ -32,7 +32,7 @@ * @author Matijs de Jong <mj...@ma...> * @copyright Copyright (c) 2011 Erasmus MC * @license New BSD License - * @version $Id$ + * @version $Id: Sample.php 203 2011-07-07 12:51:32Z matijs $ */ /** @@ -173,6 +173,22 @@ } /** + * Applies any setttings coming from the request object, e.g. processing cookies. + * + * @param Zend_Controller_Request_Abstract $request + * @return Gems_User_User (continuation pattern) + */ + public function applyRequest(Zend_Controller_Request_Abstract $request) + { + // MUtil_Echo::track($this->getOrganizationId(), Gems_Cookies::getOrganization($request)); + if (! $this->getOrganizationId()) { + $this->_setVar('user_organization_id', Gems_Cookies::getOrganization($request)); + } + + return $this; + } + + /** * Return true if a password reset key can be created. * * @return boolean Modified: trunk/library/classes/Gems/User/UserLoader.php =================================================================== --- trunk/library/classes/Gems/User/UserLoader.php 2011-11-14 15:42:16 UTC (rev 212) +++ trunk/library/classes/Gems/User/UserLoader.php 2011-11-14 17:51:04 UTC (rev 213) @@ -55,6 +55,20 @@ const USER_STAFF = 'StaffUser'; /** + * The default organization data for 'no organization'. + * + * @var array + */ + protected static $_noOrganization = array( + 'gor_id_organization' => 1, + 'gor_name' => 'NO ORGANIZATION', + 'gor_code' => null, + 'gor_style' => null, + 'gor_iso_lang' => 'en', + 'gor_active' => 0, + ); + + /** * Allows sub classes of Gems_Loader_LoaderAbstract to specify the subdirectory where to look for. * * @var string $cascade An optional subdirectory where this subclass always loads from. @@ -75,6 +89,12 @@ /** * + * @var Zend_Controller_Request_Abstract + */ + protected $request; + + /** + * * @var Zend_Session_Namespace */ protected $session; @@ -87,6 +107,13 @@ protected static $currentUser; /** + * Session storage of loaded organizations. + * + * @var Zend_Session_Namespace + */ + protected static $organizationStore; + + /** * Checks the password for the specified $login_name and $organization and * handles the login security. * @@ -209,6 +236,49 @@ } /** + * Returns an organization object, initiated from the database or from + * self::$_noOrganization when the database does not yet exist. + * + * @param int $organizationId Optional, uses current user when empty + * @return Gems_User_Organization + */ + public function getOrganization($organizationId = null) + { + if (! self::$organizationStore) { + self::$organizationStore = new Zend_Session_Namespace('gems.' . GEMS_PROJECT_NAME . '.organizations'); + } + + if (null === $organizationId) { + $organizationId = intval(self::$currentUser->getOrganizationId()); + } + + if (! self::$organizationStore->__isset($organizationId)) { + + // We are not sure the is a database at this moment + try { + $data = $this->db->fetchRow('SELECT * FROM gems__organizations WHERE gor_id_organization = ? LIMIT 1', $organizationId); + } catch (Zend_Db_Exception $e) { + $data = false; + } + if (! $data) { + // Use default + $data = self::$_noOrganization; + + // But do attempt to get the last added organization. + foreach (self::$organizationStore->getIterator() as $key => $value) { + if ($key !== 0) { + $organizationId = $key; + $data = self::$organizationStore->__get($key); + } + } + } + self::$organizationStore->__set($organizationId, $data); + } + + return new Gems_User_Organization(self::$organizationStore->__get($organizationId)); + } + + /** * Returns a user object, that may be empty if no user exist. * * @param string $login_name @@ -262,7 +332,9 @@ */ protected function getUserClassName($login_name, $organization) { - if (is_null($login_name) && is_null($organization)) return 'NoLoginDefinition'; + if ((null == $login_name) || (null == $organization)) { + return 'NoLoginDefinition'; + } if ($this->isProjectUser($login_name)) { return 'ProjectUserDefinition'; } Modified: trunk/library/classes/GemsEscort.php =================================================================== --- trunk/library/classes/GemsEscort.php 2011-11-14 15:42:16 UTC (rev 212) +++ trunk/library/classes/GemsEscort.php 2011-11-14 17:51:04 UTC (rev 213) @@ -89,7 +89,7 @@ $firebug = $application->getOption('firebug'); $this->_startFirebird = $firebug['log']; - + Zend_Session::start( array( 'name' => GEMS_PROJECT_NAME_UC . 'SESSID', @@ -1064,21 +1064,7 @@ */ public function getCurrentOrganization() { - /* - if ($this instanceof Gems_Project_Organization_MultiOrganizationInterface) { - return $this->getUserOrganization(); - } - - if ($this instanceof Gems_Project_Organization_SingleOrganizationInterface) { - return $this->getRespondentOrganization(); - } - */ - - if (isset($this->session->user_organization_id)) { - return $this->session->user_organization_id; - } else { - return Gems_Cookies::getOrganization(Zend_Controller_Front::getInstance()->getRequest()); - } + return $this->getLoader()->getCurrentUser()->getOrganizationId(); } /** @@ -1357,7 +1343,7 @@ public function prepareController() { if ($this instanceof Gems_Project_Layout_MultiLayoutInterface) { - $this->layoutSwitch($this->request, $this->session); + $this->layoutSwitch($this->request); } } @@ -1448,7 +1434,8 @@ public function routeShutdown(Zend_Controller_Request_Abstract $request) { $loader = $this->getLoader(); - $user = $loader->getCurrentUser(); + $user = $loader->getCurrentUser() + ->applyRequest($request); // MUtil_Echo::r($request->getParams(), 'params'); // MUtil_Echo::r($request->getUserParams(), 'userparams'); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2011-11-14 15:42:22
|
Revision: 212 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=212&view=rev Author: mennodekker Date: 2011-11-14 15:42:16 +0000 (Mon, 14 Nov 2011) Log Message: ----------- Fixing some flaws in #31: remember last organization restored, nologin selected more efficient and bypassing security by checking through gems_user_user Modified Paths: -------------- trunk/library/classes/Gems/User/NoLoginDefinition.php trunk/library/classes/Gems/User/User.php trunk/library/classes/Gems/User/UserLoader.php Modified: trunk/library/classes/Gems/User/NoLoginDefinition.php =================================================================== --- trunk/library/classes/Gems/User/NoLoginDefinition.php 2011-11-14 13:01:31 UTC (rev 211) +++ trunk/library/classes/Gems/User/NoLoginDefinition.php 2011-11-14 15:42:16 UTC (rev 212) @@ -71,7 +71,7 @@ return array( 'user_active' => false, 'user_role' => 'nologin', - 'user_organization_id' => 0, + //'user_organization_id' => 0, //REMOVED AS IT BREAKS STORING LAST ORGANIZATION ); } } Modified: trunk/library/classes/Gems/User/User.php =================================================================== --- trunk/library/classes/Gems/User/User.php 2011-11-14 13:01:31 UTC (rev 211) +++ trunk/library/classes/Gems/User/User.php 2011-11-14 15:42:16 UTC (rev 212) @@ -200,7 +200,7 @@ */ public function checkPassword($password) { - return $this->definition->checkPassword($this->getLoginName(), $this->getOrganizationId(), $password); + return $this->userLoader->checkPassword($this->getLoginName(), $this->getOrganizationId(), $password); } /** Modified: trunk/library/classes/Gems/User/UserLoader.php =================================================================== --- trunk/library/classes/Gems/User/UserLoader.php 2011-11-14 13:01:31 UTC (rev 211) +++ trunk/library/classes/Gems/User/UserLoader.php 2011-11-14 15:42:16 UTC (rev 212) @@ -262,6 +262,7 @@ */ protected function getUserClassName($login_name, $organization) { + if (is_null($login_name) && is_null($organization)) return 'NoLoginDefinition'; if ($this->isProjectUser($login_name)) { return 'ProjectUserDefinition'; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2011-11-14 13:01:40
|
Revision: 211 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=211&view=rev Author: matijsdejong Date: 2011-11-14 13:01:31 +0000 (Mon, 14 Nov 2011) Log Message: ----------- Reintegrated Added Paths: ----------- branches/merged/newUser2/ Removed Paths: ------------- branches/newUser2/ Property changes on: branches/merged/newUser2 ___________________________________________________________________ Added: svn:mergeinfo + /branches/newUser:113-150 /trunk/library:176-190,192-195 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2011-11-14 13:00:47
|
Revision: 210 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=210&view=rev Author: matijsdejong Date: 2011-11-14 13:00:40 +0000 (Mon, 14 Nov 2011) Log Message: ----------- No longer in use Added Paths: ----------- branches/merged/newUser/ Removed Paths: ------------- branches/newUser/ Property changes on: branches/merged/newUser ___________________________________________________________________ Added: svn:mergeinfo + /trunk/library:114-122,125-139,142-144,147 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2011-11-14 12:59:31
|
Revision: 209 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=209&view=rev Author: matijsdejong Date: 2011-11-14 12:59:25 +0000 (Mon, 14 Nov 2011) Log Message: ----------- Branches in this folder are no longer developed. Added Paths: ----------- branches/merged/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2011-11-14 12:53:59
|
Revision: 208 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=208&view=rev Author: matijsdejong Date: 2011-11-14 12:53:50 +0000 (Mon, 14 Nov 2011) Log Message: ----------- Reintegration of newUser2 branch for #31 - note: gems__users is no longer used. Modified Paths: -------------- trunk/library/changelog.txt trunk/library/classes/Gems/Auth.php trunk/library/classes/Gems/Cookies.php trunk/library/classes/Gems/Default/AskAction.php trunk/library/classes/Gems/Default/CronAction.php trunk/library/classes/Gems/Default/ExportAction.php trunk/library/classes/Gems/Default/IndexAction.php trunk/library/classes/Gems/Default/OptionAction.php trunk/library/classes/Gems/Default/OrganizationAction.php trunk/library/classes/Gems/Default/RespondentAction.php trunk/library/classes/Gems/Default/StaffAction.php trunk/library/classes/Gems/Default/SurveyMaintenanceAction.php trunk/library/classes/Gems/Default/TokenPlanAction.php trunk/library/classes/Gems/Email/TemplateMailer.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/Model/DbaModel.php trunk/library/classes/Gems/Model.php trunk/library/classes/Gems/Project/Organization/MultiOrganizationInterface.php trunk/library/classes/Gems/Project/ProjectSettings.php trunk/library/classes/Gems/Tracker/Token.php trunk/library/classes/Gems/User/UserLoader.php trunk/library/classes/Gems/Util/DbLookup.php trunk/library/classes/GemsEscort.php trunk/library/classes/MUtil/Date.php trunk/library/classes/MUtil/Model/DatabaseModelAbstract.php trunk/library/classes/MUtil/Model/FormBridge.php trunk/library/classes/MUtil/Model/JoinModel.php trunk/library/classes/MUtil/Registry/Source.php trunk/library/configs/db/patches.sql trunk/library/configs/db/tables/gems__organizations.20.sql trunk/library/configs/db/tables/gems__staff.20.sql trunk/library/configs/db/tables/gems__user_ids.10.sql trunk/library/configs/db/tables/gems__user_logins.10.sql trunk/library/configs/db/tables/gems__user_passwords.50.sql Added Paths: ----------- trunk/library/classes/Gems/User/LoginPasswordValidator.php trunk/library/classes/Gems/User/NoLoginDefinition.php trunk/library/classes/Gems/User/OldStaffUserDefinition.php trunk/library/classes/Gems/User/ProjectUserDefinition.php trunk/library/classes/Gems/User/StaffUserDefinition.php trunk/library/classes/Gems/User/User.php trunk/library/classes/Gems/User/UserDefinitionAbstract.php trunk/library/classes/Gems/User/UserDefinitionInterface.php trunk/library/classes/Gems/User/UserPasswordValidator.php trunk/library/configs/db/tables/gems__user_login_attempts.10.sql Removed Paths: ------------- trunk/library/classes/Gems/Model/UserModel.php 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/Validate/GemsPasswordUsername.php trunk/library/configs/db/tables/gems__users.10.sql trunk/library/configs/db_multi_layout/ Property Changed: ---------------- trunk/library/ Property changes on: trunk/library ___________________________________________________________________ Modified: svn:mergeinfo - /branches/newUser:113-150 + /branches/newUser:113-150 /branches/newUser2:175-207 Modified: trunk/library/changelog.txt =================================================================== --- trunk/library/changelog.txt 2011-11-14 12:43:05 UTC (rev 207) +++ trunk/library/changelog.txt 2011-11-14 12:53:50 UTC (rev 208) @@ -1,7 +1,8 @@ Important changes from 1.4.3 => 1.5 ============================================================ Passwords should be set with a project.ini->salt. Salt is now a required project setting! -The table gems__staff is split into gems__staff and gems__user with all login data in gems__users. +The table gems__staff is split into gems__staff, gems__user_logins with generic login data and gems__users_passwords containing db stored password information. +The table gems__user_ids provides unique and non-sequential user ids accross gems__staff and gems__respondents. The gems__respondent.grs_bsn has been renamed to grs_ssn, to make the code more international. 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-11-14 12:43:05 UTC (rev 207) +++ trunk/library/classes/Gems/Auth.php 2011-11-14 12:53:50 UTC (rev 208) @@ -98,8 +98,8 @@ * Lookup last failed login and number of failed logins */ try { - $sql = "SELECT gsu_failed_logins, UNIX_TIMESTAMP(gsu_last_failed) - AS gsu_last_failed FROM gems__users WHERE gsu_login = ?"; + $sql = "SELECT gul_failed_logins, UNIX_TIMESTAMP(gul_last_failed) AS gul_last_failed + FROM gems__user_logins WHERE gul_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['gsu_failed_logins'], $this->_delayFactor); - $remaining = ($results['gsu_last_failed'] + $delay) - time(); + $delay = pow($results['gul_failed_logins'], $this->_delayFactor); + $remaining = ($results['gul_last_failed'] + $delay) - time(); - if ($results['gsu_failed_logins'] > 0 && $remaining > 0) { + if ($results['gul_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-11-14 12:43:05 UTC (rev 207) +++ trunk/library/classes/Gems/Cookies.php 2011-11-14 12:53:50 UTC (rev 208) @@ -26,6 +26,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * + * * @package Gems * @subpackage Cookies * @author Matijs de Jong <mj...@ma...> @@ -73,14 +74,14 @@ } /** - * Get the organization from the cookie. + * Get the current organization from the cookie. * * @param Zend_Controller_Request_Abstract $request - * @return int The organization + * @return int The current organization */ public static function getOrganization(Zend_Controller_Request_Abstract $request) { - return self::get($request, self::ORGANIZATION_COOKIE); + return intval(self::get($request, self::ORGANIZATION_COOKIE)); } /** @@ -120,13 +121,15 @@ /** * Store the organization in a cookie. * - * @param int $locale Organization to store + * @param int $organization Organization to store * @param string $basepath The folder of the domain, if any. * @return boolean True if the cookie was stored. */ - public static function setOrganization($locale, $basepath = '/') + public static function setOrganization($organization, $basepath = '/') { - // Set the cookie for 30 days - return self::set(self::ORGANIZATION_COOKIE, $locale, 30, $basepath); + if ($organization) { + // Set the cookie for 30 days + return self::set(self::ORGANIZATION_COOKIE, $organization, 30, $basepath); + } } } Modified: trunk/library/classes/Gems/Default/AskAction.php =================================================================== --- trunk/library/classes/Gems/Default/AskAction.php 2011-11-14 12:43:05 UTC (rev 207) +++ trunk/library/classes/Gems/Default/AskAction.php 2011-11-14 12:53:50 UTC (rev 208) @@ -82,13 +82,14 @@ /*************** * Get the url * ***************/ - $url = $token->getUrl($language, $this->session->user_id ? $this->session->user_id : $respId); + $user = $this->loader->getCurrentUser(); + $url = $token->getUrl($language, $user->getUserId() ? $user->getUserId() : $respId); /************************ * Optional user logout * ************************/ - if (isset($this->session->user_logout) && $this->session->user_logout) { - $this->escort->afterLogout(); + if ($user->isLogoutOnSurvey()) { + $user->unsetAsCurrentUser(); } /*********************************** Modified: trunk/library/classes/Gems/Default/CronAction.php =================================================================== --- trunk/library/classes/Gems/Default/CronAction.php 2011-11-14 12:43:05 UTC (rev 207) +++ trunk/library/classes/Gems/Default/CronAction.php 2011-11-14 12:53:50 UTC (rev 208) @@ -26,17 +26,23 @@ * (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 + * + * @author Michiel Rook <mi...@to...> + * @package Gems * @subpackage Default + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @version $Id$ */ /** * Performs bulk-mail action, can be called from a cronjob * - * @author Michiel Rook <mi...@to...> - * @package Gems + * @package Gems * @subpackage Default + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @since Class available since version 1.4 */ class Gems_Default_CronAction extends MUtil_Controller_Action { @@ -69,6 +75,12 @@ /** * + * @var Gems_Loader + */ + public $loader; + + /** + * * @var Gems_Menu */ public $menu; @@ -125,7 +137,7 @@ */ protected function getUserLogin($userId) { - return $this->db->fetchOne("SELECT gsu_login FROM gems__users WHERE gsu_id_user = ?", $userId); + return $this->db->fetchOne("SELECT gsf_login FROM gems__staff WHERE gsf_id_user = ?", $userId); } public function indexAction() @@ -141,112 +153,78 @@ public function mailJob() { - // Test: update `gems__tokens` set `gto_mail_sent_date` = null where `gto_mail_sent_date` > '2011-10-23' + $userLoader = $this->loader->getUserLoader(); + $startUser = $userLoader->getCurrentUser(); + $user = $startUser; - $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 ($user->getUserId() != $job['gmj_id_user_as']) { + $user = $userLoader->getUserByStaffId($job['gmj_id_user_as']); } - 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 ($user->isActive()) { + if (! $user->isCurrentUser()) { + $user->setAsCurrentUser(); + } - if (count($tokensData)) { - $mailer->setMethod($job['gmj_process_method']); - if ($job['gmj_from_method'] == 'F') { - $mailer->setFrom($job['gmj_from_fixed']); + // 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 { - $mailer->setFrom($job['gmj_from_method']); + $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']; + } - $templateData = $this->getTemplate($job['gmj_id_message']); - $mailer->setSubject($templateData['gmt_subject']); - $mailer->setBody($templateData['gmt_body']); + $tokensData = $model->load($filter); - $mailer->setTokens(MUtil_Ra::column('gto_id_token', $tokensData)); - $mailer->process($tokensData); - } + 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']); + } - Gems_Auth::getInstance()->clearIdentity(); - $this->escort->session->unsetAll(); + $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); + } + } } } $msg = $mailer->getMessages(); if (! $msg) { - $msg[] = $this->_('No mails sent'); + $msg[] = $this->_('No mails sent.'); } - - $this->html->append($msg); - - if ($currentUser) { - $this->escort->loadLoginInfo($currentUser); - } else { - $this->escort->afterLogout(); + if ($mailer->bounceCheck()) { + array_unshift($msg, $this->_('On this test system all mail will be delivered to the from address.')); } - /* - if (isset($this->project->email['automatic'])) { - $batches = $this->project->email['automatic']; - $numBatches = count($batches['mode']); + $this->addMessage($msg); - 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(); - } + if (! $startUser->isCurrentUser()) { + $startUser->setAsCurrentUser(); } - // */ } } \ No newline at end of file Modified: trunk/library/classes/Gems/Default/ExportAction.php =================================================================== --- trunk/library/classes/Gems/Default/ExportAction.php 2011-11-14 12:43:05 UTC (rev 207) +++ trunk/library/classes/Gems/Default/ExportAction.php 2011-11-14 12:53:50 UTC (rev 208) @@ -144,7 +144,7 @@ { //Read some data from tables, initialize defaults... $surveys = $this->db->fetchPairs('SELECT gsu_id_survey, gsu_survey_name FROM gems__surveys WHERE gsu_active = 1 ORDER BY gsu_survey_name'); - $organizations = $this->escort->getAllowedOrganizations(); + $organizations = $this->loader->getCurrentUser()->getAllowedOrganizations(); $types = $this->export->getExportClasses(); //Create the basic form @@ -230,7 +230,7 @@ $answerModel = $survey->getAnswerModel($language); //Now add the organization id => name mapping - $answerModel->set('organizationid', 'multiOptions', $this->escort->getAllowedOrganizations()); + $answerModel->set('organizationid', 'multiOptions', $this->loader->getCurrentUser()->getAllowedOrganizations()); if (count($answers) === 0) { $answers[0] = array('' => sprintf($this->_('No %s found.'), $this->getTopic(0))); Modified: trunk/library/classes/Gems/Default/IndexAction.php =================================================================== --- trunk/library/classes/Gems/Default/IndexAction.php 2011-11-14 12:43:05 UTC (rev 207) +++ trunk/library/classes/Gems/Default/IndexAction.php 2011-11-14 12:53:50 UTC (rev 208) @@ -66,37 +66,94 @@ public $menu; /** - * Extension point, use different auth adapter if needed depending on the provided formValues + * @var Gems_Project_ProjectSettings + */ + public $project; + + /** + * Returns a link for the token input page. * - * This could be an organization passed in the login-form or something else. + * @return MUtil_Form_Element_Html + */ + protected function _getAskTokenLinkElement() + { + // Veld token + $element = new MUtil_Form_Element_Html('askToken'); + $element->br(); + $element->actionLink(array('controller' => 'ask', 'action' => 'token'), $this->_('Enter your token...')); + + return $element; + } + + /** + * Returns a basic form for this action. * - * @param array $formValues - * @return Zend_Auth_Adapter_Interface + * @param $description Optional description, %s is filled with project name. + * @return Gems_Form */ - protected function _getAuthAdapter($formValues) { - $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; + protected function _getBasicForm($description = null) + { + Gems_Html::init(); + + $form = new Gems_Form(array('labelWidthFactor' => $this->labelWidthFactor)); + $form->setMethod('post'); + if ($description) { + $form->setDescription(sprintf($description, $this->project->getName())); + } + + return $form; } /** - * New version of login form + * Returns an element for keeping a reset key. * + * @return Zend_Form_Element_Hidden + */ + protected function _getKeyElement() + { + return new Zend_Form_Element_Hidden('key'); + } + + /** + * Returns a login form + * * @return Gems_Form */ protected function _getLoginForm() { - Gems_Html::init(); + $form = $this->_getBasicForm($this->_('Login to %s application')); + $form->addElement($this->_getOrganizationElement()); + $form->addElement($this->_getUserLoginElement()); + $form->addElement($this->_getPasswordElement()); + $form->addElement($this->_getSubmitButton($this->_('Login'))); + $form->addElement($this->_getAskTokenLinkElement()); + $form->addElement($this->_getResetLinkElement()); - $this->track[] = 'Get login form.'; + return $form; + } - $delayFactor = (isset($this->project->account) && isset($this->project->account['delayFactor']) ? $this->project->account['delayFactor'] : null); + /** + * Returns a link to the login page + * + * @return MUtil_Form_Element_Html + */ + protected function _getLoginLinkElement() + { + // Reset password + $element = new MUtil_Form_Element_Html('resetPassword'); + $element->br(); + $element->actionLink(array('controller' => 'index', 'action' => 'login'), $this->_('Back to login')); - $form = new Gems_Form(array('labelWidthFactor' => $this->labelWidthFactor)); - $form->setMethod('post'); - $form->setDescription(sprintf($this->_('Login to %s application'), $this->project->name)); + return $element; + } + /** + * Returns an element for determining / selecting the organization. + * + * @return Zend_Form_Element_Xhtml + */ + protected function _getOrganizationElement() + { if ($this->escort instanceof Gems_Project_Organization_SingleOrganizationInterface) { $element = new Zend_Form_Element_Hidden('organization'); $element->setValue($this->escort->getRespondentOrganization()); @@ -110,56 +167,106 @@ $element->setValue($this->escort->getCurrentOrganization()); } } - $form->addElement($element); - // Veld inlognaam - $element = new Zend_Form_Element_Text('userlogin'); - $element->setLabel($this->_('Username')); - $element->setAttrib('size', 10); - $element->setAttrib('maxlength', 20); - $element->setRequired(true); - $form->addElement($element); + return $element; + } + /** + * Returns a password element. + * + * @return Zend_Form_Element_Password + */ + protected function _getPasswordElement() + { // Veld password $element = new Zend_Form_Element_Password('password'); $element->setLabel($this->_('Password')); $element->setAttrib('size', 10); $element->setAttrib('maxlength', 20); $element->setRequired(true); - //$element->addValidator(new Gems_Validate_GemsPasswordUsername('userlogin', 'password', $this->db, $delayFactor)); - $form->addElement($element); + $element->addValidator(new Gems_User_LoginPasswordValidator($this->loader->getUserLoader(), 'userlogin', 'organization', $this->translate)); - // Submit knop - $element = new Zend_Form_Element_Submit('button'); - $element->setLabel($this->_('Login')); - $element->setAttrib('class', 'button'); - $form->addElement($element); + return $element; + } - // Veld token - $element = new MUtil_Form_Element_Html('askToken'); - $element->br(); - $element->actionLink(array('controller' => 'ask', 'action' => 'token'), $this->_('Enter your token...')); - $form->addElement($element); + /** + * Gets a reset password form. + * + * @return Gems_Form + */ + protected function _getResetForm() + { + $form = $this->_getBasicForm($this->_('Reset password for %s application')); + $form->addElement($this->_getKeyElement()); + $form->addElement($this->_getOrganizationElement()); + $form->addElement($this->_getUserLoginElement()); + $form->addElement($this->_getSubmitButton($this->_('Reset password'))); + $form->addElement($this->_getLoginLinkElement()); + return $form; + } + + /** + * Returns a link to the reset password page + * + * @return MUtil_Form_Element_Html + */ + protected function _getResetLinkElement() + { // Reset password $element = new MUtil_Form_Element_Html('resetPassword'); $element->br(); $element->actionLink(array('controller' => 'index', 'action' => 'resetpassword'), $this->_('Lost password')); - $form->addElement($element); - return $form; + return $element; } - // Dummy: always rerouted by GemsEscort + /** + * Returns a submit button. + * + * @param string $label + * @return Zend_Form_Element_Submit + */ + protected function _getSubmitButton($label) + { + // Submit knop + $element = new Zend_Form_Element_Submit('button'); + $element->setLabel($label); + $element->setAttrib('class', 'button'); + + return $element; + } + + /** + * Returns a login name element. + * + * @return Zend_Form_Element_Text + */ + protected function _getUserLoginElement() + { + // Veld inlognaam + $element = new Zend_Form_Element_Text('userlogin'); + $element->setLabel($this->_('Username')); + $element->setAttrib('size', 10); + $element->setAttrib('maxlength', 20); + $element->setRequired(true); + + return $element; + } + + /** + * Dummy: always rerouted by GemsEscort + */ public function indexAction() { } + /** + * Default login page + */ 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)) { + // 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 ($this->loader->getCurrentUser()->isActive()) { if ($menuItem = $this->menu->findFirst(array('allowed' => true, 'visible' => true))) { $redirector = Zend_Controller_Action_HelperBroker::getStaticHelper('redirector'); $redirector->gotoRoute($menuItem->toRouteUrl($this->getRequest())); @@ -167,87 +274,33 @@ $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'])) { + $request = $this->getRequest(); + if ($request->isPost()) { + if ($form->isValid($request->getPost(), false)) { - } // */ + $user = $this->loader->getUser($request->getParam('userlogin'), $request->getParam('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']; - $this->session->user_group = 800; - $this->session->user_role = 'master'; - $this->session->user_organization_id = 70; - $this->session->user_organization_name = 'SUPER ADMIN'; - $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); + if ($user->isActive()) { + $user->setAsCurrentUser(); /** - * Ready + * Fix current locale / organization in cookies */ - $this->addMessage(sprintf($this->_('Login successful, welcome %s.'), $this->session->user_name)); - $this->_reroute(array('controller' => 'database', 'action' => 'index'), true); - return; - } - //Now check authentication - $adapter = $this->_getAuthAdapter($form->getValues()); - $auth = Gems_Auth::getInstance(); - $result = $auth->authenticate($adapter, $_POST['userlogin']); + Gems_Cookies::setLocale($user->getLocale(), $this->basepath->getBasePath()); + Gems_Cookies::setOrganization($user->getOrganizationId(), $this->basepath->getBasePath()); - // 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(); - $this->addMessage($errors); - $code = $result->getCode(); - if ($code != Gems_Auth::ERROR_PASSWORD_DELAY) { - $this->escort->afterFailedLogin(); - } - - $this->view->form = $form; - } else { - // Load login data - $this->escort->loadLoginInfo($_POST['userlogin']); - /** - * Perform any project specific post login activities - */ - $this->escort->afterLogin($_POST['userlogin']); - - /** - * Fix current locale & organization - */ - Gems_Cookies::setLocale($this->session->user_locale, $this->basepath->getBasePath()); - Gems_Cookies::setOrganization($this->session->user_organization_id, $this->basepath->getBasePath()); - - /** * Ready */ - $this->addMessage(sprintf($this->_('Login successful, welcome %s.'), $this->session->user_name)); + $this->addMessage(sprintf($this->_('Login successful, welcome %s.'), $user->getFullName())); /** * Log the login */ - Gems_AccessLog::getLog($this->db)->log("index.login", $this->getRequest(), null, $this->session->user_id, true); + Gems_AccessLog::getLog($this->db)->log("index.login", $this->getRequest(), null, $user->getUserId(), true); if ($previousRequestParameters = $this->session->previousRequestParameters) { $this->_reroute(array('controller' => $previousRequestParameters['controller'], 'action' => $previousRequestParameters['action']), false); @@ -255,116 +308,87 @@ // This reroutes to the first available menu page after login $this->_reroute(array('controller' => null, 'action' => null), true); } + return; } } else { $errors = $form->getErrors(); - - $this->view->form = $form; } - } else { - $this->view->form = $form; } + $this->view->form = $form; } + /** + * Default logoff action + */ public function logoffAction() { - $this->addMessage($this->_('Good bye: ') . $this->session->user_name); - Gems_Auth::getInstance()->clearIdentity(); - $this->escort->afterLogout(); + $user = $this->loader->getCurrentUser(); + + $this->addMessage(sprintf($this->_('Good bye: %s.'), $user->getFullName())); + $user->unsetAsCurrentUser(); $this->_reroute(array('action' => 'index'), true); } - protected function _getResetForm() - { - $form = new Gems_Form(array('labelWidthFactor' => $this->labelWidthFactor)); - $form->setMethod('post'); - $form->setDescription(sprintf($this->_('Reset password for %s application'), $this->project->name)); - - // Veld inlognaam - $element = new Zend_Form_Element_Text('userlogin'); - $element->setLabel($this->_('Username')); - $element->setAttrib('size', 10); - $element->setAttrib('maxlength', 20); - $element->setRequired(true); - $form->addElement($element); - - // Submit knop - $element = new Zend_Form_Element_Submit('button'); - $element->setLabel($this->_('Reset password')); - $element->setAttrib('class', 'button'); - $form->addElement($element); - - return $form; - } - + /** + * Reset password page. + */ public function resetpasswordAction() { $this->view->setScriptPath(GEMS_LIBRARY_DIR . '/views/scripts' ); + $request = $this->getRequest(); $form = $this->_getResetForm(); - $mail = new MUtil_Mail(); - $mail->setFrom('no...@er...'); + if ($request->isPost() && $form->isValid($request->getPost())) { - if (isset($this->escort->project->email) && isset($this->escort->project->email['bcc'])) { - $mail->addBcc($this->escort->project->email['bcc']); - } + $user = $this->loader->getUser($request->getParam('userlogin'), $request->getParam('organization')); - if ($this->_request->isPost() && $form->isValid($_POST)) { - $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 ($user->canResetPassword()) { + if ($key = $request->getParam('key')) { + // Key has been passed by mail + if ($user->checkPasswordResetKey($key)) { + $user->setPasswordResetRequired(true); + $user->setAsCurrentUser(); + $this->addMessage($this->_('Reset accepted, enter your new password.')); + $user->gotoStartPage($this->menu, $request); + return; + } else { + $this->addMessage($this->_('This key timed out or does not belong to this user.')); + } + } else { + // P{ass mail by key + $mail = new MUtil_Mail(); + $mail->setFrom('mj...@ma...'); + $mail->addTo($user->getEmailAddress(), $user->getFullName()); - if (empty($result) || empty($result['gsf_email'])) { - $this->addMessage($this->_('No such user found or no e-mail address known')); - } 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); + if (isset($this->escort->project->email) && isset($this->escort->project->email['bcc'])) { + $mail->addBcc($this->escort->project->email['bcc']); + } - $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); + $key = $user->getPasswordResetKey(); - $mail->addTo($email); + $url = $this->util->getCurrentURI('index/resetpassword/key/' . $key); - try { - $mail->send(); - $this->addMessage($this->_('Follow the instructions in the e-mail')); - } catch (Exception $e) { - $this->addMessage($this->_('Unable to send e-mail')); - throw $e; - } - } - } else if ($key = $this->_request->getParam('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); + $mail->setSubject($this->_('Password reset requested')); + $mail->setBodyText(sprintf($this->_('To reset your password for %s, please click this link: %s'), GEMS_PROJECT_NAME_UC, $url)); - if (!empty($result)) { - // generate new password - $password = $this->escort->getRandomPassword(); - $passwordHash = $this->escort->passwordHash(null, $password, false); - $mail->setSubject('New password'); - $mail->setBodyText('Your new password has been generated. Your new password is: ' . $password); - - $mail->addTo($result['gsf_email']); - - try { - $mail->send(); - $this->addMessage($this->_('An e-mail was sent containing your new password')); - $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')); - throw $e; + try { + $mail->send(); + $this->addMessage($this->_('We sent you an e-mail with a reset link. Click on the link in the e-mail.')); + } catch (Exception $e) { + $this->addMessage($this->_('Unable to send e-mail.')); + throw $e; + } } } else { - $this->addMessage($this->_('Unknown request')); + $this->addMessage($this->_('No such user found or no e-mail address known or user cannot be reset.')); } } - + if ($request->getParam('key')) { + $this->addMessage($this->_('We received your password reset key.')); + $this->addMessage($this->_('Please enter the organization and username belonging to this key.')); + } $this->view->form = $form; } } Modified: trunk/library/classes/Gems/Default/OptionAction.php =================================================================== --- trunk/library/classes/Gems/Default/OptionAction.php 2011-11-14 12:43:05 UTC (rev 207) +++ trunk/library/classes/Gems/Default/OptionAction.php 2011-11-14 12:53:50 UTC (rev 208) @@ -1,6 +1,5 @@ <?php - /** * Copyright (c) 2011, Erasmus MC * All rights reserved. @@ -26,60 +25,52 @@ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** * - * @author Matijs de Jong - * @since 1.0 - * @version 1.1 - * @package Gems + * + * @package Gems * @subpackage Default + * @author Matijs de Jong <mj...@ma...> + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @version $Id$ */ /** * - * @author Matijs de Jong - * @package Gems + * @package Gems * @subpackage Default + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @since Class available since version 1.1 */ class Gems_Default_OptionAction extends Gems_Controller_BrowseEditAction { public $autoFilter = 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 - * having to recode the core table building code. - * - * @param MUtil_Model_FormBridge $bridge - * @param MUtil_Model_ModelAbstract $model - * @param array $data The data that will later be loaded into the form - * @param optional boolean $new Form should be for a new element - * @return void|array When an array of new values is return, these are used to update the $data array in the calling function + * @var Gems_Project_ProjectSettings */ - 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('gsu_login', array('size' => 15, 'minlength' => 4)); - $bridge->addText( 'gsf_first_name'); - $bridge->addText( 'gsf_surname_prefix'); - $bridge->addText( 'gsf_last_name'); - $bridge->addText( 'gsf_email', array('size' => 30)); + public $project; - $bridge->addRadio( 'gsf_gender', 'separator', ''); - - $bridge->addSelect( 'gsf_iso_lang', array('label' => $this->_('Language'), 'multiOptions' => $this->util->getLocalized()->getLanguages())); - } - + /** + * Hook to perform action after a record (with changes) was saved + * + * As the data was already saved, it can NOT be changed anymore + * + * @param array $data + * @param boolean $isNew + * @return boolean True when you want to display the default 'saved' messages + */ public function afterSave(array $data, $isNew) { - $this->escort->loadLoginInfo($data['gsu_login']); + // Reload the current user data + $this->loader->getUser($data['gsf_login'], $data['gsf_id_organization']); } + /** + * Allow a user to change his / her password. + */ public function changePasswordAction() { /************* @@ -87,20 +78,31 @@ *************/ $form = $this->createForm(); - $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 + $user = $this->loader->getCurrentUser(); + + if (! $user->canSetPassword()) { + $this->addMessage($this->_('You are not allowed to change your password.')); + return; + } + + if ($user->isPasswordResetRequired()) { + $this->menu->setVisible(false); + } elseif ($user->hasPassword()) { + // Field current password + // + // This is only used when the password is already set, which may not always be the case + // e.g. when using embedded login in Pulse. $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)); + $element->addValidator(new Gems_User_UserPasswordValidator($user, $this->translate)); $form->addElement($element); } - // Veld new password + // Field new password $element = new Zend_Form_Element_Password('new_password'); $element->setLabel($this->_('New password')); $element->setAttrib('size', 10); @@ -111,7 +113,7 @@ $element->addValidator(new MUtil_Validate_IsConfirmed('repeat_password', $this->_('Repeat password'))); $form->addElement($element); - // Veld repeat password + // Field repeat password $element = new Zend_Form_Element_Password('repeat_password'); $element->setLabel($this->_('Repeat password')); $element->setAttrib('size', 10); @@ -130,21 +132,10 @@ * Process form * ****************/ if ($this->_request->isPost() && $form->isValid($_POST)) { + $user->setPassword($_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); - - // $data = $_POST; - // $data['name'] = ''; - // $data['type'] = $this->_('raw'); - - // $results = array(); - // $this->_runScript($data, $results); $this->addMessage($this->_('New password is active.')); - $this->afterSaveRoute($this->getRequest()); + $this->_reroute(array($this->getRequest()->getActionKey() => 'edit')); } else { if (isset($_POST['old_password'])) { @@ -162,7 +153,7 @@ $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()) { + if (! $user->isPasswordResetRequired() && ($links = $this->createMenuLinks())) { $table->tf(); // Add empty cell, no label $linksCell = $table->tf($links); } @@ -185,23 +176,23 @@ */ public function createModel($detailed, $action) { - $model = new Gems_Model_UserModel('staff', 'gems__staff', array('gsu_id_user' => 'gsf_id_user'), 'gsf'); - $model->copyKeys(); + $model = $this->loader->getModels()->getStaffModel(); - $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...'); - $model->set('gsf_last_name', 'label', $this->_('Last name'), 'required', true); + $model->set('gsf_login', 'label', $this->_('Login Name'), 'elementClass', 'Exhibitor'); + $model->set('gsf_email', 'label', $this->_('E-Mail'), 'size', 30); + $model->set('gsf_first_name', 'label', $this->_('First name')); + $model->set('gsf_surname_prefix', 'label', $this->_('Surname prefix'), 'description', 'de, van der, \'t, etc...'); + $model->set('gsf_last_name', 'label', $this->_('Last name'), 'required', true); + $model->set('gsf_gender', 'label', $this->_('Gender'), 'multiOptions', $this->util->getTranslated()->getGenders(), + 'elementClass', 'Radio', 'separator', ''); + $model->set('gsf_iso_lang', 'label', $this->_('Language'), 'multiOptions', $this->util->getLocalized()->getLanguages()); - $model->set('gsf_gender', 'label', $this->_('Gender'), 'multiOptions', $this->util->getTranslated()->getGenders()); - return $model; } public function editAction() { - $this->getModel()->setFilter(array('gsu_id_user' => $this->session->user_id)); + $this->getModel()->setFilter(array('gsf_id_user' => $this->loader->getCurrentUser()->getUserId())); if ($form = $this->processForm()) { $this->html->h3(sprintf($this->_('Options'), $this->getTopic())); @@ -222,7 +213,7 @@ WHERE glac.glac_name = 'index.login' ORDER BY glua.glua_created DESC LIMIT 10"; - $activity = $this->db->fetchAll($sql, $this->session->user_id); + $activity = $this->db->fetchAll($sql, $this->loader->getCurrentUser()->getUserId()); foreach (array_keys($activity) as $key) { $date = new MUtil_Date($activity[$key]['glua_created']); Modified: trunk/library/classes/Gems/Default/OrganizationAction.php =================================================================== --- trunk/library/classes/Gems/Default/OrganizationAction.php 2011-11-14 12:43:05 UTC (rev 207) +++ trunk/library/classes/Gems/Default/OrganizationAction.php 2011-11-14 12:53:50 UTC (rev 208) @@ -50,7 +50,7 @@ $url = base64_decode($request->getParam('current_uri')); $oldOrgId = $this->session->user_organization_id; - $allowedOrganizations = $this->escort->getAllowedOrganizations(); + $allowedOrganizations = $this->loader->getCurrentUser()->getAllowedOrganizations(); if ($orgId = array_search($org, $allowedOrganizations)) { $this->session->user_organization_id = $orgId; $this->session->user_organization_name = $allowedOrganizations[$orgId]; Modified: trunk/library/classes/Gems/Default/RespondentAction.php =================================================================== --- trunk/library/classes/Gems/Default/RespondentAction.php 2011-11-14 12:43:05 UTC (rev 207) +++ trunk/library/classes/Gems/Default/RespondentAction.php 2011-11-14 12:53:50 UTC (rev 208) @@ -316,26 +316,6 @@ $this->html[] = $form; } - public function getPhysicians() - { - $session = new Zend_Session_Namespace('Pulse_' . __FILE__); - - if (! isset($session->physicians)) { - $organizationId = $this->escort->getCurrentOrganization(); - - $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__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; - } - - return $this->util->getTranslated()->getEmptyDropdownArray() + $session->physicians; - } - public function getMenuParameter($name, $default) { switch ($name) { Modified: trunk/library/classes/Gems/Default/StaffAction.php =================================================================== --- trunk/library/classes/Gems/Default/StaffAction.php 2011-11-14 12:43:05 UTC (rev 207) +++ trunk/library/classes/Gems/Default/StaffAction.php 2011-11-14 12:53:50 UTC (rev 208) @@ -44,7 +44,9 @@ */ class Gems_Default_StaffAction extends Gems_Controller_BrowseEditAction { - public $filterStandard = array('gsu_active' => 1); + public $defaultStaffDefinition = Gems_User_UserLoader::USER_STAFF; + + public $filterStandard = array('gsf_active' => 1); public $sortKey = array('name' => SORT_ASC); protected $_instanceId; @@ -92,39 +94,58 @@ { $dbLookup = $this->util->getDbLookup(); + switch ($data['gul_user_class']) { + case Gems_User_UserLoader::USER_STAFF: + Gems_Model::addUserPassword($model); + $passwordField = 'gup_password'; + $model->setOnSave($passwordField, array($this->project, 'getValueHashForModel')); + break; + + case Gems_User_UserLoader::USER_OLD_STAFF: + $passwordField = 'gsf_password'; + $model->setOnSave($passwordField, array($this, 'getOldPasswordHash')); + break; + + default: + $passwordField = false; + break; + } + $model->set('gsf_id_primary_group', 'multiOptions', MUtil_Lazy::call($dbLookup->getAllowedStaffGroups)); if ($new) { $model->set('gsf_id_primary_group', 'default', $dbLookup->getDefaultGroup()); - } else { - $model->set('gsu_password', 'description', $this->_('Enter only when changing')); - $model->setSaveWhenNotNull('gsu_password'); + } elseif ($passwordField) { + $model->set($passwordField, 'description', $this->_('Enter only when changing')); + $model->setSaveWhenNotNull($passwordField); } - $model->setOnSave('gsu_password', array($this->escort, 'passwordHash')); $ucfirst = new Zend_Filter_Callback('ucfirst'); - $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', array('gsu_id_user'))); + $bridge->addHidden( 'gsf_id_user'); + $bridge->addHidden( 'gul_id_user'); + $bridge->addHidden( 'gup_id_user'); + $bridge->addHidden( 'gul_user_class'); + $bridge->addText( 'gsf_login', 'size', 15, 'minlength', 4, + 'validator', $model->createUniqueValidator('gsf_login', array('gsf_id_user'))); // 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'); + $bridge->addHiddenMulti($model->getKeyCopyName('gsf_id_organization')); + $bridge->addSelect('gsf_id_organization'); } else { - $bridge->addExhibitor('gsu_id_organization'); + $bridge->addExhibitor('gsf_id_organization'); } - $bridge->addPassword('gsu_password', - 'label', $this->_('Password'), - 'minlength', $this->project->passwords['MinimumLength'], - // 'renderPassword', true, - 'repeatLabel', $this->_('Repeat password'), - 'required', $new, - 'size', 15 - ); + if ($passwordField) { + $bridge->addPassword($passwordField, + 'label', $this->_('Password'), + 'minlength', $this->project->passwords['MinimumLength'], + // 'renderPassword', true, + 'repeatLabel', $this->_('Repeat password'), + 'required', $new, + 'size', 15 + ); + } $bridge->addRadio( 'gsf_gender', 'separator', ''); $bridge->addText( 'gsf_first_name', 'label', $this->_('First name')); $bridge->addFilter( 'gsf_first_name', $ucfirst); @@ -141,15 +162,15 @@ public function afterFormLoad(array &$data, $isNew) { - if (array_key_exists('gsu_login', $data)) { - $this->_instanceId = $data['gsu_login']; + if (array_key_exists('glf_login', $data)) { + $this->_instanceId = $data['gsf_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['gsu_id_organization'] == $this->escort->getCurrentOrganization())) { + $data['gsf_id_organization'] == $this->escort->getCurrentOrganization())) { throw new Zend_Exception($this->_('You are not allowed to edit this staff member.')); } } @@ -169,21 +190,17 @@ { // MUtil_Model::$verbose = true; - $model = new Gems_Model_UserModel('staff', 'gems__staff', array('gsu_id_user' => 'gsf_id_user'), 'gsf'); - if ($detailed) { - $model->copyKeys(); - } - //$model->resetOrder(); + $model = $this->loader->getModels()->getStaffModel(); - $model->set('gsu_login', 'label', $this->_('Login')); + $model->set('gsf_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('gsu_id_organization', $this->escort->getCurrentOrganization()); + $this->menu->getParameterSource()->offsetSet('gsf_id_organization', $this->escort->getCurrentOrganization()); - $model->set('gsu_id_organization', 'label', $this->_('Organization'), + $model->set('gsf_id_organization', 'label', $this->_('Organization'), 'multiOptions', $this->util->getDbLookup()->getOrganizations(), 'default', $this->escort->getCurrentOrganization()); } @@ -192,12 +209,12 @@ $model->set('gsf_gender', 'label', $this->_('Gender'), 'multiOptions', $this->util->getTranslated()->getGenders()); if ($detailed) { - $model->set('gsu_user_class', 'default', 'StaffUser'); + $model->set('gul_user_class', 'default', $this->defaultStaffDefinition); ... [truncated message content] |
From: <gem...@li...> - 2011-11-14 12:43:15
|
Revision: 207 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=207&view=rev Author: matijsdejong Date: 2011-11-14 12:43:05 +0000 (Mon, 14 Nov 2011) Log Message: ----------- reintegrated branch 176 Property Changed: ---------------- branches/newUser2/ Property changes on: branches/newUser2 ___________________________________________________________________ Modified: svn:mergeinfo - /branches/newUser:113-150 /trunk/library:177-190,192-195 + /branches/newUser:113-150 /trunk/library:176-190,192-195 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2011-11-14 12:31:57
|
Revision: 206 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=206&view=rev Author: michieltcs Date: 2011-11-14 12:31:51 +0000 (Mon, 14 Nov 2011) Log Message: ----------- Refs #448 - add session name and cookie path to prevent clashes Modified Paths: -------------- trunk/library/classes/GemsEscort.php Modified: trunk/library/classes/GemsEscort.php =================================================================== --- trunk/library/classes/GemsEscort.php 2011-11-14 12:10:52 UTC (rev 205) +++ trunk/library/classes/GemsEscort.php 2011-11-14 12:31:51 UTC (rev 206) @@ -89,8 +89,13 @@ $firebug = $application->getOption('firebug'); $this->_startFirebird = $firebug['log']; - - Zend_Session::start(); + + Zend_Session::start( + array( + 'name' => GEMS_PROJECT_NAME_UC . 'SESSID', + 'cookie_path' => dirname($_SERVER['SCRIPT_NAME']) + ) + ); } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |