Exemplo n.º 1
0
 public function run()
 {
     preg_match("/(^.*?)\\?|(^.*)/", $_SERVER['REQUEST_URI'], $matchs);
     $currentRoute = empty($matchs[1]) ? $matchs[2] : $matchs[1];
     //$closeUser = Yii::app()->params['close_user'];
     if ($this->allMenu) {
         $actions = Action::model()->getAllMenu();
     } else {
         $actions = Privilege::getMenu($this->userid);
     }
     //var_dump($this->userid,$actions);exit;
     $first = $second = array();
     foreach ($actions as $v) {
         if ($v['is_menu'] == 1) {
             $first[$v['aid']] = $v;
         } else {
             if ($v['is_menu'] == 2) {
                 if (!isset($second[$v['first_menu']])) {
                     $second[$v['first_menu']] = array();
                 }
                 $second[$v['first_menu']][] = $v;
             }
         }
     }
     if (empty($this->horiz)) {
         $this->render('main.views.widget.left_menu_metro', array('first' => $first, 'second' => $second));
     } else {
         $this->render('main.views.widget.horiz_menu_metro', array('first' => $first, 'second' => $second));
     }
 }
Exemplo n.º 2
0
 protected function beforeAction($action)
 {
     header("Cache-Control: no-cache, must-revalidate");
     date_default_timezone_set('PRC');
     // 登陆
     preg_match("/(^.*?)\\?|(^.*)/", $_SERVER['REQUEST_URI'], $matchs);
     $requestUrl = empty($matchs[1]) ? $matchs[2] : $matchs[1];
     // 页面title
     $actionInfo = Action::model()->find("route=:route", array(':route' => $requestUrl));
     if (!empty($actionInfo)) {
         $this->actionName = $actionInfo['aname'];
     }
     $closeUser = Yii::app()->params['close_user'];
     // 登陆限制
     if ($closeUser || ($_SERVER['REQUEST_URI'] == '/main/user/logout' || preg_match('|^/main/user/login|', $_SERVER['REQUEST_URI']) || preg_match('|^/main/user/register|', $_SERVER['REQUEST_URI']) || $requestUrl == '/site/error')) {
         return true;
     }
     // get user info
     $userInfo = Login::getLoginInfo();
     $url = urlencode($_SERVER['REQUEST_URI']);
     if (empty($userInfo)) {
         $this->redirect('/main/user/login?url=' . $url);
     }
     $this->userid = $userInfo['uid'];
     $this->userInfo = $userInfo;
     // 权限限制
     if ($userInfo['uname'] == 'superman' && !Privilege::hasPrivilege($userInfo['uid'], $requestUrl) && $requestUrl != '/site/index' && $requestUrl != '/main/user/lock') {
         return false;
     }
     return true;
 }
Exemplo n.º 3
0
 public function run()
 {
     preg_match("/(^.*?)\\?|(^.*)/", $_SERVER['REQUEST_URI'], $matchs);
     $curRoute = empty($matchs[1]) ? $matchs[2] : $matchs[1];
     $level = 1;
     $curAction = Action::model()->find("route=:route", array(":route" => $curRoute));
     $firstAction = array();
     if ($curAction['is_menu'] == 2) {
         $level = 2;
         $firstAction = Action::model()->findByPk($curAction['first_menu']);
     }
     $this->render('main.views.widget.page_title_metro', array('level' => $level, 'first' => $firstAction, 'curaction' => $curAction));
 }
 public function actionEdit()
 {
     //echo "<pre>";var_dump($_REQUEST);exit;
     $action = new Action();
     $actionInfo = array();
     $label = '';
     foreach ($_REQUEST as $k => $v) {
         $_REQUEST[$k] = trim($v);
     }
     $menutype = isset($_REQUEST['menu_type']) ? intval($_REQUEST['menu_type']) : '0';
     $whichFirstMenu = isset($_REQUEST['firstmenu']) ? intval($_REQUEST['firstmenu']) : '-1';
     $menusort = isset($_REQUEST['menusort']) ? intval($_REQUEST['menusort']) : 0;
     $firstmenus = Action::model()->findAll('is_menu=1');
     if (isset($_REQUEST['id']) && $_REQUEST['id'] != '') {
         // 修改
         $actionInfo = $action->find('aid=:id', array(':id' => $_REQUEST['id']));
         if (!empty($_REQUEST['modify'])) {
             $action->updateByPk($_REQUEST['id'], array('aname' => $_REQUEST['name'], 'route' => $_REQUEST['route'], 'is_menu' => $menutype, 'menusort' => $menusort, 'first_menu' => $whichFirstMenu));
             $this->redirect('/main/action/list');
         }
     } elseif (!empty($_REQUEST['name'])) {
         // 新增
         $actionInfo = $action->find('aname=:name or route=:route', array(':name' => $_REQUEST['name'], ':route' => $_REQUEST['route']));
         if (!empty($actionInfo)) {
             $this->render('edit', array('firstmenus' => $firstmenus, 'entity' => $actionInfo, 'label' => 'has_action'));
             exit;
         }
         if (!empty($_REQUEST['modify'])) {
             $action->aname = $_REQUEST['name'];
             $action->route = $_REQUEST['route'];
             $action->is_menu = $menutype;
             $action->first_menu = $whichFirstMenu;
             $action->menusort = $menusort;
             $action->save();
             $this->redirect('/main/action/list');
         }
         //echo "<pre>";var_dump($_REQUEST,$actionInfo);exit;
     }
     $this->render('edit', array('firstmenus' => $firstmenus, 'entity' => $actionInfo, 'label' => $label));
 }