コード例 #1
0
ファイル: Phorum_user.php プロジェクト: nistormihai/Newscoop
  	/**
  	 * Create the user.  The user cannot be created if the user is
  	 * banned or the user name or email already exists.  The optional
  	 * $p_userId parameter is there for the cases where Phorum is run
  	 * inside of another master application and you want to use the
  	 * master application user ID for the Phorum ID.
  	 *
  	 * @param string $p_username
	 * @param string $p_password
  	 * @param string $p_email
  	 * @param int $p_userId
  	 * @param bool $p_encryptedPassword
  	 * @return boolean
  	 */
  	public function create($p_username, $p_password, $p_email, $p_userId = null,
  	                       $p_encryptedPassword = false)
  	{
		$userdata = array();

	   	if (Phorum_user::UserNameExists($p_username)) {
	   		return false;
	   	}

	   	if (Phorum_user::EmailExists($p_email)) {
	   		return false;
	   	}

		if (Phorum_user::IsBanned($p_username, $p_email)) {
			return false;
		}

		if (!is_null($p_userId) && is_numeric($p_userId)) {
			$tmpUser = new Phorum_user($p_userId);
//			$userdata['user_id'] = $p_userId;
			$userdata['fk_campsite_user_id'] = $p_userId;
			if ($tmpUser->exists()) {
				unset($userdata['user_id']);
			}
		}

		$userdata['username'] = $p_username;
		$userdata['password'] = $p_encryptedPassword ? $p_password : sha1($p_password);
		$userdata['email'] = $p_email;
		$userdata['date_added'] = time();
		$userdata['date_last_active'] = time();
		$userdata['hide_email'] = true;
		$userdata['active'] = PHORUM_USER_ACTIVE;

		// Create the user
		$this->m_data['user_id'] = phorum_db_user_add( $userdata );

		// Refresh the object from the database.
		$this->fetch();

		return true;
	} // fn create