From 09fffebffe9ab1cf7622aa141150157b0746e20d Mon Sep 17 00:00:00 2001 From: cweiske Date: Sun, 25 Oct 2009 19:32:48 +0000 Subject: test if deleting bookmarks works. to do this, we need a new testbase method to create users, plus we need to return the uid when creating a new user. registration process needs to be adopted to that. git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@417 b3834d28-1941-0410-a4f8-b48e95affb8f --- src/SemanticScuttle/Service/User.php | 37 +++++++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 7 deletions(-) (limited to 'src/SemanticScuttle/Service/User.php') diff --git a/src/SemanticScuttle/Service/User.php b/src/SemanticScuttle/Service/User.php index bf44c4b..035c9e2 100644 --- a/src/SemanticScuttle/Service/User.php +++ b/src/SemanticScuttle/Service/User.php @@ -400,24 +400,47 @@ class SemanticScuttle_Service_User extends SemanticScuttle_DbService return true; } - function addUser($username, $password, $email) { + /** + * Create a new user in database. + * No checks are done in here - you ought to have checked + * everything before calling this method! + * + * @param string $username Username to use + * @param string $password Password to use + * @param string $email Email to use + * + * @return mixed Integer user ID if all is well, + * boolean false if an error occured + */ + public function addUser($username, $password, $email) + { // Set up the SQL UPDATE statement. $datetime = gmdate('Y-m-d H:i:s', time()); $password = $this->sanitisePassword($password); - $values = array('username' => $username, 'password' => $password, 'email' => $email, 'uDatetime' => $datetime, 'uModified' => $datetime); - $sql = 'INSERT INTO '. $this->getTableName() .' '. $this->db->sql_build_array('INSERT', $values); + $values = array( + 'username' => $username, + 'password' => $password, + 'email' => $email, + 'uDatetime' => $datetime, + 'uModified' => $datetime + ); + $sql = 'INSERT INTO '. $this->getTableName() + . ' '. $this->db->sql_build_array('INSERT', $values); // Execute the statement. $this->db->sql_transaction('begin'); if (!($dbresult = & $this->db->sql_query($sql))) { $this->db->sql_transaction('rollback'); - message_die(GENERAL_ERROR, 'Could not insert user', '', __LINE__, __FILE__, $sql, $this->db); + message_die( + GENERAL_ERROR, 'Could not insert user', + '', __LINE__, __FILE__, $sql, $this->db + ); return false; } + $uId = $this->db->sql_nextid($dbresult); $this->db->sql_transaction('commit'); - // Everything worked out, so return true. - return true; + return $uId; } function updateUser($uId, $password, $name, $email, $homepage, $uContent) { @@ -564,7 +587,7 @@ class SemanticScuttle_Service_User extends SemanticScuttle_DbService * * @see updateSessionStability() */ - publi function isSessionStable() + public function isSessionStable() { return $_SESSION['sessionStable'] == 1; } -- cgit v1.2.3-54-g00ecf