mosUser Class Reference

Inheritance diagram for mosUser:

aliroDatabaseRow aliroDBGeneralRow aliroUser

List of all members.

Public Member Functions

 userStore ($password='', $activation='')
 delete ($oid=null)
 check ()

Protected Member Functions

 getSessionData ()

Protected Attributes

 $DBclass = 'aliroDatabase'
 $tableName = '#__users'
 $rowKey = 'id'


Detailed Description

Users Table Class

Aliro

Definition at line 58 of file aliroUser.php.


Member Function Documentation

mosUser::getSessionData (  )  [protected]

Fill a user object with information from the current session

Definition at line 66 of file aliroUser.php.

References criticalInfo::getInstance(), aliroSessionFactory::getSession(), int(), and name.

Referenced by aliroUser::__construct(), and aliroUser::reset().

00066                                         {
00067         // Avoid using aliroRequest here - this will run before it is available
00068         $prefix = criticalInfo::getInstance()->isAdmin ? 'admin' : 'user';
00069         // Get session to ensure initialisation - don't actually need it - but do need session started
00070         // This shouldn't be necessary, but left in just to be sure
00071         aliroSessionFactory::getSession();
00072         $this->id = isset($_SESSION["aliro_{$prefix}id"]) ? (int) $_SESSION["aliro_{$prefix}id"] : 0;
00073         $this->name = isset($_SESSION["aliro_{$prefix}name"]) ? $_SESSION["aliro_{$prefix}name"] : '';
00074         $this->username = isset($_SESSION["aliro_{$prefix}username"]) ? $_SESSION["aliro_{$prefix}username"] : '';
00075         $this->email = isset($_SESSION["aliro_{$prefix}email"]) ? $_SESSION["aliro_{$prefix}email"] : '';
00076         $this->sendEmail = isset($_SESSION["aliro_{$prefix}sendEmail"]) ? $_SESSION["aliro_{$prefix}sendEmail"] : '';
00077         $this->usertype = isset($_SESSION["aliro_{$prefix}type"]) ? $_SESSION["aliro_{$prefix}type"] : '';
00078         $this->gid = isset($_SESSION["aliro_{$prefix}gid"]) ? (int) $_SESSION["aliro_{$prefix}gid"] : 0;
00079     }

mosUser::userStore ( password = '',
activation = '' 
)

Definition at line 82 of file aliroUser.php.

References aliroCoreDatabase::getInstance(), aliroAdminAuthenticator::getInstance(), aliroDBGeneralRow::insert(), T_(), and aliroDBGeneralRow::update().

00082                                                             {
00083         $salt = aliroAdminAuthenticator::getInstance()->makeSalt();
00084         if ($this->id) {
00085             $ret = $this->update();
00086             if ($password) {
00087                 $database = aliroCoreDatabase::getInstance();
00088                 $database->doSQL("UPDATE #__core_users SET salt = IF(salt='', '$salt', salt), password = MD5(CONCAT(salt, '$password')) WHERE id = $this->id");
00089             }
00090         }
00091         else {
00092             $database = aliroCoreDatabase::getInstance();
00093             $database->doSQL("INSERT INTO #__core_users (password, salt, activation) VALUES (MD5(CONCAT('$salt', '$password')), '$salt', '$activation')");
00094             $this->id = $database->insertid();
00095             $ret = $this->insert();
00096         }
00097         if ($ret) return true;
00098         $this->_error = T_('mosUser::store failed');
00099         return false;
00100     }

mosUser::delete ( oid = null  ) 

Reimplemented from aliroDBGeneralRow.

Definition at line 102 of file aliroUser.php.

References aliroDatabase::getInstance(), and aliroCoreDatabase::getInstance().

00102                                       {
00103         if ($oid) $this->id = intval( $oid );
00104         aliroCoreDatabase::getInstance()->doSQL("DELETE FROM `#__core_users` WHERE `id` = '$this->id'");
00105         $database = aliroDatabase::getInstance();
00106         $database->doSQL("DELETE FROM `#__users` WHERE `id` = '$this->id'");
00107         // cleanup related data from private messaging
00108         $database->setQuery( "DELETE FROM `#__messages_cfg` WHERE `user_id`='$this->id'" );
00109         $database->query();
00110         $database->setQuery( "DELETE FROM `#__messages` WHERE `user_id_to`='{$this->id}'" );
00111         $database->query();
00112         return true;
00113     }

mosUser::check (  ) 

Reimplemented from aliroDBGeneralRow.

Definition at line 115 of file aliroUser.php.

References aliroCore::get(), aliroRequest::getInstance(), aliroDatabase::getInstance(), name, and T_().

00115                             {
00116         if ($this->name == '') $error = T_('Please enter your name');
00117         elseif ($this->username == '') $error = T_('Please enter a user name');
00118         elseif (strlen($this->username) < 3 OR preg_match("/[\\<\\>\\\"\\'\\%\\;\\(\\)\\&\\+\\-]/", $this->username)) $error = sprintf(T_('Please enter a valid %s.  No spaces, more than %d characters and containing only the characters 0-9,a-z, or A-Z'), T_('Username'), 2 );
00119         elseif (($this->email == '') OR preg_match("/[\w\.\-]+@\w+[\w\.\-]*?\.\w{1,4}/", $this->email ) == 0) $error = T_('Please enter a valid e-mail address');
00120         else {
00121             // check for existing username
00122             $database = aliroDatabase::getInstance();
00123             $database->setQuery( "SELECT COUNT(id) FROM #__users WHERE LOWER(username)=LOWER('$this->username') AND id!='$this->id'");
00124             if ($database->loadResult()) $error = T_('This username/password is already in use. Please try another.');
00125             elseif (aliroCore::get('mosConfig_uniquemail')) {
00126                 // check for existing email
00127                 $database->setQuery( "SELECT COUNT(id) FROM #__users WHERE email='$this->email' AND id!='$this->id'");
00128                 if ($database->loadResult()) $error = T_('This e-mail is already registered. If you forgot the password click on "Password Reminder" and new password will be sent to you.');
00129             }
00130         }
00131         if (isset($error)) {
00132             aliroRequest::getInstance()->setErrorMessage($error, _ALIRO_ERROR_FATAL);
00133             return false;
00134         }
00135         return true;
00136     }


Member Data Documentation

mosUser::$DBclass = 'aliroDatabase' [protected]

Definition at line 59 of file aliroUser.php.

mosUser::$tableName = '#__users' [protected]

Definition at line 60 of file aliroUser.php.

mosUser::$rowKey = 'id' [protected]

Definition at line 61 of file aliroUser.php.


The documentation for this class was generated from the following file:

Generated on Thu Apr 17 13:03:35 2008 for ALIRO by  doxygen 1.5.5