Esempio n. 1
0
 public static function requireMinimumRole($role_name)
 {
     if (Yii::$app->user->identity->role_id >= ValueHelpers::getRoleValue($role_name)) {
         return true;
     } else {
         return false;
     }
 }
Esempio n. 2
0
 public function loginAdmin()
 {
     if ($this->validate() && $this->getUser()->role_id >= ValueHelpers::getRoleValue('Admin') && $this->getUser()->status_id == ValueHelpers::getStatusValue('Active')) {
         return Yii::$app->user->login($this->getUser(), $this->rememberMe ? 3600 * 24 * 30 : 0);
     } else {
         throw new NotFoundHttpException('You Shall Not Pass.');
     }
 }
 public static function requireMinimumRole($role_name, $userId = null)
 {
     if (ValueHelpers::isRoleNameValid($role_name)) {
         if ($userId == null) {
             $userRoleValue = ValueHelpers::getUsersRoleValue();
         } else {
             $userRoleValue = ValueHelpers::getUsersRoleValue($userId);
         }
         return $userRoleValue >= ValueHelpers::getRoleValue($role_name) ? true : false;
     } else {
         return false;
     }
 }
Esempio n. 4
0
    <title><?php 
echo Html::encode($this->title);
?>
</title>
    <?php 
$this->head();
?>
</head>
<body>
<?php 
$this->beginBody();
?>

<div class="wrap">
    <?php 
$is_admin = ValueHelpers::getRoleValue("Admin");
if (!Yii::$app->user->isGuest) {
    NavBar::begin(['brandLabel' => 'Yii 2 build <i class="fa fa-plug"></i> Admin', 'brandUrl' => Yii::$app->homeUrl, 'options' => ['class' => 'navbar-inverse navbar-fixed-top']]);
} else {
    NavBar::begin(['brandLabel' => 'Yii 2 Build <i class="fa fa-plug"></i>', 'brandUrl' => Yii::$app->homeUrl, 'options' => ['class' => 'navbar-inverse navbar-fixed-top']]);
}
$menuItems = [['label' => 'Home', 'url' => ['/site/index']]];
if (!Yii::$app->user->isGuest && Yii::$app->user->identity->role_id >= $is_admin) {
    $menuItems[] = ['label' => 'Users', 'url' => ['user/index']];
    $menuItems[] = ['label' => 'Profiles', 'url' => ['profile/index']];
    $menuItems[] = ['label' => 'Roles', 'url' => ['/role/index']];
    $menuItems[] = ['label' => 'User Types', 'url' => ['/user-type/index']];
    $menuItems[] = ['label' => 'Statuses', 'url' => ['/status/index']];
}
if (Yii::$app->user->isGuest) {
    $menuItems[] = ['label' => 'Login', 'url' => ['/site/login']];
Esempio n. 5
0
    <title><?php 
echo Html::encode($this->title);
?>
</title>

    <?php 
$this->head();
?>
</head>
<body>
<?php 
$this->beginBody();
?>
<div class="wrap">
    <?php 
$is_admin = ValueHelpers::getRoleValue('Admin');
if (!Yii::$app->user->isGuest) {
    NavBar::begin(['brandLabel' => 'Yii 2 Build <i class="fa fa-plug"></i> Admin', 'brandUrl' => Yii::$app->homeUrl, 'options' => ['class' => 'navbar-inverse navbar-fixed-top']]);
} else {
    NavBar::begin(['brandLabel' => 'Yii 2 Build <i class="fa fa-plug"></i>', 'brandUrl' => Yii::$app->homeUrl, 'options' => ['class' => 'navbar-inverse navbar-fixed-top']]);
}
$menuItems = [['label' => 'Home', 'url' => ['/site/index']]];
if (!Yii::$app->user->isGuest && Yii::$app->user->identity->role_id >= $is_admin) {
    $menuItems[] = ['label' => 'Users', 'url' => ['user/index']];
    $menuItems[] = ['label' => 'Profiles', 'url' => ['profile/index']];
    $menuItems[] = ['label' => 'Roles', 'url' => ['/role/index']];
    $menuItems[] = ['label' => 'User Types', 'url' => ['/user-type/index']];
    $menuItems[] = ['label' => 'Statuses', 'url' => ['/status/index']];
}
if (Yii::$app->user->isGuest) {
    $menuItems[] = ['label' => 'Login', 'url' => ['/site/login']];
Esempio n. 6
0
    <title><?php 
echo Html::encode($this->title);
?>
</title>
    <?php 
$this->head();
?>
</head>
<body>
<?php 
$this->beginBody();
?>

<div class="wrap">
    <?php 
$admin_id = ValueHelpers::getRoleValue('Admin');
if (!Yii::$app->user->isGuest) {
    NavBar::begin(['brandLabel' => 'Yii 2 Build <i class = "fa fa-plug"></i> Admin', 'brandUrl' => Yii::$app->homeUrl, 'options' => ['class' => 'navbar-inverse navbar-fixed-top']]);
} else {
    NavBar::begin(['brandLabel' => 'Yii 2 Build <i class = "fa fa-plug"></i>', 'brandUrl' => Yii::$app->homeUrl, 'options' => ['class' => 'navbar-inverse navbar-fixed-top']]);
}
$menuItems = [['label' => 'Home', 'url' => ['/site/index']]];
if (!Yii::$app->user->isGuest && Yii::$app->user->identity->role_id >= $admin_id) {
    $menuItems[] = ['label' => 'Users', 'url' => ['user/index']];
    $menuItems[] = ['label' => 'Profiles', 'url' => ['profile/index']];
    $menuItems[] = ['label' => 'Roles', 'url' => ['role/index']];
    $menuItems[] = ['label' => 'User Types', 'url' => ['user-type/index']];
    $menuItems[] = ['label' => 'Statuses', 'url' => ['status/index']];
}
if (Yii::$app->user->isGuest) {
    $menuItems[] = ['label' => 'Login', 'url' => ['/site/login']];