本文整理汇总了PHP中fAuthorization::setUserAuthLevel方法的典型用法代码示例。如果您正苦于以下问题:PHP fAuthorization::setUserAuthLevel方法的具体用法?PHP fAuthorization::setUserAuthLevel怎么用?PHP fAuthorization::setUserAuthLevel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类fAuthorization
的用法示例。
在下文中一共展示了fAuthorization::setUserAuthLevel方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: User
<?php
include './resources/init.php';
if (isset($_POST['type'])) {
if ($_POST['type'] == "logout") {
fAuthorization::destroyUserInfo();
} else {
if ($_POST['type'] == "login") {
try {
$user = new User($_POST['username']);
} catch (fException $e) {
fURL::redirect(URL_ROOT . "authentication.php");
}
if (sha1($_POST['password']) == $user->getPassword()) {
fAuthorization::setUserAuthLevel($user->getLevel());
fAuthorization::setUserToken($_POST['username']);
fURL::redirect(fAuthorization::getRequestedUrl(true, URL_ROOT . "inventory.php"));
} else {
fURL::redirect(URL_ROOT . "authentication.php");
}
}
}
} else {
if (isset($_GET['type']) == "logout") {
fAuthorization::destroyUserInfo();
}
}
$tmpl->place('header');
$tmpl->place('menu');
?>
<div class="span-24 last">
示例2: UserPermission
fAuthorization::setUserAuthLevel('super');
break;
case 2:
fAuthorization::setUserAuthLevel('admin');
break;
case 3:
case 4:
case 5:
case 6:
case 7:
case 8:
fAuthorization::setUserAuthLevel('employee');
break;
case 9:
default:
fAuthorization::setUserAuthLevel('guest');
break;
}
$up = new UserPermission();
$tmp = $up->getByIdUser($u->prepareIdUser());
$permissions = array('banner' => array(), 'news' => array(), 'classified' => array(), 'social' => array(), 'poll' => array(), 'turism' => array(), 'plaza' => array(), 'autoplus' => array(), 'real' => array(), 'user' => array(), 'franchise' => array());
foreach ($tmp as $item) {
switch ($item->prepareIdPermission()) {
case 1:
$permissions['banner'][] = 'add';
break;
case 2:
$permissions['banner'][] = 'edit';
break;
case 3:
$permissions['banner'][] = 'delete';
示例3: testCheckLoggedIn2
public function testCheckLoggedIn2()
{
$this->assertEquals(FALSE, fAuthorization::checkLoggedIn());
fAuthorization::setAuthLevels(array('user' => 20, 'admin' => 50));
fAuthorization::setUserAuthLevel('admin');
$this->assertEquals(TRUE, fAuthorization::checkLoggedIn());
}
示例4: login
/**
* Attempt to login, and register through fAuthorization when successful.
*
* @throws sfNotFoundException When no user by provided username exists
* @throws sfBadPasswordException When the given password fails to match
*
* @param string $username Username for attempted login
* @param string $password Provided password to match
* @return boolean True when successful
*/
public static function login($username, $password)
{
$login_attempt = sfCore::make('sfUser');
// will throw sfNotFoundException if not available
$login_attempt->loadByUsername($username);
if (!$login_attempt->matchPassword($password)) {
throw new sfBadPasswordException();
return;
}
fAuthorization::setUserAuthLevel($login_attempt->getLevel());
fAuthorization::setUserToken($username);
static::evaluateSession();
return true;
}