Example #1
0
 /**
  * Logs in a user using the provided username and password.
  *
  * @return boolean whether the user is logged in successfully
  */
 public function login()
 {
     if ($this->validate() && Yii::$app->user->login($this->getUser(), $this->rememberMe ? 3600 * 24 * 30 : 0)) {
         $user = Yii::$app->user;
         if ($user->identity->className() == Tech::className() && $user->identity->reload_roles) {
             MenuHelper::invalidate();
             $user->identity->reload_roles = false;
             $user->identity->save(false);
         }
         return true;
     } else {
         return false;
     }
 }
Example #2
0
 /**
  * @inheritdoc
  */
 public function afterSave()
 {
     $authManager = Yii::$app->authManager;
     // Get a list of the user's current roles (if any)
     $oldRoles = array_keys($authManager->getRolesByUser($this->contact_id));
     // Remove entries for old roles that were unchecked
     foreach (array_diff($oldRoles, $this->roles) as $roleName) {
         $authManager->revoke($authManager->getRole($roleName), $this->contact_id);
     }
     // Insert entries for newly selected roles
     foreach (array_diff($this->roles, $oldRoles) as $roleName) {
         $authManager->assign($authManager->getRole($roleName), $this->contact_id);
     }
     MenuHelper::invalidate();
 }
 public function actionAssign($action)
 {
     $post = Yii::$app->getRequest()->post();
     $routes = $post['routes'];
     $manager = Yii::$app->getAuthManager();
     $error = [];
     if ($action == 'assign') {
         $this->saveNew($routes);
     } else {
         foreach ($routes as $route) {
             $child = $manager->getPermission($route);
             try {
                 $manager->remove($child);
             } catch (Exception $exc) {
                 $error[] = $exc->getMessage();
             }
         }
     }
     MenuHelper::invalidate();
     Yii::$app->getResponse()->format = Response::FORMAT_JSON;
     return [$this->actionRouteSearch('new', $post['search_av']), $this->actionRouteSearch('exists', $post['search_asgn']), $error];
 }
 /**
  * Assign or remove items
  * @param string $action
  * @return array
  */
 public function actionAssign()
 {
     $post = Yii::$app->getRequest()->post();
     $action = $post['action'];
     $routes = $post['routes'];
     $manager = Yii::$app->getAuthManager();
     $error = [];
     if ($action == 'assign') {
         $this->saveNew($routes);
     } else {
         foreach ($routes as $route) {
             $child = $manager->getPermission($route);
             try {
                 $manager->remove($child);
             } catch (Exception $exc) {
                 $error[] = $exc->getMessage();
             }
         }
     }
     MenuHelper::invalidate();
     Yii::$app->getResponse()->format = Response::FORMAT_JSON;
     return ['type' => 'S', 'errors' => $error];
 }
Example #5
0
?>
</head>
<body>
<?php 
$this->beginBody();
?>

<div class="wrap">
    <?php 
NavBar::begin(['brandLabel' => 'My Company', 'brandUrl' => Yii::$app->homeUrl, 'options' => ['class' => 'navbar-inverse navbar-fixed-top']]);
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']];
}
echo NavX::widget(['options' => ['class' => 'navbar-nav'], 'items' => MenuHelper::getAssignedMenu(Yii::$app->user->id), 'activateParents' => true, 'encodeLabels' => false]);
echo Nav::widget(['options' => ['class' => 'navbar-nav navbar-right'], 'items' => $menuItems, 'activateParents' => true, 'encodeLabels' => false]);
/*echo Nav::widget([
      'options' => ['class' => 'navbar-nav navbar-right'],
      'items' => MenuHelper::getAssignedMenu(Yii::$app->user->id),
  ]);*/
NavBar::end();
?>

    <div class="container">
        <?php 
