本文整理汇总了PHP中common\models\User::isUserAdmin方法的典型用法代码示例。如果您正苦于以下问题:PHP User::isUserAdmin方法的具体用法?PHP User::isUserAdmin怎么用?PHP User::isUserAdmin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类common\models\User
的用法示例。
在下文中一共展示了User::isUserAdmin方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: behaviors
/**
* @inheritdoc
*/
public function behaviors()
{
return ['access' => ['class' => AccessControl::className(), 'only' => ['index', 'delete'], 'rules' => [['allow' => true, 'actions' => ['index', 'delete'], 'roles' => ['@'], 'matchCallback' => function () {
//Llamada al método que comprueba si es un vendedor
return \common\models\User::isUserAdmin(Yii::$app->user->identity->id);
}]]], 'verbs' => ['class' => VerbFilter::className(), 'actions' => ['delete' => ['POST']]]];
}
示例2: loginAdmin
public function loginAdmin()
{
if ($this->validate() && User::isUserAdmin($this->username)) {
return Yii::$app->user->login($this->getUser(), $this->rememberMe ? 3600 * 24 * 30 : 0);
} else {
return false;
}
}
示例3: loginAdmin
public function loginAdmin()
{
if ($this->validate() && User::isUserAdmin($this->username)) {
return Yii::$app->user->login($this->getUser(), $this->rememberMe ? 3600 * 24 * 30 : 0);
} else {
$this->addError('password', 'Incorrect username or password.');
return false;
}
}
示例4: behaviors
/**
* @inheritdoc
*/
public function behaviors()
{
return ['access' => ['class' => AccessControl::className(), 'rules' => [['actions' => ['error'], 'allow' => true, 'matchCallback' => function ($rule, $action) {
if (!User::isUserAdmin(Yii::$app->user->identity->username)) {
return $this->redirect(['../']);
} else {
return true;
}
}], ['actions' => ['logout'], 'allow' => true, 'roles' => ['@']], ['actions' => ['login', 'index'], 'allow' => true, 'roles' => ['@'], 'matchCallback' => function ($rule, $action) {
if (!User::isUserAdmin(Yii::$app->user->identity->username)) {
return $this->redirect(['../']);
} else {
return true;
}
}]]], 'verbs' => ['class' => VerbFilter::className(), 'actions' => ['logout' => ['post']]]];
}
示例5: behaviors
/**
* @inheritdoc
*/
public function behaviors()
{
return ['verbs' => ['class' => VerbFilter::className(), 'actions' => ['delete' => ['POST']]], 'access' => ['class' => AccessControl::className(), 'rules' => [['allow' => true, 'roles' => ['@'], 'matchCallback' => function ($rule, $action) {
return User::isUserAdmin(Yii::$app->user->identity->username);
}]]]];
}
示例6: behaviors
/**
* Restrict access permissions to admin user and users with auth-item 'module-controller'
* @inheritdoc
*/
public function behaviors()
{
return ['access' => ['class' => AccessControl::className(), 'rules' => [['actions' => ['index', 'view', 'create', 'update', 'delete', 'recalculate'], 'allow' => true, 'roles' => ['@'], 'matchCallback' => function ($rule, $action) {
return User::isUserAdmin(Yii::$app->user->identity->username);
}]]]];
}
示例7: isset
echo Html::encode($this->title);
?>
</title>
<?php
$this->head();
?>
</head>
<body>
<?php
$this->beginBody();
?>
<div class="wrap">
<?php
NavBar::begin(['brandLabel' => 'Origin of the Memes', 'brandUrl' => Yii::$app->homeUrl, 'options' => ['class' => 'navbar-inverse navbar-fixed-top']]);
$menuItems = [];
if (!Yii::$app->user->isGuest && User::isUserAdmin(Yii::$app->user->identity->username)) {
$menuItems = [['label' => 'Vidmage', 'items' => [['label' => 'Vidmage List', 'url' => ['/vidmage/index']], ['label' => 'Vidmage New', 'url' => ['/vidmage/create']], ['label' => 'Category', 'url' => ['/category/index']], ['label' => 'Author', 'url' => ['/author/index']], ['label' => 'Tag', 'url' => ['/tag/index']]]], ['label' => 'Meme', 'url' => ['/meme/index']], ['label' => 'Platform', 'url' => ['/platform/index']]];
}
if (Yii::$app->user->isGuest) {
$menuItems[] = ['label' => 'Login', 'url' => ['/site/login']];
} else {
$menuItems[] = ['label' => 'Logout (' . Yii::$app->user->identity->username . ')', 'url' => ['/site/logout'], 'linkOptions' => ['data-method' => 'post']];
}
$menuItems[] = ['label' => 'Frontend', 'url' => Yii::getAlias('@frontendUrl')];
echo Nav::widget(['options' => ['class' => 'navbar-nav navbar-left'], 'items' => $menuItems]);
NavBar::end();
?>
<div class="container">
<?php
echo Breadcrumbs::widget(['links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : []]);
示例8: behaviors
/**
* @inheritdoc
*/
public function behaviors()
{
return ['access' => ['class' => AccessControl::className(), 'rules' => [['actions' => ['login', 'error'], 'allow' => true], ['actions' => ['index', 'logout'], 'allow' => true, 'roles' => ['@'], 'matchCallback' => function ($rule, $action) {
return User::isUserAdmin(Yii::$app->user->identity->username);
}]]], 'verbs' => ['class' => VerbFilter::className(), 'actions' => ['logout' => ['post']]]];
}