/** * Load multiple UserDBO's from database * * @param string $filter A WHERE clause * @param string $sortby Field name to sort results by * @param string $sortdir Direction to sort in (ASEC or DESC) * @param int $limit Limit the number of results * @param int $start Record number to start the results at * @return array Array of UserDBO's */ function load_array_UserDBO($filter = null, $sortby = null, $sortdir = null, $limit = null, $start = null) { $DB = DBConnection::getDBConnection(); // Build query $sql = $DB->build_select_sql("user", "*", $filter, $sortby, $sortdir, $limit, $start); // Run query if (!($result = @mysql_query($sql, $DB->handle()))) { // Query error throw new DBException(mysql_error($DB->handle())); } if (mysql_num_rows($result) == 0) { // No Users found throw new DBNoRowsFoundException(); } // Build an array of UserDBOs from the result set $user_dbo_array = array(); while ($data = mysql_fetch_array($result)) { // Create and initialize a new UserDBO with the data from the DB $dbo = new UserDBO(); $dbo->load($data); // Add UserDBO to array $user_dbo_array[] = $dbo; } // Return the UserDBO array return $user_dbo_array; }
/** * Process New User * * Verify the username requested does not already exist, then * ask the client to confirm the new User. */ function process_new_user() { if ($this->post['password'] != $this->post['repassword']) { // Destroy the password values so they're not echoed to the form unset($this->session['new_user']['password']); unset($this->session['new_user']['repassword']); // Password not entered correctly throw new SWUserException("[PASSWORD_MISMATCH]"); } // Verify this username does not already exist try { load_UserDBO($this->post['username']); // Username already exists throw new SWUserException("[DB_USER_EXISTS]"); } catch (DBNoRowsFoundException $e) { } // Prepare UserDBO for database insertion $user_dbo = new UserDBO(); $user_dbo->load($this->post); // MAY CHANGE $user_dbo->setPassword($this->post['password']); // Place DBO in the session for the confirm & receipt page $this->session['new_user_dbo'] = $user_dbo; // Ask client to confirm $this->setTemplate("confirm"); }