From: <gem...@li...> - 2011-11-01 13:52:27
|
Revision: 159 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=159&view=rev Author: matijsdejong Date: 2011-11-01 13:52:15 +0000 (Tue, 01 Nov 2011) Log Message: ----------- Ticket #33: date types for tracks fields, including use in track rounds. AnswerModelSnippetGeneric now shows a 'Fill in' button when possible and has extra usage options. Undo of change 157, but corrected the bug. Fixed bug in Lazy::first FormBridge::applyFixedOptions is now a static public function for use elsewhere. Modified Paths: -------------- trunk/library/classes/Gems/Default/TrackFieldsAction.php trunk/library/classes/Gems/Tracker/Engine/StepEngineAbstract.php trunk/library/classes/Gems/Tracker/Engine/TrackEngineAbstract.php trunk/library/classes/Gems/Tracker/RespondentTrack.php trunk/library/classes/Gems/Tracker/Snippets/AnswerModelSnippetGeneric.php trunk/library/classes/Gems/Tracker/SurveyModel.php trunk/library/classes/MUtil/Lazy.php trunk/library/classes/MUtil/Model/FormBridge.php trunk/library/classes/MUtil/Model/TableModel.php trunk/library/configs/db/patches.sql trunk/library/configs/db/tables/gems__track_fields.20.sql trunk/library/snippets/EditTrackSnippet.php Modified: trunk/library/classes/Gems/Default/TrackFieldsAction.php =================================================================== --- trunk/library/classes/Gems/Default/TrackFieldsAction.php 2011-11-01 13:30:39 UTC (rev 158) +++ trunk/library/classes/Gems/Default/TrackFieldsAction.php 2011-11-01 13:52:15 UTC (rev 159) @@ -67,9 +67,12 @@ $bridge->addExhibitor('gtf_id_track'); $bridge->addText('gtf_id_order'); $bridge->addText('gtf_field_name', 'size', '30', 'minlength', 4, 'required', true, 'validator', $model->createUniqueValidator(array('gtf_field_name','gtf_id_track'))); + $bridge->addText('gtf_field_code', 'minlength', 4, 'description', $this->_('Optional extra name to link the field to program code.')); + $bridge->addText('gtf_field_description', 'size', 30, 'description', $this->_('Optional extra description to show the user.')); $bridge->addTextarea('gtf_field_values', 'minlength', 4, 'rows', 4, 'description', $this->_('Separate multiple values with a vertical bar (|)'), 'required', false); $bridge->addSelect('gtf_field_type'); $bridge->addCheckBox('gtf_required'); + $bridge->addCheckBox('gtf_readonly', 'description', $this->_('Check this box if this field is always set by code instead of the user.')); } /** @@ -104,16 +107,23 @@ public function createModel($detailed, $action) { $trackId = $this->_getIdParam(); - $types = array('select' => $this->_('Select one'), 'multiselect' => $this->_('Select multiple'), 'text' => $this->_('Free text')); + $types = array('select' => $this->_('Select one'), 'multiselect' => $this->_('Select multiple'), 'date' => $this->_('Date'), 'text' => $this->_('Free text')); $model = new MUtil_Model_TableModel('gems__track_fields'); $model->setKeys(array('fid' => 'gtf_id_field', MUtil_Model::REQUEST_ID => 'gtf_id_track')); $model->set('gtf_id_track', 'label', $this->_('Track'), 'multiOptions', $this->util->getTrackData()->getAllTracks()); $model->set('gtf_id_order', 'label', $this->_('Order')); $model->set('gtf_field_name', 'label', $this->_('Name')); + if ($detailed) { + $model->set('gtf_field_code', 'label', $this->_('Code Name')); + $model->set('gtf_field_description', 'label', $this->_('Description')); + } $model->set('gtf_field_values', 'label', $this->_('Values')); $model->set('gtf_field_type', 'label', $this->_('Type'), 'multiOptions', $types); $model->set('gtf_required', 'label', $this->_('Required'), 'multiOptions', $this->util->getTranslated()->getYesNo()); + if ($detailed) { + $model->set('gtf_readonly', 'label', $this->_('Readonly'), 'multiOptions', $this->util->getTranslated()->getYesNo()); + } Gems_Model::setChangeFieldsByPrefix($model, 'gtf'); Modified: trunk/library/classes/Gems/Tracker/Engine/StepEngineAbstract.php =================================================================== --- trunk/library/classes/Gems/Tracker/Engine/StepEngineAbstract.php 2011-11-01 13:30:39 UTC (rev 158) +++ trunk/library/classes/Gems/Tracker/Engine/StepEngineAbstract.php 2011-11-01 13:52:15 UTC (rev 159) @@ -359,12 +359,22 @@ return $survey->getDatesList($language); case self::RESPONDENT_TRACK_TABLE: - return array( + $this->_ensureTrackFields(); + + $results = array( 'gr2t_start_date' => $this->_('Track start'), 'gr2t_end_date' => $this->_('Track end'), // 'gr2t_created' => $this->_('Track created'), ); + foreach ($this->_trackFields as $field) { + if ('date' == $field['gtf_field_type']) { + $results[$field['gtf_id_field']] = $field['gtf_field_name']; + } + } + + return $results; + case self::TOKEN_TABLE: return array( 'gto_valid_from' => $this->_('Valid from'), Modified: trunk/library/classes/Gems/Tracker/Engine/TrackEngineAbstract.php =================================================================== --- trunk/library/classes/Gems/Tracker/Engine/TrackEngineAbstract.php 2011-11-01 13:30:39 UTC (rev 158) +++ trunk/library/classes/Gems/Tracker/Engine/TrackEngineAbstract.php 2011-11-01 13:52:15 UTC (rev 159) @@ -173,7 +173,7 @@ protected function _ensureTrackFields() { if (! is_array($this->_trackFields)) { - $sql = "SELECT gtf_id_field, gtf_field_name, gtf_field_values, gtf_field_type, gtf_required + $sql = "SELECT * FROM gems__track_fields WHERE gtf_id_track = ? ORDER BY gtf_id_order"; @@ -493,24 +493,38 @@ $name = (string) $field['gtf_id_field']; - switch ($field['gtf_field_type']) { - case "multiselect": - $element = new Zend_Form_Element_MultiCheckbox($name); - $element->setMultiOptions($multi); - break; + if ($field['gtf_readonly']) { + $element = new MUtil_Form_Element_Exhibitor($name); - case "select": - $element = new Zend_Form_Element_Select($name); - $element->setMultiOptions($empty + $multi); - break; + } else { + switch ($field['gtf_field_type']) { + case "multiselect": + $element = new Zend_Form_Element_MultiCheckbox($name); + $element->setMultiOptions($multi); + break; - default: - $element = new Zend_Form_Element_Text($name); - $element->setAttrib('size', 40); - break; + case "select": + $element = new Zend_Form_Element_Select($name); + $element->setMultiOptions($empty + $multi); + break; + + case "date": + $options = array(); + MUtil_Model_FormBridge::applyFixedOptions('date', $options); + + $element = new MUtil_JQuery_Form_Element_DatePicker($name, $options); + $element->setStorageFormat('yyyy-MM-dd'); + break; + + default: + $element = new Zend_Form_Element_Text($name); + $element->setAttrib('size', 40); + break; + } } $element->setLabel($field['gtf_field_name']) - ->setRequired($field['gtf_required']); + ->setRequired($field['gtf_required']) + ->setDescription($field['gtf_field_description']); $elements[$name] = $element; } @@ -734,15 +748,33 @@ */ public function setFieldsData($respTrackId, array $data) { + $elements = null; $newValues = array(); // MUtil_Echo::track($data); + $this->_ensureTrackFields(); + foreach ($data as $id => $value) { if (is_array($value)) { $value = implode(self::FIELD_SEP, $value); } + // Do the hard work for storing dates + if (isset($this->_trackFields[$id]['gtf_field_type']) && ('date' == $this->_trackFields[$id]['gtf_field_type'])) { + if (! $elements) { + $elements = $this->getFieldsElements(); + } + if (isset($elements[$id])) { + $elem = $elements[$id]; + if ($elem instanceof MUtil_JQuery_Form_Element_DatePicker) { + // I do not like regenerating elements either, but this + // is the only place where we KNOW this information for sure. + $value = MUtil_Date::format($value, $elem->getStorageFormat(), $elem->getDateFormat()); + } + } + } + $newValues[]= array( 'gr2t2f_id_respondent_track' => $respTrackId, 'gr2t2f_id_field' => $id, @@ -765,7 +797,7 @@ /** * Updates the number of rounds in this track. - * + * * @param int $userId The current user * @return int 1 if data changed, 0 otherwise */ Modified: trunk/library/classes/Gems/Tracker/RespondentTrack.php =================================================================== --- trunk/library/classes/Gems/Tracker/RespondentTrack.php 2011-11-01 13:30:39 UTC (rev 158) +++ trunk/library/classes/Gems/Tracker/RespondentTrack.php 2011-11-01 13:52:15 UTC (rev 159) @@ -58,6 +58,12 @@ /** * + * @var array Field data + */ + protected $_fieldData = null; + + /** + * * @var Gems_Tracker_Token */ protected $_firstToken; @@ -107,6 +113,18 @@ } /** + * Makes sure the fieldData is in $this->_fieldData + * + * @param boolean $reload Optional parameter to force reload. + */ + private function _ensureFieldData($reload = false) + { + if ((null === $this->_fieldData) || $reload) { + $this->_fieldData = $this->getTrackEngine()->getFieldsData($this->_respTrackId); + } + } + + /** * Makes sure the receptioncode data is part of the $this->_respTrackData * * @param boolean $reload Optional parameter to force reload. @@ -344,14 +362,26 @@ public function getDate($fieldName) { if (isset($this->_respTrackData[$fieldName])) { - if (Zend_Date::isDate($this->_respTrackData[$fieldName], Gems_Tracker::DB_DATETIME_FORMAT)) { - return new MUtil_Date($this->_respTrackData[$fieldName], Gems_Tracker::DB_DATETIME_FORMAT); + $date = $this->_respTrackData[$fieldName]; + } else { + $this->_ensureFieldData(); + + if (isset($this->_fieldData[$fieldName])) { + $date = $this->_fieldData[$fieldName]; + } else { + $date = false; } - if (Zend_Date::isDate($this->_respTrackData[$fieldName], Gems_Tracker::DB_DATE_FORMAT)) { - return new MUtil_Date($this->_respTrackData[$fieldName], Gems_Tracker::DB_DATE_FORMAT); + } + + if ($date) { + if (Zend_Date::isDate($date, Gems_Tracker::DB_DATETIME_FORMAT)) { + return new MUtil_Date($date, Gems_Tracker::DB_DATETIME_FORMAT); } + if (Zend_Date::isDate($date, Gems_Tracker::DB_DATE_FORMAT)) { + return new MUtil_Date($date, Gems_Tracker::DB_DATE_FORMAT); + } if (Gems_Tracker::$verbose) { - MUtil_Echo::r($this->_respTrackData[$fieldName], 'Missed track date value:'); + MUtil_Echo::r($date, 'Missed track date value:'); } } } @@ -375,6 +405,18 @@ } /** + * Returns the field data for this respondent track id. + * + * @return array of the existing field values for this respondent track + */ + public function getFieldData() + { + $this->_ensureFieldData(); + + return $this->_fieldData; + } + + /** * Returns the first token in this track * * @return Gems_Tracker_Token Modified: trunk/library/classes/Gems/Tracker/Snippets/AnswerModelSnippetGeneric.php =================================================================== --- trunk/library/classes/Gems/Tracker/Snippets/AnswerModelSnippetGeneric.php 2011-11-01 13:30:39 UTC (rev 158) +++ trunk/library/classes/Gems/Tracker/Snippets/AnswerModelSnippetGeneric.php 2011-11-01 13:52:15 UTC (rev 159) @@ -83,6 +83,13 @@ protected $locale; /** + * Switch to put the display of the cancel and pritn buttons. + * + * @var boolean + */ + protected $showButtons = true; + + /** * Switch to put the display of the current token as select to true or false. * * @var boolean @@ -149,7 +156,20 @@ } $bridge->th($this->_('Token')); - $td = $bridge->tdh($bridge->gto_id_token->strtoupper()); + + $tokenUpper = $bridge->gto_id_token->strtoupper(); + if ($menuItem = $this->menu->find(array('controller' => 'ask', 'action' => 'take', 'allowed' => true))) { + $source = new Gems_Menu_ParameterSource(); + $source->setTokenId($bridge->gto_id_token); + $source->offsetSet('can_be_taken', $bridge->can_be_taken); + + $link = $menuItem->toActionLink($source); + $link->title = array($this->_('Token'), $tokenUpper); + + $td = $bridge->tdh($bridge->can_be_taken->if($link, $tokenUpper)); + } else { + $td = $bridge->tdh($tokenUpper); + } $td->appendAttrib('class', $selectedClass); $td->appendAttrib('class', $bridge->row_class); } @@ -207,9 +227,11 @@ $htmlDiv->ul($this->_('No token specified.'), array('class' => 'errors')); } - $buttonDiv = $htmlDiv->buttonDiv(); - $buttonDiv->actionLink(array(), $this->_('Close'), array('onclick' => 'window.close();')); - $buttonDiv->actionLink(array(), $this->_('Print'), array('onclick' => 'window.print();')); + if ($this->showButtons) { + $buttonDiv = $htmlDiv->buttonDiv(); + $buttonDiv->actionLink(array(), $this->_('Close'), array('onclick' => 'window.close();')); + $buttonDiv->actionLink(array(), $this->_('Print'), array('onclick' => 'window.print();')); + } return $htmlDiv; } Modified: trunk/library/classes/Gems/Tracker/SurveyModel.php =================================================================== --- trunk/library/classes/Gems/Tracker/SurveyModel.php 2011-11-01 13:30:39 UTC (rev 158) +++ trunk/library/classes/Gems/Tracker/SurveyModel.php 2011-11-01 13:52:15 UTC (rev 159) @@ -1,6 +1,5 @@ <?php - /** * Copyright (c) 2011, Erasmus MC * All rights reserved. @@ -26,22 +25,24 @@ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** - * @author Matijs de Jong - * @since 1.4 - * @version 1.4 - * @package Gems + * + * + * @package Gems * @subpackage Tracker + * @author Matijs de Jong <mj...@ma...> + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @version $Id$ */ /** - * Description of SurveyModel + * More correctly a Survey ANSWERS Model as it adds answers to token information/ * - * @author Matijs de Jong - * @package Gems + * @package Gems * @subpackage Tracker + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @since Class available since version 1.4 */ class Gems_Tracker_SurveyModel extends Gems_Model_JoinModel { @@ -63,6 +64,9 @@ $this->addTable('gems__reception_codes', array('gto_reception_code' => 'grc_id_reception_code')); $this->addColumn( + 'CASE WHEN grc_success = 1 AND gto_valid_from <= CURRENT_TIMESTAMP AND gto_completion_time IS NULL AND (gto_valid_until IS NULL OR gto_valid_until >= CURRENT_TIMESTAMP) THEN 1 ELSE 0 END', + 'can_be_taken'); + $this->addColumn( "CASE WHEN grc_success = 1 THEN '' ELSE 'deleted' END", 'row_class'); Modified: trunk/library/classes/MUtil/Lazy.php =================================================================== --- trunk/library/classes/MUtil/Lazy.php 2011-11-01 13:30:39 UTC (rev 158) +++ trunk/library/classes/MUtil/Lazy.php 2011-11-01 13:52:15 UTC (rev 159) @@ -1,39 +1,38 @@ <?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$ */ /** @@ -48,9 +47,11 @@ * 3 - an object propery * 4 - an array object * - * @author Matijs de Jong - * @package MUtil + * @package MUtil * @subpackage Lazy + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @since Class available since version 1.0 */ class MUtil_Lazy { @@ -77,10 +78,10 @@ $args = func_get_args(); // Last value first - $result = array_pop($args); + $result = array_shift($args); - foreach (array_reverse($args) as $arg) { - $result = new MUtil_Lazy_Call(array($arg, 'if'), array($arg, $result)); + foreach ($args as $arg) { + $result = new MUtil_Lazy_Call(array($result, 'if'), array($result, $arg)); } return $result; } @@ -130,16 +131,16 @@ return new MUtil_Lazy_Property($object, $property); } - /** - * Raises a MUtil_Lazy_LazyInterface one level, but may still + /** + * Raises a MUtil_Lazy_LazyInterface one level, but may still * return a MUtil_Lazy_LazyInterface. - * - * This function is usually used to perform a e.g. filter function on object that may e.g. + * + * This function is usually used to perform a e.g. filter function on object that may e.g. * contain Repeater objects. - * + * * @param mixed $object Usually an object of type MUtil_Lazy_LazyInterface * @param mixed $stack Optional variable stack for evaluation - * @return mixed + * @return mixed */ public static function raise($object, $stack = null) { @@ -153,7 +154,7 @@ /** * * @param mixed $repeatable - * @return MUtil_Lazy_RepeatableInterface + * @return MUtil_Lazy_RepeatableInterface */ public static function repeat($repeatable) { @@ -164,18 +165,18 @@ return new MUtil_Lazy_Repeatable($repeatable); } - /** - * Raises a MUtil_Lazy_LazyInterface until the return object is not a + /** + * Raises a MUtil_Lazy_LazyInterface until the return object is not a * MUtil_Lazy_LazyInterface object. - * - * @param mixed $object Usually an object of type MUtil_Lazy_LazyInterface + * + * @param mixed $object Usually an object of type MUtil_Lazy_LazyInterface * @param mixed $stack Optional variable stack for evaluation * @return mixed Something not lazy */ public static function rise($object, $stack = null) { $stack = self::toStack($stack, __FUNCTION__); - + // Resolving when MUtil_Lazy_LazyInterface. while ($object instanceof MUtil_Lazy_LazyInterface) { $object = $object->__toValue($stack); @@ -192,11 +193,11 @@ return $object; } - /** + /** * Turns any input into a MUtil_Lazy_StackInterface object. - * - * @param mixed $stack Value to be turned into stack for evaluation - * @param string A string describing where the stack was created. + * + * @param mixed $stack Value to be turned into stack for evaluation + * @param string A string describing where the stack was created. * @return MUtil_Lazy_StackInterface A usable stack */ private static function toStack($stack, $source) Modified: trunk/library/classes/MUtil/Model/FormBridge.php =================================================================== --- trunk/library/classes/MUtil/Model/FormBridge.php 2011-11-01 13:30:39 UTC (rev 158) +++ trunk/library/classes/MUtil/Model/FormBridge.php 2011-11-01 13:52:15 UTC (rev 159) @@ -112,7 +112,7 @@ return $element; } - protected function _applyFixedOptions($type, array &$options) + public static function applyFixedOptions($type, array &$options) { static $typeOptions; @@ -268,7 +268,7 @@ $options = $this->_mergeOptions($name, $options, self::DISPLAY_OPTIONS, self::CHECK_OPTIONS); - $this->_applyFixedOptions(__FUNCTION__, $options); + self::applyFixedOptions(__FUNCTION__, $options); $element = new Zend_Form_Element_Checkbox($name, $options); @@ -286,7 +286,7 @@ $elementName = $name; // Allow centrally set options - $this->_applyFixedOptions(__FUNCTION__, $options); + self::applyFixedOptions(__FUNCTION__, $options); if (isset($options['dateFormat'])) { // Make sure the model knows the dateFormat (can be important for storage). Modified: trunk/library/classes/MUtil/Model/TableModel.php =================================================================== --- trunk/library/classes/MUtil/Model/TableModel.php 2011-11-01 13:30:39 UTC (rev 158) +++ trunk/library/classes/MUtil/Model/TableModel.php 2011-11-01 13:52:15 UTC (rev 159) @@ -77,7 +77,8 @@ { return $this->_deleteTableData( $this->_table, - $this->_checkFilterUsed($filter)); + $this->_checkFilterUsed($filter), + $this->_deleteValues); } /** Modified: trunk/library/configs/db/patches.sql =================================================================== --- trunk/library/configs/db/patches.sql 2011-11-01 13:30:39 UTC (rev 158) +++ trunk/library/configs/db/patches.sql 2011-11-01 13:52:15 UTC (rev 159) @@ -233,3 +233,8 @@ ALTER TABLE `gems__staff` CHANGE `gsf_login` `gsf_login` VARCHAR( 20 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, CHANGE `gsf_password` `gsf_password` VARCHAR( 32 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, CHANGE `gsf_id_organization` `gsf_id_organization` BIGINT( 20 ) NULL DEFAULT NULL; + +-- PATCH: Extra information for track fields +ALTER TABLE gems__track_fields ADD gtf_field_code varchar(20) CHARACTER SET 'utf8' COLLATE 'utf8_general_ci' null AFTER gtf_field_name, + ADD gtf_field_description varchar(200) CHARACTER SET 'utf8' COLLATE 'utf8_general_ci' null AFTER gtf_field_code, + ADD gtf_readonly boolean not null default false AFTER gtf_required; \ No newline at end of file Modified: trunk/library/configs/db/tables/gems__track_fields.20.sql =================================================================== --- trunk/library/configs/db/tables/gems__track_fields.20.sql 2011-11-01 13:30:39 UTC (rev 158) +++ trunk/library/configs/db/tables/gems__track_fields.20.sql 2011-11-01 13:52:15 UTC (rev 159) @@ -6,12 +6,15 @@ gtf_id_order int not null default 10, gtf_field_name varchar(200) CHARACTER SET 'utf8' COLLATE 'utf8_general_ci' not null, + gtf_field_code varchar(20) CHARACTER SET 'utf8' COLLATE 'utf8_general_ci' null, + gtf_field_description varchar(200) CHARACTER SET 'utf8' COLLATE 'utf8_general_ci' null, gtf_field_values text CHARACTER SET 'utf8' COLLATE 'utf8_general_ci' null, gtf_field_type varchar(20) CHARACTER SET 'utf8' COLLATE 'utf8_general_ci' not null, gtf_required boolean not null default false, + gtf_readonly boolean not null default false, gtf_changed timestamp not null default current_timestamp on update current_timestamp, gtf_changed_by bigint unsigned not null, Modified: trunk/library/snippets/EditTrackSnippet.php =================================================================== --- trunk/library/snippets/EditTrackSnippet.php 2011-11-01 13:30:39 UTC (rev 158) +++ trunk/library/snippets/EditTrackSnippet.php 2011-11-01 13:52:15 UTC (rev 159) @@ -130,6 +130,7 @@ $model = $this->getModel(); $this->formData = $model->save($this->formData); $changed = $model->getChanged(); + $refresh = false; // Retrieve the key if just created if ($this->createData) { @@ -140,18 +141,25 @@ $this->trackEngine->checkRoundsFor($this->respondentTrack, $this->userId); } elseif (! (isset($this->formData['gr2t_completed']) && $this->formData['gr2t_completed'])) { - // Check if sartdate has changed + // Check if startdate has changed if (! $this->respondentTrack->getStartDate()->equals(new MUtil_Date($this->formData['gr2t_start_date']))) { - // Perform a refresh from the database, to avoid date trouble - $this->respondentTrack->refresh(); - $this->respondentTrack->checkTrackTokens($this->userId); + $refresh = true; } } if ($this->trackEngine && isset($this->formData[self::TRACKFIELDS_ID])) { $changed = $this->trackEngine->setFieldsData($this->respondentTrackId, $this->formData[self::TRACKFIELDS_ID]) ? 1 : $changed; + $refresh = $refresh || $changed; } + if ($refresh) { + Gems_Tracker::$verbose; + // Perform a refresh from the database, to avoid date trouble + $this->respondentTrack->refresh(); + $this->respondentTrack->checkTrackTokens($this->userId); + } + + // Communicate with the user $this->afterSave($changed); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |