/** * Used to vaidate a user's credentials. (uname, pass) * @param array $creds the uname and password passed in as an array. * @return bool */ function validateCredentials($creds) { $where_clause = new WhereClause('name', $creds['uname']); $where_clause->w_and('password', $creds['password']); $this->where_clause($where_clause); $user_info = $this->getOneUsingWhere(); if ($user_info != NULL) { if (is_object($user_info)) { if ($user_info->uid > 0) { $_SESSION['authed_user'] = $user_info->uid; $this->authed_user = $user_info->uid; return TRUE; } } } return FALSE; }
/** * check to see if this user has a prefs entry, and optionally create * one if they don't * *@access public *@param int $uid the uid to look for *@param bool $create automagically create prefs entry? (default:false) *@param string $auth_mod the auth mod they should be found under *@param array initial_data the initial stuff to populate prefs with. *@return bool */ public function checkUID($uid, $create = false, $auth_mod = NULL, $initial_data = NULL) { if ($auth_mod == NULL) { $auth_mod = self::$config->auth_class; } $data = array('fname' => '', 'lname' => '', 'perms' => 0, 'auth_mod' => $auth_mod, 'uid' => $uid); // for now, only set fname and lname, perms should remain 0 until set by an admin. if (is_array($initial_data)) { $data['fname'] = $initial_data['fname']; $data['lname'] = $initial_data['lname']; } API::DEBUG("[Prefs::checkUID()] " . print_r($data, true), 1); $where_tmp = new WhereClause('uid', $uid); $where_tmp->w_and('auth_mod', $auth_mod); $this->where_clause($where_tmp); $results = $this->getUsingWhere(); if (count($results) > 1) { API::DEBUG("[Prefs::checkUID()] Multiple results returned for '{$uid}' and '{$auth_mod}'."); API::DEBUG("[Prefs::checkUID()] This is bad because I am using the first one."); } if (count($results) < 1) { if ($create === TRUE) { // create the entry. $this->set_data($data, true); return TRUE; } return FALSE; } return TRUE; }
function getUserPerms($uid, $auth_mod = NULL) { if ($auth_mod == NULL) { $auth_mod = self::$config->auth_class; } $prefs = new Prefs($uid); API::DEBUG("[Perms::getUserPerms()] uid = {$uid}, auth_mod = {$auth_mod}"); $tmp_where = new WhereClause('uid', $uid); $tmp_where->w_and('auth_mod', $auth_mod); $prefs->where_clause($tmp_where); $perms = $prefs->getUsingWhere(); return $perms; }