From: <gem...@li...> - 2012-03-19 18:34:52
|
Revision: 555 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=555&view=rev Author: matijsdejong Date: 2012-03-19 18:34:45 +0000 (Mon, 19 Mar 2012) Log Message: ----------- Moving login form from IndexAction.php Moving away from array values in authenticate simplified layoutSwitch Modified Paths: -------------- trunk/library/classes/Gems/Auth/Adapter/Callback.php trunk/library/classes/Gems/Default/IndexAction.php trunk/library/classes/Gems/Form.php trunk/library/classes/Gems/Project/Layout/MultiLayoutInterface.php trunk/library/classes/Gems/User/DbUserDefinitionAbstract.php trunk/library/classes/Gems/User/NoLoginDefinition.php trunk/library/classes/Gems/User/OldStaffUserDefinition.php trunk/library/classes/Gems/User/ProjectUserDefinition.php trunk/library/classes/Gems/User/RadiusUserDefinition.php trunk/library/classes/Gems/User/User.php trunk/library/classes/Gems/User/UserDefinitionInterface.php trunk/library/classes/Gems/User/UserLoader.php trunk/library/classes/Gems/Util/DbLookup.php trunk/library/classes/GemsEscort.php Added Paths: ----------- trunk/library/classes/Gems/User/Form/ trunk/library/classes/Gems/User/Form/LoginForm.php Modified: trunk/library/classes/Gems/Auth/Adapter/Callback.php =================================================================== --- trunk/library/classes/Gems/Auth/Adapter/Callback.php 2012-03-16 15:26:05 UTC (rev 554) +++ trunk/library/classes/Gems/Auth/Adapter/Callback.php 2012-03-19 18:34:45 UTC (rev 555) @@ -75,7 +75,7 @@ * @param string $identity The identity to use * @param array $params Array of parameters needed for the callback */ - public function __construct($callback, $identity, $params) + public function __construct($callback, $identity, $params = array()) { $this->_callback = $callback; $this->_identity = $identity; Modified: trunk/library/classes/Gems/Default/IndexAction.php =================================================================== --- trunk/library/classes/Gems/Default/IndexAction.php 2012-03-16 15:26:05 UTC (rev 554) +++ trunk/library/classes/Gems/Default/IndexAction.php 2012-03-19 18:34:45 UTC (rev 555) @@ -139,22 +139,39 @@ /** * Returns a login form * - * @param boolean $showTokenButton Optional, show 'Ask token' button, $this->showTokenButton is used when not specified - * @param boolean $showPasswordLostButton Optional, show 'Lost password' button, $this->showPasswordLostButton is used when not specified + * @param boolean $showToken Optional, show 'Ask token' button, $this->showTokenButton is used when not specified + * @param boolean $showPasswordLost Optional, show 'Lost password' button, $this->showPasswordLostButton is used when not specified * @return Gems_Form */ - protected function _getLoginForm($showTokenButton = null, $showPasswordLostButton = null) + protected function _getLoginForm($showToken = null, $showPasswordLost = null) { - $form = $this->_getBasicForm($this->_('Login to %s application')); + $args = MUtil_Ra::args(func_get_args(), + array( + 'showToken' => 'is_boolean', + 'showPasswordLost' => 'is_boolean', + 'description' => 'is_string', + ), + array( + 'showToken' => $this->showTokenButton, + 'showPasswordLost' => $this->showPasswordLostButton, + 'description' => $this->_('Login to %s application'), + 'labelWidthFactor' => $this->labelWidthFactor, + )); + + Gems_Html::init(); + + return $this->loader->getUserLoader()->getLoginForm($args); + + $form = $this->_getBasicForm(); $form->addElement($this->_getOrganizationElement()); $form->addElement($this->_getUserLoginElement()); $form->addElement($this->_getPasswordElement()); $form->addElement($this->_getSubmitButton($this->_('Login'))); - if (null === $showTokenButton ? $this->showTokenButton : $showTokenButton) { + if (null === $showToken ? $this->showTokenButton : $showToken) { $form->addElement($this->_getAskTokenLinkElement()); } - if (null === $showPasswordLostButton ? $this->showPasswordLostButton : $showPasswordLostButton) { + if (null === $showPasswordLost ? $this->showPasswordLostButton : $showPasswordLost) { $form->addElement($this->_getResetLinkElement()); } @@ -309,30 +326,6 @@ { $request = $this->getRequest(); - /** - * @@TODO: Start block to move to Gems_User_User->getCurrentOrganizationId() - * - * At that place the cookie is read, but this could be changed to use url like here - * or maybe referrer, ip-range, get-param etc. - */ - // Allow layout switching based on request base url - if ($this->escort instanceof Gems_Project_Layout_MultiLayoutInterface) { - $hostUrl = $this->escort->loader->getUtil()->getCurrentURI(); - - // MUtil_Echo::track($hostUrl); - - $organizationId = $this->util->getDbLookup()->getOrganizationForUrl($hostUrl); - - if ($organizationId) { - $user = $this->escort->getLoader()->getUserLoader()->getCurrentUser(); - $user->setCurrentOrganization($organizationId); - $this->escort->layoutSwitch($request); - } - } - /** - * End block to move to Gems_User_User->getCurrentOrganizationId() - */ - $form = $this->_getLoginForm(); if ($request->isPost()) { @@ -360,7 +353,7 @@ } // */ /** - * Fix current locale / organization in cookies + * Fix current locale in cookies */ Gems_Cookies::setLocale($user->getLocale(), $this->basepath->getBasePath()); Modified: trunk/library/classes/Gems/Form.php =================================================================== --- trunk/library/classes/Gems/Form.php 2012-03-16 15:26:05 UTC (rev 554) +++ trunk/library/classes/Gems/Form.php 2012-03-19 18:34:45 UTC (rev 555) @@ -40,7 +40,7 @@ * @copyright Copyright (c) 2011 Erasmus MC * @license New BSD License */ -class Gems_Form extends MUtil_Form +class Gems_Form extends MUtil_Form implements MUtil_Registry_TargetInterface { /** * This variable holds all the stylesheets attached to this form @@ -116,15 +116,75 @@ $this->_css[$file] = $media; } - public function getCss() { + /** + * Allows the loader to set resources. + * + * @param string $name Name of resource to set + * @param mixed $resource The resource. + * @return boolean True if $resource was OK + */ + public function answerRegistryRequest($name, $resource) + { + if (MUtil_Registry_Source::$verbose) { + MUtil_Echo::r('Resource set: ' . get_class($this) . '->' . __FUNCTION__ . + '("' . $name . '", ' . + (is_object($resource) ? get_class($resource) : gettype($resource)) . ')'); + } + $this->$name = $resource; + + return true; + } + + /** + * Should be called after answering the request to allow the Target + * to check if all required registry values have been set correctly. + * + * @return boolean False if required values are missing. + */ + public function checkRegistryRequestsAnswers() + { + return true; + } + + /** + * Filters the names that should not be requested. + * + * Can be overriden. + * + * @param string $name + * @return boolean + */ + protected function filterRequestNames($name) + { + return '_' !== $name[0]; + } + + public function getCss() + { return $this->_css; } - public function getAutoSubmit() { + public function getAutoSubmit() + { return $this->_autosubmit; } /** + * Allows the loader to know the resources to set. + * + * Returns those object variables defined by the subclass but not at the level of this definition. + * + * Can be overruled. + * + * @return array of string names + */ + public function getRegistryRequests() + { + // MUtil_Echo::track(array_filter(array_keys(get_object_vars($this)), array($this, 'filterRequestNames'))); + return array_filter(array_keys(get_object_vars($this)), array($this, 'filterRequestNames')); + } + + /** * Is this a form that autosubmits? * * @return boolean Modified: trunk/library/classes/Gems/Project/Layout/MultiLayoutInterface.php =================================================================== --- trunk/library/classes/Gems/Project/Layout/MultiLayoutInterface.php 2012-03-16 15:26:05 UTC (rev 554) +++ trunk/library/classes/Gems/Project/Layout/MultiLayoutInterface.php 2012-03-19 18:34:45 UTC (rev 555) @@ -62,7 +62,7 @@ /** * Performs the actual switch of the layout * - * @param Zend_Controller_Request_Abstract $request + * @param string $style Style, when null derived from request */ - public function layoutSwitch(Zend_Controller_Request_Abstract $request); + public function layoutSwitch($style = null); } \ No newline at end of file Modified: trunk/library/classes/Gems/User/DbUserDefinitionAbstract.php =================================================================== --- trunk/library/classes/Gems/User/DbUserDefinitionAbstract.php 2012-03-16 15:26:05 UTC (rev 554) +++ trunk/library/classes/Gems/User/DbUserDefinitionAbstract.php 2012-03-19 18:34:45 UTC (rev 555) @@ -120,18 +120,26 @@ return false; } - public function getAuthAdapter($formValues) + /** + * Returns an initialized Zend_Auth_Adapter_Interface + * + * @param string $username + * @param int $organizationId + * @param string $password + * @return Zend_Auth_Adapter_Interface + */ + public function getAuthAdapter($username, $organizationId, $password) { $adapter = new Zend_Auth_Adapter_DbTable($this->db, 'gems__user_passwords', 'gul_login', 'gup_password'); - $pwd_hash = $this->hashPassword($formValues['password']); + $pwd_hash = $this->hashPassword($password); $select = $adapter->getDbSelect(); $select->join('gems__user_logins', 'gup_id_user = gul_id_user', array()) ->where('gul_can_login = 1') - ->where('gul_id_organization = ?', $formValues['organization']); + ->where('gul_id_organization = ?', $organizationId); - $adapter->setIdentity($formValues['userlogin']) + $adapter->setIdentity($username) ->setCredential($pwd_hash); return $adapter; @@ -185,7 +193,7 @@ $result = array( 'user_active' => false, 'user_role' => 'nologin', - ); + ); } return $result; Property changes on: trunk/library/classes/Gems/User/Form ___________________________________________________________________ Added: bugtraq:url + http://survey.erasmusmc.nl/support/mantis/view.php?id=%BUGID% Added: bugtraq:logregex + #(\d+) Added: trunk/library/classes/Gems/User/Form/LoginForm.php =================================================================== --- trunk/library/classes/Gems/User/Form/LoginForm.php (rev 0) +++ trunk/library/classes/Gems/User/Form/LoginForm.php 2012-03-19 18:34:45 UTC (rev 555) @@ -0,0 +1,460 @@ +<?php + +/** + * Copyright (c) 2012, Erasmus MC + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Erasmus MC nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * + * @package Gems + * @subpackage User + * @author Matijs de Jong <mj...@ma...> + * @copyright Copyright (c) 2012 Erasmus MC + * @license New BSD License + * @version $id: LoginForm.php 203 2012-01-01t 12:51:32Z matijs $ + */ + +/** + * + * + * @package Gems + * @subpackage User + * @copyright Copyright (c) 2012 Erasmus MC + * @license New BSD License + * @since Class available since version 1.5 + */ +class Gems_User_Form_LoginForm extends Gems_Form +{ + /** + * The field name for the lost password element. + * + * @var string + */ + protected $_lostPasswordFieldName = 'lost_password'; + + /** + * The field name for the organization element. + * + * @var string + */ + protected $_organizationFieldName = 'organization'; + + + /** + * When true the organization was derived from the the url + * + * @var boolean + */ + protected $_organizationFromUrl = false; + + /** + * The field name for the password element. + * + * @var string + */ + protected $_passwordFieldName = 'password'; + + /** + * The field name for the submit element. + * + * @var string + */ + protected $_submitFieldName = 'button'; + + /** + * The field name for the token element. + * + * @var string + */ + protected $_tokenFieldName = 'token_link'; + + /** + * The field name for the username element. + * + * @var string + */ + protected $_usernameFieldName = 'userlogin'; + + /** + * When true all elements are loaded after initiation. + * + * @var boolean + */ + protected $loadDefault = true; + + /** + * + * @var Gems_Loader + */ + protected $loader; + + /** + * For small numbers of organizations a multiline selectbox will be nice. This + * setting handles how many lines will display at once. Use 1 for the normal + * dropdown selectbox + * + * @var int + */ + protected $organizationMaxLines = 6; + + /** + * + * @var Zend_Controller_Request_Abstract + */ + protected $request; + + /** + * The default behaviour for showing a lost password button + * + * @var boolean + */ + protected $showPasswordLost = true; + + /** + * The default behaviour for showing an 'ask token' button + * + * @var boolean + */ + protected $showToken = true; + + /** + * + * @var Zend_Translate + */ + protected $translate; + + /** + * + * @var Zend_Util + */ + protected $util; + + /** + * Should be called after answering the request to allow the Target + * to check if all required registry values have been set correctly. + * + * @return boolean False if required values are missing. + */ + public function checkRegistryRequestsAnswers() + { + if ($this->loadDefault) { + $this->loadDefaultElements(); + } + + return true; + } + + /** + * Returns the organization id that should currently be used for this form. + * + * @return int Returns the current organization id, if any + */ + public function getCurrentOrganizationId() + { + // Url determines organization first. + $uri = $this->util->getCurrentURI(); + // MUtil_Echo::track($uri); + + if ($orgId = $this->util->getDbLookup()->getOrganizationForUrl($uri)) { + $this->_organizationFromUrl = true; + $this->loader->getCurrentUser()->setCurrentOrganization($orgId); + return $orgId; + } + + $request = $this->getRequest(); + if ($request->isPost() && ($orgId = $request->getParam($this->_organizationFieldName))) { + return $orgId; + } + + return $this->loader->getCurrentUser()->getCurrentOrganizationId(); + } + + /** + * Returns a list with the organizations the user can select for login. + * + * @return array orgId => Name + */ + public function getLoginOrganizations() + { + return $this->util->getDbLookup()->getOrganizationsForLogin(); + } + + /** + * Returns/sets a link to the reset password page + * + * @return MUtil_Form_Element_Html + */ + public function getLostPasswordElement() + { + $element = $this->getElement($this->_lostPasswordFieldName); + + if (! $element) { + // Reset password + $element = new MUtil_Form_Element_Html($this->_lostPasswordFieldName); + // $element->br(); + $element->a(array('controller' => 'index', 'action' => 'resetpassword'), $this->translate->_('Lost password'), array('class' => 'actionlink')); + + $this->addElement($element); + } + + return $element; + } + + /** + * Returns/sets an element for determining / selecting the organization. + * + * @return Zend_Form_Element_Xhtml + */ + public function getOrganizationElement() + { + $element = $this->getElement($this->_organizationFieldName); + $orgId = $this->getCurrentOrganizationId(); + $orgs = $this->getLoginOrganizations(); + $hidden = $this->_organizationFromUrl || (count($orgs) < 2); + + if ($hidden) { + if (! $element instanceof Zend_Form_Element_Hidden) { + $element = new Zend_Form_Element_Hidden($this->_organizationFieldName); + + $this->addElement($element); + } + + if (! $this->_organizationFromUrl) { + $orgIds = array_keys($orgs); + $orgId = reset($orgIds); + } + + } elseif (! $element instanceof Zend_Form_Element_Select) { + $element = new Zend_Form_Element_Select($this->_organizationFieldName); + $element->setLabel($this->translate->_('Organization')); + $element->setRequired(true); + $element->setMultiOptions($orgs); + + if ($this->organizationMaxLines > 1) { + $element->setAttrib('size', max(count($orgs) + 1, $this->organizationMaxLines)); + } + $this->addElement($element); + + } + $element->setValue($orgId); + + return $element; + } + + /** + * Returns/sets a password element. + * + * @return Zend_Form_Element_Password + */ + public function getPasswordElement() + { + $element = $this->getElement($this->_passwordFieldName); + + if (! $element) { + // Veld password + $element = new Zend_Form_Element_Password($this->_passwordFieldName); + $element->setLabel($this->translate->_('Password')); + $element->setAttrib('size', 10); + $element->setAttrib('maxlength', 20); + $element->setRequired(true); + + $this->addElement($element); + } + + return $element; + } + + /** + * Return the Request object + * + * @return Zend_Controller_Request_Abstract + */ + public function getRequest() + { + if (! $this->request) { + $this->request = Zend_Controller_Front::getInstance()->getRequest(); + } + return $this->request; + } + + /** + * Returns/sets a submit button. + * + * @param string $label + * @return Zend_Form_Element_Submit + */ + public function getSubmitButton($label = null) + { + $element = $this->getElement($this->_submitFieldName); + + if (! $element) { + // Submit knop + $element = new Zend_Form_Element_Submit($this->_submitFieldName); + $element->setLabel(null === $label ? $this->translate->_('Login') : $label); + $element->setAttrib('class', 'button'); + + $this->addElement($element); + } + + return $element; + } + + /** + * Returns/sets a link for the token input page. + * + * @return MUtil_Form_Element_Html + */ + public function getTokenElement() + { + $element = $this->getElement($this->_tokenFieldName); + + if (! $element) { + // Veld token + $element = new MUtil_Form_Element_Html($this->_tokenFieldName); + // $element->br(); + $element->a(array('controller' => 'ask', 'action' => 'token'), $this->translate->_('Enter your token...'), array('class' => 'actionlink')); + + $this->addElement($element); + } + + return $element; + } + + /** + * Returns/sets a login name element. + * + * @return Zend_Form_Element_Text + */ + public function getUserNameElement() + { + $element = $this->getElement($this->_usernameFieldName); + + if (! $element) { + // Veld inlognaam + $element = new Zend_Form_Element_Text($this->_usernameFieldName); + $element->setLabel($this->translate->_('Username')); + $element->setAttrib('size', 10); + $element->setAttrib('maxlength', 20); + $element->setRequired(true); + + $this->addElement($element); + } + + return $element; + } + + /** + * The function that determines the element load order + * + * @return Gems_User_Form_LoginForm (continuation pattern) + */ + public function loadDefaultElements() + { + $this->getOrganizationElement(); + $this->getUserNameElement(); + $this->getPasswordElement(); + $this->getSubmitButton(); + + if ($this->showPasswordLost) { + $this->getLostPasswordElement(); + } + if ($this->showToken) { + $this->getTokenElement(); + } + + return $this; + } + + /** + * When true all elements are loaded after initiation. + * + * Enables loading of parameter through Zend_Form::__construct() + * + * @param boolean $loadDefault + * @return Gems_User_Form_LoginForm (continuation pattern) + */ + public function setLoadDefault($loadDefault = true) + { + $this->loadDefault = $loadDefault; + + return $this; + } + + /** + * For small numbers of organizations a multiline selectbox will be nice. This + * setting handles how many lines will display at once. Use 1 for the normal + * dropdown selectbox + * + * Enables loading of parameter through Zend_Form::__construct() + * + * @param int $organizationMaxLines + * @return Gems_User_Form_LoginForm (continuation pattern) + */ + public function setOrganizationMaxLines($organizationMaxLines) + { + $this->organizationMaxLines = $organizationMaxLines; + + return $this; + } + + /** + * The behaviour for showing a lost password button + * + * Enables loading of parameter through Zend_Form::__construct() + * + * @param boolean $showPasswordLost + * @return Gems_User_Form_LoginForm (continuation pattern) + */ + public function setShowPasswordLost($showPasswordLost = true) + { + $this->showPasswordLost = $showPasswordLost; + + return $this; + } + + /** + * The default behaviour for showing an 'ask token' button + * + * Enables loading of parameter through Zend_Form::__construct() + * + * @param boolean $showToken + * @return Gems_User_Form_LoginForm (continuation pattern) + */ + public function setShowToken($showToken = true) + { + $this->showToken = $showToken; + + return $this; + } + + /** + * True when this form was submitted. + * + * @return boolean + */ + public function wasSubmitted() + { + return $this->getSubmitButton()->isChecked(); + } +} Modified: trunk/library/classes/Gems/User/NoLoginDefinition.php =================================================================== --- trunk/library/classes/Gems/User/NoLoginDefinition.php 2012-03-16 15:26:05 UTC (rev 554) +++ trunk/library/classes/Gems/User/NoLoginDefinition.php 2012-03-19 18:34:45 UTC (rev 555) @@ -46,14 +46,27 @@ */ class Gems_User_NoLoginDefinition extends Gems_User_UserDefinitionAbstract { - public function alwaysFalse($params) + /** + * Helper method for the case a user tries to authenticate while he is inactive + * + * @return boolean + */ + public function alwaysFalse() { return false; } - public function getAuthAdapter($formValues) + /** + * Returns an initialized Zend_Auth_Adapter_Interface + * + * @param string $username + * @param int $organizationId + * @param string $password + * @return Zend_Auth_Adapter_Interface + */ + public function getAuthAdapter($username, $organizationId, $password) { - $adapter = new Gems_Auth_Adapter_Callback(array($this,'alwaysFalse'), $formValues['userlogin'], $formValues); + $adapter = new Gems_Auth_Adapter_Callback(array($this,'alwaysFalse'), $username); return $adapter; } Modified: trunk/library/classes/Gems/User/OldStaffUserDefinition.php =================================================================== --- trunk/library/classes/Gems/User/OldStaffUserDefinition.php 2012-03-16 15:26:05 UTC (rev 554) +++ trunk/library/classes/Gems/User/OldStaffUserDefinition.php 2012-03-19 18:34:45 UTC (rev 555) @@ -119,17 +119,25 @@ } } - public function getAuthAdapter($formValues) + /** + * Returns an initialized Zend_Auth_Adapter_Interface + * + * @param string $username + * @param int $organizationId + * @param string $password + * @return Zend_Auth_Adapter_Interface + */ + public function getAuthAdapter($username, $organizationId, $password) { $adapter = new Zend_Auth_Adapter_DbTable(null, 'gems__staff', 'gsf_login', 'gsf_password'); - $pwd_hash = $this->hashPassword($formValues['password']); + $pwd_hash = $this->hashPassword($password); $select = $adapter->getDbSelect(); $select->where('gsf_active = 1') - ->where('gsf_id_organization = ?', $formValues['organization']); + ->where('gsf_id_organization = ?', $organizationId); - $adapter->setIdentity($formValues['userlogin']) + $adapter->setIdentity($username) ->setCredential($pwd_hash); return $adapter; Modified: trunk/library/classes/Gems/User/ProjectUserDefinition.php =================================================================== --- trunk/library/classes/Gems/User/ProjectUserDefinition.php 2012-03-16 15:26:05 UTC (rev 554) +++ trunk/library/classes/Gems/User/ProjectUserDefinition.php 2012-03-19 18:34:45 UTC (rev 555) @@ -52,9 +52,17 @@ */ protected $project; - public function getAuthAdapter($formValues) + /** + * Returns an initialized Zend_Auth_Adapter_Interface + * + * @param string $username + * @param int $organizationId + * @param string $password + * @return Zend_Auth_Adapter_Interface + */ + public function getAuthAdapter($username, $organizationId, $password) { - $adapter = new Gems_Auth_Adapter_Callback(array($this->project,'checkSuperAdminPassword'), $formValues['userlogin'], array($formValues['password'])); + $adapter = new Gems_Auth_Adapter_Callback(array($this->project,'checkSuperAdminPassword'), $username, array($password)); return $adapter; } Modified: trunk/library/classes/Gems/User/RadiusUserDefinition.php =================================================================== --- trunk/library/classes/Gems/User/RadiusUserDefinition.php 2012-03-16 15:26:05 UTC (rev 554) +++ trunk/library/classes/Gems/User/RadiusUserDefinition.php 2012-03-19 18:34:45 UTC (rev 555) @@ -2,7 +2,7 @@ /** * Copyright (c) 2011, Erasmus MC * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright @@ -13,7 +13,7 @@ * * Neither the name of Erasmus MC nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE @@ -24,7 +24,7 @@ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * @package Gems * @subpackage User * @copyright Copyright (c) 2011 Erasmus MC @@ -128,17 +128,20 @@ /** * Returns an initialized Zend_Auth_Adapter_Interface * + * @param string $username + * @param int $organizationId + * @param string $password * @return Zend_Auth_Adapter_Interface */ - public function getAuthAdapter($formValues) + public function getAuthAdapter($username, $organizationId, $password) { //Ok hardcoded for now this needs to be read from the userdefinition - $configData = $this->loadConfig(array('gor_id_organization' => $formValues['organization'])); + $configData = $this->loadConfig(array('gor_id_organization' => $organizationId)); $config = array('ip' => $configData['grcfg_ip'], 'authenticationport' => $configData['grcfg_port'], 'sharedsecret' => $configData['grcfg_secret']); - + //Unset empty foreach($config as $key=>$value) { if (empty($value)) { @@ -147,8 +150,8 @@ } $adapter = new Gems_User_Adapter_Radius($config); - $adapter->setIdentity($formValues['userlogin']) - ->setCredential($formValues['password']); + $adapter->setIdentity($username) + ->setCredential($password); return $adapter; } @@ -243,7 +246,7 @@ * * For now these will be added in the organization dialog as most of the time the config * will be organization specific. To be extended when needed - * + * * @return boolean */ public function hasConfig() @@ -274,7 +277,7 @@ public function loadConfig($data) { $model = $this->getConfigModel(); - + $newData = $model->loadFirst(array('grcfg_id_organization'=>$data['gor_id_organization'])); $newData['grcfg_id_organization'] = $data['gor_id_organization']; Modified: trunk/library/classes/Gems/User/User.php =================================================================== --- trunk/library/classes/Gems/User/User.php 2012-03-16 15:26:05 UTC (rev 554) +++ trunk/library/classes/Gems/User/User.php 2012-03-19 18:34:45 UTC (rev 555) @@ -87,6 +87,12 @@ protected $definition; /** + * + * @var Zend_Controller_Request_Abstract + */ + protected $request; + + /** * Required * * @var Zend_Session_Namespace @@ -230,10 +236,9 @@ /** * Helper method for the case a user tries to authenticate while he is inactive * - * @param array $params * @return boolean */ - public function alwaysFalse($params) + public function alwaysFalse() { return false; } @@ -252,9 +257,9 @@ $formValues['organization'] = $this->getBaseOrganizationId(); if ($this->isActive()) { - $adapter = $this->definition->getAuthAdapter($formValues); + $adapter = $this->definition->getAuthAdapter($formValues['userlogin'], $formValues['organization'], $formValues['password']); } else { - $adapter = new Gems_Auth_Adapter_Callback(array($this,'alwaysFalse'), $formValues['userlogin'], $formValues); + $adapter = new Gems_Auth_Adapter_Callback(array($this,'alwaysFalse'), $formValues['userlogin']); } $authResult = $auth->authenticate($adapter, $formValues); @@ -397,8 +402,8 @@ $orgId = $this->_getVar('user_organization_id'); //If not set, read it from the cookie - if ($this->isCurrentUser() && is_null($orgId)) { - $orgId = Gems_Cookies::getOrganization(Zend_Controller_Front::getInstance()->getRequest()); + if ($this->isCurrentUser() && (null === $orgId)) { + $orgId = Gems_Cookies::getOrganization($this->getRequest()); } return $orgId; } @@ -591,6 +596,19 @@ } /** + * Return the Request object + * + * @return Zend_Controller_Request_Abstract + */ + public function getRequest() + { + if (! $this->request) { + $this->request = Zend_Controller_Front::getInstance()->getRequest(); + } + return $this->request; + } + + /** * Returns the current user role. * * @return string @@ -871,6 +889,15 @@ // End depreciation warning if ($this->isCurrentUser()) { + if (! Gems_Cookies::setOrganization($organizationId, $this->basepath->getBasePath())) { + throw new Exception($this->translate->_('Cookies must be enabled for this site.')); + } + + $escort = GemsEscort::getInstance(); + if ($escort instanceof Gems_Project_Layout_MultiLayoutInterface) { + $escort->layoutSwitch($organization->getStyle()); + } + // Now update the requestcache to change the oldOrgId to the new orgId // Don't do it when the oldOrgId doesn't match if ($requestCache = $this->session->requestCache) { @@ -894,10 +921,6 @@ $this->session->requestCache = $requestCache; } } - - if (! Gems_Cookies::setOrganization($organizationId, $this->basepath->getBasePath())) { - throw new Exception($this->translate->_('Cookies must be enabled for this site.')); - } } } Modified: trunk/library/classes/Gems/User/UserDefinitionInterface.php =================================================================== --- trunk/library/classes/Gems/User/UserDefinitionInterface.php 2012-03-16 15:26:05 UTC (rev 554) +++ trunk/library/classes/Gems/User/UserDefinitionInterface.php 2012-03-19 18:34:45 UTC (rev 555) @@ -80,9 +80,12 @@ /** * Returns an initialized Zend_Auth_Adapter_Interface * + * @param string $username + * @param int $organizationId + * @param string $password * @return Zend_Auth_Adapter_Interface */ - public function getAuthAdapter($formValues); + public function getAuthAdapter($username, $organizationId, $password); /** * Return a password reset key Modified: trunk/library/classes/Gems/User/UserLoader.php =================================================================== --- trunk/library/classes/Gems/User/UserLoader.php 2012-03-16 15:26:05 UTC (rev 554) +++ trunk/library/classes/Gems/User/UserLoader.php 2012-03-19 18:34:45 UTC (rev 555) @@ -208,6 +208,25 @@ } /** + * Returns a login form + * + * @param mixed $args_array MUtil_Ra::args array for LoginForm initiation. + * @return Gems_User_Form_LoginForm + */ + public function getLoginForm($args_array) + { + $args = MUtil_Ra::args(func_get_args()); + + if (isset($args['description'])) { + $args['description'] = sprintf($args['description'], $this->project->getName()); + } + + $form = $this->_loadClass('Form_LoginForm', true, array($args)); + + return $form; + } + + /** * Returns an organization object, initiated from the database or from * self::$_noOrganization when the database does not yet exist. * Modified: trunk/library/classes/Gems/Util/DbLookup.php =================================================================== --- trunk/library/classes/Gems/Util/DbLookup.php 2012-03-16 15:26:05 UTC (rev 554) +++ trunk/library/classes/Gems/Util/DbLookup.php 2012-03-19 18:34:45 UTC (rev 555) @@ -250,6 +250,7 @@ $organizations = $this->db->fetchPairs('SELECT gor_id_organization, gor_name FROM gems__organizations WHERE gor_active=1 AND gor_has_login=1 ORDER BY gor_name'); } catch (Exception $e) { try { + // 1.4 fallback $organizations = $this->db->fetchPairs('SELECT gor_id_organization, gor_name FROM gems__organizations WHERE gor_active=1 ORDER BY gor_name'); } catch (Exception $e) { $organizations = array(); @@ -278,7 +279,7 @@ return $organizations; } - + /** * Returns the organization * @param string $url @@ -287,7 +288,8 @@ public function getOrganizationForUrl($url) { try { - return $this->db->fetchOne("SELECT gor_id_organization FROM gems__organizations WHERE gor_active=1 AND gor_url_base = ?", $url); + $url = trim($this->db->quote($url), "'"); + return $this->db->fetchOne("SELECT gor_id_organization FROM gems__organizations WHERE gor_active=1 AND CONCAT(' ', gor_url_base, ' ') LIKE '% $url %'"); } catch (Exception $e) { return null; } Modified: trunk/library/classes/GemsEscort.php =================================================================== --- trunk/library/classes/GemsEscort.php 2012-03-16 15:26:05 UTC (rev 554) +++ trunk/library/classes/GemsEscort.php 2012-03-19 18:34:45 UTC (rev 555) @@ -1398,7 +1398,7 @@ public function prepareController() { if ($this instanceof Gems_Project_Layout_MultiLayoutInterface) { - $this->layoutSwitch($this->request); + $this->layoutSwitch(); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2012-03-27 16:39:15
|
Revision: 567 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=567&view=rev Author: matijsdejong Date: 2012-03-27 16:39:04 +0000 (Tue, 27 Mar 2012) Log Message: ----------- Active fix in RespondentUserDefinition.php PhpDoc added to Lazy Modified Paths: -------------- trunk/library/classes/Gems/User/RespondentUserDefinition.php trunk/library/classes/MUtil/Lazy.php Modified: trunk/library/classes/Gems/User/RespondentUserDefinition.php =================================================================== --- trunk/library/classes/Gems/User/RespondentUserDefinition.php 2012-03-27 15:07:22 UTC (rev 566) +++ trunk/library/classes/Gems/User/RespondentUserDefinition.php 2012-03-27 16:39:04 UTC (rev 567) @@ -59,6 +59,7 @@ $select = new Zend_Db_Select($this->db); $select->from('gems__user_logins', array( 'user_login_id' => 'gul_id_user', + 'user_active' => 'gul_can_login', )) ->join('gems__respondent2org', 'gul_login = gr2o_patient_nr AND gul_id_organization = gr2o_id_organization', array( 'user_login' => 'gr2o_patient_nr', Modified: trunk/library/classes/MUtil/Lazy.php =================================================================== --- trunk/library/classes/MUtil/Lazy.php 2012-03-27 15:07:22 UTC (rev 566) +++ trunk/library/classes/MUtil/Lazy.php 2012-03-27 16:39:04 UTC (rev 567) @@ -145,7 +145,15 @@ } } - public static function method($object, $method, $arg_array = null) + /** + * Return a lazy callable to an object + * + * @param Object $object + * @param string $method Method of the object + * @param mixed $arg_array1 Optional, first of any arguments to the call + * @return MUtil_Lazy_Call + */ + public static function method($object, $method, $arg_array1 = null) { $args = array_slice(func_get_args(), 2); return new MUtil_Lazy_Call(array($object, $method), $args); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2012-03-29 11:44:23
|
Revision: 575 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=575&view=rev Author: matijsdejong Date: 2012-03-29 11:44:15 +0000 (Thu, 29 Mar 2012) Log Message: ----------- New methods for mailings UserLoader should no longer fold during transition to 1.5.3 New MUtil_Ra::braceKeys A lot of docblocks Modified Paths: -------------- trunk/library/classes/Gems/Default/IndexAction.php trunk/library/classes/Gems/Email/TemplateMailer.php trunk/library/classes/Gems/Menu/MenuList.php trunk/library/classes/Gems/Project/ProjectSettings.php trunk/library/classes/Gems/User/Organization.php trunk/library/classes/Gems/User/User.php trunk/library/classes/Gems/User/UserLoader.php trunk/library/classes/Gems/Util/Translated.php trunk/library/classes/MUtil/Mail.php trunk/library/classes/MUtil/Ra.php Added Paths: ----------- trunk/library/classes/Gems/Mail.php Modified: trunk/library/classes/Gems/Default/IndexAction.php =================================================================== --- trunk/library/classes/Gems/Default/IndexAction.php 2012-03-29 10:01:28 UTC (rev 574) +++ trunk/library/classes/Gems/Default/IndexAction.php 2012-03-29 11:44:15 UTC (rev 575) @@ -93,21 +93,6 @@ protected $showTokenButton = true; /** - * Returns a link for the token input page. - * - * @return MUtil_Form_Element_Html - */ - protected function _getAskTokenLinkElement() - { - // Veld token - $element = new MUtil_Form_Element_Html('askToken'); - $element->br(); - $element->actionLink(array('controller' => 'ask', 'action' => 'token'), $this->_('Enter your token...')); - - return $element; - } - - /** * Returns a basic form for this action. * * @param $description Optional description, %s is filled with project name. @@ -161,21 +146,6 @@ Gems_Html::init(); return $this->loader->getUserLoader()->getLoginForm($args); - /* - $form = $this->_getBasicForm(); - $form->addElement($this->_getOrganizationElement()); - $form->addElement($this->_getUserLoginElement()); - $form->addElement($this->_getPasswordElement()); - $form->addElement($this->_getSubmitButton($this->_('Login'))); - - if (null === $showToken ? $this->showTokenButton : $showToken) { - $form->addElement($this->_getAskTokenLinkElement()); - } - if (null === $showPasswordLost ? $this->showPasswordLostButton : $showPasswordLost) { - $form->addElement($this->_getResetLinkElement()); - } - - return $form; // */ } /** @@ -233,23 +203,6 @@ } /** - * Returns a password element. - * - * @return Zend_Form_Element_Password - */ - protected function _getPasswordElement() - { - // Veld password - $element = new Zend_Form_Element_Password('password'); - $element->setLabel($this->_('Password')); - $element->setAttrib('size', 10); - $element->setAttrib('maxlength', 20); - $element->setRequired(true); - - return $element; - } - - /** * Gets a reset password form. * * @return Gems_Form @@ -325,13 +278,13 @@ public function loginAction() { $request = $this->getRequest(); + $form = $this->_getLoginForm(); - $form = $this->_getLoginForm(); - if ($request->isPost()) { if ($form->isValid($request->getPost(), false)) { $user = $form->getUser(); + // Retrieve these before the session is reset $previousRequestParameters = $this->session->previousRequestParameters; $user->setAsCurrentUser(); @@ -422,37 +375,15 @@ $this->addMessage($this->_('This key timed out or does not belong to this user.')); } } else { - // Pass mail by key - $mail = new MUtil_Mail(); - $mail->addTo($user->getEmailAddress(), $user->getFullName()); + $subjectTemplate = $this->_('Password reset requested'); + $bbBodyTemplate = $this->_("To set a new password for the [b]{organization}[/b] site [b]{project}[/b], please click on this link:\n{reset_url}"); - if (isset($this->escort->project->email['site'])) { - $mail->setFrom($this->escort->project->email['site']); - } elseif ($from = $user->getCurrentOrganization()->getEmail()) { - $mail->setFrom($from); - } elseif ($from = $user->getBaseOrganization()->getEmail()) { - $mail->setFrom($from); + $messages = $user->sendMail($subjectTemplate, $bbBodyTemplate, true); + if (! $messages) { + // Everything went OK! + $messages = $this->_('We sent you an e-mail with a reset link. Click on the link in the e-mail.'); } - if (isset($this->escort->project->email) && isset($this->escort->project->email['bcc'])) { - $mail->addBcc($this->escort->project->email['bcc']); - } - - - $key = $user->getPasswordResetKey(); - - $url = $this->util->getCurrentURI('index/resetpassword/key/' . $key); - - $mail->setSubject($this->_('Password reset requested')); - $mail->setBodyText(sprintf($this->_('To reset your password for %s, please click this link: %s'), GEMS_PROJECT_NAME_UC, $url)); - - - try { - $mail->send(); - $this->addMessage($this->_('We sent you an e-mail with a reset link. Click on the link in the e-mail.')); - } catch (Exception $e) { - $this->addMessage($this->_('Unable to send e-mail.')); - throw $e; - } + $this->addMessage($messages); } } else { $this->addMessage($this->_('No such user found or no e-mail address known or user cannot be reset.')); Modified: trunk/library/classes/Gems/Email/TemplateMailer.php =================================================================== --- trunk/library/classes/Gems/Email/TemplateMailer.php 2012-03-29 10:01:28 UTC (rev 574) +++ trunk/library/classes/Gems/Email/TemplateMailer.php 2012-03-29 11:44:15 UTC (rev 575) @@ -117,7 +117,7 @@ */ public function bounceCheck() { - return isset($this->escort->project->email['bounce']) && $this->escort->project->email['bounce']; + return $this->escort->project->getEmailBounce(); } /** @@ -338,11 +338,9 @@ $this->setTokenData($tokenData); - $style = isset($tokenData['gor_style']) ? $tokenData['gor_style'] : GEMS_PROJECT_NAME; + $mail = new Gems_Mail(); + $mail->setTemplateStyle($tokenData['gor_style']); - $mail = new MUtil_Mail(); - $mail->setHtmlTemplateFile(APPLICATION_PATH . '/configs/email/' . $style . '.html'); - $mail->setFrom($from, $from_name); $mail->addTo($to, $to_name); if (isset($this->escort->project->email['bcc'])) { Added: trunk/library/classes/Gems/Mail.php =================================================================== --- trunk/library/classes/Gems/Mail.php (rev 0) +++ trunk/library/classes/Gems/Mail.php 2012-03-29 11:44:15 UTC (rev 575) @@ -0,0 +1,100 @@ +<?php + +/** + * Copyright (c) 2012, Erasmus MC + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Erasmus MC nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * + * @package Gems + * @subpackage Mail + * @author Matijs de Jong <mj...@ma...> + * @copyright Copyright (c) 2012 Erasmus MC + * @license New BSD License + * @version $id: Mail.php 203 2012-01-01t 12:51:32Z matijs $ + */ + +/** + * + * + * @package Gems + * @subpackage Mail + * @copyright Copyright (c) 2012 Erasmus MC + * @license New BSD License + * @since Class available since version 1.5.3 + */ +class Gems_Mail extends MUtil_Mail +{ + /** + * Adds To-header and recipient, $email can be an array, or a single string address + * + * @param string|array $email + * @param string $name + * @param boolean $bounce When true the e-mail is bounced to the from address + * @return Zend_Mail Provides fluent interface + */ + public function addTo($email, $name = '', $bounce = false) + { + if ($bounce) { + $name = str_replace('@', ' at ', $email); + $email = $this->getFrom(); + + if (! $email) { + throw new Gems_Exception_Coding('Adding bounce To address while From is not set.'); + } + } + + return parent::addTo($email, $name); + } + + /** + * Returns the the current template + * + * @return string + */ + public function getHtmlTemplate() + { + if (! $this->_htmlTemplate) { + $this->setTemplateStyle(); + } + + return parent::getHtmlTemplate(); + } + + /** + * Set the template using style as basis + * + * @param string $style + * @return MUtil_Mail (continuation pattern) + */ + public function setTemplateStyle($style = null) + { + if (null == $style) { + $style = GEMS_PROJECT_NAME; + } + $this->setHtmlTemplateFile(APPLICATION_PATH . '/configs/email/' . $style . '.html'); + + return $this; + } +} Modified: trunk/library/classes/Gems/Menu/MenuList.php =================================================================== --- trunk/library/classes/Gems/Menu/MenuList.php 2012-03-29 10:01:28 UTC (rev 574) +++ trunk/library/classes/Gems/Menu/MenuList.php 2012-03-29 11:44:15 UTC (rev 575) @@ -363,6 +363,6 @@ } // Call the toActionLink(Lower) function with the sources given. - return call_user_func_array(array($this->offsetGet($key), $this->linkFunction), $sources); + return call_user_func_array(array($this->offsetGet($key), $this->linkFunction), $sources); } } Modified: trunk/library/classes/Gems/Project/ProjectSettings.php =================================================================== --- trunk/library/classes/Gems/Project/ProjectSettings.php 2012-03-29 10:01:28 UTC (rev 574) +++ trunk/library/classes/Gems/Project/ProjectSettings.php 2012-03-29 11:44:15 UTC (rev 575) @@ -230,6 +230,55 @@ /** + * Returns the public description of this project. + * + * @return string + */ + public function getDescription() + { + if ($this->offsetExists('description')) { + return $this->offsetGet('description'); + } else { + return $this->offsetGet('name'); + } + } + + /** + * The the email BCC address - if any + * + * @return string + */ + public function getEmailBcc() + { + if ($this->offsetExists('email') && isset($this->email['bcc'])) { + return trim($this->email['bcc']); + } + } + + /** + * Should all mail be bounced to the sender? + * + * @return boolean + */ + public function getEmailBounce() + { + if ($this->offsetExists('email') && isset($this->email['bounce'])) { + return (boolean) $this->email['bounce']; + } + return false; + } + + /** + * Returns the from address + * + * @return string E-Mail address + */ + public function getFrom() + { + return $this->getSiteEmail(); + } + + /** * Returns the initial password specified for users - if any. * * @return String @@ -244,7 +293,23 @@ } /** + * Array of field name => values for sending E-Mail + * + * @return array + */ + public function getMailFields() + { + $result['project'] = $this->getName(); + $result['project_bcc'] = $this->getEmailBcc(); + $result['project_description'] = $this->getDescription(); + $result['project_from'] = $this->getFrom(); + + return $result; + } + + /** * Returns the public name of this project. + * * @return string */ public function getName() @@ -287,6 +352,18 @@ } /** + * The site email address - if any + * + * @return string + */ + public function getSiteEmail() + { + if ($this->offsetExists('email') && isset($this->email['site'])) { + return trim($this->email['site']); + } + } + + /** * Returns the super admin name, if any * * @return string Modified: trunk/library/classes/Gems/User/Organization.php =================================================================== --- trunk/library/classes/Gems/User/Organization.php 2012-03-29 10:01:28 UTC (rev 574) +++ trunk/library/classes/Gems/User/Organization.php 2012-03-29 11:44:15 UTC (rev 575) @@ -164,6 +164,16 @@ } /** + * Returns the from address + * + * @return string E-Mail address + */ + public function getFrom() + { + return $this->getEmail(); + } + + /** * Get the organization id. * * @return int @@ -174,6 +184,24 @@ } /** + * Array of field name => values for sending E-Mail + * + * @return array + */ + public function getMailFields() + { + $result['organization'] = $this->getName(); + $result['organization_location'] = $this->_get('gor_location'); + $result['organization_reply_name'] = $this->_get('gor_contact_name'); + $result['organization_reply_to'] = $this->_get('gor_contact_email'); + $result['organization_signature'] = $this->getSignature(); + $result['organization_url'] = $this->_get('gor_url'); + $result['organization_welcome'] = $this->getWelcome(); + + return $result; + } + + /** * Get the name of the organization. * * @return string @@ -204,6 +232,16 @@ } /** + * Has org an email attribute? + * + * @return boolean + */ + public function hasEmail() + { + return $this->_has('gor_contact_email'); + } + + /** * Load the data when the cache is empty. * * @param mixed $id Modified: trunk/library/classes/Gems/User/User.php =================================================================== --- trunk/library/classes/Gems/User/User.php 2012-03-29 10:01:28 UTC (rev 574) +++ trunk/library/classes/Gems/User/User.php 2012-03-29 11:44:15 UTC (rev 575) @@ -102,6 +102,12 @@ /** * + * @var Gems_Project_ProjectSettings + */ + protected $project; + + /** + * * @var Zend_Controller_Request_Abstract */ protected $request; @@ -611,6 +617,30 @@ } /** + * Returns the from address + * + * @return string E-Mail address + */ + public function getFrom() + { + // Gather possible sources of a from address + $sources[] = $this->getBaseOrganization(); + if ($this->getBaseOrganizationId() != $this->getCurrentOrganizationId()) { + $sources[] = $this->getCurrentOrganization(); + } + $sources[] = $this->project; + + foreach ($sources as $source) { + if ($from = $source->getFrom()) { + return $from; + } + } + + // We really don't like it, but sometimes the only way to get a from address. + return $this->getEmailAddress(); + } + + /** * Returns the full user name (first, prefix, last). * * @return string @@ -637,29 +667,59 @@ } /** + * Returns the gender for use as part of a sentence, e.g. Dear Mr/Mrs + * + * In practice: starts lowercase + * + * @param string $locale + * @return array gender => string + */ + protected function getGenderGreeting($locale = null) + { + $greetings = $this->util->getTranslated()->getGenderGreeting($locale); + + if (isset($greetings[$this->_getVar('user_gender')])) { + return $greetings[$this->_getVar('user_gender')]; + } + } + + /** + * Returns the gender for use in stand-alone name display + * + * In practice: starts uppercase + * + * @param string $locale + * @return array gender => string + */ + protected function getGenderHello($locale = null) + { + $greetings = $this->util->getTranslated()->getGenderHello($locale); + + if (isset($greetings[$this->_getVar('user_gender')])) { + return $greetings[$this->_getVar('user_gender')]; + } + } + + /** * Returns a standard greeting for the current user. * + * @param string $locale * @return int */ - public function getGreeting() + public function getGreeting($locale = null) { if (! $this->_getVar('user_greeting')) { - $greeting = array(); - $greetings = $this->util->getTranslated()->getGenderGreeting(); + $greeting[] = $this->getGenderGreeting($locale); - if (isset($greetings[$this->_getVar('user_gender')])) { - $greeting[] = $greetings[$this->_getVar('user_gender')]; - } if ($this->_getVar('user_last_name')) { - if ($this->_getVar('user_surname_prefix')) { - $greeting[] = $this->_getVar('user_surname_prefix'); - } + $greeting[] = $this->_getVar('user_surname_prefix'); $greeting[] = $this->_getVar('user_last_name'); } else { $name = $this->getLoginName(); $name = substr($name, 0, 3) . str_repeat('*', strlen($name) - 2); $greeting[] = $name; } + array_filter($greeting); $this->_setVar('user_greeting', implode(' ', $greeting)); } @@ -698,6 +758,36 @@ } /** + * Array of field name => values for sending E-Mail + * + * @param string $locale + * @return array + */ + public function getMailFields($locale = null) + { + $orgResults = $this->getBaseOrganization()->getMailFields(); + $projResults = $this->project->getMailFields(); + + $result['bcc'] = $projResults['project_bcc']; + $result['email'] = $this->getEmailAddress(); + $result['first_name'] = $this->_getVar('user_first_name'); + $result['from'] = $this->getFrom(); + $result['full_name'] = trim($this->getGenderHello($locale) . ' ' . $this->getFullName()); + $result['greeting'] = $this->getGreeting($locale); + $result['last_name'] = ltrim($this->_getVar('user_surname_prefix') . ' ') . $this->_getVar('user_last_name'); + $result['login_url'] = $this->util->getCurrentURI(); + $result['name'] = $this->getFullName(); + + $result = $result + $orgResults + $projResults; + + $result['reset_ask'] = $this->util->getCurrentURI('index/resetpassword'); + $result['reply_to'] = $result['from']; + $result['to'] = $result['email']; + + return $result; + } + + /** * Return a password reset key * * @return string @@ -721,6 +811,20 @@ } /** + * Array of field name => values for sending a reset password E-Mail + * + * @param string $locale + * @return array + */ + public function getResetPasswordMailFields($locale = null) + { + $result['reset_key'] = $this->getPasswordResetKey(); + $result['reset_url'] = $this->util->getCurrentURI('index/resetpassword/key/' . $result['reset_key']); + + return $result + $this->getMailFields($locale); + } + + /** * Returns the current user role. * * @return string @@ -942,7 +1046,51 @@ } /** + * Send an e-mail to this user * + * @param string $subjectTemplate A subject template in which {fields} are replaced + * @param string $bbBodyTemplate A BB Code body template in which {fields} are replaced + * @param boolean $useResetFields When true get a reset key for this user + * @param string $locale Optional locale + * @return mixed String or array of warnings when something went wrong + */ + public function sendMail($subjectTemplate, $bbBodyTemplate, $useResetFields = false, $locale = null) + { + if ($useResetFields && (! $this->canResetPassword())) { + return $this->_('Trying to send a password reset to a user that cannot be reset.'); + } + + $mail = new Gems_Mail(); + $mail->setTemplateStyle($this->getBaseOrganization()->getStyle()); + $mail->setFrom($this->getFrom()); + $mail->addTo($this->getEmailAddress(), $this->getFullName(), $this->project->getEmailBounce()); + if ($bcc = $this->project->getEmailBcc()) { + $mail->addBcc($bcc); + } + + if ($useResetFields) { + $fields = $this->getResetPasswordMailFields($locale); + } else { + $fields = $this->getMailFields($locale); + } + $fields = MUtil_Ra::braceKeys($fields, '{', '}'); + + $mail->setSubject(strtr($subjectTemplate, $fields)); + $mail->setBodyBBCode(strtr($bbBodyTemplate, $fields)); + + try { + $mail->send(); + return null; + + } catch (Exception $e) { + return array( + $this->_('Unable to send e-mail.'), + $e->getMessage()); + } + } + + /** + * * @param string $defName Optional * @return Gems_User_User (continuation pattern) */ Modified: trunk/library/classes/Gems/User/UserLoader.php =================================================================== --- trunk/library/classes/Gems/User/UserLoader.php 2012-03-29 10:01:28 UTC (rev 574) +++ trunk/library/classes/Gems/User/UserLoader.php 2012-03-29 11:44:15 UTC (rev 575) @@ -263,7 +263,13 @@ if (! self::$currentUser) { if ($this->session->__isset('__user_definition')) { $defName = $this->session->__get('__user_definition'); - self::$currentUser = $this->_loadClass('User', true, array($this->session, $this->_getClass($defName . 'Definition'))); + + // Check for during upgrade. Remove for version 1.6 + if (substr($defName, -10, 10) != 'Definition') { + $defName .= 'Definition'; + } + + self::$currentUser = $this->_loadClass('User', true, array($this->session, $this->_getClass($defName))); } else { self::$currentUser = $this->getUser(null, null); self::$currentUser->setAsCurrentUser(); @@ -503,7 +509,7 @@ // MUtil_Echo::track($defName, $login_name, $userOrganization, $values); $values = $this->ensureDefaultUserValues($values, $definition, $defName); - MUtil_Echo::track($values, $userName, $userOrganization, $defName); + // MUtil_Echo::track($values, $userName, $userOrganization, $defName); return $this->_loadClass('User', true, array($values, $definition)); } Modified: trunk/library/classes/Gems/Util/Translated.php =================================================================== --- trunk/library/classes/Gems/Util/Translated.php 2012-03-29 10:01:28 UTC (rev 574) +++ trunk/library/classes/Gems/Util/Translated.php 2012-03-29 11:44:15 UTC (rev 575) @@ -193,16 +193,38 @@ return self::$emptyDropdownArray; } + /** + * Returns the functional description of a gender for use in e.g. interface elements + * + * @param string $locale + * @return array gender => string + */ public function getGenders($locale = null) { return array('M' => $this->_('Male', $locale), 'F' => $this->_('Female', $locale), 'U' => $this->_('Unknown', $locale)); } + /** + * Returns the gender for use as part of a sentence, e.g. Dear Mr/Mrs + * + * In practice: starts lowercase + * + * @param string $locale + * @return array gender => string + */ public function getGenderGreeting($locale = null) { return array('M' => $this->_('mr.', $locale), 'F' => $this->_('mrs.', $locale), 'U' => $this->_('mr./mrs.', $locale)); } + /** + * Returns the gender for use in stand-alone name display + * + * In practice: starts uppercase + * + * @param string $locale + * @return array gender => string + */ public function getGenderHello($locale = null) { return array('M' => $this->_('Mr.', $locale), 'F' => $this->_('Mrs.', $locale), 'U' => $this->_('Mr./Mrs.', $locale)); Modified: trunk/library/classes/MUtil/Mail.php =================================================================== --- trunk/library/classes/MUtil/Mail.php 2012-03-29 10:01:28 UTC (rev 574) +++ trunk/library/classes/MUtil/Mail.php 2012-03-29 11:44:15 UTC (rev 575) @@ -1,39 +1,64 @@ <?php - -/** - * Copyright (c) 2011, Erasmus MC - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of Erasmus MC nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - + /** - * @package MUtil + * Copyright (c) 2011, Erasmus MC + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Erasmus MC nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * + * @package MUtil + * @subpackage Mail + * @author Matijs de Jong <mj...@ma...> + * @copyright Copyright (c) 2012 Erasmus MC + * @license New BSD License + * @version $id: Mail.php 203 2012-01-01t 12:51:32Z matijs $ */ + +/** + * Extends standard Zend_Mail with functions for using HTML templates for all mails + * and adding content using BB Code text. + * + * @package MUtil + * @subpackage Mail + * @copyright Copyright (c) 2012 Erasmus MC + * @license New BSD License + * @since Class available since version 1.1 + */ class MUtil_Mail extends Zend_Mail { - private $_htmlTemplate; + /** + * HTML Template for html part of the message + * + * @var string + */ + protected $_htmlTemplate; + /** + * Returns the the current template + * + * @return string + */ public function getHtmlTemplate() { if (! $this->_htmlTemplate) { @@ -43,6 +68,12 @@ return $this->_htmlTemplate; } + /** + * Set both the Html and Text versions of a message + * + * @param string $content + * @return MUtil_Mail (continuation pattern) + */ public function setBodyBBCode($content) { $this->setBodyHtml(MUtil_Markup::render($content, 'Bbcode', 'Html')); @@ -52,12 +83,12 @@ } /** - * Sets the HTML body for the message + * Sets the HTML body for the message, using a template for html if it exists/ * * @param string $html * @param string $charset * @param string $encoding - * @return Zend_Mail Provides fluent interface + * @return MUtil_Mail (continuation pattern) */ public function setBodyHtml($html, $charset = null, $encoding = Zend_Mime::ENCODING_QUOTEDPRINTABLE) { @@ -68,12 +99,24 @@ return parent::setBodyHtml($html, $charset, $encoding); } + /** + * Set's a html template in which the message content is placed. + * + * @param string $template + * @return MUtil_Mail MUtil_Mail (continuation pattern) + */ public function setHtmlTemplate($template) { $this->_htmlTemplate = $template; return $this; } + /** + * Set the basic html template with the content of a filename + * + * @param string $filename + * @return MUtil_Mail (continuation pattern) + */ public function setHtmlTemplateFile($filename) { if (file_exists($filename)) { Modified: trunk/library/classes/MUtil/Ra.php =================================================================== --- trunk/library/classes/MUtil/Ra.php 2012-03-29 10:01:28 UTC (rev 574) +++ trunk/library/classes/MUtil/Ra.php 2012-03-29 11:44:15 UTC (rev 575) @@ -267,7 +267,8 @@ // 1: Not yet set && 2: lax types used if ((! isset($args[$name])) && - ($laxTypes || (null === $ntype))) { + ($laxTypes || (null === $ntype)) && + isset($args[$current])) { $args[$name] = $args[$current]; unset($args[$current]); @@ -345,6 +346,28 @@ } /** + * Put braces around the array keys. + * + * @param array $input + * @param string $left Brace string, e.g. '%', '{', '[', '"' + * @param string $right Optional, when emptu same as left. + * @return array Array with the same values but braces around the keys + */ + public static function braceKeys(array $input, $left, $right = null) + { + if (null === $right) { + $right = $left; + } + $results = array(); + + foreach ($input as $key => $value) { + $results[$left . $key . $right] = $value; + } + + return $results; + } + + /** * Extracts a column from a nested array of values, maintaining index association. * * The default RELAXED mode will return only values where these exist and are not null. @@ -442,7 +465,7 @@ return true; } - + return is_scalar($value); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2012-04-06 18:09:37
|
Revision: 603 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=603&view=rev Author: matijsdejong Date: 2012-04-06 18:09:30 +0000 (Fri, 06 Apr 2012) Log Message: ----------- Fixed bug in change password form Form element errors are displayed after the description = easier on the eye Added documentation to form layout elements ElementDecorator.php can now display the errors for the whole form on top of the form Modified Paths: -------------- trunk/library/classes/Gems/User/Form/ChangePasswordForm.php trunk/library/classes/MUtil/Form.php trunk/library/classes/MUtil/Html/DlElement.php trunk/library/classes/MUtil/Html/ElementDecorator.php trunk/library/classes/MUtil/Html/FormLayout.php trunk/library/classes/MUtil/Html/TableElement.php trunk/library/classes/MUtil/Html.php Modified: trunk/library/classes/Gems/User/Form/ChangePasswordForm.php =================================================================== --- trunk/library/classes/Gems/User/Form/ChangePasswordForm.php 2012-04-06 14:02:23 UTC (rev 602) +++ trunk/library/classes/Gems/User/Form/ChangePasswordForm.php 2012-04-06 18:09:30 UTC (rev 603) @@ -75,13 +75,6 @@ protected $_reportRulesFieldName = 'report_rules'; /** - * The field name for the submit element. - * - * @var string - */ - protected $_submitFieldName = 'submit'; - - /** * Layout table * * @var MUtil_Html_TableElements @@ -327,25 +320,13 @@ } /** - * Returns/sets a submit button. + * Returns the label for the submitbutton * - * @param string $label - * @return Zend_Form_Element_Submit + * @return string */ - public function getSubmitButton($label = null) + public function getSubmitButtonLabel() { - $element = $this->getElement($this->_submitFieldName); - - if (! $element) { - // Submit knop - $element = new Zend_Form_Element_Submit($this->_submitFieldName); - $element->setLabel(null === $label ? $this->translate->_('Save') : $label); - $element->setAttrib('class', 'button'); - - $this->addElement($element); - } - - return $element; + return $this->translate->_($this->translate->_('Save')); } /** Modified: trunk/library/classes/MUtil/Form.php =================================================================== --- trunk/library/classes/MUtil/Form.php 2012-04-06 14:02:23 UTC (rev 602) +++ trunk/library/classes/MUtil/Form.php 2012-04-06 18:09:30 UTC (rev 603) @@ -45,7 +45,12 @@ class MUtil_Form extends Zend_Form { protected $_displayOrder = array('element', 'errors', 'description'); + + /** + * $var MUtil_HtmlElement + */ protected $_html_element; + protected $_labelWidth; protected $_labelWidthFactor; protected $_no_dojo = true; @@ -161,11 +166,25 @@ } /** + * Returns an Html element that is used to render the form contents. * - * @return MUtil_Html_HtmlElement + * @return MUtil_Html_HtmlElement Or an equivalent class */ public function getHtml() { + if (! $this->_html_element) { + foreach ($this->_decorators as $decorator) { + if ($decorator instanceof MUtil_Html_ElementDecorator) { + break; + } + } + if ($decorator instanceof MUtil_Html_ElementDecorator) { + $this->_html_element = $decorator->getHtmlElement(); + } else { + $this->setHtml(); + } + } + return $this->_html_element; } @@ -253,7 +272,7 @@ return $this; } - public function setDisplayOrder(array $order) + public function setDisplayOrder(array $order) { $this->_displayOrder = $order; @@ -304,6 +323,12 @@ return $this; } + /** + * Render the element labels with a fixed width + * + * @param mixed $width The style.width content for the labels + * @return MUtil_Form (continuation pattern) + */ public function setLabelWidth($width) { $this->_labelWidth = $width; @@ -316,6 +341,13 @@ return $this; } + /** + * Render elements with an automatically calculated label width, by multiplying the maximum number of + * characters in a label with this factor. + * + * @param float $factor To multiply the widest nummers of letters in the labels with to calculate the width in em at drawing time + * @return MUtil_Form (continuation pattern) + */ public function setLabelWidthFactor($factor) { $this->_labelWidthFactor = $factor; Modified: trunk/library/classes/MUtil/Html/DlElement.php =================================================================== --- trunk/library/classes/MUtil/Html/DlElement.php 2012-04-06 14:02:23 UTC (rev 602) +++ trunk/library/classes/MUtil/Html/DlElement.php 2012-04-06 18:09:30 UTC (rev 603) @@ -1,53 +1,90 @@ <?php - -/** - * Copyright (c) 2011, Erasmus MC - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of Erasmus MC nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - /** - * @author Matijs de Jong - * @since 1.0 - * @version 1.1 - * @package MUtil + * Copyright (c) 2011, Erasmus MC + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Erasmus MC nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * + * @package MUtil * @subpackage Html + * @author Matijs de Jong <mj...@ma...> + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @version $Id$ */ +/** + * Html DL element with functions for applying it to a form. + * + * @package MUtil + * @subpackage Html + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @since Class available since version 1.0 + */ class MUtil_Html_DlElement extends MUtil_Html_HtmlElement implements MUtil_Html_FormLayout { - public $renderWithoutContent = false; - + /** + * Only dt and dd elements are allowed as content. + * + * @var string|array A string or array of string values of the allowed element tags. + */ protected $_allowedChildTags = array('dt', 'dd'); + /** + * Put a Dl element on it's own line + * + * @var string Content added after the element. + */ protected $_appendString = "\n"; + /** + * Can process form elements + * + * @var array + */ protected $_specialTypes = array( 'Zend_Form' => 'setAsFormLayout', ); + /** + * Should have content + * + * @var boolean The element is rendered even without content when true. + */ + public $renderWithoutContent = false; + + + /** + * Make a DL element + * + * Any parameters are added as either content, attributes or handled + * as special types, if defined as such for this element. + * + * @param mixed $arg_array MUtil_Ra::args arguments + */ public function __construct($arg_array = null) { $args = MUtil_Ra::args(func_get_args()); @@ -94,6 +131,15 @@ return $ds; } + /** + * Helper function for creating automatically calculated widths. + * + * @staticvar Zend_Form $last_form Prevent recalculation. This function is called for every label + * @staticvar string $last_factor Last result + * @param Zend_Form $form The form to calculate the widest label for + * @param float $factor The factor to multiple the number of characters with for to get the number of em's + * @return string E.g.: '10em' + */ public static function calculateAutoWidthFormLayout(Zend_Form $form, $factor = 1) { static $last_form; @@ -130,6 +176,12 @@ } + /** + * Static helper function for creation, used by @see MUtil_Html_Creator. + * + * @param mixed $arg_array Optional MUtil_Ra::args processed settings + * @return MUtil_Html_DlElement + */ public static function dl($arg_array = null) { $args = func_get_args(); @@ -141,6 +193,14 @@ return $this->addItem($dt, $dd); } + /** + * Apply this element to the form as the output decorator. + * + * @param Zend_Form $form + * @param mixed $width The style.width content for the labels + * @param array $order The display order of the elements + * @return MUtil_Html_DlElement + */ public function setAsFormLayout(Zend_Form $form, $width = null, array $order = array('element', 'errors', 'description')) { // Make a Lazy repeater for the form elements and set it as the element repeater @@ -171,7 +231,14 @@ return $this; } - + /** + * Apply this element to the form as the output decorator with automatically calculated widths. + * + * @param Zend_Form $form + * @param float $factor To multiply the widest nummers of letters in the labels with to calculate the width in em at drawing time + * @param array $order The display order of the elements + * @return MUtil_Html_DlElement + */ public function setAutoWidthFormLayout(Zend_Form $form, $factor = 1, array $order = array('element', 'errors', 'description')) { // Lazy call becase the form might not be completed at this stage. Modified: trunk/library/classes/MUtil/Html/ElementDecorator.php =================================================================== --- trunk/library/classes/MUtil/Html/ElementDecorator.php 2012-04-06 14:02:23 UTC (rev 602) +++ trunk/library/classes/MUtil/Html/ElementDecorator.php 2012-04-06 18:09:30 UTC (rev 603) @@ -1,51 +1,102 @@ <?php - -/** - * Copyright (c) 2011, Erasmus MC - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of Erasmus MC nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - /** - * @author Matijs de Jong - * @since 1.0 - * @version 1.1 - * @package MUtil + * Copyright (c) 2011, Erasmus MC + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Erasmus MC nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * + * @package MUtil * @subpackage Html + * @author Matijs de Jong <mj...@ma...> + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @version $Id$ */ +/** + * Zend style form decorator the uses MUtil_Html + * + * @package MUtil + * @subpackage Html + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @since Class available since version 1.0 + */ class MUtil_Html_ElementDecorator extends Zend_Form_Decorator_Abstract { + /** + * + * @var MUtil_Html_HtmlInterface + */ protected $_html_element; + + /** + * When existing prepends all error messages before the form elements. + * + * When a MUtil_Html_HtmlElement the errors are appended to the element, + * otherwise an UL is created + * + * @var mixed + */ + protected $_prepend_errors; + + /** + * Any content to be displayed before the visible elements + * + * @var mixed + */ protected $_prologue; + /** + * The element used to display the (visible) form elements. + * + * @return MUtil_Html_HtmlInterface + */ public function getHtmlElement() { return $this->_html_element; } + /** + * Must the form prepend all error messages before the visible form elements? + * + * When a MUtil_Html_HtmlElement the errors are appended to the element, + * otherwise an UL is created + * + * @return mixed false, true or MUtil_Html_HtmlElement + */ + public function getPrependErrors() + { + return $this->_prepend_errors; + } + + /** + * Any content to be displayed before the visible elements + * + * @return mixed + */ public function getPrologue() { return $this->_prologue; @@ -82,7 +133,23 @@ } else { $prologue = ''; } + if ($prependErrors = $this->getPrependErrors()) { + $form = $this->getElement(); + if ($errors = $form->getMessages()) { + $errors = MUtil_Ra::flatten($errors); + $errors = array_unique($errors); + if ($prependErrors instanceof MUtil_Html_ElementInterface) { + $html = $prependErrors; + } else { + $html = MUtil_Html::create('ul'); + } + $html->append($errors); + + $prologue .= $html->render($view); + } + } + $result = $this->renderElement($htmlelement, $view); if (parent::APPEND == $this->getPlacement()) { @@ -107,12 +174,42 @@ return $htmlElement->render($view); } + /** + * Set the default + * + * @param MUtil_Html_HtmlInterface $htmlElement + * @return MUtil_Html_ElementDecorator (continuation pattern) + */ public function setHtmlElement(MUtil_Html_HtmlInterface $htmlElement) { $this->_html_element = $htmlElement; return $this; } + /** + * Set the form to prepends all error messages before the visible form elements. + * + * When a MUtil_Html_HtmlElement the errors are appended to the element, + * otherwise an UL is created + * + * @param mixed $prepend false, true or MUtil_Html_HtmlElement + * @return MUtil_Html_ElementDecorator (continuation pattern) + */ + public function setPrependErrors($prepend = true) + { + $this->_prepend_errors = $prepend; + return $this; + } + + /** + * Hidden elements should be displayed at the start of the form. + * + * If the prologue is a MUtil_Lazy_RepeatableFormElements repeater then all the hidden elements are + * displayed in a div at the start of the form. + * + * @param mixed $prologue E.g. a repeater or a html element + * @return MUtil_Html_ElementDecorator + */ public function setPrologue($prologue) { $this->_prologue = $prologue; Modified: trunk/library/classes/MUtil/Html/FormLayout.php =================================================================== --- trunk/library/classes/MUtil/Html/FormLayout.php 2012-04-06 14:02:23 UTC (rev 602) +++ trunk/library/classes/MUtil/Html/FormLayout.php 2012-04-06 18:09:30 UTC (rev 603) @@ -1,42 +1,57 @@ <?php - -/** - * Copyright (c) 2011, Erasmus MC - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of Erasmus MC nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - /** - * @author Matijs de Jong - * @since 1.0 - * @version 1.1 - * @package MUtil + * Copyright (c) 2011, Erasmus MC + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Erasmus MC nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * + * @package MUtil * @subpackage Html + * @author Matijs de Jong <mj...@ma...> + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @version $Id$ */ +/** + * Interface extensions that allows HtmlElements to define how to display + * form elements. + * + * @package MUtil + * @subpackage Html + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @since Class available since version 1.0 + */ interface MUtil_Html_FormLayout { + /** + * Apply this element to the form as the output decorator. + * + * @param Zend_Form $form + * @return MUtil_Html_FormLayout + */ public function setAsFormLayout(Zend_Form $form); } Modified: trunk/library/classes/MUtil/Html/TableElement.php =================================================================== --- trunk/library/classes/MUtil/Html/TableElement.php 2012-04-06 14:02:23 UTC (rev 602) +++ trunk/library/classes/MUtil/Html/TableElement.php 2012-04-06 18:09:30 UTC (rev 603) @@ -1,6 +1,5 @@ <?php - /** * Copyright (c) 2011, Erasmus MC * All rights reserved. @@ -734,6 +733,14 @@ return $this; } + /** + * Apply this element to the form as the output decorator. + * + * @param Zend_Form $form + * @param boolean $add_description When true the description is displayed + * @param boolean $include_description When false the description is added in a separate column instead of the element column. + * @return MUtil_Html_TableElement + */ public function setAsFormLayout(Zend_Form $form, $add_description = false, $include_description = false) { // Make a Lazy repeater for the form elements and set it as the element repeater @@ -746,12 +753,12 @@ // $this->tdh()->label('[', $formrep->element, ']'); $elements[] = $formrep->element; - $elements[] = ' '; - $elements[] = $formrep->errors; if ($add_description && $include_description) { $elements[] = ' '; $elements[] = $formrep->description; } + $elements[] = ' '; + $elements[] = $formrep->errors; $this->addColumn($elements); // Element, Error & optional description if ($add_description && (! $include_description)) { $this->addColumn($formrep->description); // Description in separate column Modified: trunk/library/classes/MUtil/Html.php =================================================================== --- trunk/library/classes/MUtil/Html.php 2012-04-06 14:02:23 UTC (rev 602) +++ trunk/library/classes/MUtil/Html.php 2012-04-06 18:09:30 UTC (rev 603) @@ -98,6 +98,7 @@ } /** + * Create an element or return an element creator * * @param string $tagName Optional tag to create * @param mixed $arg_array Optional MUtil_Ra::args processed settings @@ -131,6 +132,13 @@ return self::getCreator()->create($tagName, $args); } + /** + * Create an element bypassing the standard element creation function stored for certain tags. + * + * @param string $tagName Optional tag to create + * @param mixed $arg_array Optional MUtil_Ra::args processed settings + * @return MUtil_Html_HtmlElement Always, never another type + */ public static function createRaw($tagName, array $args = array()) { return self::getCreator()->createRaw($tagName, $args); @@ -196,11 +204,26 @@ return self::$_snippetLoader; } + /** + * Replaces the non html name characters in the name. + * + * Helper function for working with Zend_Form_Element's + * + * @param string $name + * @param string $belongsTo + * @return string + */ public static function name2id($name, $belongsTo = null) { return preg_replace('/\[([^\]]+)\]/', '-$1', $name . '-' . $belongsTo); } + /** + * String content that should be rendered without output escaping + * + * @param string $content + * @return MUtil_Html_Raw + */ public static function raw($content) { return self::getCreator()->create('raw', array($content)); @@ -285,6 +308,12 @@ } } + /** + * Returns a href attribute + * + * @param mixed $arg_array MUtil_Args::ra arguements + * @return MUtil_Html_HrefArrayAttribute + */ public static function url($arg_array = null) { $args = func_get_args(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2012-04-23 10:33:42
|
Revision: 628 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=628&view=rev Author: mennodekker Date: 2012-04-23 10:33:33 +0000 (Mon, 23 Apr 2012) Log Message: ----------- Introduction logLevels, to allow different logging for develop/test environments vs production environment Modified Paths: -------------- trunk/library/classes/Gems/Log.php trunk/library/classes/Gems/Project/ProjectSettings.php trunk/library/classes/GemsEscort.php Modified: trunk/library/classes/Gems/Log.php =================================================================== --- trunk/library/classes/Gems/Log.php 2012-04-20 07:26:30 UTC (rev 627) +++ trunk/library/classes/Gems/Log.php 2012-04-23 10:33:33 UTC (rev 628) @@ -99,6 +99,14 @@ } } */ + foreach ($info as $line) { + $this->log($line, Zend_Log::ERR); + } + + // Now empty as we are going to log potentially sensitive debug data + // We log this with a Zend_Log::DEBUG level, so filter can strip it if needed + $info = array(); + if (!empty($request)) { $info[] = 'Request Parameters:'; foreach ($request->getParams() as $key => $value) { @@ -110,7 +118,7 @@ $info[] = $exception->getTraceAsString(); foreach ($info as $line) { - $this->log($line, Zend_Log::ERR); + $this->log($line, Zend_Log::DEBUG); } } Modified: trunk/library/classes/Gems/Project/ProjectSettings.php =================================================================== --- trunk/library/classes/Gems/Project/ProjectSettings.php 2012-04-20 07:26:30 UTC (rev 627) +++ trunk/library/classes/Gems/Project/ProjectSettings.php 2012-04-23 10:33:33 UTC (rev 628) @@ -325,6 +325,34 @@ } /** + * Get the logLevel to use with the Gems_Log + * + * Default settings is for development and testing environment to use Zend_Log::DEBUG and + * for all other environments to use the Zend_Log::ERR level. This can be overruled by + * specifying a logLevel in the project.ini + * + * Using a level higher than Zend_Log::ERR will output full error messages, traces and request + * info to the logfile. Please be aware that this might introduce a security risk as passwords + * might be written to the logfile in plain text. + * + * @return int The loglevel to use + */ + public function getLogLevel() + { + if (isset($this['logLevel'])) { + $logLevel = $this['logLevel']; + } else { + if ('development' == APPLICATION_ENV || 'testing' == APPLICATION_ENV) { + $logLevel = Zend_Log::DEBUG; + } else { + $logLevel = Zend_Log::ERR; + } + } + + return $logLevel; + } + + /** * Array of field name => values for sending E-Mail * * @return array Modified: trunk/library/classes/GemsEscort.php =================================================================== --- trunk/library/classes/GemsEscort.php 2012-04-20 07:26:30 UTC (rev 627) +++ trunk/library/classes/GemsEscort.php 2012-04-23 10:33:33 UTC (rev 628) @@ -200,6 +200,7 @@ */ protected function _initLogger() { + $this->bootstrap('project'); // Make sure the project object is available $logger = Gems_Log::getLogger(); $log_path = GEMS_ROOT_DIR . '/var/logs'; @@ -211,11 +212,15 @@ die(sprintf($this->translate->_('Path %s not writable'), $log_path)); } + $filter = new Zend_Log_Filter_Priority($project->getLogLevel()); + $writer->addFilter($filter); $logger->addWriter($writer); // OPTIONAL STARTY OF FIREBUG LOGGING. if ($this->_startFirebird) { $logger->addWriter(new Zend_Log_Writer_Firebug()); + //We do not add the logLevel here, as the firebug window is intended for use by + //developers only and it is only written to the active users' own screen. } Zend_Registry::set('logger', $logger); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2012-05-04 09:44:54
|
Revision: 666 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=666&view=rev Author: michieltcs Date: 2012-05-04 09:44:43 +0000 (Fri, 04 May 2012) Log Message: ----------- Set cookies to http only, and make them secure on production sites (which should be on https) Modified Paths: -------------- trunk/library/classes/Gems/Cookies.php trunk/library/classes/GemsEscort.php Modified: trunk/library/classes/Gems/Cookies.php =================================================================== --- trunk/library/classes/Gems/Cookies.php 2012-05-04 08:52:10 UTC (rev 665) +++ trunk/library/classes/Gems/Cookies.php 2012-05-04 09:44:43 UTC (rev 666) @@ -102,7 +102,7 @@ } // Set the cookie for 30 days - return setcookie($name, $value, time() + ($days * 86400), $basepath); + return setcookie($name, $value, time() + ($days * 86400), $basepath, '', (APPLICATION_ENV == 'production'), true); } /** Modified: trunk/library/classes/GemsEscort.php =================================================================== --- trunk/library/classes/GemsEscort.php 2012-05-04 08:52:10 UTC (rev 665) +++ trunk/library/classes/GemsEscort.php 2012-05-04 09:44:43 UTC (rev 666) @@ -90,8 +90,10 @@ $firebug = $application->getOption('firebug'); $this->_startFirebird = $firebug['log']; - $sessionOptions['name'] = GEMS_PROJECT_NAME_UC . '_' . md5(APPLICATION_PATH) . '_SESSID'; - $sessionOptions['cookie_path'] = strtr(dirname($_SERVER['SCRIPT_NAME']), '\\', '/'); + $sessionOptions['name'] = GEMS_PROJECT_NAME_UC . '_' . md5(APPLICATION_PATH) . '_SESSID'; + $sessionOptions['cookie_path'] = strtr(dirname($_SERVER['SCRIPT_NAME']), '\\', '/'); + $sessionOptions['cookie_httponly'] = true; + $sessionOptions['cookie_secure'] = (APPLICATION_ENV == 'production'); Zend_Session::start($sessionOptions); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2012-05-16 10:44:48
|
Revision: 684 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=684&view=rev Author: mennodekker Date: 2012-05-16 10:44:42 +0000 (Wed, 16 May 2012) Log Message: ----------- Restored redirection / post saving after session timeout Modified Paths: -------------- trunk/library/classes/Gems/Default/IndexAction.php trunk/library/classes/GemsEscort.php Modified: trunk/library/classes/Gems/Default/IndexAction.php =================================================================== --- trunk/library/classes/Gems/Default/IndexAction.php 2012-05-15 12:11:40 UTC (rev 683) +++ trunk/library/classes/Gems/Default/IndexAction.php 2012-05-16 10:44:42 UTC (rev 684) @@ -203,13 +203,14 @@ $request = $this->getRequest(); $form = $this->createLoginForm(); + // Retrieve these before the session is reset + $staticSession = GemsEscort::getInstance()->getStaticSession(); + $previousRequestParameters = $staticSession->previousRequestParameters; + $previousRequestMode = $staticSession->previousRequestMode; + if ($request->isPost()) { if ($form->isValid($request->getPost(), false)) { $user = $form->getUser(); - - // Retrieve these before the session is reset - $previousRequestParameters = $this->session->previousRequestParameters; - $user->setAsCurrentUser(); if ($messages = $user->reportPasswordWeakness($request->getParam($form->passwordFieldName))) { Modified: trunk/library/classes/GemsEscort.php =================================================================== --- trunk/library/classes/GemsEscort.php 2012-05-15 12:11:40 UTC (rev 683) +++ trunk/library/classes/GemsEscort.php 2012-05-16 10:44:42 UTC (rev 684) @@ -410,6 +410,10 @@ $session->user_role = 'nologin'; } + // Since userloading can clear the session, we put stuff that should remain (like redirect info) + // in a different namespace that we call a 'static session', use getStaticSession to access. + $this->staticSession = new Zend_Session_Namespace('gems.' . GEMS_PROJECT_NAME . '.sessionStatic'); + return $session; } @@ -1309,6 +1313,16 @@ } /** + * Returns a static session, that will not be affected by loading or unloading a user + * + * @return Zend_Session_Namespace + */ + public function getStaticSession() + { + return $this->staticSession; + } + + /** * Hook 12: Called after an action is dispatched by Zend_Controller_Dispatcher. * * This callback allows for proxy or filter behavior. By altering the @@ -1387,20 +1401,21 @@ */ public function preDispatch(Zend_Controller_Request_Abstract $request) { - if ($this->session->user_id && $previousRequestParameters = $this->session->previousRequestParameters) { + $staticSession = $this->getStaticSession(); + if ($this->session->user_id && $previousRequestParameters = $staticSession->previousRequestParameters) { unset($previousRequestParameters['save_button']); unset($previousRequestParameters['userlogin']); unset($previousRequestParameters['password']); // fake POST - if ($this->session->previousRequestMode == 'POST') { + if ($staticSession->previousRequestMode == 'POST') { $this->addMessage($this->_('Take note: your session has expired, your inputs were not saved. Please check the input data and try again')); $_POST = $previousRequestParameters; - $_SERVER['REQUEST_METHOD'] = $this->session->previousRequestMode; - $this->session->previousRequestMode = null; + $_SERVER['REQUEST_METHOD'] = $staticSession->previousRequestMode; + $staticSession->previousRequestMode = null; } - $this->session->previousRequestParameters = null; + $staticSession->previousRequestParameters = null; } $this->setControllerDirectory($request); @@ -1576,8 +1591,9 @@ $this->addMessage($this->_('You must login to access this page.')); // save original request, we will redirect back once the user succesfully logs in - $this->session->previousRequestParameters = $request->getParams(); - $this->session->previousRequestMode = ($request->isPost() ? "POST" : "GET"); + $staticSession = $this->getStaticSession(); + $staticSession->previousRequestParameters = $request->getParams(); + $staticSession->previousRequestMode = ($request->isPost() ? "POST" : "GET"); } $redirector = Zend_Controller_Action_HelperBroker::getStaticHelper('redirector'); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2012-05-18 14:38:30
|
Revision: 691 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=691&view=rev Author: michieltcs Date: 2012-05-18 14:38:23 +0000 (Fri, 18 May 2012) Log Message: ----------- Move PDF version validation to MUtil_Validate_Pdf Modified Paths: -------------- trunk/library/classes/Gems/Default/SurveyMaintenanceAction.php Added Paths: ----------- trunk/library/classes/MUtil/Validate/Pdf.php Modified: trunk/library/classes/Gems/Default/SurveyMaintenanceAction.php =================================================================== --- trunk/library/classes/Gems/Default/SurveyMaintenanceAction.php 2012-05-18 14:35:15 UTC (rev 690) +++ trunk/library/classes/Gems/Default/SurveyMaintenanceAction.php 2012-05-18 14:38:23 UTC (rev 691) @@ -130,7 +130,8 @@ 'destination', $this->loader->getPdf()->getUploadDir('survey_pdfs'), 'extension', 'pdf', 'filename', $data['gsu_id_survey'], - 'required', false); + 'required', false) + ->addValidator(new MUtil_Validate_Pdf()); $bridge->addExhibitor( 'track_count', 'label', $this->_('Usage'), 'value', $data['track_count']); @@ -242,21 +243,12 @@ } // Set the value of the field in the database. - $data['gsu_survey_pdf'] = null; $new_name = $data['gsu_id_survey'] . '.pdf'; - $pdfSource = $form->new_pdf->getDestination() . DIRECTORY_SEPARATOR . $new_name; - if (file_exists($pdfSource)) { - $objFactory = Zend_Pdf_ElementFactory::createFactory(1); - $parser = new Zend_Pdf_Parser($pdfSource, $objFactory, true); - $version = $parser->getPDFVersion(); - - if (version_compare($version, '1.4', '>')) { - $this->addMessage(sprintf($this->_('Unsupported PDF version %s - only versions 1.0 - 1.4 are supported.'), $version)); - return false; - } - + if (file_exists($form->new_pdf->getDestination() . DIRECTORY_SEPARATOR . $new_name)) { $data['gsu_survey_pdf'] = $new_name; + } else { + $data['gsu_survey_pdf'] = null; } $data['gtr_track_class'] = 'SingleSurveyEngine'; Added: trunk/library/classes/MUtil/Validate/Pdf.php =================================================================== --- trunk/library/classes/MUtil/Validate/Pdf.php (rev 0) +++ trunk/library/classes/MUtil/Validate/Pdf.php 2012-05-18 14:38:23 UTC (rev 691) @@ -0,0 +1,80 @@ +<?php + + +/** + * Copyright (c) 2012, Erasmus MC + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Erasmus MC nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * @author Michiel Rook <mi...@to...> + * @version $Id$ + * @package MUtil + * @subpackage Validate + */ + +/** + * + * @author Michiel Rook <mi...@to...> + * @package MUtil + * @subpackage Validate + */ +class MUtil_Validate_Pdf extends Zend_Validate_Abstract +{ + /** + * Error constants + */ + const ERROR_INVALID_VERSION = 'invalidVersion'; + + /** + * @var array Message templates + */ + protected $_messageTemplates = array( + self::ERROR_INVALID_VERSION => 'Unsupported PDF version %value% - only versions 1.0 - 1.4 are supported.' + ); + + /** + * Returns true if and only if $value meets the validation requirements + * + * If $value fails validation, then this method returns false, and + * getMessages() will return an array of messages that explain why the + * validation failed. + * + * @param mixed $value + * @return boolean + * @throws Zend_Valid_Exception If validation of $value is impossible + */ + public function isValid($value, $context = array()) + { + $objFactory = Zend_Pdf_ElementFactory::createFactory(1); + $parser = new Zend_Pdf_Parser($value, $objFactory, true); + $version = $parser->getPDFVersion(); + + if (version_compare($version, '1.4', '>')) { + $this->_error(self::ERROR_INVALID_VERSION, $version); + return false; + } + + return true; + } +} Property changes on: trunk/library/classes/MUtil/Validate/Pdf.php ___________________________________________________________________ Added: svn:keywords + Id Rev Revision Date Author Added: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2012-05-24 13:29:11
|
Revision: 700 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=700&view=rev Author: matijsdejong Date: 2012-05-24 13:29:00 +0000 (Thu, 24 May 2012) Log Message: ----------- Real fix for 695: the problem was in teh double application of a dateFormat with a formatFunction (disable everywhere) and a default value that use a different date format than the storageFormat. Modified Paths: -------------- trunk/library/classes/Gems/Default/SurveyAction.php trunk/library/classes/Gems/Default/TrackAction.php trunk/library/classes/Gems/Default/TrackActionAbstract.php trunk/library/classes/Gems/FormattedData.php trunk/library/classes/Gems/Tracker/Snippets/EditTrackSnippetAbstract.php trunk/library/classes/Gems/Tracker/Snippets/ShowTrackUsageAbstract.php trunk/library/classes/MUtil/Model/TableBridgeAbstract.php trunk/library/classes/MUtil/View/Helper/Exhibitor.php Modified: trunk/library/classes/Gems/Default/SurveyAction.php =================================================================== --- trunk/library/classes/Gems/Default/SurveyAction.php 2012-05-24 12:37:55 UTC (rev 699) +++ trunk/library/classes/Gems/Default/SurveyAction.php 2012-05-24 13:29:00 UTC (rev 700) @@ -190,10 +190,14 @@ //$model->resetOrder(); $model->set('gsu_survey_name', 'label', $this->_('Survey')); $model->set('ggp_name', 'label', $this->_('By'), 'elementClass', 'Exhibitor'); - $model->set('gtr_date_start', 'label', $this->_('From'), 'dateFormat', Gems_Tracker::DB_DATE_FORMAT, 'tdClass', 'date', - 'formatFunction', $this->util->getTranslated()->formatDate); - $model->set('gtr_date_until', 'label', $this->_('Until'), 'dateFormat', Gems_Tracker::DB_DATE_FORMAT, 'tdClass', 'date', - 'formatFunction', $this->util->getTranslated()->formatDateNa); + $model->set('gtr_date_start', 'label', $this->_('From'), + 'dateFormat', 'dd-MM-yyyy', + 'tdClass', 'date', + 'formatFunction', $this->util->getTranslated()->formatDate); + $model->set('gtr_date_until', 'label', $this->_('Until'), + 'dateFormat', 'dd-MM-yyyy', + 'tdClass', 'date', + 'formatFunction', $this->util->getTranslated()->formatDateNa); return $model; } Modified: trunk/library/classes/Gems/Default/TrackAction.php =================================================================== --- trunk/library/classes/Gems/Default/TrackAction.php 2012-05-24 12:37:55 UTC (rev 699) +++ trunk/library/classes/Gems/Default/TrackAction.php 2012-05-24 13:29:00 UTC (rev 700) @@ -327,9 +327,9 @@ //$model->resetOrder(); $model->set('gtr_track_name', 'label', $this->_('Track')); $model->set('gtr_survey_rounds', 'label', $this->_('Survey #'), 'tdClass', 'centerAlign', 'thClass', 'centerAlign'); - $model->set('gtr_date_start', 'label', $this->_('From'), 'dateFormat', Gems_Tracker::DB_DATE_FORMAT, + $model->set('gtr_date_start', 'label', $this->_('From'), 'dateFormat', 'dd-MM-yyyy', 'formatFunction', $this->util->getTranslated()->formatDate); - $model->set('gtr_date_until', 'label', $this->_('Until'), 'dateFormat', Gems_Tracker::DB_DATE_FORMAT, + $model->set('gtr_date_until', 'label', $this->_('Until'), 'dateFormat', 'dd-MM-yyyy', 'formatFunction', $this->util->getTranslated()->formatDateNa); return $model; Modified: trunk/library/classes/Gems/Default/TrackActionAbstract.php =================================================================== --- trunk/library/classes/Gems/Default/TrackActionAbstract.php 2012-05-24 12:37:55 UTC (rev 699) +++ trunk/library/classes/Gems/Default/TrackActionAbstract.php 2012-05-24 13:29:00 UTC (rev 700) @@ -209,9 +209,9 @@ 'description', $this->_('Enter the particulars concerning the assignment to this respondent.')); $model->set('assigned_by', 'label', $this->_('Assigned by')); $model->set('gr2t_start_date', 'label', $this->_('Start'), - 'dateFormat', Gems_Tracker::DB_DATE_FORMAT, + 'dateFormat', 'dd-MM-yyyy', 'formatFunction', $this->util->getTranslated()->formatDate, - 'default', MUtil_Date::format(new Zend_date(), 'dd-MM-yyyy')); + 'default', new Zend_date()); $model->set('gr2t_reception_code'); $model->set('gr2t_comment', 'label', $this->_('Comment')); Modified: trunk/library/classes/Gems/FormattedData.php =================================================================== --- trunk/library/classes/Gems/FormattedData.php 2012-05-24 12:37:55 UTC (rev 699) +++ trunk/library/classes/Gems/FormattedData.php 2012-05-24 13:29:00 UTC (rev 700) @@ -109,13 +109,12 @@ } } - if ($dateFormat = $model->get($name, 'dateFormat')) { - $storageFormat = $model->get($name, 'storageFormat'); - $result = MUtil_Date::format($result, $dateFormat, $storageFormat); - } if ($callback = $model->get($name, 'formatFunction')) { $result = call_user_func($callback, $result); + } elseif ($dateFormat = $model->get($name, 'dateFormat')) { + $storageFormat = $model->get($name, 'storageFormat'); + $result = MUtil_Date::format($result, $dateFormat, $storageFormat); } if ($function = $model->get($name, 'itemDisplay')) { Modified: trunk/library/classes/Gems/Tracker/Snippets/EditTrackSnippetAbstract.php =================================================================== --- trunk/library/classes/Gems/Tracker/Snippets/EditTrackSnippetAbstract.php 2012-05-24 12:37:55 UTC (rev 699) +++ trunk/library/classes/Gems/Tracker/Snippets/EditTrackSnippetAbstract.php 2012-05-24 13:29:00 UTC (rev 700) @@ -150,9 +150,9 @@ $model->set('gr2t_track_info', 'label', $this->_('Description')); $model->set('assigned_by', 'label', $this->_('Assigned by')); $model->set('gr2t_start_date', 'label', $this->_('Start'), - 'dateFormat', Gems_Tracker::DB_DATE_FORMAT, + 'dateFormat', 'dd-MM-yyyy', 'formatFunction', $this->loader->getUtil()->getTranslated()->formatDate, - 'default', MUtil_Date::format(new Zend_date(), 'dd-MM-yyyy')); + 'default', new Zend_date()); $model->set('gr2t_reception_code'); $model->set('gr2t_comment', 'label', $this->_('Comment')); @@ -267,11 +267,11 @@ $filter['gr2o_id_organization'] = $this->organizationId; $this->formData = $this->getModel()->loadNew(null, $filter); - } else { parent::loadFormData(); } + MUtil_Echo::track($this->formData); if (! array_key_exists(self::TRACKFIELDS_ID, $this->formData)) { if ($this->trackEngine) { $this->formData[self::TRACKFIELDS_ID] = $this->trackEngine->getFieldsData($this->respondentTrackId); Modified: trunk/library/classes/Gems/Tracker/Snippets/ShowTrackUsageAbstract.php =================================================================== --- trunk/library/classes/Gems/Tracker/Snippets/ShowTrackUsageAbstract.php 2012-05-24 12:37:55 UTC (rev 699) +++ trunk/library/classes/Gems/Tracker/Snippets/ShowTrackUsageAbstract.php 2012-05-24 13:29:00 UTC (rev 700) @@ -1,10 +1,9 @@ <?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 @@ -15,7 +14,7 @@ * * Neither the name of Erasmus MC nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE @@ -26,8 +25,8 @@ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * + * + * * @package Gems * @subpackage Tracker * @author Matijs de Jong <mj...@ma...> @@ -38,9 +37,9 @@ /** * Displays the assignments of a track to a respondent. - * - * This code contains some display options for excluding or marking a single track - * and for processing the passed parameters identifying the respondent and the + * + * This code contains some display options for excluding or marking a single track + * and for processing the passed parameters identifying the respondent and the * optional single track. * * @package Gems @@ -62,68 +61,68 @@ /** * Optional, when true current item is not shown, when false the current row is marked as the currentRow. - * + * * @var boolean */ protected $excludeCurrent = false; - + /** * @var Zend_Db_Adapter_Abstract */ protected $db; - + /** * Required - * + * * @var Gems_Loader */ protected $loader; - + /** * Optional, required when using $trackEngine or $trackId only * * @var int Organization Id */ protected $organizationId; - + /** * Optional, required when using $trackEngine or $trackId only * * @var int Patient Id */ protected $patientId; - + /** * Optional, one of $respondentTrack, $respondentTrackId, $trackEngine, $trackId should be set * * @var Gems_Tracker_RespondentTrack */ protected $respondentTrack; - + /** * * @var int Respondent Track Id */ protected $respondentTrackId; - + /** * Optional, one of $respondentTrack, $respondentTrackId, $trackEngine, $trackId should be set - * + * * $trackEngine and TrackId need $patientId and $organizationId to be set as well - * + * * @var Gems_Tracker_Engine_TrackEngineInterface */ protected $trackEngine; - + /** * Optional, one of $respondentTrack, $respondentTrackId, $trackEngine, $trackId should be set * * $trackEngine and TrackId need $patientId and $organizationId to be set as well - * + * * @var int Track Id */ protected $trackId; - + /** * Should be called after answering the request to allow the Target * to check if all required registry values have been set correctly. @@ -134,7 +133,7 @@ { return $this->db && $this->loader && parent::checkRegistryRequestsAnswers(); } - + /** * Creates the model * @@ -143,20 +142,20 @@ protected function createModel() { $model = $this->loader->getTracker()->getRespondentTrackModel(); - + $model->set('gtr_track_name', 'label', $this->_('Track')); $model->set('gr2t_track_info', 'label', $this->_('Description'), 'description', $this->_('Enter the particulars concerning the assignment to this respondent.')); $model->set('assigned_by', 'label', $this->_('Assigned by')); $model->set('gr2t_start_date', 'label', $this->_('Start'), - 'dateFormat', Gems_Tracker::DB_DATE_FORMAT, + 'dateFormat', 'dd-MM-yyyy', 'formatFunction', $this->loader->getUtil()->getTranslated()->formatDate, - 'default', MUtil_Date::format(new Zend_date(), 'dd-MM-yyyy')); + 'default', new Zend_date()); $model->set('gr2t_reception_code'); - + return $model; } - + /** * Create the snippets content * @@ -168,19 +167,19 @@ public function getHtmlOutput(Zend_View_Abstract $view) { $seq = $this->getHtmlSequence(); - + $seq->h3($this->getTitle()); - + $table = parent::getHtmlOutput($view); $this->applyHtmlAttributes($table); - + $seq->append($table); - + return $seq; } abstract protected function getTitle(); - + /** * The place to check if the data set in the snippet is valid * to generate the snippet. @@ -206,7 +205,7 @@ if ((! $this->trackId) && $this->trackEngine) { $this->trackId = $this->trackEngine->getTrackId(); } - + // Check if a sufficient set of data is there if (! ($this->trackId || $this->patientId || $this->organizationId)) { // Now we really need $this->respondentTrack @@ -219,7 +218,7 @@ } } } - + if (! $this->trackId) { $this->trackId = $this->respondentTrack->getTrackId(); } @@ -229,9 +228,9 @@ if (! $this->organizationId) { $this->organizationId = $this->respondentTrack->getOrganizationId(); } - + // MUtil_Echo::track($this->trackId, $this->patientId, $this->organizationId, $this->respondentTrackId); - + return parent::hasHtmlOutput(); } @@ -241,15 +240,15 @@ * @param MUtil_Model_ModelAbstract $model */ protected function processFilterAndSort(MUtil_Model_ModelAbstract $model) - { + { if ($this->request) { $this->processSortOnly($model); } - + $filter['gtr_id_track'] = $this->trackId; $filter['gr2o_patient_nr'] = $this->patientId; $filter['gr2o_id_organization'] = $this->organizationId; - + if ($this->excludeCurrent) { $filter[] = $this->db->quoteInto('gr2t_id_respondent_track != ?', $this->respondentTrackId); } Modified: trunk/library/classes/MUtil/Model/TableBridgeAbstract.php =================================================================== --- trunk/library/classes/MUtil/Model/TableBridgeAbstract.php 2012-05-24 12:37:55 UTC (rev 699) +++ trunk/library/classes/MUtil/Model/TableBridgeAbstract.php 2012-05-24 13:29:00 UTC (rev 700) @@ -89,7 +89,9 @@ $value = MUtil_Lazy::offsetGet($multi, $value); } - if ($format = $this->model->get($name, 'dateFormat')) { + if ($function = $this->model->get($name, 'formatFunction')) { + $value = MUtil_Lazy::call($function, $value); + } elseif ($format = $this->model->get($name, 'dateFormat')) { if (is_callable($format)) { $value = MUtil_Lazy::call($format, $value); } else { @@ -97,10 +99,6 @@ } } - if ($function = $this->model->get($name, 'formatFunction')) { - $value = MUtil_Lazy::call($function, $value); - } - if ($marker = $this->model->get($name, 'markCallback')) { $value = MUtil_Lazy::call($marker, $value); } Modified: trunk/library/classes/MUtil/View/Helper/Exhibitor.php =================================================================== --- trunk/library/classes/MUtil/View/Helper/Exhibitor.php 2012-05-24 12:37:55 UTC (rev 699) +++ trunk/library/classes/MUtil/View/Helper/Exhibitor.php 2012-05-24 13:29:00 UTC (rev 700) @@ -1,47 +1,47 @@ <?php - -/** - * Copyright (c) 2011, Erasmus MC - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of Erasmus MC nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - /** - * - * @author Matijs de Jong - * @since 1.0 - * @version 1.1 - * @package MUtil + * Copyright (c) 2011, Erasmus MC + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Erasmus MC nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * + * @package MUtil * @subpackage View + * @author Matijs de Jong <mj...@ma...> + * @copyright Copyright (c) 2012 Erasmus MC + * @license New BSD License + * @version $id: FormSelectHtml.php 203 2012-01-01t 12:51:32Z matijs $ */ /** - * - * @author Matijs de Jong - * @package MUtil + * + * @package MUtil * @subpackage View + * @copyright Copyright (c) 2012 Erasmus MC + * @license New BSD License + * @since Class available since version 1.0 */ class MUtil_View_Helper_Exhibitor extends Zend_View_Helper_FormElement { @@ -80,18 +80,16 @@ } } - if (isset($attribs['dateFormat'])) { + if (isset($attribs['formatFunction'])) { + $callback = $attribs['formatFunction']; + $result = call_user_func($callback, $result); + } elseif (isset($attribs['dateFormat'])) { $dateFormat = $attribs['dateFormat']; $storageFormat = isset($attribs['storageFormat']) ? $attribs['storageFormat'] : null; $result = MUtil_Date::format($result, $dateFormat, $storageFormat); } - if (isset($attribs['formatFunction'])) { - $callback = $attribs['formatFunction']; - $result = call_user_func($callback, $result); - } - if (isset($attribs['itemDisplay'])) { $function = $attribs['itemDisplay']; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2012-05-31 20:52:16
|
Revision: 726 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=726&view=rev Author: michieltcs Date: 2012-05-31 20:52:10 +0000 (Thu, 31 May 2012) Log Message: ----------- Fix spelling of Zend_Date Modified Paths: -------------- trunk/library/classes/Gems/Default/RespondentExportAction.php trunk/library/classes/Gems/Default/TrackActionAbstract.php trunk/library/classes/Gems/Tracker/Snippets/EditTrackSnippetAbstract.php trunk/library/classes/Gems/Tracker/Snippets/ShowTrackUsageAbstract.php trunk/library/classes/MUtil/Date.php trunk/library/classes/MUtil/JQuery/Form/Element/DatePicker.php trunk/library/classes/MUtil/Validate/Date/DateAfter.php trunk/library/classes/MUtil/Validate/Date/DateBefore.php Modified: trunk/library/classes/Gems/Default/RespondentExportAction.php =================================================================== --- trunk/library/classes/Gems/Default/RespondentExportAction.php 2012-05-31 20:30:49 UTC (rev 725) +++ trunk/library/classes/Gems/Default/RespondentExportAction.php 2012-05-31 20:52:10 UTC (rev 726) @@ -201,7 +201,7 @@ $trackModel->set('assigned_by', 'label', $this->_('Assigned by')); $trackModel->set('gr2t_start_date', 'label', $this->_('Start'), 'formatFunction', $this->util->getTranslated()->formatDate, - 'default', MUtil_Date::format(new Zend_date(), 'dd-MM-yyyy')); + 'default', MUtil_Date::format(new Zend_Date(), 'dd-MM-yyyy')); $trackModel->set('gr2t_reception_code'); $trackModel->set('gr2t_comment', 'label', $this->_('Comment')); $trackModel->setFilter(array('gr2t_id_respondent_track' => $track->getRespondentTrackId())); Modified: trunk/library/classes/Gems/Default/TrackActionAbstract.php =================================================================== --- trunk/library/classes/Gems/Default/TrackActionAbstract.php 2012-05-31 20:30:49 UTC (rev 725) +++ trunk/library/classes/Gems/Default/TrackActionAbstract.php 2012-05-31 20:52:10 UTC (rev 726) @@ -211,7 +211,7 @@ $model->set('gr2t_start_date', 'label', $this->_('Start'), 'dateFormat', 'dd-MM-yyyy', 'formatFunction', $this->util->getTranslated()->formatDate, - 'default', new Zend_date()); + 'default', new Zend_Date()); $model->set('gr2t_reception_code'); $model->set('gr2t_comment', 'label', $this->_('Comment')); Modified: trunk/library/classes/Gems/Tracker/Snippets/EditTrackSnippetAbstract.php =================================================================== --- trunk/library/classes/Gems/Tracker/Snippets/EditTrackSnippetAbstract.php 2012-05-31 20:30:49 UTC (rev 725) +++ trunk/library/classes/Gems/Tracker/Snippets/EditTrackSnippetAbstract.php 2012-05-31 20:52:10 UTC (rev 726) @@ -152,7 +152,7 @@ $model->set('gr2t_start_date', 'label', $this->_('Start'), 'dateFormat', 'dd-MM-yyyy', 'formatFunction', $this->loader->getUtil()->getTranslated()->formatDate, - 'default', new Zend_date()); + 'default', new Zend_Date()); $model->set('gr2t_reception_code'); $model->set('gr2t_comment', 'label', $this->_('Comment')); Modified: trunk/library/classes/Gems/Tracker/Snippets/ShowTrackUsageAbstract.php =================================================================== --- trunk/library/classes/Gems/Tracker/Snippets/ShowTrackUsageAbstract.php 2012-05-31 20:30:49 UTC (rev 725) +++ trunk/library/classes/Gems/Tracker/Snippets/ShowTrackUsageAbstract.php 2012-05-31 20:52:10 UTC (rev 726) @@ -150,7 +150,7 @@ $model->set('gr2t_start_date', 'label', $this->_('Start'), 'dateFormat', 'dd-MM-yyyy', 'formatFunction', $this->loader->getUtil()->getTranslated()->formatDate, - 'default', new Zend_date()); + 'default', new Zend_Date()); $model->set('gr2t_reception_code'); return $model; Modified: trunk/library/classes/MUtil/Date.php =================================================================== --- trunk/library/classes/MUtil/Date.php 2012-05-31 20:30:49 UTC (rev 725) +++ trunk/library/classes/MUtil/Date.php 2012-05-31 20:52:10 UTC (rev 726) @@ -180,22 +180,22 @@ public function intDayOfYear($locale = null) { - return intval($this->get(Zend_date::DAY_OF_YEAR, $locale)); + return intval($this->get(Zend_Date::DAY_OF_YEAR, $locale)); } public function intMonth($locale = null) { - return intval($this->get(Zend_date::MONTH, $locale)); + return intval($this->get(Zend_Date::MONTH, $locale)); } public function intWeek($locale = null) { - return intval($this->get(Zend_date::WEEK, $locale)); + return intval($this->get(Zend_Date::WEEK, $locale)); } public function intYear($locale = null) { - return intval($this->get(Zend_date::YEAR, $locale)); + return intval($this->get(Zend_Date::YEAR, $locale)); } /** Modified: trunk/library/classes/MUtil/JQuery/Form/Element/DatePicker.php =================================================================== --- trunk/library/classes/MUtil/JQuery/Form/Element/DatePicker.php 2012-05-31 20:30:49 UTC (rev 725) +++ trunk/library/classes/MUtil/JQuery/Form/Element/DatePicker.php 2012-05-31 20:52:10 UTC (rev 726) @@ -159,7 +159,7 @@ } } } - if ($this->_dateValue instanceof Zend_date) { + if ($this->_dateValue instanceof Zend_Date) { $this->_applyDateFormat(); } else { parent::setValue($value); Modified: trunk/library/classes/MUtil/Validate/Date/DateAfter.php =================================================================== --- trunk/library/classes/MUtil/Validate/Date/DateAfter.php 2012-05-31 20:30:49 UTC (rev 725) +++ trunk/library/classes/MUtil/Validate/Date/DateAfter.php 2012-05-31 20:52:10 UTC (rev 726) @@ -90,7 +90,7 @@ $this->_afterDate = new Zend_Date(); } - if ($this->_afterDate instanceof Zend_date) { + if ($this->_afterDate instanceof Zend_Date) { $after = $this->_afterDate; } elseif (isset($context[$this->_afterDate])) { $after = new Zend_Date($context[$this->_afterDate], $this->getDateFormat()); Modified: trunk/library/classes/MUtil/Validate/Date/DateBefore.php =================================================================== --- trunk/library/classes/MUtil/Validate/Date/DateBefore.php 2012-05-31 20:30:49 UTC (rev 725) +++ trunk/library/classes/MUtil/Validate/Date/DateBefore.php 2012-05-31 20:52:10 UTC (rev 726) @@ -90,7 +90,7 @@ $this->_beforeDate = new Zend_Date(); } - if ($this->_beforeDate instanceof Zend_date) { + if ($this->_beforeDate instanceof Zend_Date) { $before = $this->_beforeDate; } elseif (isset($context[$this->_beforeDate])) { $before = new Zend_Date($context[$this->_beforeDate], $this->getDateFormat()); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2012-06-07 13:21:06
|
Revision: 742 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=742&view=rev Author: matijsdejong Date: 2012-06-07 13:20:56 +0000 (Thu, 07 Jun 2012) Log Message: ----------- page + item are now also stored in RequestCache so you really return to the last page #534 After editing / creating a user, you go to 'reset password' form by defaultStaffDefinition + reset button in browse screen #325 Can no longer edit 'higher' role User object now hasAllowedRole() and empty name still generates some name text display Modified Paths: -------------- trunk/library/classes/Gems/Controller/BrowseEditAction.php trunk/library/classes/Gems/Default/StaffAction.php trunk/library/classes/Gems/Html.php trunk/library/classes/Gems/Menu/MenuAbstract.php trunk/library/classes/Gems/Model/StaffModel.php trunk/library/classes/Gems/Model.php trunk/library/classes/Gems/Snippets/ModelTableSnippetAbstract.php trunk/library/classes/Gems/User/User.php trunk/library/classes/GemsEscort.php trunk/library/classes/MUtil/Html/PagePanel.php Modified: trunk/library/classes/Gems/Controller/BrowseEditAction.php =================================================================== --- trunk/library/classes/Gems/Controller/BrowseEditAction.php 2012-06-07 13:04:33 UTC (rev 741) +++ trunk/library/classes/Gems/Controller/BrowseEditAction.php 2012-06-07 13:20:56 UTC (rev 742) @@ -132,6 +132,7 @@ $request = $this->getRequest(); $search = $this->getCachedRequestData(false); $params = array('baseUrl' => $search); + // MUtil_Echo::track($search); // Load the filters $this->_applySearchParameters($model); @@ -164,9 +165,6 @@ $table = $this->getBrowseTable($search); $paginator = $model->loadPaginator(); $table->setRepeater($paginator); - - // Apply request cache to request, so pagination is preserved too - $request->setParams(array_intersect_key($search, array('page'=>1,'items'=>1))); $table->tfrow()->pagePanel($paginator, $request, $this->translate, $params); if (isset($sequence)) { @@ -617,7 +615,7 @@ $this->requestCache->setRequest($this->request); // Button text should not be stored. - $this->requestCache->removeParams(self::SEARCH_BUTTON, /*'page', 'items',*/ 'action'); + $this->requestCache->removeParams(self::SEARCH_BUTTON, 'action'); } $data = $this->requestCache->getProgramParams(); Modified: trunk/library/classes/Gems/Default/StaffAction.php =================================================================== --- trunk/library/classes/Gems/Default/StaffAction.php 2012-06-07 13:04:33 UTC (rev 741) +++ trunk/library/classes/Gems/Default/StaffAction.php 2012-06-07 13:20:56 UTC (rev 742) @@ -44,6 +44,16 @@ */ class Gems_Default_StaffAction extends Gems_Controller_BrowseEditAction { + protected $_instanceId; + protected $_organizations; + + /** + * The current user for detailed actions, set by createModel() + * + * @var Gems_User_User + */ + protected $_user = false; + //@@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; @@ -51,9 +61,6 @@ public $filterStandard = array('gsf_active' => 1); public $sortKey = array('name' => SORT_ASC); - protected $_instanceId; - protected $_organizations; - /** * Adds columns from the model to the bridge that creates the browse table. * @@ -106,10 +113,14 @@ } } } - // Add edit button if allowed, otherwise show, again if allowed + // Add edit button if allowed if ($menuItem = $this->findAllowedMenuItem('edit')) { $bridge->addItemLink($menuItem->toActionLinkLower($this->getRequest(), $bridge)); } + // Add reset button if allowed + if ($menuItem = $this->findAllowedMenuItem('reset')) { + $bridge->addItemLink($menuItem->toActionLink($this->getRequest(), $bridge, $this->_('reset'))); + } } /** @@ -128,24 +139,13 @@ { // Sorry, for the time being no password complexity checking on new // users. Can be done, but is to complex for the moment. - if ($new) { - $user = false; - } else { - $user = $this->loader->getUserLoader()->getUserByStaffId($data['gsf_id_user']); - // MUtil_Echo::track($data['gsf_id_user'], $user->getLoginName()); - } // Find out if this group is in the inheritance path of the current user - $allowedGroups = $this->util->getDbLookup()->getAllowedStaffGroups(); - if (!array_key_exists($data['gsf_id_primary_group'], $allowedGroups)) { - //Not allowed to update - $model->set('gsf_id_primary_group', 'elementClass', 'Exhibitor'); - } else { - //Allow only certain groups - $model->set('gsf_id_primary_group', 'multiOptions', $allowedGroups); - } + // and allow those certain groups + $model->set('gsf_id_primary_group', 'multiOptions', $this->util->getDbLookup()->getAllowedStaffGroups()); + if ($new) { - $model->set('gsf_id_primary_group', 'default', $dbLookup->getDefaultGroup()); + $model->set('gsf_id_primary_group', 'default', $this->util->getDbLookup()->getDefaultGroup()); } $ucfirst = new Zend_Filter_Callback('ucfirst'); @@ -302,8 +302,26 @@ */ public function createModel($detailed, $action) { + if ($detailed) { + // Make sure the user is loaded + $this->loadUser(); + + if ($this->_user) { + switch ($action) { + case 'create': + case 'show': + break; + + default: + if (! $this->_user->hasAllowedRole()) { + throw new Gems_Exception($this->_('No access to page'), 403, null, + sprintf($this->_('Access to this page is not allowed for current role: %s.'), $this->loader->getCurrentUser()->getRole())); + } + } + } + } + // MUtil_Model::$verbose = true; - $model = $this->loader->getModels()->getStaffModel(); $model->set('gsf_login', 'label', $this->_('Username')); @@ -340,6 +358,43 @@ return $model; } + /** + * Return an array with route options depending on de $data given. + * + * @param mixed $data array or Zend_Controller_Request_Abstract + * @return mixed array with route options or false when no redirect is found + */ + public function getAfterSaveRoute($data) + { + if (! $this->_user) { + $this->_user = $this->loader->getUser($data['gul_login'], $data['gul_id_organization']); + } + MUtil_Echo::track($this->_user->canSetPassword()); + + if ($this->_user->canSetPassword()) { + if ($currentItem = $this->menu->getCurrent()) { + $controller = $this->_getParam('controller'); + + if ($data instanceof Zend_Controller_Request_Abstract) { + $refData = $data; + $refData->setParam('accessible_role', $this->_user->hasAllowedRole()); + } elseif (is_array($data)) { + $refData = $this->getModel()->getKeyRef($data) + $data; + $refData['accessible_role'] = $this->_user->hasAllowedRole(); + } else { + throw new Gems_Exception_Coding('The variable $data must be an array or a Zend_Controller_Request_Abstract object.'); + } + + // Look for reset + if ($menuItem = $this->menu->findController($controller, 'reset')) { + return $menuItem->toRouteUrl($refData); + } + } + } + + return parent::getAfterSaveRoute($data, $isNew); + } + protected function getAutoSearchElements(MUtil_Model_ModelAbstract $model, array $data) { $elements = parent::getAutoSearchElements($model, $data); @@ -415,20 +470,17 @@ return $this->_('Staff'); } - public function init() + /** + * Load the user selected by the request - if any + */ + protected function loadUser() { - parent::init(); - - //Make sure the menu always has the gsd_id_organization parameter - $orgId = $this->getRequest()->getParam('gsf_id_organization'); - - if (is_null($orgId)) { - //Get the selected gsf_id_organization used in the index - $dataIdx = $this->getCachedRequestData(true, 'index', true); - $orgId = isset($dataIdx['gsf_id_organization']) ? $dataIdx['gsf_id_organization'] : $this->loader->getCurrentUser()->getCurrentOrganizationId(); + if ($staff_id = $this->_getIdParam()) { + $this->_user = $this->loader->getUserLoader()->getUserByStaffId($staff_id); + $source = $this->menu->getParameterSource(); + $source->offsetSet('gsf_id_organization', $this->_user->getBaseOrganizationId()); + $source->offsetSet('accessible_role', $this->_user->hasAllowedRole()); } - - $this->menu->getParameterSource()->offsetSet('gsf_id_organization', $orgId); } /** @@ -436,12 +488,12 @@ */ public function resetAction() { - $staff_id = $this->_getIdParam(); - $user = $this->loader->getUserLoader()->getUserByStaffId($staff_id); + // Make sure the user is loaded + $this->loadUser(); - $this->html->h3(sprintf($this->_('Reset password for: %s'), $user->getFullName())); + $this->html->h3(sprintf($this->_('Reset password for: %s'), $this->_user->getFullName())); - if (! $user->canSetPassword()) { + if (! ($this->_user->hasAllowedRole() && $this->_user->canSetPassword())) { $this->addMessage($this->_('You are not allowed to change this password.')); return; } @@ -449,7 +501,7 @@ /************* * Make form * *************/ - $form = $user->getChangePasswordForm(array('askOld' => false)); + $form = $this->_user->getChangePasswordForm(array('askOld' => false)); /**************** * Process form * @@ -464,12 +516,14 @@ /**************** * Display form * ****************/ - if ($user->isPasswordResetRequired()) { + if ($this->_user->isPasswordResetRequired()) { $this->menu->setVisible(false); } else { $form->addButtons($this->createMenuLinks()); } + $this->beforeFormDisplay($form, false); + $this->html[] = $form; } } Modified: trunk/library/classes/Gems/Html.php =================================================================== --- trunk/library/classes/Gems/Html.php 2012-06-07 13:04:33 UTC (rev 741) +++ trunk/library/classes/Gems/Html.php 2012-06-07 13:20:56 UTC (rev 742) @@ -147,7 +147,8 @@ $args['class'] = new MUtil_Html_ClassArrayAttribute('browselink'); } - // MUtil_Echo::r($args); + // MUtil_Echo::track($args); + // MUtil_Echo::track($panel_args['baseUrl']); $pager = new MUtil_Html_PagePanel($panel_args); $pager[] = $pager->pageLinks( Modified: trunk/library/classes/Gems/Menu/MenuAbstract.php =================================================================== --- trunk/library/classes/Gems/Menu/MenuAbstract.php 2012-06-07 13:04:33 UTC (rev 741) +++ trunk/library/classes/Gems/Menu/MenuAbstract.php 2012-06-07 13:20:56 UTC (rev 742) @@ -395,7 +395,7 @@ if (! $this->escort->hasPrivilege('pr.staff.edit.all')) { $filter = array_keys($this->escort->loader->getCurrentUser()->getAllowedOrganizations()); foreach ($pages as $sub_page) { - $sub_page->setParameterFilter('gsf_id_organization', $filter); + $sub_page->setParameterFilter('gsf_id_organization', $filter, 'accessible_role', 1); } } Modified: trunk/library/classes/Gems/Model/StaffModel.php =================================================================== --- trunk/library/classes/Gems/Model/StaffModel.php 2012-06-07 13:04:33 UTC (rev 741) +++ trunk/library/classes/Gems/Model/StaffModel.php 2012-06-07 13:20:56 UTC (rev 742) @@ -1,8 +1,9 @@ <?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 @@ -13,7 +14,7 @@ * * Neither the name of Erasmus MC nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE @@ -24,7 +25,7 @@ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The staff model * * @package Gems @@ -47,14 +48,18 @@ */ class Gems_Model_StaffModel extends Gems_Model_ModelAbstract { - /** - * @var Gems_Loader - */ - public $loader; - - public function __construct() + public function __construct(Gems_Loader $loader) { parent::__construct('staff', 'gems__staff', 'gsf'); + + $allowedGroups = $loader->getUtil()->getDbLookup()->getAllowedStaffGroups(); + if ($allowedGroups) { + $expr = new Zend_Db_Expr('CASE WHEN gsf_id_primary_group IN (' . implode(', ', array_keys($allowedGroups)) . ') THEN 1 ELSE 0 END'); + } else { + $expr = new Zend_Db_Expr('0'); + } + $this->addColumn($expr, 'accessible_role'); + $this->set('accessible_role', 'default', 1); } /** Modified: trunk/library/classes/Gems/Model.php =================================================================== --- trunk/library/classes/Gems/Model.php 2012-06-07 13:04:33 UTC (rev 741) +++ trunk/library/classes/Gems/Model.php 2012-06-07 13:20:56 UTC (rev 742) @@ -264,7 +264,7 @@ */ public function getStaffModel() { - $model = $this->_loadClass('StaffModel', true); + $model = $this->_loadClass('StaffModel', true, array($this->loader)); $this->addUserLogin($model, 'gsf_login', 'gsf_id_organization'); $this->setAsGemsUserId($model, 'gsf_id_user'); Modified: trunk/library/classes/Gems/Snippets/ModelTableSnippetAbstract.php =================================================================== --- trunk/library/classes/Gems/Snippets/ModelTableSnippetAbstract.php 2012-06-07 13:04:33 UTC (rev 741) +++ trunk/library/classes/Gems/Snippets/ModelTableSnippetAbstract.php 2012-06-07 13:20:56 UTC (rev 742) @@ -175,10 +175,11 @@ { if ($this->requestCache) { // Items that should not be stored. - $this->requestCache->removeParams('page', 'items', 'action'); + $this->requestCache->removeParams('action'); if ((! $this->baseUrl)) { $this->baseUrl = $this->requestCache->getProgramParams(); + // MUtil_Echo::track($this->baseUrl); if (MUtil_Registry_Source::$verbose) { MUtil_Echo::track($this->baseUrl); Modified: trunk/library/classes/Gems/User/User.php =================================================================== --- trunk/library/classes/Gems/User/User.php 2012-06-07 13:04:33 UTC (rev 741) +++ trunk/library/classes/Gems/User/User.php 2012-06-07 13:20:56 UTC (rev 742) @@ -682,7 +682,7 @@ if (! $name) { // Use obfuscated login name $name = $this->getLoginName(); - $name = substr($name, 0, 3) . str_repeat('*', strlen($name) - 2); + $name = substr($name, 0, 3) . str_repeat('*', max(5, strlen($name) - 2)); } $this->_setVar('user_name', $name); @@ -962,6 +962,20 @@ } /** + * Return true if this user has a role that is accessible by the current user + * + * @return boolean + */ + public function hasAllowedRole() + { + if ($allowedGroups = $this->util->getDbLookup()->getAllowedStaffGroups()) { + return isset($allowedGroups[$this->getGroup()]) ? 1 : 0; + } else { + return 0; + } + } + + /** * Return true if this user has a password. * * @return boolean @@ -1092,7 +1106,7 @@ if ($this->isBlockable()) { $auths['block'] = array($this, 'authorizeBlock'); } - + // organization ip restriction $auths['orgip'] = array($this, 'authorizeOrgIp'); Modified: trunk/library/classes/GemsEscort.php =================================================================== --- trunk/library/classes/GemsEscort.php 2012-06-07 13:04:33 UTC (rev 741) +++ trunk/library/classes/GemsEscort.php 2012-06-07 13:20:56 UTC (rev 742) @@ -1577,7 +1577,7 @@ $this->setError( $this->_('No access to page'), 403, - sprintf($this->_('Access to this page is not allowed for current role: %s.'), $this->session->user_role) + sprintf($this->_('Access to this page is not allowed for current role: %s.'), $user->getRole()) ); } else { // No longer logged in Modified: trunk/library/classes/MUtil/Html/PagePanel.php =================================================================== --- trunk/library/classes/MUtil/Html/PagePanel.php 2012-06-07 13:04:33 UTC (rev 741) +++ trunk/library/classes/MUtil/Html/PagePanel.php 2012-06-07 13:20:56 UTC (rev 742) @@ -49,6 +49,10 @@ */ class MUtil_Html_PagePanel extends MUtil_Html_Sequence implements MUtil_Lazy_Procrastinator { + /** + * + * @var array + */ protected $_baseUrl = array(); protected $_currentPage; @@ -201,7 +205,10 @@ if ($param_name = $this->getCurrentPageParam()) { $request = $this->getRequest(); - if ($currentPage = $request->getParam($param_name)) { + if (isset($this->_baseUrl[$param_name])) { + $this->_currentPage = $this->_baseUrl[$param_name]; + // Set cookie + } elseif ($currentPage = $request->getParam($param_name)) { $this->_currentPage = $currentPage; // Set cookie } elseif ($request instanceof Zend_Controller_Request_Http) { @@ -231,9 +238,16 @@ if ($param_name = $this->getItemCountParam()) { $request = $this->getRequest(); - if ($itemCount = $request->getParam($param_name)) { + if (isset($this->_baseUrl[$param_name])) { + $this->_itemCount = $this->_baseUrl[$param_name]; + } elseif ($itemCount = $request->getParam($param_name)) { $this->_itemCount = $itemCount; - setcookie($param_name, $itemCount, time() + (30 * 86400), $this->getCookieLocation()); + } + + if ($this->_itemCount) { + // Store + setcookie($param_name, $this->_itemCount, time() + (30 * 86400), $this->getCookieLocation()); + } elseif ($request instanceof Zend_Controller_Request_Http) { $this->_itemCount = $request->getCookie($param_name, $this->_itemCount); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2012-06-21 10:00:57
|
Revision: 775 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=775&view=rev Author: matijsdejong Date: 2012-06-21 10:00:46 +0000 (Thu, 21 Jun 2012) Log Message: ----------- Stage 2 multi organization: internally all patient identification is done by id1 + id2 for org Still working on output and finding and fixing bugs Modified Paths: -------------- trunk/library/classes/Gems/Default/RespondentAction.php trunk/library/classes/Gems/Default/TrackActionAbstract.php trunk/library/classes/Gems/Menu/ParameterSource.php trunk/library/classes/Gems/Menu/SubMenuItem.php trunk/library/classes/Gems/Menu.php trunk/library/classes/Gems/Model/HiddenOrganizationModel.php trunk/library/classes/MUtil/Model.php Modified: trunk/library/classes/Gems/Default/RespondentAction.php =================================================================== --- trunk/library/classes/Gems/Default/RespondentAction.php 2012-06-21 09:38:22 UTC (rev 774) +++ trunk/library/classes/Gems/Default/RespondentAction.php 2012-06-21 10:00:46 UTC (rev 775) @@ -347,10 +347,10 @@ { switch ($name) { case 'gr2o_patient_nr': - return $this->_getParam(MUtil_Model::REQUEST_ID, $this->_getParam(MUtil_Model::REQUEST_ID . '1', $default)); + return $this->_getParam(MUtil_Model::REQUEST_ID, $this->_getParam(MUtil_Model::REQUEST_ID1, $default)); case 'gr2o_id_organization': - return $this->_getParam(MUtil_Model::REQUEST_ID . '1', $default ? $default : $this->loader->getCurrentUser()->getCurrentOrganizationId()); + return $this->_getParam(MUtil_Model::REQUEST_ID1, $default ? $default : $this->loader->getCurrentUser()->getCurrentOrganizationId()); case 'gto_id_token': return null; Modified: trunk/library/classes/Gems/Default/TrackActionAbstract.php =================================================================== --- trunk/library/classes/Gems/Default/TrackActionAbstract.php 2012-06-21 09:38:22 UTC (rev 774) +++ trunk/library/classes/Gems/Default/TrackActionAbstract.php 2012-06-21 10:00:46 UTC (rev 775) @@ -138,8 +138,8 @@ */ protected function _getPatientAndOrganisationParam() { - $patientId = $this->_getParam(MUtil_Model::REQUEST_ID . '1'); - $orgId = $this->_getParam(MUtil_Model::REQUEST_ID . '2'); + $patientId = $this->_getParam(MUtil_Model::REQUEST_ID1); + $orgId = $this->_getParam(MUtil_Model::REQUEST_ID2); // When no resp id, check the current menu item paramter filter that MUtil_Model::REQUEST_ID does not contain a token if ((! $patientId) && $this->menu->getCurrent()->checkParameterFilter(Gems_Model::ID_TYPE)) { @@ -333,10 +333,11 @@ if (isset($data[MUtil_Model::REQUEST_ID])) { $keys[] = MUtil_Model::REQUEST_ID; - } elseif (isset($data[MUtil_Model::REQUEST_ID . '1'])) { + } elseif (isset($data[MUtil_Model::REQUEST_ID1])) { $i = 1; while (isset($data[MUtil_Model::REQUEST_ID . $i])) { $keys[] = MUtil_Model::REQUEST_ID . $i; + $i++; } } else { $keys = $model->getKeys(); @@ -376,16 +377,11 @@ public function initFilter() { // FROM REQUEST - if ($param = $this->_getParam(MUtil_Model::REQUEST_ID . '1')) { + if ($param = $this->_getParam(MUtil_Model::REQUEST_ID1)) { $this->filterStandard['gr2o_patient_nr'] = $param; - - } elseif ($param = $this->_getParam(MUtil_Model::REQUEST_ID)) { - $this->filterStandard['gr2o_patient_nr'] = $param; } - if ($param = $this->_getParam(MUtil_Model::REQUEST_ID . '2')) { + if ($param = $this->_getParam(MUtil_Model::REQUEST_ID2)) { $this->filterStandard['gr2o_id_organization'] = $param; - } else { - $this->filterStandard['gr2o_id_organization'] = $this->escort->getCurrentOrganization(); } if ($param = $this->_getParam(Gems_Model::RESPONDENT_TRACK)) { Modified: trunk/library/classes/Gems/Menu/ParameterSource.php =================================================================== --- trunk/library/classes/Gems/Menu/ParameterSource.php 2012-06-21 09:38:22 UTC (rev 774) +++ trunk/library/classes/Gems/Menu/ParameterSource.php 2012-06-21 10:00:46 UTC (rev 775) @@ -85,13 +85,9 @@ public function setPatient($patientNumber, $organizationId) { - if (! $this->offsetExists(MUtil_Model::REQUEST_ID)) { - $this->offsetSet(MUtil_Model::REQUEST_ID, $patientNumber); - } + $this->_setMulti($patientNumber, MUtil_Model::REQUEST_ID1, 'gr2o_patient_nr'); + $this->_setMulti($organizationId, MUtil_Model::REQUEST_ID2, 'gr2o_id_organization'); - $this->_setMulti($patientNumber, MUtil_Model::REQUEST_ID . '1', 'gr2o_patient_nr'); - $this->_setMulti($organizationId, MUtil_Model::REQUEST_ID . '2', 'gr2o_id_organization'); - return $this; } Modified: trunk/library/classes/Gems/Menu/SubMenuItem.php =================================================================== --- trunk/library/classes/Gems/Menu/SubMenuItem.php 2012-06-21 09:38:22 UTC (rev 774) +++ trunk/library/classes/Gems/Menu/SubMenuItem.php 2012-06-21 10:00:46 UTC (rev 775) @@ -187,11 +187,11 @@ if ($this->_hiddenOrgId) { // Remove org paramter that should remain hidden. - if (isset($parameters[MUtil_Model::REQUEST_ID . '1'], $parameters[MUtil_Model::REQUEST_ID . '2']) && - (! $parameters[MUtil_Model::REQUEST_ID . '2'] instanceof MUtil_Lazy_LazyInterface) && - ($parameters[MUtil_Model::REQUEST_ID . '2'] == $this->_hiddenOrgId)) { - $parameters[MUtil_Model::REQUEST_ID] = $parameters[MUtil_Model::REQUEST_ID . '1']; - unset($parameters[MUtil_Model::REQUEST_ID . '1'], $parameters[MUtil_Model::REQUEST_ID . '2']); + if (isset($parameters[MUtil_Model::REQUEST_ID1], $parameters[MUtil_Model::REQUEST_ID2]) && + (! $parameters[MUtil_Model::REQUEST_ID2] instanceof MUtil_Lazy_LazyInterface) && + ($parameters[MUtil_Model::REQUEST_ID2] == $this->_hiddenOrgId)) { + $parameters[MUtil_Model::REQUEST_ID] = $parameters[MUtil_Model::REQUEST_ID1]; + unset($parameters[MUtil_Model::REQUEST_ID1], $parameters[MUtil_Model::REQUEST_ID2]); } } @@ -573,6 +573,12 @@ $source[$key] = $value; } } + if ($this->_hiddenOrgId) { + if ($patientId = $request->getParam(MUtil_Model::REQUEST_ID)) { + $request->setParam(MUtil_Model::REQUEST_ID1, $patientId); + $request->setParam(MUtil_Model::REQUEST_ID2, $this->_hiddenOrgId); + } + } return $this; } Modified: trunk/library/classes/Gems/Menu.php =================================================================== --- trunk/library/classes/Gems/Menu.php 2012-06-21 09:38:22 UTC (rev 774) +++ trunk/library/classes/Gems/Menu.php 2012-06-21 10:00:46 UTC (rev 775) @@ -264,8 +264,8 @@ { $orgId = $this->escort->getLoader()->getCurrentUser()->getCurrentOrganizationId(); - $params = array(MUtil_Model::REQUEST_ID => 'gr2o_patient_nr'); - $params = array(MUtil_Model::REQUEST_ID . '1' => 'gr2o_patient_nr', MUtil_Model::REQUEST_ID . '2' => 'gr2o_id_organization'); + // $params = array(MUtil_Model::REQUEST_ID => 'gr2o_patient_nr'); + $params = array(MUtil_Model::REQUEST_ID1 => 'gr2o_patient_nr', MUtil_Model::REQUEST_ID2 => 'gr2o_id_organization'); // MAIN RESPONDENTS ITEM $page = $this->addPage($label, 'pr.respondent', 'respondent'); @@ -275,12 +275,11 @@ ->setNamedParameters($params) ->setHiddenOrgId($orgId); - /* iff( is('gr2o_id_organization', $this->escort->getCurrentOrganization()), - aget(MUtil_Model::REQUEST_ID, 'gr2o_patient_nr'), - aget(MUtil_Model::REQUEST_ID . '1', 'gr2o_patient_nr', MUtil_Model::REQUEST_ID . '2', 'gr2o_id_organization') + aget(MUtil_Model::REQUEST_ID, 'gr2o_patient_nr'), + aget(MUtil_Model::REQUEST_ID1, 'gr2o_patient_nr', MUtil_Model::REQUEST_ID2, 'gr2o_id_organization') ); */ Modified: trunk/library/classes/Gems/Model/HiddenOrganizationModel.php =================================================================== --- trunk/library/classes/Gems/Model/HiddenOrganizationModel.php 2012-06-21 09:38:22 UTC (rev 774) +++ trunk/library/classes/Gems/Model/HiddenOrganizationModel.php 2012-06-21 10:00:46 UTC (rev 775) @@ -93,6 +93,8 @@ if ($field2 = array_shift($keys)) { $parameters[$field2] = $this->getCurrentOrganization(); + MUtil_Echo::r('Still using old HiddenModel parameters.', 'DEPRECIATION WARNING'); + MUtil_Echo::r($parameters); } unset($parameters[MUtil_Model::REQUEST_ID]); @@ -149,11 +151,11 @@ } if ($organizationInKey) { - $href[MUtil_Model::REQUEST_ID] = self::_getValueFrom(reset($keys), $forData); + $href[MUtil_Model::REQUEST_ID] = self::_getValueFrom(reset($keys), $forData); } else { - $href[MUtil_Model::REQUEST_ID . '1'] = self::_getValueFrom(reset($keys), $forData); + $href[MUtil_Model::REQUEST_ID1] = self::_getValueFrom(reset($keys), $forData); next($keys); - $href[MUtil_Model::REQUEST_ID . '2'] = self::_getValueFrom(key($keys), $forData); + $href[MUtil_Model::REQUEST_ID2] = self::_getValueFrom(key($keys), $forData); } return $href; Modified: trunk/library/classes/MUtil/Model.php =================================================================== --- trunk/library/classes/MUtil/Model.php 2012-06-21 09:38:22 UTC (rev 774) +++ trunk/library/classes/MUtil/Model.php 2012-06-21 10:00:46 UTC (rev 775) @@ -1,33 +1,33 @@ <?php - -/** - * Copyright (c) 2011, Erasmus MC - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of Erasmus MC nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - + /** + * Copyright (c) 2011, Erasmus MC + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Erasmus MC nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/** * @author Matijs de Jong * @since 1.0 * @version 1.1 @@ -36,11 +36,46 @@ */ class MUtil_Model { + /** + * In order to keep the url's short and to hide any field names from + * the user, model identifies key values by using 'id' for a single + * key value and id1, id2, etc... for multiple keys. + */ const REQUEST_ID = 'id'; + /** + * Helper constant for first key value in multi value key. + */ + const REQUEST_ID1 = 'id1'; + + /** + * Helper constant for second key value in multi value key. + */ + const REQUEST_ID2 = 'id2'; + + /** + * Helper constant for third key value in multi value key. + */ + const REQUEST_ID3 = 'id3'; + + /** + * Helper constant for forth key value in multi value key. + */ + const REQUEST_ID4 = 'id4'; + + /** + * Default parameter name for sorting ascending. + */ const SORT_ASC_PARAM = 'asort'; + + /** + * Default parameter name for sorting descending. + */ const SORT_DESC_PARAM = 'dsort'; + /** + * Default parameter name for wildcard text search. + */ const TEXT_FILTER = 'search'; const TYPE_STRING = 1; @@ -65,4 +100,3 @@ */ public static $verbose = false; } - This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2012-07-13 10:01:46
|
Revision: 839 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=839&view=rev Author: mennodekker Date: 2012-07-13 10:01:36 +0000 (Fri, 13 Jul 2012) Log Message: ----------- Fixing concatenated row in exhibitor and formatted data Modified Paths: -------------- trunk/library/classes/Gems/FormattedData.php trunk/library/classes/MUtil/View/Helper/Exhibitor.php Modified: trunk/library/classes/Gems/FormattedData.php =================================================================== --- trunk/library/classes/Gems/FormattedData.php 2012-07-13 09:51:02 UTC (rev 838) +++ trunk/library/classes/Gems/FormattedData.php 2012-07-13 10:01:36 UTC (rev 839) @@ -103,8 +103,20 @@ if ($multiOptions = $model->get($name, 'multiOptions')) { if (is_array($multiOptions)) { - if (array_key_exists($result, $multiOptions)) { - $result = $multiOptions[$result]; + /* + * Sometimes a field is an array and will be formatted later on using the + * formatFunction -> handle each element in the array. + */ + if (is_array($result)) { + foreach($result as $key => $value) { + if (array_key_exists($value, $multiOptions)) { + $result[$key] = $multiOptions[$value]; + } + } + } else { + if (array_key_exists($result, $multiOptions)) { + $result = $multiOptions[$result]; + } } } } Modified: trunk/library/classes/MUtil/View/Helper/Exhibitor.php =================================================================== --- trunk/library/classes/MUtil/View/Helper/Exhibitor.php 2012-07-13 09:51:02 UTC (rev 838) +++ trunk/library/classes/MUtil/View/Helper/Exhibitor.php 2012-07-13 10:01:36 UTC (rev 839) @@ -74,8 +74,20 @@ $multiOptions = $attribs['multiOptions']; if (is_array($multiOptions)) { - if (array_key_exists($value, $multiOptions)) { - $result = $multiOptions[$value]; + /* + * Sometimes a field is an array and will be formatted later on using the + * formatFunction -> handle each element in the array. + */ + if (is_array($result)) { + foreach($result as $key => $arrayValue) { + if (array_key_exists($arrayValue, $multiOptions)) { + $result[$key] = $multiOptions[$arrayValue]; + } + } + } else { + if (array_key_exists($result, $multiOptions)) { + $result = $multiOptions[$result]; + } } } } @@ -123,7 +135,7 @@ $result = $callback($result); } */ - if (isset($attribs['nohidden']) && $attribs['nohidden']) { + if (isset($attribs['nohidden']) && $attribs['nohidden'] || is_array($value)) { return $result; } else { return $this->_hidden($name, $value) . $result; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2012-07-13 10:04:58
|
Revision: 841 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=841&view=rev Author: mennodekker Date: 2012-07-13 10:04:47 +0000 (Fri, 13 Jul 2012) Log Message: ----------- Allow to export staff to excel + in detailed view roles won't be cut off Modified Paths: -------------- trunk/library/classes/Gems/Default/RoleAction.php trunk/library/classes/Gems/Menu/MenuAbstract.php trunk/library/classes/GemsEscort.php Modified: trunk/library/classes/Gems/Default/RoleAction.php =================================================================== --- trunk/library/classes/Gems/Default/RoleAction.php 2012-07-13 10:02:53 UTC (rev 840) +++ trunk/library/classes/Gems/Default/RoleAction.php 2012-07-13 10:04:47 UTC (rev 841) @@ -235,7 +235,10 @@ $tp = new MUtil_Model_Type_ConcatenatedRow(',', ', '); $tp->apply($model, 'grl_parents'); - $model->set('grl_privileges', 'label', $this->_('Privileges'), 'formatFunction', array($this, 'formatLongLine')); + $model->set('grl_privileges', 'label', $this->_('Privileges')); + if (!$detailed) { + $model->set('grl_privileges', 'formatFunction', array($this, 'formatLongLine')); + } Gems_Model::setChangeFieldsByPrefix($model, 'grl'); Modified: trunk/library/classes/Gems/Menu/MenuAbstract.php =================================================================== --- trunk/library/classes/Gems/Menu/MenuAbstract.php 2012-07-13 10:02:53 UTC (rev 840) +++ trunk/library/classes/Gems/Menu/MenuAbstract.php 2012-07-13 10:04:47 UTC (rev 841) @@ -409,6 +409,7 @@ $pages[] = $page->addEditAction(); $pages[] = $page->addAction($this->_('Reset password'), 'pr.staff.edit', 'reset')->setModelParameters(1); $pages[] = $page->addDeleteAction(); + $pages[] = $page->addExcelAction(); if (! $this->escort->hasPrivilege('pr.staff.edit.all')) { $filter = array_keys($this->escort->loader->getCurrentUser()->getAllowedOrganizations()); foreach ($pages as $sub_page) { Modified: trunk/library/classes/GemsEscort.php =================================================================== --- trunk/library/classes/GemsEscort.php 2012-07-13 10:02:53 UTC (rev 840) +++ trunk/library/classes/GemsEscort.php 2012-07-13 10:04:47 UTC (rev 841) @@ -430,7 +430,7 @@ */ protected function _initTranslate() { - $this->bootstrap('locale'); + $this->bootstrap('locale'); $language = $this->locale->getLanguage(); @@ -516,9 +516,8 @@ return $view; } - protected function _initZFDebug() - { - /* + /*protected function _initZFDebug() + { // if ((APPLICATION_ENV === 'development') && if ((APPLICATION_ENV !== 'production') && (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 6.') === FALSE)) { @@ -546,8 +545,8 @@ $this->bootstrap('frontController'); $frontController = $this->getResource('frontController'); $frontController->registerPlugin($debug); - } // */ - } + } + }// */ /** * Function called if specified in the Project.ini layoutPrepare section before This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2012-08-22 10:54:05
|
Revision: 900 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=900&view=rev Author: mennodekker Date: 2012-08-22 10:53:51 +0000 (Wed, 22 Aug 2012) Log Message: ----------- bug #555: added transparent .less to .css compiling to the headlink helper Added Paths: ----------- trunk/library/classes/Gems/View/Helper/HeadLink.php trunk/library/classes/Lessphp/ trunk/library/classes/Lessphp/LICENSE trunk/library/classes/Lessphp/lessc.inc.php Added: trunk/library/classes/Gems/View/Helper/HeadLink.php =================================================================== --- trunk/library/classes/Gems/View/Helper/HeadLink.php (rev 0) +++ trunk/library/classes/Gems/View/Helper/HeadLink.php 2012-08-22 10:53:51 UTC (rev 900) @@ -0,0 +1,97 @@ +<?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. + * + * Transparent LESS compiling for all headlink files with .less extension + * + * @package Gems + * @subpackage View\Helper + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @version $Id: Sample.php 215 2011-07-12 08:52:54Z michiel $ + */ + +// We need to load the class first +include_once 'Lessphp/lessc.inc.php'; + +/** + * Add transparent LESS compiling to the headlink + * + * Using http://leafo.net/lessphp/ this helper compiles http://lesscss.org/ to a css file. + * Compiling takes some time, so it will only run when the input file is newer than + * the output file or when the output file doesn't exist. + * + * Append ?compilecss to the url to force it to create new css. + * + * @package Gems + * @subpackage View\Helper + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @since Class available since version 1.0 + * @deprecated Class deprecated since version 2.0 + */ +class Gems_View_Helper_HeadLink extends Zend_View_Helper_HeadLink +{ + public function itemToString(\stdClass $item) + { + $attributes = (array) $item; + + if (isset($attributes['type']) && $attributes['type'] == 'text/css') { + // This is a stylesheet, consider extension and compile .less to .css + if (substr($attributes['href'],-5) == '.less') { + + + // Get the baseurl, it was appende to the href in escort + $baseUrl = Zend_Controller_Front::getInstance()->getBaseUrl(); + + // String the baseurl and add full path to the webdir + $inFile = GEMS_WEB_DIR . substr($attributes['href'], strlen($baseUrl)); + $outFile = substr($inFile, 0, -4) . 'css'; + + // Try compiling + try { + $params = Zend_Controller_Front::getInstance()->getRequest()->getParams(); + if (array_key_exists('compilecss', $params)) { + $lessc = new lessc(); + $result = $lessc->compileFile($inFile, $outFile); + } else { + $result = lessc::ccompile($inFile, $outFile); + } + } catch (Exception $exc) { + // If we have an error, present it if not in production + if (APPLICATION_ENV !== 'production') { + MUtil_Echo::pre($exc->getMessage()); + } + } + + // Modify object, not the derived array + $item->href = substr($attributes['href'], 0, -4) . 'css'; + } + } + + return parent::itemToString($item); + } +} \ No newline at end of file Added: trunk/library/classes/Lessphp/LICENSE =================================================================== --- trunk/library/classes/Lessphp/LICENSE (rev 0) +++ trunk/library/classes/Lessphp/LICENSE 2012-08-22 10:53:51 UTC (rev 900) @@ -0,0 +1,660 @@ +For ease of distribution, lessphp 0.2.0 is under a dual license. +You are free to pick which one suits your needs. + + + + +MIT LICENSE + + + + +Copyright (c) 2010 Leaf Corcoran, http://leafo.net/lessphp + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + + + +GPL VERSION 3 + + + + + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + Added: trunk/library/classes/Lessphp/lessc.inc.php =================================================================== --- trunk/library/classes/Lessphp/lessc.inc.php (rev 0) +++ trunk/library/classes/Lessphp/lessc.inc.php 2012-08-22 10:53:51 UTC (rev 900) @@ -0,0 +1,3359 @@ +<?php + +/** + * lessphp v0.3.8 + * http://leafo.net/lessphp + * + * LESS css compiler, adapted from http://lesscss.org + * + * Copyright 2012, Leaf Corcoran <le...@gm...> + * Licensed under MIT or GPLv3, see LICENSE + */ + + +/** + * The less compiler and parser. + * + * Converting LESS to CSS is a three stage process. The incoming file is parsed + * by `lessc_parser` into a syntax tree, then it is compiled into another tree + * representing the CSS structure by `lessc`. The CSS tree is fed into a + * formatter, like `lessc_formatter` which then outputs CSS as a string. + * + * During the first compile, all values are *reduced*, which means that their + * types are brought to the lowest form before being dump as strings. This + * handles math equations, variable dereferences, and the like. + * + * The `parse` function of `lessc` is the entry point. + * + * In summary: + * + * The `lessc` class creates an intstance of the parser, feeds it LESS code, + * then transforms the resulting tree to a CSS tree. This class also holds the + * evaluation context, such as all available mixins and variables at any given + * time. + * + * The `lessc_parser` class is only concerned with parsing its input. + * + * The `lessc_formatter` takes a CSS tree, and dumps it to a formatted string, + * handling things like indentation. + */ +class lessc { + static public $VERSION = "v0.3.8"; + static protected $TRUE = array("keyword", "true"); + static protected $FALSE = array("keyword", "false"); + + protected $libFunctions = array(); + protected $registeredVars = array(); + protected $preserveComments = false; + + public $vPrefix = '@'; // prefix of abstract properties + public $mPrefix = '$'; // prefix of abstract blocks + public $parentSelector = '&'; + + public $importDisabled = false; + public $importDir = ''; + + protected $numberPrecision = null; + + // set to the parser that generated the current line when compiling + // so we know how to create error messages + protected $sourceParser = null; + protected $sourceLoc = null; + + static public $defaultValue = array("keyword", ""); + + static protected $nextImportId = 0; // uniquely identify imports + + // attempts to find the path of an import url, returns null for css files + protected function findImport($url) { + foreach ((array)$this->importDir as $dir) { + $full = $dir.(substr($dir, -1) != '/' ? '/' : '').$url; + if ($this->fileExists($file = $full.'.less') || $this->fileExists($file = $full)) { + return $file; + } + } + + return null; + } + + protected function fileExists($name) { + return is_file($name); + } + + static public function compressList($items, $delim) { + if (!isset($items[1]) && isset($items[0])) return $items[0]; + else return array('list', $delim, $items); + } + + static public function preg_quote($what) { + return preg_quote($what, '/'); + } + + protected function tryImport($importPath, $parentBlock, $out) { + if ($importPath[0] == "function" && $importPath[1] == "url") { + $importPath = $this->flattenList($importPath[2]); + } + + $str = $this->coerceString($importPath); + if ($str === null) return false; + + $url = $this->compileValue($this->lib_e($str)); + + // don't import if it ends in css + if (substr_compare($url, '.css', -4, 4) === 0) return false; + + $realPath = $this->findImport($url); + if ($realPath === null) return false; + + if ($this->importDisabled) { + return array(false, "/* import disabled */"); + } + + $this->addParsedFile($realPath); + $parser = $this->makeParser($realPath); + $root = $parser->parse(file_get_contents($realPath)); + + // set the parents of all the block props + foreach ($root->props as $prop) { + if ($prop[0] == "block") { + $prop[1]->parent = $parentBlock; + } + } + + // copy mixins into scope, set their parents + // bring blocks from import into current block + // TODO: need to mark the source parser these came from this file + foreach ($root->children as $childName => $child) { + if (isset($parentBlock->children[$childName])) { + $parentBlock->children[$childName] = array_merge( + $parentBlock->children[$childName], + $child); + } else { + $parentBlock->children[$childName] = $child; + } + } + + $pi = pathinfo($realPath); + $dir = $pi["dirname"]; + + list($top, $bottom) = $this->sortProps($root->props, true); + $this->compileImportedProps($top, $parentBlock, $out, $parser, $dir); + + return array(true, $bottom, $parser, $dir); + } + + protected function compileImportedProps($props, $block, $out, $sourceParser, $importDir) { + $oldSourceParser = $this->sourceParser; + + $oldImport = $this->importDir; + + // TODO: this is because the importDir api is stupid + $this->importDir = (array)$this->importDir; + array_unshift($this->importDir, $importDir); + + foreach ($props as $prop) { + $this->compileProp($prop, $block, $out); + } + + $this->importDir = $oldImport; + $this->sourceParser = $oldSourceParser; + } + + /** + * Recursively compiles a block. + * + * A block is analogous to a CSS block in most cases. A single LESS document + * is encapsulated in a block when parsed, but it does not have parent tags + * so all of it's children appear on the root level when compiled. + * + * Blocks are made up of props and children. + * + * Props are property instructions, array tuples which describe an action + * to be taken, eg. write a property, set a variable, mixin a block. + * + * The children of a block are just all the blocks that are defined within. + * This is used to look up mixins when performing a mixin. + * + * Compiling the block involves pushing a fresh environment on the stack, + * and iterating through the props, compiling each one. + * + * See lessc::compileProp() + * + */ + protected function compileBlock($block) { + switch ($block->type) { + case "root": + $this->compileRoot($block); + break; + case null: + $this->compileCSSBlock($block); + break; + case "media": + $this->compileMedia($block); + break; + case "directive": + $name = "@" . $block->name; + if (!empty($block->value)) { + $name .= " " . $this->compileValue($this->reduce($block->value)); + } + + $this->compileNestedBlock($block, array($name)); + break; + default: + $this->throwError("unknown block type: $block->type\n"); + } + } + + protected function compileCSSBlock($block) { + $env = $this->pushEnv(); + + $selectors = $this->compileSelectors($block->tags); + $env->selectors = $this->multiplySelectors($selectors); + $out = $this->makeOutputBlock(null, $env->selectors); + + $this->scope->children[] = $out; + $this->compileProps($block, $out); + + $block->scope = $env; // mixins carry scope with them! + $this->popEnv(); + } + + protected function compileMedia($media) { + $env = $this->pushEnv($media); + $parentScope = $this->mediaParent($this->scope); + + $query = $this->compileMediaQuery($this->multiplyMedia($env)); + + $this->scope = $this->makeOutputBlock($media->type, array($query)); + $parentScope->children[] = $this->scope; + + $this->compileProps($media, $this->scope); + + if (count($this->scope->lines) > 0) { + $orphanSelelectors = $this->findClosestSelectors(); + if (!is_null($orphanSelelectors)) { + $orphan = $this->makeOutputBlock(null, $orphanSelelectors); + $orphan->lines = $this->scope->lines; + array_unshift($this->scope->children, $orphan); + $this->scope->lines = array(); + } + } + + $this->scope = $this->scope->parent; + $this->popEnv(); + } + + protected function mediaParent($scope) { + while (!empty($scope->parent)) { + if (!empty($scope->type) && $scope->type != "media") { + break; + } + $scope = $scope->parent; + } + + return $scope; + } + + protected function compileNestedBlock($block, $selectors) { + $this->pushEnv($block); + $this->scope = $this->makeOutputBlock($block->type, $selectors); + $this->scope->parent->children[] = $this->scope; + + $this->compileProps($block, $this->scope); + + $this->scope = $this->scope->parent; + $this->popEnv(); + } + + protected function compileRoot($root) { + $this->pushEnv(); + $this->scope = $this->makeOutputBlock($root->type); + $this->compileProps($root, $this->scope); + $this->popEnv(); + } + + protected function compileProps($block, $out) { + foreach ($this->sortProps($block->props) as $prop) { + $this->compileProp($prop, $block, $out); + } + } + + protected function sortProps($props, $split = false) { + $vars = array(); + $imports = array(); + $other = array(); + + foreach ($props as $prop) { + switch ($prop[0]) { + case "assign": + if (isset($prop[1][0]) && $prop[1][0] == $this->vPrefix) { + $vars[] = $prop; + } else { + $other[] = $prop; + } + break; + case "import": + $id = self::$nextImportId++; + $prop[] = $id; + $imports[] = $prop; + $other[] = array("import_mixin", $id); + break; + default: + $other[] = $prop; + } + } + + if ($split) { + return array(array_merge($vars, $imports), $other); + } else { + return array_merge($vars, $imports, $other); + } + } + + protected function compileMediaQuery($queries) { + $compiledQueries = array(); + foreach ($queries as $query) { + $parts = array(); + foreach ($query as $q) { + switch ($q[0]) { + case "mediaType": + $parts[] = implode(" ", array_slice($q, 1)); + break; + case "mediaExp": + if (isset($q[2])) { + $parts[] = "($q[1]: " . + $this->compileValue($this->reduce($q[2])) . ")"; + } else { + $parts[] = "($q[1])"; + } + break; + } + } + + if (count($parts) > 0) { + $compiledQueries[] = implode(" and ", $parts); + } + } + + $out = "@media"; + if (!empty($parts)) { + $out .= " " . + implode($this->formatter->selectorSeparator, $compiledQueries); + } + return $out; + } + + protected function multiplyMedia($env, $childQueries = null) { + if (is_null($env) || + !empty($env->block->type) && $env->block->type != "media") + { + return $childQueries; + } + + // plain old block, skip + if (empty($env->block->type)) { + return $this->multiplyMedia($env->parent, $childQueries); + } + + $out = array(); + $queries = $env->block->queries; + if (is_null($childQueries)) { + $out = $queries; + } else { + foreach ($queries as $parent) { + foreach ($childQueries as $child) { + $out[] = array_merge($parent, $child); + } + } + } + + return $this->multiplyMedia($env->parent, $out); + } + + protected function expandParentSelectors(&$tag, $replace) { + $parts = explode("$&$", $tag); + $count = 0; + foreach ($parts as &$part) { + $part = str_replace($this->parentSelector, $replace, $part, $c); + $count += $c; + } + $tag = implode($this->parentSelector, $parts); + return $count; + } + + protected function findClosestSelectors() { + $env = $this->env; + $selectors = null; + while ($env !== null) { + if (isset($env->selectors)) { + $selectors = $env->selectors; + break; + } + $env = $env->parent; + } + + return $selectors; + } + + + // multiply $selectors against the nearest selectors in env + protected function multiplySelectors($selectors) { + // find parent selectors + + $parentSelectors = $this->findClosestSelectors(); + if (is_null($parentSelectors)) { + // kill parent reference in top level selector + foreach ($selectors as &$s) { + $this->expandParentSelectors($s, ""); + } + + return $selectors; + } + + $out = array(); + foreach ($parentSelectors as $parent) { + foreach ($selectors as $child) { + $count = $this->expandParentSelectors($child, $parent); + + // don't prepend the parent tag if & was used + if ($count > 0) { + $out[] = trim($child); + } else { + $out[] = trim($parent . ' ' . $child); + } + } + } + + return $out; + } + + // reduces selector expressions + protected function compileSelectors($selectors) { + $out = array(); + + foreach ($selectors as $s) { + if (is_array($s)) { + list(, $value) = $s; + $out[] = $this->compileValue($this->reduce($value)); + } else { + $out[] = $s; + } + } + + return $out; + } + + protected function eq($left, $right) { + return $left == $right; + } + + protected function patternMatch($block, $callingArgs) { + // match the guards if it has them + // any one of the groups must have all its guards pass for a match + if (!empty($block->guards)) { + $groupPassed = false; + foreach ($block->guards as $guardGroup) { + foreach ($guardGroup as $guard) { + $this->pushEnv(); + $this->zipSetArgs($block->args, $callingArgs); + + $negate = false; + if ($guard[0] == "negate") { + $guard = $guard[1]; + $negate = true; + } + + $passed = $this->reduce($guard) == self::$TRUE; + if ($negate) $passed = !$passed; + + $this->popEnv(); + + if ($passed) { + $groupPassed = true; + } else { + $groupPassed = false; + break; + } + } + + if ($groupPassed) break; + } + + if (!$groupPassed) { + return false; + } + } + + $numCalling = count($callingArgs); + + if (empty($block->args)) { + return $block->isVararg || $numCalling == 0; + } + + $i = -1; // no args + // try to match by arity or by argument literal + foreach ($block->args as $i => $arg) { + switch ($arg[0]) { + case "lit": + if (empty($callingArgs[$i]) || !$this->eq($arg[1], $callingArgs[$i])) { + return false; + } + break; + case "arg": + // no arg and no default value + if (!isset($callingArgs[$i]) && !isset($arg[2])) { + return false; + } + break; + case "rest": + $i--; // rest can be empty + break 2; + } + } + + if ($block->isVararg) { + return true; // not having enough is handled above + } else { + $numMatched = $i + 1; + // greater than becuase default values always match + return $numMatched >= $numCalling; + } + } + + protected function patternMatchAll($blocks, $callingArgs) { + $matches = null; + foreach ($blocks as $block) { + if ($this->patternMatch($block, $callingArgs)) { + $matches[] = $block; + } + } + + return $matches; + } + + // attempt to find blocks matched by path and args + protected function findBlocks($searchIn, $path, $args, $seen=array()) { + if ($searchIn == null) return null; + if (isset($seen[$searchIn->id])) return null; + $seen[$searchIn->id] = true; + + $name = $path[0]; + + if (isset($searchIn->children[$name])) { + $blocks = $searchIn->children[$name]; + if (count($path) == 1) { + $matches = $this->patternMatchAll($blocks, $args); + if (!empty($matches)) { + // This will return all blocks that match in the closest + // scope that has any matching block, like lessjs + return $matches; + } + } else { + $matches = array(); + foreach ($blocks as $subBlock) { + $subMatches = $this->findBlocks($subBlock, + array_slice($path, 1), $args, $seen); + + if (!is_null($subMatches)) { + foreach ($subMatches as $sm) { + $matches[] = $sm; + } + } + } + + return count($matches) > 0 ? $matches : null; + } + } + + if ($searchIn->parent === $searchIn) return null; + return $this->findBlocks($searchIn->parent, $path, $args, $seen); + } + + // sets all argument names in $args to either the default value + // or the one passed in through $values + protected function zipSetArgs($args, $values) { + $i = 0; + $assignedValues = array(); + foreach ($args as $a) { + if ($a[0] == "arg") { + if ($i < count($values) && !is_null($values[$i])) { + $value = $values[$i]; + } elseif (isset($a[2])) { + $value = $a[2]; + } else $value = null; + + $value = $this->reduce($value); + $this->set($a[1], $value); + $assignedValues[] = $value; + } + $i++; + } + + // check for a rest + $last = end($args); + if ($last[0] == "rest") { + $rest = array_slice($values, count($args) - 1); + $this->set($last[1], $this->reduce(array("list", " ", $rest))); + } + + $this->env->arguments = $assignedValues; + } + + // compile a prop and update $lines or $blocks appropriately + protected function compileProp($prop, $block, $out) { + // set error position context + $this->sourceLoc = isset($prop[-1]) ? $prop[-1] : -1; + + switch ($prop[0]) { + case 'assign': + list(, $name, $value) = $prop; + if ($name[0] == $this->vPrefix) { + $this->set($name, $value); + } else { + $out->lines[] = $this->formatter->property($name, + $this->compileValue($this->reduce($value))); + } + break; + case 'block': + list(, $child) = $prop; + $this->compileBlock($child); + break; + case 'mixin': + list(, $path, $args, $suffix) = $prop; + + $args = array_map(array($this, "reduce"), (array)$args); + $mixins = $this->findBlocks($block, $path, $args); + + if ($mixins === null) { + // fwrite(STDERR,"failed to find block: ".implode(" > ", $path)."\n"); + break; // throw error here?? + } + + foreach ($mixins as $mixin) { + $haveScope = false; + if (isset($mixin->parent->scope)) { + $haveScope = true; + $mixinParentEnv = $this->pushEnv(); + $mixinParentEnv->storeParent = $mixin->parent->scope; + } + + $haveArgs = false; + if (isset($mixin->args)) { + $haveArgs = true; + $this->pushEnv(); + $this->zipSetArgs($mixin->args, $args); + } + + $oldParent = $mixin->parent; + if ($mixin != $block) $mixin->parent = $block; + + foreach ($this->sortProps($mixin->props) as $subProp) { + if ($suffix !== null && + $subProp[0] == "assign" && + is_string($subProp[1]) && + $subProp[1]{0} != $this->vPrefix) + { + $subProp[2] = array( + 'list', ' ', + array($subProp[2], array('keyword', $suffix)) + ); + } + + $this->compileProp($subProp, $mixin, $out); + } + + $mixin->parent = $oldParent; + + if ($haveArgs) $this->popEnv(); + if ($haveScope) $this->popEnv(); + } + + break; + case 'raw': + $out->lines[] = $prop[1]; + break; + case "directive": + list(, $name, $value) = $prop; + $out->lines[] = "@$name " . $this->compileValue($this->reduce($value)).';'; + break; + case "comment": + $out->lines[] = $prop[1]; + break; + case "import"; + list(, $importPath, $importId) = $prop; + $importPath = $this->reduce($importPath); + + if (!isset($this->env->imports)) { + $this->env->imports = array(); + } + + $result = $this->tryImport($importPath, $block, $out); + + $this->env->imports[$importId] = $result === false ? + array(false, "@import " . $this->compileValue($importPath).";") : + $result; + + break; + case "import_mixin": + list(,$importId) = $prop; + $import = $this->env->imports[$importId]; + if ($import[0] === false) { + $out->lines[] = $import[1]; + } else { + list(, $bottom, $parser, $importDir) = $import; + $this->compileImportedProps($bottom, $block, $out, $parser, $importDir); + } + + break; + default: + $this->throwError("unknown op: {$prop[0]}\n"); + } + } + + + /** + * Compiles a primitive value into a CSS property value. + * + * Values in lessphp are typed by being wrapped in arrays, their format is + * typically: + * + * array(type, contents [, additional_contents]*) + * + * The input is expected to be reduced. This function will not work on + * things like expressions and variables. + */ + protected function compileValue($value) { + switch ($value[0]) { + case 'list': + // [1] - delimiter + // [2] - array of values + return implode($value[1], array_map(array($this, 'compileValue'), $value[2])); + case 'raw_color': + if (!empty($this->formatter->compressColors)) { + return $this->compileValue($this->coerceColor($value)); + } + return $value[1]; + case 'keyword': + // [1] - the keyword + return $value[1]; + case 'number': + list(, $num, $unit) = $value; + // [1] - the number + // [2] - the unit + if ($this->numberPrecision !== null) { + $num = round($num, $this->numberPrecision); + } + return $num . $unit; + case 'string': + // [1] - contents of string (includes quotes) + list(, $delim, $content) = $value; + foreach ($content as &$part) { + if (is_array($part)) { + $part = $this->compileValue($part); + } + } + return $delim . implode($content) . $delim; + case 'color': + // [1] - red component (either number or a %) + // [2] - green component + // [3] - blue component + // [4] - optional alpha component + list(, $r, $g, $b) = $value; + $r = round($r); + $g = round($g); + $b = round($b); + + if (count($value) == 5 && $value[4] != 1) { // rgba + ... [truncated message content] |
From: <gem...@li...> - 2012-09-20 09:52:12
|
Revision: 948 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=948&view=rev Author: mennodekker Date: 2012-09-20 09:52:05 +0000 (Thu, 20 Sep 2012) Log Message: ----------- Fixed notice on user edit Removed no longer functional micro-optimization from formbridge Modified Paths: -------------- trunk/library/classes/Gems/User/User.php trunk/library/classes/MUtil/Model/FormBridge.php Modified: trunk/library/classes/Gems/User/User.php =================================================================== --- trunk/library/classes/Gems/User/User.php 2012-09-20 09:18:22 UTC (rev 947) +++ trunk/library/classes/Gems/User/User.php 2012-09-20 09:52:05 UTC (rev 948) @@ -229,7 +229,9 @@ if ($store instanceof Zend_Session_Namespace) { $store->__unset($name); } else { - $store->offsetUnset($name, $value); + if ($store->offsetExists($name)) { + $store->offsetUnset($name); + } } } Modified: trunk/library/classes/MUtil/Model/FormBridge.php =================================================================== --- trunk/library/classes/MUtil/Model/FormBridge.php 2012-09-20 09:18:22 UTC (rev 947) +++ trunk/library/classes/MUtil/Model/FormBridge.php 2012-09-20 09:52:05 UTC (rev 948) @@ -252,9 +252,8 @@ } $options = array_intersect_key($options, $allowedOptionsFlipped); - // Now get all options from the model, and extract only the allowed ones - $modelOptions = $this->model->get($name); - $modelOptions = array_intersect_key($modelOptions, $allowedOptionsFlipped); + // Now get allowed options from the model + $modelOptions = $this->model->get($name, $allowedOptions); // Merge them: first use supplied $options, and add missing values from model return (array) $options + (array) $modelOptions; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2012-10-02 07:47:48
|
Revision: 967 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=967&view=rev Author: mennodekker Date: 2012-10-02 07:47:36 +0000 (Tue, 02 Oct 2012) Log Message: ----------- Keywords updated Modified Paths: -------------- trunk/library/classes/Gems/Event/Survey/BeforeAnswering/GetPreviousAnswers.php trunk/library/classes/Gems/Event/Survey/Completed/BmiCalculation.php trunk/library/classes/Gems/Event/Survey/Completed/DisplayVars.php trunk/library/classes/Gems/Event/SurveyDisplayEventInterface.php trunk/library/classes/Gems/Export/RespondentExport.php trunk/library/classes/Gems/Snippets/AutosearchFormSnippet.php trunk/library/classes/Gems/Snippets/Export/ReportFooterSnippet.php trunk/library/classes/Gems/Snippets/Export/ReportHeaderSnippet.php trunk/library/classes/Gems/Snippets/Export/RespondentSnippet.php trunk/library/classes/Gems/Snippets/Export/SurveyHeaderSnippet.php trunk/library/classes/Gems/Snippets/SnippetLoader.php trunk/library/classes/Gems/Task/Tracker/CheckTrackRounds.php trunk/library/classes/Gems/Task/Tracker/SourceCommand.php trunk/library/classes/Gems/User/Adapter/Radius/radius.class.php trunk/library/classes/Gems/User/Adapter/Radius.php trunk/library/classes/Gems/User/Form/LayeredLoginForm.php trunk/library/classes/Gems/User/Validate/GetUserPasswordValidator.php trunk/library/classes/Gems/User/Validate/NewPasswordValidator.php trunk/library/classes/Gems/User/Validate/PasswordValidatorAbstract.php trunk/library/classes/Gems/User/Validate/UserPasswordValidator.php trunk/library/classes/Gems/View/Helper/HeadLink.php trunk/library/classes/MUtil/Batch/BatchAbstract.php trunk/library/classes/MUtil/Batch/WaitBatch.php trunk/library/classes/MUtil/Controller/ModelSnippetActionAbstract.php trunk/library/classes/MUtil/Html/IFrame.php trunk/library/classes/MUtil/Html/PFormElement.php trunk/library/classes/MUtil/Html/ProgressPanel.php trunk/library/classes/MUtil/Html/SrcArrayAttribute.php trunk/library/classes/MUtil/Mail/Transport/EchoLog.php trunk/library/classes/MUtil/ProgressBar/Adapter/JsPush.php trunk/library/classes/MUtil/Snippets/ModelYesNoDeleteSnippetAbstract.php trunk/library/classes/MUtil/Snippets/SnippetLoaderInterface.php trunk/library/classes/MUtil/Snippets/Standard/ModelYesNoDeleteSnippet.php trunk/library/classes/Zend/Translate/Adapter.php Property Changed: ---------------- trunk/library/classes/Gems/Event/Survey/BeforeAnswering/GetPreviousAnswers.php trunk/library/classes/Gems/Event/Survey/Completed/BmiCalculation.php trunk/library/classes/Gems/Event/Survey/Completed/DisplayVars.php trunk/library/classes/Gems/Event/Survey/Display/ByValue.php trunk/library/classes/Gems/Event/Survey/Display/OnlyAnswered.php trunk/library/classes/Gems/Event/Survey/Display/Reverse.php trunk/library/classes/Gems/Event/SurveyAnswerFilterAbstract.php trunk/library/classes/Gems/Event/SurveyDisplayEventInterface.php trunk/library/classes/Gems/Export/RespondentExport.php trunk/library/classes/Gems/Filter/TrailingSlash.php trunk/library/classes/Gems/Form/AutoLoadFormAbstract.php trunk/library/classes/Gems/Mail.php trunk/library/classes/Gems/Menu/ContainerItem.php trunk/library/classes/Gems/Menu/HiddenOrganizationHrefAttribute.php trunk/library/classes/Gems/Snippets/AutosearchFormSnippet.php trunk/library/classes/Gems/Snippets/Export/ReportFooterSnippet.php trunk/library/classes/Gems/Snippets/Export/ReportHeaderSnippet.php trunk/library/classes/Gems/Snippets/Export/RespondentSnippet.php trunk/library/classes/Gems/Snippets/Export/SurveyHeaderSnippet.php trunk/library/classes/Gems/Snippets/SnippetLoader.php trunk/library/classes/Gems/Task/Tracker/CheckTrackRounds.php trunk/library/classes/Gems/Task/Tracker/SourceCommand.php trunk/library/classes/Gems/Tracker/Form/AskTokenForm.php trunk/library/classes/Gems/Tracker/Snippets/AnswerNameFilterInterface.php trunk/library/classes/Gems/Tracker/Snippets/ShowTokenLoopAbstract.php trunk/library/classes/Gems/User/Adapter/Radius/radius.class.php trunk/library/classes/Gems/User/Adapter/Radius.php trunk/library/classes/Gems/User/Form/ChangePasswordForm.php trunk/library/classes/Gems/User/Form/LayeredLoginForm.php trunk/library/classes/Gems/User/Form/LoginForm.php trunk/library/classes/Gems/User/Form/OrganizationFormAbstract.php trunk/library/classes/Gems/User/Form/ResetRequestForm.php trunk/library/classes/Gems/User/Validate/GetUserInterface.php trunk/library/classes/Gems/User/Validate/GetUserPasswordValidator.php trunk/library/classes/Gems/User/Validate/NewPasswordValidator.php trunk/library/classes/Gems/User/Validate/PasswordValidatorAbstract.php trunk/library/classes/Gems/User/Validate/ResetRequestValidator.php trunk/library/classes/Gems/User/Validate/UserPasswordValidator.php trunk/library/classes/Gems/View/Helper/HeadLink.php trunk/library/classes/MUtil/Batch/BatchAbstract.php trunk/library/classes/MUtil/Batch/BatchException.php trunk/library/classes/MUtil/Batch/WaitBatch.php trunk/library/classes/MUtil/Controller/ModelSnippetActionAbstract.php trunk/library/classes/MUtil/Form/Element/Multiselect.php trunk/library/classes/MUtil/Form/Element/Select.php trunk/library/classes/MUtil/Html/Code/DynamicAbstract.php trunk/library/classes/MUtil/Html/Code/JavaScript.php trunk/library/classes/MUtil/Html/HnElement.php trunk/library/classes/MUtil/Html/IFrame.php trunk/library/classes/MUtil/Html/PFormElement.php trunk/library/classes/MUtil/Html/ProgressPanel.php trunk/library/classes/MUtil/Html/SrcArrayAttribute.php trunk/library/classes/MUtil/Mail/Transport/EchoLog.php trunk/library/classes/MUtil/Model/SelectModelPaginator.php trunk/library/classes/MUtil/Model/Type/ConcatenatedRow.php trunk/library/classes/MUtil/ProgressBar/Adapter/JsPush.php trunk/library/classes/MUtil/Queue/Adapter/DbPrefixed.php trunk/library/classes/MUtil/Snippets/ModelYesNoDeleteSnippetAbstract.php trunk/library/classes/MUtil/Snippets/SnippetLoaderInterface.php trunk/library/classes/MUtil/Snippets/Standard/ModelYesNoDeleteSnippet.php trunk/library/classes/MUtil/View/Helper/FormSelectHtml.php trunk/library/classes/Zend/Translate/Adapter.php Modified: trunk/library/classes/Gems/Event/Survey/BeforeAnswering/GetPreviousAnswers.php =================================================================== --- trunk/library/classes/Gems/Event/Survey/BeforeAnswering/GetPreviousAnswers.php 2012-10-01 15:04:49 UTC (rev 966) +++ trunk/library/classes/Gems/Event/Survey/BeforeAnswering/GetPreviousAnswers.php 2012-10-02 07:47:36 UTC (rev 967) @@ -32,7 +32,7 @@ * @author Matijs de Jong <mj...@ma...> * @copyright Copyright (c) 2011 Erasmus MC * @license New BSD License - * @version $Id: Sample.php 203 2011-07-07 12:51:32Z matijs $ + * @version $Id$ */ /** Property changes on: trunk/library/classes/Gems/Event/Survey/BeforeAnswering/GetPreviousAnswers.php ___________________________________________________________________ Added: svn:keywords + Id Rev Revision Date Author Modified: trunk/library/classes/Gems/Event/Survey/Completed/BmiCalculation.php =================================================================== --- trunk/library/classes/Gems/Event/Survey/Completed/BmiCalculation.php 2012-10-01 15:04:49 UTC (rev 966) +++ trunk/library/classes/Gems/Event/Survey/Completed/BmiCalculation.php 2012-10-02 07:47:36 UTC (rev 967) @@ -32,7 +32,7 @@ * @author Matijs de Jong <mj...@ma...> * @copyright Copyright (c) 2011 Erasmus MC * @license New BSD License - * @version $Id: Sample.php 203 2011-07-07 12:51:32Z matijs $ + * @version $Id$ */ /** Property changes on: trunk/library/classes/Gems/Event/Survey/Completed/BmiCalculation.php ___________________________________________________________________ Added: svn:keywords + Id Rev Revision Date Author Modified: trunk/library/classes/Gems/Event/Survey/Completed/DisplayVars.php =================================================================== --- trunk/library/classes/Gems/Event/Survey/Completed/DisplayVars.php 2012-10-01 15:04:49 UTC (rev 966) +++ trunk/library/classes/Gems/Event/Survey/Completed/DisplayVars.php 2012-10-02 07:47:36 UTC (rev 967) @@ -30,7 +30,7 @@ * @subpackage Event * @copyright Copyright (c) 2011 Erasmus MC * @license New BSD License - * @version $Id: Sample.php 215 2011-07-12 08:52:54Z michiel $ + * @version $Id$ */ /** Property changes on: trunk/library/classes/Gems/Event/Survey/Completed/DisplayVars.php ___________________________________________________________________ Added: svn:keywords + Id Rev Revision Date Author Property changes on: trunk/library/classes/Gems/Event/Survey/Display/ByValue.php ___________________________________________________________________ Added: svn:keywords + Id Rev Revision Date Author Property changes on: trunk/library/classes/Gems/Event/Survey/Display/OnlyAnswered.php ___________________________________________________________________ Added: svn:keywords + Id Rev Revision Date Author Property changes on: trunk/library/classes/Gems/Event/Survey/Display/Reverse.php ___________________________________________________________________ Added: svn:keywords + Id Rev Revision Date Author Property changes on: trunk/library/classes/Gems/Event/SurveyAnswerFilterAbstract.php ___________________________________________________________________ Added: svn:keywords + Id Rev Revision Date Author Modified: trunk/library/classes/Gems/Event/SurveyDisplayEventInterface.php =================================================================== --- trunk/library/classes/Gems/Event/SurveyDisplayEventInterface.php 2012-10-01 15:04:49 UTC (rev 966) +++ trunk/library/classes/Gems/Event/SurveyDisplayEventInterface.php 2012-10-02 07:47:36 UTC (rev 967) @@ -32,7 +32,7 @@ * @author Matijs de Jong <mj...@ma...> * @copyright Copyright (c) 2011 Erasmus MC * @license New BSD License - * @version $Id: SurveyCompletedEventInterface.php 59 2011-09-22 07:23:44Z mennodekker $ + * @version $Id$ */ /** Property changes on: trunk/library/classes/Gems/Event/SurveyDisplayEventInterface.php ___________________________________________________________________ Added: svn:keywords + Id Rev Revision Date Author Modified: trunk/library/classes/Gems/Export/RespondentExport.php =================================================================== --- trunk/library/classes/Gems/Export/RespondentExport.php 2012-10-01 15:04:49 UTC (rev 966) +++ trunk/library/classes/Gems/Export/RespondentExport.php 2012-10-02 07:47:36 UTC (rev 967) @@ -29,7 +29,7 @@ * @subpackage Export * @copyright Copyright (c) 2011 Erasmus MC * @license New BSD License - * @version $Id: Sample.php 215 2011-07-12 08:52:54Z michiel $ + * @version $Id$ */ /** Property changes on: trunk/library/classes/Gems/Export/RespondentExport.php ___________________________________________________________________ Added: svn:keywords + Id Rev Revision Date Author Property changes on: trunk/library/classes/Gems/Filter/TrailingSlash.php ___________________________________________________________________ Added: svn:keywords + Id Rev Revision Date Author Property changes on: trunk/library/classes/Gems/Form/AutoLoadFormAbstract.php ___________________________________________________________________ Added: svn:keywords + Id Rev Revision Date Author Property changes on: trunk/library/classes/Gems/Mail.php ___________________________________________________________________ Added: svn:keywords + Id Rev Revision Date Author Property changes on: trunk/library/classes/Gems/Menu/ContainerItem.php ___________________________________________________________________ Added: svn:keywords + Id Rev Revision Date Author Property changes on: trunk/library/classes/Gems/Menu/HiddenOrganizationHrefAttribute.php ___________________________________________________________________ Added: svn:keywords + Id Rev Revision Date Author Modified: trunk/library/classes/Gems/Snippets/AutosearchFormSnippet.php =================================================================== --- trunk/library/classes/Gems/Snippets/AutosearchFormSnippet.php 2012-10-01 15:04:49 UTC (rev 966) +++ trunk/library/classes/Gems/Snippets/AutosearchFormSnippet.php 2012-10-02 07:47:36 UTC (rev 967) @@ -32,7 +32,7 @@ * @author Matijs de Jong <mj...@ma...> * @copyright Copyright (c) 2011 Erasmus MC * @license New BSD License - * @version $Id: Sample.php 203 2011-07-07 12:51:32Z matijs $ + * @version $Id$ */ /** Property changes on: trunk/library/classes/Gems/Snippets/AutosearchFormSnippet.php ___________________________________________________________________ Added: svn:keywords + Id Rev Revision Date Author Modified: trunk/library/classes/Gems/Snippets/Export/ReportFooterSnippet.php =================================================================== --- trunk/library/classes/Gems/Snippets/Export/ReportFooterSnippet.php 2012-10-01 15:04:49 UTC (rev 966) +++ trunk/library/classes/Gems/Snippets/Export/ReportFooterSnippet.php 2012-10-02 07:47:36 UTC (rev 967) @@ -29,7 +29,7 @@ * @subpackage Snippets * @copyright Copyright (c) 2011 Erasmus MC * @license New BSD License - * @version $Id: Sample.php 215 2011-07-12 08:52:54Z michiel $ + * @version $Id$ */ /** Property changes on: trunk/library/classes/Gems/Snippets/Export/ReportFooterSnippet.php ___________________________________________________________________ Added: svn:keywords + Id Rev Revision Date Author Modified: trunk/library/classes/Gems/Snippets/Export/ReportHeaderSnippet.php =================================================================== --- trunk/library/classes/Gems/Snippets/Export/ReportHeaderSnippet.php 2012-10-01 15:04:49 UTC (rev 966) +++ trunk/library/classes/Gems/Snippets/Export/ReportHeaderSnippet.php 2012-10-02 07:47:36 UTC (rev 967) @@ -29,7 +29,7 @@ * @subpackage Snippets * @copyright Copyright (c) 2011 Erasmus MC * @license New BSD License - * @version $Id: Sample.php 215 2011-07-12 08:52:54Z michiel $ + * @version $Id$ */ /** Property changes on: trunk/library/classes/Gems/Snippets/Export/ReportHeaderSnippet.php ___________________________________________________________________ Added: svn:keywords + Id Rev Revision Date Author Modified: trunk/library/classes/Gems/Snippets/Export/RespondentSnippet.php =================================================================== --- trunk/library/classes/Gems/Snippets/Export/RespondentSnippet.php 2012-10-01 15:04:49 UTC (rev 966) +++ trunk/library/classes/Gems/Snippets/Export/RespondentSnippet.php 2012-10-02 07:47:36 UTC (rev 967) @@ -29,7 +29,7 @@ * @subpackage Snippets * @copyright Copyright (c) 2011 Erasmus MC * @license New BSD License - * @version $Id: Sample.php 215 2011-07-12 08:52:54Z michiel $ + * @version $Id$ */ /** Property changes on: trunk/library/classes/Gems/Snippets/Export/RespondentSnippet.php ___________________________________________________________________ Added: svn:keywords + Id Rev Revision Date Author Modified: trunk/library/classes/Gems/Snippets/Export/SurveyHeaderSnippet.php =================================================================== --- trunk/library/classes/Gems/Snippets/Export/SurveyHeaderSnippet.php 2012-10-01 15:04:49 UTC (rev 966) +++ trunk/library/classes/Gems/Snippets/Export/SurveyHeaderSnippet.php 2012-10-02 07:47:36 UTC (rev 967) @@ -29,7 +29,7 @@ * @subpackage Snippets * @copyright Copyright (c) 2011 Erasmus MC * @license New BSD License - * @version $Id: Sample.php 215 2011-07-12 08:52:54Z michiel $ + * @version $Id$ */ /** Property changes on: trunk/library/classes/Gems/Snippets/Export/SurveyHeaderSnippet.php ___________________________________________________________________ Added: svn:keywords + Id Rev Revision Date Author Modified: trunk/library/classes/Gems/Snippets/SnippetLoader.php =================================================================== --- trunk/library/classes/Gems/Snippets/SnippetLoader.php 2012-10-01 15:04:49 UTC (rev 966) +++ trunk/library/classes/Gems/Snippets/SnippetLoader.php 2012-10-02 07:47:36 UTC (rev 967) @@ -31,7 +31,7 @@ * @subpackage Snippets * @copyright Copyright (c) 2011 Erasmus MC * @license New BSD License - * @version $Id: Sample.php 215 2011-07-12 08:52:54Z michiel $ + * @version $Id$ */ /** Property changes on: trunk/library/classes/Gems/Snippets/SnippetLoader.php ___________________________________________________________________ Added: svn:keywords + Id Rev Revision Date Author Modified: trunk/library/classes/Gems/Task/Tracker/CheckTrackRounds.php =================================================================== --- trunk/library/classes/Gems/Task/Tracker/CheckTrackRounds.php 2012-10-01 15:04:49 UTC (rev 966) +++ trunk/library/classes/Gems/Task/Tracker/CheckTrackRounds.php 2012-10-02 07:47:36 UTC (rev 967) @@ -31,7 +31,7 @@ * @author Matijs de Jong <mj...@ma...> * @copyright Copyright (c) 2011 Erasmus MC * @license New BSD License - * @version $Id: CheckTokenCompletion.php 528 2012-03-01 14:06:23Z mennodekker $ + * @version $Id$ */ /** Property changes on: trunk/library/classes/Gems/Task/Tracker/CheckTrackRounds.php ___________________________________________________________________ Added: svn:keywords + Id Rev Revision Date Author Modified: trunk/library/classes/Gems/Task/Tracker/SourceCommand.php =================================================================== --- trunk/library/classes/Gems/Task/Tracker/SourceCommand.php 2012-10-01 15:04:49 UTC (rev 966) +++ trunk/library/classes/Gems/Task/Tracker/SourceCommand.php 2012-10-02 07:47:36 UTC (rev 967) @@ -29,7 +29,7 @@ * @subpackage Task_Tracker * @copyright Copyright (c) 2011 Erasmus MC * @license New BSD License - * @version $Id: SourceSyncSurveys.php 528 2012-03-01 14:06:23Z mennodekker $ + * @version $Id$ */ /** Property changes on: trunk/library/classes/Gems/Task/Tracker/SourceCommand.php ___________________________________________________________________ Added: svn:keywords + Id Rev Revision Date Author Property changes on: trunk/library/classes/Gems/Tracker/Form/AskTokenForm.php ___________________________________________________________________ Added: svn:keywords + Id Rev Revision Date Author Property changes on: trunk/library/classes/Gems/Tracker/Snippets/AnswerNameFilterInterface.php ___________________________________________________________________ Added: svn:keywords + Id Rev Revision Date Author Property changes on: trunk/library/classes/Gems/Tracker/Snippets/ShowTokenLoopAbstract.php ___________________________________________________________________ Added: svn:keywords + Id Rev Revision Date Author Modified: trunk/library/classes/Gems/User/Adapter/Radius/radius.class.php =================================================================== --- trunk/library/classes/Gems/User/Adapter/Radius/radius.class.php 2012-10-01 15:04:49 UTC (rev 966) +++ trunk/library/classes/Gems/User/Adapter/Radius/radius.class.php 2012-10-02 07:47:36 UTC (rev 967) @@ -46,9 +46,9 @@ * @author: SysCo/al * @since CreationDate: 2008-01-04 * @copyright (c) 2008 by SysCo systemes de communication sa - * @version $LastChangedRevision: 1.2.2 $ - * @version $LastChangedDate: 2009-01-05 $ - * @version $LastChangedBy: SysCo/al $ + * @version $LastChangedRevision$ + * @version $LastChangedDate$ + * @version $LastChangedBy$ * @link $HeadURL: radius.class.php $ * @link http://developer.sysco.ch/php/ * @link dev...@sy... Property changes on: trunk/library/classes/Gems/User/Adapter/Radius/radius.class.php ___________________________________________________________________ Added: svn:keywords + Id Rev Revision Date Author Modified: trunk/library/classes/Gems/User/Adapter/Radius.php =================================================================== --- trunk/library/classes/Gems/User/Adapter/Radius.php 2012-10-01 15:04:49 UTC (rev 966) +++ trunk/library/classes/Gems/User/Adapter/Radius.php 2012-10-02 07:47:36 UTC (rev 967) @@ -29,7 +29,7 @@ * @subpackage User * @copyright Copyright (c) 2011 Erasmus MC * @license New BSD License - * @version $Id: Radius.php 228 2011-12-21 09:39:34Z 175780 $ + * @version $Id$ */ include_once 'Radius/radius.class.php'; Property changes on: trunk/library/classes/Gems/User/Adapter/Radius.php ___________________________________________________________________ Added: svn:keywords + Id Rev Revision Date Author Property changes on: trunk/library/classes/Gems/User/Form/ChangePasswordForm.php ___________________________________________________________________ Added: svn:keywords + Id Rev Revision Date Author Modified: trunk/library/classes/Gems/User/Form/LayeredLoginForm.php =================================================================== --- trunk/library/classes/Gems/User/Form/LayeredLoginForm.php 2012-10-01 15:04:49 UTC (rev 966) +++ trunk/library/classes/Gems/User/Form/LayeredLoginForm.php 2012-10-02 07:47:36 UTC (rev 967) @@ -30,7 +30,7 @@ * @subpackage User\Form * @copyright Copyright (c) 2011 Erasmus MC * @license New BSD License - * @version $Id: Sample.php 215 2011-07-12 08:52:54Z michiel $ + * @version $Id$ */ /** Property changes on: trunk/library/classes/Gems/User/Form/LayeredLoginForm.php ___________________________________________________________________ Added: svn:keywords + Id Rev Revision Date Author Property changes on: trunk/library/classes/Gems/User/Form/LoginForm.php ___________________________________________________________________ Added: svn:keywords + Id Rev Revision Date Author Property changes on: trunk/library/classes/Gems/User/Form/OrganizationFormAbstract.php ___________________________________________________________________ Added: svn:keywords + Id Rev Revision Date Author Property changes on: trunk/library/classes/Gems/User/Form/ResetRequestForm.php ___________________________________________________________________ Added: svn:keywords + Id Rev Revision Date Author Property changes on: trunk/library/classes/Gems/User/Validate/GetUserInterface.php ___________________________________________________________________ Added: svn:keywords + Id Rev Revision Date Author Modified: trunk/library/classes/Gems/User/Validate/GetUserPasswordValidator.php =================================================================== --- trunk/library/classes/Gems/User/Validate/GetUserPasswordValidator.php 2012-10-01 15:04:49 UTC (rev 966) +++ trunk/library/classes/Gems/User/Validate/GetUserPasswordValidator.php 2012-10-02 07:47:36 UTC (rev 967) @@ -32,7 +32,7 @@ * @author Matijs de Jong <mj...@ma...> * @copyright Copyright (c) 2011 Erasmus MC * @license New BSD License - * @version $Id: UserPasswordValidator.php 370 2011-12-19 09:27:19Z mennodekker $ + * @version $Id$ */ /** Property changes on: trunk/library/classes/Gems/User/Validate/GetUserPasswordValidator.php ___________________________________________________________________ Added: svn:keywords + Id Rev Revision Date Author Modified: trunk/library/classes/Gems/User/Validate/NewPasswordValidator.php =================================================================== --- trunk/library/classes/Gems/User/Validate/NewPasswordValidator.php 2012-10-01 15:04:49 UTC (rev 966) +++ trunk/library/classes/Gems/User/Validate/NewPasswordValidator.php 2012-10-02 07:47:36 UTC (rev 967) @@ -32,7 +32,7 @@ * @author Matijs de Jong <mj...@ma...> * @copyright Copyright (c) 2011 Erasmus MC * @license New BSD License - * @version $Id: UserNewPasswordValidator.php 553 2012-03-16 12:32:50Z matijsdejong $ + * @version $Id$ */ /** Property changes on: trunk/library/classes/Gems/User/Validate/NewPasswordValidator.php ___________________________________________________________________ Added: svn:keywords + Id Rev Revision Date Author Modified: trunk/library/classes/Gems/User/Validate/PasswordValidatorAbstract.php =================================================================== --- trunk/library/classes/Gems/User/Validate/PasswordValidatorAbstract.php 2012-10-01 15:04:49 UTC (rev 966) +++ trunk/library/classes/Gems/User/Validate/PasswordValidatorAbstract.php 2012-10-02 07:47:36 UTC (rev 967) @@ -32,7 +32,7 @@ * @author Matijs de Jong <mj...@ma...> * @copyright Copyright (c) 2011 Erasmus MC * @license New BSD License - * @version $Id: UserPasswordValidator.php 370 2011-12-19 09:27:19Z mennodekker $ + * @version $Id$ */ /** Property changes on: trunk/library/classes/Gems/User/Validate/PasswordValidatorAbstract.php ___________________________________________________________________ Added: svn:keywords + Id Rev Revision Date Author Property changes on: trunk/library/classes/Gems/User/Validate/ResetRequestValidator.php ___________________________________________________________________ Added: svn:keywords + Id Rev Revision Date Author Modified: trunk/library/classes/Gems/User/Validate/UserPasswordValidator.php =================================================================== --- trunk/library/classes/Gems/User/Validate/UserPasswordValidator.php 2012-10-01 15:04:49 UTC (rev 966) +++ trunk/library/classes/Gems/User/Validate/UserPasswordValidator.php 2012-10-02 07:47:36 UTC (rev 967) @@ -32,7 +32,7 @@ * @author Matijs de Jong <mj...@ma...> * @copyright Copyright (c) 2011 Erasmus MC * @license New BSD License - * @version $Id: UserPasswordValidator.php 370 2011-12-19 09:27:19Z mennodekker $ + * @version $Id$ */ /** Property changes on: trunk/library/classes/Gems/User/Validate/UserPasswordValidator.php ___________________________________________________________________ Added: svn:keywords + Id Rev Revision Date Author Modified: trunk/library/classes/Gems/View/Helper/HeadLink.php =================================================================== --- trunk/library/classes/Gems/View/Helper/HeadLink.php 2012-10-01 15:04:49 UTC (rev 966) +++ trunk/library/classes/Gems/View/Helper/HeadLink.php 2012-10-02 07:47:36 UTC (rev 967) @@ -31,7 +31,7 @@ * @subpackage View\Helper * @copyright Copyright (c) 2011 Erasmus MC * @license New BSD License - * @version $Id: Sample.php 215 2011-07-12 08:52:54Z michiel $ + * @version $Id$ */ // We need to load the class first @@ -50,8 +50,7 @@ * @subpackage View\Helper * @copyright Copyright (c) 2011 Erasmus MC * @license New BSD License - * @since Class available since version 1.0 - * @deprecated Class deprecated since version 2.0 + * @since Class available since version 1.5.5 */ class Gems_View_Helper_HeadLink extends Zend_View_Helper_HeadLink { Property changes on: trunk/library/classes/Gems/View/Helper/HeadLink.php ___________________________________________________________________ Added: svn:keywords + Id Rev Revision Date Author Modified: trunk/library/classes/MUtil/Batch/BatchAbstract.php =================================================================== --- trunk/library/classes/MUtil/Batch/BatchAbstract.php 2012-10-01 15:04:49 UTC (rev 966) +++ trunk/library/classes/MUtil/Batch/BatchAbstract.php 2012-10-02 07:47:36 UTC (rev 967) @@ -32,7 +32,7 @@ * @author Matijs de Jong <mj...@ma...> * @copyright Copyright (c) 2012 Erasmus MC * @license New BSD License - * @version $Id: Sample.php 203 2011-07-07 12:51:32Z matijs $ + * @version $Id$ */ /** Property changes on: trunk/library/classes/MUtil/Batch/BatchAbstract.php ___________________________________________________________________ Added: svn:keywords + Id Rev Revision Date Author Property changes on: trunk/library/classes/MUtil/Batch/BatchException.php ___________________________________________________________________ Added: svn:keywords + Id Rev Revision Date Author Modified: trunk/library/classes/MUtil/Batch/WaitBatch.php =================================================================== --- trunk/library/classes/MUtil/Batch/WaitBatch.php 2012-10-01 15:04:49 UTC (rev 966) +++ trunk/library/classes/MUtil/Batch/WaitBatch.php 2012-10-02 07:47:36 UTC (rev 967) @@ -32,7 +32,7 @@ * @author Matijs de Jong <mj...@ma...> * @copyright Copyright (c) 2011 Erasmus MC * @license New BSD License - * @version $Id: Sample.php 203 2012-07-07 12:51:32Z matijs $ + * @version $Id$ */ /** Property changes on: trunk/library/classes/MUtil/Batch/WaitBatch.php ___________________________________________________________________ Added: svn:keywords + Id Rev Revision Date Author Modified: trunk/library/classes/MUtil/Controller/ModelSnippetActionAbstract.php =================================================================== --- trunk/library/classes/MUtil/Controller/ModelSnippetActionAbstract.php 2012-10-01 15:04:49 UTC (rev 966) +++ trunk/library/classes/MUtil/Controller/ModelSnippetActionAbstract.php 2012-10-02 07:47:36 UTC (rev 967) @@ -32,7 +32,7 @@ * @author Matijs de Jong <mj...@ma...> * @copyright Copyright (c) 2011 Erasmus MC * @license New BSD License - * @version $Id: Sample.php 203 2011-07-07 12:51:32Z matijs $ + * @version $Id$ */ /** Property changes on: trunk/library/classes/MUtil/Controller/ModelSnippetActionAbstract.php ___________________________________________________________________ Added: svn:keywords + Id Rev Revision Date Author Property changes on: trunk/library/classes/MUtil/Form/Element/Multiselect.php ___________________________________________________________________ Added: svn:keywords + Id Rev Revision Date Author Property changes on: trunk/library/classes/MUtil/Form/Element/Select.php ___________________________________________________________________ Added: svn:keywords + Id Rev Revision Date Author Property changes on: trunk/library/classes/MUtil/Html/Code/DynamicAbstract.php ___________________________________________________________________ Added: svn:keywords + Id Rev Revision Date Author Property changes on: trunk/library/classes/MUtil/Html/Code/JavaScript.php ___________________________________________________________________ Added: svn:keywords + Id Rev Revision Date Author Property changes on: trunk/library/classes/MUtil/Html/HnElement.php ___________________________________________________________________ Added: svn:keywords + Id Rev Revision Date Author Modified: trunk/library/classes/MUtil/Html/IFrame.php =================================================================== --- trunk/library/classes/MUtil/Html/IFrame.php 2012-10-01 15:04:49 UTC (rev 966) +++ trunk/library/classes/MUtil/Html/IFrame.php 2012-10-02 07:47:36 UTC (rev 967) @@ -32,7 +32,7 @@ * @author Matijs de Jong <mj...@ma...> * @copyright Copyright (c) 2011 Erasmus MC * @license New BSD License - * @version $Id: AElement.php 515 2012-02-23 15:40:31Z matijsdejong $ + * @version $Id$ */ /** Property changes on: trunk/library/classes/MUtil/Html/IFrame.php ___________________________________________________________________ Added: svn:keywords + Id Rev Revision Date Author Modified: trunk/library/classes/MUtil/Html/PFormElement.php =================================================================== --- trunk/library/classes/MUtil/Html/PFormElement.php 2012-10-01 15:04:49 UTC (rev 966) +++ trunk/library/classes/MUtil/Html/PFormElement.php 2012-10-02 07:47:36 UTC (rev 967) @@ -32,7 +32,7 @@ * @author Matijs de Jong <mj...@ma...> * @copyright Copyright (c) 2011 Erasmus MC * @license New BSD License - * @version $Id: TableElement.php 53 2011-09-20 16:00:47Z matijsdejong $ + * @version $Id$ */ /** Property changes on: trunk/library/classes/MUtil/Html/PFormElement.php ___________________________________________________________________ Added: svn:keywords + Id Rev Revision Date Author Modified: trunk/library/classes/MUtil/Html/ProgressPanel.php =================================================================== --- trunk/library/classes/MUtil/Html/ProgressPanel.php 2012-10-01 15:04:49 UTC (rev 966) +++ trunk/library/classes/MUtil/Html/ProgressPanel.php 2012-10-02 07:47:36 UTC (rev 967) @@ -32,7 +32,7 @@ * @author Matijs de Jong <mj...@ma...> * @copyright Copyright (c) 2011 Erasmus MC * @license New BSD License - * @version $Id: Sample.php 203 2011-07-07 12:51:32Z matijs $ + * @version $Id$ */ /** Property changes on: trunk/library/classes/MUtil/Html/ProgressPanel.php ___________________________________________________________________ Added: svn:keywords + Id Rev Revision Date Author Modified: trunk/library/classes/MUtil/Html/SrcArrayAttribute.php =================================================================== --- trunk/library/classes/MUtil/Html/SrcArrayAttribute.php 2012-10-01 15:04:49 UTC (rev 966) +++ trunk/library/classes/MUtil/Html/SrcArrayAttribute.php 2012-10-02 07:47:36 UTC (rev 967) @@ -32,7 +32,7 @@ * @author Matijs de Jong <mj...@ma...> * @copyright Copyright (c) 2011 Erasmus MC * @license New BSD License - * @version $Id: AttributeAbstract.php 514 2012-02-23 15:00:56Z matijsdejong $ + * @version $Id$ */ /** Property changes on: trunk/library/classes/MUtil/Html/SrcArrayAttribute.php ___________________________________________________________________ Added: svn:keywords + Id Rev Revision Date Author Modified: trunk/library/classes/MUtil/Mail/Transport/EchoLog.php =================================================================== --- trunk/library/classes/MUtil/Mail/Transport/EchoLog.php 2012-10-01 15:04:49 UTC (rev 966) +++ trunk/library/classes/MUtil/Mail/Transport/EchoLog.php 2012-10-02 07:47:36 UTC (rev 967) @@ -32,7 +32,7 @@ * @author Matijs de Jong <mj...@ma...> * @copyright Copyright (c) 2011 Erasmus MC * @license New BSD License - * @version $Id: Sample.php 203 2011-07-07 12:51:32Z matijs $ + * @version $Id$ */ /** Property changes on: trunk/library/classes/MUtil/Mail/Transport/EchoLog.php ___________________________________________________________________ Added: svn:keywords + Id Rev Revision Date Author Property changes on: trunk/library/classes/MUtil/Model/SelectModelPaginator.php ___________________________________________________________________ Added: svn:keywords + Id Rev Revision Date Author Property changes on: trunk/library/classes/MUtil/Model/Type/ConcatenatedRow.php ___________________________________________________________________ Added: svn:keywords + Id Rev Revision Date Author Modified: trunk/library/classes/MUtil/ProgressBar/Adapter/JsPush.php =================================================================== --- trunk/library/classes/MUtil/ProgressBar/Adapter/JsPush.php 2012-10-01 15:04:49 UTC (rev 966) +++ trunk/library/classes/MUtil/ProgressBar/Adapter/JsPush.php 2012-10-02 07:47:36 UTC (rev 967) @@ -32,7 +32,7 @@ * @author Matijs de Jong <mj...@ma...> * @copyright Copyright (c) 2012 Erasmus MC * @license New BSD License - * @version $Id: JsPush.php 203 2012-01-01t 12:51:32Z matijs $ + * @version $Id$ */ /** Property changes on: trunk/library/classes/MUtil/ProgressBar/Adapter/JsPush.php ___________________________________________________________________ Added: svn:keywords + Id Rev Revision Date Author Property changes on: trunk/library/classes/MUtil/Queue/Adapter/DbPrefixed.php ___________________________________________________________________ Added: svn:keywords + Id Rev Revision Date Author Modified: trunk/library/classes/MUtil/Snippets/ModelYesNoDeleteSnippetAbstract.php =================================================================== --- trunk/library/classes/MUtil/Snippets/ModelYesNoDeleteSnippetAbstract.php 2012-10-01 15:04:49 UTC (rev 966) +++ trunk/library/classes/MUtil/Snippets/ModelYesNoDeleteSnippetAbstract.php 2012-10-02 07:47:36 UTC (rev 967) @@ -32,7 +32,7 @@ * @author Matijs de Jong <mj...@ma...> * @copyright Copyright (c) 2011 Erasmus MC * @license New BSD License - * @version $Id: Sample.php 203 2011-07-07 12:51:32Z matijs $ + * @version $Id$ */ /** Property changes on: trunk/library/classes/MUtil/Snippets/ModelYesNoDeleteSnippetAbstract.php ___________________________________________________________________ Added: svn:keywords + Id Rev Revision Date Author Modified: trunk/library/classes/MUtil/Snippets/SnippetLoaderInterface.php =================================================================== --- trunk/library/classes/MUtil/Snippets/SnippetLoaderInterface.php 2012-10-01 15:04:49 UTC (rev 966) +++ trunk/library/classes/MUtil/Snippets/SnippetLoaderInterface.php 2012-10-02 07:47:36 UTC (rev 967) @@ -29,7 +29,7 @@ * @subpackage Snippets * @copyright Copyright (c) 2011 Erasmus MC * @license New BSD License - * @version $Id: Sample.php 215 2011-07-12 08:52:54Z michiel $ + * @version $Id$ */ /** Property changes on: trunk/library/classes/MUtil/Snippets/SnippetLoaderInterface.php ___________________________________________________________________ Added: svn:keywords + Id Rev Revision Date Author Modified: trunk/library/classes/MUtil/Snippets/Standard/ModelYesNoDeleteSnippet.php =================================================================== --- trunk/library/classes/MUtil/Snippets/Standard/ModelYesNoDeleteSnippet.php 2012-10-01 15:04:49 UTC (rev 966) +++ trunk/library/classes/MUtil/Snippets/Standard/ModelYesNoDeleteSnippet.php 2012-10-02 07:47:36 UTC (rev 967) @@ -32,7 +32,7 @@ * @author Matijs de Jong <mj...@ma...> * @copyright Copyright (c) 2011 Erasmus MC * @license New BSD License - * @version $Id: Sample.php 203 2011-07-07 12:51:32Z matijs $ + * @version $Id$ */ /** Property changes on: trunk/library/classes/MUtil/Snippets/Standard/ModelYesNoDeleteSnippet.php ___________________________________________________________________ Added: svn:keywords + Id Rev Revision Date Author Property changes on: trunk/library/classes/MUtil/View/Helper/FormSelectHtml.php ___________________________________________________________________ Added: svn:keywords + Id Rev Revision Date Author Modified: trunk/library/classes/Zend/Translate/Adapter.php =================================================================== --- trunk/library/classes/Zend/Translate/Adapter.php 2012-10-01 15:04:49 UTC (rev 966) +++ trunk/library/classes/Zend/Translate/Adapter.php 2012-10-02 07:47:36 UTC (rev 967) @@ -17,7 +17,7 @@ * @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 $ + * @version $Id$ */ /** Property changes on: trunk/library/classes/Zend/Translate/Adapter.php ___________________________________________________________________ Added: svn:keywords + Id Rev Revision Date Author This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2012-11-15 15:37:10
|
Revision: 1018 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=1018&view=rev Author: matijsdejong Date: 2012-11-15 15:37:03 +0000 (Thu, 15 Nov 2012) Log Message: ----------- Token/ask is now token language and organization aware Modified Paths: -------------- trunk/library/classes/Gems/Default/AskAction.php trunk/library/classes/Gems/Tracker/RespondentTrack.php trunk/library/classes/Gems/Tracker/Token.php trunk/library/classes/MUtil/Controller/Action.php Modified: trunk/library/classes/Gems/Default/AskAction.php =================================================================== --- trunk/library/classes/Gems/Default/AskAction.php 2012-11-15 14:18:41 UTC (rev 1017) +++ trunk/library/classes/Gems/Default/AskAction.php 2012-11-15 15:37:03 UTC (rev 1018) @@ -65,6 +65,39 @@ protected $labelWidthFactor = 0.8; /** + * + * @var Zend_Locale + */ + public $locale; + + /** + * The current token ID + * + * set by _initToken() + * + * @var Gems_Tracker + */ + protected $tokenId; + + /** + * The current token + * + * set by _initToken() + * + * @var Gems_Tracker_Token + */ + protected $token; + + /** + * The tracker + * + * set by _initToken() + * + * @var Gems_Tracker + */ + protected $tracker; + + /** * Set to true in child class for automatic creation of $this->html. * * To initiate the use of $this->html from the code call $this->initHtml() @@ -77,6 +110,52 @@ public $useHtmlView = true; /** + * Common handler utility to initialize tokens from parameters + * + * @return boolean True if there is a real token specified in the request + */ + protected function _initToken() + { + if ($this->tracker) { + return $this->token && $this->token->exists; + } + + $this->tracker = $this->loader->getTracker(); + $this->tokenId = $this->tracker->filterToken($this->_getParam(MUtil_Model::REQUEST_ID)); + + if (! $this->tokenId) { + return false; + } + + $this->token = $this->tracker->getToken($this->tokenId); + + if (! $this->token->exists) { + return false; + } + + if (! $this->loader->getCurrentUser()->isActive()) { + $tokenLang = strtolower($this->token->getRespondentLanguage()); + // MUtil_Echo::track($tokenLang, $this->locale->getLanguage()); + if ($tokenLang != $this->locale->getLanguage()) { + $this->locale->setLocale($tokenLang); + $this->translate->getAdapter()->setLocale($this->locale); + $this->session->user_locale = $tokenLang; + Gems_Cookies::setLocale($tokenLang, $this->basepath->getBasePath()); + } + + $currentOrg = $this->loader->getOrganization(); + $tokenOrgId = $this->token->getOrganizationId(); + + if ($tokenOrgId != $currentOrg->getId()) { + $this->loader->getOrganization($tokenOrgId) + ->setAsCurrentOrganization(); + } + } + + return true; + } + + /** * Function for overruling the display of the login form. * * @param Gems_Tracker_Form_AskTokenForm $form @@ -113,40 +192,47 @@ * Find token * **************/ - if ($tokenId = $this->_getParam(MUtil_Model::REQUEST_ID)) { - $tracker = $this->loader->getTracker(); - $tokenId = $tracker->filterToken($tokenId); - $token = $tracker->getToken($tokenId); + if (! $this->_initToken()) { + if ($this->tokenId) { + // There is a token but is incorrect + $this->addMessage(sprintf( + $this->_('The token %s does not exist (any more).'), + strtoupper($this->tokenId) + )); + } + $this->_forward('index'); + return; + } - if ($token->exists) { + /**************************** + * Update open tokens first * + ****************************/ + $this->tracker->processCompletedTokens( + $this->token->getRespondentId(), + $this->token->getChangedBy(), + $this->token->getOrganizationId() + ); - /**************************** - * Update open tokens first * - ****************************/ - $respId = $token->getRespondentId(); - $tracker->processCompletedTokens($respId, $token->getChangedBy()); + // Display token when possible + if ($this->html->snippet($this->forwardSnippets, 'token', $this->token)) { + return; + } - // Display token when possible - if ($this->html->snippet($this->forwardSnippets, 'token', $token)) { - return; - } - - // Snippet had nothing to display, because of an answer - if ($this->getRequest()->getActionName() == 'return') { - $this->addMessage(sprintf($this->_('Thank you for answering. At the moment we have no further surveys for you to take.'), strtoupper($tokenId))); - } else { - $this->addMessage(sprintf($this->_('The survey for token %s has been answered and no further surveys are open.'), strtoupper($tokenId))); - } - - // Do not enter a loop!! Reroute! - $this->_reroute(array('controller' => 'ask', 'action' => 'index'), true); - - } else { - $this->addMessage(sprintf($this->_('The token %s does not exist (any more).'), strtoupper($tokenId))); - } + // Snippet had nothing to display, because of an answer + if ($this->getRequest()->getActionName() == 'return') { + $this->addMessage(sprintf( + $this->_('Thank you for answering. At the moment we have no further surveys for you to take.'), + strtoupper($this->tokenId) + )); + } else { + $this->addMessage(sprintf( + $this->_('The survey for token %s has been answered and no further surveys are open.'), + strtoupper($this->tokenId) + )); } - $this->_forward('index'); + // Do not enter a loop!! Reroute! + $this->_reroute(array('controller' => 'ask', 'action' => 'index'), true); } /** @@ -161,7 +247,10 @@ $request = $this->getRequest(); $tracker = $this->loader->getTracker(); - $form = $tracker->getAskTokenForm(array('displayOrder' => array('element', 'description', 'errors'), 'labelWidthFactor' => 0.8)); + $form = $tracker->getAskTokenForm(array( + 'displayOrder' => array('element', 'description', 'errors'), + 'labelWidthFactor' => 0.8 + )); if ($request->isPost() && $form->isValid($request->getParams())) { $this->_forward('forward'); @@ -173,58 +262,51 @@ } /** - * Common handler utility to initialize tokens from parameters - */ - protected function initToken() - { - $this->tracker = $this->loader->getTracker(); - $this->tokenId = $this->tracker->filterToken($this->_getParam(MUtil_Model::REQUEST_ID)); - $this->token = $this->tracker->getToken($this->tokenId); - } - - /** * The action where survey sources should return to after survey completion */ public function returnAction() { - $tracker = $this->loader->getTracker(); + if (! $this->_initToken()) { + // In all other cases: the action that generates meaningfull warnings and is reachable for everyone + $this->_forward('forward'); + return; + } - if ($tokenId = $this->_getParam(MUtil_Model::REQUEST_ID)) { - $tokenId = $tracker->filterToken($tokenId); - $token = $tracker->getToken($tokenId); + if ($url = $this->token->getReturnUrl()) { + // Check for completed tokens + $this->tracker->processCompletedTokens( + $this->token->getRespondentId(), + $this->token->getChangedBy(), + $this->token->getOrganizationId() + ); - if ($url = $token->getReturnUrl()) { - // Check for completed tokens - $this->loader->getTracker()->processCompletedTokens($token->getRespondentId(), $token->getChangedBy()); + // Redirect at once, might be another site url + header('Location: ' . $url); + exit(); + } - // Redirect at once, might be another site url - header('Location: ' . $url); - exit(); - } + // No return? Check for old style user based return + $user = $this->loader->getCurrentUser(); - // Nor return? Check for old style user based return - $user = $this->loader->getCurrentUser(); + if (! $user->isActive()) { + $this->_forward('forward'); + return; + } - if ($user->isActive() && ($parameters = $user->getSurveyReturn())) { + // Check for completed tokens + $this->tracker->processCompletedTokens($this->token->getRespondentId(), $user->getUserId()); - // Check for completed tokens - $this->loader->getTracker()->processCompletedTokens($token->getRespondentId(), $user->getUserId()); - - if (! $parameters) { - // Default - $request = $this->getRequest(); - $parameters[$request->getControllerKey()] = 'respondent'; - $parameters[$request->getActionKey()] = 'show'; - $parameters[MUtil_Model::REQUEST_ID] = $token->getPatientNumber(); - } - - $this->_reroute($parameters, true); - return; - } + // Get return route parameters + $parameters = $user->getSurveyReturn(); + if (! $parameters) { + // Default fallback for the fallback + $request = $this->getRequest(); + $parameters[$request->getControllerKey()] = 'respondent'; + $parameters[$request->getActionKey()] = 'show'; + $parameters[MUtil_Model::REQUEST_ID] = $this->token->getPatientNumber(); } - // In all other cases: the action that generates meaningfull warnings as is reachable for everyone - $this->_forward('forward'); + $this->_reroute($parameters, true); } /** @@ -248,34 +330,39 @@ */ public function toSurveyAction() { - $tracker = $this->loader->getTracker(); - if ($tokenId = $this->_getParam(MUtil_Model::REQUEST_ID)) { - $tokenId = $tracker->filterToken($tokenId); + if (! $this->_initToken()) { + // Default option + $this->_forward('index'); + } - if ($token = $tracker->getToken($tokenId)) { - $language = $this->locale->getLanguage(); - $user = $this->loader->getCurrentUser(); + $language = $this->locale->getLanguage(); + $user = $this->loader->getCurrentUser(); - try { - $url = $token->getUrl($language, $user->getUserId() ? $user->getUserId() : $token->getRespondentId()); + try { + $url = $this->token->getUrl( + $language, + $user->getUserId() ? $user->getUserId() : $this->token->getRespondentId() + ); - /************************ - * Optional user logout * - ************************/ - if ($user->isLogoutOnSurvey()) { - $user->unsetAsCurrentUser(); - } + /************************ + * Optional user logout * + ************************/ + if ($user->isLogoutOnSurvey()) { + $user->unsetAsCurrentUser(); + } - // Redirect at once - header('Location: ' . $url); - exit(); - } catch (Gems_Tracker_Source_SurveyNotFoundException $e) { - $this->addMessage(sprintf($this->_('The survey for token %s is no longer active.'), $tokenId)); - } - } + // Redirect at once + header('Location: ' . $url); + exit(); + + } catch (Gems_Tracker_Source_SurveyNotFoundException $e) { + $this->addMessage(sprintf( + $this->_('The survey for token %s is no longer active.'), + strtoupper($this->tokenId) + )); + + // Default option + $this->_forward('index'); } - - // Default option - $this->_forward('index'); } } Modified: trunk/library/classes/Gems/Tracker/RespondentTrack.php =================================================================== --- trunk/library/classes/Gems/Tracker/RespondentTrack.php 2012-11-15 14:18:41 UTC (rev 1017) +++ trunk/library/classes/Gems/Tracker/RespondentTrack.php 2012-11-15 15:37:03 UTC (rev 1018) @@ -94,6 +94,12 @@ /** * + * @var Zend_Locale + */ + protected $locale; + + /** + * * @var Gems_Tracker */ protected $tracker; @@ -511,13 +517,32 @@ } /** + * Return the default language for the respondent + * + * @return string Two letter language code + */ + public function getRespondentLanguage() + { + if (! isset($this->_respTrackData['grs_iso_lang'])) { + $this->_ensureRespondentData(); + + if (! isset($this->_respTrackData['grs_iso_lang'])) { + // Still not set in a project? The it is single language + $this->_respTrackData['grs_iso_lang'] = $this->locale->getLanguage(); + } + } + + return $this->_respTrackData['grs_iso_lang']; + } + + /** * Return the name of the respondent * * @return string The respondents name */ public function getRespondentName() { - if (! isset($this->_respTrackData['grs_first_name'], $this->_respTrackData['grs_surname_prefix'], $this->_respTrackData['grs_last_name'])) { + if (! isset($this->_respTrackData['grs_first_name'], $this->_respTrackData['grs_last_name'])) { $this->_ensureRespondentData(); } Modified: trunk/library/classes/Gems/Tracker/Token.php =================================================================== --- trunk/library/classes/Gems/Tracker/Token.php 2012-11-15 14:18:41 UTC (rev 1017) +++ trunk/library/classes/Gems/Tracker/Token.php 2012-11-15 15:37:03 UTC (rev 1018) @@ -120,6 +120,12 @@ /** * + * @var Zend_Locale + */ + protected $locale; + + /** + * * @var Gems_Tracker_Survey */ protected $survey; @@ -132,7 +138,7 @@ /** * - * @var Zend_Translate_Adapter + * @var Zend_Translate */ public $translate; @@ -195,6 +201,7 @@ $respId = $this->_gemsData['gto_id_respondent']; $orgId = $this->_gemsData['gto_id_organization']; + MUtil_Echo::track($this->_gemsData); if ($row = $this->db->fetchRow($sql, array($respId, $orgId))) { $this->_gemsData = $this->_gemsData + $row; @@ -887,7 +894,26 @@ } /** + * Return the default language for the respondent * + * @return string Two letter language code + */ + public function getRespondentLanguage() + { + if (! isset($this->_gemsData['grs_iso_lang'])) { + $this->_ensureRespondentData(); + + if (! isset($this->_gemsData['grs_iso_lang'])) { + // Still not set in a project? The it is single language + $this->_gemsData['grs_iso_lang'] = $this->locale->getLanguage(); + } + } + + return $this->_gemsData['grs_iso_lang']; + } + + /** + * * @return string */ public function getRespondentLastName() @@ -989,24 +1015,27 @@ * Returns a string that tells if the token is open, completed or any other * status you might like. This will not be interpreted by the tracker it is * for display purposes only + * + * @return string Token status description */ public function getStatus() { $today = new Zend_Date(); - $status = $this->translate->_('Open'); if ($this->isCompleted()) { - $status = $this->translate->_('Completed'); + $status = $this->translate->getAdapter()->_('Completed'); } else { $validFrom = $this->getValidFrom(); $validUntil = $this->getValidUntil(); - if (!empty($validUntil) && $validUntil->isEarlier($today)) { - $status = $this->translate->_('Missed'); - } else if (!empty($validFrom) && $validFrom->isLater($today)) { - $status = $this->translate->_('Future'); - } else if (empty($validFrom) && empty($validUntil)) { - $status = $this->translate->_('Future'); + if (! empty($validUntil) && $validUntil->isEarlier($today)) { + $status = $this->translate->getAdapter()->_('Missed'); + } elseif (! empty($validFrom) && $validFrom->isLater($today)) { + $status = $this->translate->getAdapter()->_('Future'); + } elseif (empty($validFrom) && empty($validUntil)) { + $status = $this->translate->getAdapter()->_('Future'); + } else { + $status = $this->translate->getAdapter()->_('Open'); } } Modified: trunk/library/classes/MUtil/Controller/Action.php =================================================================== --- trunk/library/classes/MUtil/Controller/Action.php 2012-11-15 14:18:41 UTC (rev 1017) +++ trunk/library/classes/MUtil/Controller/Action.php 2012-11-15 15:37:03 UTC (rev 1018) @@ -88,7 +88,7 @@ * The code will use a Potemkin Translate adapter when Zend_Translate is not set in the registry, so * the code will still work, it just will not translate. * - * @var Zend_Translate $translate + * @var Zend_Translate */ public $translate; @@ -372,9 +372,9 @@ public function getTranslate() { if (! $this->translate) { - $translate = Zend_Registry::get('Zend_Translate'); - - if (null === $translate) { + if (Zend_Registry::isRegistered('Zend_Translate')) { + $translate = Zend_Registry::get('Zend_Translate'); + } else { // Make sure there always is a translator $translate = new MUtil_Translate_Adapter_Potemkin(); Zend_Registry::set('Zend_Translate', $translate); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2012-11-15 17:48:03
|
Revision: 1020 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=1020&view=rev Author: matijsdejong Date: 2012-11-15 17:47:56 +0000 (Thu, 15 Nov 2012) Log Message: ----------- Fix for always getting last set of answers Fix for new Databasemodel save options Modified Paths: -------------- trunk/library/classes/Gems/Tracker/Model/SingleSurveyTokenModel.php trunk/library/classes/Gems/Tracker/Source/LimeSurvey1m9Database.php trunk/library/classes/MUtil/Model/TableModel.php Modified: trunk/library/classes/Gems/Tracker/Model/SingleSurveyTokenModel.php =================================================================== --- trunk/library/classes/Gems/Tracker/Model/SingleSurveyTokenModel.php 2012-11-15 16:18:58 UTC (rev 1019) +++ trunk/library/classes/Gems/Tracker/Model/SingleSurveyTokenModel.php 2012-11-15 17:47:56 UTC (rev 1020) @@ -83,7 +83,8 @@ * @param array $oldKeys The original keys as they where before the changes * @return array The values for this table as they were updated */ - protected function _saveTableData(Zend_Db_Table_Abstract $table, array $newValues, array $oldKeys = null) + protected function _saveTableData(Zend_Db_Table_Abstract $table, array $newValues, + array $oldKeys = null, $saveMode = self::SAVE_MODE_ALL) { $table_name = $this->_getTableName($table); @@ -98,7 +99,7 @@ return $tokenData; } else { - return parent::_saveTableData($table, $newValues, $oldKeys); + return parent::_saveTableData($table, $newValues, $oldKeys, $saveMode); } } Modified: trunk/library/classes/Gems/Tracker/Source/LimeSurvey1m9Database.php =================================================================== --- trunk/library/classes/Gems/Tracker/Source/LimeSurvey1m9Database.php 2012-11-15 16:18:58 UTC (rev 1019) +++ trunk/library/classes/Gems/Tracker/Source/LimeSurvey1m9Database.php 2012-11-15 17:47:56 UTC (rev 1020) @@ -791,7 +791,9 @@ $token = $this->_getToken($tokenId); try { - $values = $lsDb->fetchRow("SELECT * FROM $lsTab WHERE token = ?", $token); + // Order by ID desc to get the same answers used as in the row retrieved by + // getRawTokenAnswerRows() in case of double rows + $values = $lsDb->fetchRow("SELECT * FROM $lsTab WHERE token = ? ORDER BY id DESC", $token); } catch (Zend_Db_Statement_Exception $exception) { $this->logger->logError($exception, $this->request); $values = false; @@ -874,16 +876,17 @@ // this way other sources that don't perform changes on the token field don't have to loop // over this field. The survey(answer)model could possibly perform the translation for this source if ($rows) { + $map = $this->_getFieldMap($sourceSurveyId); if (isset($filter[$tokenField])) { foreach ($rows as $values) { $token = $originals[$values['token']]; - $results[$token] = $this->_getFieldMap($sourceSurveyId)->mapKeysToTitles($values); + $results[$token] = $map->mapKeysToTitles($values); } return $results; } else { //@@TODO If we do the mapping in the select statement, maybe we can gain some performance here foreach ($rows as $values) { - $results[] = $this->_getFieldMap($sourceSurveyId)->mapKeysToTitles($values); + $results[] = $map->mapKeysToTitles($values); } return $results; } @@ -1052,9 +1055,13 @@ $lsTab = $this->_getSurveyTableName($sourceSurveyId); $lsTokenId = $this->_getToken($token->getTokenId()); + // MUtil_Echo::track($answers); + $answers = $this->_getFieldMap($sourceSurveyId)->mapTitlesToKeys($answers); $answers = $this->_filterAnswersOnly($sourceSurveyId, $answers); + // MUtil_Echo::track($answers); + if ($lsDb->fetchOne("SELECT token FROM $lsTab WHERE token = ?", $lsTokenId)) { $where = $lsDb->quoteInto("token = ?", $lsTokenId); $lsDb->update($lsTab, $answers, $where); @@ -1067,7 +1074,6 @@ $answers['startdate'] = $current; $lsDb->insert($lsTab, $answers); - } } Modified: trunk/library/classes/MUtil/Model/TableModel.php =================================================================== --- trunk/library/classes/MUtil/Model/TableModel.php 2012-11-15 16:18:58 UTC (rev 1019) +++ trunk/library/classes/MUtil/Model/TableModel.php 2012-11-15 17:47:56 UTC (rev 1020) @@ -119,6 +119,6 @@ { // $this->_saveTableData returns the new row values, including any automatic changes. // add $newValues to throw nothing away. - return $this->_saveTableData($this->_table, $newValues, $filter) + $newValues; + return $this->_saveTableData($this->_table, $newValues, $filter, parent::SAVE_MODE_ALL) + $newValues; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2012-11-21 19:09:39
|
Revision: 1027 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=1027&view=rev Author: matijsdejong Date: 2012-11-21 19:09:32 +0000 (Wed, 21 Nov 2012) Log Message: ----------- tokenanswerspersistence is now required in LimeSurvey surveys Removed debugging code from DatabaseModelAbstract.php Modified Paths: -------------- trunk/library/classes/Gems/Tracker/Source/LimeSurvey1m9Database.php trunk/library/classes/MUtil/Model/DatabaseModelAbstract.php Modified: trunk/library/classes/Gems/Tracker/Source/LimeSurvey1m9Database.php =================================================================== --- trunk/library/classes/Gems/Tracker/Source/LimeSurvey1m9Database.php 2012-11-21 16:03:11 UTC (rev 1026) +++ trunk/library/classes/Gems/Tracker/Source/LimeSurvey1m9Database.php 2012-11-21 19:09:32 UTC (rev 1027) @@ -380,7 +380,7 @@ // SELECT sid, surveyls_title AS short_title, surveyls_description AS description, active, datestamp, ' . $this->_anonymizedField . ' $select = $lsDb->select(); - $select->from($this->_getSurveysTableName(), array('active', 'datestamp', $this->_anonymizedField)) + $select->from($this->_getSurveysTableName(), array('active', 'datestamp', 'tokenanswerspersistence', $this->_anonymizedField)) ->joinInner( $this->_getSurveyLanguagesTableName(), 'sid = surveyls_survey_id AND language = surveyls_language', @@ -414,6 +414,11 @@ $surveyor_status .= 'Not date stamped. '; } + // DATESTAMP + if ($lsSurvey['tokenanswerspersistence'] == 'N') { + $surveyor_status .= 'Token-based persistence is disabled. '; + } + // IS ACTIVE if ($lsSurvey['active'] == 'Y') { $surveyor_active = true; Modified: trunk/library/classes/MUtil/Model/DatabaseModelAbstract.php =================================================================== --- trunk/library/classes/MUtil/Model/DatabaseModelAbstract.php 2012-11-21 16:03:11 UTC (rev 1026) +++ trunk/library/classes/MUtil/Model/DatabaseModelAbstract.php 2012-11-21 19:09:32 UTC (rev 1027) @@ -477,7 +477,7 @@ // Check for actual values for this table to save. // MUtil_Echo::track($newValues); if ($returnValues = $this->_filterDataFor($table_name, $newValues, ! $update)) { - if (true || MUtil_Model::$verbose) { + if (MUtil_Model::$verbose) { MUtil_Echo::r($returnValues, 'Return'); } // MUtil_Echo::track($returnValues); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2012-11-22 13:21:12
|
Revision: 1035 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=1035&view=rev Author: matijsdejong Date: 2012-11-22 13:21:02 +0000 (Thu, 22 Nov 2012) Log Message: ----------- Fix for #564 marker tags appeared in the href email address Modified Paths: -------------- trunk/library/classes/Gems/Default/RespondentAction.php trunk/library/classes/MUtil/Model/TableBridgeAbstract.php Modified: trunk/library/classes/Gems/Default/RespondentAction.php =================================================================== --- trunk/library/classes/Gems/Default/RespondentAction.php 2012-11-22 12:13:14 UTC (rev 1034) +++ trunk/library/classes/Gems/Default/RespondentAction.php 2012-11-22 13:21:02 UTC (rev 1035) @@ -46,6 +46,17 @@ */ abstract class Gems_Default_RespondentAction extends Gems_Controller_BrowseEditAction implements Gems_Menu_ParameterSourceInterface { + public $exportSnippets = array('RespondentDetailsSnippet'); + + public $filterStandard = array('grc_success' => 1); + + /** + * Variable for correctly displaying e-mail addresses + * + * @var MUtil_Lazy_LazyAbstract + */ + protected $grs_email; + public $showSnippets = array( 'RespondentDetailsSnippet', 'AddTracksSnippet', @@ -53,10 +64,6 @@ 'RespondentTokenSnippet', ); - public $exportSnippets = array('RespondentDetailsSnippet'); - - public $filterStandard = array('grc_success' => 1); - public $sortKey = array('gr2o_opened' => SORT_DESC); public $useTabbedForms = true; @@ -72,8 +79,9 @@ */ protected function addBrowseTableColumns(MUtil_Model_TableBridge $bridge, MUtil_Model_ModelAbstract $model) { + $this->grs_email = $bridge->getLazy('grs_email'); $model->setIfExists('gr2o_opened', 'tableDisplay', 'small'); - $model->setIfExists('grs_email', 'itemDisplay', 'MUtil_Html_AElement::ifmail'); + $model->setIfExists('grs_email', 'itemDisplay', array($this, 'ifmail')); if ($menuItem = $this->findAllowedMenuItem('show')) { $bridge->addItemLink($menuItem->toActionLinkLower($this->getRequest(), $bridge)); @@ -329,6 +337,43 @@ $this->html[] = $form; } + public function exportAction() + { + //First show the respondent snippet + $model = $this->getModel(); + $data = $model->applyRequest($this->getRequest(), true)->loadFirst(); + + if (! isset($data['grs_id_user'])) { + $this->addMessage(sprintf($this->_('Unknown %s requested'), $this->getTopic())); + $this->_reroute(array('action' => 'index')); + } + + $params['model'] = $model; + $params['baseUrl'] = array(MUtil_Model::REQUEST_ID1 => $this->_getParam(MUtil_Model::REQUEST_ID1), MUtil_Model::REQUEST_ID2 => $this->_getParam(MUtil_Model::REQUEST_ID2)); + $params['buttons'] = $this->createMenuLinks(); + $params['onclick'] = $this->findAllowedMenuItem('edit'); + if ($params['onclick']) { + $params['onclick'] = $params['onclick']->toHRefAttribute($this->getRequest()); + } + $params['respondentData'] = $data; + $this->addSnippets($this->exportSnippets, $params); + + //Now show the export form + $export = $this->loader->getRespondentExport($this); + $form = $export->getForm(); + $this->html->h2($this->_('Export respondent')); + $div = $this->html->div(array('id' => 'mainform')); + $div[] = $form; + + $request = $this->getRequest(); + + $form->populate($request->getParams()); + + if ($request->isPost()) { + $export->render((array) $data['gr2o_patient_nr'], $this->getRequest()->getParam('group'), $this->getRequest()->getParam('format')); + } + } + /** * Returns a text element for autosearch. Can be overruled. * @@ -426,6 +471,23 @@ } /** + * Helper function for preventing the marker value being mixed up in the output + * + * @param MUtil_Lazy_LazyAbstract $value + * @return MUtil_Html_AElement + */ + public function ifmail($value) + { + return MUtil_Lazy::iff($this->grs_email, + new MUtil_Html_AElement( + array('mailto:', $this->grs_email), + $value, + array('onclick' => 'event.cancelBubble=true;') + ) + ); + } + + /** * Overrule default index for the case that the current * organization cannot have users. */ @@ -505,41 +567,4 @@ $params['respondentData'] = $data; $this->addSnippets($this->showSnippets, $params); } - - public function exportAction() - { - //First show the respondent snippet - $model = $this->getModel(); - $data = $model->applyRequest($this->getRequest(), true)->loadFirst(); - - if (! isset($data['grs_id_user'])) { - $this->addMessage(sprintf($this->_('Unknown %s requested'), $this->getTopic())); - $this->_reroute(array('action' => 'index')); - } - - $params['model'] = $model; - $params['baseUrl'] = array(MUtil_Model::REQUEST_ID1 => $this->_getParam(MUtil_Model::REQUEST_ID1), MUtil_Model::REQUEST_ID2 => $this->_getParam(MUtil_Model::REQUEST_ID2)); - $params['buttons'] = $this->createMenuLinks(); - $params['onclick'] = $this->findAllowedMenuItem('edit'); - if ($params['onclick']) { - $params['onclick'] = $params['onclick']->toHRefAttribute($this->getRequest()); - } - $params['respondentData'] = $data; - $this->addSnippets($this->exportSnippets, $params); - - //Now show the export form - $export = $this->loader->getRespondentExport($this); - $form = $export->getForm(); - $this->html->h2($this->_('Export respondent')); - $div = $this->html->div(array('id' => 'mainform')); - $div[] = $form; - - $request = $this->getRequest(); - - $form->populate($request->getParams()); - - if ($request->isPost()) { - $export->render((array) $data['gr2o_patient_nr'], $this->getRequest()->getParam('group'), $this->getRequest()->getParam('format')); - } - } } Modified: trunk/library/classes/MUtil/Model/TableBridgeAbstract.php =================================================================== --- trunk/library/classes/MUtil/Model/TableBridgeAbstract.php 2012-11-22 12:13:14 UTC (rev 1034) +++ trunk/library/classes/MUtil/Model/TableBridgeAbstract.php 2012-11-22 13:21:02 UTC (rev 1035) @@ -192,6 +192,12 @@ return $name; } + /** + * Return the lazy value without any makeup. + * + * @param string $name + * @return MUtil_Lazy_LazyAbstract + */ public function getLazy($name) { if (! $this->repeater) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2012-12-20 10:57:27
|
Revision: 1069 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=1069&view=rev Author: matijsdejong Date: 2012-12-20 10:57:18 +0000 (Thu, 20 Dec 2012) Log Message: ----------- Started using MUtil/Db/Expr/CurrentTimestamp.php and MUtil/Translate/Translateable.php Modified Paths: -------------- trunk/library/classes/Gems/AccessLog.php trunk/library/classes/Gems/Default/RespondentAction.php trunk/library/classes/Gems/Email/Mailer.php trunk/library/classes/Gems/Email/TemplateMailer.php trunk/library/classes/Gems/Model/RespondentModel.php trunk/library/classes/Gems/Model.php trunk/library/classes/Gems/Tracker/Engine/TrackEngineAbstract.php trunk/library/classes/Gems/Tracker/RespondentTrack.php trunk/library/classes/Gems/Tracker/Source/LimeSurvey1m9Database.php trunk/library/classes/Gems/Tracker/Source/SourceAbstract.php trunk/library/classes/Gems/Tracker/Survey.php trunk/library/classes/Gems/Tracker/Token/TokenLibrary.php trunk/library/classes/Gems/Tracker/Token.php trunk/library/classes/Gems/User/DbUserDefinitionAbstract.php trunk/library/classes/Gems/User/OldStaffUserDefinition.php trunk/library/classes/Gems/User/Organization.php trunk/library/classes/Gems/User/User.php trunk/library/classes/Gems/User/UserLoader.php trunk/library/classes/Gems/Util/DatabasePatcher.php trunk/library/classes/MUtil/Snippets/SnippetAbstract.php Added Paths: ----------- trunk/library/classes/MUtil/Db/ trunk/library/classes/MUtil/Db/Expr/ trunk/library/classes/MUtil/Db/Expr/CurrentTimestamp.php Modified: trunk/library/classes/Gems/AccessLog.php =================================================================== --- trunk/library/classes/Gems/AccessLog.php 2012-12-17 12:46:11 UTC (rev 1068) +++ trunk/library/classes/Gems/AccessLog.php 2012-12-20 10:57:18 UTC (rev 1069) @@ -1,6 +1,5 @@ <?php - /** * Copyright (c) 2011, Erasmus MC * All rights reserved. @@ -125,7 +124,7 @@ * actions like the autofilter */ //$values['glac_log'] = !substr_count($action, '.autofilter'); - $values['glac_created'] = new Zend_Db_Expr('CURRENT_TIMESTAMP'); + $values['glac_created'] = new MUtil_Db_Expr_CurrentTimestamp(); $this->_db->insert('gems__log_actions', $values); @@ -192,7 +191,7 @@ $values['glua_organization'] = $this->_userInfo->user_organization_id ? $this->_userInfo->user_organization_id : 0; $values['glua_action'] = $this->getActionId($action); $values['glua_role'] = $this->_userInfo->user_role ? $this->_userInfo->user_role : '--not set--' ; - $values['glua_created'] = new Zend_Db_Expr('CURRENT_TIMESTAMP'); + $values['glua_created'] = new MUtil_Db_Expr_CurrentTimestamp(); if ($request instanceof Zend_Controller_Request_Http) { $values['glua_remote_ip'] = $request->getClientIp(); Modified: trunk/library/classes/Gems/Default/RespondentAction.php =================================================================== --- trunk/library/classes/Gems/Default/RespondentAction.php 2012-12-17 12:46:11 UTC (rev 1068) +++ trunk/library/classes/Gems/Default/RespondentAction.php 2012-12-20 10:57:18 UTC (rev 1069) @@ -284,7 +284,7 @@ // Perform actual save, but not simple stop codes. if ($code->isForRespondents()) { $values['gr2o_reception_code'] = $data['gr2o_reception_code']; - $values['gr2o_changed'] = new Zend_Db_Expr('CURRENT_TIMESTAMP'); + $values['gr2o_changed'] = new MUtil_Db_Expr_CurrentTimestamp(); $values['gr2o_changed_by'] = $userId; $where = 'gr2o_id_user = ? AND gr2o_id_organization = ?'; @@ -497,8 +497,8 @@ if ($patientId) { $where['gr2o_patient_nr = ?'] = $patientId; $where['gr2o_id_organization = ?'] = $orgId ? $orgId : $this->escort->getCurrentOrganization(); - $values['gr2o_opened'] = new Zend_Db_Expr('CURRENT_TIMESTAMP'); - $values['gr2o_opened_by'] = $this->session->user_id; + $values['gr2o_opened'] = new MUtil_Db_Expr_CurrentTimestamp(); + $values['gr2o_opened_by'] = $this->session->user_id; $this->db->update('gems__respondent2org', $values, $where); } Modified: trunk/library/classes/Gems/Email/Mailer.php =================================================================== --- trunk/library/classes/Gems/Email/Mailer.php 2012-12-17 12:46:11 UTC (rev 1068) +++ trunk/library/classes/Gems/Email/Mailer.php 2012-12-20 10:57:18 UTC (rev 1069) @@ -1,4 +1,5 @@ <?php + /** * Copyright (c) 2011, Erasmus MC * All rights reserved. @@ -166,7 +167,7 @@ { return $this->messages; } - + /** * Logs the communication if needed * @@ -177,7 +178,7 @@ protected function logCommunication($to = null, $from = null, $tokenData = array() ) { if (null === $this->_changeDate) { - $this->_changeDate = new Zend_Db_Expr('CURRENT_TIMESTAMP'); + $this->_changeDate = new MUtil_Db_Expr_CurrentTimestamp(); } $db = $this->escort->db; @@ -225,7 +226,7 @@ MUtil_Echo::r($from, $from_name); } - + // If bounce is active, the Gems_Mail will take care of resetting the to field if (!$this->bounceCheck()) { $validate = new Zend_Validate_EmailAddress(); @@ -236,7 +237,7 @@ } $mail = new Gems_Mail(); - + $mail->setFrom($from, $from_name); $mail->addTo($to, $to_name); if (isset($this->escort->project->email['bcc'])) { @@ -254,7 +255,7 @@ try { $mail->send($this->checkTransport($from)); $result = false; - + // communication successful, now log it $this->logCommunication($to, $from, $tokenData); Modified: trunk/library/classes/Gems/Email/TemplateMailer.php =================================================================== --- trunk/library/classes/Gems/Email/TemplateMailer.php 2012-12-17 12:46:11 UTC (rev 1068) +++ trunk/library/classes/Gems/Email/TemplateMailer.php 2012-12-20 10:57:18 UTC (rev 1069) @@ -518,7 +518,7 @@ protected function updateToken(array $tokenData, $to = null, $from = null) { if (null === $this->_changeDate) { - $this->_changeDate = new Zend_Db_Expr('CURRENT_TIMESTAMP'); + $this->_changeDate = new MUtil_Db_Expr_CurrentTimestamp(); } $db = $this->escort->db; Modified: trunk/library/classes/Gems/Model/RespondentModel.php =================================================================== --- trunk/library/classes/Gems/Model/RespondentModel.php 2012-12-17 12:46:11 UTC (rev 1068) +++ trunk/library/classes/Gems/Model/RespondentModel.php 2012-12-20 10:57:18 UTC (rev 1069) @@ -79,7 +79,7 @@ $this->setKeys($this->_getKeysFor('gems__respondent2org')); - $this->setOnSave('gr2o_opened', new Zend_Db_Expr('CURRENT_TIMESTAMP')); + $this->setOnSave('gr2o_opened', new MUtil_Db_Expr_CurrentTimestamp()); $this->setSaveOnChange('gr2o_opened'); $this->setOnSave('gr2o_opened_by', GemsEscort::getInstance()->session->user_id); $this->setSaveOnChange('gr2o_opened_by'); Modified: trunk/library/classes/Gems/Model.php =================================================================== --- trunk/library/classes/Gems/Model.php 2012-12-17 12:46:11 UTC (rev 1068) +++ trunk/library/classes/Gems/Model.php 2012-12-20 10:57:18 UTC (rev 1069) @@ -138,7 +138,7 @@ public function createGemsUserId($value, $isNew = false, $name = null, array $context = array()) { if ($isNew || (null === $value)) { - $creationTime = new Zend_Db_Expr('CURRENT_TIMESTAMP'); + $creationTime = new MUtil_Db_Expr_CurrentTimestamp(); do { $out = mt_rand(1, 9); @@ -288,9 +288,9 @@ $created_field = $prefix . '_created'; $created_by_field = $prefix . '_created_by'; - $model->setOnSave($changed_field, new Zend_Db_Expr('CURRENT_TIMESTAMP')); + $model->setOnSave($changed_field, new MUtil_Db_Expr_CurrentTimestamp()); $model->setSaveOnChange($changed_field); - $model->setOnSave($created_field, new Zend_Db_Expr('CURRENT_TIMESTAMP')); + $model->setOnSave($created_field, new MUtil_Db_Expr_CurrentTimestamp()); $model->setSaveWhenNew($created_field); if (! $userid) { Modified: trunk/library/classes/Gems/Tracker/Engine/TrackEngineAbstract.php =================================================================== --- trunk/library/classes/Gems/Tracker/Engine/TrackEngineAbstract.php 2012-12-17 12:46:11 UTC (rev 1068) +++ trunk/library/classes/Gems/Tracker/Engine/TrackEngineAbstract.php 2012-12-20 10:57:18 UTC (rev 1069) @@ -44,7 +44,7 @@ * @license New BSD License * @since Class available since version 1.4 */ -abstract class Gems_Tracker_Engine_TrackEngineAbstract extends MUtil_Registry_TargetAbstract implements Gems_Tracker_Engine_TrackEngineInterface +abstract class Gems_Tracker_Engine_TrackEngineAbstract extends MUtil_Translate_TranslateableAbstract implements Gems_Tracker_Engine_TrackEngineInterface { const FIELD_SEP = '|'; @@ -97,16 +97,8 @@ */ protected $tracker; - /** - * Set as this is a MUtil_Registry_TargetInterface * - * @var Zend_Translate $translate - */ - protected $translate; - - /** - * * @var Gems_Util */ protected $util; @@ -118,23 +110,7 @@ protected $view; /** - * Copy from Zend_Translate_Adapter * - * Translates the given string - * returns the translation - * - * @param string $text 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 _($text, $locale = null) - { - return $this->translate->getAdapter()->_($text, $locale); - } - - /** - * * @param array $trackData array containing track record */ public function __construct($trackData) @@ -237,7 +213,7 @@ } if (! isset($values['gto_changed'])) { - $values['gtr_changed'] = new Zend_Db_Expr('CURRENT_TIMESTAMP'); + $values['gtr_changed'] = new MUtil_Db_Expr_CurrentTimestamp(); } if (! isset($values['gtr_changed_by'])) { $values['gtr_changed_by'] = $userId; Modified: trunk/library/classes/Gems/Tracker/RespondentTrack.php =================================================================== --- trunk/library/classes/Gems/Tracker/RespondentTrack.php 2012-12-17 12:46:11 UTC (rev 1068) +++ trunk/library/classes/Gems/Tracker/RespondentTrack.php 2012-12-20 10:57:18 UTC (rev 1069) @@ -36,6 +36,7 @@ */ /** + * Object representing a track assignment to a respondent. * * @package Gems * @subpackage Tracker @@ -250,7 +251,7 @@ } if (! isset($values['gr2t_changed'])) { - $values['gr2t_changed'] = new Zend_Db_Expr('CURRENT_TIMESTAMP'); + $values['gr2t_changed'] = new MUtil_Db_Expr_CurrentTimestamp(); } if (! isset($values['gr2t_changed_by'])) { $values['gr2t_changed_by'] = $userId; @@ -413,7 +414,7 @@ if ($date instanceof MUtil_Date) { return $date; } - + if (Zend_Date::isDate($date, Gems_Tracker::DB_DATETIME_FORMAT)) { return new MUtil_Date($date, Gems_Tracker::DB_DATETIME_FORMAT); } Modified: trunk/library/classes/Gems/Tracker/Source/LimeSurvey1m9Database.php =================================================================== --- trunk/library/classes/Gems/Tracker/Source/LimeSurvey1m9Database.php 2012-12-17 12:46:11 UTC (rev 1068) +++ trunk/library/classes/Gems/Tracker/Source/LimeSurvey1m9Database.php 2012-12-20 10:57:18 UTC (rev 1069) @@ -36,7 +36,8 @@ */ /** - * Class description of LimeSurvey1m9Database + * LimeSurvey1m9Database is a Source interface that enables the use of LimeSurvey 1.9.x + * installation as survey/answer source for Gems projects. * * @package Gems * @subpackage Tracker @@ -347,7 +348,7 @@ $values['gso_active'] = $active ? 1 : 0; $values['gso_status'] = $active ? 'Active' : 'Inactive'; - $values['gso_last_synch'] = new Zend_Db_Expr('CURRENT_TIMESTAMP'); + $values['gso_last_synch'] = new MUtil_Db_Expr_CurrentTimestamp(); $this->_updateSource($values, $userId); @@ -1071,7 +1072,7 @@ $where = $lsDb->quoteInto("token = ?", $lsTokenId); $lsDb->update($lsTab, $answers, $where); } else { - $current = new Zend_Db_Expr('CURRENT_TIMESTAMP'); + $current = new MUtil_Db_Expr_CurrentTimestamp(); $answers['token'] = $lsTokenId; $answers['startlanguage'] = $this->locale->getLanguage(); Modified: trunk/library/classes/Gems/Tracker/Source/SourceAbstract.php =================================================================== --- trunk/library/classes/Gems/Tracker/Source/SourceAbstract.php 2012-12-17 12:46:11 UTC (rev 1068) +++ trunk/library/classes/Gems/Tracker/Source/SourceAbstract.php 2012-12-20 10:57:18 UTC (rev 1069) @@ -49,11 +49,11 @@ { /** * Holds the current batch if there is any - * + * * @var Gems_Task_TaskRunnerBatch */ protected $_batch = null; - + /** * The database connection to Gems itself * @@ -166,11 +166,11 @@ AND gsu_surveyor_id NOT IN (' . implode(', ', $surveyorSids) . ')'; // Fixed values - $data['gsu_active'] = 0; + $data['gsu_active'] = 0; $data['gsu_surveyor_active'] = 0; - $data['gsu_status'] = 'Survey was removed from source.'; - $data['gsu_changed'] = new Zend_Db_Expr('CURRENT_TIMESTAMP'); - $data['gsu_changed_by'] = $userId; + $data['gsu_status'] = 'Survey was removed from source.'; + $data['gsu_changed'] = new MUtil_Db_Expr_CurrentTimestamp(); + $data['gsu_changed_by'] = $userId; $this->_gemsDb->update('gems__surveys', $data, $sqlWhere); @@ -198,7 +198,7 @@ } if (! isset($values['gso_changed'])) { - $values['gso_changed'] = new Zend_Db_Expr('CURRENT_TIMESTAMP'); + $values['gso_changed'] = new MUtil_Db_Expr_CurrentTimestamp(); } if (! isset($values['gso_changed_by'])) { $values['gso_changed_by'] = $userId; Modified: trunk/library/classes/Gems/Tracker/Survey.php =================================================================== --- trunk/library/classes/Gems/Tracker/Survey.php 2012-12-17 12:46:11 UTC (rev 1068) +++ trunk/library/classes/Gems/Tracker/Survey.php 2012-12-20 10:57:18 UTC (rev 1069) @@ -36,7 +36,7 @@ */ /** - * Class description of Survey + * Object representing a specific Survey * * @package Gems * @subpackage Tracker @@ -151,7 +151,7 @@ } if (! isset($values['gsu_changed'])) { - $values['gsu_changed'] = new Zend_Db_Expr('CURRENT_TIMESTAMP'); + $values['gsu_changed'] = new MUtil_Db_Expr_CurrentTimestamp(); } if (! isset($values['gsu_changed_by'])) { $values['gsu_changed_by'] = $userId; @@ -166,7 +166,7 @@ } else { if (! isset($values['gsu_created'])) { - $values['gsu_created'] = new Zend_Db_Expr('CURRENT_TIMESTAMP'); + $values['gsu_created'] = new MUtil_Db_Expr_CurrentTimestamp(); } if (! isset($values['gsu_created_by'])) { $values['gsu_created_by'] = $userId; Modified: trunk/library/classes/Gems/Tracker/Token/TokenLibrary.php =================================================================== --- trunk/library/classes/Gems/Tracker/Token/TokenLibrary.php 2012-12-17 12:46:11 UTC (rev 1068) +++ trunk/library/classes/Gems/Tracker/Token/TokenLibrary.php 2012-12-20 10:57:18 UTC (rev 1069) @@ -36,7 +36,7 @@ */ /** - * Class description of TokenLibrary + * Utility functions for token string functions * * @package Gems * @subpackage Tracker @@ -127,7 +127,7 @@ */ public function createToken(array $tokenData, $userId) { - $current = new Zend_Db_Expr('CURRENT_TIMESTAMP'); + $current = new MUtil_Db_Expr_CurrentTimestamp(); $tokenData['gto_changed'] = $current; $tokenData['gto_changed_by'] = $userId; Modified: trunk/library/classes/Gems/Tracker/Token.php =================================================================== --- trunk/library/classes/Gems/Tracker/Token.php 2012-12-17 12:46:11 UTC (rev 1068) +++ trunk/library/classes/Gems/Tracker/Token.php 2012-12-20 10:57:18 UTC (rev 1069) @@ -36,7 +36,7 @@ */ /** - * Utility class for checking and changing tokens. + * Object class for checking and changing tokens. * * @package Gems * @subpackage Tracker @@ -232,7 +232,7 @@ } if (! isset($values['gto_changed'])) { - $values['gto_changed'] = new Zend_Db_Expr('CURRENT_TIMESTAMP'); + $values['gto_changed'] = new MUtil_Db_Expr_CurrentTimestamp(); } if (! isset($values['gto_changed_by'])) { $values['gto_changed_by'] = $userId; @@ -657,7 +657,7 @@ if ($this->_gemsData[$fieldName] instanceof MUtil_Date) { return $this->_gemsData[$fieldName]; } - + if (Zend_Date::isDate($this->_gemsData[$fieldName], Gems_Tracker::DB_DATETIME_FORMAT)) { return new MUtil_Date($this->_gemsData[$fieldName], Gems_Tracker::DB_DATETIME_FORMAT); } @@ -1157,7 +1157,7 @@ $survey->copyTokenToSource($this, $language); if (! $this->_gemsData['gto_in_source']) { - $values['gto_start_time'] = new Zend_Db_Expr('CURRENT_TIMESTAMP'); + $values['gto_start_time'] = new MUtil_Db_Expr_CurrentTimestamp(); $values['gto_in_source'] = 1; } $values['gto_by'] = $userId; Modified: trunk/library/classes/Gems/User/DbUserDefinitionAbstract.php =================================================================== --- trunk/library/classes/Gems/User/DbUserDefinitionAbstract.php 2012-12-17 12:46:11 UTC (rev 1068) +++ trunk/library/classes/Gems/User/DbUserDefinitionAbstract.php 2012-12-20 10:57:18 UTC (rev 1069) @@ -149,7 +149,7 @@ } else { $data['gup_reset_key'] = $this->hashPassword(time() . $user->getEmailAddress()); } - $data['gup_reset_requested'] = new Zend_Db_Expr('CURRENT_TIMESTAMP'); + $data['gup_reset_requested'] = new MUtil_Db_Expr_CurrentTimestamp(); // Loop for case when hash is not unique while (true) { Modified: trunk/library/classes/Gems/User/OldStaffUserDefinition.php =================================================================== --- trunk/library/classes/Gems/User/OldStaffUserDefinition.php 2012-12-17 12:46:11 UTC (rev 1068) +++ trunk/library/classes/Gems/User/OldStaffUserDefinition.php 2012-12-20 10:57:18 UTC (rev 1069) @@ -163,7 +163,7 @@ } else { $data['gsf_reset_key'] = $this->hashPassword(time() . $user->getEmailAddress()); } - $data['gsf_reset_req'] = new Zend_Db_Expr('CURRENT_TIMESTAMP'); + $data['gsf_reset_req'] = new MUtil_Db_Expr_CurrentTimestamp(); // Loop for case when hash is not unique while (true) { @@ -280,7 +280,7 @@ try { $user_id = $this->db->fetchOne($sql, array($user->getLoginName(), $user->getBaseOrganizationId())); - $currentTimestamp = new Zend_Db_Expr('CURRENT_TIMESTAMP'); + $currentTimestamp = new MUtil_Db_Expr_CurrentTimestamp(); // Move to USER_STAFF $values['gup_id_user'] = $user_id; Modified: trunk/library/classes/Gems/User/Organization.php =================================================================== --- trunk/library/classes/Gems/User/Organization.php 2012-12-17 12:46:11 UTC (rev 1068) +++ trunk/library/classes/Gems/User/Organization.php 2012-12-20 10:57:18 UTC (rev 1069) @@ -373,7 +373,7 @@ { if (! $this->_get('gor_has_respondents')) { $values['gor_has_respondents'] = 1; - $values['gor_changed'] = new Zend_Db_Expr('CURRENT_TIMESTAMP'); + $values['gor_changed'] = new MUtil_Db_Expr_CurrentTimestamp(); $values['gor_changed_by'] = $userId; $where = $this->db->quoteInto('gor_id_organization = ?', $this->_id); Modified: trunk/library/classes/Gems/User/User.php =================================================================== --- trunk/library/classes/Gems/User/User.php 2012-12-17 12:46:11 UTC (rev 1068) +++ trunk/library/classes/Gems/User/User.php 2012-12-20 10:57:18 UTC (rev 1069) @@ -300,7 +300,7 @@ } // Always record the last fail - $values['gula_last_failed'] = new Zend_Db_Expr('CURRENT_TIMESTAMP'); + $values['gula_last_failed'] = new MUtil_Db_Expr_CurrentTimestamp(); $values['gula_failed_logins'] = max(1, $values['gula_failed_logins']); // Response gets slowly slower Modified: trunk/library/classes/Gems/User/UserLoader.php =================================================================== --- trunk/library/classes/Gems/User/UserLoader.php 2012-12-17 12:46:11 UTC (rev 1068) +++ trunk/library/classes/Gems/User/UserLoader.php 2012-12-20 10:57:18 UTC (rev 1069) @@ -176,7 +176,7 @@ */ public function createUser($login_name, $organization, $userClassName, $userId) { - $now = new Zend_Db_Expr('CURRENT_TIMESTAMP'); + $now = new MUtil_Db_Expr_CurrentTimestamp();; $values['gul_user_class'] = $userClassName; $values['gul_can_login'] = 1; @@ -553,9 +553,9 @@ $values['gul_id_organization'] = $organization; $values['gul_user_class'] = self::USER_OLD_STAFF; // Old staff as password is still in gems__staff $values['gul_can_login'] = 1; - $values['gul_changed'] = new Zend_Db_Expr('CURRENT_TIMESTAMP'); + $values['gul_changed'] = new MUtil_Db_Expr_CurrentTimestamp(); $values['gul_changed_by'] = $user_id; - $values['gul_created'] = new Zend_Db_Expr('CURRENT_TIMESTAMP'); + $values['gul_created'] = $values['gul_changed']; $values['gul_created_by'] = $user_id; try { Modified: trunk/library/classes/Gems/Util/DatabasePatcher.php =================================================================== --- trunk/library/classes/Gems/Util/DatabasePatcher.php 2012-12-17 12:46:11 UTC (rev 1068) +++ trunk/library/classes/Gems/Util/DatabasePatcher.php 2012-12-20 10:57:18 UTC (rev 1069) @@ -157,7 +157,7 @@ $sql .= ' ORDER BY gpa_level, gpa_location, gpa_id_patch'; // MUtil_Echo::rs($ignoreCompleted, $ignoreExecuted, $sql); - $current = new Zend_Db_Expr('CURRENT_TIMESTAMP'); + $current = new MUtil_Db_Expr_CurrentTimestamp(); $executed = 0; $patches = $this->db->fetchAll($sql, $patchLevel); @@ -235,7 +235,7 @@ $tree = MUtil_Ra_Nested::toTree($existing, 'gpa_level', 'gpa_location', 'gpa_name', 'gpa_order'); $changed = 0; - $current = new Zend_Db_Expr('CURRENT_TIMESTAMP'); + $current = new MUtil_Db_Expr_CurrentTimestamp(); $minimum = $this->getMinimumPatchLevel(); // MUtil_Echo::track($minimum); Added: trunk/library/classes/MUtil/Db/Expr/CurrentTimestamp.php =================================================================== --- trunk/library/classes/MUtil/Db/Expr/CurrentTimestamp.php (rev 0) +++ trunk/library/classes/MUtil/Db/Expr/CurrentTimestamp.php 2012-12-20 10:57:18 UTC (rev 1069) @@ -0,0 +1,56 @@ +<?php + +/** + * Copyright (c) 2011, Erasmus MC + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Erasmus MC nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * + * @package MUtil + * @subpackage Db + * @author Matijs de Jong <mj...@ma...> + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @version $Id: CurrentTimestamp.php$ + */ + +/** + * Standard current timestamp expression + * + * @package MUtil + * @subpackage Db + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @since Class available since version 1.1.36 + */ +class MUtil_Db_Expr_CurrentTimestamp extends Zend_Db_Expr +{ + /** + * Instantiate teh current timestamp expression. + */ + public function __construct() + { + parent::__construct('CURRENT_TIMESTAMP'); + } +} Modified: trunk/library/classes/MUtil/Snippets/SnippetAbstract.php =================================================================== --- trunk/library/classes/MUtil/Snippets/SnippetAbstract.php 2012-12-17 12:46:11 UTC (rev 1068) +++ trunk/library/classes/MUtil/Snippets/SnippetAbstract.php 2012-12-20 10:57:18 UTC (rev 1069) @@ -52,7 +52,7 @@ * @license New BSD License * @since Class available since version 1.1 */ -abstract class MUtil_Snippets_SnippetAbstract extends MUtil_Registry_TargetAbstract implements MUtil_Snippets_SnippetInterface +abstract class MUtil_Snippets_SnippetAbstract extends MUtil_Translate_TranslateableAbstract implements MUtil_Snippets_SnippetInterface { /** * @@ -83,29 +83,6 @@ public $resetRoute = false; /** - * Set as this is a MUtil_Registry_TargetInterface - * - * @var Zend_Translate $translate - */ - protected $translate; - - /** - * Copy from Zend_Translate_Adapter - * - * Translates the given string - * returns the translation - * - * @param string $text 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 _($text, $locale = null) - { - return $this->translate->getAdapter()->_($text, $locale); - } - - /** * Adds one or more messages to the session based message store. * * @param mixed $message_args Can be an array or multiple argemuents. Each sub element is a single message string @@ -214,26 +191,6 @@ } /** - * Copy from Zend_Translate_Adapter - * - * 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) - { - $args = func_get_args(); - return call_user_func_array(array($this->translate->getAdapter(), 'plural'), $args); - } - - /** * When there is a redirectRoute this function will execute it. * * When hasHtmlOutput() is true this functions should not be called. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2013-01-16 12:56:29
|
Revision: 1107 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=1107&view=rev Author: matijsdejong Date: 2013-01-16 12:56:22 +0000 (Wed, 16 Jan 2013) Log Message: ----------- PluginLoader.php paths no longer have to reverse themselves for every load Snippets/SnippetLoader.php loads non-prefixed classes last Modified Paths: -------------- trunk/library/classes/Gems/Snippets/SnippetLoader.php trunk/library/classes/MUtil/Loader/PluginLoader.php Modified: trunk/library/classes/Gems/Snippets/SnippetLoader.php =================================================================== --- trunk/library/classes/Gems/Snippets/SnippetLoader.php 2013-01-16 12:34:42 UTC (rev 1106) +++ trunk/library/classes/Gems/Snippets/SnippetLoader.php 2013-01-16 12:56:22 UTC (rev 1107) @@ -72,13 +72,8 @@ GEMS_LIBRARY_DIR . '/snippets', GEMS_ROOT_DIR . '/application/snippets', ); - foreach ($noPrefixDirs as $dir) { - if (file_exists($dir)) { - $this->_loader->addPrefixPath('', $dir); - } - } - - // $this->_loader->addPrefixPath('MUtil_Snippets', GEMS_LIBRARY_DIR . '/classes/MUtil/Snippets/Standard'); + $this->_loader->addPrefixPath('', $noPrefixDirs, false); + // $this->_loader->addFallBackPath(); // Enable to allow full class name specification } /** Modified: trunk/library/classes/MUtil/Loader/PluginLoader.php =================================================================== --- trunk/library/classes/MUtil/Loader/PluginLoader.php 2013-01-16 12:34:42 UTC (rev 1106) +++ trunk/library/classes/MUtil/Loader/PluginLoader.php 2013-01-16 12:56:22 UTC (rev 1107) @@ -49,17 +49,14 @@ /** * Add the default autoloader to this plugin loader. * + * @param boolean $prepend Put path at the beginning of the stack, the default is false * @return Zend_Loader_PluginLoader (continuation pattern) */ - public function addFallBackPath() + public function addFallBackPath($prepend = false) { // Add each of the classpath directories to the prefixpaths // with an empty prefix. - foreach (Zend_Loader::explodeIncludePath() as $include) { - if ($real = realpath($include)) { - parent::addPrefixPath('', $real); - } - } + $this->addPrefixPath('', Zend_Loader::explodeIncludePath(), $prepend); return $this; } @@ -68,20 +65,72 @@ * Add prefixed paths to the registry of paths * * @param string $prefix - * @param string $path + * @param mixed $paths String or an array of strings + * @param boolean $prepend Put path at the beginning of the stack (has no effect when prefix / dir already set) * @return Zend_Loader_PluginLoader (continuation pattern) */ - public function addPrefixPath($prefix, $path) + public function addPrefixPath($prefix, $paths, $prepend = true) { - if (!is_string($prefix) || !is_string($path)) { + if (!is_string($prefix) || !(is_string($paths) || is_array($paths))) { throw new Zend_Loader_PluginLoader_Exception('Zend_Loader_PluginLoader::addPrefixPath() method only takes strings for prefix and path.'); } - // MUtil_Echo::track(self::getAbsolutePaths($path)); - foreach (self::getAbsolutePaths($path) as $sub) { - parent::addPrefixPath($prefix, $sub); + $prefix = $this->_formatPrefix($prefix); + if ($this->_useStaticRegistry) { + $registry = self::$_staticPrefixToPaths[$this->_useStaticRegistry]; + } else { + $registry = $this->_prefixToPaths; } + if (isset($registry[$prefix])) { + $newPaths = $registry[$prefix]; + } else { + $newPaths = array(); + } + + $changed = false; + foreach ((array) $paths as $path) { + $path = rtrim($path, '/\\') . '/'; + + // MUtil_Echo::track(self::getAbsolutePaths($path)); + foreach (self::getAbsolutePaths($path) as $sub) { + if (! in_array($sub, $newPaths)) { + if ($prepend) { + array_unshift($newPaths, $sub . DIRECTORY_SEPARATOR); + } else { + array_push($newPaths, $sub . DIRECTORY_SEPARATOR); + } + $changed = true; + } + } + } + + if ($changed) { + if ($this->_useStaticRegistry) { + if ($prepend && !isset(self::$_staticPrefixToPaths[$this->_useStaticRegistry][$prefix])) { + self::$_staticPrefixToPaths[$this->_useStaticRegistry] = + array($prefix => $newPaths) + + self::$_staticPrefixToPaths[$this->_useStaticRegistry]; + } else { + self::$_staticPrefixToPaths[$this->_useStaticRegistry][$prefix] = $newPaths; + } + } else { + if ($prepend && !isset($this->_prefixToPaths[$prefix])) { + $this->_prefixToPaths = + array($prefix => $newPaths) + + $this->_prefixToPaths; + } else { + $this->_prefixToPaths[$prefix] = $newPaths; + } + } + } + /* + if (isset($this->_prefixToPaths[$prefix])) { + MUtil_Echo::track($prefix, $this->_prefixToPaths); + } else { + MUtil_Echo::track($prefix); + } // */ + return $this; } @@ -208,7 +257,7 @@ // Check simple concatenation foreach ($includePaths as $include) { if ($real = realpath($include . $path)) { - $results[] = $real;; + $results[] = $real; } } @@ -217,6 +266,18 @@ } /** + * Get path stack + * + * @param string $prefix + * @return false|array False if prefix does not exist, array otherwise + */ + public function getPaths($prefix = null) + { + // To return the same result as in the past. + return array_reverse(parent::getPaths($prefix)); + } + + /** * Do a quick check for a path being absolute (may not work for some exotic absolute paths though) * * @param string $path @@ -265,7 +326,6 @@ $registry = $this->_prefixToPaths; } - $registry = array_reverse($registry, true); $found = false; $classFile = str_replace('_', DIRECTORY_SEPARATOR, $name) . '.php'; $incFile = self::getIncludeFileCache(); @@ -277,8 +337,6 @@ break; } - $paths = array_reverse($paths, true); - foreach ($paths as $path) { $loadFile = $path . $classFile; // Can use file_exist now, as any paths in the class path that This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2013-01-22 18:30:32
|
Revision: 1120 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=1120&view=rev Author: matijsdejong Date: 2013-01-22 18:30:24 +0000 (Tue, 22 Jan 2013) Log Message: ----------- Extended transformer interface for transformFilter Moved _checkFilterUsed and _checkSortUsed to the initial input functions from the later processing functions Modified Paths: -------------- trunk/library/classes/Gems/Export/ExportModel.php trunk/library/classes/Gems/Model/DbaModel.php trunk/library/classes/Gems/Tracker/SurveyModel.php trunk/library/classes/Gems/Util/TrackData.php trunk/library/classes/MUtil/Model/DatabaseModelAbstract.php trunk/library/classes/MUtil/Model/ModelAbstract.php trunk/library/classes/MUtil/Model/ModelTransformerAbstract.php trunk/library/classes/MUtil/Model/ModelTransformerInterface.php trunk/library/classes/MUtil/Model/Transform/JoinTransformer.php Modified: trunk/library/classes/Gems/Export/ExportModel.php =================================================================== --- trunk/library/classes/Gems/Export/ExportModel.php 2013-01-21 16:38:54 UTC (rev 1119) +++ trunk/library/classes/Gems/Export/ExportModel.php 2013-01-22 18:30:24 UTC (rev 1120) @@ -57,11 +57,11 @@ /** * Returns a nested array containing the items requested. * - * @param mixed $filter True to use the stored filter, array to specify a different filter - * @param mixed $sort True to use the stored sort, array to specify a different sort + * @param array $filter Filter array, num keys contain fixed expresions, text keys are equal or one of filters + * @param array $sort Sort array field name => sort type * @return array Nested array or false */ - protected function _load($filter = true, $sort = true) + protected function _load(array $filter, array $sort) { $result = array(); foreach ($this->getItemsOrdered() as $item) { Modified: trunk/library/classes/Gems/Model/DbaModel.php =================================================================== --- trunk/library/classes/Gems/Model/DbaModel.php 2013-01-21 16:38:54 UTC (rev 1119) +++ trunk/library/classes/Gems/Model/DbaModel.php 2013-01-22 18:30:24 UTC (rev 1120) @@ -147,20 +147,20 @@ /** * Returns a nested array containing the items requested. * - * @param mixed $filter True to use the stored filter, array to specify a different filter - * @param mixed $sort True to use the stored sort, array to specify a different sort + * @param array $filter Filter array, num keys contain fixed expresions, text keys are equal or one of filters + * @param array $sort Sort array field name => sort type * @return array Nested array or false */ - protected function _load($filter = true, $sort = true) + protected function _load(array $filter, array $sort) { $data = $this->_loadAllData(); if ($filter) { - $data = $this->_filterData($data, $this->_checkFilterUsed($filter)); + $data = $this->_filterData($data, $filter); } if ($sort) { - $data = $this->_sortData($data, $this->_checkSortUsed($sort)); + $data = $this->_sortData($data, $sort); } return $data; Modified: trunk/library/classes/Gems/Tracker/SurveyModel.php =================================================================== --- trunk/library/classes/Gems/Tracker/SurveyModel.php 2013-01-21 16:38:54 UTC (rev 1119) +++ trunk/library/classes/Gems/Tracker/SurveyModel.php 2013-01-22 18:30:24 UTC (rev 1120) @@ -87,11 +87,11 @@ /** * Returns a nested array containing the items requested. * - * @param mixed $filter True to use the stored filter, array to specify a different filter - * @param mixed $sort True to use the stored sort, array to specify a different sort + * @param array $filter Filter array, num keys contain fixed expresions, text keys are equal or one of filters + * @param array $sort Sort array field name => sort type * @return array Nested array or false */ - protected function _load($filter = true, $sort = true) + protected function _load(array $filter, array $sort) { return $this->addAnswers(parent::_load($filter, $sort)); } Modified: trunk/library/classes/Gems/Util/TrackData.php =================================================================== --- trunk/library/classes/Gems/Util/TrackData.php 2013-01-21 16:38:54 UTC (rev 1119) +++ trunk/library/classes/Gems/Util/TrackData.php 2013-01-22 18:30:24 UTC (rev 1120) @@ -48,6 +48,12 @@ { /** * + * @var Zend_Cache_Core + */ + protected $cache; + + /** + * * @var Zend_Db_Adapter_Abstract */ protected $db; Modified: trunk/library/classes/MUtil/Model/DatabaseModelAbstract.php =================================================================== --- trunk/library/classes/MUtil/Model/DatabaseModelAbstract.php 2013-01-21 16:38:54 UTC (rev 1119) +++ trunk/library/classes/MUtil/Model/DatabaseModelAbstract.php 2013-01-22 18:30:24 UTC (rev 1120) @@ -120,11 +120,11 @@ /** * Get a select statement using a filter and sort * - * @param array $filter - * @param array $sort + * @param array $filter Filter array, num keys contain fixed expresions, text keys are equal or one of filters + * @param array $sort Sort array field name => sort type * @return Zend_Db_Table_Select */ - protected function _createSelect($filter = null, $sort = null) + protected function _createSelect(array $filter, array $sort) { $select = $this->getSelect(); @@ -154,7 +154,7 @@ $adapter = $this->getAdapter(); // Filter - foreach ($this->_checkFilterUsed($filter) as $name => $value) { + foreach ($filter as $name => $value) { if (is_int($name)) { $select->where($value); } else { @@ -183,43 +183,41 @@ } // Sort - if ($sort = $this->_checkSortUsed($sort)) { - foreach ($sort as $key => $order) { - if (is_numeric($key) || is_string($order)) { - if ($this->has($order)) { - $sqlsort[] = $order; - } - } else { - // Code not needed at least for MySQL, a named calculated column can be used in - // an ORDER BY. However, it does work. - /* - if ($expression = $this->get($key, 'column_expression')) { - //The brackets tell Zend_Db_Select that this is an epression in a sort. - $key = '(' . $expression . ')'; - } // */ - switch ($order) { - case SORT_ASC: - if ($this->has($key)) { - $sqlsort[] = $key . ' ASC'; - } - break; - case SORT_DESC: - if ($this->has($key)) { - $sqlsort[] = $key . ' DESC'; - } - break; - default: - if ($this->has($order)) { - $sqlsort[] = $order; - } - break; - } + foreach ($sort as $key => $order) { + if (is_numeric($key) || is_string($order)) { + if ($this->has($order)) { + $sqlsort[] = $order; } + } else { + // Code not needed at least for MySQL, a named calculated column can be used in + // an ORDER BY. However, it does work. + /* + if ($expression = $this->get($key, 'column_expression')) { + //The brackets tell Zend_Db_Select that this is an epression in a sort. + $key = '(' . $expression . ')'; + } // */ + switch ($order) { + case SORT_ASC: + if ($this->has($key)) { + $sqlsort[] = $key . ' ASC'; + } + break; + case SORT_DESC: + if ($this->has($key)) { + $sqlsort[] = $key . ' DESC'; + } + break; + default: + if ($this->has($order)) { + $sqlsort[] = $order; + } + break; + } } + } - if (isset($sqlsort)) { - $select->order($sqlsort); - } + if (isset($sqlsort)) { + $select->order($sqlsort); } if (MUtil_Model::$verbose) { @@ -319,11 +317,11 @@ /** * Returns a nested array containing the items requested. * - * @param mixed $filter True to use the stored filter, array to specify a different filter - * @param mixed $sort True to use the stored sort, array to specify a different sort + * @param array $filter Filter array, num keys contain fixed expresions, text keys are equal or one of filters + * @param array $sort Sort array field name => sort type * @return array Nested array or false */ - protected function _load($filter = true, $sort = true) + protected function _load(array $filter, array $sort) { return $this->_createSelect($filter, $sort)->query(Zend_Db::FETCH_ASSOC)->fetchAll(); } @@ -331,11 +329,11 @@ /** * Returns an array containing the first requested item. * - * @param mixed $filter True to use the stored filter, array to specify a different filter - * @param mixed $sort True to use the stored sort, array to specify a different sort - * @return array An array or false + * @param array $filter Filter array, num keys contain fixed expresions, text keys are equal or one of filters + * @param array $sort Sort array field name => sort type + * @return array Nested array or false */ - protected function _loadFirst($filter = true, $sort = true) + protected function _loadFirst(array $filter, array $sort) { $select = $this->_createSelect($filter, $sort); $select->limit(1, 0); @@ -930,7 +928,10 @@ */ public function loadPaginator($filter = true, $sort = true) { - $select = $this->_createSelect($filter, $sort); + $select = $this->_createSelect( + $this->_checkFilterUsed($filter), + $this->_checkSortUsed($sort) + ); $adapter = new MUtil_Model_SelectModelPaginator($select, $this); return new Zend_Paginator($adapter); Modified: trunk/library/classes/MUtil/Model/ModelAbstract.php =================================================================== --- trunk/library/classes/MUtil/Model/ModelAbstract.php 2013-01-21 16:38:54 UTC (rev 1119) +++ trunk/library/classes/MUtil/Model/ModelAbstract.php 2013-01-22 18:30:24 UTC (rev 1120) @@ -144,6 +144,9 @@ $filter = $this->getFilter(); } if ($filter && is_array($filter)) { + foreach ($this->_transformers as $transformer) { + $filter = $transformer->transformFilter($this, $filter); + } if ($this->hasTextSearchFilter() && ($param = $this->getTextFilter())) { if (isset($filter[$param])) { @@ -271,20 +274,20 @@ /** * Returns a nested array containing the items requested. * - * @param mixed $filter True to use the stored filter, array to specify a different filter - * @param mixed $sort True to use the stored sort, array to specify a different sort + * @param array $filter Filter array, num keys contain fixed expresions, text keys are equal or one of filters + * @param array $sort Sort array field name => sort type * @return array Nested array or false */ - abstract protected function _load($filter = true, $sort = true); + abstract protected function _load(array $filter, array $sort); /** * Returns a nested array containing the items requested. * - * @param mixed $filter True to use the stored filter, array to specify a different filter - * @param mixed $sort True to use the stored sort, array to specify a different sort + * @param array $filter Filter array, num keys contain fixed expresions, text keys are equal or one of filters + * @param array $sort Sort array field name => sort type * @return array Nested array or false */ - protected function _loadFirst($filter = true, $sort = true) + protected function _loadFirst(array $filter, array $sort) { $data = $this->_load($filter, $sort); @@ -1048,7 +1051,10 @@ */ public function load($filter = true, $sort = true) { - $data = $this->_load($filter, $sort); + $data = $this->_load( + $this->_checkFilterUsed($filter), + $this->_checkSortUsed($sort) + ); if (is_array($data)) { $data = $this->processAfterLoad($data); @@ -1066,7 +1072,10 @@ */ public function loadFirst($filter = true, $sort = true) { - $row = $this->_loadFirst($filter, $sort); + $row = $this->_loadFirst( + $this->_checkFilterUsed($filter), + $this->_checkSortUsed($sort) + ); // MUtil_Echo::track($row); if (! is_array($row)) { Modified: trunk/library/classes/MUtil/Model/ModelTransformerAbstract.php =================================================================== --- trunk/library/classes/MUtil/Model/ModelTransformerAbstract.php 2013-01-21 16:38:54 UTC (rev 1119) +++ trunk/library/classes/MUtil/Model/ModelTransformerAbstract.php 2013-01-22 18:30:24 UTC (rev 1120) @@ -154,6 +154,21 @@ } /** + * This transform function checks the filter for + * a) retreiving filters to be applied to the transforming data, + * b) adding filters that are the result + * + * @param MUtil_Model_ModelAbstract $model + * @param array $filter + * @return array The (optionally changed) filter + */ + public function transformFilter(MUtil_Model_ModelAbstract $model, array $filter) + { + // No changes + return $filter; + } + + /** * The transform function performs the actual transformation of the data and is called after * the loading of the data in the source model. * Modified: trunk/library/classes/MUtil/Model/ModelTransformerInterface.php =================================================================== --- trunk/library/classes/MUtil/Model/ModelTransformerInterface.php 2013-01-21 16:38:54 UTC (rev 1119) +++ trunk/library/classes/MUtil/Model/ModelTransformerInterface.php 2013-01-22 18:30:24 UTC (rev 1120) @@ -58,6 +58,17 @@ public function getFieldInfo(MUtil_Model_ModelAbstract $model); /** + * This transform function checks the filter for + * a) retreiving filters to be applied to the transforming data, + * b) adding filters that are the result + * + * @param MUtil_Model_ModelAbstract $model + * @param array $filter + * @return array The (optionally changed) filter + */ + public function transformFilter(MUtil_Model_ModelAbstract $model, array $filter); + + /** * The transform function performs the actual transformation of the data and is called after * the loading of the data in the source model. * Modified: trunk/library/classes/MUtil/Model/Transform/JoinTransformer.php =================================================================== --- trunk/library/classes/MUtil/Model/Transform/JoinTransformer.php 2013-01-21 16:38:54 UTC (rev 1119) +++ trunk/library/classes/MUtil/Model/Transform/JoinTransformer.php 2013-01-22 18:30:24 UTC (rev 1120) @@ -61,14 +61,12 @@ public function addModel(MUtil_Model_ModelAbstract $subModel, array $joinFields) { + // MUtil_Model::$verbose = true; + $name = $subModel->getName(); $this->_subModels[$name] = $subModel; $this->_joins[$name] = $joinFields; - if (count($joinFields) > 1) { - throw new MUtil_Model_ModelException(__CLASS__ . " currently accepts single field joins only."); - } - return $this; } @@ -88,6 +86,9 @@ foreach ($sub->getItemNames() as $name) { if (! $model->has($name)) { $data[$name] = $sub->get($name); + + // Remove unsuited data + unset($data[$name]['table'], $data[$name]['column_expression']); } } } @@ -95,6 +96,29 @@ } /** + * This transform function checks the filter for + * a) retreiving filters to be applied to the transforming data, + * b) adding filters that are the result + * + * @param MUtil_Model_ModelAbstract $model + * @param array $filter + * @return array The (optionally changed) filter + */ + public function transformFilter(MUtil_Model_ModelAbstract $model, array $filter) + { + // Make sure the join fields are in the result set/ + foreach ($this->_joins as $joins) { + foreach ($joins as $source => $target) { + if (!is_integer($source)) { + $model->get($source); + } + } + } + + return $filter; + } + + /** * The transform function performs the actual transformation of the data and is called after * the loading of the data in the source model. * @@ -122,17 +146,45 @@ $sdata = $sub->load(array($skey => $mfor)); // MUtil_Echo::track($sdata); - $skeys = array_flip(MUtil_Ra::column($skey, $sdata)); - $empty = array_fill_keys(array_keys(reset($sdata)), null); + if ($sdata) { + $skeys = array_flip(MUtil_Ra::column($skey, $sdata)); + $empty = array_fill_keys(array_keys(reset($sdata)), null); + foreach ($data as &$mrow) { + $mfind = $mrow[$mkey]; + + if (isset($skeys[$mfind])) { + $mrow += $sdata[$skeys[$mfind]]; + } else { + $mrow += $empty; + } + } + } else { + $empty = array_fill_keys($sub->getItemNames(), null); + + foreach ($data as &$mrow) { + $mrow += $empty; + } + } + } else { + $empty = array_fill_keys($sub->getItemNames(), null); foreach ($data as &$mrow) { - $mfind = $mrow[$mkey]; + $filter = $sub->getFilter(); + foreach ($this->_joins[$name] as $from => $to) { + if (isset($mrow[$from])) { + $filter[$to] = $mrow[$from]; + } + } - if (isset($skeys[$mfind])) { - $mrow += $sdata[$skeys[$mfind]]; + $sdata = $sub->loadFirst($filter); + + if ($sdata) { + $mrow += $sdata; } else { $mrow += $empty; } + + // MUtil_Echo::track($sdata, $mrow); } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gem...@li...> - 2013-03-14 08:42:57
|
Revision: 1178 http://sourceforge.net/p/gemstracker/code/1178 Author: mennodekker Date: 2013-03-14 08:42:54 +0000 (Thu, 14 Mar 2013) Log Message: ----------- Hidden elements should go into the subform so they are available for validation Modified Paths: -------------- trunk/library/classes/Gems/Snippets/ModelTabFormSnippetGeneric.php trunk/library/classes/Gems/TabForm.php trunk/library/classes/MUtil/Validate/Db/UniqueValue.php Modified: trunk/library/classes/Gems/Snippets/ModelTabFormSnippetGeneric.php =================================================================== --- trunk/library/classes/Gems/Snippets/ModelTabFormSnippetGeneric.php 2013-03-13 16:12:06 UTC (rev 1177) +++ trunk/library/classes/Gems/Snippets/ModelTabFormSnippetGeneric.php 2013-03-14 08:42:54 UTC (rev 1178) @@ -153,8 +153,12 @@ $form->addElement($element); $element->removeDecorator('HtmlTag'); $element->removeDecorator('Label'); - $form->addDisplayGroup(array('formLinks'), 'form_buttons'); - $form->getDisplayGroup(Gems_TabForm::GROUP_OTHER)->removeElement($element->getName()); + + if (is_null($form->getDisplayGroup(Gems_TabForm::GROUP_OTHER))) { + $form->addDisplayGroup(array($element), Gems_TabForm::GROUP_OTHER); + } else { + $form->getDisplayGroup(Gems_TabForm::GROUP_OTHER)->addElement($element); + } } } Modified: trunk/library/classes/Gems/TabForm.php =================================================================== --- trunk/library/classes/Gems/TabForm.php 2013-03-13 16:12:06 UTC (rev 1177) +++ trunk/library/classes/Gems/TabForm.php 2013-03-14 08:42:54 UTC (rev 1178) @@ -102,27 +102,13 @@ */ public function addElement($element, $name = null, $options = null) { - if ($element instanceof Zend_Form_Element_Hidden) { - parent::addElement($element, $name, $options); - - //Remove decorators - $element->removeDecorator('HtmlTag'); - $element->removeDecorator('Label'); - - $this->addToOtherGroup($element); - - $element->removeDecorator('DtDdWrapper'); - - return $this; - } - if ($this->currentTab) { return $this->currentTab->addElement($element, $name, $options); } else { parent::addElement($element, $name, $options); if (is_string($element)) { - $element = $this->getElement($element); + $element = $this->getElement($name); } $this->addToOtherGroup($element); Modified: trunk/library/classes/MUtil/Validate/Db/UniqueValue.php =================================================================== --- trunk/library/classes/MUtil/Validate/Db/UniqueValue.php 2013-03-13 16:12:06 UTC (rev 1177) +++ trunk/library/classes/MUtil/Validate/Db/UniqueValue.php 2013-03-14 08:42:54 UTC (rev 1178) @@ -108,8 +108,7 @@ public function isValid($value, $context = array()) { - // Quick fix for context not being complete in subform - $context = $context + $_POST; + $context = $context; /** * Check for an adapter being defined. if not, fetch the default adapter. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |