From: <gem...@li...> - 2011-11-22 15:30:53
|
Revision: 271 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=271&view=rev Author: mennodekker Date: 2011-11-22 15:30:41 +0000 (Tue, 22 Nov 2011) Log Message: ----------- Unrelated fix to IndexAction resetpassword (dev email removed) to be ported to trunk some day :) + added some first thoughts on changes needed to allow projects to work with the new system Modified Paths: -------------- branches/userloader/classes/Gems/Default/IndexAction.php branches/userloader/classes/Gems/Default/StaffAction.php branches/userloader/classes/Gems/User/UserLoader.php Modified: branches/userloader/classes/Gems/Default/IndexAction.php =================================================================== --- branches/userloader/classes/Gems/Default/IndexAction.php 2011-11-22 15:18:23 UTC (rev 270) +++ branches/userloader/classes/Gems/Default/IndexAction.php 2011-11-22 15:30:41 UTC (rev 271) @@ -1,5 +1,4 @@ <?php - /** * Copyright (c) 2011, Erasmus MC * All rights reserved. @@ -360,12 +359,14 @@ $this->addMessage($this->_('This key timed out or does not belong to this user.')); } } else { - // P{ass mail by key + // Pass mail by key $mail = new MUtil_Mail(); - $mail->setFrom('mj...@ma...'); $mail->addTo($user->getEmailAddress(), $user->getFullName()); - if (isset($this->escort->project->email) && isset($this->escort->project->email['bcc'])) { + if (isset($this->escort->project->email['site'])) { + $mail->setFrom($this->escort->project->email['site']); + } + if (isset($this->escort->project->email['bcc'])) { $mail->addBcc($this->escort->project->email['bcc']); } Modified: branches/userloader/classes/Gems/Default/StaffAction.php =================================================================== --- branches/userloader/classes/Gems/Default/StaffAction.php 2011-11-22 15:18:23 UTC (rev 270) +++ branches/userloader/classes/Gems/Default/StaffAction.php 2011-11-22 15:30:41 UTC (rev 271) @@ -44,6 +44,8 @@ */ class Gems_Default_StaffAction extends Gems_Controller_BrowseEditAction { + //@@TODO What if we want a different one per organization? + //Maybe check if org has a default and otherwise use this one? public $defaultStaffDefinition = Gems_User_UserLoader::USER_STAFF; public $filterStandard = array('gsf_active' => 1); @@ -94,21 +96,22 @@ { $dbLookup = $this->util->getDbLookup(); - switch ($data['gul_user_class']) { - case Gems_User_UserLoader::USER_STAFF: + $passwordField = false; + + //@@TODO Like this? should work when user is not saved, but storing the password should be done when + //we do have a user... + $definition = $this->loader->getUserLoader()->getUserDefinition($data['gul_user_class']); + + if ($definition->canSetPassword()) { + //@@TODO: Should we handle it like this? The userdef has a setpassword method... + if ($definition instanceof Gems_User_StaffUserDefinition) { Gems_Model::addUserPassword($model); $passwordField = 'gup_password'; $model->setOnSave($passwordField, array($this->project, 'getValueHash')); - break; - - case Gems_User_UserLoader::USER_OLD_STAFF: + } elseif ($definition instanceof Gems_User_OldStaffUserDefinition) { $passwordField = 'gsf_password'; $model->setOnSave($passwordField, array($this, 'getOldPasswordHash')); - break; - - default: - $passwordField = false; - break; + } } $model->set('gsf_id_primary_group', 'multiOptions', MUtil_Lazy::call($dbLookup->getAllowedStaffGroups)); @@ -125,6 +128,8 @@ $bridge->addHidden( 'gul_id_user'); $bridge->addHidden( 'gup_id_user'); $bridge->addHidden( 'gul_user_class'); + //@@TODO: How do we change this? Only per org, or allow per user? + //What classes are available? Maybe use something like event loader and add a little desc. to each type? $bridge->addText( 'gsf_login', 'size', 15, 'minlength', 4, 'validator', $model->createUniqueValidator('gsf_login', array('gsf_id_user'))); Modified: branches/userloader/classes/Gems/User/UserLoader.php =================================================================== --- branches/userloader/classes/Gems/User/UserLoader.php 2011-11-22 15:18:23 UTC (rev 270) +++ branches/userloader/classes/Gems/User/UserLoader.php 2011-11-22 15:30:41 UTC (rev 271) @@ -188,7 +188,7 @@ { $defName = $this->getUserClassName($login_name, $organization); - $definition = $this->_getClass($defName); + $definition = $this->getUserDefinition($defName); $values = $definition->getUserData($login_name, $organization); @@ -206,6 +206,20 @@ } /** + * Retrieve a userdefinition, so we can check it's capabilities without + * instantiating a user + * + * @param type $userClassName + * @return Gems_User_UserDefinitionInterface + */ + public function getUserDefinition($userClassName) + { + $definition = $this->_getClass($userClassName); + + return $definition; + } + + /** * Get a staff user using the $staff_id * * @param int $staff_id This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |