]> git.mxchange.org Git - shipsimu.git/blob - inc/classes/main/user/guest/class_Guest.php
Now we really have ship-simu specific user/member classes
[shipsimu.git] / inc / classes / main / user / guest / class_Guest.php
1 <?php
2 /**
3  * A generic class for handling guests
4  *
5  * @author              Roland Haeder <webmaster@ship-simu.org>
6  * @version             0.0.0
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
10  *
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.
15  *
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.
20  *
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/>.
23  */
24 class Guest extends BaseUser implements ManageableGuest, Registerable {
25         // Exceptions
26         const EXCEPTION_USERNAME_NOT_FOUND   = 0x170;
27         const EXCEPTION_USER_EMAIL_NOT_FOUND = 0x171;
28         const EXCEPTION_USER_PASS_MISMATCH   = 0x172;
29
30         /**
31          * Protected constructor
32          *
33          * @return      void
34          */
35         protected function __construct () {
36                 // Call parent constructor
37                 parent::__construct(__CLASS__);
38
39                 // Set part description
40                 $this->setObjectDescription("Generic guest class");
41
42                 // Create unique ID number
43                 $this->generateUniqueId();
44         }
45
46         /**
47          * Creates an instance of this user class by a provided username. This
48          * factory method will check if the username is already taken and if not
49          * so it will throw an exception.
50          *
51          * @param       $userName               Username we need a class instance for
52          * @return      $userInstance   An instance of this user class
53          * @throws      UsernameMissingException        If the username does not exist
54          */
55         public final static function createGuestByUsername ($userName) {
56                 // Get a new instance
57                 $userInstance = new Guest();
58
59                 // Set the username
60                 $userInstance->setUserName($userName);
61
62                 // Check if the username exists
63                 if (!$userInstance->ifUsernameExists()) {
64                         // Throw an exception here
65                         throw new UsernameMissingException(array($userInstance, $userName), self::EXCEPTION_USERNAME_NOT_FOUND);
66                 }
67
68                 // Return the instance
69                 return $userInstance;
70         }
71
72         /**
73          * Creates an instance of this user class by a provided email address. This
74          * factory method will not check if the email address is there.
75          *
76          * @param       $email                  Email address of the user
77          * @return      $userInstance   An instance of this user class
78          */
79         public final static function createGuestByEmail ($email) {
80                 // Get a new instance
81                 $userInstance = new Guest();
82
83                 // Set the username
84                 $userInstance->setEmail($email);
85
86                 // Return the instance
87                 return $userInstance;
88         }
89
90         /**
91          * Updates the last activity timestamp and last performed action in the
92          * database result. You should call flushPendingUpdates() to flush these updates
93          * to the database layer.
94          *
95          * @param       $requestInstance        A requestable class instance
96          * @return      void
97          */
98         public function updateLastActivity (Requestable $requestInstance) {
99                 // No activity will be logged for guest accounts
100         }
101
102         /**
103          * Flushs all pending updates to the database layer
104          *
105          * @return      void
106          */
107         public function flushPendingUpdates () {
108                 // No updates will be flushed to database!
109         }
110
111         /**
112          * Adds data for later complete update
113          *
114          * @param       $column         Column we want to update
115          * @param       $value          New value to store in database
116          * @return      void
117          */
118         public function addUpdateData ($column, $value) {
119                 // Nothing shall be updated by user him/her self
120         }
121 }
122
123 // [EOF]
124 ?>