3 * A special guest class for Ship-Simu
5 * @author Roland Haeder <webmaster@ship-simu.org>
7 * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software
8 * @license GNU GPL 3.0 or any newer version
9 * @link http://www.ship-simu.org
11 * This program is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation, either version 3 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program. If not, see <http://www.gnu.org/licenses/>.
24 class ShipSimuGuest extends BaseUser implements ManageableGuest, Registerable {
26 const EXCEPTION_USERNAME_NOT_FOUND = 0x170;
27 const EXCEPTION_USER_EMAIL_NOT_FOUND = 0x171;
28 const EXCEPTION_USER_PASS_MISMATCH = 0x172;
31 * Protected constructor
33 * @param $className Name of the class
36 protected function __construct ($className = "") {
37 // Is the class name empty? Then this is not a specialized user class
38 if (empty($className)) $className = __CLASS__;
40 // Call parent constructor
41 parent::__construct($className);
45 * Creates an instance of this user class by a provided username. This
46 * factory method will check if the username is already taken and if not
47 * so it will throw an exception.
49 * @param $userName Username we need a class instance for
50 * @return $userInstance An instance of this user class
51 * @throws UsernameMissingException If the username does not exist
53 public final static function createGuestByUsername ($userName) {
55 $userInstance = new ShipSimuGuest();
58 $userInstance->setUserName($userName);
60 // Check if the username exists
61 if (!$userInstance->ifUsernameExists()) {
62 // Throw an exception here
63 throw new UsernameMissingException(array($userInstance, $userName), self::EXCEPTION_USERNAME_NOT_FOUND);
66 // Return the instance
71 * Creates an instance of this user class by a provided email address. This
72 * factory method will not check if the email address is there.
74 * @param $email Email address of the user
75 * @return $userInstance An instance of this user class
77 public final static function createGuestByEmail ($email) {
79 $userInstance = new ShipSimuGuest();
82 $userInstance->setEmail($email);
84 // Return the instance
89 * Updates the last activity timestamp and last performed action in the
90 * database result. You should call flushPendingUpdates() to flush these updates
91 * to the database layer.
93 * @param $requestInstance A requestable class instance
96 public function updateLastActivity (Requestable $requestInstance) {
97 // No activity will be logged for guest accounts
101 * Flushs all pending updates to the database layer
105 public function flushPendingUpdates () {
106 // No updates will be flushed to database!