/**
  * @inheritdoc
  */
 public function beforeAction($action)
 {
     if (!AdminUser::isLoged()) {
         if (!in_array($action->id, ['login'])) {
             if ($this->request->getIsAjax()) {
                 $this->setError('login.failed', 401);
                 $this->setResponseData('data', Url::toRoute('/admin/default/login'));
             } else {
                 $this->redirect(Url::toRoute('/admin/default/login'));
             }
         }
     } else {
         /**
          * @var $this->user \liuxy\admin\models\AdminUser
          */
         $this->user = AdminUser::getUser();
         /**
          * 校验权限
          */
         if (!AdminUser::hasPermission($this->user->id, $action->controller->route)) {
             if (!in_array($action->id, ['deny', 'login', 'logout', ''])) {
                 if ($this->request->getIsAjax()) {
                     $this->setError(Module::t('deny'), 403);
                 } else {
                     $this->redirect(Url::toRoute('/admin/default/deny'));
                 }
             }
         }
     }
     return parent::beforeAction($action);
     // TODO: Change the autogenerated stub
 }
 /**
  * 删除角色
  */
 public function actionDelete()
 {
     $id = $this->get('id', 0);
     $role = Role::findeByCache($id);
     if ($role) {
         if ($role['id'] == 1) {
             $this->setError(Module::t('error.role.power.edit'));
         } else {
             Role::deleteAll(['id' => $id]);
             RolePermission::deleteAll(['role_id' => $id]);
         }
     } else {
         $this->setError(Module::t('error.role.notexists'));
     }
 }
                <?php 
echo $form->field('pids')->hiddenInput();
?>
                <?php 
echo $form->field('name')->textInput(['placeholder' => Module::t('name')]);
?>
                <?php 
echo $form->field('description')->textInput(['placeholder' => Module::t('description')]);
?>
                <div class="form-group">
                    <div class="col-md-12">
                        <div class="portlet green-meadow box">
                            <div class="portlet-title">
                                <div class="caption">
                                    <i class="fa fa-cogs"></i><?php 
echo Module::t('role.perm.owner');
?>
                                </div>
                            </div>
                            <div class="portlet-body">
                                <div id="perm-tree" class="tree-demo" style="max-height: 200px;overflow-y:auto">
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <?php 
ActiveForm::end();
?>
            </div>
        </div>
                        <li>
                            <a href="<?php 
echo Url::toRoute('/admin/user/profile');
?>
">
                                <i class="icon-user"></i><?php 
echo Module::t('user.info');
?>
</a>
                        </li>
                        <li>
                            <a href="<?php 
echo Url::toRoute('/admin/default/logout');
?>
">
                                <i class="icon-key"></i><?php 
echo Module::t('user.logout');
?>
</a>
                        </li>
                    </ul>
                </li>
                <!-- END USER LOGIN DROPDOWN -->
            </ul>
        </div>
        <!-- END TOP NAVIGATION MENU -->
    </div>
    <!-- END HEADER INNER -->
</div>
<!-- END HEADER -->
 /**
  * 获取管理员信息
  */
 public function actionGet()
 {
     $id = $this->get('id', 0);
     $user = AdminUser::findByCache($id);
     if ($user) {
         $roles = AdminUserRole::findAllArray(['user_id' => $id]);
         if ($roles) {
             $user['roles'] = $roles;
         }
         $this->setResponseData('data', $user);
     } else {
         $this->setError(Module::t('error.user.notexists'));
     }
 }
Beispiel #6
0
echo $this->render('//layouts/sidebar-menu', ['menus' => $subMenu, 'current' => $current]);
?>
		<!-- BEGIN CONTENT -->
		<div class="page-content-wrapper">
			<div class="page-content"">

			<!-- BEGIN PAGE HEADER-->
			<div class="page-bar">
			    <ul class="page-breadcrumb">
			        <li>
			            <i class="fa fa-home"></i>
			            <a href="<?php 
