Esempio n. 1
0
 /**
  * 检查页面权限
  * @param unknown $authority        	
  * @param unknown $checkvalue        	
  * @return boolean
  */
 public function checkAuthority($authority, $checkvalue)
 {
     if (empty($authority)) {
         return false;
     }
     //超管直接返回成功
     if ($authority == '-1') {
         return true;
     }
     Doo::loadClassAt('Menu', 'default');
     $menu = new menu(DBproxy::getManage());
     $menuList = $menu->getMenuArray();
     foreach ($menuList as $key => $var) {
         if (empty($var['url'])) {
             continue;
         }
         if (strpos($var['url'], '/') !== 0) {
             continue;
         }
         $menuid = -2;
         if (strpos($var['url'], '/') === 0) {
             $first = '';
         } else {
             $first = '/';
         }
         // var_dump($_SERVER['REDIRECT_URL'] , trim('/'.Doo::conf()->adminRoute.$first.$var['url']),'<br>');
         //寻找后台菜单URL和当前URL 是否匹配。
         if ($_SERVER['REDIRECT_URL'] == trim('/' . Doo::conf()->adminRoute . $first . $var['url'])) {
             $menuid = $var['id'];
             // echo '<pre>';var_dump($_SESSION['authory'],isset($authority[$menuid]),$var);
             // var_dump($authority,$menuid,$checkvalue);die;
         }
         if (isset($authority[$menuid]) && ($authority[$menuid] & $checkvalue) == $checkvalue) {
             return true;
         }
     }
     return false;
 }
Esempio n. 2
0
 /**
  * 取得表单配置
  * @param  boolean $isInsert 1 是插入表单配置,0 是修改表单
  * @param  array   $data    修改表单时传入数组
  * @param  array   $nowUserRole    角色数组,根据此参数生成要提交的表单
  * @return array
  */
 protected function _getFormConfig($isInsert = true, $data = array(), $nowUserRole = array())
 {
     Doo::loadClassAt('DataExt', 'default');
     $dataExt = new DataExt();
     Doo::loadClassAt('Menu', 'default');
     $menu = new Menu(DBproxy::getManage());
     $perms = array();
     $menus = $menu->get_menu_formlists($perms);
     if (isset($data['perm'])) {
         $menus = $data['perm'];
     }
     $insertForm = array('method' => 'post', 'renderFormat' => 'html', 'action' => '', 'attributes' => array('id' => 'js-form', 'class' => 'form-horizontal'), 'elements' => array('errors' => array('display', array('div' => false, 'label-hide' => true, 'content' => '<div id="js-form-errors" class=""></div><div style="clear:both"></div>')), 'name' => array('text', array('label' => '操作员姓名', 'attributes' => array('class' => "m-wrap small"), 'value' => '', 'help' => '<span class="label label-warning"> *最长为30个字符</span>')), 'uname' => array('text', array('label' => '登陆账号', 'attributes' => array('class' => "m-wrap small"), 'value' => '')), 'password' => array('password', array('label' => '登陆密码', 'attributes' => array('class' => "m-wrap small"), 'value' => '')), 'password2' => array('password', array('label' => '确认密码', 'attributes' => array('class' => "m-wrap small"), 'value' => '')), 'roleid' => array('select', array('label' => '所属角色', 'multioptions' => UserController::getRoleList(), 'value' => Doo::conf()->adminRoleId)), 'is_locked' => array('select', array('label' => '账号是否被锁', 'attributes' => array('class' => 'm-wrap small'), 'multioptions' => ApplicationController::$locked, 'value' => 0)), 'is_check' => array('select', array('label' => '账号是否通过验证', 'attributes' => array('class' => 'm-wrap small'), 'multioptions' => array(0 => '未通过验证', 1 => '验证通过'), 'value' => 0)), 'mobile' => array('text', array('label' => '手机号码', 'attributes' => array('class' => 'm-wrap small'), 'value' => '', 'help' => ' 注:请输入包括国家/地区代码的手机号码。')), 'email' => array('text', array('label' => '邮箱账号', 'attributes' => array('class' => 'm-wrap small'), 'value' => ''))));
     $btnArr = $this->_btnForm();
     $insertForm['elements'] = array_merge($insertForm['elements'], $btnArr);
     if ($isInsert) {
         unset($insertForm['elements']['is_check']);
         return $insertForm;
     } else {
         // //编辑时筹码不需要修改
         // $insertForm['elements']['CasinoChips'][0] = 'display';
         // $insertForm['elements']['CasinoChips'][1]['content'] = '<label class="m-wrap text">' . $data['CasinoChips'] . '</label>';
         //编辑时登录账户不需要修改
         $insertForm['elements']['uname'][0] = 'display';
         $insertForm['elements']['uname'][1]['content'] = '<label class="m-wrap text">' . $data['uname'] . '<input type="hidden" name="uname" id="uname-element" value="' . $data['uname'] . '"> </label>';
         //修改时,不需要显示密码
         unset($insertForm['elements']['password']);
         unset($insertForm['elements']['password2']);
         // 将数据写入表单
         foreach ($data as $key => $val) {
             if (isset($insertForm['elements'][$key])) {
                 $insertForm['elements'][$key][1]['value'] = $val;
             }
         }
         return $insertForm;
     }
 }
