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-12-02 11:32:39
|
Revision: 330 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=330&view=rev Author: michieltcs Date: 2011-12-02 11:32:33 +0000 (Fri, 02 Dec 2011) Log Message: ----------- Special case for session expiration in the auto filter Modified Paths: -------------- branches/1.5.0-pulse/library/classes/GemsEscort.php Modified: branches/1.5.0-pulse/library/classes/GemsEscort.php =================================================================== --- branches/1.5.0-pulse/library/classes/GemsEscort.php 2011-12-01 16:51:32 UTC (rev 329) +++ branches/1.5.0-pulse/library/classes/GemsEscort.php 2011-12-02 11:32:33 UTC (rev 330) @@ -1512,6 +1512,9 @@ ); } else { // No longer logged in + if ($request->getActionName() == 'autofilter') { + throw new Gems_Exception("Session expired", 401); + } if ($menuItem = $this->menu->findFirst(array('allowed' => true, 'visible' => true))) { $this->addMessage($this->_('You are no longer logged in.')); $this->addMessage($this->_('You must login to access this page.')); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2011-12-01 16:51:42
|
Revision: 329 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=329&view=rev Author: matijsdejong Date: 2011-12-01 16:51:32 +0000 (Thu, 01 Dec 2011) Log Message: ----------- Whoops, echo off. Modified Paths: -------------- branches/1.5.0-pulse/library/classes/Gems/Menu/ParameterCollector.php Modified: branches/1.5.0-pulse/library/classes/Gems/Menu/ParameterCollector.php =================================================================== --- branches/1.5.0-pulse/library/classes/Gems/Menu/ParameterCollector.php 2011-12-01 16:44:33 UTC (rev 328) +++ branches/1.5.0-pulse/library/classes/Gems/Menu/ParameterCollector.php 2011-12-01 16:51:32 UTC (rev 329) @@ -101,7 +101,7 @@ $this->values[$name] = $source->__get($name); } elseif (is_array($source)) { - MUtil_Echo::track($name, $source); + // MUtil_Echo::track($name, $source); if (isset($source[$name])) { $this->values[$name] = $source[$name]; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2011-12-01 16:44:42
|
Revision: 328 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=328&view=rev Author: matijsdejong Date: 2011-12-01 16:44:33 +0000 (Thu, 01 Dec 2011) Log Message: ----------- Whoops, echo off. Modified Paths: -------------- branches/1.5.0-pulse/library/classes/Gems/Tracker/Source/LimeSurvey1m9Database.php Modified: branches/1.5.0-pulse/library/classes/Gems/Tracker/Source/LimeSurvey1m9Database.php =================================================================== --- branches/1.5.0-pulse/library/classes/Gems/Tracker/Source/LimeSurvey1m9Database.php 2011-12-01 16:40:45 UTC (rev 327) +++ branches/1.5.0-pulse/library/classes/Gems/Tracker/Source/LimeSurvey1m9Database.php 2011-12-01 16:44:33 UTC (rev 328) @@ -1004,7 +1004,7 @@ } if ($missingFields) { $sql = "ALTER TABLE " . $this->_getTokenTableName($sid) . " " . implode(', ', $missingFields); - MUtil_Echo::track($sql); + // MUtil_Echo::track($sql); try { $lsDb->query($sql); } catch (Zend_Exception $e) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2011-12-01 16:40:52
|
Revision: 327 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=327&view=rev Author: matijsdejong Date: 2011-12-01 16:40:45 +0000 (Thu, 01 Dec 2011) Log Message: ----------- WARNING: Synchronize all sources!!! The respondent track id was added to the fields. Modified Paths: -------------- branches/1.5.0-pulse/library/classes/Gems/Tracker/Source/LimeSurvey1m9Database.php Modified: branches/1.5.0-pulse/library/classes/Gems/Tracker/Source/LimeSurvey1m9Database.php =================================================================== --- branches/1.5.0-pulse/library/classes/Gems/Tracker/Source/LimeSurvey1m9Database.php 2011-12-01 15:26:53 UTC (rev 326) +++ branches/1.5.0-pulse/library/classes/Gems/Tracker/Source/LimeSurvey1m9Database.php 2011-12-01 16:40:45 UTC (rev 327) @@ -64,7 +64,20 @@ protected $_anonymizedField = 'private'; /** + * A map containing attributename => databasefieldname mappings * + * Should contain maps for respondentid, organizationid and consentcode. + * + * @var array + */ + protected $_attributeMap = array( + 'respondentid' => 'attribute_1', + 'organizationid' => 'attribute_2', + 'consentcode' => 'attribute_3', + 'resptrackid' => 'attribute_4'); + + /** + * * @var array of Gems_Tracker_Source_LimeSurvey1m9FieldMap */ private $_fieldMaps; @@ -106,6 +119,21 @@ protected $util; /** + * Returns a list of field names that should be set in a newly inserted token. + * + * @param Gems_Tracker_Token $token + */ + protected function _fillAttributeMap(Gems_Tracker_Token $token) + { + $values[$this->_attributeMap['respondentid']] = (string) $token->getRespondentId(); + $values[$this->_attributeMap['organizationid']] = (string) $token->getOrganizationId(); + $values[$this->_attributeMap['consentcode']] = (string) $token->getConsentCode(); + $values[$this->_attributeMap['resptrackid']] = (string) $token->getRespondentTrackId(); + + return $values; + } + + /** * Filters an answers array, return only those fields that where answered by the user. * * @param int $sourceSurveyId Survey ID @@ -362,10 +390,9 @@ * Insert token in table (if not there) * ****************************************/ - $values['completed'] = 'N'; // Apparently it is possible to have this value filled without a survey questionnaire. - $values['attribute_1'] = (string) $token->getRespondentId(); - $values['attribute_2'] = (string) $token->getOrganizationId(); - $values['attribute_3'] = (string) $token->getConsentCode(); + // Get the mapped values + $values = $this->_fillAttributeMap($token); + $values['completed'] = 'N'; // Apparently it is possible to have this value filled without a survey questionnaire. $result = 0; if ($oldValues = $lsDb->fetchRow("SELECT * FROM $lsTokens WHERE token = ? LIMIT 1", $tokenId)) { @@ -614,9 +641,7 @@ $quotedSurveyTable = $lsDb->quoteIdentifier($lsSurveyTable . '.token'); $select = $lsDb->select(); - $select->from($lsTokenTable, array('respondentid' => 'attribute_1', - 'organizationid' => 'attribute_2', - 'consentcode' => 'attribute_3')) + $select->from($lsTokenTable, $this->_attributeMap) ->join($lsSurveyTable, $quotedTokenTable . ' = ' . $quotedSurveyTable); //Now process the filters @@ -632,19 +657,13 @@ unset($filter['token']); } - //now map the attributes to the right fields - if (isset($filter['respondentid'])) { - $filter['attribute_1'] = $filter['respondentid']; - unset($filter['respondentid']); + // now map the attributes to the right fields + foreach ($this->_attributeMap as $name => $field) { + if (isset($filter[$name])) { + $filter[$field] = $filter[$name]; + unset($filter[organizationid]); + } } - if (isset($filter['organizationid'])) { - $filter['attribute_2'] = $filter['organizationid']; - unset($filter['organizationid']); - } - if (isset($filter['consentcode'])) { - $filter['attribute_3'] = $filter['consentcode']; - unset($filter['consentcode']); - } } foreach ($filter as $field => $values) { @@ -917,10 +936,10 @@ if ($surveyor_survey[$this->_anonymizedField] == 'Y') { $surveyor_status .= 'Uses anonymous answers. '; } elseif ($surveyor_survey[$this->_anonymizedField] !== 'N') { - //This is for the case that $this->_anonymizedField is empty, we show an update statement. - //The answers already in the table can only be linked to the repsonse based on the completion time - //this requires a manual action as token table only hold minuts while survey table holds seconds - //and we might have responses with the same timestamp. + // This is for the case that $this->_anonymizedField is empty, we show an update statement. + // The answers already in the table can only be linked to the repsonse based on the completion time + // this requires a manual action as token table only hold minuts while survey table holds seconds + // and we might have responses with the same timestamp. $update = "UPDATE " . $this->_getSurveysTableName() . " SET `" . $this->_anonymizedField . "` = 'N' WHERE sid = " . $sid . ';'; $update .= "ALTER TABLE " . $this->_getSurveyTableName($sid) . " ADD `token` varchar(36) default NULL;"; MUtil_Echo::r($update); @@ -977,6 +996,24 @@ $surveyor_status .= 'Token field length is too short. '; } + $missingFields = array(); + foreach ($this->_attributeMap as $name => $field) { + if (! isset($tokenTable[$field])) { + $missingFields[] = "ADD $field varchar(255) CHARACTER SET 'utf8' COLLATE 'utf8_general_ci'"; + } + } + if ($missingFields) { + $sql = "ALTER TABLE " . $this->_getTokenTableName($sid) . " " . implode(', ', $missingFields); + MUtil_Echo::track($sql); + try { + $lsDb->query($sql); + } catch (Zend_Exception $e) { + $surveyor_status .= 'Token attributes could not be created. '; + $surveyor_status .= $e->getMessage() . ' '; + // MUtil_Echo::track($e); + } + } + /* $attrCount = 0; for ($i = 1; $i < 10; $i++) { $attrFields[$i] = isset($tokenTable['attribute_' . $i]); @@ -997,7 +1034,7 @@ $surveyor_status .= sprintf('Token attribute field %d is missing. ', $i); } } - } + } // */ } if ($updateTokens && (! $surveyor_status)) { @@ -1047,7 +1084,7 @@ if (substr($surveyor_status, 0, 127) != (string) $survey->getStatus()) { if ($surveyor_status) { $values['gsu_status'] = substr($surveyor_status, 0, 127); - $messages[] = sprintf($this->translate->_('The status of the \'%s\' survey has changed to \'%s\'.'), $survey->getName(), $data['gsu_status']); + $messages[] = sprintf($this->translate->_('The status of the \'%s\' survey has changed to \'%s\'.'), $survey->getName(), $values['gsu_status']); } else { $values['gsu_status'] = new Zend_Db_Expr('NULL'); $messages[] = sprintf($this->translate->_('The status warning for the \'%s\' survey was removed.'), $survey->getName()); @@ -1098,7 +1135,7 @@ if (null === $consentCode) { $consentCode = (string) $token->getConsentCode(); } - $values['attribute_3'] = $consentCode; + $values[$this->_attributeMap['consentcode']] = $consentCode; if ($oldValues = $lsDb->fetchRow("SELECT * FROM $lsTokens WHERE token = ? LIMIT 1", $tokenId)) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2011-12-01 15:27:01
|
Revision: 326 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=326&view=rev Author: mennodekker Date: 2011-12-01 15:26:53 +0000 (Thu, 01 Dec 2011) Log Message: ----------- Merged userloader branch up to revision 321 - indexAction: use project email for retrieve password emails - StaffAction: start towards better handling of other userclasses (mainly raising questions) unique gsf_login replaced by unique gsf_login + gsf_id_organization unique constraint on email removed (one email can have two logins for example admin / non admin login (needs check with password retrieval) - SurveyMaintenanceAction: Show description of survey (so we can see what 'version' we use - ProjectSettings: Just a note on init and notice fixes - TabForm: bugfixes - TrackEngineAbstract: Show description of survey (like in SurveyMaintenanceAction - Survey: allow to read description - Organization: moved -> access to get, so we can have default values and get something when key exists but value is null - UserLoader: Related to StaffAction, retrieve definition without having a user - TrackData: Extra method to have surveys with and without description - patches.sql: Remove unique constraint from the index to allow multiple accounts with the same email Revision Links: -------------- http://gemstracker.svn.sourceforge.net/gemstracker/?rev=321&view=rev Modified Paths: -------------- trunk/library/classes/Gems/Default/IndexAction.php trunk/library/classes/Gems/Default/StaffAction.php trunk/library/classes/Gems/Default/SurveyMaintenanceAction.php trunk/library/classes/Gems/Project/ProjectSettings.php trunk/library/classes/Gems/TabForm.php trunk/library/classes/Gems/Tracker/Engine/TrackEngineAbstract.php trunk/library/classes/Gems/Tracker/Survey.php trunk/library/classes/Gems/User/Organization.php trunk/library/classes/Gems/User/UserLoader.php trunk/library/classes/Gems/Util/TrackData.php trunk/library/configs/db/patches.sql Added Paths: ----------- trunk/library/classes/Zend/ trunk/library/classes/Zend/Translate/ trunk/library/classes/Zend/Translate/Adapter.php Removed Paths: ------------- trunk/library/classes/Zend/Translate/ trunk/library/classes/Zend/Translate/Adapter.php Property Changed: ---------------- trunk/library/ Property changes on: trunk/library ___________________________________________________________________ Modified: svn:mergeinfo - /branches/1.5.0-pulse/library:306-311 /branches/newUser:113-150 /branches/newUser2:175-207 /tags/1.5.0beta1/library:305 + /branches/1.5.0-pulse/library:306-311 /branches/newUser:113-150 /branches/newUser2:175-207 /branches/userloader:259-324 /tags/1.5.0beta1/library:305 Modified: trunk/library/classes/Gems/Default/IndexAction.php =================================================================== --- trunk/library/classes/Gems/Default/IndexAction.php 2011-12-01 15:14:59 UTC (rev 325) +++ trunk/library/classes/Gems/Default/IndexAction.php 2011-12-01 15:26:53 UTC (rev 326) @@ -1,5 +1,4 @@ <?php - /** * Copyright (c) 2011, Erasmus MC * All rights reserved. @@ -416,12 +415,14 @@ $this->addMessage($this->_('This key timed out or does not belong to this user.')); } } else { - // P{ass mail by key + // Pass mail by key $mail = new MUtil_Mail(); - $mail->setFrom('mj...@ma...'); $mail->addTo($user->getEmailAddress(), $user->getFullName()); - if (isset($this->escort->project->email) && isset($this->escort->project->email['bcc'])) { + if (isset($this->escort->project->email['site'])) { + $mail->setFrom($this->escort->project->email['site']); + } + if (isset($this->escort->project->email['bcc'])) { $mail->addBcc($this->escort->project->email['bcc']); } Modified: trunk/library/classes/Gems/Default/StaffAction.php =================================================================== --- trunk/library/classes/Gems/Default/StaffAction.php 2011-12-01 15:14:59 UTC (rev 325) +++ trunk/library/classes/Gems/Default/StaffAction.php 2011-12-01 15:26:53 UTC (rev 326) @@ -44,6 +44,8 @@ */ class Gems_Default_StaffAction extends Gems_Controller_BrowseEditAction { + //@@TODO What if we want a different one per organization? + //Maybe check if org has a default and otherwise use this one? public $defaultStaffDefinition = Gems_User_UserLoader::USER_STAFF; public $filterStandard = array('gsf_active' => 1); @@ -102,22 +104,23 @@ } $dbLookup = $this->util->getDbLookup(); - switch ($data['gul_user_class']) { - case Gems_User_UserLoader::USER_STAFF: + $passwordField = false; + + //@@TODO Like this? should work when user is not saved, but storing the password should be done when + //we do have a user... + $definition = $this->loader->getUserLoader()->getUserDefinition($data['gul_user_class'].'Definition'); + + if ($definition->canSetPassword()) { + //@@TODO: Should we handle it like this? The userdef has a setpassword method... + if ($definition instanceof Gems_User_StaffUserDefinition) { Gems_Model::addUserPassword($model); $passwordField = 'gup_password'; $model->setOnSave($passwordField, array($this->project, 'getValueHash')); - break; - - case Gems_User_UserLoader::USER_OLD_STAFF: + } elseif ($definition instanceof Gems_User_OldStaffUserDefinition) { $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) { @@ -133,8 +136,10 @@ $bridge->addHidden( 'gul_id_user'); $bridge->addHidden( 'gup_id_user'); $bridge->addHidden( 'gul_user_class'); + //@@TODO: How do we change this? Only per org, or allow per user? + //What classes are available? Maybe use something like event loader and add a little desc. to each type? $bridge->addText( 'gsf_login', 'size', 15, 'minlength', 4, - 'validator', $model->createUniqueValidator('gsf_login', array('gsf_id_user'))); + 'validator', $model->createUniqueValidator(array('gsf_login', 'gsf_id_organization'), array('gsf_id_user'))); // Can the organization be changed? if ($this->escort->hasPrivilege('pr.staff.edit.all')) { @@ -163,7 +168,7 @@ $bridge->addText( 'gsf_surname_prefix', 'label', $this->_('Surname prefix'), 'description', 'de, van der, \'t, etc...'); $bridge->addText( 'gsf_last_name', 'label', $this->_('Last name'), 'required', true); $bridge->addFilter( 'gsf_last_name', $ucfirst); - $bridge->addText( 'gsf_email', array('size' => 30))->addValidator('SimpleEmail')->addValidator($model->createUniqueValidator('gsf_email')); + $bridge->addText( 'gsf_email', array('size' => 30))->addValidator('SimpleEmail'); $bridge->addSelect('gsf_id_primary_group'); $bridge->addCheckbox('gsf_logout_on_survey', 'description', $this->_('If checked the user will logoff when answering a survey.')); Modified: trunk/library/classes/Gems/Default/SurveyMaintenanceAction.php =================================================================== --- trunk/library/classes/Gems/Default/SurveyMaintenanceAction.php 2011-12-01 15:14:59 UTC (rev 325) +++ trunk/library/classes/Gems/Default/SurveyMaintenanceAction.php 2011-12-01 15:26:53 UTC (rev 326) @@ -344,11 +344,11 @@ $model->resetOrder(); $model->set('gsu_survey_name', 'label', $this->_('Name')); + $model->set('gsu_survey_description', 'label', $this->_('Description'), 'formatFunction', array(__CLASS__, 'formatDescription')); $model->set('gso_source_name', 'label', $this->_('Source')); $model->set('gsu_status_show', 'label', $this->_('Status in source')); if ($detailed) { - $model->set('gsu_survey_description', 'label', $this->_('Description'), 'formatFunction', array(__CLASS__, 'formatDescription')); $model->set('gsu_surveyor_active', 'label', $this->_('Active in source')); $model->set('gsu_active', 'label', sprintf($this->_('Active in %s'), GEMS_PROJECT_NAME_UC)); } else { Modified: trunk/library/classes/Gems/Project/ProjectSettings.php =================================================================== --- trunk/library/classes/Gems/Project/ProjectSettings.php 2011-12-01 15:14:59 UTC (rev 325) +++ trunk/library/classes/Gems/Project/ProjectSettings.php 2011-12-01 15:26:53 UTC (rev 326) @@ -97,6 +97,8 @@ parent::__construct($array, ArrayObject::ARRAY_AS_PROPS); + //@@TODO: some checks should not be done on each and every request! + // this can be a problem when testing $this->checkRequiredValues(); } @@ -276,7 +278,7 @@ */ public function getSuperAdminName() { - if (isset($this->admin['user'])) { + if (isset($this->admin) && isset($this->admin['user'])) { return $this->admin['user']; } } @@ -288,7 +290,7 @@ */ protected function getSuperAdminPassword() { - if (isset($this->admin['pwd'])) { + if (isset($this->admin) && isset($this->admin['pwd'])) { return $this->admin['pwd']; } } Modified: trunk/library/classes/Gems/TabForm.php =================================================================== --- trunk/library/classes/Gems/TabForm.php 2011-12-01 15:14:59 UTC (rev 325) +++ trunk/library/classes/Gems/TabForm.php 2011-12-01 15:26:53 UTC (rev 326) @@ -60,18 +60,22 @@ if ($this->currentTab && !($element instanceof Zend_Form_Element_Hidden)) { return $this->currentTab->addElement($element, $name, $options); } else { + parent::addElement($element, $name, $options); + if (is_string($element)) { + $element = $this->getElement($element); + } if ($element instanceof Zend_Form_Element_Hidden) { //Remove decorators $element->removeDecorator('htmlTag'); $element->removeDecorator('Label'); - } else { + } elseif ($element instanceof Zend_Form_Element) { $error = $element->getDecorator('Errors'); if ($error instanceof Zend_Form_Decorator_Errors) { $element->removeDecorator('Errors'); $element->addDecorator($error); } } - return parent::addElement($element, $name, $options); + return $this; } } @@ -337,6 +341,13 @@ * @return Gems_TabForm */ public function setView(Zend_View_Interface $view = null) { + /** + * If the form is populated... and we have a tab set... select it + */ + if ($tab = $this->getValue('tab')) { + $this->selectTab($tab); + } + $form = parent::setView($view); if ($view) { Modified: trunk/library/classes/Gems/Tracker/Engine/TrackEngineAbstract.php =================================================================== --- trunk/library/classes/Gems/Tracker/Engine/TrackEngineAbstract.php 2011-12-01 15:14:59 UTC (rev 325) +++ trunk/library/classes/Gems/Tracker/Engine/TrackEngineAbstract.php 2011-12-01 15:26:53 UTC (rev 326) @@ -702,7 +702,7 @@ $model->set('gro_id_track', 'label', $this->_('Track'), 'elementClass', 'exhibitor', 'multiOptions', MUtil_Lazy::call($this->util->getTrackData()->getAllTracks)); } - $model->set('gro_id_survey', 'label', $this->_('Survey'), 'multiOptions', $this->util->getTrackData()->getAllSurveys()); + $model->set('gro_id_survey', 'label', $this->_('Survey'), 'multiOptions', $this->util->getTrackData()->getAllSurveysAndDescriptions()); $model->set('gro_id_order', 'label', $this->_('Order'), 'default', 10, 'validators[]', $model->createUniqueValidator(array('gro_id_order', 'gro_id_track'))); $model->set('gro_round_description', 'label', $this->_('Description'), 'size', '30'); //, 'minlength', 4, 'required', true); $model->set('gro_changed_event', 'label', $this->_('After change'), 'multiOptions', $this->events->listRoundChangedEvents()); Modified: trunk/library/classes/Gems/Tracker/Survey.php =================================================================== --- trunk/library/classes/Gems/Tracker/Survey.php 2011-12-01 15:14:59 UTC (rev 325) +++ trunk/library/classes/Gems/Tracker/Survey.php 2011-12-01 15:26:53 UTC (rev 326) @@ -1,5 +1,4 @@ <?php - /** * Copyright (c) 2011, Erasmus MC * All rights reserved. @@ -262,7 +261,16 @@ return $source->getDatesList($language, $this->_surveyId, $this->_gemsSurvey['gsu_surveyor_id']); } + /** + * + * @return string Description of the survey + */ + public function getDescription() + { + return $this->_gemsSurvey['gsu_survey_description']; + } + /** * * @return int Gems group id for survey Modified: trunk/library/classes/Gems/User/Organization.php =================================================================== --- trunk/library/classes/Gems/User/Organization.php 2011-12-01 15:14:59 UTC (rev 325) +++ trunk/library/classes/Gems/User/Organization.php 2011-12-01 15:26:53 UTC (rev 326) @@ -77,22 +77,6 @@ protected $db; /** - * 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 (isset($this->_data[$name])) { - return $this->_data[$name]; - } - - return parent::__get($name); - } - - /** * Set menu parameters from the organization * * @param Gems_Menu_ParameterSource $source @@ -122,6 +106,22 @@ { return (boolean) $this->_get('gor_has_respondents') || $this->_get('gor_add_respondents'); } + + /** + * Returns the $key in organizationData when set otherwise the default value + * + * @param string $key + * @param mixed $default + * @return mixed + */ + public function get($key, $default = null) + { + if (array_key_exists($key, $this->_data)) { + return $this->_data[$key]; + } else { + return $default; + } + } /** * Get the organizations this organizations can access. Modified: trunk/library/classes/Gems/User/UserLoader.php =================================================================== --- trunk/library/classes/Gems/User/UserLoader.php 2011-12-01 15:14:59 UTC (rev 325) +++ trunk/library/classes/Gems/User/UserLoader.php 2011-12-01 15:26:53 UTC (rev 326) @@ -189,7 +189,7 @@ list($defName, $userOrganization) = $this->getUserClassInfo($login_name, $currentOrganization); // MUtil_Echo::track($defName, $userOrganization); - $definition = $this->_getClass($defName); + $definition = $this->getUserDefinition($defName); $values = $definition->getUserData($login_name, $userOrganization); // MUtil_Echo::track($defName, $login_name, $userOrganization, $values); @@ -208,6 +208,20 @@ } /** + * Retrieve a userdefinition, so we can check it's capabilities without + * instantiating a user + * + * @param type $userClassName + * @return Gems_User_UserDefinitionInterface + */ + public function getUserDefinition($userClassName) + { + $definition = $this->_getClass($userClassName); + + return $definition; + } + + /** * Get a staff user using the $staff_id * * @param int $staff_id Modified: trunk/library/classes/Gems/Util/TrackData.php =================================================================== --- trunk/library/classes/Gems/Util/TrackData.php 2011-12-01 15:14:59 UTC (rev 325) +++ trunk/library/classes/Gems/Util/TrackData.php 2011-12-01 15:26:53 UTC (rev 326) @@ -95,6 +95,13 @@ return $surveys; } // */ + + /** + * Retrieve an array of key/value pairs for gsu_id_survey and gsu_survey_name + * + * @staticvar array $surveys + * @return array + */ public function getAllSurveys() { static $surveys; @@ -107,6 +114,23 @@ } /** + * Retrieve an array of key/value pairs for gsu_id_survey and gsu_survey_name plus gsu_survey_description + * + * @staticvar array $surveys + * @return array + */ + public function getAllSurveysAndDescriptions() + { + static $surveys; + + if (! $surveys) { + $surveys = $this->db->fetchPairs('SELECT gsu_id_survey, LEFT(CONCAT_WS(" - ", gsu_survey_name, gsu_survey_description),50) FROM gems__surveys ORDER BY gsu_survey_name'); + } + + return $surveys; + } + + /** * Returns array (id => name) of all tracks, sorted alphabetically * @return array */ Deleted: trunk/library/classes/Zend/Translate/Adapter.php =================================================================== --- branches/userloader/classes/Zend/Translate/Adapter.php 2011-12-01 14:57:08 UTC (rev 324) +++ trunk/library/classes/Zend/Translate/Adapter.php 2011-12-01 15:26:53 UTC (rev 326) @@ -1,999 +0,0 @@ -<?php -/** - * Zend Framework - * - * LICENSE - * - * This source file is subject to the new BSD license that is bundled - * with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://framework.zend.com/license/new-bsd - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to li...@ze... so we can send you a copy immediately. - * - * @category Zend - * @package Zend_Translate - * @subpackage Zend_Translate_Adapter - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Adapter.php 24268 2011-07-25 14:47:42Z guilhermeblanco $ - */ - -/** - * @see Zend_Locale - */ -require_once 'Zend/Locale.php'; - -/** - * @see Zend_Translate_Plural - */ -require_once 'Zend/Translate/Plural.php'; - -/** - * Basic adapter class for each translation source adapter - * - * THIS CLASS IS ALTERED FOR THE GEMSTRACKER PROJECT TO NEVER CACHE THE OPTIONS AS THEY CHANGE - * ON EVERY REQUEST AND THIS COUSES TROUBLE AS DESCRIBED AND IGNORED BY ZEND IN - * http://framework.zend.com/issues/browse/ZF-9850 - * - * @category Zend - * @package Zend_Translate - * @subpackage Zend_Translate_Adapter - * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) - * @license http://framework.zend.com/license/new-bsd New BSD License - */ -abstract class Zend_Translate_Adapter { - /** - * Shows if locale detection is in automatic level - * @var boolean - */ - private $_automatic = true; - - /** - * Internal value to see already routed languages - * @var array() - */ - private $_routed = array(); - - /** - * Internal cache for all adapters - * @var Zend_Cache_Core - */ - protected static $_cache = null; - - /** - * Internal value to remember if cache supports tags - * - * @var boolean - */ - private static $_cacheTags = false; - - /** - * Scans for the locale within the name of the directory - * @constant integer - */ - const LOCALE_DIRECTORY = 'directory'; - - /** - * Scans for the locale within the name of the file - * @constant integer - */ - const LOCALE_FILENAME = 'filename'; - - /** - * Array with all options, each adapter can have own additional options - * 'clear' => when true, clears already loaded translations when adding new files - * 'content' => content to translate or file or directory with content - * 'disableNotices' => when true, omits notices from being displayed - * 'ignore' => a prefix for files and directories which are not being added - * 'locale' => the actual set locale to use - * 'log' => a instance of Zend_Log where logs are written to - * 'logMessage' => message to be logged - * 'logPriority' => priority which is used to write the log message - * 'logUntranslated' => when true, untranslated messages are not logged - * 'reload' => reloads the cache by reading the content again - * 'scan' => searches for translation files using the LOCALE constants - * 'tag' => tag to use for the cache - * - * @var array - */ - protected $_options = array( - 'clear' => false, - 'content' => null, - 'disableNotices' => false, - 'ignore' => '.', - 'locale' => 'auto', - 'log' => null, - 'logMessage' => "Untranslated message within '%locale%': %message%", - 'logPriority' => 5, - 'logUntranslated' => false, - 'reload' => false, - 'route' => null, - 'scan' => null, - 'tag' => 'Zend_Translate' - ); - - /** - * Translation table - * @var array - */ - protected $_translate = array(); - - /** - * Generates the adapter - * - * @param array|Zend_Config $options Translation options for this adapter - * @throws Zend_Translate_Exception - * @return void - */ - public function __construct($options = array()) - { - if ($options instanceof Zend_Config) { - $options = $options->toArray(); - } else if (func_num_args() > 1) { - $args = func_get_args(); - $options = array(); - $options['content'] = array_shift($args); - - if (!empty($args)) { - $options['locale'] = array_shift($args); - } - - if (!empty($args)) { - $opt = array_shift($args); - $options = array_merge($opt, $options); - } - } else if (!is_array($options)) { - $options = array('content' => $options); - } - - if (array_key_exists('cache', $options)) { - self::setCache($options['cache']); - unset($options['cache']); - } - - /*if (isset(self::$_cache)) { - $id = 'Zend_Translate_' . $this->toString() . '_Options'; - $result = self::$_cache->load($id); - if ($result) { - $this->_options = $result; - } - }*/ - - if (empty($options['locale']) || ($options['locale'] === "auto")) { - $this->_automatic = true; - } else { - $this->_automatic = false; - } - - $locale = null; - if (!empty($options['locale'])) { - $locale = $options['locale']; - unset($options['locale']); - } - - $this->setOptions($options); - $options['locale'] = $locale; - - if (!empty($options['content'])) { - $this->addTranslation($options); - } - - if ($this->getLocale() !== (string) $options['locale']) { - $this->setLocale($options['locale']); - } - } - - /** - * Add translations - * - * This may be a new language or additional content for an existing language - * If the key 'clear' is true, then translations for the specified - * language will be replaced and added otherwise - * - * @param array|Zend_Config $options Options and translations to be added - * @throws Zend_Translate_Exception - * @return Zend_Translate_Adapter Provides fluent interface - */ - public function addTranslation($options = array()) - { - if ($options instanceof Zend_Config) { - $options = $options->toArray(); - } else if (func_num_args() > 1) { - $args = func_get_args(); - $options = array(); - $options['content'] = array_shift($args); - - if (!empty($args)) { - $options['locale'] = array_shift($args); - } - - if (!empty($args)) { - $opt = array_shift($args); - $options = array_merge($opt, $options); - } - } else if (!is_array($options)) { - $options = array('content' => $options); - } - - if (!isset($options['content']) || empty($options['content'])) { - require_once 'Zend/Translate/Exception.php'; - throw new Zend_Translate_Exception("Required option 'content' is missing"); - } - - $originate = null; - if (!empty($options['locale'])) { - $originate = (string) $options['locale']; - } - - if ((array_key_exists('log', $options)) && !($options['log'] instanceof Zend_Log)) { - require_once 'Zend/Translate/Exception.php'; - throw new Zend_Translate_Exception('Instance of Zend_Log expected for option log'); - } - - try { - if (!($options['content'] instanceof Zend_Translate) && !($options['content'] instanceof Zend_Translate_Adapter)) { - if (empty($options['locale'])) { - $options['locale'] = null; - } - - $options['locale'] = Zend_Locale::findLocale($options['locale']); - } - } catch (Zend_Locale_Exception $e) { - require_once 'Zend/Translate/Exception.php'; - throw new Zend_Translate_Exception("The given Language '{$options['locale']}' does not exist", 0, $e); - } - - $options = $options + $this->_options; - if (is_string($options['content']) and is_dir($options['content'])) { - $options['content'] = realpath($options['content']); - $prev = ''; - $iterator = new RecursiveIteratorIterator( - new RecursiveRegexIterator( - new RecursiveDirectoryIterator($options['content'], RecursiveDirectoryIterator::KEY_AS_PATHNAME), - '/^(?!.*(\.svn|\.cvs)).*$/', RecursiveRegexIterator::MATCH - ), - RecursiveIteratorIterator::SELF_FIRST - ); - - foreach ($iterator as $directory => $info) { - $file = $info->getFilename(); - if (is_array($options['ignore'])) { - foreach ($options['ignore'] as $key => $ignore) { - if (strpos($key, 'regex') !== false) { - if (preg_match($ignore, $directory)) { - // ignore files matching the given regex from option 'ignore' and all files below - continue 2; - } - } else if (strpos($directory, DIRECTORY_SEPARATOR . $ignore) !== false) { - // ignore files matching first characters from option 'ignore' and all files below - continue 2; - } - } - } else { - if (strpos($directory, DIRECTORY_SEPARATOR . $options['ignore']) !== false) { - // ignore files matching first characters from option 'ignore' and all files below - continue; - } - } - - if ($info->isDir()) { - // pathname as locale - if (($options['scan'] === self::LOCALE_DIRECTORY) and (Zend_Locale::isLocale($file, true, false))) { - $options['locale'] = $file; - $prev = (string) $options['locale']; - } - } else if ($info->isFile()) { - // filename as locale - if ($options['scan'] === self::LOCALE_FILENAME) { - $filename = explode('.', $file); - array_pop($filename); - $filename = implode('.', $filename); - if (Zend_Locale::isLocale((string) $filename, true, false)) { - $options['locale'] = (string) $filename; - } else { - $parts = explode('.', $file); - $parts2 = array(); - foreach($parts as $token) { - $parts2 += explode('_', $token); - } - $parts = array_merge($parts, $parts2); - $parts2 = array(); - foreach($parts as $token) { - $parts2 += explode('-', $token); - } - $parts = array_merge($parts, $parts2); - $parts = array_unique($parts); - $prev = ''; - foreach($parts as $token) { - if (Zend_Locale::isLocale($token, true, false)) { - if (strlen($prev) <= strlen($token)) { - $options['locale'] = $token; - $prev = $token; - } - } - } - } - } - - try { - $options['content'] = $info->getPathname(); - $this->_addTranslationData($options); - } catch (Zend_Translate_Exception $e) { - // ignore failed sources while scanning - } - } - } - - unset($iterator); - } else { - $this->_addTranslationData($options); - } - - if ((isset($this->_translate[$originate]) === true) and (count($this->_translate[$originate]) > 0)) { - $this->setLocale($originate); - } - - return $this; - } - - /** - * Sets new adapter options - * - * @param array $options Adapter options - * @throws Zend_Translate_Exception - * @return Zend_Translate_Adapter Provides fluent interface - */ - public function setOptions(array $options = array()) - { - $change = false; - $locale = null; - foreach ($options as $key => $option) { - if ($key == 'locale') { - $locale = $option; - } else if ((isset($this->_options[$key]) and ($this->_options[$key] != $option)) or - !isset($this->_options[$key])) { - if (($key == 'log') && !($option instanceof Zend_Log)) { - require_once 'Zend/Translate/Exception.php'; - throw new Zend_Translate_Exception('Instance of Zend_Log expected for option log'); - } - - if ($key == 'cache') { - self::setCache($option); - continue; - } - - $this->_options[$key] = $option; - $change = true; - } - } - - if ($locale !== null) { - $this->setLocale($locale); - } - - /*if (isset(self::$_cache) and ($change == true)) { - $id = 'Zend_Translate_' . $this->toString() . '_Options'; - if (self::$_cacheTags) { - self::$_cache->save($this->_options, $id, array($this->_options['tag'])); - } else { - self::$_cache->save($this->_options, $id); - } - }*/ - - return $this; - } - - /** - * Returns the adapters name and it's options - * - * @param string|null $optionKey String returns this option - * null returns all options - * @return integer|string|array|null - */ - public function getOptions($optionKey = null) - { - if ($optionKey === null) { - return $this->_options; - } - - if (isset($this->_options[$optionKey]) === true) { - return $this->_options[$optionKey]; - } - - return null; - } - - /** - * Gets locale - * - * @return Zend_Locale|string|null - */ - public function getLocale() - { - return $this->_options['locale']; - } - - /** - * Sets locale - * - * @param string|Zend_Locale $locale Locale to set - * @throws Zend_Translate_Exception - * @return Zend_Translate_Adapter Provides fluent interface - */ - public function setLocale($locale) - { - if (($locale === "auto") or ($locale === null)) { - $this->_automatic = true; - } else { - $this->_automatic = false; - } - - try { - $locale = Zend_Locale::findLocale($locale); - } catch (Zend_Locale_Exception $e) { - require_once 'Zend/Translate/Exception.php'; - throw new Zend_Translate_Exception("The given Language ({$locale}) does not exist", 0, $e); - } - - if (!isset($this->_translate[$locale])) { - $temp = explode('_', $locale); - if (!isset($this->_translate[$temp[0]]) and !isset($this->_translate[$locale])) { - if (!$this->_options['disableNotices']) { - if ($this->_options['log']) { - $this->_options['log']->log("The language '{$locale}' has to be added before it can be used.", $this->_options['logPriority']); - } else { - trigger_error("The language '{$locale}' has to be added before it can be used.", E_USER_NOTICE); - } - } - } - - $locale = $temp[0]; - } - - if (empty($this->_translate[$locale])) { - if (!$this->_options['disableNotices']) { - if ($this->_options['log']) { - $this->_options['log']->log("No translation for the language '{$locale}' available.", $this->_options['logPriority']); - } else { - trigger_error("No translation for the language '{$locale}' available.", E_USER_NOTICE); - } - } - } - - if ($this->_options['locale'] != $locale) { - $this->_options['locale'] = $locale; - - /*if (isset(self::$_cache)) { - $id = 'Zend_Translate_' . $this->toString() . '_Options'; - if (self::$_cacheTags) { - self::$_cache->save($this->_options, $id, array($this->_options['tag'])); - } else { - self::$_cache->save($this->_options, $id); - } - }*/ - } - - return $this; - } - - /** - * Returns the available languages from this adapter - * - * @return array|null - */ - public function getList() - { - $list = array_keys($this->_translate); - $result = null; - foreach($list as $value) { - if (!empty($this->_translate[$value])) { - $result[$value] = $value; - } - } - return $result; - } - - /** - * Returns the message id for a given translation - * If no locale is given, the actual language will be used - * - * @param string $message Message to get the key for - * @param string|Zend_Locale $locale (optional) Language to return the message ids from - * @return string|array|false - */ - public function getMessageId($message, $locale = null) - { - if (empty($locale) or !$this->isAvailable($locale)) { - $locale = $this->_options['locale']; - } - - return array_search($message, $this->_translate[(string) $locale]); - } - - /** - * Returns all available message ids from this adapter - * If no locale is given, the actual language will be used - * - * @param string|Zend_Locale $locale (optional) Language to return the message ids from - * @return array - */ - public function getMessageIds($locale = null) - { - if (empty($locale) or !$this->isAvailable($locale)) { - $locale = $this->_options['locale']; - } - - return array_keys($this->_translate[(string) $locale]); - } - - /** - * Returns all available translations from this adapter - * If no locale is given, the actual language will be used - * If 'all' is given the complete translation dictionary will be returned - * - * @param string|Zend_Locale $locale (optional) Language to return the messages from - * @return array - */ - public function getMessages($locale = null) - { - if ($locale === 'all') { - return $this->_translate; - } - - if ((empty($locale) === true) or ($this->isAvailable($locale) === false)) { - $locale = $this->_options['locale']; - } - - return $this->_translate[(string) $locale]; - } - - /** - * Is the wished language available ? - * - * @see Zend_Locale - * @param string|Zend_Locale $locale Language to search for, identical with locale identifier, - * @see Zend_Locale for more information - * @return boolean - */ - public function isAvailable($locale) - { - $return = isset($this->_translate[(string) $locale]); - return $return; - } - - /** - * Load translation data - * - * @param mixed $data - * @param string|Zend_Locale $locale - * @param array $options (optional) - * @return array - */ - abstract protected function _loadTranslationData($data, $locale, array $options = array()); - - /** - * Internal function for adding translation data - * - * This may be a new language or additional data for an existing language - * If the options 'clear' is true, then the translation data for the specified - * language is replaced and added otherwise - * - * @see Zend_Locale - * @param array|Zend_Config $content Translation data to add - * @throws Zend_Translate_Exception - * @return Zend_Translate_Adapter Provides fluent interface - */ - private function _addTranslationData($options = array()) - { - if ($options instanceof Zend_Config) { - $options = $options->toArray(); - } else if (func_num_args() > 1) { - $args = func_get_args(); - $options['content'] = array_shift($args); - - if (!empty($args)) { - $options['locale'] = array_shift($args); - } - - if (!empty($args)) { - $options += array_shift($args); - } - } - - if (($options['content'] instanceof Zend_Translate) || ($options['content'] instanceof Zend_Translate_Adapter)) { - $options['usetranslateadapter'] = true; - if (!empty($options['locale']) && ($options['locale'] !== 'auto')) { - $options['content'] = $options['content']->getMessages($options['locale']); - } else { - $content = $options['content']; - $locales = $content->getList(); - foreach ($locales as $locale) { - $options['locale'] = $locale; - $options['content'] = $content->getMessages($locale); - $this->_addTranslationData($options); - } - - return $this; - } - } - - try { - $options['locale'] = Zend_Locale::findLocale($options['locale']); - } catch (Zend_Locale_Exception $e) { - require_once 'Zend/Translate/Exception.php'; - throw new Zend_Translate_Exception("The given Language '{$options['locale']}' does not exist", 0, $e); - } - - if ($options['clear'] || !isset($this->_translate[$options['locale']])) { - $this->_translate[$options['locale']] = array(); - } - - $read = true; - if (isset(self::$_cache)) { - $id = 'Zend_Translate_' . md5(serialize($options['content'])) . '_' . $this->toString(); - $temp = self::$_cache->load($id); - if ($temp) { - $read = false; - } - } - - if ($options['reload']) { - $read = true; - } - - if ($read) { - if (!empty($options['usetranslateadapter'])) { - $temp = array($options['locale'] => $options['content']); - } else { - $temp = $this->_loadTranslationData($options['content'], $options['locale'], $options); - } - } - - if (empty($temp)) { - $temp = array(); - } - - $keys = array_keys($temp); - foreach($keys as $key) { - if (!isset($this->_translate[$key])) { - $this->_translate[$key] = array(); - } - - if (array_key_exists($key, $temp) && is_array($temp[$key])) { - $this->_translate[$key] = $temp[$key] + $this->_translate[$key]; - } - } - - if ($this->_automatic === true) { - $find = new Zend_Locale($options['locale']); - $browser = $find->getEnvironment() + $find->getBrowser(); - arsort($browser); - foreach($browser as $language => $quality) { - if (isset($this->_translate[$language])) { - $this->_options['locale'] = $language; - break; - } - } - } - - if (($read) and (isset(self::$_cache))) { - $id = 'Zend_Translate_' . md5(serialize($options['content'])) . '_' . $this->toString(); - if (self::$_cacheTags) { - self::$_cache->save($temp, $id, array($this->_options['tag'])); - } else { - self::$_cache->save($temp, $id); - } - } - - return $this; - } - - /** - * Translates the given string - * returns the translation - * - * @see Zend_Locale - * @param string|array $messageId Translation string, or Array for plural translations - * @param string|Zend_Locale $locale (optional) Locale/Language to use, identical with - * locale identifier, @see Zend_Locale for more information - * @return string - */ - public function translate($messageId, $locale = null) - { - if ($locale === null) { - $locale = $this->_options['locale']; - } - - $plural = null; - if (is_array($messageId)) { - if (count($messageId) > 2) { - $number = array_pop($messageId); - if (!is_numeric($number)) { - $plocale = $number; - $number = array_pop($messageId); - } else { - $plocale = 'en'; - } - - $plural = $messageId; - $messageId = $messageId[0]; - } else { - $messageId = $messageId[0]; - } - } - - if (!Zend_Locale::isLocale($locale, true, false)) { - if (!Zend_Locale::isLocale($locale, false, false)) { - // language does not exist, return original string - $this->_log($messageId, $locale); - // use rerouting when enabled - if (!empty($this->_options['route'])) { - if (array_key_exists($locale, $this->_options['route']) && - !array_key_exists($locale, $this->_routed)) { - $this->_routed[$locale] = true; - return $this->translate($messageId, $this->_options['route'][$locale]); - } - } - - $this->_routed = array(); - if ($plural === null) { - return $messageId; - } - - $rule = Zend_Translate_Plural::getPlural($number, $plocale); - if (!isset($plural[$rule])) { - $rule = 0; - } - - return $plural[$rule]; - } - - $locale = new Zend_Locale($locale); - } - - $locale = (string) $locale; - if ((is_string($messageId) || is_int($messageId)) && isset($this->_translate[$locale][$messageId])) { - // return original translation - if ($plural === null) { - $this->_routed = array(); - return $this->_translate[$locale][$messageId]; - } - - $rule = Zend_Translate_Plural::getPlural($number, $locale); - if (isset($this->_translate[$locale][$plural[0]][$rule])) { - $this->_routed = array(); - return $this->_translate[$locale][$plural[0]][$rule]; - } - } else if (strlen($locale) != 2) { - // faster than creating a new locale and separate the leading part - $locale = substr($locale, 0, -strlen(strrchr($locale, '_'))); - - if ((is_string($messageId) || is_int($messageId)) && isset($this->_translate[$locale][$messageId])) { - // return regionless translation (en_US -> en) - if ($plural === null) { - $this->_routed = array(); - return $this->_translate[$locale][$messageId]; - } - - $rule = Zend_Translate_Plural::getPlural($number, $locale); - if (isset($this->_translate[$locale][$plural[0]][$rule])) { - $this->_routed = array(); - return $this->_translate[$locale][$plural[0]][$rule]; - } - } - } - - $this->_log($messageId, $locale); - // use rerouting when enabled - if (!empty($this->_options['route'])) { - if (array_key_exists($locale, $this->_options['route']) && - !array_key_exists($locale, $this->_routed)) { - $this->_routed[$locale] = true; - return $this->translate($messageId, $this->_options['route'][$locale]); - } - } - - $this->_routed = array(); - if ($plural === null) { - return $messageId; - } - - $rule = Zend_Translate_Plural::getPlural($number, $plocale); - if (!isset($plural[$rule])) { - $rule = 0; - } - - return $plural[$rule]; - } - - /** - * Translates the given string using plural notations - * Returns the translated string - * - * @see Zend_Locale - * @param string $singular Singular translation string - * @param string $plural Plural translation string - * @param integer $number Number for detecting the correct plural - * @param string|Zend_Locale $locale (Optional) Locale/Language to use, identical with - * locale identifier, @see Zend_Locale for more information - * @return string - */ - public function plural($singular, $plural, $number, $locale = null) - { - return $this->translate(array($singular, $plural, $number), $locale); - } - - /** - * Logs a message when the log option is set - * - * @param string $message Message to log - * @param String $locale Locale to log - */ - protected function _log($message, $locale) { - if ($this->_options['logUntranslated']) { - $message = str_replace('%message%', $message, $this->_options['logMessage']); - $message = str_replace('%locale%', $locale, $message); - if ($this->_options['log']) { - $this->_options['log']->log($message, $this->_options['logPriority']); - } else { - trigger_error($message, E_USER_NOTICE); - } - } - } - - /** - * Translates the given string - * returns the translation - * - * @param string $messageId Translation string - * @param string|Zend_Locale $locale (optional) Locale/Language to use, identical with locale - * identifier, @see Zend_Locale for more information - * @return string - */ - public function _($messageId, $locale = null) - { - return $this->translate($messageId, $locale); - } - - /** - * Checks if a string is translated within the source or not - * returns boolean - * - * @param string $messageId Translation string - * @param boolean $original (optional) Allow translation only for original language - * when true, a translation for 'en_US' would give false when it can - * be translated with 'en' only - * @param string|Zend_Locale $locale (optional) Locale/Language to use, identical with locale identifier, - * see Zend_Locale for more information - * @return boolean - */ - public function isTranslated($messageId, $original = false, $locale = null) - { - if (($original !== false) and ($original !== true)) { - $locale = $original; - $original = false; - } - - if ($locale === null) { - $locale = $this->_options['locale']; - } - - if (!Zend_Locale::isLocale($locale, true, false)) { - if (!Zend_Locale::isLocale($locale, false, false)) { - // language does not exist, return original string - return false; - } - - $locale = new Zend_Locale($locale); - } - - $locale = (string) $locale; - if ((is_string($messageId) || is_int($messageId)) && isset($this->_translate[$locale][$messageId])) { - // return original translation - return true; - } else if ((strlen($locale) != 2) and ($original === false)) { - // faster than creating a new locale and separate the leading part - $locale = substr($locale, 0, -strlen(strrchr($locale, '_'))); - - if ((is_string($messageId) || is_int($messageId)) && isset($this->_translate[$locale][$messageId])) { - // return regionless translation (en_US -> en) - return true; - } - } - - // No translation found, return original - return false; - } - - /** - * Returns the set cache - * - * @return Zend_Cache_Core The set cache - */ - public static function getCache() - { - return self::$_cache; - } - - /** - * Sets a cache for all Zend_Translate_Adapters - * - * @param Zend_Cache_Core $cache Cache to store to - */ - public static function setCache(Zend_Cache_Core $cache) - { - self::$_cache = $cache; - self::_getTagSupportForCache(); - } - - /** - * Returns true when a cache is set - * - * @return boolean - */ - public static function hasCache() - { - if (self::$_cache !== null) { - return true; - } - - return false; - } - - /** - * Removes any set cache - * - * @return void - */ - public static function removeCache() - { - self::$_cache = null; - } - - /** - * Clears all set cache data - * - * @param string $tag Tag to clear when the default tag name is not used - * @return void - */ - public static function clearCache($tag = null) - { - require_once 'Zend/Cache.php'; - if (self::$_cacheTags) { - if ($tag == null) { - $tag = 'Zend_Translate'; - } - - self::$_cache->clean(Zend_Cache::CLEANING_MODE_MATCHING_TAG, array($tag)); - } else { - self::$_cache->clean(Zend_Cache::CLEANING_MODE_ALL); - } - } - - /** - * Returns the adapter name - * - * @return string - */ - abstract public function toString(); - - /** - * Internal method to check if the given cache supports tags - * - * @param Zend_Cache $cache - */ - private static function _getTagSupportForCache() - { - $backend = self::$_cache->getBackend(); - if ($backend instanceof Zend_Cache_Backend_ExtendedInterface) { - $cacheOptions = $backend->getCapabilities(); - self::$_cacheTags = $cacheOptions['tags']; - } else { - self::$_cacheTags = false; - } - - return self::$_cacheTags; - } -} \ No newline at end of file Copied: trunk/library/classes/Zend/Translate/Adapter.php (from rev 324, branches/userloader/classes/Zend/Translate/Adapter.php) =================================================================== --- trunk/library/classes/Zend/Translate/Adapter.php (rev 0) +++ trunk/library/classes/Zend/Translate/Adapter.php 2011-12-01 15:26:53 UTC (rev 326) @@ -0,0 +1,999 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to li...@ze... so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Translate + * @subpackage Zend_Translate_Adapter + * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id: Adapter.php 24268 2011-07-25 14:47:42Z guilhermeblanco $ + */ + +/** + * @see Zend_Locale + */ +require_once 'Zend/Locale.php'; + +/** + * @see Zend_Translate_Plural + */ +require_once 'Zend/Translate/Plural.php'; + +/** + * Basic adapter class for each translation source adapter + * + * THIS CLASS IS ALTERED FOR THE GEMSTRACKER PROJECT TO NEVER CACHE THE OPTIONS AS THEY CHANGE + * ON EVERY REQUEST AND THIS COUSES TROUBLE AS DESCRIBED AND IGNORED BY ZEND IN + * http://framework.zend.com/issues/browse/ZF-9850 + * + * @category Zend + * @package Zend_Translate + * @subpackage Zend_Translate_Adapter + * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + */ +abstract class Zend_Translate_Adapter { + /** + * Shows if locale detection is in automatic level + * @var boolean + */ + private $_automatic = true; + + /** + * Internal value to see already routed languages + * @var array() + */ + private $_routed = array(); + + /** + * Internal cache for all adapters + * @var Zend_Cache_Core + */ + protected static $_cache = null; + + /** + * Internal value to remember if cache supports tags + * + * @var boolean + */ + private static $_cacheTags = false; + + /** + * Scans for the locale within the name of the directory + * @constant integer + */ + const LOCALE_DIRECTORY = 'directory'; + + /** + * Scans for the locale within the name of the file + * @constant integer + */ + const LOCALE_FILENAME = 'filename'; + + /** + * Array with all options, each adapter can have own additional options + * 'clear' => when true, clears already loaded translations when adding new files + * 'content' => content to translate or file or directory with content + * 'disableNotices' => when true, omits notices from being displayed + * 'ignore' => a prefix for files and directories which are not being added + * 'locale' => the actual set locale to use + * 'log' => a instance of Zend_Log where logs are written to + * 'logMessage' => message to be logged + * 'logPriority' => priority which is used to write the log message + * 'logUntranslated' => when true, untranslated messages are not logged + * 'reload' => reloads the cache by reading the content again + * 'scan' => searches for translation files using the LOCALE constants + * 'tag' => tag to use for the cache + * + * @var array + */ + protected $_options = array( + 'clear' => false, + 'content' => null, + 'disableNotices' => false, + 'ignore' => '.', + 'locale' => 'auto', + 'log' => null, + 'logMessage' => "Untranslated message within '%locale%': %message%", + 'logPriority' => 5, + 'logUntranslated' => false, + 'reload' => false, + 'route' => null, + 'scan' => null, + 'tag' => 'Zend_Translate' + ); + + /** + * Translation table + * @var array + */ + protected $_translate = array(); + + /** + * Generates the adapter + * + * @param array|Zend_Config $options Translation options for this adapter + * @throws Zend_Translate_Exception + * @return void + */ + public function __construct($options = array()) + { + if ($options instanceof Zend_Config) { + $options = $options->toArray(); + } else if (func_num_args() > 1) { + $args = func_get_args(); + $options = array(); + $options['content'] = array_shift($args); + + if (!empty($args)) { + $options['locale'] = array_shift($args); + } + + if (!empty($args)) { + $opt = array_shift($args); + $options = array_merge($opt, $options); + } + } else if (!is_array($options)) { + $options = array('content' => $options); + } + + if (array_key_exists('cache', $options)) { + self::setCache($options['cache']); + unset($options['cache']); + } + + /*if (isset(self::$_cache)) { + $id = 'Zend_Translate_' . $this->toString() . '_Options'; + $result = self::$_cache->load($id); + if ($result) { + $this->_options = $result; + } + }*/ + + if (empty($options['locale']) || ($options['locale'] === "auto")) { + $this->_automatic = true; + } else { + $this->_automatic = false; + } + + $locale = null; + if (!empty($options['locale'])) { + $locale = $options['locale']; + unset($options['locale']); + } + + $this->setOptions($options); + $options['locale'] = $locale; + + if (!empty($options['content'])) { + $this->addTranslation($options); + } + + if ($this->getLocale() !== (string) $options['locale']) { + $this->setLocale($options['locale']); + } + } + + /** + * Add translations + * + * This may be a new language or additional content for an existing language + * If the key 'clear' is true, then translations for the specified + * language will be replaced and ad... [truncated message content] |
From: <gem...@li...> - 2011-12-01 15:15:06
|
Revision: 325 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=325&view=rev Author: matijsdejong Date: 2011-12-01 15:14:59 +0000 (Thu, 01 Dec 2011) Log Message: ----------- Removed filter for surveys of other track types. Modified Paths: -------------- branches/1.5.0-pulse/library/classes/Gems/Default/TokenPlanAction.php Modified: branches/1.5.0-pulse/library/classes/Gems/Default/TokenPlanAction.php =================================================================== --- branches/1.5.0-pulse/library/classes/Gems/Default/TokenPlanAction.php 2011-12-01 14:57:08 UTC (rev 324) +++ branches/1.5.0-pulse/library/classes/Gems/Default/TokenPlanAction.php 2011-12-01 15:14:59 UTC (rev 325) @@ -308,7 +308,6 @@ WHERE gsu_active=1 AND gro_active=1 AND gtr_active=1 AND - gtr_track_type='T' AND INSTR(gtr_organizations, '|$orgId|') > 0"; /* TODO: use this when we can update this list using ajax if (isset($data['gsu_id_primary_group'])) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2011-12-01 14:57:17
|
Revision: 324 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=324&view=rev Author: matijsdejong Date: 2011-12-01 14:57:08 +0000 (Thu, 01 Dec 2011) Log Message: ----------- Inactive rounds that are not being answered are now removed from existing tracks, when checking them. Modified Paths: -------------- branches/1.5.0-pulse/library/classes/Gems/Tracker/ChangeTracker.php branches/1.5.0-pulse/library/classes/Gems/Tracker/Engine/TrackEngineAbstract.php Modified: branches/1.5.0-pulse/library/classes/Gems/Tracker/ChangeTracker.php =================================================================== --- branches/1.5.0-pulse/library/classes/Gems/Tracker/ChangeTracker.php 2011-12-01 11:59:09 UTC (rev 323) +++ branches/1.5.0-pulse/library/classes/Gems/Tracker/ChangeTracker.php 2011-12-01 14:57:08 UTC (rev 324) @@ -27,7 +27,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...> @@ -49,6 +49,7 @@ public $checkedTokens = 0; public $createdTokens = 0; public $checkedRespondentTracks = 0; + public $deletedTokens = 0; public $resultDataChanges = 0; public $roundChangeUpdates = 0; public $roundCompletionCauses = 0; @@ -82,6 +83,9 @@ if ($this->roundChangeUpdates) { $messages[] = sprintf($t->_('Round changes propagated to %d tokens.'), $this->roundChangeUpdates); } + if ($this->deletedTokens) { + $messages[] = sprintf($t->_('%d tokens deleted by round changes.'), $this->deletedTokens); + } if ($this->createdTokens) { $messages[] = sprintf($t->_('%d tokens created to by round changes.'), $this->createdTokens); } Modified: branches/1.5.0-pulse/library/classes/Gems/Tracker/Engine/TrackEngineAbstract.php =================================================================== --- branches/1.5.0-pulse/library/classes/Gems/Tracker/Engine/TrackEngineAbstract.php 2011-12-01 11:59:09 UTC (rev 323) +++ branches/1.5.0-pulse/library/classes/Gems/Tracker/Engine/TrackEngineAbstract.php 2011-12-01 14:57:08 UTC (rev 324) @@ -248,6 +248,7 @@ $sql = "SELECT gro_id_round, gro_id_survey, gro_id_order, gro_round_description FROM gems__rounds WHERE gro_id_track = ? AND + gro_active = 1 AND gro_id_round NOT IN (SELECT gto_id_round FROM gems__tokens WHERE gto_id_respondent_track = ?) ORDER BY gro_id_order"; @@ -389,10 +390,13 @@ //Step one: update existing tokens $changes->roundChangeUpdates += $this->checkExistingRoundsFor($respTrack, $userId); - // Step two: create lacking tokens + //Step two: deactivate inactive rounds + $changes->deletedTokens += $this->removeInactiveRounds($respTrack, $userId); + + // Step three: create lacking tokens $changes->createdTokens += $this->addNewTokens($respTrack, $userId); - // Step three: set the dates and times + // Step four: set the dates and times $changed = $this->checkTokensFromStart($respTrack, $userId); if ($changed) { $changes->tokenDateCauses++; @@ -758,6 +762,28 @@ } /** + * Remove the unanswered tokens for inactive rounds. + * + * @param Gems_Tracker_RespondentTrack $respTrack The respondent track to check + * @param int $userId Id of the user who takes the action (for logging) + * @return int The number of tokens changed by this code + */ + protected function removeInactiveRounds(Gems_Tracker_RespondentTrack $respTrack, $userId) + { + $qTrackId = $this->db->quote($this->_trackId); + $qRespTrackId = $this->db->quote($respTrack->getRespondentTrackId()); + + $where = "gto_start_time IS NULL AND + gto_id_respondent_track = $qRespTrackId AND + gto_id_round IN (SELECT gro_id_round + FROM gems__rounds + WHERE gro_active = 0 AND + gro_id_track = $qTrackId)"; + + return $this->db->delete('gems__tokens', $where); + } + + /** * Saves the field data for the respondent track id. * * @param int $respTrackId Gems respondent track id This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2011-12-01 11:59:16
|
Revision: 323 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=323&view=rev Author: matijsdejong Date: 2011-12-01 11:59:09 +0000 (Thu, 01 Dec 2011) Log Message: ----------- Bugfix: parameter source object did not handle array sources Modified Paths: -------------- branches/1.5.0-pulse/library/classes/Gems/Menu/ParameterCollector.php Modified: branches/1.5.0-pulse/library/classes/Gems/Menu/ParameterCollector.php =================================================================== --- branches/1.5.0-pulse/library/classes/Gems/Menu/ParameterCollector.php 2011-12-01 10:43:40 UTC (rev 322) +++ branches/1.5.0-pulse/library/classes/Gems/Menu/ParameterCollector.php 2011-12-01 11:59:09 UTC (rev 323) @@ -51,10 +51,19 @@ public function __construct() { - $sources = MUtil_Ra::flatten(func_get_args()); - foreach ($sources as $source) { - $this->addSource($source); + $sources = MUtil_Ra::args(func_get_args()); + $array = array(); + foreach ($sources as $key => $source) { + // Fix for array sources. + if (is_string($key)) { + $array[$key] = $source; + } else { + $this->addSource($source); + } } + if ($array) { + $this->addSource($array); + } } public function addSource($source) @@ -92,6 +101,7 @@ $this->values[$name] = $source->__get($name); } elseif (is_array($source)) { + MUtil_Echo::track($name, $source); if (isset($source[$name])) { $this->values[$name] = $source[$name]; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2011-12-01 10:43:49
|
Revision: 322 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=322&view=rev Author: matijsdejong Date: 2011-12-01 10:43:40 +0000 (Thu, 01 Dec 2011) Log Message: ----------- Documentation fix and extra parameter for FormBridge Modified Paths: -------------- branches/1.5.0-pulse/library/classes/MUtil/Model/FormBridge.php branches/1.5.0-pulse/library/classes/MUtil/Model/Type/ConcatenatedRow.php Modified: branches/1.5.0-pulse/library/classes/MUtil/Model/FormBridge.php =================================================================== --- branches/1.5.0-pulse/library/classes/MUtil/Model/FormBridge.php 2011-12-01 08:20:54 UTC (rev 321) +++ branches/1.5.0-pulse/library/classes/MUtil/Model/FormBridge.php 2011-12-01 10:43:40 UTC (rev 322) @@ -80,7 +80,7 @@ self::AUTO_OPTIONS => array('elementClass'), self::CHECK_OPTIONS => array('checkedValue', 'uncheckedValue'), self::DATE_OPTIONS => array('dateFormat', 'storageFormat'), - self::DISPLAY_OPTIONS => array('accesskey', 'class', 'disabled', 'description', 'escape', 'label', 'onclick', 'readonly', 'required', 'tabindex'), + self::DISPLAY_OPTIONS => array('accesskey', 'autoInsertNotEmptyValidator', 'class', 'disabled', 'description', 'escape', 'label', 'onclick', 'readonly', 'required', 'tabindex'), self::EXHIBIT_OPTIONS => array('formatFunction'), self::FILE_OPTIONS => array('accept', 'count', 'destination', 'valueDisabled'), self::GROUP_OPTIONS => array('elements', 'legend', 'separator'), Modified: branches/1.5.0-pulse/library/classes/MUtil/Model/Type/ConcatenatedRow.php =================================================================== --- branches/1.5.0-pulse/library/classes/MUtil/Model/Type/ConcatenatedRow.php 2011-12-01 08:20:54 UTC (rev 321) +++ branches/1.5.0-pulse/library/classes/MUtil/Model/Type/ConcatenatedRow.php 2011-12-01 10:43:40 UTC (rev 322) @@ -86,7 +86,7 @@ } /** - * A ModelAbstract->setOnSave() function that concatenates the + * A ModelAbstract->setOnLoad() function that concatenates the * value if it is an array. * * @see Gems_Model_ModelAbstract This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2011-12-01 08:21:00
|
Revision: 321 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=321&view=rev Author: mennodekker Date: 2011-12-01 08:20:54 +0000 (Thu, 01 Dec 2011) Log Message: ----------- Don't cache options as they change a lot, see http://framework.zend.com/issues/browse/ZF-9850 Modified Paths: -------------- branches/userloader/classes/Zend/Translate/Adapter.php Modified: branches/userloader/classes/Zend/Translate/Adapter.php =================================================================== --- branches/userloader/classes/Zend/Translate/Adapter.php 2011-12-01 08:14:56 UTC (rev 320) +++ branches/userloader/classes/Zend/Translate/Adapter.php 2011-12-01 08:20:54 UTC (rev 321) @@ -33,6 +33,10 @@ /** * Basic adapter class for each translation source adapter * + * THIS CLASS IS ALTERED FOR THE GEMSTRACKER PROJECT TO NEVER CACHE THE OPTIONS AS THEY CHANGE + * ON EVERY REQUEST AND THIS COUSES TROUBLE AS DESCRIBED AND IGNORED BY ZEND IN + * http://framework.zend.com/issues/browse/ZF-9850 + * * @category Zend * @package Zend_Translate * @subpackage Zend_Translate_Adapter @@ -149,13 +153,13 @@ unset($options['cache']); } - if (isset(self::$_cache)) { + /*if (isset(self::$_cache)) { $id = 'Zend_Translate_' . $this->toString() . '_Options'; $result = self::$_cache->load($id); if ($result) { $this->_options = $result; } - } + }*/ if (empty($options['locale']) || ($options['locale'] === "auto")) { $this->_automatic = true; @@ -369,14 +373,14 @@ $this->setLocale($locale); } - if (isset(self::$_cache) and ($change == true)) { + /*if (isset(self::$_cache) and ($change == true)) { $id = 'Zend_Translate_' . $this->toString() . '_Options'; if (self::$_cacheTags) { self::$_cache->save($this->_options, $id, array($this->_options['tag'])); } else { self::$_cache->save($this->_options, $id); } - } + }*/ return $this; } @@ -461,14 +465,14 @@ if ($this->_options['locale'] != $locale) { $this->_options['locale'] = $locale; - if (isset(self::$_cache)) { + /*if (isset(self::$_cache)) { $id = 'Zend_Translate_' . $this->toString() . '_Options'; if (self::$_cacheTags) { self::$_cache->save($this->_options, $id, array($this->_options['tag'])); } else { self::$_cache->save($this->_options, $id); } - } + }*/ } return $this; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2011-12-01 08:15:03
|
Revision: 320 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=320&view=rev Author: mennodekker Date: 2011-12-01 08:14:56 +0000 (Thu, 01 Dec 2011) Log Message: ----------- Original Zend_Translate_Adapter to be modified later Added Paths: ----------- branches/userloader/classes/Zend/ branches/userloader/classes/Zend/Translate/ branches/userloader/classes/Zend/Translate/Adapter.php Added: branches/userloader/classes/Zend/Translate/Adapter.php =================================================================== --- branches/userloader/classes/Zend/Translate/Adapter.php (rev 0) +++ branches/userloader/classes/Zend/Translate/Adapter.php 2011-12-01 08:14:56 UTC (rev 320) @@ -0,0 +1,995 @@ +<?php +/** + * Zend Framework + * + * LICENSE + * + * This source file is subject to the new BSD license that is bundled + * with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://framework.zend.com/license/new-bsd + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to li...@ze... so we can send you a copy immediately. + * + * @category Zend + * @package Zend_Translate + * @subpackage Zend_Translate_Adapter + * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + * @version $Id: Adapter.php 24268 2011-07-25 14:47:42Z guilhermeblanco $ + */ + +/** + * @see Zend_Locale + */ +require_once 'Zend/Locale.php'; + +/** + * @see Zend_Translate_Plural + */ +require_once 'Zend/Translate/Plural.php'; + +/** + * Basic adapter class for each translation source adapter + * + * @category Zend + * @package Zend_Translate + * @subpackage Zend_Translate_Adapter + * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + */ +abstract class Zend_Translate_Adapter { + /** + * Shows if locale detection is in automatic level + * @var boolean + */ + private $_automatic = true; + + /** + * Internal value to see already routed languages + * @var array() + */ + private $_routed = array(); + + /** + * Internal cache for all adapters + * @var Zend_Cache_Core + */ + protected static $_cache = null; + + /** + * Internal value to remember if cache supports tags + * + * @var boolean + */ + private static $_cacheTags = false; + + /** + * Scans for the locale within the name of the directory + * @constant integer + */ + const LOCALE_DIRECTORY = 'directory'; + + /** + * Scans for the locale within the name of the file + * @constant integer + */ + const LOCALE_FILENAME = 'filename'; + + /** + * Array with all options, each adapter can have own additional options + * 'clear' => when true, clears already loaded translations when adding new files + * 'content' => content to translate or file or directory with content + * 'disableNotices' => when true, omits notices from being displayed + * 'ignore' => a prefix for files and directories which are not being added + * 'locale' => the actual set locale to use + * 'log' => a instance of Zend_Log where logs are written to + * 'logMessage' => message to be logged + * 'logPriority' => priority which is used to write the log message + * 'logUntranslated' => when true, untranslated messages are not logged + * 'reload' => reloads the cache by reading the content again + * 'scan' => searches for translation files using the LOCALE constants + * 'tag' => tag to use for the cache + * + * @var array + */ + protected $_options = array( + 'clear' => false, + 'content' => null, + 'disableNotices' => false, + 'ignore' => '.', + 'locale' => 'auto', + 'log' => null, + 'logMessage' => "Untranslated message within '%locale%': %message%", + 'logPriority' => 5, + 'logUntranslated' => false, + 'reload' => false, + 'route' => null, + 'scan' => null, + 'tag' => 'Zend_Translate' + ); + + /** + * Translation table + * @var array + */ + protected $_translate = array(); + + /** + * Generates the adapter + * + * @param array|Zend_Config $options Translation options for this adapter + * @throws Zend_Translate_Exception + * @return void + */ + public function __construct($options = array()) + { + if ($options instanceof Zend_Config) { + $options = $options->toArray(); + } else if (func_num_args() > 1) { + $args = func_get_args(); + $options = array(); + $options['content'] = array_shift($args); + + if (!empty($args)) { + $options['locale'] = array_shift($args); + } + + if (!empty($args)) { + $opt = array_shift($args); + $options = array_merge($opt, $options); + } + } else if (!is_array($options)) { + $options = array('content' => $options); + } + + if (array_key_exists('cache', $options)) { + self::setCache($options['cache']); + unset($options['cache']); + } + + if (isset(self::$_cache)) { + $id = 'Zend_Translate_' . $this->toString() . '_Options'; + $result = self::$_cache->load($id); + if ($result) { + $this->_options = $result; + } + } + + if (empty($options['locale']) || ($options['locale'] === "auto")) { + $this->_automatic = true; + } else { + $this->_automatic = false; + } + + $locale = null; + if (!empty($options['locale'])) { + $locale = $options['locale']; + unset($options['locale']); + } + + $this->setOptions($options); + $options['locale'] = $locale; + + if (!empty($options['content'])) { + $this->addTranslation($options); + } + + if ($this->getLocale() !== (string) $options['locale']) { + $this->setLocale($options['locale']); + } + } + + /** + * Add translations + * + * This may be a new language or additional content for an existing language + * If the key 'clear' is true, then translations for the specified + * language will be replaced and added otherwise + * + * @param array|Zend_Config $options Options and translations to be added + * @throws Zend_Translate_Exception + * @return Zend_Translate_Adapter Provides fluent interface + */ + public function addTranslation($options = array()) + { + if ($options instanceof Zend_Config) { + $options = $options->toArray(); + } else if (func_num_args() > 1) { + $args = func_get_args(); + $options = array(); + $options['content'] = array_shift($args); + + if (!empty($args)) { + $options['locale'] = array_shift($args); + } + + if (!empty($args)) { + $opt = array_shift($args); + $options = array_merge($opt, $options); + } + } else if (!is_array($options)) { + $options = array('content' => $options); + } + + if (!isset($options['content']) || empty($options['content'])) { + require_once 'Zend/Translate/Exception.php'; + throw new Zend_Translate_Exception("Required option 'content' is missing"); + } + + $originate = null; + if (!empty($options['locale'])) { + $originate = (string) $options['locale']; + } + + if ((array_key_exists('log', $options)) && !($options['log'] instanceof Zend_Log)) { + require_once 'Zend/Translate/Exception.php'; + throw new Zend_Translate_Exception('Instance of Zend_Log expected for option log'); + } + + try { + if (!($options['content'] instanceof Zend_Translate) && !($options['content'] instanceof Zend_Translate_Adapter)) { + if (empty($options['locale'])) { + $options['locale'] = null; + } + + $options['locale'] = Zend_Locale::findLocale($options['locale']); + } + } catch (Zend_Locale_Exception $e) { + require_once 'Zend/Translate/Exception.php'; + throw new Zend_Translate_Exception("The given Language '{$options['locale']}' does not exist", 0, $e); + } + + $options = $options + $this->_options; + if (is_string($options['content']) and is_dir($options['content'])) { + $options['content'] = realpath($options['content']); + $prev = ''; + $iterator = new RecursiveIteratorIterator( + new RecursiveRegexIterator( + new RecursiveDirectoryIterator($options['content'], RecursiveDirectoryIterator::KEY_AS_PATHNAME), + '/^(?!.*(\.svn|\.cvs)).*$/', RecursiveRegexIterator::MATCH + ), + RecursiveIteratorIterator::SELF_FIRST + ); + + foreach ($iterator as $directory => $info) { + $file = $info->getFilename(); + if (is_array($options['ignore'])) { + foreach ($options['ignore'] as $key => $ignore) { + if (strpos($key, 'regex') !== false) { + if (preg_match($ignore, $directory)) { + // ignore files matching the given regex from option 'ignore' and all files below + continue 2; + } + } else if (strpos($directory, DIRECTORY_SEPARATOR . $ignore) !== false) { + // ignore files matching first characters from option 'ignore' and all files below + continue 2; + } + } + } else { + if (strpos($directory, DIRECTORY_SEPARATOR . $options['ignore']) !== false) { + // ignore files matching first characters from option 'ignore' and all files below + continue; + } + } + + if ($info->isDir()) { + // pathname as locale + if (($options['scan'] === self::LOCALE_DIRECTORY) and (Zend_Locale::isLocale($file, true, false))) { + $options['locale'] = $file; + $prev = (string) $options['locale']; + } + } else if ($info->isFile()) { + // filename as locale + if ($options['scan'] === self::LOCALE_FILENAME) { + $filename = explode('.', $file); + array_pop($filename); + $filename = implode('.', $filename); + if (Zend_Locale::isLocale((string) $filename, true, false)) { + $options['locale'] = (string) $filename; + } else { + $parts = explode('.', $file); + $parts2 = array(); + foreach($parts as $token) { + $parts2 += explode('_', $token); + } + $parts = array_merge($parts, $parts2); + $parts2 = array(); + foreach($parts as $token) { + $parts2 += explode('-', $token); + } + $parts = array_merge($parts, $parts2); + $parts = array_unique($parts); + $prev = ''; + foreach($parts as $token) { + if (Zend_Locale::isLocale($token, true, false)) { + if (strlen($prev) <= strlen($token)) { + $options['locale'] = $token; + $prev = $token; + } + } + } + } + } + + try { + $options['content'] = $info->getPathname(); + $this->_addTranslationData($options); + } catch (Zend_Translate_Exception $e) { + // ignore failed sources while scanning + } + } + } + + unset($iterator); + } else { + $this->_addTranslationData($options); + } + + if ((isset($this->_translate[$originate]) === true) and (count($this->_translate[$originate]) > 0)) { + $this->setLocale($originate); + } + + return $this; + } + + /** + * Sets new adapter options + * + * @param array $options Adapter options + * @throws Zend_Translate_Exception + * @return Zend_Translate_Adapter Provides fluent interface + */ + public function setOptions(array $options = array()) + { + $change = false; + $locale = null; + foreach ($options as $key => $option) { + if ($key == 'locale') { + $locale = $option; + } else if ((isset($this->_options[$key]) and ($this->_options[$key] != $option)) or + !isset($this->_options[$key])) { + if (($key == 'log') && !($option instanceof Zend_Log)) { + require_once 'Zend/Translate/Exception.php'; + throw new Zend_Translate_Exception('Instance of Zend_Log expected for option log'); + } + + if ($key == 'cache') { + self::setCache($option); + continue; + } + + $this->_options[$key] = $option; + $change = true; + } + } + + if ($locale !== null) { + $this->setLocale($locale); + } + + if (isset(self::$_cache) and ($change == true)) { + $id = 'Zend_Translate_' . $this->toString() . '_Options'; + if (self::$_cacheTags) { + self::$_cache->save($this->_options, $id, array($this->_options['tag'])); + } else { + self::$_cache->save($this->_options, $id); + } + } + + return $this; + } + + /** + * Returns the adapters name and it's options + * + * @param string|null $optionKey String returns this option + * null returns all options + * @return integer|string|array|null + */ + public function getOptions($optionKey = null) + { + if ($optionKey === null) { + return $this->_options; + } + + if (isset($this->_options[$optionKey]) === true) { + return $this->_options[$optionKey]; + } + + return null; + } + + /** + * Gets locale + * + * @return Zend_Locale|string|null + */ + public function getLocale() + { + return $this->_options['locale']; + } + + /** + * Sets locale + * + * @param string|Zend_Locale $locale Locale to set + * @throws Zend_Translate_Exception + * @return Zend_Translate_Adapter Provides fluent interface + */ + public function setLocale($locale) + { + if (($locale === "auto") or ($locale === null)) { + $this->_automatic = true; + } else { + $this->_automatic = false; + } + + try { + $locale = Zend_Locale::findLocale($locale); + } catch (Zend_Locale_Exception $e) { + require_once 'Zend/Translate/Exception.php'; + throw new Zend_Translate_Exception("The given Language ({$locale}) does not exist", 0, $e); + } + + if (!isset($this->_translate[$locale])) { + $temp = explode('_', $locale); + if (!isset($this->_translate[$temp[0]]) and !isset($this->_translate[$locale])) { + if (!$this->_options['disableNotices']) { + if ($this->_options['log']) { + $this->_options['log']->log("The language '{$locale}' has to be added before it can be used.", $this->_options['logPriority']); + } else { + trigger_error("The language '{$locale}' has to be added before it can be used.", E_USER_NOTICE); + } + } + } + + $locale = $temp[0]; + } + + if (empty($this->_translate[$locale])) { + if (!$this->_options['disableNotices']) { + if ($this->_options['log']) { + $this->_options['log']->log("No translation for the language '{$locale}' available.", $this->_options['logPriority']); + } else { + trigger_error("No translation for the language '{$locale}' available.", E_USER_NOTICE); + } + } + } + + if ($this->_options['locale'] != $locale) { + $this->_options['locale'] = $locale; + + if (isset(self::$_cache)) { + $id = 'Zend_Translate_' . $this->toString() . '_Options'; + if (self::$_cacheTags) { + self::$_cache->save($this->_options, $id, array($this->_options['tag'])); + } else { + self::$_cache->save($this->_options, $id); + } + } + } + + return $this; + } + + /** + * Returns the available languages from this adapter + * + * @return array|null + */ + public function getList() + { + $list = array_keys($this->_translate); + $result = null; + foreach($list as $value) { + if (!empty($this->_translate[$value])) { + $result[$value] = $value; + } + } + return $result; + } + + /** + * Returns the message id for a given translation + * If no locale is given, the actual language will be used + * + * @param string $message Message to get the key for + * @param string|Zend_Locale $locale (optional) Language to return the message ids from + * @return string|array|false + */ + public function getMessageId($message, $locale = null) + { + if (empty($locale) or !$this->isAvailable($locale)) { + $locale = $this->_options['locale']; + } + + return array_search($message, $this->_translate[(string) $locale]); + } + + /** + * Returns all available message ids from this adapter + * If no locale is given, the actual language will be used + * + * @param string|Zend_Locale $locale (optional) Language to return the message ids from + * @return array + */ + public function getMessageIds($locale = null) + { + if (empty($locale) or !$this->isAvailable($locale)) { + $locale = $this->_options['locale']; + } + + return array_keys($this->_translate[(string) $locale]); + } + + /** + * Returns all available translations from this adapter + * If no locale is given, the actual language will be used + * If 'all' is given the complete translation dictionary will be returned + * + * @param string|Zend_Locale $locale (optional) Language to return the messages from + * @return array + */ + public function getMessages($locale = null) + { + if ($locale === 'all') { + return $this->_translate; + } + + if ((empty($locale) === true) or ($this->isAvailable($locale) === false)) { + $locale = $this->_options['locale']; + } + + return $this->_translate[(string) $locale]; + } + + /** + * Is the wished language available ? + * + * @see Zend_Locale + * @param string|Zend_Locale $locale Language to search for, identical with locale identifier, + * @see Zend_Locale for more information + * @return boolean + */ + public function isAvailable($locale) + { + $return = isset($this->_translate[(string) $locale]); + return $return; + } + + /** + * Load translation data + * + * @param mixed $data + * @param string|Zend_Locale $locale + * @param array $options (optional) + * @return array + */ + abstract protected function _loadTranslationData($data, $locale, array $options = array()); + + /** + * Internal function for adding translation data + * + * This may be a new language or additional data for an existing language + * If the options 'clear' is true, then the translation data for the specified + * language is replaced and added otherwise + * + * @see Zend_Locale + * @param array|Zend_Config $content Translation data to add + * @throws Zend_Translate_Exception + * @return Zend_Translate_Adapter Provides fluent interface + */ + private function _addTranslationData($options = array()) + { + if ($options instanceof Zend_Config) { + $options = $options->toArray(); + } else if (func_num_args() > 1) { + $args = func_get_args(); + $options['content'] = array_shift($args); + + if (!empty($args)) { + $options['locale'] = array_shift($args); + } + + if (!empty($args)) { + $options += array_shift($args); + } + } + + if (($options['content'] instanceof Zend_Translate) || ($options['content'] instanceof Zend_Translate_Adapter)) { + $options['usetranslateadapter'] = true; + if (!empty($options['locale']) && ($options['locale'] !== 'auto')) { + $options['content'] = $options['content']->getMessages($options['locale']); + } else { + $content = $options['content']; + $locales = $content->getList(); + foreach ($locales as $locale) { + $options['locale'] = $locale; + $options['content'] = $content->getMessages($locale); + $this->_addTranslationData($options); + } + + return $this; + } + } + + try { + $options['locale'] = Zend_Locale::findLocale($options['locale']); + } catch (Zend_Locale_Exception $e) { + require_once 'Zend/Translate/Exception.php'; + throw new Zend_Translate_Exception("The given Language '{$options['locale']}' does not exist", 0, $e); + } + + if ($options['clear'] || !isset($this->_translate[$options['locale']])) { + $this->_translate[$options['locale']] = array(); + } + + $read = true; + if (isset(self::$_cache)) { + $id = 'Zend_Translate_' . md5(serialize($options['content'])) . '_' . $this->toString(); + $temp = self::$_cache->load($id); + if ($temp) { + $read = false; + } + } + + if ($options['reload']) { + $read = true; + } + + if ($read) { + if (!empty($options['usetranslateadapter'])) { + $temp = array($options['locale'] => $options['content']); + } else { + $temp = $this->_loadTranslationData($options['content'], $options['locale'], $options); + } + } + + if (empty($temp)) { + $temp = array(); + } + + $keys = array_keys($temp); + foreach($keys as $key) { + if (!isset($this->_translate[$key])) { + $this->_translate[$key] = array(); + } + + if (array_key_exists($key, $temp) && is_array($temp[$key])) { + $this->_translate[$key] = $temp[$key] + $this->_translate[$key]; + } + } + + if ($this->_automatic === true) { + $find = new Zend_Locale($options['locale']); + $browser = $find->getEnvironment() + $find->getBrowser(); + arsort($browser); + foreach($browser as $language => $quality) { + if (isset($this->_translate[$language])) { + $this->_options['locale'] = $language; + break; + } + } + } + + if (($read) and (isset(self::$_cache))) { + $id = 'Zend_Translate_' . md5(serialize($options['content'])) . '_' . $this->toString(); + if (self::$_cacheTags) { + self::$_cache->save($temp, $id, array($this->_options['tag'])); + } else { + self::$_cache->save($temp, $id); + } + } + + return $this; + } + + /** + * Translates the given string + * returns the translation + * + * @see Zend_Locale + * @param string|array $messageId Translation string, or Array for plural translations + * @param string|Zend_Locale $locale (optional) Locale/Language to use, identical with + * locale identifier, @see Zend_Locale for more information + * @return string + */ + public function translate($messageId, $locale = null) + { + if ($locale === null) { + $locale = $this->_options['locale']; + } + + $plural = null; + if (is_array($messageId)) { + if (count($messageId) > 2) { + $number = array_pop($messageId); + if (!is_numeric($number)) { + $plocale = $number; + $number = array_pop($messageId); + } else { + $plocale = 'en'; + } + + $plural = $messageId; + $messageId = $messageId[0]; + } else { + $messageId = $messageId[0]; + } + } + + if (!Zend_Locale::isLocale($locale, true, false)) { + if (!Zend_Locale::isLocale($locale, false, false)) { + // language does not exist, return original string + $this->_log($messageId, $locale); + // use rerouting when enabled + if (!empty($this->_options['route'])) { + if (array_key_exists($locale, $this->_options['route']) && + !array_key_exists($locale, $this->_routed)) { + $this->_routed[$locale] = true; + return $this->translate($messageId, $this->_options['route'][$locale]); + } + } + + $this->_routed = array(); + if ($plural === null) { + return $messageId; + } + + $rule = Zend_Translate_Plural::getPlural($number, $plocale); + if (!isset($plural[$rule])) { + $rule = 0; + } + + return $plural[$rule]; + } + + $locale = new Zend_Locale($locale); + } + + $locale = (string) $locale; + if ((is_string($messageId) || is_int($messageId)) && isset($this->_translate[$locale][$messageId])) { + // return original translation + if ($plural === null) { + $this->_routed = array(); + return $this->_translate[$locale][$messageId]; + } + + $rule = Zend_Translate_Plural::getPlural($number, $locale); + if (isset($this->_translate[$locale][$plural[0]][$rule])) { + $this->_routed = array(); + return $this->_translate[$locale][$plural[0]][$rule]; + } + } else if (strlen($locale) != 2) { + // faster than creating a new locale and separate the leading part + $locale = substr($locale, 0, -strlen(strrchr($locale, '_'))); + + if ((is_string($messageId) || is_int($messageId)) && isset($this->_translate[$locale][$messageId])) { + // return regionless translation (en_US -> en) + if ($plural === null) { + $this->_routed = array(); + return $this->_translate[$locale][$messageId]; + } + + $rule = Zend_Translate_Plural::getPlural($number, $locale); + if (isset($this->_translate[$locale][$plural[0]][$rule])) { + $this->_routed = array(); + return $this->_translate[$locale][$plural[0]][$rule]; + } + } + } + + $this->_log($messageId, $locale); + // use rerouting when enabled + if (!empty($this->_options['route'])) { + if (array_key_exists($locale, $this->_options['route']) && + !array_key_exists($locale, $this->_routed)) { + $this->_routed[$locale] = true; + return $this->translate($messageId, $this->_options['route'][$locale]); + } + } + + $this->_routed = array(); + if ($plural === null) { + return $messageId; + } + + $rule = Zend_Translate_Plural::getPlural($number, $plocale); + if (!isset($plural[$rule])) { + $rule = 0; + } + + return $plural[$rule]; + } + + /** + * Translates the given string using plural notations + * Returns the translated string + * + * @see Zend_Locale + * @param string $singular Singular translation string + * @param string $plural Plural translation string + * @param integer $number Number for detecting the correct plural + * @param string|Zend_Locale $locale (Optional) Locale/Language to use, identical with + * locale identifier, @see Zend_Locale for more information + * @return string + */ + public function plural($singular, $plural, $number, $locale = null) + { + return $this->translate(array($singular, $plural, $number), $locale); + } + + /** + * Logs a message when the log option is set + * + * @param string $message Message to log + * @param String $locale Locale to log + */ + protected function _log($message, $locale) { + if ($this->_options['logUntranslated']) { + $message = str_replace('%message%', $message, $this->_options['logMessage']); + $message = str_replace('%locale%', $locale, $message); + if ($this->_options['log']) { + $this->_options['log']->log($message, $this->_options['logPriority']); + } else { + trigger_error($message, E_USER_NOTICE); + } + } + } + + /** + * Translates the given string + * returns the translation + * + * @param string $messageId Translation string + * @param string|Zend_Locale $locale (optional) Locale/Language to use, identical with locale + * identifier, @see Zend_Locale for more information + * @return string + */ + public function _($messageId, $locale = null) + { + return $this->translate($messageId, $locale); + } + + /** + * Checks if a string is translated within the source or not + * returns boolean + * + * @param string $messageId Translation string + * @param boolean $original (optional) Allow translation only for original language + * when true, a translation for 'en_US' would give false when it can + * be translated with 'en' only + * @param string|Zend_Locale $locale (optional) Locale/Language to use, identical with locale identifier, + * see Zend_Locale for more information + * @return boolean + */ + public function isTranslated($messageId, $original = false, $locale = null) + { + if (($original !== false) and ($original !== true)) { + $locale = $original; + $original = false; + } + + if ($locale === null) { + $locale = $this->_options['locale']; + } + + if (!Zend_Locale::isLocale($locale, true, false)) { + if (!Zend_Locale::isLocale($locale, false, false)) { + // language does not exist, return original string + return false; + } + + $locale = new Zend_Locale($locale); + } + + $locale = (string) $locale; + if ((is_string($messageId) || is_int($messageId)) && isset($this->_translate[$locale][$messageId])) { + // return original translation + return true; + } else if ((strlen($locale) != 2) and ($original === false)) { + // faster than creating a new locale and separate the leading part + $locale = substr($locale, 0, -strlen(strrchr($locale, '_'))); + + if ((is_string($messageId) || is_int($messageId)) && isset($this->_translate[$locale][$messageId])) { + // return regionless translation (en_US -> en) + return true; + } + } + + // No translation found, return original + return false; + } + + /** + * Returns the set cache + * + * @return Zend_Cache_Core The set cache + */ + public static function getCache() + { + return self::$_cache; + } + + /** + * Sets a cache for all Zend_Translate_Adapters + * + * @param Zend_Cache_Core $cache Cache to store to + */ + public static function setCache(Zend_Cache_Core $cache) + { + self::$_cache = $cache; + self::_getTagSupportForCache(); + } + + /** + * Returns true when a cache is set + * + * @return boolean + */ + public static function hasCache() + { + if (self::$_cache !== null) { + return true; + } + + return false; + } + + /** + * Removes any set cache + * + * @return void + */ + public static function removeCache() + { + self::$_cache = null; + } + + /** + * Clears all set cache data + * + * @param string $tag Tag to clear when the default tag name is not used + * @return void + */ + public static function clearCache($tag = null) + { + require_once 'Zend/Cache.php'; + if (self::$_cacheTags) { + if ($tag == null) { + $tag = 'Zend_Translate'; + } + + self::$_cache->clean(Zend_Cache::CLEANING_MODE_MATCHING_TAG, array($tag)); + } else { + self::$_cache->clean(Zend_Cache::CLEANING_MODE_ALL); + } + } + + /** + * Returns the adapter name + * + * @return string + */ + abstract public function toString(); + + /** + * Internal method to check if the given cache supports tags + * + * @param Zend_Cache $cache + */ + private static function _getTagSupportForCache() + { + $backend = self::$_cache->getBackend(); + if ($backend instanceof Zend_Cache_Backend_ExtendedInterface) { + $cacheOptions = $backend->getCapabilities(); + self::$_cacheTags = $cacheOptions['tags']; + } else { + self::$_cacheTags = false; + } + + return self::$_cacheTags; + } +} \ 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-30 21:57:16
|
Revision: 319 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=319&view=rev Author: michieltcs Date: 2011-11-30 21:57:10 +0000 (Wed, 30 Nov 2011) Log Message: ----------- Only call toArray() on non-null object Modified Paths: -------------- branches/1.5.0-pulse/library/classes/MUtil/Model/DatabaseModelAbstract.php Modified: branches/1.5.0-pulse/library/classes/MUtil/Model/DatabaseModelAbstract.php =================================================================== --- branches/1.5.0-pulse/library/classes/MUtil/Model/DatabaseModelAbstract.php 2011-11-30 13:19:06 UTC (rev 318) +++ branches/1.5.0-pulse/library/classes/MUtil/Model/DatabaseModelAbstract.php 2011-11-30 21:57:10 UTC (rev 319) @@ -417,12 +417,14 @@ $wheres[] = $adapter->quoteInto($text, $value); } // Retrieve the record from the database - $oldValues = $table->fetchRow('(' . implode(' ) AND (', $wheres) . ')')->toArray(); + $oldValues = $table->fetchRow('(' . implode(' ) AND (', $wheres) . ')'); if (! $oldValues) { // MUtil_Echo::r('INSERT!!', 'Old not found'); // Apparently the record does not exist in the database $update = false; + } else { + $oldValues = $oldValues->toArray(); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2011-11-30 13:19:17
|
Revision: 318 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=318&view=rev Author: mennodekker Date: 2011-11-30 13:19:06 +0000 (Wed, 30 Nov 2011) Log Message: ----------- Added TODO after seeing a lot of notices that are fixed in the previous commit and having troubles in unit testing Modified Paths: -------------- branches/userloader/classes/Gems/Project/ProjectSettings.php Modified: branches/userloader/classes/Gems/Project/ProjectSettings.php =================================================================== --- branches/userloader/classes/Gems/Project/ProjectSettings.php 2011-11-30 13:14:29 UTC (rev 317) +++ branches/userloader/classes/Gems/Project/ProjectSettings.php 2011-11-30 13:19:06 UTC (rev 318) @@ -97,6 +97,8 @@ parent::__construct($array, ArrayObject::ARRAY_AS_PROPS); + //@@TODO: some checks should not be done on each and every request! + // this can be a problem when testing $this->checkRequiredValues(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2011-11-30 13:14:40
|
Revision: 317 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=317&view=rev Author: mennodekker Date: 2011-11-30 13:14:29 +0000 (Wed, 30 Nov 2011) Log Message: ----------- Fixing notices Modified Paths: -------------- branches/userloader/classes/Gems/Project/ProjectSettings.php Modified: branches/userloader/classes/Gems/Project/ProjectSettings.php =================================================================== --- branches/userloader/classes/Gems/Project/ProjectSettings.php 2011-11-30 10:33:50 UTC (rev 316) +++ branches/userloader/classes/Gems/Project/ProjectSettings.php 2011-11-30 13:14:29 UTC (rev 317) @@ -268,7 +268,7 @@ */ public function getSuperAdminName() { - if (isset($this->admin['user'])) { + if (isset($this->admin) && isset($this->admin['user'])) { return $this->admin['user']; } } @@ -280,7 +280,7 @@ */ protected function getSuperAdminPassword() { - if (isset($this->admin['pwd'])) { + if (isset($this->admin) && isset($this->admin['pwd'])) { return $this->admin['pwd']; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2011-11-30 10:33:56
|
Revision: 316 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=316&view=rev Author: matijsdejong Date: 2011-11-30 10:33:50 +0000 (Wed, 30 Nov 2011) Log Message: ----------- Updated version numbers Really solved problem with staff deletion. Database models are more stable now. Modified Paths: -------------- branches/1.5.0-pulse/library/classes/Gems/Model.php branches/1.5.0-pulse/library/classes/Gems/Versions.php branches/1.5.0-pulse/library/classes/MUtil/Model/DatabaseModelAbstract.php branches/1.5.0-pulse/library/classes/MUtil/Model/JoinModel.php branches/1.5.0-pulse/library/classes/MUtil/Version.php Modified: branches/1.5.0-pulse/library/classes/Gems/Model.php =================================================================== --- branches/1.5.0-pulse/library/classes/Gems/Model.php 2011-11-29 16:26:57 UTC (rev 315) +++ branches/1.5.0-pulse/library/classes/Gems/Model.php 2011-11-30 10:33:50 UTC (rev 316) @@ -105,6 +105,7 @@ protected function addUserLogin(Gems_Model_JoinModel $model, $loginField, $organizationField) { $model->addTable('gems__user_logins', array($loginField => 'gul_login', $organizationField => 'gul_id_organization'), 'gul'); + $model->setTableKeysToJoin('gems__user_logins'); } /** Modified: branches/1.5.0-pulse/library/classes/Gems/Versions.php =================================================================== --- branches/1.5.0-pulse/library/classes/Gems/Versions.php 2011-11-29 16:26:57 UTC (rev 315) +++ branches/1.5.0-pulse/library/classes/Gems/Versions.php 2011-11-30 10:33:50 UTC (rev 316) @@ -43,7 +43,7 @@ { public final function getBuild() { - return 42; + return 43; } public final function getGemsVersion() Modified: branches/1.5.0-pulse/library/classes/MUtil/Model/DatabaseModelAbstract.php =================================================================== --- branches/1.5.0-pulse/library/classes/MUtil/Model/DatabaseModelAbstract.php 2011-11-29 16:26:57 UTC (rev 315) +++ branches/1.5.0-pulse/library/classes/MUtil/Model/DatabaseModelAbstract.php 2011-11-30 10:33:50 UTC (rev 316) @@ -244,6 +244,11 @@ return $this->_filterDataForSave($tableData, $isNew); } + /** + * + * @param string $table_name Does not test for existence + * @return array Numeric array containing the key field names. + */ protected function _getKeysFor($table_name) { $keys = array(); @@ -277,7 +282,7 @@ { $table_name = $this->_getTableName($table); - // MUtil_Echo::r($table->info('metadata')); + // MUtil_Echo::track($table->info('metadata')); foreach ($table->info('metadata') as $field) { $name = $field['COLUMN_NAME']; $finfo = array('table' => $table_name); @@ -406,12 +411,15 @@ if ($update) { // MUtil_Echo::r($filter, 'Filter'); + $adapter = $this->getAdapter(); + $wheres = array(); + foreach ($filter as $text => $value) { + $wheres[] = $adapter->quoteInto($text, $value); + } // Retrieve the record from the database - $oldValueSet = call_user_func_array(array($table, 'find'), $filter); + $oldValues = $table->fetchRow('(' . implode(' ) AND (', $wheres) . ')')->toArray(); - if ($oldValueSet->count()) { - $oldValues = $oldValueSet->current()->toArray(); - } else { + if (! $oldValues) { // MUtil_Echo::r('INSERT!!', 'Old not found'); // Apparently the record does not exist in the database $update = false; @@ -441,14 +449,19 @@ // Update the row if ($changed = $table->update($returnValues, $filter)) { $this->addChanged($changed); - return $this->_updateCopyKeys($primaryKeys, $returnValues); + // Make sure the copy keys (if any) have the new values as well + $returnValues = $this->_updateCopyKeys($primaryKeys, $returnValues); + + // Add the old values as we have them and they may be of use later on. + $returnValues = $returnValues + $oldValues; + + return $returnValues; } } } } - // No changes were made, return empty array. - // The non-abstract child class should take care - // of returning the original values. + // Add the old values as we have them and they may be of use later on. + return $returnValues + $oldValues; } else { // Perform insert @@ -782,6 +795,12 @@ // abstract public function save(array $newValues); + /** + * Function to turn database insertion on or off for this model. + * + * @param boolean $value + * @return MUtil_Model_DatabaseModelAbstract (continuation pattern) + */ public function setCreate($value = true) { $this->canCreate = (bool) $value; @@ -795,7 +814,7 @@ * @param mxied $value1 * @param string $field2 * @param mixed $key2 - * @return MUtil_Model_TableModel + * @return MUtil_Model_DatabaseModelAbstract (continuation pattern) */ public function setDeleteValues($arrayOrField1 = null, $value1 = null, $field2 = null, $key2 = null) { @@ -804,6 +823,15 @@ return $this; } + /** + * When passed an array this method set the keys of this database object + * to those keys. + * When passed a string it is assumed to be a table name and the keys of + * this object are set to those of that table. + * + * @param mixed $keysOrTableName array or string + * @return MUtil_Model_DatabaseModelAbstract (continuation pattern) + */ public function setKeysToTable($keysOrTableName) { if (is_string($keysOrTableName)) { @@ -812,8 +840,17 @@ $keys = $keysOrTableName; } $this->setKeys($keys); + + return $this; } + /** + * Changes the key copy string that is used to create a new identifier + * for keys. + * + * @param string $value A sting of at least 3 characters containing %s. + * @return MUtil_Model_DatabaseModelAbstract (continuation pattern) + */ public function setKeyCopier($value = self::KEY_COPIER) { $this->keyCopier = $value; Modified: branches/1.5.0-pulse/library/classes/MUtil/Model/JoinModel.php =================================================================== --- branches/1.5.0-pulse/library/classes/MUtil/Model/JoinModel.php 2011-11-29 16:26:57 UTC (rev 315) +++ branches/1.5.0-pulse/library/classes/MUtil/Model/JoinModel.php 2011-11-30 10:33:50 UTC (rev 316) @@ -292,9 +292,40 @@ /** * * @param string $table_name Does not test for existence - * @param bool $saveable Will changes to this table be saved - * @return MUtil_Model_JoinModel + * @return MUtil_Model_JoinModel (continuation pattern) */ + public function setTableKeysToJoin($table_name) + { + $origKeys = $this->_getKeysFor($table_name); + + // First remove old keys + foreach ($origKeys as $key) { + $this->del($key, 'key'); + } + + foreach ($this->_joinFields as $left => $right) { + if (is_string($left) && $this->is($left, 'table', $table_name)) { + $this->set($left, 'key', true); + } + if (is_string($right) && $this->is($right, 'table', $table_name)) { + $this->set($right, 'key', true); + } + } + + return $this; + } + + /** + * Add the table to the default save tables. + * + * Only tables marked as save tables are saved during a save() or delete(), + * unless this is overuled by the extra parameter for those functions in + * this object. + * + * @param string $table_name Does not test for existence + * @param boolean $saveable Will changes to this table be saved + * @return MUtil_Model_JoinModel (continuation pattern) + */ public function setTableSaveable($table_name, $saveable = true) { // MUtil_Echo::r(func_get_args(), __CLASS__ . '->' . __FUNCTION__); Modified: branches/1.5.0-pulse/library/classes/MUtil/Version.php =================================================================== --- branches/1.5.0-pulse/library/classes/MUtil/Version.php 2011-11-29 16:26:57 UTC (rev 315) +++ branches/1.5.0-pulse/library/classes/MUtil/Version.php 2011-11-30 10:33:50 UTC (rev 316) @@ -1,40 +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 MUtil */ class MUtil_Version { const MAJOR = 1; const MINOR = 0; - const BUILD = 28; + const BUILD = 30; public static function get() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2011-11-29 16:27:03
|
Revision: 315 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=315&view=rev Author: matijsdejong Date: 2011-11-29 16:26:57 +0000 (Tue, 29 Nov 2011) Log Message: ----------- Reverted changed, they removed the error, but did not solve the problem. The problem on deleting staff is something low level in JoinModel and I'm thinking about how to solve it. Modified Paths: -------------- branches/1.5.0-pulse/library/classes/MUtil/Model/JoinModel.php branches/1.5.0-pulse/library/configs/db/patches.sql Modified: branches/1.5.0-pulse/library/classes/MUtil/Model/JoinModel.php =================================================================== --- branches/1.5.0-pulse/library/classes/MUtil/Model/JoinModel.php 2011-11-29 14:55:15 UTC (rev 314) +++ branches/1.5.0-pulse/library/classes/MUtil/Model/JoinModel.php 2011-11-29 16:26:57 UTC (rev 315) @@ -175,6 +175,7 @@ $filter = $this->_checkFilterUsed($filter); if ($this->_deleteValues) { + // MUtil_Model::$verbose = true; $changed = $this->save($this->_deleteValues + $filter, $filter, $saveTables); } else { $changed = 0; @@ -255,8 +256,7 @@ $oldChanged = $this->getChanged(); - // MUtil_Echo::r($newValues, __CLASS__ . '->' . __FUNCTION__); - // MUtil_Echo::r($saveTables, __CLASS__ . '->' . __FUNCTION__); + // MUtil_Echo::track($newValues, $filter, $saveTables, $this->_joinFields); $oldValues = $newValues; foreach ($saveTables as $table_name) { @@ -265,6 +265,7 @@ // Use is_string as $target and $target can be e.g. a Zend_Db_Expr() object if (! (is_string($target) && isset($newValues[$target]) && $newValues[$target])) { if (! (is_string($source) && isset($newValues[$source]) && $newValues[$source])) { + // MUtil_Echo::track('Missing: ' . $source . ' -> ' . $target); continue; } $newValues[$target] = $newValues[$source]; @@ -276,8 +277,8 @@ //$this->_saveTableData returns the new row values, including any automatic changes. $newValues = $this->_saveTableData($this->_tables[$table_name], $newValues, $filter) + $oldValues; + // MUtil_Echo::track($oldValues, $newValues); $oldValues = $newValues; - // MUtil_Echo::r($newValues, 'JoinModel, after: ' . $table_name); } // If anything has changed, it counts as only one item for the user. Modified: branches/1.5.0-pulse/library/configs/db/patches.sql =================================================================== --- branches/1.5.0-pulse/library/configs/db/patches.sql 2011-11-29 14:55:15 UTC (rev 314) +++ branches/1.5.0-pulse/library/configs/db/patches.sql 2011-11-29 16:26:57 UTC (rev 315) @@ -353,7 +353,3 @@ grc_changed, grc_changed_by, grc_created, grc_created_by) VALUES ('stop', 'Stop surveys', 0, 2, 0, 0, 0, 0, 1, CURRENT_TIMESTAMP, 1, CURRENT_TIMESTAMP, 1); - --- PATCH: Defaults for non-null columns -ALTER TABLE `gems__user_logins` CHANGE `gul_login` `gul_login` varchar(30) CHARACTER SET 'utf8' COLLATE 'utf8_general_ci' not null default ''; -ALTER TABLE `gems__user_logins` CHANGE `gul_id_organization` `gul_id_organization` bigint not null default 0; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2011-11-29 14:55:26
|
Revision: 314 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=314&view=rev Author: michieltcs Date: 2011-11-29 14:55:15 +0000 (Tue, 29 Nov 2011) Log Message: ----------- Set defaults for non-null columns in gems__user_logins Modified Paths: -------------- branches/1.5.0-pulse/library/configs/db/patches.sql Modified: branches/1.5.0-pulse/library/configs/db/patches.sql =================================================================== --- branches/1.5.0-pulse/library/configs/db/patches.sql 2011-11-29 11:38:22 UTC (rev 313) +++ branches/1.5.0-pulse/library/configs/db/patches.sql 2011-11-29 14:55:15 UTC (rev 314) @@ -353,3 +353,7 @@ grc_changed, grc_changed_by, grc_created, grc_created_by) VALUES ('stop', 'Stop surveys', 0, 2, 0, 0, 0, 0, 1, CURRENT_TIMESTAMP, 1, CURRENT_TIMESTAMP, 1); + +-- PATCH: Defaults for non-null columns +ALTER TABLE `gems__user_logins` CHANGE `gul_login` `gul_login` varchar(30) CHARACTER SET 'utf8' COLLATE 'utf8_general_ci' not null default ''; +ALTER TABLE `gems__user_logins` CHANGE `gul_id_organization` `gul_id_organization` bigint not null default 0; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2011-11-29 11:38:32
|
Revision: 313 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=313&view=rev Author: matijsdejong Date: 2011-11-29 11:38:22 +0000 (Tue, 29 Nov 2011) Log Message: ----------- Fixes for MGZ tracker isses 461, 457 en een begin voor 456 Modified Paths: -------------- branches/1.5.0-pulse/library/classes/Gems/Default/StaffAction.php branches/1.5.0-pulse/library/classes/GemsEscort.php branches/1.5.0-pulse/library/configs/db/patches.sql branches/1.5.0-pulse/library/configs/db/tables/gems__organizations.20.sql Modified: branches/1.5.0-pulse/library/classes/Gems/Default/StaffAction.php =================================================================== --- branches/1.5.0-pulse/library/classes/Gems/Default/StaffAction.php 2011-11-29 11:15:11 UTC (rev 312) +++ branches/1.5.0-pulse/library/classes/Gems/Default/StaffAction.php 2011-11-29 11:38:22 UTC (rev 313) @@ -166,6 +166,7 @@ $bridge->addText( 'gsf_email', array('size' => 30))->addValidator('SimpleEmail')->addValidator($model->createUniqueValidator('gsf_email')); $bridge->addSelect('gsf_id_primary_group'); + $bridge->addCheckbox('gul_can_login', 'description', $this->_('Users can only login when this box is checked.')); $bridge->addCheckbox('gsf_logout_on_survey', 'description', $this->_('If checked the user will logoff when answering a survey.')); $bridge->addSelect('gsf_iso_lang'); @@ -222,10 +223,11 @@ if ($detailed) { $model->set('gul_user_class', 'default', $this->defaultStaffDefinition); $model->set('gsf_iso_lang', 'label', $this->_('Language'), 'multiOptions', $this->util->getLocalized()->getLanguages()); + $model->set('gul_can_login', 'label', $this->_('Can login'), 'multiOptions', $this->util->getTranslated()->getYesNo()); $model->set('gsf_logout_on_survey', 'label', $this->_('Logout on survey'), 'multiOptions', $this->util->getTranslated()->getYesNo()); } - $model->setDeleteValues('gsf_active', 0); + $model->setDeleteValues('gsf_active', 0, 'gul_can_login', 0); return $model; } Modified: branches/1.5.0-pulse/library/classes/GemsEscort.php =================================================================== --- branches/1.5.0-pulse/library/classes/GemsEscort.php 2011-11-29 11:15:11 UTC (rev 312) +++ branches/1.5.0-pulse/library/classes/GemsEscort.php 2011-11-29 11:38:22 UTC (rev 313) @@ -797,7 +797,7 @@ protected function _layoutOrganizationSwitcher() // Gems_Project_Organization_MultiOrganizationInterface { $user = $this->getLoader()->getCurrentUser(); - if ($orgs = $user->getAllowedOrganizations()) { + if ($user->isActive() && ($orgs = $user->getAllowedOrganizations())) { // Organization switcher $orgSwitch = MUtil_Html::create('div', array('id' => 'organizations')); $currentId = $user->getCurrentOrganizationId(); Modified: branches/1.5.0-pulse/library/configs/db/patches.sql =================================================================== --- branches/1.5.0-pulse/library/configs/db/patches.sql 2011-11-29 11:15:11 UTC (rev 312) +++ branches/1.5.0-pulse/library/configs/db/patches.sql 2011-11-29 11:38:22 UTC (rev 313) @@ -331,6 +331,8 @@ UPDATE `gems__organizations` SET gor_has_login = COALESCE((SELECT 1 FROM gems__staff WHERE gsf_id_organization = gor_id_organization GROUP BY gsf_id_organization), 0); +ALTER TABLE `gems__organizations` CHANGE `gor_has_respondents` `gor_has_respondents` TINYINT( 1 ) NOT NULL DEFAULT '0'; + -- PATCH: Log failed logins INSERT INTO `gems__log_actions` (`glac_id_action`, `glac_name`, `glac_change`, `glac_log`, `glac_created`) VALUES (NULL , 'loginFail', '0', '1', CURRENT_TIMESTAMP); Modified: branches/1.5.0-pulse/library/configs/db/tables/gems__organizations.20.sql =================================================================== --- branches/1.5.0-pulse/library/configs/db/tables/gems__organizations.20.sql 2011-11-29 11:15:11 UTC (rev 312) +++ branches/1.5.0-pulse/library/configs/db/tables/gems__organizations.20.sql 2011-11-29 11:38:22 UTC (rev 313) @@ -21,7 +21,7 @@ not null default 'en' references gems__languages (gml_iso_lang), gor_has_login boolean not null default 1, - gor_has_respondents boolean not null default 1, + gor_has_respondents boolean not null default 0, gor_add_respondents boolean not null default 1, gor_respondent_group bigint unsigned references gems__groups (ggp_id_group) null, gor_active boolean not null default 1, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2011-11-29 11:15:22
|
Revision: 312 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=312&view=rev Author: michieltcs Date: 2011-11-29 11:15:11 +0000 (Tue, 29 Nov 2011) Log Message: ----------- Merge Modified Paths: -------------- trunk/library/classes/Gems/User/Organization.php Property Changed: ---------------- trunk/ trunk/library/ trunk/library/classes/Gems/User/UserPasswordValidator.php Property changes on: trunk ___________________________________________________________________ Added: svn:mergeinfo + /branches/1.5.0-pulse:306-311 /tags/1.5.0beta1:305 Property changes on: trunk/library ___________________________________________________________________ Modified: svn:mergeinfo - /branches/newUser:113-150 /branches/newUser2:175-207 + /branches/1.5.0-pulse/library:306-311 /branches/newUser:113-150 /branches/newUser2:175-207 /tags/1.5.0beta1/library:305 Modified: trunk/library/classes/Gems/User/Organization.php =================================================================== --- trunk/library/classes/Gems/User/Organization.php 2011-11-29 10:58:17 UTC (rev 311) +++ trunk/library/classes/Gems/User/Organization.php 2011-11-29 11:15:11 UTC (rev 312) @@ -195,17 +195,21 @@ $data = $this->db->fetchRow($sql, $id); if ($data) { - $dbOrgId = $this->db->quote($id, Zend_Db::INT_TYPE); - $sql = "SELECT gor_id_organization, gor_name - FROM gems__organizations - WHERE gor_active = 1 AND - ( - gor_id_organization = $dbOrgId OR - gor_accessible_by LIKE '%:$dbOrgId:%' - ) - ORDER BY gor_name"; - $data['can_access'] = $this->db->fetchPairs($sql); - natsort($data['can_access']); + try { + $dbOrgId = $this->db->quote($id, Zend_Db::INT_TYPE); + $sql = "SELECT gor_id_organization, gor_name + FROM gems__organizations + WHERE gor_active = 1 AND + ( + gor_id_organization = $dbOrgId OR + gor_accessible_by LIKE '%:$dbOrgId:%' + ) + ORDER BY gor_name"; + $data['can_access'] = $this->db->fetchPairs($sql); + natsort($data['can_access']); + } catch (Exception $e) { + $data['can_access'] = array(); + } // MUtil_Echo::track($sql, $data['can_access']); } else { Property changes on: trunk/library/classes/Gems/User/UserPasswordValidator.php ___________________________________________________________________ Deleted: svn:mergeinfo - /branches/newUser/classes/Gems/User/UserPasswordValidator.php:113-150 /branches/newUser2/classes/Gems/User/UserPasswordValidator.php:175-207 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2011-11-29 10:58:27
|
Revision: 311 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=311&view=rev Author: matijsdejong Date: 2011-11-29 10:58:17 +0000 (Tue, 29 Nov 2011) Log Message: ----------- Removed Paths: ------------- branches/1.5.0beta1/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2011-11-29 10:56:34
|
Revision: 310 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=310&view=rev Author: matijsdejong Date: 2011-11-29 10:56:25 +0000 (Tue, 29 Nov 2011) Log Message: ----------- Added Paths: ----------- branches/1.5.0beta1/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2011-11-29 10:34:00
|
Revision: 309 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=309&view=rev Author: mennodekker Date: 2011-11-29 10:33:49 +0000 (Tue, 29 Nov 2011) Log Message: ----------- Added description to survey_id dropdown in round editor Modified Paths: -------------- branches/userloader/classes/Gems/Tracker/Engine/TrackEngineAbstract.php branches/userloader/classes/Gems/Util/TrackData.php Modified: branches/userloader/classes/Gems/Tracker/Engine/TrackEngineAbstract.php =================================================================== --- branches/userloader/classes/Gems/Tracker/Engine/TrackEngineAbstract.php 2011-11-29 08:34:05 UTC (rev 308) +++ branches/userloader/classes/Gems/Tracker/Engine/TrackEngineAbstract.php 2011-11-29 10:33:49 UTC (rev 309) @@ -702,7 +702,7 @@ $model->set('gro_id_track', 'label', $this->_('Track'), 'elementClass', 'exhibitor', 'multiOptions', MUtil_Lazy::call($this->util->getTrackData()->getAllTracks)); } - $model->set('gro_id_survey', 'label', $this->_('Survey'), 'multiOptions', $this->util->getTrackData()->getAllSurveys()); + $model->set('gro_id_survey', 'label', $this->_('Survey'), 'multiOptions', $this->util->getTrackData()->getAllSurveysAndDescriptions()); $model->set('gro_id_order', 'label', $this->_('Order'), 'default', 10, 'validators[]', $model->createUniqueValidator(array('gro_id_order', 'gro_id_track'))); $model->set('gro_round_description', 'label', $this->_('Description'), 'size', '30'); //, 'minlength', 4, 'required', true); $model->set('gro_changed_event', 'label', $this->_('After change'), 'multiOptions', $this->events->listRoundChangedEvents()); Modified: branches/userloader/classes/Gems/Util/TrackData.php =================================================================== --- branches/userloader/classes/Gems/Util/TrackData.php 2011-11-29 08:34:05 UTC (rev 308) +++ branches/userloader/classes/Gems/Util/TrackData.php 2011-11-29 10:33:49 UTC (rev 309) @@ -95,6 +95,13 @@ return $surveys; } // */ + + /** + * Retrieve an array of key/value pairs for gsu_id_survey and gsu_survey_name + * + * @staticvar array $surveys + * @return array + */ public function getAllSurveys() { static $surveys; @@ -107,6 +114,23 @@ } /** + * Retrieve an array of key/value pairs for gsu_id_survey and gsu_survey_name plus gsu_survey_description + * + * @staticvar array $surveys + * @return array + */ + public function getAllSurveysAndDescriptions() + { + static $surveys; + + if (! $surveys) { + $surveys = $this->db->fetchPairs('SELECT gsu_id_survey, LEFT(CONCAT_WS(" - ", gsu_survey_name, gsu_survey_description),50) FROM gems__surveys ORDER BY gsu_survey_name'); + } + + return $surveys; + } + + /** * Returns array (id => name) of all tracks, sorted alphabetically * @return array */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2011-11-29 08:34:16
|
Revision: 308 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=308&view=rev Author: mennodekker Date: 2011-11-29 08:34:05 +0000 (Tue, 29 Nov 2011) Log Message: ----------- Created a get method for organizationData so simple additions to organizationData don't need to subclass to access their variables Modified Paths: -------------- branches/userloader/classes/Gems/User/Organization.php Modified: branches/userloader/classes/Gems/User/Organization.php =================================================================== --- branches/userloader/classes/Gems/User/Organization.php 2011-11-29 08:14:48 UTC (rev 307) +++ branches/userloader/classes/Gems/User/Organization.php 2011-11-29 08:34:05 UTC (rev 308) @@ -98,7 +98,6 @@ /** * 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 @@ -108,9 +107,7 @@ 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."); } @@ -155,6 +152,22 @@ } /** + * Returns the $key in organizationData when set otherwise the default value + * + * @param string $key + * @param mixed $default + * @return mixed + */ + public function get($key, $default = null) + { + if (array_key_exists($key, $this->_organizationData)) { + return $this->_organizationData[$key]; + } else { + return $default; + } + } + + /** * Get the style attribute. * * @return string This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2011-11-29 08:14:58
|
Revision: 307 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=307&view=rev Author: michieltcs Date: 2011-11-29 08:14:48 +0000 (Tue, 29 Nov 2011) Log Message: ----------- Fallback if gor_accessible is not defined (yet) Modified Paths: -------------- branches/1.5.0-pulse/library/classes/Gems/User/Organization.php Modified: branches/1.5.0-pulse/library/classes/Gems/User/Organization.php =================================================================== --- branches/1.5.0-pulse/library/classes/Gems/User/Organization.php 2011-11-28 20:19:39 UTC (rev 306) +++ branches/1.5.0-pulse/library/classes/Gems/User/Organization.php 2011-11-29 08:14:48 UTC (rev 307) @@ -195,17 +195,21 @@ $data = $this->db->fetchRow($sql, $id); if ($data) { - $dbOrgId = $this->db->quote($id, Zend_Db::INT_TYPE); - $sql = "SELECT gor_id_organization, gor_name - FROM gems__organizations - WHERE gor_active = 1 AND - ( - gor_id_organization = $dbOrgId OR - gor_accessible_by LIKE '%:$dbOrgId:%' - ) - ORDER BY gor_name"; - $data['can_access'] = $this->db->fetchPairs($sql); - natsort($data['can_access']); + try { + $dbOrgId = $this->db->quote($id, Zend_Db::INT_TYPE); + $sql = "SELECT gor_id_organization, gor_name + FROM gems__organizations + WHERE gor_active = 1 AND + ( + gor_id_organization = $dbOrgId OR + gor_accessible_by LIKE '%:$dbOrgId:%' + ) + ORDER BY gor_name"; + $data['can_access'] = $this->db->fetchPairs($sql); + natsort($data['can_access']); + } catch (Exception $e) { + $data['can_access'] = array(); + } // MUtil_Echo::track($sql, $data['can_access']); } else { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2011-11-28 20:19:45
|
Revision: 306 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=306&view=rev Author: michieltcs Date: 2011-11-28 20:19:39 +0000 (Mon, 28 Nov 2011) Log Message: ----------- Copy the tagged version to a new branch for the 1.5 beta pulse production run Added Paths: ----------- branches/1.5.0-pulse/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |