更新数据库地址

This commit is contained in:
邹景立 2017-02-20 10:38:10 +08:00
parent 3eade2347d
commit a937e804b9
2 changed files with 2 additions and 74 deletions

View File

@ -54,79 +54,6 @@ class Menu extends BasicAdmin {
$data = Tools::arr2table($data); $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() { public function forbid() {
$this->error('请不要禁用菜单...');
if (Data::update($this->table)) { if (Data::update($this->table)) {
$this->success("菜单禁用成功!", ''); $this->success("菜单禁用成功!", '');
} else { } else {

View File

@ -14,7 +14,7 @@ return [
// 数据库类型 // 数据库类型
'type' => 'mysql', 'type' => 'mysql',
// 服务器地址 // 服务器地址
'hostname' => 'data.cuci.cc', 'hostname' => 'think.ctolog.com',
// 数据库名 // 数据库名
'database' => 'think.admin', 'database' => 'think.admin',
// 用户名 // 用户名