echo Breadcrumbs::widget(['links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : []]);
?>
        <?php 
echo Alert::widget();
?>
 /**
  * Deletes an existing AuthItem model.
  * If deletion is successful, the browser will be redirected to the 'index' page.
  * @param  string $id
  * @return mixed
  */
 public function actionDelete($id)
 {
     $model = $this->findModel($id);
     Yii::$app->authManager->remove($model->item);
     MenuHelper::invalidate();
     return $this->redirect(['index']);
 }
Example #7
0
 /**
  * Assign or remove items
  * @param string $id
  * @param string $action
  * @return array
  */
 public function actionAssign($id, $action)
 {
     $post = Yii::$app->getRequest()->post();
     $roles = $post['roles'];
     $manager = Yii::$app->getAuthManager();
     $parent = $manager->getRole($id);
     $error = [];
     if ($action == 'assign') {
         foreach ($roles as $role) {
             $child = $manager->getRole($role);
             $child = $child ?: $manager->getPermission($role);
             try {
                 $manager->addChild($parent, $child);
             } catch (\Exception $e) {
                 $error[] = $e->getMessage();
             }
         }
     } else {
         foreach ($roles as $role) {
             $child = $manager->getRole($role);
             $child = $child ?: $manager->getPermission($role);
             try {
                 $manager->removeChild($parent, $child);
             } catch (\Exception $e) {
                 $error[] = $e->getMessage();
             }
         }
     }
     MenuHelper::invalidate();
     Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
     return [$this->actionRoleSearch($id, 'avaliable', $post['search_av']), $this->actionRoleSearch($id, 'assigned', $post['search_asgn']), $error];
 }
 /**
  * Assign or revoke assignment to user
  * @param  integer $id
  * @param  string  $action
  * @return mixed
  */
 public function actionAssign()
 {
     $post = Yii::$app->request->post();
     $id = $post['id'];
     $action = $post['action'];
     $roles = $post['roles'];
     $manager = Yii::$app->authManager;
     $error = [];
     if ($action == 'assign') {
         foreach ($roles as $name) {
             try {
                 $item = $manager->getRole($name);
                 $item = $item ?: $manager->getPermission($name);
                 $manager->assign($item, $id);
             } catch (\Exception $exc) {
                 $error[] = $exc->getMessage();
             }
         }
     } else {
         foreach ($roles as $name) {
             try {
                 $item = $manager->getRole($name);
                 $item = $item ?: $manager->getPermission($name);
                 $manager->revoke($item, $id);
             } catch (\Exception $exc) {
                 $error[] = $exc->getMessage();
             }
         }
     }
     MenuHelper::invalidate();
     Yii::$app->response->format = Response::FORMAT_JSON;
     return ['type' => 'S', 'errors' => $error];
 }
               'linkOptions' => ['data-method' => 'post']
           ],
   ],
    ]);
    NavBar::end();
* 
*/
?>
    
    <?php 
//    $logo1 = Html::img(Yii::getAlias('@web').'/images/museomoisesville.png', ['height'=>'30']);
//    $logo = Html::img('@web/gestion.png', ['width'=>'300']);
NavBar::begin(['brandLabel' => '<img src="' . \Yii::getAlias('@web') . '/images/museomoisesville.png' . ' " width="8%" style="float:left;margin-top:-7px; margin-right:10px;"><img src="' . \Yii::getAlias('@web') . '/images/gestion.png' . ' " width="320" style="float:left;">', 'brandUrl' => 'index.php?r=site/index', 'brandOptions' => ['title' => 'Gestión de Colecciones', 'style' => 'width:auto'], 'options' => ['id' => 'top-menu', 'class' => 'navbar-inverse'], 'innerContainerOptions' => ['class' => 'kv-container'], 'renderInnerContainer' => true]);
// *************************COMPONENT MenuHelper ****************************************
//the menu will be displayed according to user permissions
echo Nav::widget(['options' => ['class' => 'navbar-nav '], 'items' => MenuHelper::getAssignedMenu(Yii::$app->user->id)]);
// *************************fin component MenuHelper ****************************************
$itemsRight = [Yii::$app->user->isGuest ? ['label' => 'Ingresar', 'url' => ['/site/login']] : ['label' => 'Salir (' . Yii::$app->user->identity->username . ')', 'url' => ['/site/logout'], 'linkOptions' => ['data-method' => 'post']]];
echo NavX::widget(['options' => ['class' => 'navbar-nav navbar-right'], 'items' => $itemsRight]);
NavBar::end();
?>
    
    <?php 
