mirror of
https://gitee.com/zoujingli/ThinkAdmin.git
synced 2025-04-06 03:58:04 +08:00
更新数据库地址
This commit is contained in:
parent
3eade2347d
commit
a937e804b9
@ -54,79 +54,6 @@ class Menu extends BasicAdmin {
|
||||
$data = Tools::arr2table($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增编辑方法
|
||||
*/
|
||||
public function form() {
|
||||
// 读取节点列表
|
||||
if ($this->request->isGet() && $this->request->get('action') === 'nodelist') {
|
||||
$list = Db::name("SystemNode")->where(["status" => 1, "is_menu" => 1])->order("module asc,controller asc")->select();
|
||||
$new_data = [];
|
||||
foreach ($list as $value) {
|
||||
if (empty($value['pnode'])) {
|
||||
//主节点
|
||||
$new_data[$value['module']]['node'] = $value['module'];
|
||||
$new_data[$value['module']]['title'] = $value['menu_desc'];
|
||||
} elseif (substr_count($value['pnode'], ' / ') == 0) {
|
||||
//二级节点
|
||||
$new_data[$value['module']]["_sub_"][$value['controller']]["node"] = $value['pnode'];
|
||||
$new_data[$value['module']]["_sub_"][$value['controller']]["title"] = $value['menu_desc'];
|
||||
} else {
|
||||
//三级节点
|
||||
$new_data[$value['module']]["_sub_"][$value['controller']]["_sub_"][$value['method']] = array("node" => $value['node'], "title" => $value['menu_desc']);
|
||||
}
|
||||
}
|
||||
return $new_data;
|
||||
}
|
||||
// 表单操作
|
||||
$db = Db::name($this->table);
|
||||
if ($this->request->isPost()) {
|
||||
$post = $this->request->post();
|
||||
if (!isset($post['id'])) {
|
||||
if ($db->insert($post)) {
|
||||
$this->success("数据保存成功", '');
|
||||
} else {
|
||||
$this->error("数据保存失败");
|
||||
}
|
||||
} else {
|
||||
Data::save($db, $post);
|
||||
$this->success("数据保存成功");
|
||||
}
|
||||
} else {
|
||||
$id = $this->request->get('id');
|
||||
$vo = $db->where(["id" => $id, 'status' => 1])->find();
|
||||
$this->assign("vo", $vo);
|
||||
/* 去除自己的菜单及子菜单 */
|
||||
$_menus = Db::name($this->table)->where('status', '1')->order('sort ASC,id ASC')->select();
|
||||
$menus = Tools::arr2table($_menus);
|
||||
foreach ($menus as $key => &$menu) {
|
||||
$current_path = "-{$vo['pid']}-{$vo['id']}";
|
||||
if ($vo['pid'] !== '' && (stripos("{$menu['path']}-", "{$current_path}-") !== false || $menu['path'] === $current_path)) {
|
||||
unset($menus[$key]);
|
||||
}
|
||||
}
|
||||
$this->assign('menus', $menus);
|
||||
//节点列表
|
||||
$db = Db::name("SystemNode")->field('node,is_menu,menu_desc')->where('is_menu', '1')->order('node ASC');
|
||||
$nodes = parent::_list($db, false, false);
|
||||
$this->assign('nodes', $nodes['list']);
|
||||
$this->assign("title", "编辑菜单");
|
||||
return $this->fetch();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 表单数据
|
||||
*/
|
||||
protected function _form_filter() {
|
||||
if ($this->request->isGet()) {
|
||||
//节点列表
|
||||
$db = Db::name("SystemNode")->field('node,is_menu,menu_desc')->where('is_menu', '1')->order('node ASC');
|
||||
$nodes = parent::_list($db, false, false);
|
||||
$this->assign('nodes', $nodes['list']);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加菜单
|
||||
*/
|
||||
@ -157,6 +84,7 @@ class Menu extends BasicAdmin {
|
||||
* 菜单禁用
|
||||
*/
|
||||
public function forbid() {
|
||||
$this->error('请不要禁用菜单...');
|
||||
if (Data::update($this->table)) {
|
||||
$this->success("菜单禁用成功!", '');
|
||||
} else {
|
||||
|
@ -14,7 +14,7 @@ return [
|
||||
// 数据库类型
|
||||
'type' => 'mysql',
|
||||
// 服务器地址
|
||||
'hostname' => 'data.cuci.cc',
|
||||
'hostname' => 'think.ctolog.com',
|
||||
// 数据库名
|
||||
'database' => 'think.admin',
|
||||
// 用户名
|
||||
|
Loading…
x
Reference in New Issue
Block a user