Beispiel #1
0
 /**
  * Checks the number of entries of given login name
  *
  * @param  string $login        Loginname
  * @param  array  $optionslData Optional data
  * @return integer
  */
 public function checkLogin($login, array $optionalData = null)
 {
     $check = sprintf("\n            SELECT\n                login\n            FROM\n                %sfaquserlogin\n            WHERE\n                login = '******'", SQLPREFIX, $this->db->escapeString($login));
     $check = $this->db->query($check);
     $error = $this->db->error();
     if (strlen($error) > 0) {
         $this->errors[] = $error;
         return 0;
     }
     return $this->db->numRows($check);
 }
Beispiel #2
0
 /**
  * Counting the views of a FAQ record
  *
  * @param  integer $id id
  * @return void
  */
 public function logViews($id)
 {
     $nVisits = 0;
     $query = sprintf("\n            SELECT\n                visits\n            FROM\n                %sfaqvisits\n            WHERE\n                id = %d\n            AND\n                lang = '%s'", SQLPREFIX, $id, $this->language);
     $result = $this->db->query($query);
     if ($this->db->numRows($result)) {
         $row = $this->db->fetchObject($result);
         $nVisits = $row->visits;
     }
     if ($nVisits == 0) {
         $this->add($id);
     } else {
         $this->update($id);
     }
 }
Beispiel #3
0
 /**
  * Loads the user-data from the database and returns an
  * associative array with the fields and values.
  *
  * @param  integer $user_id User ID
  * @return bool
  */
 public function load($user_id)
 {
     $user_id = (int) $user_id;
     if ($user_id <= 0 && $user_id != -1) {
         return false;
     }
     $this->user_id = $user_id;
     $select = sprintf("\n            SELECT\n                last_modified, \n                display_name, \n                email\n            FROM\n                %sfaquserdata\n            WHERE\n                user_id = %d", SQLPREFIX, $this->user_id);
     $res = $this->db->query($select);
     if ($this->db->numRows($res) != 1) {
         return false;
     }
     $this->data = $this->db->fetch_assoc($res);
     return true;
 }
Beispiel #4
0
 /**
  * loads basic user information from the database selecting the user with
  * specified login.
  *
  * @param  string $login       Login name
  * @param  bool   $raise_error Raise error?
  * @return bool
  */
 public function getUserByLogin($login, $raise_error = true)
 {
     $select = sprintf("\n            SELECT\n                user_id,\n                login,\n                account_status\n            FROM\n                %sfaquser\n            WHERE\n                login = '******'", SQLPREFIX, $this->db->escapeString($login));
     $res = $this->db->query($select);
     if ($this->db->numRows($res) != 1) {
         if ($raise_error) {
             $this->errors[] = self::ERROR_USER_INCORRECT_LOGIN;
         }
         return false;
     }
     $user = $this->db->fetch_assoc($res);
     $this->user_id = (int) $user['user_id'];
     $this->login = (string) $user['login'];
     $this->status = (string) $user['account_status'];
     // get user-data
     if (!$this->userdata instanceof PMF_User_UserData) {
         $this->userdata = new PMF_User_UserData();
     }
     $this->userdata->load($this->getUserId());
     return true;
 }