Exemplo n.º 1
0
 /**
  * Returns the array of possible user roles.
  * NOTE: used in user/index view.
  *
  * @return mixed
  */
 public static function getRolesList()
 {
     $roles = [];
     foreach (AuthItem::getRoles() as $item_name) {
         $roles[$item_name->name] = $item_name->name;
     }
     return $roles;
 }
Exemplo n.º 2
0
 public static function getCashierRole()
 {
     foreach (AuthItem::getRoles() as $item_name) {
         if ($item_name->name === 'cashier') {
             $role = $item_name->name;
         }
     }
     return $role;
 }
Exemplo n.º 3
0
 public static function assignRole($id)
 {
     Role::deleteAll(['user_id' => $id]);
     $usersCount = User::find()->count();
     $auth = Yii::$app->authManager;
     // FIRST USER
     if ($usersCount === 1) {
         $array = (array) AuthItem::getDevRole();
         foreach ($array as $key) {
             $role = $key->name;
         }
         $auth->assign($role, $id);
         return $role;
     } else {
         $array = (array) AuthItem::getParentRole();
         foreach ($array as $key) {
             $role = $key->name;
         }
         $auth->assign($role, $id);
         return $role;
     }
 }
Exemplo n.º 4
0
    ?>
                        <?php 
    echo Html::img([Yii::$app->params['avatar'], ['alt' => 'user', 'class' => 'tiny image']]);
    ?>
                    <?php 
}
?>
                </div>
                <div class="ui center aligned content">

                </div>
                <div class="extra content">
                    <div class="row">
                        <div class="col-lg-12 col-md-12 col-sm-12">
                            <?php 
foreach (AuthItem::getRoles() as $item_name) {
    ?>
                                <?php 
    $roles[$item_name->name] = ucfirst($item_name->name);
    ?>
                            <?php 
}
?>
                            <?php 
echo $form->field($role, 'item_name', ['inputTemplate' => '<label for="Role" style="font-weight: 600; color: #555;">Role</label>{input}'])->dropDownList($roles, ['class' => 'form-control pva-form-control'])->label(false);
?>
                        </div>
                    </div>
                </div>
            </div>
        </div>