Пример #1
0
 /**
  * Constructor
  *
  * Initializes a TIP_User instance and performs the user authentication.
  *
  * Notice in this constructor no external modules can be called, because
  * many of them (if not all) depend on TIP_User. So the eventual errors
  * are stored in the $_constructor_error private property and processed
  * in the postConstructor() method.
  *
  * @param array $options Properties values
  */
 protected function __construct($options)
 {
     parent::__construct($options);
     $this->keys['CID'] = null;
     // Get user id and password from the TIP_User cookie
     @(list($id, $password) = explode(',', TIP::getCookie('TIP_User', 'string'), 2));
     if (is_null($id) || is_null($password)) {
         // Anonymous access
         return;
     }
     // Get user id and password from the data source: this view is
     // never ended to keep the current user as default row
     $view = $this->startDataView($this->data->rowFilter((int) $id));
     if (is_null($view)) {
         $this->_constructor_error = 'select';
         return;
     }
     $this->_row =& $view->current();
     if (is_null($this->_row)) {
         // User id not found in the data source
         $this->_constructor_error = 'notfound';
     } elseif (crypt($this->_row['password'], $password) != $password) {
         // Invalid password
         $this->_constructor_error = 'denied';
     }
 }