diff --git a/Application/Admin/Controller/AdminController.class.php b/Application/Admin/Controller/AdminController.class.php index bc4fcf5f5..1031054a3 100644 --- a/Application/Admin/Controller/AdminController.class.php +++ b/Application/Admin/Controller/AdminController.class.php @@ -210,17 +210,22 @@ class AdminController extends Controller { * * @author 朱亚杰 */ - final protected function editRow ( $model ,$data, $where , $msg ){ + final protected function editRow ( $model ,$data, $where , $msg = [] , $is_subsite = false){ $id = array_unique((array)I('id',0)); $id = is_array($id) ? implode(',',$id) : $id; + if( $is_subsite ) { + $Model = SM($model); + }else { + $Model = M($model); + } //如存在id字段,则加入该条件 - $fields = D($model)->getDbFields(); + $fields = $Model->getDbFields(); if(in_array('id',$fields) && !empty($id)){ $where = array_merge( array('id' => array('in', $id )) ,(array)$where ); } $msg = array_merge( array( 'success'=>'操作成功!', 'error'=>'操作失败!', 'url'=>'' ,'ajax'=>IS_AJAX) , (array)$msg ); - if( D($model)->where($where)->save($data)!==false ) { + if( $Model->where($where)->save($data)!==false ) { $this->success($msg['success'],$msg['url'],$msg['ajax']); }else{ $this->error($msg['error'],$msg['url'],$msg['ajax']); diff --git a/Application/Admin/Controller/MenuController.class.php b/Application/Admin/Controller/MenuController.class.php index ca2e39d85..41e300d12 100644 --- a/Application/Admin/Controller/MenuController.class.php +++ b/Application/Admin/Controller/MenuController.class.php @@ -27,11 +27,11 @@ class MenuController extends AdminController { } $title = trim(I('get.title')); $type = C('CONFIG_GROUP_LIST'); - $all_menu = M('Menu')->getField('id,title'); + $all_menu = SM('Menu')->getField('id,title'); $map['pid'] = $pid; if($title) $map['title'] = array('like',"%{$title}%"); - $list = M("Menu")->where($map)->field(true)->order('sort asc,id asc')->select(); + $list = SM("Menu")->where($map)->field(true)->order('sort asc,id asc')->select(); int_to_string($list,array('hide'=>array(1=>'是',0=>'否'),'is_dev'=>array(1=>'是',0=>'否'))); if($list) { @@ -45,15 +45,11 @@ class MenuController extends AdminController { } // 记录当前列表页的cookie Cookie('__forward__',$_SERVER['REQUEST_URI']); - $this->meta_title = '菜单列表'; - - $this->m_title = '菜单管理'; - $url = 'Menu/index'; - $this->m_url = $url; - $this->assign('commonset',M('Kuaijieicon')->where(['url'=>$url,'status'=>1])->find()); - - + $this->m_title = '菜单管理'; + $url = 'Menu/index'; + $this->m_url = $url; + $this->assign('commonset',M('Kuaijieicon')->where(['url'=>$url,'status'=>1])->find()); $this->display(); } @@ -63,7 +59,7 @@ class MenuController extends AdminController { */ public function add(){ if(IS_POST){ - $Menu = D('Menu'); + $Menu = SM('Menu'); $data = $Menu->create(); if($data){ $id = $Menu->add(); @@ -80,17 +76,16 @@ class MenuController extends AdminController { } } else { $this->assign('info',array('pid'=>I('pid'))); - $menus = M('Menu')->field(true)->select(); + $menus = SM('Menu')->field(true)->select(); $menus = D('Common/Tree')->toFormatTree($menus); $menus = array_merge(array(0=>array('id'=>0,'title_show'=>'顶级菜单')), $menus); $this->assign('Menus', $menus); $this->meta_title = '新增后台菜单'; - $this->m_title = '菜单管理'; - $url = 'Menu/index'; - $this->m_url = $url; - $this->assign('commonset',M('Kuaijieicon')->where(['url'=>$url,'status'=>1])->find()); - + $this->m_title = '菜单管理'; + $url = 'Menu/index'; + $this->m_url = $url; + $this->assign('commonset',M('Kuaijieicon')->where(['url'=>$url,'status'=>1])->find()); $this->display('edit'); } @@ -102,7 +97,7 @@ class MenuController extends AdminController { */ public function edit($id = 0){ if(IS_POST){ - $Menu = D('Menu'); + $Menu = SM('Menu'); $data = $Menu->create(); if($data){ if($Menu->save()!== false){ @@ -119,8 +114,8 @@ class MenuController extends AdminController { } else { $info = array(); /* 获取数据 */ - $info = M('Menu')->field(true)->find($id); - $menus = M('Menu')->field(true)->select(); + $info = SM('Menu')->field(true)->find($id); + $menus = SM('Menu')->field(true)->select(); $menus = D('Common/Tree')->toFormatTree($menus); $menus = array_merge(array(0=>array('id'=>0,'title_show'=>'顶级菜单')), $menus); @@ -131,11 +126,10 @@ class MenuController extends AdminController { $this->assign('info', $info); $this->meta_title = '编辑后台菜单'; - $this->m_title = '菜单管理'; - $url = 'Menu/index'; - $this->m_url = $url; - $this->assign('commonset',M('Kuaijieicon')->where(['url'=>$url,'status'=>1])->find()); - + $this->m_title = '菜单管理'; + $url = 'Menu/index'; + $this->m_url = $url; + $this->assign('commonset',M('Kuaijieicon')->where(['url'=>$url,'status'=>1])->find()); $this->display(); } @@ -153,7 +147,7 @@ class MenuController extends AdminController { } $map = array('id' => array('in', $id) ); - if(M('Menu')->where($map)->delete()){ + if(SM('Menu')->where($map)->delete()){ session('ADMIN_MENU_LIST',null); //记录行为 action_log('update_menu', 'Menu', $id, UID); @@ -165,12 +159,12 @@ class MenuController extends AdminController { public function toogleHide($id,$value = 1){ session('ADMIN_MENU_LIST',null); - $this->editRow('Menu', array('hide'=>$value), array('id'=>$id)); + $this->editRow('Menu', array('hide'=>$value), array('id'=>$id),[],true); } public function toogleDev($id,$value = 1){ session('ADMIN_MENU_LIST',null); - $this->editRow('Menu', array('is_dev'=>$value), array('id'=>$id)); + $this->editRow('Menu', array('is_dev'=>$value), array('id'=>$id),[],true); } public function importFile($tree = null, $pid=0){ @@ -178,7 +172,7 @@ class MenuController extends AdminController { $file = APP_PATH."Admin/Conf/Menu.php"; $tree = require_once($file); } - $menuModel = D('Menu'); + $menuModel = SM('Menu'); foreach ($tree as $value) { $add_pid = $menuModel->add( array( @@ -200,7 +194,7 @@ class MenuController extends AdminController { if(IS_POST){ $tree = I('post.tree'); $lists = explode(PHP_EOL, $tree); - $menuModel = M('Menu'); + $menuModel = SM('Menu'); if($lists == array()){ $this->error('请按格式填写批量导入的菜单,至少一个菜单'); }else{ @@ -227,13 +221,13 @@ class MenuController extends AdminController { $this->meta_title = '批量导入后台菜单'; $pid = (int)I('get.pid'); $this->assign('pid', $pid); - $data = M('Menu')->where("id={$pid}")->field(true)->find(); + $data = SM('Menu')->where("id={$pid}")->field(true)->find(); $this->assign('data', $data); - $this->m_title = '菜单管理'; - $url = 'Menu/index'; - $this->m_url = $url; - $this->assign('commonset',M('Kuaijieicon')->where(['url'=>$url,'status'=>1])->find()); + $this->m_title = '菜单管理'; + $url = 'Menu/index'; + $this->m_url = $url; + $this->assign('commonset',M('Kuaijieicon')->where(['url'=>$url,'status'=>1])->find()); $this->display(); @@ -258,24 +252,21 @@ class MenuController extends AdminController { $map['pid'] = $pid; } } - $list = M('Menu')->where($map)->field('id,title')->order('sort asc,id asc')->select(); + $list = SM('Menu')->where($map)->field('id,title')->order('sort asc,id asc')->select(); $this->assign('list', $list); $this->meta_title = '菜单排序'; - $this->m_title = '菜单管理'; - $url = 'Menu/index'; - $this->m_url = $url; - $this->assign('commonset',M('Kuaijieicon')->where(['url'=>$url,'status'=>1])->find()); - - - + $this->m_title = '菜单管理'; + $url = 'Menu/index'; + $this->m_url = $url; + $this->assign('commonset',M('Kuaijieicon')->where(['url'=>$url,'status'=>1])->find()); $this->display(); }elseif (IS_POST){ $ids = I('post.ids'); $ids = explode(',', $ids); foreach ($ids as $key=>$value){ - $res = M('Menu')->where(array('id'=>$value))->setField('sort', $key+1); + $res = SM('Menu')->where(array('id'=>$value))->setField('sort', $key+1); } if($res !== false){ session('ADMIN_MENU_LIST',null);