本文整理匯總了PHP中User_Model::auth_data方法的典型用法代碼示例。如果您正苦於以下問題:PHP User_Model::auth_data方法的具體用法?PHP User_Model::auth_data怎麽用?PHP User_Model::auth_data使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類User_Model
的用法示例。
在下文中一共展示了User_Model::auth_data方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: loadUser
/**
* Load data of an user into the $auth_data static var
*
* @param string $username User name
* @return boolean True on success, false on failure
*/
public function loadUser($username)
{
$users = DB::select('
SELECT u.*, s.firstname, s.lastname, s.student_number, s.promo
FROM users u
LEFT JOIN students s ON s.username = u.username
WHERE u.username = ?
', array($username));
if (isset($users[0])) {
User_Model::$auth_data = $users[0];
} else {
throw new Exception('User not found');
}
//permet de checker l'autenticit� de l'admin
if (isset(User_Model::$auth_data['admin']) && User_Model::$auth_data['admin'] == 1) {
if (Cache::read('auth_admin')) {
Cache::delete('auth_admin');
}
Cache::write('auth_admin', 1, 3600);
}
// If the user is a student
if (isset(User_Model::$auth_data['student_number'])) {
// Avatar
User_Model::$auth_data['avatar_url'] = Student_Model::getAvatarURL(User_Model::$auth_data['student_number'], true);
User_Model::$auth_data['avatar_big_url'] = Student_Model::getAvatarURL(User_Model::$auth_data['student_number'], false);
}
}
示例2: loadUser
/**
* Load data of an user into the $auth_data static var
*
* @param string $username User name
* @return boolean True on success, false on failure
*/
public function loadUser($username)
{
$users = DB::select('
SELECT u.*, s.firstname, s.lastname, s.student_number, s.promo
FROM users u
LEFT JOIN students s ON s.username = u.username
WHERE u.username = ?
', array($username));
if (isset($users[0])) {
User_Model::$auth_data = $users[0];
} else {
throw new Exception('User not found');
}
// If the user is a student
if (isset(User_Model::$auth_data['student_number'])) {
// Avatar
User_Model::$auth_data['avatar_url'] = Student_Model::getAvatarURL(User_Model::$auth_data['student_number'], true);
User_Model::$auth_data['avatar_big_url'] = Student_Model::getAvatarURL(User_Model::$auth_data['student_number'], false);
}
}