Esempio n. 3
0
<?php

Doo::loadClassAt('Menu', 'default');
Doo::loadClassAt('Role', 'default');
Doo::loadClassAt('User', 'default');
$_SERVER['REDIRECT_URL'] = isset($_SERVER['REDIRECT_URL']) ? $_SERVER['REDIRECT_URL'] : '';
$role = new role(DBproxy::getManage());
$user = new user(DBproxy::getManage());
$data['userinfo'] = $userinfo = $user->getUserInfo();
$roles = $role->get_roles();
$data['menu'] = new menu(DBproxy::getManage());
$role_name = array();
if (!empty($userinfo['roleids'])) {
    foreach ($userinfo['roleids'] as $roleid) {
        $role_names[] = $roles[$roleid];
    }
}
$role_name = $role_name_s = !empty($role_names) ? implode(', ', $role_names) : '';
if (!empty($role_names) && count($role_names) > 1) {
    $role_name_s = $role_names[0] . '...';
} else {
    $role_name_s = $role_names[0];
}
//顶部导航index
$data['top'] = isset($_GET['top']) ? $_GET['top'] : -1;
if (isset($_GET['top'])) {
    $data['top'] = $_SESSION['menu_top'] = $_GET['top'];
} else {
    $data['top'] = isset($_SESSION['menu_top']) ? $_SESSION['menu_top'] : $data['menu']->getTop();
}
$data['role_name_s'] = $role_name_s;
Esempio n. 4
0
 /**
  * 取得表单配置
  * @param  boolean $isInsert 1 是插入表单配置,0 是修改表单
  * @param  array   $data    修改表单时传入数组
  * @return array
  */
 protected function _getFormConfig($isInsert = true, $data = array(), $info = array())
 {
     Doo::loadClassAt('DataExt', 'default');
     $dataExt = new DataExt();
     Doo::loadClassAt('Menu', 'default');
     $menu = new menu(DBproxy::getManage());
     // 		D($info);
     $name = isset($info['menu_name']) ? $info['menu_name'] : '';
     $typeId = isset($info['type_id']) ? $info['type_id'] : 0;
     $sortId = isset($info['sort_id']) ? $info['sort_id'] : 0;
     $permId = isset($info['perm_id']) ? $info['perm_id'] : 0;
     //权限换算
     $permList = $menu->getMenuList($permId);
     $isShow = isset($info['is_show']) ? $info['is_show'] : 1;
     $pageUrl = isset($info['page_url']) ? $info['page_url'] : '';
     $parentId = isset($info['parent_id']) ? $info['parent_id'] : 0;
     $sep = isset($info['_sep']) ? $info['_sep'] : '';
     $menuRecursStr = $menu->getParentidTree(0);
     $list = array();
     $list[0] = '顶层菜单';
     foreach ($data as $row => $rowData) {
         if ($rowData['type_id'] == 1) {
             continue;
         }
         $sep = substr($rowData['_sep'], 1);
         if ($sep != '') {
             $sep = str_replace('.', '&nbsp;&nbsp;&nbsp;&nbsp;', $sep);
             $dot = '└─';
             if (isset($data[$row + 1])) {
                 if ($data[$row + 1]['parent_id'] == $rowData['parent_id']) {
                     $dot = '├─';
                 }
             }
             //$sep = $sep.$dot;
             //$dot = '';
         } else {
             $dot = '├─';
         }
         $sep = $sep . $dot;
         $dot = '';
         $list[$rowData['id']] = $sep . $rowData['menu_name'];
     }
     $insertForm = array('method' => 'post', 'renderFormat' => 'html', 'action' => '', 'attributes' => array('id' => 'js-form', 'class' => 'form-horizontal'), 'elements' => array('errors' => array('display', array('div' => false, 'label-hide' => true, 'content' => '<div id="js-form-errors" class=""></div><div style="clear:both"></div>')), 'parent_id' => array('select', array('label' => '父类标识:', 'attributes' => array('class' => "m-wrap"), 'multioptions' => $list, 'value' => $parentId)), 'type_id' => array('select', array('label' => '菜单类型:', 'attributes' => array('class' => "m-wrap"), 'multioptions' => array(1 => '页面', 2 => '分类'), 'value' => $typeId)), 'menu_name' => array('text', array('label' => '菜单名称:', 'attributes' => array('class' => "m-wrap"), 'value' => $name, 'help' => '必填项')), 'page_url' => array('text', array('label' => '菜单地址:', 'attributes' => array('class' => "m-wrap"), 'value' => $pageUrl, 'help' => '必填项')), 'permission' => array('MultiCheckbox', array('label' => '菜单权限:', 'multioptions' => PageAuth::getDefined(), 'value' => $permList, 'help' => '<span class="label-warning label">修改菜单地址时将自动勾选</span>')), 'sort_id' => array('text', array('label' => '排序标识:', 'attributes' => array('class' => "m-wrap"), 'value' => $sortId, 'help' => '必填项')), 'is_show' => array('MultiRadio', array('label' => '是否显示:', 'multioptions' => array(1 => '是', 0 => '否'), 'value' => array($isShow))), 'saveAndReutrn' => array('button', array('div' => false, 'left' => '<div class="form-actions js-submitButton">', 'label' => '<i class="icon-arrow-left"></i>保存&返回', 'attributes' => array('class' => "btn blue"), 'value' => 1)), 'saveAndAdd' => array('button', array('div' => false, 'left' => ' ', 'label' => '<i class="icon-plus"></i>保存&新增', 'attributes' => array('class' => "btn blue"), 'value' => 1)), 'cancel' => array('display', array('div' => false, 'left' => ' ', 'content' => '<a class="btn" href="' . $_SERVER['REQUEST_URI'] . '"><i class="icon-undo"></i>取消</a>')), 'cancelAndReturn' => array('display', array('div' => false, 'left' => ' ', 'right' => '</div>', 'content' => '<a class="btn" href="' . MenuController::$dataTableUrl . '"><i class="icon-arrow-left"></i>取消&返回</a>'))));
     if ($isInsert) {
         return $insertForm;
     } else {
         // 将数据写入表单
         foreach ($data as $key => $val) {
             if (isset($insertForm['elements'][$key])) {
                 $insertForm['elements'][$key][1]['value'] = $val;
             }
         }
         return $insertForm;
     }
 }
Esempio n. 5
0
 public function beforeRun($resource, $action)
 {
     header("Content-type:text/html;charset=utf-8");
     parent::beforeRun($resource, $action);
     Doo::loadClassAt('User', 'default');
     $this->_user = new User(DBproxy::getManage());
     $this->_pageAuth = new PageAuth();
     $this->_action = $action;
     if ($this->_checkIsLogin) {
         if (!$this->_user->isLogin()) {
             $this->notLoginPage();
             exit;
         }
     } else {
         $this->_checkPageAuth = TRUE;
         // 关闭登录验证时,自动关闭页面权限验证
     }
     if ($this->_checkPageAuth) {
         $this->_currentPageAuth = isset($this->_checkActionAuthList[$action]) ? $this->_checkActionAuthList[$action] : $this->_checkActionAuthList['notauth'];
         if (!$this->_pageAuth->auth($this->_currentPageAuth)) {
             $this->notAuthPage();
             exit;
         }
     }
     $this->_pageTitle = Doo::conf()->siteName;
     $this->_opname = $this->_user->getUsername();
     $this->init();
 }
Esempio n. 6
0
 public function mod()
 {
     $id = (int) $this->getUrlVar('id');
     Doo::loadClassAt('Role', 'default');
     $role = new role();
     $data = $role->get_one($id);
     if (empty($data)) {
         $this->alert('没有找到数据');
         return;
     }
     if ($this->isAjax() && $_POST) {
         $v = Doo::loadHelper('DooValidator', true);
         $success = true;
         $errors = array();
         //D($postData);
         $rules = array('name' => array(array('required', "请填写角色名"), array('minlength', 2, "角色名最少长度不允许少于2个字节"), array('maxlength', 12, "角色名最大长度不允许大于12个字节")), 'perm' => array(array('required', "请勾选角色权限")));
         // 验证数据
         if ($errors = $v->validate($_POST, $rules)) {
             $success = false;
         }
         // 插入角色数据
         if ($success) {
             $role = Doo::loadClass('Role', true);
             $_POST['id'] = $id;
             list($success, $errors) = array_values($role->update($_POST));
         }
         // 处理返回路径
         if ($success) {
             if (isset($_POST['saveAndReutrn'])) {
                 $errors = RoleController::$dataTableUrl;
             } else {
                 if (isset($_POST['saveAndSee'])) {
                     $errors = RoleController::$modUrl . $errors;
                 } else {
                     $errors = RoleController::$addUrl;
                 }
             }
         }
         $this->ajaxFormResult($success, $errors);
     } else {
         Doo::loadClassAt('html/DooFormExt', 'default');
         Doo::loadClassAt('Menu', 'default');
         $menu = new Menu(DBproxy::getManage());
         $perms = $role->get_role_perm($id);
         $menus = $menu->get_menu_formlists($perms);
         // 引入树状css
         array_push($this->_includeCssFileList, 'css/tree.css');
         $form = new DooFormExt(array('method' => 'post', 'renderFormat' => 'html', 'action' => '', 'attributes' => array('id' => 'js-form', 'class' => 'form-horizontal'), 'elements' => array('errors' => array('display', array('div' => false, 'label' => false, 'content' => '<div id="js-form-errors" class=""></div><div style="clear:both"></div>')), 'name' => array('text', array('label' => '角色名', 'attributes' => array('class' => "m-wrap"), 'value' => $data[0]['name'])), 'menus' => array('display', array('label' => '菜单', 'content' => '<div style="width:800px;height:500px;overflow-y:auto;" class="tree-wrapper">' . $menus . '</div>')), 'saveAndReutrn' => array('button', array('div' => false, 'left' => '<div class="form-actions js-submitButton">', 'label' => '<i class="icon-arrow-left"></i>保存&返回', 'attributes' => array('class' => "btn blue"), 'value' => 1)), 'saveAndSee' => array('button', array('div' => false, 'left' => ' ', 'label' => '保存&查看<i class="icon-arrow-right"></i>', 'attributes' => array('class' => "btn blue"), 'value' => 1)), 'cancelAndReturn' => array('display', array('div' => false, 'left' => ' ', 'right' => '</div>', 'content' => '<a class="btn" href="' . RoleController::$dataTableUrl . '"><i class="icon-arrow-left"></i>取消&返回</a>')))));
         $this->contentlayoutRender($form->render());
     }
 }