From: <gem...@li...> - 2011-10-27 16:21:56
|
Revision: 151 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=151&view=rev Author: matijsdejong Date: 2011-10-27 16:21:42 +0000 (Thu, 27 Oct 2011) Log Message: ----------- First step for #31: login info moved from gems__staff to gems__users.10.sql Temp fix for moving to new password situation while retaining the older versions. DeleteValues moved up to DatabaseModelAbstract. setModelParameters() added to menu for 2 parameter menu items. Modified Paths: -------------- trunk/library/changelog.txt trunk/library/classes/Gems/Auth.php trunk/library/classes/Gems/Cookies.php trunk/library/classes/Gems/Default/CronAction.php trunk/library/classes/Gems/Default/IndexAction.php trunk/library/classes/Gems/Default/OptionAction.php trunk/library/classes/Gems/Default/RespondentAction.php trunk/library/classes/Gems/Default/StaffAction.php trunk/library/classes/Gems/Default/TokenPlanAction.php trunk/library/classes/Gems/Loader/LoaderAbstract.php trunk/library/classes/Gems/Loader.php trunk/library/classes/Gems/Menu/MenuAbstract.php trunk/library/classes/Gems/Menu/SubMenuItem.php trunk/library/classes/Gems/Util/DbLookup.php trunk/library/classes/Gems/Validate/GemsPasswordUsername.php trunk/library/classes/GemsEscort.php trunk/library/classes/MUtil/Model/DatabaseModelAbstract.php trunk/library/classes/MUtil/Model/JoinModel.php trunk/library/classes/MUtil/Model/ModelAbstract.php trunk/library/classes/MUtil/Model/TableBridgeAbstract.php trunk/library/classes/MUtil/Model/TableModel.php trunk/library/configs/db/patches.sql trunk/library/configs/db/tables/gems__staff.20.sql trunk/library/controllers/StaffController.php trunk/library/languages/default-nl.mo trunk/library/languages/default-nl.po Added Paths: ----------- trunk/library/classes/Gems/Model/UserModel.php trunk/library/classes/Gems/User/ trunk/library/classes/Gems/User/DatabaseUserAbstract.php trunk/library/classes/Gems/User/NoLoginUser.php trunk/library/classes/Gems/User/ProjectSuperUser.php trunk/library/classes/Gems/User/RespondentUser.php trunk/library/classes/Gems/User/StaffUser.php trunk/library/classes/Gems/User/UserAbstract.php trunk/library/classes/Gems/User/UserInterface.php trunk/library/classes/Gems/User/UserLoader.php trunk/library/configs/db/tables/gems__users.10.sql Removed Paths: ------------- trunk/library/classes/Gems/User/DatabaseUserAbstract.php trunk/library/classes/Gems/User/NoLoginUser.php trunk/library/classes/Gems/User/ProjectSuperUser.php trunk/library/classes/Gems/User/RespondentUser.php trunk/library/classes/Gems/User/StaffUser.php trunk/library/classes/Gems/User/UserAbstract.php trunk/library/classes/Gems/User/UserInterface.php trunk/library/classes/Gems/User/UserLoader.php Property Changed: ---------------- trunk/library/ Property changes on: trunk/library ___________________________________________________________________ Added: svn:mergeinfo + /branches/newUser:113-150 Modified: trunk/library/changelog.txt =================================================================== --- trunk/library/changelog.txt 2011-10-27 15:55:57 UTC (rev 150) +++ trunk/library/changelog.txt 2011-10-27 16:21:42 UTC (rev 151) @@ -1,5 +1,7 @@ Important changes from 1.4.3 => 1.5 ============================================================ +The table gems__staff is split into gems__staff and gems__user with all login data in gems__users +Passwords should be set with a project.ini->salt MailController is now called MailTemplateController EmailController is now called CronController (with stub for compatibility) Modified: trunk/library/classes/Gems/Auth.php =================================================================== --- trunk/library/classes/Gems/Auth.php 2011-10-27 15:55:57 UTC (rev 150) +++ trunk/library/classes/Gems/Auth.php 2011-10-27 16:21:42 UTC (rev 151) @@ -98,8 +98,8 @@ * Lookup last failed login and number of failed logins */ try { - $sql = "SELECT gsf_failed_logins, UNIX_TIMESTAMP(gsf_last_failed) - AS gsf_last_failed FROM gems__staff WHERE gsf_login = ?"; + $sql = "SELECT gsu_failed_logins, UNIX_TIMESTAMP(gsu_last_failed) + AS gsu_last_failed FROM gems__users WHERE gsu_login = ?"; $results = $this->db->fetchRow($sql, array($username)); } catch (Zend_Db_Exception $zde) { //If we need to apply a db patch, just use a default value @@ -107,10 +107,10 @@ MUtil_Echo::r(GemsEscort::getInstance()->translate->_('Please update the database')); } - $delay = pow($results['gsf_failed_logins'], $this->_delayFactor); - $remaining = ($results['gsf_last_failed'] + $delay) - time(); + $delay = pow($results['gsu_failed_logins'], $this->_delayFactor); + $remaining = ($results['gsu_last_failed'] + $delay) - time(); - if ($results['gsf_failed_logins'] > 0 && $remaining > 0) { + if ($results['gsu_failed_logins'] > 0 && $remaining > 0) { //$this->_obscureValue = false; $result = $this->_error(self::ERROR_PASSWORD_DELAY, ceil($remaining / 60)); } Modified: trunk/library/classes/Gems/Cookies.php =================================================================== --- trunk/library/classes/Gems/Cookies.php 2011-10-27 15:55:57 UTC (rev 150) +++ trunk/library/classes/Gems/Cookies.php 2011-10-27 16:21:42 UTC (rev 151) @@ -1,63 +1,86 @@ <?php - -/** - * Copyright (c) 2011, Erasmus MC - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of Erasmus MC nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * @author Matijs de Jong - * @since 1.0 - * @version $Id$ + +/** + * Copyright (c) 2011, Erasmus MC + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Erasmus MC nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * * @package Gems * @subpackage Cookies + * @author Matijs de Jong <mj...@ma...> * @copyright Copyright (c) 2011 Erasmus MC * @license New BSD License + * @version $Id$ */ /** * Static Gems cookie utilities - * - * @author Matijs de Jong + * * @package Gems * @subpackage Cookies * @copyright Copyright (c) 2011 Erasmus MC * @license New BSD License + * @since Class available since version 1.0 */ class Gems_Cookies { const LOCALE_COOKIE = 'gems_locale'; - public static function get(Zend_Controller_Request_Abstract $request, $name) + /** + * Get a specific cookie from the request. + * + * @param Zend_Controller_Request_Abstract $request + * @param string $name + * @param mixed $default + * @return mixed Cookie value + */ + public static function get(Zend_Controller_Request_Abstract $request, $name, $default = null) { - return $request->getCookie($name); + return $request->getCookie($name, $default); } + /** + * Get the current locale from the cookie. + * + * @param Zend_Controller_Request_Abstract $request + * @return string The current locale + */ public static function getLocale(Zend_Controller_Request_Abstract $request) { return self::get($request, self::LOCALE_COOKIE); } + /** + * Store this cookie in a generic save method that works for both sub-directory + * installations and own url installations. + * + * @param string $name Name of the cookie + * @param mixed $value Value to set + * @param int $days Number of days to keep this cookie + * @param string $basepath The folder of the domain, if any. + * @return boolean True if the cookie was stored. + */ public static function set($name, $value, $days = 30, $basepath = '/') { // Gems uses the empty string when the base path is '/' @@ -69,6 +92,13 @@ return setcookie($name, $value, time() + ($days * 86400), $basepath); } + /** + * Store the locale in a cookie. + * + * @param string $locale Locale to store + * @param string $basepath The folder of the domain, if any. + * @return boolean True if the cookie was stored. + */ public static function setLocale($locale, $basepath = '/') { // Set the cookie for 30 days Modified: trunk/library/classes/Gems/Default/CronAction.php =================================================================== --- trunk/library/classes/Gems/Default/CronAction.php 2011-10-27 15:55:57 UTC (rev 150) +++ trunk/library/classes/Gems/Default/CronAction.php 2011-10-27 16:21:42 UTC (rev 151) @@ -125,7 +125,7 @@ */ protected function getUserLogin($userId) { - return $this->db->fetchOne("SELECT gsf_login FROM gems__staff WHERE gsf_id_user = ?", $userId); + return $this->db->fetchOne("SELECT gsu_login FROM gems__users WHERE gsu_id_user = ?", $userId); } public function indexAction() Modified: trunk/library/classes/Gems/Default/IndexAction.php =================================================================== --- trunk/library/classes/Gems/Default/IndexAction.php 2011-10-27 15:55:57 UTC (rev 150) +++ trunk/library/classes/Gems/Default/IndexAction.php 2011-10-27 16:21:42 UTC (rev 151) @@ -74,7 +74,7 @@ * @return Zend_Auth_Adapter_Interface */ protected function _getAuthAdapter($formValues) { - $adapter = new Zend_Auth_Adapter_DbTable($this->db, 'gems__staff', 'gsf_login', 'gsf_password'); + $adapter = new Zend_Auth_Adapter_DbTable($this->db, 'gems__users', 'gsu_login', 'gsu_password'); $adapter->setIdentity($formValues['userlogin']); $adapter->setCredential($this->escort->passwordHash(null, $formValues['password'], false)); return $adapter; @@ -97,6 +97,21 @@ $form->setMethod('post'); $form->setDescription(sprintf($this->_('Login to %s application'), $this->project->name)); + if ($this->escort instanceof Gems_Project_Organization_SingleOrganizationInterface) { + $element = new Zend_Form_Element_Hidden('organization'); + $element->setValue($this->escort->getRespondentOrganization()); + } else { + $element = new Zend_Form_Element_Select('organization'); + $element->setLabel($this->_('Organization')); + $element->setMultiOptions($this->util->getDbLookup()->getOrganizations()); + $element->setRequired(true); + + if (! $this->_request->isPost()) { + $element->setValue($this->escort->getCurrentOrganization()); + } + } + $form->addElement($element); + // Veld inlognaam $element = new Zend_Form_Element_Text('userlogin'); $element->setLabel($this->_('Username')); @@ -135,7 +150,7 @@ return $form; } - // Dummy: always rerouted by Gems + // Dummy: always rerouted by GemsEscort public function indexAction() { } public function loginAction() @@ -152,11 +167,17 @@ $this->_reroute(array('controller' => 'respondent', 'action'=>'index')); } } + // MUtil_Echo::track(get_class($this->loader->getUser('super', null))); $form = $this->_getLoginForm(); if ($this->_request->isPost()) { if ($form->isValid($_POST, false)) { + /* + if ($user = $this->loader->getUser($_POST['userlogin'], $_POST['organization'])) { + + } // */ + if (isset($this->project->admin) && $this->project->admin['user'] == $_POST['userlogin'] && $this->project->admin['pwd'] == $_POST['password']) { $this->session->user_id = 2000; $this->session->user_name = $_POST['userlogin']; @@ -180,6 +201,19 @@ $adapter = $this->_getAuthAdapter($form->getValues()); $auth = Gems_Auth::getInstance(); $result = $auth->authenticate($adapter, $_POST['userlogin']); + + // Allow login using old password. + if ((! $result->isValid()) && ($userid = $this->db->fetchOne("SELECT gsu_id_user FROM gems__users WHERE gsu_active = 1 AND gsu_password IS NULL AND gsu_login = ?", $_POST['userlogin']))) { + + $adapter = new Zend_Auth_Adapter_DbTable($this->db, 'gems__staff', 'gsf_id_user', 'gsf_password'); + $adapter->setIdentity($userid); + $adapter->setCredential(md5($_POST['password'], false)); + $result = $auth->authenticate($adapter, $_POST['userlogin']); + MUtil_Echo::track('old autho'); + } else { + MUtil_Echo::track('new autho'); + } + if (!$result->isValid()) { // Invalid credentials $errors = $result->getMessages(); @@ -295,19 +329,19 @@ } if ($this->_request->isPost() && $form->isValid($_POST)) { - $sql = $this->db->quoteInto("SELECT gsf_id_user,gsf_email,gsf_reset_key,DATEDIFF(NOW(), gsf_reset_req) AS gsf_days FROM gems__staff WHERE gsf_login = ?", $_POST['userlogin']); + $sql = $this->db->quoteInto("SELECT gsu_id_user, gsf_email, gsu_reset_key, DATEDIFF(NOW(), gsu_reset_requested) AS gsf_days FROM gems__users INNER JOIN gems__staff ON gsu_id_user = gsf_id_user WHERE gsu_login = ?", $_POST['userlogin']); $result = $this->db->fetchRow($sql); if (empty($result) || empty($result['gsf_email'])) { $this->addMessage($this->_('No such user found or no e-mail address known')); - } else if (!empty($result['gsf_reset_key']) && $result['gsf_days'] < 1) { + } else if (!empty($result['gsu_reset_key']) && $result['gsf_days'] < 1) { $this->addMessage($this->_('Reset e-mail already sent, please try again after 24 hours')); } else { $email = $result['gsf_email']; $key = md5(time() . $email); $url = $this->util->getCurrentURI('index/resetpassword/key/' . $key); - $this->db->update('gems__staff', array('gsf_reset_key' => $key, 'gsf_reset_req' => new Zend_Db_Expr('NOW()')), 'gsf_id_user = ' . $result['gsf_id_user']); + $this->db->update('gems__users', array('gsu_reset_key' => $key, 'gsu_reset_requested' => new Zend_Db_Expr('NOW()')), 'gsu_id_user = ' . $result['gsu_id_user']); $mail->setSubject('Password reset requested'); $mail->setBodyText('To reset your password, please click this link: ' . $url); @@ -323,7 +357,7 @@ } } } else if ($key = $this->_request->getParam('key')) { - $sql = $this->db->quoteInto("SELECT gsf_id_user,gsf_email FROM gems__staff WHERE gsf_reset_key = ?", $key); + $sql = $this->db->quoteInto("SELECT gsu_id_user, gsf_email FROM gems__users INNER JOIN gems__staff ON gsu_id_user = gsf_id_user WHERE gsu_reset_key = ?", $key); $result = $this->db->fetchRow($sql); if (!empty($result)) { @@ -339,7 +373,7 @@ try { $mail->send(); $this->addMessage($this->_('An e-mail was sent containing your new password')); - $this->db->update('gems__staff', array('gsf_reset_key' => new Zend_Db_Expr('NULL'), 'gsf_reset_req' => new Zend_Db_Expr('NULL'), 'gsf_password' => $passwordHash), 'gsf_id_user = ' . $result['gsf_id_user']); + $this->db->update('gems__users', array('gsu_reset_key' => new Zend_Db_Expr('NULL'), 'gsu_reset_requested' => new Zend_Db_Expr('NULL'), 'gsu_password' => $passwordHash), 'gsu_id_user = ' . $result['gsu_id_user']); $this->_reroute(array('action' => 'index'), true); } catch (Exception $e) { $this->addMessage($this->_('Unable to send e-mail')); Modified: trunk/library/classes/Gems/Default/OptionAction.php =================================================================== --- trunk/library/classes/Gems/Default/OptionAction.php 2011-10-27 15:55:57 UTC (rev 150) +++ trunk/library/classes/Gems/Default/OptionAction.php 2011-10-27 16:21:42 UTC (rev 151) @@ -61,8 +61,10 @@ */ protected function addFormElements(MUtil_Model_FormBridge $bridge, MUtil_Model_ModelAbstract $model, array $data, $new = false) { + $bridge->addHidden( 'gsu_id_user'); + $bridge->addHidden( 'gsu_id_organization'); $bridge->addHidden( 'gsf_id_user'); - $bridge->addExhibitor('gsf_login', array('size' => 15, 'minlength' => 4)); + $bridge->addExhibitor('gsu_login', array('size' => 15, 'minlength' => 4)); $bridge->addText( 'gsf_first_name'); $bridge->addText( 'gsf_surname_prefix'); $bridge->addText( 'gsf_last_name'); @@ -71,12 +73,11 @@ $bridge->addRadio( 'gsf_gender', 'separator', ''); $bridge->addSelect( 'gsf_iso_lang', array('label' => $this->_('Language'), 'multiOptions' => $this->util->getLocalized()->getLanguages())); - $bridge->addCheckbox( 'gsf_logout_on_survey', 'label', $this->_('Logout on survey'), 'description', $this->_('If checked you will logoff after answering a survey.')); } public function afterSave(array $data, $isNew) { - $this->escort->loadLoginInfo($data['gsf_login']); + $this->escort->loadLoginInfo($data['gsu_login']); } public function changePasswordAction() @@ -86,15 +87,18 @@ *************/ $form = $this->createForm(); - // Veld current password - $element = new Zend_Form_Element_Password('old_password'); - $element->setLabel($this->_('Current password')); - $element->setAttrib('size', 10); - $element->setAttrib('maxlength', 20); - $element->setRenderPassword(true); - $element->setRequired(true); - $element->addValidator(new Gems_Validate_GemsPasswordUsername($this->session->user_login, 'old_password', $this->db)); - $form->addElement($element); + $sql = "SELECT CASE WHEN gsu_password IS NULL THEN 0 ELSE 1 END FROM gems__users WHERE gsu_id_user = ? AND gsu_id_organization = ?"; + if ($this->db->fetchOne($sql, array($this->session->user_id, $this->session->user_organization_id))) { + // Veld current password + $element = new Zend_Form_Element_Password('old_password'); + $element->setLabel($this->_('Current password')); + $element->setAttrib('size', 10); + $element->setAttrib('maxlength', 20); + $element->setRenderPassword(true); + $element->setRequired(true); + $element->addValidator(new Gems_Validate_GemsPasswordUsername($this->session->user_login, 'old_password', $this->db)); + $form->addElement($element); + } // Veld new password $element = new Zend_Form_Element_Password('new_password'); @@ -127,8 +131,9 @@ ****************/ if ($this->_request->isPost() && $form->isValid($_POST)) { - $data['gsf_id_user'] = $this->session->user_id; - $data['gsf_password'] = $this->escort->passwordHash(null,$_POST['new_password']); + $data['gsu_id_user'] = $this->session->user_id; + $data['gsu_id_organization'] = $this->session->user_organization_id; + $data['gsu_password'] = $this->escort->passwordHash(null, $_POST['new_password']); $this->getModel()->save($data); @@ -180,10 +185,10 @@ */ public function createModel($detailed, $action) { - $model = new MUtil_Model_TableModel('gems__staff'); - $model->canCreate = false; + $model = new Gems_Model_UserModel('staff', 'gems__staff', array('gsu_id_user' => 'gsf_id_user'), 'gsf'); + $model->copyKeys(); - $model->set('gsf_login', 'label', $this->_('Login Name')); + $model->set('gsu_login', 'label', $this->_('Login Name')); $model->set('gsf_email', 'label', $this->_('E-Mail')); $model->set('gsf_first_name', 'label', $this->_('First name')); $model->set('gsf_surname_prefix', 'label', $this->_('Surname prefix'), 'description', 'de, van der, \'t, etc...'); @@ -191,14 +196,12 @@ $model->set('gsf_gender', 'label', $this->_('Gender'), 'multiOptions', $this->util->getTranslated()->getGenders()); - Gems_Model::setChangeFieldsByPrefix($model, 'gsf'); - return $model; } public function editAction() { - $this->getModel()->setFilter(array('gsf_id_user' => $this->session->user_id)); + $this->getModel()->setFilter(array('gsu_id_user' => $this->session->user_id)); if ($form = $this->processForm()) { $this->html->h3(sprintf($this->_('Options'), $this->getTopic())); Modified: trunk/library/classes/Gems/Default/RespondentAction.php =================================================================== --- trunk/library/classes/Gems/Default/RespondentAction.php 2011-10-27 15:55:57 UTC (rev 150) +++ trunk/library/classes/Gems/Default/RespondentAction.php 2011-10-27 16:21:42 UTC (rev 151) @@ -326,8 +326,8 @@ $values = $this->db->fetchPairs(" SELECT gsf_id_user, CONCAT(gsf_last_name, ', ', COALESCE(CONCAT(gsf_first_name, ' '), ''), COALESCE(gsf_surname_prefix, '')) AS name - FROM gems__staff INNER JOIN gems__groups ON gsf_id_primary_group = ggp_id_group - WHERE gsf_active=1 AND gsf_id_organization = ? AND ggp_role = 'physician' + FROM (gems__users INNER JOIN gems__staff ON gsu_id_user = gsf_id_user) INNER JOIN gems__groups ON gsf_id_primary_group = ggp_id_group + WHERE gsu_active=1 AND gsu_id_organization = ? AND ggp_role = 'physician' ORDER BY 2", $organizationId); $session->physicians = $values; Modified: trunk/library/classes/Gems/Default/StaffAction.php =================================================================== --- trunk/library/classes/Gems/Default/StaffAction.php 2011-10-27 15:55:57 UTC (rev 150) +++ trunk/library/classes/Gems/Default/StaffAction.php 2011-10-27 16:21:42 UTC (rev 151) @@ -44,7 +44,7 @@ */ class Gems_Default_StaffAction extends Gems_Controller_BrowseEditAction { - public $filterStandard = array('gsf_active' => 1); + public $filterStandard = array('gsu_active' => 1); public $sortKey = array('name' => SORT_ASC); protected $_instanceId; @@ -96,18 +96,28 @@ if ($new) { $model->set('gsf_id_primary_group', 'default', $dbLookup->getDefaultGroup()); } else { - $model->set('gsf_password', 'description', $this->_('Enter only when changing')); - $model->setSaveWhenNotNull('gsf_password'); + $model->set('gsu_password', 'description', $this->_('Enter only when changing')); + $model->setSaveWhenNotNull('gsu_password'); } - $model->setOnSave('gsf_password', array($this->escort, 'passwordHash')); + $model->setOnSave('gsu_password', array($this->escort, 'passwordHash')); $ucfirst = new Zend_Filter_Callback('ucfirst'); - $bridge->addHidden( 'gsf_id_user'); - $bridge->addText( 'gsf_login', 'size', 15, 'minlength', 4, - 'validator', $model->createUniqueValidator('gsf_login')); + $bridge->addHidden( 'gsu_id_user'); + $bridge->addHidden( 'gsf_id_user'); // Needed for e-mail validation + $bridge->addHidden( 'gsu_user_class'); + $bridge->addText( 'gsu_login', 'size', 15, 'minlength', 4, + 'validator', $model->createUniqueValidator('gsu_login')); - $bridge->addPassword('gsf_password', + // Can the organization be changed? + if ($this->escort->hasPrivilege('pr.staff.edit.all')) { + $bridge->addHiddenMulti($model->getKeyCopyName('gsu_id_organization')); + $bridge->addSelect('gsu_id_organization'); + } else { + $bridge->addExhibitor('gsu_id_organization'); + } + + $bridge->addPassword('gsu_password', 'label', $this->_('Password'), 'minlength', $this->project->passwords['MinimumLength'], // 'renderPassword', true, @@ -123,11 +133,6 @@ $bridge->addFilter( 'gsf_last_name', $ucfirst); $bridge->addText( 'gsf_email', array('size' => 30))->addValidator('SimpleEmail')->addValidator($model->createUniqueValidator('gsf_email')); - if ($this->escort->hasPrivilege('pr.staff.edit.all')) { - $bridge->addSelect('gsf_id_organization'); - } else { - $bridge->addExhibitor('gsf_id_organization'); - } $bridge->addSelect('gsf_id_primary_group'); $bridge->addCheckbox('gsf_logout_on_survey', 'description', $this->_('If checked the user will logoff when answering a survey.')); @@ -136,15 +141,15 @@ public function afterFormLoad(array &$data, $isNew) { - if (array_key_exists('gsf_login', $data)) { - $this->_instanceId = $data['gsf_login']; + if (array_key_exists('gsu_login', $data)) { + $this->_instanceId = $data['gsu_login']; } $sql = "SELECT ggp_id_group,ggp_role FROM gems__groups WHERE ggp_id_group = " . (int) $data['gsf_id_primary_group']; $groups = $this->db->fetchPairs($sql); if (! ($this->escort->hasPrivilege('pr.staff.edit.all') || - $data['gsf_id_organization'] == $this->escort->getCurrentOrganization())) { + $data['gsu_id_organization'] == $this->escort->getCurrentOrganization())) { throw new Zend_Exception($this->_('You are not allowed to edit this staff member.')); } } @@ -164,18 +169,21 @@ { // MUtil_Model::$verbose = true; - $model = new MUtil_Model_TableModel('gems__staff'); + $model = new Gems_Model_UserModel('staff', 'gems__staff', array('gsu_id_user' => 'gsf_id_user'), 'gsf'); + if ($detailed) { + $model->copyKeys(); + } //$model->resetOrder(); - $model->set('gsf_login', 'label', $this->_('Login')); + $model->set('gsu_login', 'label', $this->_('Login')); $model->set('name', 'label', $this->_('Name'), 'column_expression', "CONCAT(COALESCE(CONCAT(gsf_last_name, ', '), '-, '), COALESCE(CONCAT(gsf_first_name, ' '), ''), COALESCE(gsf_surname_prefix, ''))"); $model->set('gsf_email', 'label', $this->_('E-Mail'), 'itemDisplay', 'MUtil_Html_AElement::ifmail'); if ($detailed || $this->escort->hasPrivilege('pr.staff.see.all')) { - $this->menu->getParameterSource()->offsetSet('gsf_id_organization', $this->escort->getCurrentOrganization()); + $this->menu->getParameterSource()->offsetSet('gsu_id_organization', $this->escort->getCurrentOrganization()); - $model->set('gsf_id_organization', 'label', $this->_('Organization'), + $model->set('gsu_id_organization', 'label', $this->_('Organization'), 'multiOptions', $this->util->getDbLookup()->getOrganizations(), 'default', $this->escort->getCurrentOrganization()); } @@ -184,14 +192,13 @@ $model->set('gsf_gender', 'label', $this->_('Gender'), 'multiOptions', $this->util->getTranslated()->getGenders()); if ($detailed) { + $model->set('gsu_user_class', 'default', 'StaffUser'); $model->set('gsf_iso_lang', 'label', $this->_('Language'), 'multiOptions', $this->util->getLocalized()->getLanguages()); $model->set('gsf_logout_on_survey', 'label', $this->_('Logout on survey'), 'multiOptions', $this->util->getTranslated()->getYesNo()); } - $model->setDeleteValues('gsf_active', 0); + $model->setDeleteValues('gsu_active', 0); - Gems_Model::setChangeFieldsByPrefix($model, 'gsf'); - return $model; } @@ -201,8 +208,8 @@ if ($this->escort->hasPrivilege('pr.staff.see.all')) { // Select organization - $options = array('' => $this->_('(all organizations)')) + $this->getModel()->get('gsf_id_organization', 'multiOptions'); - $select = new Zend_Form_Element_Select('gsf_id_organization', array('multiOptions' => $options)); + $options = array('' => $this->_('(all organizations)')) + $this->getModel()->get('gsu_id_organization', 'multiOptions'); + $select = new Zend_Form_Element_Select('gsu_id_organization', array('multiOptions' => $options)); // Position as second element $search = array_shift($elements); @@ -227,7 +234,7 @@ $filter = parent::getDataFilter($data); if (! $this->escort->hasPrivilege('pr.staff.see.all')) { - $filter['gsf_id_organization'] = $this->escort->getCurrentOrganization(); + $filter['gsu_id_organization'] = $this->escort->getCurrentOrganization(); } return $filter; } @@ -257,8 +264,8 @@ // Model filter has now been set. $data = $this->getModel()->loadFirst(); - $this->_setParam('gsf_id_organization', $data['gsf_id_organization']); - $this->menu->getParameterSource()->offsetSet('gsf_id_organization', $data['gsf_id_organization']); + $this->_setParam('gsu_id_organization', $data['gsu_id_organization']); + $this->menu->getParameterSource()->offsetSet('gsu_id_organization', $data['gsu_id_organization']); } return parent::getShowTable($columns, $filter, $sort); } Modified: trunk/library/classes/Gems/Default/TokenPlanAction.php =================================================================== --- trunk/library/classes/Gems/Default/TokenPlanAction.php 2011-10-27 15:55:57 UTC (rev 150) +++ trunk/library/classes/Gems/Default/TokenPlanAction.php 2011-10-27 16:21:42 UTC (rev 151) @@ -351,9 +351,9 @@ COALESCE(gems__staff.gsf_first_name, ''), COALESCE(CONCAT(' ', gems__staff.gsf_surname_prefix), '') ) AS gsf_name - FROM gems__staff INNER JOIN gems__respondent2track ON gsf_id_user = gr2t_created_by + FROM (gems__users INNER JOIN gems__staff ON gsu_id_user = gsf_id_user) INNER JOIN gems__respondent2track ON gsu_id_user = gr2t_created_by WHERE gr2t_id_organization = $orgId AND - gsf_active = 1 AND + gsu_active = 1 AND gr2t_active = 1"; $elements[] = $this->_createSelectElement('gr2t_created_by', $sql, $this->_('(all staff)')); Modified: trunk/library/classes/Gems/Loader/LoaderAbstract.php =================================================================== --- trunk/library/classes/Gems/Loader/LoaderAbstract.php 2011-10-27 15:55:57 UTC (rev 150) +++ trunk/library/classes/Gems/Loader/LoaderAbstract.php 2011-10-27 16:21:42 UTC (rev 151) @@ -154,7 +154,7 @@ { // echo '_loadClassPath: ' . $this->cascade . '-' . $classname . '-' . ($create ? 1 : 0) . "<br/>\n"; // debug_print_backtrace(); - // MUtil_Echo::r($filepath, $classname, $this->cascade); + // MUtil_Echo::track($filepath, $classname, $this->cascade); if (file_exists($filepath)) { if (! class_exists($classname)) { Modified: trunk/library/classes/Gems/Loader.php =================================================================== --- trunk/library/classes/Gems/Loader.php 2011-10-27 15:55:57 UTC (rev 150) +++ trunk/library/classes/Gems/Loader.php 2011-10-27 16:21:42 UTC (rev 151) @@ -90,6 +90,12 @@ /** * + * @var Gems_User_UserLoader + */ + protected $userLoader; + + /** + * * @var Gems_Util */ protected $util; @@ -177,6 +183,28 @@ /** * + * @param string $login_name + * @param int $organization Only used when more than one organization uses this $login_name + * @return Gems_User_UserAbstract + */ + public function getUser($login_name, $organization) + { + $loader = $this->getUserLoader(); + + return $loader->getUser($login_name, $organization); + } + + /** + * + * @return Gems_User_UserLoader + */ + protected function getUserLoader() + { + return $this->_getClass('userLoader', 'User_UserLoader'); + } + + /** + * * @return Gems_Util */ public function getUtil() Modified: trunk/library/classes/Gems/Menu/MenuAbstract.php =================================================================== --- trunk/library/classes/Gems/Menu/MenuAbstract.php 2011-10-27 15:55:57 UTC (rev 150) +++ trunk/library/classes/Gems/Menu/MenuAbstract.php 2011-10-27 16:21:42 UTC (rev 151) @@ -381,13 +381,12 @@ $page = $this->addPage($label, 'pr.staff', 'staff', 'index', $other); $page->addAutofilterAction(); $page->addCreateAction(); - $page->addShowAction(); - if ($this->escort->hasPrivilege('pr.staff.edit.all')) { - $page->addEditAction(); - $page->addDeleteAction(); - } else { - $page->addEditAction()->setParameterFilter('gsf_id_organization', $this->escort->getCurrentOrganization()); - $page->addDeleteAction()->setParameterFilter('gsf_id_organization', $this->escort->getCurrentOrganization()); + $page->addShowAction()->setModelParameters(2); + $editPage = $page->addEditAction()->setModelParameters(2); + $delPage = $page->addDeleteAction()->setModelParameters(2); + if (! $this->escort->hasPrivilege('pr.staff.edit.all')) { + $editPage->setParameterFilter('gsu_id_organization', $this->escort->getCurrentOrganization()); + $delPage->setParameterFilter('gsu_id_organization', $this->escort->getCurrentOrganization()); } return $page; Modified: trunk/library/classes/Gems/Menu/SubMenuItem.php =================================================================== --- trunk/library/classes/Gems/Menu/SubMenuItem.php 2011-10-27 15:55:57 UTC (rev 150) +++ trunk/library/classes/Gems/Menu/SubMenuItem.php 2011-10-27 16:21:42 UTC (rev 151) @@ -417,7 +417,7 @@ } $menu = $this->addAction($label, $privilege, 'delete', $other); - $menu->addParameters(MUtil_Model::REQUEST_ID); + $menu->setModelParameters(1); return $menu; } @@ -436,7 +436,7 @@ } $menu = $this->addAction($label, $privilege, 'edit', $other); - $menu->addParameters(MUtil_Model::REQUEST_ID); + $menu->setModelParameters(1); return $menu; } @@ -475,6 +475,17 @@ return $this; } + /** + * Add required parameters - shown in the url - for this + * menu item. + * + * Numeric array keys are changed into the same string as the + * array value. + * + * @param mixed $arrayOrKey1 MUtil_Ra::pairs named array + * @param mixed $key2 + * @return Gems_Menu_SubMenuItem (continuation pattern) + */ public function addNamedParameters($arrayOrKey1 = null, $altName1 = null) { $params = MUtil_Ra::pairs(func_get_args()); @@ -483,16 +494,8 @@ $this->_parameters = new MUtil_Lazy_ArrayWrap(); } foreach ($params as $param => $name) { - if (! $name) { - if (is_int($param)) { - throw new Zend_Exception('Invalid integer required parameter key with empty name.'); - } else { - $name = $param; - } - } else { - if (is_int($param)) { - $param = $name; - } + if (is_int($param)) { + $param = $name; } $this->_requiredParameters[$param] = $name; $this->_parameters[$param] = MUtil_Lazy::L($name); @@ -546,7 +549,7 @@ } $menu = $this->addAction($label, $privilege, 'show', $other); - $menu->addParameters(MUtil_Model::REQUEST_ID); + $menu->setModelParameters(1); return $menu; } @@ -755,6 +758,41 @@ return $this; } + /** + * Defines the number of named parameters using the model naming + * convention: id=x or id1=x id2=y + * + * @see setNamedParamenters() + * + * @param int $idCount The number of parameters to define + * @return Gems_Menu_SubMenuItem (continuation pattern) + */ + public function setModelParameters($idCount) + { + $params = array(); + if (1 == $idCount) { + $params[MUtil_Model::REQUEST_ID] = MUtil_Model::REQUEST_ID; + } else { + for ($i = 1; $i <= $idCount; $i++) { + $params[MUtil_Model::REQUEST_ID . $i] = MUtil_Model::REQUEST_ID . $i; + } + } + $this->setNamedParameters($params); + + return $this; + } + + /** + * Set the required parameters - shown in the url - for this + * menu item. + * + * Numeric array keys are changed into the same string as the + * array value. + * + * @param mixed $arrayOrKey1 MUtil_Ra::pairs named array + * @param mixed $key2 + * @return Gems_Menu_SubMenuItem (continuation pattern) + */ public function setNamedParameters($arrayOrKey1 = null, $key2 = null) { $params = MUtil_Ra::pairs(func_get_args()); Copied: trunk/library/classes/Gems/Model/UserModel.php (from rev 150, branches/newUser/classes/Gems/Model/UserModel.php) =================================================================== --- trunk/library/classes/Gems/Model/UserModel.php (rev 0) +++ trunk/library/classes/Gems/Model/UserModel.php 2011-10-27 16:21:42 UTC (rev 151) @@ -0,0 +1,119 @@ +<?php + +/** + * Copyright (c) 2011, Erasmus MC + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Erasmus MC nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * + * @package Gems + * @subpackage Model + * @author Matijs de Jong <mj...@ma...> + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @version $Id: Sample.php 203 2011-07-07 12:51:32Z matijs $ + */ + +/** + * + * + * @package Gems + * @subpackage Model + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @since Class available since version 1.4.4 + */ +class Gems_Model_UserModel extends Gems_Model_JoinModel +{ + /** + * The length of a user id. + * + * @var int + */ + protected $userIdLen = 8; + + /** + * Create a model that joins two or more tables + * + * @param string $name The name of the model + * @param string $secondTable The optional second base table for the model + * @param array $joinFields Array of source->dest primary keys for this join + * @param string $fieldPrefix Prefix to use for change fields (date/userid) + * @param bool $saveable Will changes to this table be saved + */ + public function __construct($name, $secondTable = null, array $joinFields = null, $fieldPrefix = null, $saveable = null) + { + parent::__construct($name, 'gems__users', (null === $saveable ? $fieldPrefix : $saveable)); + + if ($fieldPrefix) { + Gems_Model::setChangeFieldsByPrefix($this, 'gsu'); + } + + if ($secondTable) { + $this->addTable($secondTable, $joinFields, $fieldPrefix, $saveable); + } + } + + /** + * Finds a random unique user id. + * + * @return int + */ + protected function _createUserId() + { + $db = $this->getAdapter(); + + $max = $this->userIdLen; + + do { + $out = mt_rand(1, 9); + for ($i = 1; $i < $this->userIdLen; $i++) { + $out .= mt_rand(0, 9); + } + // Make it a number + $out = intval($out); + + } while ($db->fetchOne('SELECT gsu_id_user FROM gems__users WHERE gsu_id_user = ?', $out)); + + return $out; + } + + /** + * Save a single model item. + * + * @param array $newValues The values to store for a single model item. + * @param array $filter If the filter contains old key values these are used + * to decide on update versus insert. + * @return array The values as they are after saving (they may change). + */ + public function save(array $newValues, array $filter = null, array $saveTables = null) + { + if (! (isset($newValues['gsu_id_user']) && $newValues['gsu_id_user'])) { + // Load a new user id if needed + $newValues['gsu_id_user'] = $this->_createUserId(); + } + + return parent::save($newValues, $filter, $saveTables); + } +} Property changes on: trunk/library/classes/Gems/User ___________________________________________________________________ Added: bugtraq:url + http://survey.erasmusmc.nl/support/mantis/view.php?id=%BUGID% Added: bugtraq:number + true Added: bugtraq:logregex + #(\d+) Deleted: trunk/library/classes/Gems/User/DatabaseUserAbstract.php =================================================================== --- branches/newUser/classes/Gems/User/DatabaseUserAbstract.php 2011-10-27 15:55:57 UTC (rev 150) +++ trunk/library/classes/Gems/User/DatabaseUserAbstract.php 2011-10-27 16:21:42 UTC (rev 151) @@ -1,83 +0,0 @@ -<?php - -/** - * Copyright (c) 2011, Erasmus MC - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of Erasmus MC nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * - * @package Gems - * @subpackage User - * @author Matijs de Jong <mj...@ma...> - * @copyright Copyright (c) 2011 Erasmus MC - * @license New BSD License - * @version $Id: Sample.php 203 2011-07-07 12:51:32Z matijs $ - */ - -/** - * - * - * @package Gems - * @subpackage User - * @copyright Copyright (c) 2011 Erasmus MC - * @license New BSD License - * @since Class available since version 1.4.4 - */ -class Gems_User_DatabaseUserAbstract extends Gems_User_UserAbstract -{ - /** - * - * @var Zend_Db_Adapter_Abstract - */ - protected $db; - - /** - * Simple used name => database field - * @var array - */ - protected $fieldMappings = array(); - - /** - * Creates the initial feed SQL select statement - * - * @return Zend_Db_Select - */ - abstract public function getSqlSelect(); - - /** - * Intialize the values for this user. - * - * Skipped when the user is the active user and is stored in the session. - * - * @param string $login_name - * @param int $organization Only used when more than one organization uses this $login_name - * @return boolean False when the object could not load. - */ - protected function initVariables($login_name, $organization) - { - $select = $this->getSqlSelect(); - - $userIds = $select->query()->fetchAll(); - } -} Copied: trunk/library/classes/Gems/User/DatabaseUserAbstract.php (from rev 150, branches/newUser/classes/Gems/User/DatabaseUserAbstract.php) =================================================================== --- trunk/library/classes/Gems/User/DatabaseUserAbstract.php (rev 0) +++ trunk/library/classes/Gems/User/DatabaseUserAbstract.php 2011-10-27 16:21:42 UTC (rev 151) @@ -0,0 +1,83 @@ +<?php + +/** + * Copyright (c) 2011, Erasmus MC + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Erasmus MC nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * + * @package Gems + * @subpackage User + * @author Matijs de Jong <mj...@ma...> + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @version $Id: Sample.php 203 2011-07-07 12:51:32Z matijs $ + */ + +/** + * + * + * @package Gems + * @subpackage User + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @since Class available since version 1.4.4 + */ +class Gems_User_DatabaseUserAbstract extends Gems_User_UserAbstract +{ + /** + * + * @var Zend_Db_Adapter_Abstract + */ + protected $db; + + /** + * Simple used name => database field + * @var array + */ + protected $fieldMappings = array(); + + /** + * Creates the initial feed SQL select statement + * + * @return Zend_Db_Select + */ + abstract public function getSqlSelect(); + + /** + * Intialize the values for this user. + * + * Skipped when the user is the active user and is stored in the session. + * + * @param string $login_name + * @param int $organization Only used when more than one organization uses this $login_name + * @return boolean False when the object could not load. + */ + protected function initVariables($login_name, $organization) + { + $select = $this->getSqlSelect(); + + $userIds = $select->query()->fetchAll(); + } +} Deleted: trunk/library/classes/Gems/User/NoLoginUser.php =================================================================== --- branches/newUser/classes/Gems/User/NoLoginUser.php 2011-10-27 15:55:57 UTC (rev 150) +++ trunk/library/classes/Gems/User/NoLoginUser.php 2011-10-27 16:21:42 UTC (rev 151) @@ -1,81 +0,0 @@ -<?php - -/** - * Copyright (c) 2011, Erasmus MC - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of Erasmus MC nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * - * @package Gems - * @subpackage User - * @author Matijs de Jong <mj...@ma...> - * @copyright Copyright (c) 2011 Erasmus MC - * @license New BSD License - * @version $Id: Sample.php 203 2011-07-07 12:51:32Z matijs $ - */ - -/** - * - * - * @package Gems - * @subpackage User - * @copyright Copyright (c) 2011 Erasmus MC - * @license New BSD License - * @since Class available since version 1.4.4 - */ -class Gems_User_NoLoginUser extends Gems_User_UserAbstract -{ - /** - * - * @var Gems_Util_Translated - */ - protected $translated; - - /** - * Check that the password is correct for this user. - * - * @param string $password Unencrypted password - * @return boolean - */ - public function checkPassword($password) - { - return false; - } - - /** - * Intialize the values for this user. - * - * Skipped when the user is the active user and is stored in the session. - * - * @param string $login_name - * @param int $organization Only used when more than one organization uses this $login_name - * @return boolean False when the object could not load. - */ - protected function initVariables($login_name, $organization) - { - $this->setRole('nologin'); - return true; - } - -} Copied: trunk/library/classes/Gems/User/NoLoginUser.php (from rev 150, branches/newUser/classes/Gems/User/NoLoginUser.php) =================================================================== --- trunk/library/classes/Gems/User/NoLoginUser.php (rev 0) +++ trunk/library/classes/Gems/User/NoLoginUser.php 2011-10-27 16:21:42 UTC (rev 151) @@ -0,0 +1,81 @@ +<?php + +/** + * Copyright (c) 2011, Erasmus MC + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Erasmus MC nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * + * @package Gems + * @subpackage User + * @author Matijs de Jong <mj...@ma...> + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @version $Id: Sample.php 203 2011-07-07 12:51:32Z matijs $ + */ + +/** + * + * + * @package Gems + * @subpackage User + * @copyright Copyright (c) 2011 Erasmus MC + * @license New BSD License + * @since Class available since version 1.4.4 + */ +class Gems_User_NoLoginUser extends Gems_User_UserAbstract +{ + /** + * + * @var Gems_Util_Translated + */ + protected $translated; + + /** + * Check that the password is correct for this user. + * + * @param string $password Unencrypted password + * @return boolean + */ + public function checkPassword($password) + { + return false; + } + + /** + * Intialize the values for this user. + * + * Skipped when the user is the active user and is stored in the session. + * + * @param string $login_name + * @param int $organization Only used when more than one organization uses this $login_name + * @return boolean False when the object could not load. + */ + protected function initVariables($login_name, $organization) + { + $this->setRole('nologin'); + return true; + } + +} Deleted: trunk/library/classes/Gems/User/ProjectSuperUser.php =================================================================== --- branches/newUser/classes/Gems/User/ProjectSuperUser.php 2011-10-27 15:55:57 UTC (rev 150) +++ trunk/library/classes/Gems/User/ProjectSuperUser.php 2011-10-27 16:21:42 UTC (rev 151) @@ -1,113 +0,0 @@ -<?php - -/** - * Copyright (c) 2011, Erasmus MC - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of Erasmus MC nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS F... [truncated message content] |