本文整理汇总了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);
}
}