echo \yii\helpers\Url::toRoute('/');
?>
"><?php 
echo Module::t('index');
?>
</a>
			            <i class="fa fa-angle-right"></i>
			        </li>
			        <?if(isset($breads)){
						$start = false;
			        	foreach ($breads as $bread) {
							?>
			        <li>
						<?
						if ($start) {?>
							<i class="fa fa-angle-right"></i>
						<?} else {
							$start = true;
						}?>
<?php

use liuxy\admin\Module;
?>
<!-- BEGIN FOOTER -->
<div class="page-footer">
    <div class="page-footer-inner"><?php 
echo Module::t('footer.copyright');
?>
</div>
    <div class="scroll-to-top">
        <i class="icon-arrow-up"></i>
    </div>
</div>
<!-- END FOOTER -->
<div class="row">
    <div class="col-md-12 page-500">
        <div class="number">
            403
        </div>
        <div class="details">
            <div class="alert alert-danger">
                <?php 
echo \liuxy\admin\Module::t('deny');
?>
            </div>
            <p>&nbsp;</p>
        </div>
    </div>
</div>
<?php

use liuxy\admin\widgets\GridTable;
use liuxy\admin\Module;
/**
 * @var $jtable \liuxy\admin\widgets\GridTable
 */
$jtable = GridTable::begin(['header' => ['id' => '#', 'text' => Module::t('name')]]);
foreach ($data as $perm) {
    $perm['id'] = substr($perm['id'], strlen('node_'), strlen($perm['id']) - strlen('node_'));
    echo $jtable->line($perm, ['pid' => $perm['id']], ['id' => ['href' => 'javascript:', 'onclick' => 'perm.get(this,\'node_' . $perm['id'] . '\')'], 'text' => ['href' => 'javascript:', 'onclick' => 'perm.get(this,\'node_' . $perm['id'] . '\')']]);
}
if ($item) {
    echo '<input type="hidden" id="goback" value="node_' . $item['parent_id'] . '"/>';
}
GridTable::end();
                <div class="form-group">
                    <label class="control-label control-label"><?php 
echo Module::t('navigation');
?>
</label>
                    <?php 
echo Radio::widget(['name' => 'is_nav', 'items' => [\liuxy\admin\models\Permission::NAV_YES => Module::t('yes'), \liuxy\admin\models\Permission::NAV_NO => Module::t('no')], 'values' => [\liuxy\admin\models\Permission::NAV_NO]]);
?>
                </div>


                <?php 
echo $form->field('description')->textInput(['placeholder' => Module::t('description')]);
?>
                <?php 
echo $form->field('icon')->textInput(['placeholder' => Module::t('description'), 'value' => 'icon-list', 'icon' => 'ace-icon fa fa-external-link', 'icon-link' => 'http://fontawesome.io/icons/', 'typehead' => true]);
?>
                <?php 
ActiveForm::end();
?>
            </div>
        </div>
    </div>
</div>
<?php 
Modal::end();
?>
<script type="text/javascript">
    _callbacks.push(function() {
        perm.init();
    });
                <?php 
echo $form->field('trd_identifier')->textInput(['placeholder' => Module::t('user.third.identifier')]);
?>

                <div class="form-group">
                    <label class="control-label control-label"><?php 
echo Module::t('role.list.title');
?>
</label>
                    <?php 
echo Checkbox::widget(['name' => 'role', 'items' => $data['roles']]);
?>
                </div>
                <div class="form-group">
                    <label class="control-label control-label"><?php 
echo Module::t('status');
?>
</label>
                    <?php 
echo Radio::widget(['name' => 'status', 'items' => $data['status'], 'values' => [1]]);
?>
                </div>



                <?php 
ActiveForm::end();
?>
            </div>
        </div>
    </div>
 /**
  * 生成分页HTML内容
  * @param $pages
  * @return string
  * @throws \Exception
  */
 public static function renderPages($pages)
 {
     $end = $pages->getOffset() + $pages->getLimit() > $pages->totalCount ? $pages->totalCount : $pages->getOffset() + $pages->getLimit();
     if ($pages->totalCount > 0) {
         $content = strtr(Module::t('gridtable.pages.title'), ['{total}' => $pages->totalCount, '{start}' => $pages->getOffset() + 1, '{end}' => $end]);
     } else {
         $content = Module::t('gridtable.norecords');
     }
     return strtr(self::PAGES, ['{pages}' => LinkPager::widget(['pagination' => $pages]), '{content}' => $content]);
 }
<?php

/**
 * Backend main page view.
 *
 * @var yii\base\View $this View
 */
use liuxy\admin\Module;
?>

<!-- BEGIN PAGE HEADER-->
<div class="page-bar">
    <ul class="page-breadcrumb">
        <li>
            <i class="fa fa-home"></i>
            <a href="index.html"><?php 
echo Module::t('admin', 'index');
?>
</a>
            <i class="fa fa-angle-right"></i>
        </li>
        <li>
            <a href="#"><?php 
echo Module::t('index.dashboard');
?>
</a>
        </li>
    </ul>
</div>
<!-- END PAGE HEADER-->
Beispiel #14
0
echo $form->field('id')->hiddenInput();
?>
                <?php 
echo $form->field('username')->textInput(['placeholder' => Module::t('user.username')]);
?>
                <?php 
echo $form->field('password')->passwordInput(['placeholder' => Module::t('user.password')]);
?>
                <?php 
echo $form->field('name')->textInput(['placeholder' => Module::t('user.name')]);
?>
                <?php 
echo Checkbox::widget(['name' => 'role', 'label' => Module::t('role.list.title'), 'items' => $data['roles']]);
?>
                <?php 
echo Radio::widget(['name' => 'status', 'label' => Module::t('status'), 'items' => $data['status'], 'values' => [1]]);
?>

                <?php 
ActiveForm::end();
?>
            </div>
        </div>
    </div>
</div>
<?php 
Modal::end();
?>
    <script type="text/javascript">
        _callbacks.push(function() {
            user.init();
 /**
  * 删除权限
  */
 public function actionDelete()
 {
     $id = $this->get('id', 0);
     if ($id == 1) {
         $this->setError(Module::t('error.perm.root.delete'));
     } else {
         $ret = Permission::remove($id);
         if (!$ret) {
             $this->setError(Module::t('error.delete'));
         }
     }
 }
Beispiel #16
0
 /**
  * Initializes the widget options.
  * This method sets the default values for various options.
  */
 protected function initOptions()
 {
     $this->options = array_merge(['class' => 'fade', 'role' => 'dialog', 'tabindex' => -1, 'aria-hidden' => 'true'], $this->options);
     Html::addCssClass($this->options, 'modal');
     if ($this->closeButton !== false) {
         $this->closeButton = array_merge(['data-dismiss' => 'modal', 'aria-hidden' => 'true', 'class' => 'close'], $this->closeButton);
     }
     if ($this->toggleButton !== false) {
         $this->toggleButton = array_merge(['data-toggle' => 'modal'], $this->toggleButton);
         if (!isset($this->toggleButton['data-target']) && !isset($this->toggleButton['href'])) {
             $this->toggleButton['data-target'] = '#' . $this->options['id'];
         }
     }
     /**
      * 初始化操作按钮
      */
     if ($this->operationButtons === false) {
         $this->operationButtons = Html::tag('button', Module::t('close'), ['data-dismiss' => 'modal', 'class' => 'btn btn-default']);
         $this->operationButtons .= Html::tag('button', Module::t('save'), ['id' => 'btn-submit', 'class' => 'btn green-meadow']);
         $this->footer = $this->operationButtons;
     }
 }
 /**
  * 无权限操作
  */
 public function actionDeny()
 {
     if ($this->request->getIsAjax()) {
         $this->setError(Module::t('deny'), 403);
     }
 }