foreach (Yii::$app->session->getAllFlashes() as $message) {
    ?>
        <?php 
    echo \kartik\widgets\Growl::widget(['type' => !empty($message['type']) ? $message['type'] : 'danger', 'title' => !empty($message['title']) ? Html::encode($message['title']) : 'Moisés Ville Museo', 'icon' => !empty($message['icon']) ? $message['icon'] : 'fa fa-info', 'body' => !empty($message['message']) ? Html::encode($message['message']) : ' ', 'showSeparator' => true, 'delay' => 1, 'pluginOptions' => ['delay' => !empty($message['duration']) ? $message['duration'] : 5000, 'placement' => ['from' => !empty($message['positonY']) ? $message['positonY'] : 'top', 'align' => !empty($message['positonX']) ? $message['positonX'] : 'right']]]);
    ?>
    <?php 
}
?>
Example #10
0
$menuModuleGroupTitle = Yii::t('backend', 'ADMINISTRATOR');
foreach ($moduleListsDb as $key => $module) {
    if (in_array($this->context->module->id, $moduleListsCd) && $this->context->module->id == $module->name) {
        $menuModuleGroupTitle = strtoupper($module->other_name);
        $menuModuleId = $module->menu_group_id;
    } else {
        $menuModuleId = 1;
        $menuModuleGroupTitle = Yii::t('backend', 'ADMINISTRATOR');
    }
}
$items = [['label' => Yii::t('backend', 'Dashboard'), 'icon' => '<i class="fa fa-dashboard"></i>', 'url' => ['default/index']], ['label' => $menuModuleGroupTitle, 'options' => ['class' => 'header']]];
$callback = function ($menu) {
    $data = eval($menu['data']);
    return ['label' => $menu['name'], 'url' => [$menu['route']], 'icon' => $data['icon'], 'badge' => $data['badge'], 'badgeBgClass' => $data['badgeBgClass'], 'items' => $menu['children']];
};
$itemsUsed = array_merge($items, MenuHelper::getAssignedMenu(Yii::$app->user->id, $menuModuleId, $callback));
?>
                <?php 
echo Menu::widget(['options' => ['class' => 'sidebar-menu'], 'linkTemplate' => '<a href="{url}">{icon}<span>{label}</span>{right-icon}{badge}</a>', 'submenuTemplate' => "\n<ul class=\"treeview-menu\">\n{items}\n</ul>\n", 'activateParents' => true, 'items' => $itemsUsed]);
?>
            </section>
            <!-- /.sidebar -->
        </aside>

        <!-- Right side column. Contains the navbar and content of the page -->
        <aside class="content-wrapper">
            <!-- Content Header (Page header) -->
            <section class="content-header">
                <h1>
                    <?php 
echo $this->title;
Example #11
0
    ?>
                <div class="wrapper">
                    <header class="main-header">
                        <a  class="logo bg-red">
                            <?php 
    echo Html::img('http://lukisongroup.com/favicon.ico', ['width' => '20']);
    ?>
                            <!-- LOGO -->
                            LukisonGroup
                        </a>
                           <!--  <div class="navbar-custom-menu">!-->
                                <?php 
    // echo  \yii\helpers\Json::encode($menuItems);
    if (!Yii::$app->user->isGuest) {
        //$menuItems  = MenuHelper::getAssignedMenu(Yii::$app->user->id);
        $menuItems = MenuHelper::getAssignedMenu(Yii::$app->user->id, null, $callback);
        $menuItems[] = ['label' => Icon::show('power-off'), 'url' => ['/site/logout'], 'linkOptions' => ['data-method' => 'post']];
        NavBar::begin(['brandLabel' => '<!-- Sidebar toggle button-->
                                                            <a href="#" class="sidebar-toggle" data-toggle="offcanvas" role="button">
                                                                <span class="sr-only">Toggle Navigation</span>
                                                            </a>', 'options' => ['class' => ['navbar navbar-inverse navbar-static-top', 'style' => 'background-color:#313131'], 'role' => 'button', 'style' => 'margin-bottom: 0']]);
        echo NavX::widget(['options' => ['class' => 'navbar-nav  navbar-left'], 'items' => $menuItems, 'activateParents' => true, 'encodeLabels' => false]);
        NavBar::end();
    }
    ?>
                           <!-- </div>!-->

                    </header>
                    <aside class="main-sidebar">
                        <section class="sidebar">
                            <!-- User Login -->
Example #12
0
$menuItems = [['label' => 'Home', 'url' => ['/site/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']];
}
echo Nav::widget(['options' => ['class' => 'navbar-nav navbar-right'], 'items' => $menuItems]);
NavBar::end();
?>
    <div class="body row">
        <div class="col-xs-2 col-lg-2 col-md-2 col-sm-2 sidebar">
        <?php 
echo 'menu';
?>
        <?php 
echo Nav::widget(['items' => MenuHelper::getAssignedMenu(Yii::$app->user->id)]);
?>

        </div>
        <div  class="col-sm-10 col-sm-offset-2 col-md-10 col-md-offset-2 main">
            <div class="wrap-admin">
                <?php 
echo Breadcrumbs::widget(['homeLink' => ['label' => 'Алмин', 'url' => ['//admin']], 'itemTemplate' => "<li><i>{link}</i></li>\n", 'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : []]);
?>
                <?php 
echo Alert::widget();
?>
                <?php 
echo $content;
?>
            </div>
Example #13
0
                <p>超级管理员</p>

                <a href="#"><i class="fa fa-circle text-success"></i> 在线</a>
            </div>
        </div>

        <!-- search form -->
        <form action="#" method="get" class="sidebar-form">
            <div class="input-group">
                <input type="text" name="q" class="form-control" placeholder="搜索..."/>
              <span class="input-group-btn">
                <button type='submit' name='search' id='search-btn' class="btn btn-flat"><i class="fa fa-search"></i>
                </button>
              </span>
            </div>
        </form>
        <!-- /.search form -->
        <?php 
$callback = function ($menu) {
    return ['label' => $menu['name'], 'url' => [$menu['route']], 'icon' => $menu['data'], 'items' => $menu['children']];
};
?>

        <?php 
echo dmstr\widgets\Menu::widget(['options' => ['class' => 'sidebar-menu'], 'items' => \yii\helpers\ArrayHelper::merge([['label' => '管理台菜单', 'options' => ['class' => 'header']]], \mdm\admin\components\MenuHelper::getAssignedMenu(Yii::$app->user->id, 14, $callback, true), [['label' => '管理台菜单', 'options' => ['class' => 'header']], ['label' => '测试页面', 'icon' => 'fa fa-flag-checkered', 'url' => ['/site/test']], ['label' => 'Gii', 'icon' => 'fa fa-file-code-o', 'url' => ['/gii'], 'template' => '<a href="{url}" target="_blank">{icon} {label}</a>'], ['label' => 'Debug', 'icon' => 'fa fa-dashboard', 'url' => ['/debug']], ['label' => 'Login', 'url' => Yii::$app->getHomeUrl(), 'visible' => Yii::$app->user->isGuest], ['label' => '系统管理', 'visible' => !Yii::$app->user->isGuest, 'icon' => 'fa fa-cog fa-lg fa-fw fa-spin', 'url' => '#', 'items' => [['label' => '系统使用帮助1', 'icon' => 'fa fa-question-circle', 'url' => ['/helpdoc']], ['label' => '系统使用帮助2', 'icon' => 'fa fa-question-circle', 'url' => ['/helpmenu/main']], ['label' => '系统参数配置', 'icon' => 'fa fa-wrench', 'url' => ['/preferences/index', 'per-page' => Yii::$app->params['backend.view_item_per_page']]], ['label' => '系统事件管理', 'icon' => 'fa fa-calendar', 'url' => ['/event/index']], ['label' => '系统事件管理', 'icon' => 'fa fa-calendar-plus-o', 'url' => ['/events/index']], ['label' => '系统提醒管理', 'icon' => 'fa fa-bell-o', 'url' => ['/reminders/index']], ['label' => '系统日志管理', 'icon' => 'fa fa-history', 'url' => '#', 'items' => [['label' => '系统日志审计', 'icon' => 'fa fa-hourglass-3', 'url' => ['/audit']], ['label' => '系统日志管理', 'icon' => 'fa fa-hourglass-1', 'url' => ['/log']], ['label' => '系统访问日志', 'icon' => 'fa fa-hourglass-2', 'url' => ['/request-log']]]]]]])]);
?>

    </section>

</aside>
Example #14
0
 /**
  * Deletes an existing Menu model.
  * If deletion is successful, the browser will be redirected to the 'index' page.
  * @param  integer $id
  * @return mixed
  */
 public function actionDelete($id)
 {
     $this->findModel($id)->delete();
     MenuHelper::invalidate();
     return $this->redirect(['index']);
 }
Example #15
0
<?php

use mdm\admin\components\MenuHelper;
?>

<aside class="main-sidebar">

    <section class="sidebar">

        <?php 
echo dmstr\widgets\Menu::widget(['options' => ['class' => 'sidebar-menu'], 'items' => [['label' => 'Menus', 'options' => ['class' => 'header']], ['label' => 'Gii', 'icon' => 'fa fa-file-code-o', 'url' => ['/gii']], ['label' => 'Debug', 'icon' => 'fa fa-dashboard', 'url' => ['/debug']], ['label' => 'Login', 'url' => ['site/login'], 'visible' => Yii::$app->user->isGuest], ['label' => 'Some tools', 'icon' => 'fa fa-share', 'url' => '#', 'items' => [['label' => 'Gii', 'icon' => 'fa fa-file-code-o', 'url' => ['/gii']], ['label' => 'Debug', 'icon' => 'fa fa-dashboard', 'url' => ['/debug']], ['label' => 'Level One', 'icon' => 'fa fa-circle-o', 'url' => '#', 'items' => [['label' => 'Level Two', 'icon' => 'fa fa-circle-o', 'url' => '#'], ['label' => 'Level Two', 'icon' => 'fa fa-circle-o', 'url' => '#', 'items' => [['label' => 'Level Three', 'icon' => 'fa fa-circle-o', 'url' => '#'], ['label' => 'Level Three', 'icon' => 'fa fa-circle-o', 'url' => '#']]]]]]]]]);
?>

        <?php 
function getItemsCallback($menu)
{
    return ['label' => $menu['name'], 'url' => [$menu['route']], 'icon' => json_decode($menu['data'], true)['icon'], 'items' => $menu['children']];
}
$menus = MenuHelper::getAssignedMenu(Yii::$app->user->id, null, 'getItemsCallback');
?>

        <?php 
echo dmstr\widgets\Menu::widget(['options' => ['class' => 'sidebar-menu'], "items" => $menus]);
?>

    </section>

</aside>
Example #16
0
echo Html::encode($this->title);
?>
</title>
    <?php 
$this->head();
?>
</head>
<body>
<?php 
$this->beginBody();
?>

<div class="wrap">
    <?php 
NavBar::begin(['brandLabel' => 'UTS Helpdesk <small>&alpha;lpha</small>', 'brandUrl' => Yii::$app->homeUrl, 'options' => ['class' => 'navbar-inverse navbar-fixed-top']]);
$menuItems = MenuHelper::getAssignedMenu(Yii::$app->user->id);
if (Yii::$app->user->isGuest) {
    $menuItems[] = ['label' => 'Login', 'url' => ['/site/login']];
} else {
    $menuItems[] = ['label' => Yii::$app->user->identity->username, 'items' => [['label' => 'Developer', 'url' => ['/tech/developer'], 'visible' => Yii::$app->user->can('Developer')], ['label' => 'Logout', 'url' => ['/site/logout'], 'linkOptions' => ['data-method' => 'post']]]];
}
echo Nav::widget(['options' => ['class' => 'navbar-nav navbar-right'], 'items' => $menuItems]);
NavBar::end();
?>

    <div class="container">
        <?php 
echo Breadcrumbs::widget(['links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : []]);
?>
        <?php 
echo Alert::widget();
Example #17
0
">
                            <i class="fa fa-circle text-success"></i>
                            <?php 
echo Yii::$app->formatter->asDatetime(time());
?>
                        </a>
                    </div>
                </div>
                <!-- sidebar menu: : style can be found in sidebar.less -->
                <?php 
$items = [['label' => Yii::t('backend', 'MAIN MENU'), 'options' => ['class' => 'header']], ['label' => Yii::t('backend', 'Timeline'), 'icon' => '<i class="fa fa-bar-chart-o"></i>', 'url' => ['/timeline-event/index'], 'badge' => TimelineEvent::find()->today()->count(), 'badgeBgClass' => 'label-success'], ['label' => Yii::t('backend', 'ADMINISTRATOR'), 'options' => ['class' => 'header']]];
$callback = function ($menu) {
    $data = eval($menu['data']);
    return ['label' => $menu['name'], 'url' => [$menu['route']], 'icon' => $data['icon'], 'badge' => $data['badge'], 'badgeBgClass' => $data['badgeBgClass'], 'items' => $menu['children']];
};
$items = array_merge($items, MenuHelper::getAssignedMenu(Yii::$app->user->id, 1, $callback));
?>
                <?php 
echo Menu::widget(['options' => ['class' => 'sidebar-menu'], 'linkTemplate' => '<a href="{url}">{icon}<span>{label}</span>{right-icon}{badge}</a>', 'submenuTemplate' => "\n<ul class=\"treeview-menu\">\n{items}\n</ul>\n", 'activateParents' => true, 'items' => $items]);
?>
            </section>
            <!-- /.sidebar -->
        </aside>

        <!-- Right side column. Contains the navbar and content of the page -->
        <aside class="content-wrapper">
            <!-- Content Header (Page header) -->
            <section class="content-header">
                <h1>
                    <?php 
echo $this->title;
Example #18
0
		</ul> 
		-->

		<?php 
use mdm\admin\components\MenuHelper;
$callback = function ($menu) {
    $data = json_decode($menu['data'], true);
    $items = $menu['children'];
    $return = ['label' => $menu['name'], 'url' => [$menu['route']]];
    //处理我们的配置
    if ($data) {
        //visible
        isset($data['visible']) && ($return['visible'] = $data['visible']);
        //icon
        isset($data['icon']) && $data['icon'] && ($return['icon'] = $data['icon']);
        //other attribute e.g. class...
        $return['options'] = $data;
    }
    //没配置图标的显示默认图标
    (!isset($return['icon']) || !$return['icon']) && ($return['icon'] = 'fa fa-circle-o');
    $items && ($return['items'] = $items);
    return $return;
};
//这里我们对一开始写的菜单menu进行了优化
echo dmstr\widgets\Menu::widget(['options' => ['class' => 'sidebar-menu'], 'items' => MenuHelper::getAssignedMenu(Yii::$app->user->id, null, $callback)]);
?>

    </section>

</aside>
Example #19
0
 /**
  * Assign or remove items
  * @param string $id
  * @param string $action
  * @return array
  */
 public function actionAssign()
 {
     $post = Yii::$app->getRequest()->post();
     $id = $post['id'];
     $action = $post['action'];
     $roles = $post['roles'];
     $manager = Yii::$app->getAuthManager();
     $parent = $manager->getRole($id);
     $error = [];
     if ($action == 'assign') {
         foreach ($roles as $role) {
             $child = $manager->getRole($role);
             $child = $child ?: $manager->getPermission($role);
             try {
                 $manager->addChild($parent, $child);
             } catch (\Exception $e) {
                 $error[] = $e->getMessage();
             }
         }
     } else {
         foreach ($roles as $role) {
             $child = $manager->getRole($role);
             $child = $child ?: $manager->getPermission($role);
             try {
                 $manager->removeChild($parent, $child);
             } catch (\Exception $e) {
                 $error[] = $e->getMessage();
             }
         }
     }
     MenuHelper::invalidate();
     Yii::$app->response->format = 'json';
     return ['type' => 'S', 'errors' => $error];
 }
 /**
  * Assign or revoke assignment to user
  * @param  integer $id
  * @param  string  $action
  * @return type
  */
 public function actionAssign($id, $action)
 {
     $post = Yii::$app->request->post();
     $roles = $post['roles'];
     $manager = Yii::$app->authManager;
     $error = [];
     if ($action == 'assign') {
         foreach ($roles as $role) {
             try {
                 $manager->assign($manager->getRole($role), $id);
             } catch (\Exception $exc) {
                 $error[] = $exc->getMessage();
             }
         }
     } else {
         foreach ($roles as $role) {
             try {
                 $manager->revoke($manager->getRole($role), $id);
             } catch (\Exception $exc) {
                 $error[] = $exc->getMessage();
             }
         }
     }
     MenuHelper::invalidate();
     Yii::$app->response->format = Response::FORMAT_JSON;
     return [$this->actionRoleSearch($id, 'avaliable', $post['search_av']), $this->actionRoleSearch($id, 'assigned', $post['search_asgn']), $error];
 }
Example #21
0
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']];
}
echo Nav::widget(['options' => ['class' => 'navbar-nav navbar-right'], 'items' => $menuItems]);
NavBar::end();
?>

    <div class="container-fluid">
        <?php 
echo Breadcrumbs::widget(['links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : []]);
?>
        <div class="col-xs-2">
            <?php 
echo SideNav::widget(['type' => SideNav::TYPE_DEFAULT, 'items' => \mdm\admin\components\MenuHelper::getAssignedMenu(Yii::$app->user->id)]);
?>
        </div>
        <div class="col-xs-10">
            <?php 
echo Alert::widget();
?>
        <?php 
echo $content;
?>
        </div>
    </div>
</div>

<footer class="footer">
    <div class="container">