From: <gem...@li...> - 2012-02-23 12:27:00
|
Revision: 512 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=512&view=rev Author: matijsdejong Date: 2012-02-23 12:26:49 +0000 (Thu, 23 Feb 2012) Log Message: ----------- Added respondent creation and initial password to core Modified Paths: -------------- trunk/library/classes/Gems/Project/ProjectSettings.php trunk/library/classes/Gems/User/UserLoader.php Modified: trunk/library/classes/Gems/Project/ProjectSettings.php =================================================================== --- trunk/library/classes/Gems/Project/ProjectSettings.php 2012-02-23 10:52:42 UTC (rev 511) +++ trunk/library/classes/Gems/Project/ProjectSettings.php 2012-02-23 12:26:49 UTC (rev 512) @@ -242,7 +242,22 @@ return -1; } + /** + * Returns the initial password specified for users - if any. + * + * @return String + */ + public function getInitialPassword() + { + if (isset($this['password']['initialPassword'])) { + return $this['password']['initialPassword']; + } else { + return null; + } + } + + /** * Returns the public name of this project. * @return string */ @@ -341,4 +356,14 @@ return md5($salted, false); } + + /** + * True if an initial password was specified for users. + * + * @return boolean + */ + public function hasInitialPassword() + { + return isset($this['password']['initialPassword']); + } } Modified: trunk/library/classes/Gems/User/UserLoader.php =================================================================== --- trunk/library/classes/Gems/User/UserLoader.php 2012-02-23 10:52:42 UTC (rev 511) +++ trunk/library/classes/Gems/User/UserLoader.php 2012-02-23 12:26:49 UTC (rev 512) @@ -132,6 +132,33 @@ } /** + * Returns a user object, that may be empty if no user exist. + * + * @param string $login_name + * @param int $organization + * @param string $userClassName + * @param int $userId The person creating the user. + * @return Gems_User_User Newly created + */ + public function createUser($login_name, $organization, $userClassName, $userId) + { + $now = new Zend_Db_Expr('CURRENT_TIMESTAMP'); + + $values['gul_login'] = $login_name; + $values['gul_id_organization'] = $organization; + $values['gul_user_class'] = $userClassName; + $values['gul_can_login'] = 1; + $values['gul_changed'] = $now; + $values['gul_changed_by'] = $userId; + $values['gul_created'] = $now; + $values['gul_created_by'] = $userId; + + $this->db->insert('gems__user_logins', $values); + + return $this->getUser($login_name, $organization); + } + + /** * Get userclass / description array of available UserDefinitions for respondents * * @return array @@ -216,7 +243,7 @@ * Returns a user object, that may be empty if no user exist. * * @param string $login_name - * @param int $organization + * @param int $currentOrganization * @return Gems_User_User But ! ->isActive when the user does not exist */ public function getUser($login_name, $currentOrganization) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |