Exemplo n.º 1
0
 /**
  * 供应商菜单角色授权
  */
 public function provider_authorizeAct()
 {
     //角色ID
     if (IS_POST) {
         $roleid = intval(I("post.roleid"));
         if (!$roleid) {
             $this->error("需要授权的角色不存在!");
         }
         if (is_array($_POST['menuid']) && count($_POST['menuid']) > 0) {
             C('TOKEN_ON', false);
             $addauthorize = array();
             //检测数据合法性
             foreach ($_POST['menuid'] as $menuid) {
                 $info = array();
                 $info['role_id'] = $roleid;
                 $info['sys_menu_id'] = $menuid;
                 $info['ctime'] = time();
                 $info['mtime'] = time();
                 $data = D('SysRoleMenu')->create($info);
                 if (!$data) {
                     $this->error(D('SysRoleMenu')->getError());
                 } else {
                     $addauthorize[] = $data;
                 }
             }
             C('TOKEN_ON', true);
             if (!$roleid || !$addauthorize || !is_array($addauthorize)) {
                 $this->error("授权失败!");
             }
             //删除旧的权限
             D('SysRoleMenu')->where(array("role_id" => $roleid))->delete();
             $res = D('SysRoleMenu')->addAll($addauthorize);
             if ($res) {
                 $this->success("授权成功!", UC("Rbac/index"));
             } else {
                 $this->error("授权失败!");
             }
         } else {
             //当没有数据时,清除当前角色授权
             D('SysRoleMenu')->where(array("role_id" => $roleid))->delete();
             $this->error("没有接收到数据,执行清除授权成功!");
         }
     } else {
         $roleid = intval(I("get.id"));
         if (!$roleid) {
             $this->error("参数错误!");
         }
         $menu = new p\Tree();
         $menu->icon = array('│ ', '├─ ', '└─ ');
         $menu->nbsp = '   ';
         $result = D('SysMenu')->order(array("listorder" => "ASC"))->select();
         $newmenus = array();
         $priv_data = D('SysRoleMenu')->where(array("role_id" => $roleid))->getField('sys_menu_id', true);
         //获取权限表数据
         foreach ($result as $m) {
             $newmenus[$m['id']] = $m;
         }
         foreach ($result as $n => $t) {
             $result[$n]['checked'] = in_array($t['id'], $priv_data) ? ' checked' : '';
             $result[$n]['level'] = $this->_get_level($t['id'], $newmenus);
             $result[$n]['parentid_node'] = $t['parentid'] ? ' class="child-of-node-' . $t['parentid'] . '"' : '';
         }
         $str = "<tr id='node-\$id' \$parentid_node>\r\n                       <td style='padding-left:30px;'>\$spacer<input type='checkbox' name='menuid[]' value='\$id' level='\$level' \$checked onclick='javascript:checknode(this);'> \$name</td>\r\n\t    \t\t\t</tr>";
         $menu->init($result);
         $categorys = $menu->get_tree(0, $str);
         $this->assign('base', __BASE__);
         $this->assign("categorys", $categorys);
         $this->assign("roleid", $roleid);
         $this->display();
     }
 }
 public function editSortAct()
 {
     $sortid = intval(I("sortid"));
     if (IS_POST) {
         //有效时间
         if ($_POST['endday']) {
             $time = explode('-', $_POST['endday']);
             $_POST['b_time'] = strtotime($time[0] . ' 00:00:00');
             $_POST['e_time'] = strtotime($time[1] . ' 23:59:59');
         }
         $data = D("Card")->create();
         if ($data) {
             if (D("Card")->save($data) !== false) {
                 $this->success("修改成功!");
             } else {
                 $this->error("修改失败!");
             }
         } else {
             $this->error('修改失败');
         }
     } else {
         $info = D('Category')->where(array('sortid' => $sortid))->find();
         $info = string_gb2312_to_utf8($info);
         $this->assign('info', $info);
         $sortTree = D('Category')->sortTree();
         $this->assign('sortTree', $sortTree);
         $result = D("Category")->field('sortid,parentid,sortname')->order(array("sortdir" => "ASC"))->select();
         $result = string_gb2312_to_utf8($result);
         $tree = new p\Tree();
         $parentid = intval(I("get.parentid"));
         foreach ($result as $r) {
             $r['selected'] = $r['id'] == $parentid ? 'selected' : '';
             $array[] = $r;
         }
         $str = "<option value='\$sortid' \$selected>\$spacer \$sortname</option>";
         $tree->init($array);
         $select_categorys = $tree->get_tree(0, $str);
         $this->assign("select_categorys", $select_categorys);
         $this->assign('jumpurl', UC("Category/editSort"));
     }
     $this->display();
 }
Exemplo n.º 3
0
 /**
  *  编辑菜单
  */
 public function menu_editAct()
 {
     if (IS_POST) {
         if (D("Menu")->create()) {
             if (D("Menu")->save() !== false) {
                 $this->_admin_log(I('post.id'), '编辑菜单', "成功!");
                 $this->success("更新成功!", UC("Menu/index"));
             } else {
                 $this->_admin_log(I('post.id'), '编辑菜单', "失败!");
                 $this->error("更新失败!");
             }
         } else {
             $this->_admin_log(I('post.id'), '编辑菜单', "失败!" . D("Menu")->getError());
             $this->error(D("Menu")->getError());
         }
     } else {
         $id = intval(I("get.id"));
         if (!$id) {
             $this->error('编辑项不存在!');
         }
         $rs = D("Menu")->where(array("id" => $id))->find();
         $result = D("Menu")->field('id,name,parentid')->order(array("listorder" => "ASC"))->select();
         $tree = new p\Tree();
         foreach ($result as $r) {
             $r['selected'] = $r['id'] == $rs['parentid'] ? 'selected' : '';
             $array[] = $r;
         }
         $str = "<option value='\$id' \$selected>\$spacer \$name</option>";
         $tree->init($array);
         $select_categorys = $tree->get_tree(0, $str);
         $this->assign("info", $rs);
         $this->assign("select_categorys", $select_categorys);
         $this->assign("headline", "编辑菜单");
         $this->assign("action_name", ACTION_NAME);
         $this->display("Menu:menu_oper");
     }
 }
 /**
  * 编辑
  */
 public function editAct()
 {
     $id = intval(I("id"));
     if (IS_POST) {
         $sort = D('WstSort')->where(array('sortid' => $_POST['sortid']))->find();
         $_POST['ldid'] = $_POST['leader'] ? implode(',', $_POST['leader']) : 0;
         $_POST['pid'] = $sort['parentid'];
         $_POST['tid'] = $sort['treedid'];
         $data = D("WstContent")->create();
         if ($data) {
             $data = string_utf8_to_gb2312($data);
             if (D("WstContent")->save($data) !== false) {
                 $this->success("修改成功!");
             } else {
                 $this->error("修改失败!");
             }
         } else {
             $this->error('"修改失败!"');
         }
     } else {
         if (!$id) {
             $this->error("非法操作!");
         }
         $data = D("WstContent")->getObject($id);
         if (!$data) {
             $this->error("该角色不存在!");
         }
         //树状栏目
         $result = D("WstSort")->field('sortid as id,sortname as name,parentid')->order(array("sortid" => "ASC"))->select();
         $result = string_gb2312_to_utf8($result);
         $tree = new p\Tree();
         foreach ($result as $r) {
             $r['selected'] = $r['id'] == $data['sortid'] ? 'selected' : '';
             $array[] = $r;
         }
         $str = "<option value='\$id' \$selected>\$spacer \$name</option>";
         $tree->init($array);
         $select_categorys = $tree->get_tree(0, $str);
         $this->assign("select_categorys", $select_categorys);
         //上传图片
         $img_upload = unifile_upload(array('name' => 'picture', 'content' => $data['picture'], 'table' => 'WstContent', 'p_key' => 'articleid', 'field_name' => 'picture'));
         $this->assign('img_upload', $img_upload);
         //编辑器
         $keditor = keditor(array('name' => 'content', 'content' => $data['content']));
         $this->assign('keditor', $keditor);
         //领导
         $leader = D('WstLd')->getContent($data['ldid']);
         $this->assign('leader', $leader);
         //领导子站
         $leaderSort = D('WstLdSort')->getContent();
         $this->assign('leaderSort', $leaderSort);
         //获取处室
         $chushi = D('WstScks')->getNewChushi();
         $this->assign('chushi', $chushi);
         //处室栏目
         $cslanmu = D('WstSort')->getChushiSort($data['scks']);
         $this->assign('cslanmu', $cslanmu);
         $this->assign('actionName', ACTION_NAME);
         $this->assign("info", $data);
         $this->display("Article:add");
     }
 }