Beispiel #1
0
 /**
  * Saves the current user-data into the database.
  * Returns true on success, otherwise false.
  *
  * @return bool
  */
 public function save()
 {
     $update = sprintf("\n            UPDATE\n                %sfaquserdata\n            SET\n                last_modified = '%s',\n                display_name  = '%s',\n                email         = '%s'\n            WHERE\n                user_id = %d", SQLPREFIX, date('YmdHis', $_SERVER['REQUEST_TIME']), $this->db->escapeString($this->data['display_name']), $this->db->escapeString($this->data['email']), $this->user_id);
     $res = $this->db->query($update);
     if (!$res) {
         return false;
     }
     return true;
 }
Beispiel #2
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 #3
0
 /**
  * Creates the part for the WHERE clause
  * 
  * @param string $searchTerm Search term
  * 
  * @return string
  */
 public function getMatchClause($searchTerm = '')
 {
     $keys = PMF_String::preg_split("/\\s+/", $searchTerm);
     $numKeys = count($keys);
     $numMatch = count($this->matchingColumns);
     $where = '';
     for ($i = 0; $i < $numKeys; $i++) {
         if (strlen($where) != 0) {
             $where = $where . " OR";
         }
         $where = $where . " (";
         for ($j = 0; $j < $numMatch; $j++) {
             if ($j != 0) {
                 $where = $where . " OR ";
             }
             $where = sprintf("%s%s LIKE '%%%s%%'", $where, $this->matchingColumns[$j], $this->dbHandle->escapeString($keys[$i]));
         }
         $where .= ")";
     }
     return $where;
 }
Beispiel #4
0
 /**
  * sets the user's status and updates the database entry.
  *
  * @param  string $status Status
  * @return boolean
  */
 public function setStatus($status)
 {
     // is status allowed?
     $status = strtolower($status);
     if (!in_array($status, array_keys($this->allowed_status))) {
         $this->errors[] = self::ERROR_USER_INVALID_STATUS;
         return false;
     }
     // update status
     $this->status = $status;
     $update = sprintf("\n            UPDATE\n                %sfaquser\n            SET\n                account_status = '%s'\n            WHERE\n                user_id = %d", SQLPREFIX, $this->db->escapeString($status), $this->user_id);
     $res = $this->db->query($update);
     if ($res) {
         return true;
     }
     return false;
 }