更新
This commit is contained in:
@@ -7,8 +7,8 @@
|
||||
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\admin\controller;
|
||||
use app\common\controller\Admin;
|
||||
namespace app\controller\admin;
|
||||
use app\controller\Admin;
|
||||
|
||||
/**
|
||||
* @title 行为管理
|
||||
@@ -26,8 +26,8 @@ class Action extends Admin {
|
||||
$order = "id desc";
|
||||
//获取列表数据
|
||||
$list = model('Action')->where($map)->order($order)->paginate(10, false, array(
|
||||
'query' => $this->request->param()
|
||||
));
|
||||
'query' => $this->request->param(),
|
||||
));
|
||||
|
||||
// 记录当前列表页的cookie
|
||||
Cookie('__forward__', $_SERVER['REQUEST_URI']);
|
||||
@@ -47,7 +47,7 @@ class Action extends Admin {
|
||||
public function add() {
|
||||
$model = model('Action');
|
||||
if ($this->request->isPost()) {
|
||||
$data = input('post.');
|
||||
$data = input('post.');
|
||||
$result = $model->save($data);
|
||||
if (false != $result) {
|
||||
action_log('add_action', 'Action', $result, session('user_auth.uid'));
|
||||
@@ -72,7 +72,7 @@ class Action extends Admin {
|
||||
public function edit($id = null) {
|
||||
$model = model('Action');
|
||||
if ($this->request->isPost()) {
|
||||
$data = input('post.');
|
||||
$data = input('post.');
|
||||
$result = $model->save($data, array('id' => $data['id']));
|
||||
if ($result !== false) {
|
||||
action_log('edit_action', 'Action', $id, session('user_auth.uid'));
|
||||
@@ -86,7 +86,7 @@ class Action extends Admin {
|
||||
return $this->error("非法操作!");
|
||||
}
|
||||
$data = array(
|
||||
'info' => $info,
|
||||
'info' => $info,
|
||||
'keyList' => $model->fieldlist,
|
||||
);
|
||||
$this->assign($data);
|
||||
@@ -105,7 +105,7 @@ class Action extends Admin {
|
||||
return $this->error("非法操作!", '');
|
||||
}
|
||||
$map['id'] = array('IN', $id);
|
||||
$result = db('Action')->where($map)->delete();
|
||||
$result = db('Action')->where($map)->delete();
|
||||
if ($result) {
|
||||
action_log('delete_action', 'Action', $id, session('user_auth.uid'));
|
||||
return $this->success('删除成功!');
|
||||
@@ -123,10 +123,10 @@ class Action extends Admin {
|
||||
if (empty($id)) {
|
||||
return $this->error("非法操作!", '');
|
||||
}
|
||||
$status = input('get.status', '', 'trim,intval');
|
||||
$message = !$status ? '禁用' : '启用';
|
||||
$status = input('get.status', '', 'trim,intval');
|
||||
$message = !$status ? '禁用' : '启用';
|
||||
$map['id'] = array('IN', $id);
|
||||
$result = db('Action')->where($map)->setField('status', $status);
|
||||
$result = db('Action')->where($map)->setField('status', $status);
|
||||
if ($result !== false) {
|
||||
action_log('setstatus_action', 'Action', $id, session('user_auth.uid'));
|
||||
return $this->success('设置' . $message . '状态成功!');
|
||||
@@ -168,12 +168,12 @@ class Action extends Admin {
|
||||
|
||||
$info = $model::get($id);
|
||||
|
||||
$info['title'] = get_action($info['action_id'], 'title');
|
||||
$info['user_id'] = get_username($info['user_id']);
|
||||
$info['action_ip'] = long2ip($info['action_ip']);
|
||||
$info['title'] = get_action($info['action_id'], 'title');
|
||||
$info['user_id'] = get_username($info['user_id']);
|
||||
$info['action_ip'] = long2ip($info['action_ip']);
|
||||
$info['create_time'] = date('Y-m-d H:i:s', $info['create_time']);
|
||||
$data = array(
|
||||
'info' => $info,
|
||||
$data = array(
|
||||
'info' => $info,
|
||||
'keyList' => $model->keyList,
|
||||
);
|
||||
$this->assign($data);
|
||||
@@ -192,7 +192,7 @@ class Action extends Admin {
|
||||
return $this->error("非法操作!", '');
|
||||
}
|
||||
$map['id'] = array('IN', $id);
|
||||
$res = db('ActionLog')->where($map)->delete();
|
||||
$res = db('ActionLog')->where($map)->delete();
|
||||
if ($res !== false) {
|
||||
action_log('delete_actionlog', 'ActionLog', $id, session('user_auth.uid'));
|
||||
return $this->success('删除成功!');
|
||||
@@ -200,7 +200,7 @@ class Action extends Admin {
|
||||
return $this->error('删除失败!');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @title 清空日志
|
||||
*/
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\admin\controller;
|
||||
use app\common\controller\Admin;
|
||||
namespace app\controller\admin;
|
||||
use app\controller\Admin;
|
||||
|
||||
/**
|
||||
* @title 广告管理
|
||||
@@ -21,7 +21,7 @@ class Ad extends Admin {
|
||||
|
||||
public function _initialize() {
|
||||
parent::_initialize();
|
||||
$this->ad = db('Ad');
|
||||
$this->ad = db('Ad');
|
||||
$this->adplace = db('AdPlace');
|
||||
}
|
||||
|
||||
@@ -29,12 +29,12 @@ class Ad extends Admin {
|
||||
* @title 广告位管理
|
||||
*/
|
||||
public function index() {
|
||||
$map = array();
|
||||
$map = array();
|
||||
$order = "id desc";
|
||||
|
||||
$list = db('AdPlace')->where($map)->order($order)->paginate(10, false, array(
|
||||
'query' => $this->request->param()
|
||||
));
|
||||
'query' => $this->request->param(),
|
||||
));
|
||||
$data = array(
|
||||
'list' => $list,
|
||||
'page' => $list->render(),
|
||||
@@ -51,14 +51,14 @@ class Ad extends Admin {
|
||||
$place = model('AdPlace');
|
||||
if ($this->request->isPost()) {
|
||||
$result = $place->change();
|
||||
if (!empty($_POST['name'])){
|
||||
if (!empty($_POST['name'])) {
|
||||
$result = $place->change();
|
||||
if ($result) {
|
||||
return $this->success("添加成功!");
|
||||
} else {
|
||||
return $this->error($place->getError());
|
||||
}
|
||||
}else{
|
||||
}
|
||||
} else {
|
||||
return $this->error("标识不能为空!");
|
||||
}
|
||||
} else {
|
||||
@@ -89,7 +89,7 @@ class Ad extends Admin {
|
||||
return $this->error("非法操作!");
|
||||
}
|
||||
$data = array(
|
||||
'info' => $info,
|
||||
'info' => $info,
|
||||
'keyList' => $place->keyList,
|
||||
);
|
||||
$this->assign($data);
|
||||
@@ -108,7 +108,7 @@ class Ad extends Admin {
|
||||
return $this->error("非法操作!");
|
||||
}
|
||||
$map['id'] = array('IN', $id);
|
||||
$result = $this->adplace->where($map)->delete();
|
||||
$result = $this->adplace->where($map)->delete();
|
||||
if ($result) {
|
||||
return $this->success("删除成功!");
|
||||
} else {
|
||||
@@ -121,13 +121,13 @@ class Ad extends Admin {
|
||||
*/
|
||||
public function lists($id = null) {
|
||||
$map['place_id'] = $id;
|
||||
$order = "id desc";
|
||||
$order = "id desc";
|
||||
|
||||
$list = db('Ad')->where($map)->order($order)->paginate(10, false, array(
|
||||
'query' => $this->request->param()
|
||||
));
|
||||
'query' => $this->request->param(),
|
||||
));
|
||||
$data = array(
|
||||
'id' => $id,
|
||||
'id' => $id,
|
||||
'list' => $list,
|
||||
'page' => $list->render(),
|
||||
);
|
||||
@@ -150,8 +150,8 @@ class Ad extends Admin {
|
||||
}
|
||||
} else {
|
||||
$info['place_id'] = $id;
|
||||
$data = array(
|
||||
'info' => $info,
|
||||
$data = array(
|
||||
'info' => $info,
|
||||
'keyList' => $ad->keyList,
|
||||
);
|
||||
$this->assign($data);
|
||||
@@ -178,7 +178,7 @@ class Ad extends Admin {
|
||||
return $this->error("非法操作!");
|
||||
}
|
||||
$data = array(
|
||||
'info' => $info,
|
||||
'info' => $info,
|
||||
'keyList' => $ad->keyList,
|
||||
);
|
||||
$this->assign($data);
|
||||
@@ -197,7 +197,7 @@ class Ad extends Admin {
|
||||
return $this->error("非法操作!");
|
||||
}
|
||||
$map['id'] = array('IN', $id);
|
||||
$result = db('ad')->where($map)->delete();
|
||||
$result = db('ad')->where($map)->delete();
|
||||
if ($result) {
|
||||
return $this->success("删除成功!");
|
||||
} else {
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\admin\controller;
|
||||
use app\common\controller\Admin;
|
||||
namespace app\controller\admin;
|
||||
use app\controller\Admin;
|
||||
|
||||
/**
|
||||
* @title 插件管理
|
||||
@@ -23,7 +23,7 @@ class Addons extends Admin {
|
||||
//加入菜单
|
||||
$this->getAddonsMenu();
|
||||
$this->addons = model('Addons');
|
||||
$this->hooks = db('Hooks');
|
||||
$this->hooks = db('Hooks');
|
||||
}
|
||||
/**
|
||||
* @title 插件列表
|
||||
@@ -33,8 +33,8 @@ class Addons extends Admin {
|
||||
$this->addons->refresh();
|
||||
}
|
||||
$list = $this->addons->order('id desc')->paginate(25, false, array(
|
||||
'query' => $this->request->param()
|
||||
));
|
||||
'query' => $this->request->param(),
|
||||
));
|
||||
// 记录当前列表页的cookie
|
||||
Cookie('__forward__', $_SERVER['REQUEST_URI']);
|
||||
|
||||
@@ -83,10 +83,10 @@ class Addons extends Admin {
|
||||
*/
|
||||
public function install() {
|
||||
$addon_name = input('addon_name', '', 'trim,ucfirst');
|
||||
$class = get_addon_class($addon_name);
|
||||
$class = get_addon_class($addon_name);
|
||||
if (class_exists($class)) {
|
||||
$addons = new $class;
|
||||
$info = $addons->info;
|
||||
$info = $addons->info;
|
||||
if (!$info || !$addons->checkInfo()) {
|
||||
//检测信息的正确性
|
||||
return $this->error('插件信息缺失');
|
||||
@@ -126,7 +126,7 @@ class Addons extends Admin {
|
||||
public function enable() {
|
||||
$id = input('id');
|
||||
cache('hooks', null);
|
||||
$model = model('Addons');
|
||||
$model = model('Addons');
|
||||
$result = $model::where(array('id' => $id))->update(array('status' => 1));
|
||||
if ($result) {
|
||||
return $this->success('启用成功');
|
||||
@@ -141,7 +141,7 @@ class Addons extends Admin {
|
||||
public function disable() {
|
||||
$id = input('id');
|
||||
cache('hooks', null);
|
||||
$model = model('Addons');
|
||||
$model = model('Addons');
|
||||
$result = $model::where(array('id' => $id))->update(array('status' => 0));
|
||||
if ($result) {
|
||||
return $this->success('禁用成功');
|
||||
@@ -166,7 +166,7 @@ class Addons extends Admin {
|
||||
$class = get_addon_class($info['name']);
|
||||
|
||||
$keyList = array();
|
||||
$data = array(
|
||||
$data = array(
|
||||
'keyList' => $keyList,
|
||||
);
|
||||
$this->assign($data);
|
||||
@@ -186,15 +186,15 @@ class Addons extends Admin {
|
||||
* @param string $addons 插件简介
|
||||
*/
|
||||
public function existHook($str, $addons, $msg = '') {
|
||||
$hook_mod = db('Hooks');
|
||||
$hook_mod = db('Hooks');
|
||||
$where['name'] = $str;
|
||||
$gethook = $hook_mod->where($where)->find();
|
||||
$gethook = $hook_mod->where($where)->find();
|
||||
if (!$gethook || empty($gethook) || !is_array($gethook)) {
|
||||
$data['name'] = $str;
|
||||
$data['name'] = $str;
|
||||
$data['description'] = $msg;
|
||||
$data['type'] = 1;
|
||||
$data['type'] = 1;
|
||||
$data['update_time'] = time();
|
||||
$data['addons'] = $addons;
|
||||
$data['addons'] = $addons;
|
||||
if (false !== $hook_mod->create($data)) {
|
||||
$hook_mod->add();
|
||||
}
|
||||
@@ -206,7 +206,7 @@ class Addons extends Admin {
|
||||
* @param string $hook 钩子名称
|
||||
*/
|
||||
public function deleteHook($hook) {
|
||||
$model = db('hooks');
|
||||
$model = db('hooks');
|
||||
$condition = array(
|
||||
'name' => $hook,
|
||||
);
|
||||
@@ -219,11 +219,11 @@ class Addons extends Admin {
|
||||
*/
|
||||
public function hooks() {
|
||||
|
||||
$map = array();
|
||||
$map = array();
|
||||
$order = "id desc";
|
||||
$list = model('Hooks')->where($map)->order($order)->paginate(10, false, array(
|
||||
'query' => $this->request->param()
|
||||
));
|
||||
$list = model('Hooks')->where($map)->order($order)->paginate(10, false, array(
|
||||
'query' => $this->request->param(),
|
||||
));
|
||||
|
||||
// 记录当前列表页的cookie
|
||||
Cookie('__forward__', $_SERVER['REQUEST_URI']);
|
||||
@@ -251,7 +251,7 @@ class Addons extends Admin {
|
||||
}
|
||||
} else {
|
||||
$keylist = $hooks->getaddons();
|
||||
$data = array(
|
||||
$data = array(
|
||||
'keyList' => $keylist,
|
||||
);
|
||||
$this->assign($data);
|
||||
@@ -273,10 +273,10 @@ class Addons extends Admin {
|
||||
return $this->error($hooks->getError());
|
||||
}
|
||||
} else {
|
||||
$info = db('Hooks')->find($id);
|
||||
$info = db('Hooks')->find($id);
|
||||
$keylist = $hooks->getaddons($info['addons']);
|
||||
$data = array(
|
||||
'info' => $info,
|
||||
$data = array(
|
||||
'info' => $info,
|
||||
'keyList' => $keylist,
|
||||
);
|
||||
$this->assign($data);
|
||||
@@ -289,9 +289,9 @@ class Addons extends Admin {
|
||||
* @title 删除钩子
|
||||
*/
|
||||
public function delhook() {
|
||||
$id = $this->getArrayParam('id');
|
||||
$id = $this->getArrayParam('id');
|
||||
$map['id'] = array('IN', $id);
|
||||
$result = $this->hooks->where($map)->delete();
|
||||
$result = $this->hooks->where($map)->delete();
|
||||
if ($result !== false) {
|
||||
return $this->success('删除成功');
|
||||
} else {
|
||||
@@ -304,7 +304,7 @@ class Addons extends Admin {
|
||||
*/
|
||||
public function updateHook() {
|
||||
$hookModel = D('Hooks');
|
||||
$data = $hookModel->create();
|
||||
$data = $hookModel->create();
|
||||
if ($data) {
|
||||
if ($data['id']) {
|
||||
$flag = $hookModel->save($data);
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\admin\controller;
|
||||
use app\common\controller\Admin;
|
||||
namespace app\controller\admin;
|
||||
use app\controller\Admin;
|
||||
|
||||
/**
|
||||
* @title 字段管理
|
||||
@@ -30,19 +30,19 @@ class Attribute extends Admin {
|
||||
$this->attr[$key] = $value[0];
|
||||
}
|
||||
$this->validate_rule = array(
|
||||
0 => '请选择',
|
||||
'regex' => '正则验证',
|
||||
'function' => '函数验证',
|
||||
'unique' => '唯一验证',
|
||||
'length' => '长度验证',
|
||||
'in' => '验证在范围内',
|
||||
'notin' => '验证不在范围内',
|
||||
'between' => '区间验证',
|
||||
0 => '请选择',
|
||||
'regex' => '正则验证',
|
||||
'function' => '函数验证',
|
||||
'unique' => '唯一验证',
|
||||
'length' => '长度验证',
|
||||
'in' => '验证在范围内',
|
||||
'notin' => '验证不在范围内',
|
||||
'between' => '区间验证',
|
||||
'notbetween' => '不在区间验证',
|
||||
);
|
||||
$this->auto_type = array(0 => '请选择', 'function' => '函数', 'field' => '字段', 'string' => '字符串');
|
||||
$this->the_time = array(0 => '请选择', '3' => '始 终', '1' => '新 增', '2' => '编 辑');
|
||||
$this->field = $this->getField();
|
||||
$this->the_time = array(0 => '请选择', '3' => '始 终', '1' => '新 增', '2' => '编 辑');
|
||||
$this->field = $this->getField();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -54,13 +54,13 @@ class Attribute extends Admin {
|
||||
return $this->error('非法操作!');
|
||||
}
|
||||
$list = model('Attribute')->where('model_id', $model_id)->order('id desc')->paginate(25, false, array(
|
||||
'query' => $this->request->param()
|
||||
));
|
||||
'query' => $this->request->param(),
|
||||
));
|
||||
|
||||
$data = array(
|
||||
'list' => $list,
|
||||
'list' => $list,
|
||||
'model_id' => $model_id,
|
||||
'page' => $list->render(),
|
||||
'page' => $list->render(),
|
||||
);
|
||||
$this->assign($data);
|
||||
$this->setMeta('字段管理');
|
||||
@@ -81,7 +81,7 @@ class Attribute extends Admin {
|
||||
}
|
||||
} else {
|
||||
$data = array(
|
||||
'info' => array('model_id' => $model_id),
|
||||
'info' => array('model_id' => $model_id),
|
||||
'fieldGroup' => $this->field,
|
||||
);
|
||||
$this->assign($data);
|
||||
@@ -96,7 +96,7 @@ class Attribute extends Admin {
|
||||
*/
|
||||
public function edit($id = '', $model_id = '') {
|
||||
if ($this->request->isPost()) {
|
||||
$result = $this->model->validate('attribute.edit')->save($this->request->param(), array('id'=>$id));
|
||||
$result = $this->model->validate('attribute.edit')->save($this->request->param(), array('id' => $id));
|
||||
if ($result) {
|
||||
return $this->success("修改成功!", url('Attribute/index', array('model_id' => $model_id)));
|
||||
} else {
|
||||
@@ -105,7 +105,7 @@ class Attribute extends Admin {
|
||||
} else {
|
||||
$info = db('Attribute')->find($id);
|
||||
$data = array(
|
||||
'info' => $info,
|
||||
'info' => $info,
|
||||
'fieldGroup' => $this->field,
|
||||
);
|
||||
$this->assign($data);
|
||||
@@ -134,7 +134,7 @@ class Attribute extends Admin {
|
||||
return $this->error($this->model->getError());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//字段编辑所需字段
|
||||
protected function getField() {
|
||||
return array(
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\admin\controller;
|
||||
use app\common\controller\Admin;
|
||||
namespace app\controller\admin;
|
||||
use app\controller\Admin;
|
||||
|
||||
/**
|
||||
* @title 频道管理
|
||||
@@ -26,9 +26,9 @@ class Channel extends Admin {
|
||||
public function index($type = 0) {
|
||||
/* 获取频道列表 */
|
||||
//$map = array('status' => array('gt', -1), 'pid'=>$pid);
|
||||
$map = array('status' => array('gt', -1));
|
||||
$map = array('status' => array('gt', -1));
|
||||
if ($type) {
|
||||
$map['type'] = $type;
|
||||
$map['type'] = $type;
|
||||
}
|
||||
$list = db('Channel')->where($map)->order('sort asc,id asc')->column('*', 'id');
|
||||
|
||||
@@ -41,7 +41,7 @@ class Channel extends Admin {
|
||||
|
||||
$data = array(
|
||||
'tree' => $list,
|
||||
'type' => $type
|
||||
'type' => $type,
|
||||
);
|
||||
$this->assign($data);
|
||||
$this->setMeta('导航管理');
|
||||
@@ -64,7 +64,7 @@ class Channel extends Admin {
|
||||
public function add() {
|
||||
if ($this->request->isPost()) {
|
||||
$Channel = model('Channel');
|
||||
$data = $this->request->post();
|
||||
$data = $this->request->post();
|
||||
if ($data) {
|
||||
$id = $Channel->save($data);
|
||||
if ($id) {
|
||||
@@ -100,7 +100,7 @@ class Channel extends Admin {
|
||||
public function edit($id = 0) {
|
||||
if ($this->request->isPost()) {
|
||||
$Channel = model('Channel');
|
||||
$data = $this->request->post();
|
||||
$data = $this->request->post();
|
||||
if ($data) {
|
||||
if (false !== $Channel->save($data, array('id' => $data['id']))) {
|
||||
//记录行为
|
||||
@@ -149,9 +149,9 @@ class Channel extends Admin {
|
||||
|
||||
$map = array('id' => array('in', $id));
|
||||
if (db('Channel')->where($map)->delete()) {
|
||||
//删除category中的ismenu字段记录
|
||||
$map = array('ismenu' => array('in', $id));
|
||||
db('Category')->where($map)->setField('ismenu',0);
|
||||
//删除category中的ismenu字段记录
|
||||
$map = array('ismenu' => array('in', $id));
|
||||
db('Category')->where($map)->setField('ismenu', 0);
|
||||
//记录行为
|
||||
action_log('update_channel', 'channel', $id, session('user_auth.uid'));
|
||||
return $this->success('删除成功');
|
||||
@@ -201,14 +201,14 @@ class Channel extends Admin {
|
||||
* @title 设置状态
|
||||
*/
|
||||
public function setStatus() {
|
||||
$id = array_unique((array) input('ids', 0));
|
||||
$id = array_unique((array) input('ids', 0));
|
||||
$status = input('status', '0', 'trim');
|
||||
|
||||
if (empty($id)) {
|
||||
return $this->error('请选择要操作的数据!');
|
||||
}
|
||||
|
||||
$map = array('id' => array('in', $id));
|
||||
$map = array('id' => array('in', $id));
|
||||
$result = db('Channel')->where($map)->update(array('status' => $status));
|
||||
if ($result) {
|
||||
return $this->success("操作成功!");
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\admin\controller;
|
||||
use app\common\controller\Admin;
|
||||
namespace app\controller\admin;
|
||||
use app\controller\Admin;
|
||||
|
||||
/**
|
||||
* @title 客户端管理
|
||||
@@ -23,70 +23,70 @@ class Client extends Admin {
|
||||
/**
|
||||
* @title 客户端列表
|
||||
*/
|
||||
public function index(){
|
||||
public function index() {
|
||||
$list = $this->model->paginate(25, false, array(
|
||||
'query' => $this->request->param()
|
||||
));
|
||||
'query' => $this->request->param(),
|
||||
));
|
||||
$data = array(
|
||||
'list' => $list,
|
||||
'page' => $list->render()
|
||||
'list' => $list,
|
||||
'page' => $list->render(),
|
||||
);
|
||||
$this->assign($data);
|
||||
$this->setMeta('客户端列表');
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @title 添加客户端
|
||||
*/
|
||||
public function add(\think\Request $request){
|
||||
public function add(\think\Request $request) {
|
||||
if ($this->request->isPost()) {
|
||||
$data = $request->param();
|
||||
$result = $this->model->validate(true)->save($data);
|
||||
if (false !== $result) {
|
||||
return $this->success('成功添加', url('client/index'));
|
||||
}else{
|
||||
} else {
|
||||
return $this->error($this->model->getError());
|
||||
}
|
||||
}else{
|
||||
$info['appid'] = rand_string(10, 1); //八位数字appid
|
||||
$info['appsecret'] = rand_string(32); //32位数字加字母秘钥
|
||||
} else {
|
||||
$info['appid'] = rand_string(10, 1); //八位数字appid
|
||||
$info['appsecret'] = rand_string(32); //32位数字加字母秘钥
|
||||
$data = array(
|
||||
'info' => $info
|
||||
'info' => $info,
|
||||
);
|
||||
$this->assign($data);
|
||||
$this->setMeta('添加客户端');
|
||||
return $this->fetch('add');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @title 编辑客户端
|
||||
*/
|
||||
public function edit(\think\Request $request){
|
||||
public function edit(\think\Request $request) {
|
||||
if ($this->request->isPost()) {
|
||||
$data = $request->param();
|
||||
$result = $this->model->validate(true)->save($data, array('id'=>$request->param('id')));
|
||||
$result = $this->model->validate(true)->save($data, array('id' => $request->param('id')));
|
||||
if (false !== $result) {
|
||||
return $this->success('修改添加', url('client/index'));
|
||||
}else{
|
||||
} else {
|
||||
return $this->error($this->model->getError());
|
||||
}
|
||||
}else{
|
||||
} else {
|
||||
$info = $this->model->where('id', $request->param('id'))->find();
|
||||
$data = array(
|
||||
'info' => $info
|
||||
'info' => $info,
|
||||
);
|
||||
$this->assign($data);
|
||||
$this->setMeta('编辑客户端');
|
||||
return $this->fetch('add');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @title 删除客户端
|
||||
*/
|
||||
public function del(\think\Request $request){
|
||||
public function del(\think\Request $request) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -7,8 +7,9 @@
|
||||
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\admin\controller;
|
||||
use app\common\controller\Admin;
|
||||
namespace app\controller\admin;
|
||||
use app\controller\Admin;
|
||||
use app\model\Config as ConfigM;
|
||||
|
||||
/**
|
||||
* @title 配置管理
|
||||
@@ -17,7 +18,7 @@ class Config extends Admin {
|
||||
|
||||
public function _initialize() {
|
||||
parent::_initialize();
|
||||
$this->model = model('Config');
|
||||
$this->model = new ConfigM();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -26,9 +27,9 @@ class Config extends Admin {
|
||||
*/
|
||||
public function index() {
|
||||
$group = input('group', 0, 'trim');
|
||||
$name = input('name', '', 'trim');
|
||||
$name = input('name', '', 'trim');
|
||||
/* 查询条件初始化 */
|
||||
$map = array('status' => 1);
|
||||
$map = array('status' => 1);
|
||||
if ($group) {
|
||||
$map['group'] = $group;
|
||||
}
|
||||
@@ -38,17 +39,17 @@ class Config extends Admin {
|
||||
}
|
||||
|
||||
$list = $this->model->where($map)->order('id desc')->paginate(25, false, array(
|
||||
'query' => $this->request->param()
|
||||
));
|
||||
'query' => $this->request->param(),
|
||||
));
|
||||
// 记录当前列表页的cookie
|
||||
Cookie('__forward__', $_SERVER['REQUEST_URI']);
|
||||
|
||||
$data = array(
|
||||
'group' => config('config_group_list'),
|
||||
'group' => config('config_group_list'),
|
||||
'config_type' => config('config_config_list'),
|
||||
'page' => $list->render(),
|
||||
'group_id' => $group,
|
||||
'list' => $list,
|
||||
'page' => $list->render(),
|
||||
'group_id' => $group,
|
||||
'list' => $list,
|
||||
);
|
||||
|
||||
$this->assign($data);
|
||||
@@ -62,7 +63,7 @@ class Config extends Admin {
|
||||
public function group($id = 1) {
|
||||
if ($this->request->isPost()) {
|
||||
$config = $this->request->post('config/a');
|
||||
$model = model('Config');
|
||||
$model = model('Config');
|
||||
foreach ($config as $key => $value) {
|
||||
$model->where(array('name' => $key))->setField('value', $value);
|
||||
}
|
||||
@@ -71,12 +72,12 @@ class Config extends Admin {
|
||||
return $this->success("更新成功!");
|
||||
} else {
|
||||
$type = config('config_group_list');
|
||||
$list = db("Config")->where(array('status' => 1, 'group' => $id))->field('id,name,title,extra,value,remark,type')->order('sort')->select();
|
||||
$list = (new ConfigM())->where(array('status' => 1, 'group' => $id))->field('id,name,title,extra,value,remark,type')->order('sort')->select();
|
||||
if ($list) {
|
||||
$this->assign('list', $list);
|
||||
$this->data['list'] = $list;
|
||||
}
|
||||
$this->assign('id', $id);
|
||||
$this->setMeta($type[$id] . '设置');
|
||||
// $this->assign('id', $id);
|
||||
// $this->setMeta($type[$id] . '设置');
|
||||
return $this->fetch();
|
||||
}
|
||||
}
|
||||
@@ -88,7 +89,7 @@ class Config extends Admin {
|
||||
public function add() {
|
||||
if ($this->request->isPost()) {
|
||||
$config = model('Config');
|
||||
$data = $this->request->post();
|
||||
$data = $this->request->post();
|
||||
if ($data) {
|
||||
$id = $config->validate(true)->save($data);
|
||||
if ($id) {
|
||||
@@ -116,7 +117,7 @@ class Config extends Admin {
|
||||
public function edit($id = 0) {
|
||||
if ($this->request->isPost()) {
|
||||
$config = model('Config');
|
||||
$data = $this->request->post();
|
||||
$data = $this->request->post();
|
||||
if ($data) {
|
||||
$result = $config->validate('Config.edit')->save($data, array('id' => $data['id']));
|
||||
if (false !== $result) {
|
||||
@@ -224,9 +225,9 @@ class Config extends Admin {
|
||||
$pc = config('pc_themes');
|
||||
$mobile = config('mobile_themes');
|
||||
$data = array(
|
||||
'pc' => $pc,
|
||||
'pc' => $pc,
|
||||
'mobile' => $mobile,
|
||||
'list' => $list,
|
||||
'list' => $list,
|
||||
);
|
||||
|
||||
$this->assign($data);
|
||||
@@ -238,12 +239,12 @@ class Config extends Admin {
|
||||
* @title 设置主题
|
||||
* @return json
|
||||
*/
|
||||
public function setthemes($name, $id){
|
||||
public function setthemes($name, $id) {
|
||||
$result = db('Config')->where('name', $name . '_themes')->setField('value', $id);
|
||||
if (false !== $result) {
|
||||
\think\Cache::clear();
|
||||
return $this->success('设置成功!');
|
||||
}else{
|
||||
} else {
|
||||
return $this->error('设置失败!');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,9 +7,8 @@
|
||||
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\admin\controller;
|
||||
use app\common\controller\Admin;
|
||||
|
||||
namespace app\controller\admin;
|
||||
use app\controller\Admin;
|
||||
|
||||
/**
|
||||
* @title 内容管理
|
||||
@@ -20,7 +19,7 @@ class Content extends Admin {
|
||||
parent::_initialize();
|
||||
$this->getContentMenu();
|
||||
$this->model_id = $model_id = $this->request->param('model_id');
|
||||
$list = db('Model')->column('*', 'id');
|
||||
$list = db('Model')->column('*', 'id');
|
||||
|
||||
if (empty($list[$model_id])) {
|
||||
return $this->error("无此模型!");
|
||||
@@ -43,14 +42,13 @@ class Content extends Admin {
|
||||
return $this->error("列表定义不正确!", url('admin/model/edit', array('id' => $this->modelInfo['id'])));
|
||||
}
|
||||
$grid_list = get_grid_list($this->modelInfo['list_grid']);
|
||||
$order = "id desc";
|
||||
$map = $this->buildMap();
|
||||
$field = array_filter($grid_list['fields']);
|
||||
|
||||
$order = "id desc";
|
||||
$map = $this->buildMap();
|
||||
$field = array_filter($grid_list['fields']);
|
||||
|
||||
$list = $this->model->where($map)->order($order)->paginate($this->modelInfo['list_row'], false, array(
|
||||
'query' => $this->request->param()
|
||||
));
|
||||
'query' => $this->request->param(),
|
||||
));
|
||||
|
||||
$data = array(
|
||||
'grid' => $grid_list,
|
||||
@@ -86,7 +84,7 @@ class Content extends Admin {
|
||||
'model_id' => $this->modelInfo['id'],
|
||||
);
|
||||
$data = array(
|
||||
'info' => $info,
|
||||
'info' => $info,
|
||||
'fieldGroup' => $this->getField($this->modelInfo),
|
||||
);
|
||||
if ($this->modelInfo['template_add']) {
|
||||
@@ -106,7 +104,7 @@ class Content extends Admin {
|
||||
*/
|
||||
public function edit($id) {
|
||||
if ($this->request->isPost()) {
|
||||
$result = $this->model->save($this->request->param(), array('id'=> $id));
|
||||
$result = $this->model->save($this->request->param(), array('id' => $id));
|
||||
if ($result !== false) {
|
||||
//记录行为
|
||||
action_log('update_content', 'content', $result, session('auth_user.uid'));
|
||||
@@ -123,8 +121,8 @@ class Content extends Admin {
|
||||
return $this->error($this->model->getError());
|
||||
}
|
||||
$info['model_id'] = $this->modelInfo['id'];
|
||||
$data = array(
|
||||
'info' => $info,
|
||||
$data = array(
|
||||
'info' => $info,
|
||||
'fieldGroup' => $this->getField($this->modelInfo),
|
||||
);
|
||||
if ($this->modelInfo['template_edit']) {
|
||||
@@ -150,7 +148,7 @@ class Content extends Admin {
|
||||
}
|
||||
|
||||
$map['id'] = array('IN', $id);
|
||||
$result = $this->model->where($map)->delete();
|
||||
$result = $this->model->where($map)->delete();
|
||||
|
||||
if (false !== $result) {
|
||||
//记录行为
|
||||
@@ -167,7 +165,7 @@ class Content extends Admin {
|
||||
*/
|
||||
public function status($id, $status) {
|
||||
$map['id'] = $id;
|
||||
$result = $this->model->where($map)->setField('status', $status);
|
||||
$result = $this->model->where($map)->setField('status', $status);
|
||||
if (false !== $result) {
|
||||
return $this->success("操作成功!");
|
||||
} else {
|
||||
@@ -181,7 +179,7 @@ class Content extends Admin {
|
||||
*/
|
||||
public function settop($id, $is_top) {
|
||||
$map['id'] = $id;
|
||||
$result = $this->model->where($map)->setField('is_top', $is_top);
|
||||
$result = $this->model->where($map)->setField('is_top', $is_top);
|
||||
if (false !== $result) {
|
||||
return $this->success("操作成功!");
|
||||
} else {
|
||||
@@ -205,7 +203,7 @@ class Content extends Admin {
|
||||
}
|
||||
|
||||
//获得数组的第一条数组
|
||||
$rows = model('Attribute')->getFieldlist($map, 'id');
|
||||
$rows = model('Attribute')->getFieldlist($map, 'id');
|
||||
if (!empty($rows)) {
|
||||
foreach ($rows as $key => $value) {
|
||||
$list[$value['group_id']][] = $value;
|
||||
@@ -213,7 +211,7 @@ class Content extends Admin {
|
||||
foreach ($field_group as $key => $value) {
|
||||
$fields[$value] = isset($list[$key]) ? $list[$key] : array();
|
||||
}
|
||||
}else{
|
||||
} else {
|
||||
$fields = array();
|
||||
}
|
||||
return $fields;
|
||||
@@ -224,7 +222,7 @@ class Content extends Admin {
|
||||
* @return [array] [查询条件]
|
||||
*/
|
||||
protected function buildMap() {
|
||||
$map = array();
|
||||
$map = array();
|
||||
$data = $this->request->param();
|
||||
foreach ($data as $key => $value) {
|
||||
if ($value) {
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\admin\controller;
|
||||
use app\common\controller\Admin;
|
||||
namespace app\controller\admin;
|
||||
use app\controller\Admin;
|
||||
|
||||
/**
|
||||
* @title 用户组管理
|
||||
@@ -22,7 +22,7 @@ class Group extends Admin {
|
||||
public function _initialize() {
|
||||
parent::_initialize();
|
||||
$this->group = model('AuthGroup');
|
||||
$this->rule = model('AuthRule');
|
||||
$this->rule = model('AuthRule');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -32,8 +32,8 @@ class Group extends Admin {
|
||||
$map['module'] = $type;
|
||||
|
||||
$list = db('AuthGroup')->where($map)->order('id desc')->paginate(10, false, array(
|
||||
'query' => $this->request->param()
|
||||
));
|
||||
'query' => $this->request->param(),
|
||||
));
|
||||
|
||||
$data = array(
|
||||
'list' => $list,
|
||||
@@ -58,7 +58,7 @@ class Group extends Admin {
|
||||
}
|
||||
} else {
|
||||
$data = array(
|
||||
'info' => array('module' => $type, 'status' => 1),
|
||||
'info' => array('module' => $type, 'status' => 1),
|
||||
'keyList' => $this->group->keyList,
|
||||
);
|
||||
$this->assign($data);
|
||||
@@ -84,7 +84,7 @@ class Group extends Admin {
|
||||
} else {
|
||||
$info = $this->group->where(array('id' => $id))->find();
|
||||
$data = array(
|
||||
'info' => $info,
|
||||
'info' => $info,
|
||||
'keyList' => $this->group->keyList,
|
||||
);
|
||||
$this->assign($data);
|
||||
@@ -93,14 +93,13 @@ class Group extends Admin {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @title 编辑用户组单字段
|
||||
*/
|
||||
public function editable() {
|
||||
$pk = input('pk', '', 'trim,intval');
|
||||
$name = input('name', '', 'trim');
|
||||
$value = input('value', '', 'trim');
|
||||
$pk = input('pk', '', 'trim,intval');
|
||||
$name = input('name', '', 'trim');
|
||||
$value = input('value', '', 'trim');
|
||||
$result = $this->group->where(array('id' => $pk))->setField($name, $value);
|
||||
if ($result) {
|
||||
return $this->success("删除成功!");
|
||||
@@ -109,7 +108,6 @@ class Group extends Admin {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @title 删除用户组
|
||||
*/
|
||||
@@ -126,7 +124,6 @@ class Group extends Admin {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @title 权限节点
|
||||
*/
|
||||
@@ -134,8 +131,8 @@ class Group extends Admin {
|
||||
$map['module'] = $type;
|
||||
|
||||
$list = db('AuthRule')->where($map)->order('id desc')->paginate(15, false, array(
|
||||
'query' => $this->request->param()
|
||||
));
|
||||
'query' => $this->request->param(),
|
||||
));
|
||||
|
||||
$data = array(
|
||||
'list' => $list,
|
||||
@@ -164,8 +161,8 @@ class Group extends Admin {
|
||||
return $this->error("非法操作!");
|
||||
}
|
||||
if ($this->request->isPost()) {
|
||||
$rule = $this->request->post('rule/a', array());
|
||||
$extend_rule = $this->request->post('extend_rule/a', array());
|
||||
$rule = $this->request->post('rule/a', array());
|
||||
$extend_rule = $this->request->post('extend_rule/a', array());
|
||||
$extend_result = $rule_result = false;
|
||||
//扩展权限
|
||||
$extend_data = array();
|
||||
@@ -179,7 +176,7 @@ class Group extends Admin {
|
||||
$extend_result = db('AuthExtend')->insertAll($extend_data);
|
||||
}
|
||||
if ($rule) {
|
||||
$rules = implode(',', $rule);
|
||||
$rules = implode(',', $rule);
|
||||
$rule_result = $this->group->where(array('id' => $id))->setField('rules', $rules);
|
||||
}
|
||||
|
||||
@@ -192,7 +189,7 @@ class Group extends Admin {
|
||||
$group = $this->group->where(array('id' => $id))->find();
|
||||
|
||||
$map['module'] = $group['module'];
|
||||
$row = db('AuthRule')->where($map)->order('id desc')->select();
|
||||
$row = db('AuthRule')->where($map)->order('id desc')->select();
|
||||
|
||||
$list = array();
|
||||
foreach ($row as $key => $value) {
|
||||
@@ -205,12 +202,12 @@ class Group extends Admin {
|
||||
->select();
|
||||
//扩展权限
|
||||
$extend_auth = db('AuthExtend')->where(array('group_id' => $id, 'type' => 2))->column('extend_id');
|
||||
$data = array(
|
||||
'list' => $list,
|
||||
'model' => $model,
|
||||
$data = array(
|
||||
'list' => $list,
|
||||
'model' => $model,
|
||||
'extend_auth' => $extend_auth,
|
||||
'auth_list' => explode(',', $group['rules']),
|
||||
'id' => $id,
|
||||
'auth_list' => explode(',', $group['rules']),
|
||||
'id' => $id,
|
||||
);
|
||||
$this->assign($data);
|
||||
$this->setMeta('授权');
|
||||
@@ -231,7 +228,7 @@ class Group extends Admin {
|
||||
}
|
||||
} else {
|
||||
$data = array(
|
||||
'info' => array('module' => $type, 'status' => 1),
|
||||
'info' => array('module' => $type, 'status' => 1),
|
||||
'keyList' => $this->rule->keyList,
|
||||
);
|
||||
$this->assign($data);
|
||||
@@ -257,7 +254,7 @@ class Group extends Admin {
|
||||
}
|
||||
$info = $this->rule->find($id);
|
||||
$data = array(
|
||||
'info' => $info,
|
||||
'info' => $info,
|
||||
'keyList' => $this->rule->keyList,
|
||||
);
|
||||
$this->assign($data);
|
||||
|
||||
@@ -10,6 +10,7 @@ namespace app\controller\admin;
|
||||
|
||||
use app\controller\Admin;
|
||||
use app\model\Member;
|
||||
use think\facade\Session;
|
||||
|
||||
/**
|
||||
* @title 后端公共模块
|
||||
@@ -39,20 +40,14 @@ class Index extends Admin {
|
||||
return $this->error('验证码错误!', '');
|
||||
}
|
||||
|
||||
$userinfo = $user->login($this->request);
|
||||
if ($userinfo) {
|
||||
// return $this->success('登录成功!', url('admin/index/index'));
|
||||
} else {
|
||||
print_r($user->error);
|
||||
// switch ($uid) {
|
||||
// case -1:$error = '用户不存在或被禁用!';
|
||||
// break; //系统级别禁用
|
||||
// case -2:$error = '密码错误!';
|
||||
// break;
|
||||
// default:$error = '未知错误!';
|
||||
// break; // 0-接口参数错误(调试阶段使用)
|
||||
// }
|
||||
return $this->error($error, '');
|
||||
try {
|
||||
$userinfo = $user->login($this->request);
|
||||
if ($userinfo) {
|
||||
Session::set('userInfo', $userinfo);
|
||||
return $this->success('登录成功!', url('/admin/index/index'));
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
return $this->error($e->getError(), '');
|
||||
}
|
||||
} else {
|
||||
return $this->fetch();
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\admin\controller;
|
||||
use app\common\controller\Admin;
|
||||
namespace app\controller\admin;
|
||||
use app\controller\Admin;
|
||||
|
||||
/**
|
||||
* @title 友情链接
|
||||
@@ -23,9 +23,9 @@ class Link extends Admin {
|
||||
$map = array();
|
||||
|
||||
$order = "id desc";
|
||||
$list = db('Link')->where($map)->order($order)->paginate(10, false, array(
|
||||
'query' => $this->request->param()
|
||||
));
|
||||
$list = db('Link')->where($map)->order($order)->paginate(10, false, array(
|
||||
'query' => $this->request->param(),
|
||||
));
|
||||
|
||||
$data = array(
|
||||
'list' => $list,
|
||||
@@ -64,13 +64,12 @@ class Link extends Admin {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @title 修改链接
|
||||
*/
|
||||
public function edit() {
|
||||
$link = model('Link');
|
||||
$id = input('id', '', 'trim,intval');
|
||||
$id = input('id', '', 'trim,intval');
|
||||
if ($this->request->isPost()) {
|
||||
$data = input('post.');
|
||||
if ($data) {
|
||||
@@ -84,12 +83,12 @@ class Link extends Admin {
|
||||
return $this->error($link->getError());
|
||||
}
|
||||
} else {
|
||||
$map = array('id' => $id);
|
||||
$map = array('id' => $id);
|
||||
$info = db('Link')->where($map)->find();
|
||||
|
||||
$data = array(
|
||||
'keyList' => $link->keyList,
|
||||
'info' => $info,
|
||||
'info' => $info,
|
||||
);
|
||||
$this->assign($data);
|
||||
$this->setMeta("编辑友链");
|
||||
@@ -107,7 +106,7 @@ class Link extends Admin {
|
||||
}
|
||||
$link = db('Link');
|
||||
|
||||
$map = array('id' => array('IN', $id));
|
||||
$map = array('id' => array('IN', $id));
|
||||
$result = $link->where($map)->delete();
|
||||
if ($result) {
|
||||
return $this->success("删除成功!");
|
||||
|
||||
@@ -7,9 +7,8 @@
|
||||
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\admin\controller;
|
||||
use app\common\controller\Admin;
|
||||
|
||||
namespace app\controller\admin;
|
||||
use app\controller\Admin;
|
||||
|
||||
/**
|
||||
* @title 菜单管理
|
||||
@@ -24,9 +23,9 @@ class Menu extends Admin {
|
||||
* @title 菜单列表
|
||||
*/
|
||||
public function index() {
|
||||
$map = array();
|
||||
$map = array();
|
||||
$title = trim(input('get.title'));
|
||||
$list = db("Menu")->where($map)->field(true)->order('sort asc,id asc')->column('*', 'id');
|
||||
$list = db("Menu")->where($map)->field(true)->order('sort asc,id asc')->column('*', 'id');
|
||||
int_to_string($list, array('hide' => array(1 => '是', 0 => '否'), 'is_dev' => array(1 => '是', 0 => '否')));
|
||||
|
||||
if (!empty($list)) {
|
||||
@@ -58,7 +57,7 @@ class Menu extends Admin {
|
||||
if ($this->request->isPost()) {
|
||||
$Menu = model('Menu');
|
||||
$data = input('post.');
|
||||
$id = $Menu->save($data);
|
||||
$id = $Menu->save($data);
|
||||
if ($id) {
|
||||
session('admin_menu_list', null);
|
||||
//记录行为
|
||||
@@ -70,7 +69,7 @@ class Menu extends Admin {
|
||||
} else {
|
||||
$this->assign('info', array('pid' => input('pid')));
|
||||
$menus = db('Menu')->select();
|
||||
$tree = new \com\Tree();
|
||||
$tree = new \com\Tree();
|
||||
$menus = $tree->toFormatTree($menus);
|
||||
if (!empty($menus)) {
|
||||
$menus = array_merge(array(0 => array('id' => 0, 'title_show' => '顶级菜单')), $menus);
|
||||
@@ -103,9 +102,9 @@ class Menu extends Admin {
|
||||
} else {
|
||||
$info = array();
|
||||
/* 获取数据 */
|
||||
$info = db('Menu')->field(true)->find($id);
|
||||
$info = db('Menu')->field(true)->find($id);
|
||||
$menus = db('Menu')->field(true)->select();
|
||||
$tree = new \com\Tree();
|
||||
$tree = new \com\Tree();
|
||||
$menus = $tree->toFormatTree($menus);
|
||||
|
||||
$menus = array_merge(array(0 => array('id' => 0, 'title_show' => '顶级菜单')), $menus);
|
||||
@@ -171,10 +170,10 @@ class Menu extends Admin {
|
||||
$add_pid = $menuModel->add(
|
||||
array(
|
||||
'title' => $value['title'],
|
||||
'url' => $value['url'],
|
||||
'pid' => $pid,
|
||||
'hide' => isset($value['hide']) ? (int) $value['hide'] : 0,
|
||||
'tip' => isset($value['tip']) ? $value['tip'] : '',
|
||||
'url' => $value['url'],
|
||||
'pid' => $pid,
|
||||
'hide' => isset($value['hide']) ? (int) $value['hide'] : 0,
|
||||
'tip' => isset($value['tip']) ? $value['tip'] : '',
|
||||
'group' => $value['group'],
|
||||
)
|
||||
);
|
||||
@@ -186,8 +185,8 @@ class Menu extends Admin {
|
||||
|
||||
public function import() {
|
||||
if ($this->request->isPost()) {
|
||||
$tree = input('post.tree');
|
||||
$lists = explode(PHP_EOL, $tree);
|
||||
$tree = input('post.tree');
|
||||
$lists = explode(PHP_EOL, $tree);
|
||||
$menuModel = db('Menu');
|
||||
if ($lists == array()) {
|
||||
return $this->error('请按格式填写批量导入的菜单,至少一个菜单');
|
||||
@@ -197,14 +196,14 @@ class Menu extends Admin {
|
||||
$record = explode('|', $value);
|
||||
if (count($record) == 4) {
|
||||
$menuModel->add(array(
|
||||
'title' => $record[0],
|
||||
'url' => $record[1],
|
||||
'pid' => $record[2],
|
||||
'sort' => 0,
|
||||
'hide' => 0,
|
||||
'tip' => '',
|
||||
'title' => $record[0],
|
||||
'url' => $record[1],
|
||||
'pid' => $record[2],
|
||||
'sort' => 0,
|
||||
'hide' => 0,
|
||||
'tip' => '',
|
||||
'is_dev' => 0,
|
||||
'group' => $record[3],
|
||||
'group' => $record[3],
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\admin\controller;
|
||||
use app\common\controller\Admin;
|
||||
namespace app\controller\admin;
|
||||
use app\controller\Admin;
|
||||
|
||||
/**
|
||||
* @title 模型管理
|
||||
@@ -29,9 +29,9 @@ class Model extends Admin {
|
||||
$map = array('status' => array('gt', -1));
|
||||
|
||||
$order = "id desc";
|
||||
$list = $this->model->where($map)->order($order)->paginate(10, false, array(
|
||||
'query' => $this->request->param()
|
||||
));
|
||||
$list = $this->model->where($map)->order($order)->paginate(10, false, array(
|
||||
'query' => $this->request->param(),
|
||||
));
|
||||
|
||||
$data = array(
|
||||
'list' => $list,
|
||||
@@ -98,9 +98,9 @@ class Model extends Admin {
|
||||
$fields = array();
|
||||
}
|
||||
$data = array(
|
||||
'info' => $info,
|
||||
'info' => $info,
|
||||
'field_group' => $field_group,
|
||||
'fields' => $fields,
|
||||
'fields' => $fields,
|
||||
);
|
||||
$this->assign($data);
|
||||
$this->setMeta('编辑模型');
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\admin\controller;
|
||||
use app\common\controller\Admin;
|
||||
namespace app\controller\admin;
|
||||
use app\controller\Admin;
|
||||
|
||||
/**
|
||||
* @title SEO管理
|
||||
@@ -20,7 +20,7 @@ class Seo extends Admin {
|
||||
|
||||
public function _initialize() {
|
||||
parent::_initialize();
|
||||
$this->seo = model('SeoRule');
|
||||
$this->seo = model('SeoRule');
|
||||
$this->rewrite = model('Rewrite');
|
||||
}
|
||||
|
||||
@@ -32,8 +32,8 @@ class Seo extends Admin {
|
||||
$map = array('status' => array('EGT', 0));
|
||||
|
||||
$list = $this->seo->where($map)->order('sort asc')->paginate(10, false, array(
|
||||
'query' => $this->request->param()
|
||||
));
|
||||
'query' => $this->request->param(),
|
||||
));
|
||||
|
||||
$data = array(
|
||||
'list' => $list,
|
||||
@@ -49,7 +49,7 @@ class Seo extends Admin {
|
||||
*/
|
||||
public function add() {
|
||||
if ($this->request->isPost()) {
|
||||
$data = $this->request->post();
|
||||
$data = $this->request->post();
|
||||
$result = $this->seo->save($data);
|
||||
if ($result) {
|
||||
return $this->success("添加成功!");
|
||||
@@ -71,7 +71,7 @@ class Seo extends Admin {
|
||||
*/
|
||||
public function edit($id = null) {
|
||||
if ($this->request->isPost()) {
|
||||
$data = $this->request->post();
|
||||
$data = $this->request->post();
|
||||
$result = $this->seo->save($data, array('id' => $data['id']));
|
||||
if (false !== $result) {
|
||||
return $this->success("修改成功!");
|
||||
@@ -79,10 +79,10 @@ class Seo extends Admin {
|
||||
return $this->error("修改失败!");
|
||||
}
|
||||
} else {
|
||||
$id = input('id', '', 'trim,intval');
|
||||
$id = input('id', '', 'trim,intval');
|
||||
$info = $this->seo->where(array('id' => $id))->find();
|
||||
$data = array(
|
||||
'info' => $info,
|
||||
'info' => $info,
|
||||
'keyList' => $this->seo->keyList,
|
||||
);
|
||||
$this->assign($data);
|
||||
@@ -155,10 +155,10 @@ class Seo extends Admin {
|
||||
return $this->error(model('Rewrite')->getError());
|
||||
}
|
||||
} else {
|
||||
$id = input('id', '', 'trim,intval');
|
||||
$id = input('id', '', 'trim,intval');
|
||||
$info = db('Rewrite')->where(array('id' => $id))->find();
|
||||
$data = array(
|
||||
'info' => $info,
|
||||
'info' => $info,
|
||||
'keyList' => $this->rewrite->keyList,
|
||||
);
|
||||
$this->assign($data);
|
||||
|
||||
@@ -7,14 +7,14 @@
|
||||
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\admin\controller;
|
||||
use app\common\controller\Admin;
|
||||
namespace app\controller\admin;
|
||||
use app\controller\Admin;
|
||||
|
||||
class Upload extends Admin {
|
||||
|
||||
public function _empty() {
|
||||
$controller = controller('common/Upload');
|
||||
$action = $this->request->action();
|
||||
$action = $this->request->action();
|
||||
return $controller->$action();
|
||||
}
|
||||
}
|
||||
@@ -7,9 +7,10 @@
|
||||
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\admin\controller;
|
||||
use app\common\controller\Admin;
|
||||
namespace app\controller\admin;
|
||||
|
||||
use app\controller\Admin;
|
||||
use app\model\Member;
|
||||
/**
|
||||
* @title 用户管理
|
||||
*/
|
||||
@@ -19,29 +20,25 @@ class User extends Admin {
|
||||
* @title 用户列表
|
||||
* @author 麦当苗儿 <zuojiazi@vip.qq.com>
|
||||
*/
|
||||
public function index() {
|
||||
public function index(Member $member) {
|
||||
$param = $this->request->param();
|
||||
$map['status'] = array('egt', 0);
|
||||
$map[] = ['status', '>=', 0];
|
||||
if (isset($param['nickname']) && $param['nickname']) {
|
||||
$map['nickname'] = array('like', '%' . $param['nickname'] . '%');
|
||||
}
|
||||
}
|
||||
if (isset($param['username']) && $param['username']) {
|
||||
$map['username'] = array('like', '%' . (string) $param['nickname'] . '%');
|
||||
}
|
||||
|
||||
$order = "uid desc";
|
||||
$list = model('Member')->where($map)->order($order)
|
||||
$list = $member->where($map)->order($order)
|
||||
->paginate(15, false, array(
|
||||
'param' => $param
|
||||
'param' => $param,
|
||||
));
|
||||
|
||||
$data = array(
|
||||
'list' => $list,
|
||||
'page' => $list->render(),
|
||||
'param' => $param
|
||||
);
|
||||
$this->assign($data);
|
||||
$this->setMeta('用户信息');
|
||||
$this->data['list'] = $list;
|
||||
$this->data['page'] = $list->render();
|
||||
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
@@ -90,7 +87,7 @@ class User extends Admin {
|
||||
$info = $this->getUserinfo();
|
||||
|
||||
$data = array(
|
||||
'info' => $info,
|
||||
'info' => $info,
|
||||
'keyList' => $model->editfield,
|
||||
);
|
||||
$this->assign($data);
|
||||
@@ -111,14 +108,13 @@ class User extends Admin {
|
||||
return $this->success('删除用户成功!');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @title 用户授权
|
||||
* @author colin <colin@tensent.cn>
|
||||
*/
|
||||
public function auth() {
|
||||
$access = model('AuthGroupAccess');
|
||||
$group = model('AuthGroup');
|
||||
$group = model('AuthGroup');
|
||||
if ($this->request->isPost()) {
|
||||
$uid = input('uid', '', 'trim,intval');
|
||||
$access->where(array('uid' => $uid))->delete();
|
||||
@@ -127,7 +123,7 @@ class User extends Admin {
|
||||
$group_id = input($key, '', 'trim,intval');
|
||||
if ($group_id) {
|
||||
$add = array(
|
||||
'uid' => $uid,
|
||||
'uid' => $uid,
|
||||
'group_id' => $group_id,
|
||||
);
|
||||
$access->save($add);
|
||||
@@ -135,8 +131,8 @@ class User extends Admin {
|
||||
}
|
||||
return $this->success("设置成功!");
|
||||
} else {
|
||||
$uid = input('id', '', 'trim,intval');
|
||||
$row = $group::select();
|
||||
$uid = input('id', '', 'trim,intval');
|
||||
$row = $group::select();
|
||||
$auth = $access::where(array('uid' => $uid))->select();
|
||||
|
||||
$auth_list = array();
|
||||
@@ -147,9 +143,9 @@ class User extends Admin {
|
||||
$list[$value['module']][] = $value;
|
||||
}
|
||||
$data = array(
|
||||
'uid' => $uid,
|
||||
'uid' => $uid,
|
||||
'auth_list' => $auth_list,
|
||||
'list' => $list,
|
||||
'list' => $list,
|
||||
);
|
||||
$this->assign($data);
|
||||
$this->setMeta("用户分组");
|
||||
@@ -166,9 +162,9 @@ class User extends Admin {
|
||||
*/
|
||||
private function getUserinfo($uid = null, $pass = null, $errormsg = null) {
|
||||
$user = model('Member');
|
||||
$uid = $uid ? $uid : input('id');
|
||||
$uid = $uid ? $uid : input('id');
|
||||
//如果无UID则修改当前用户
|
||||
$uid = $uid ? $uid : session('user_auth.uid');
|
||||
$uid = $uid ? $uid : session('user_auth.uid');
|
||||
$map['uid'] = $uid;
|
||||
if ($pass != null) {
|
||||
unset($map);
|
||||
@@ -199,13 +195,13 @@ class User extends Admin {
|
||||
|
||||
//密码验证
|
||||
$User = new UserApi();
|
||||
$uid = $User->login(UID, $password, 4);
|
||||
$uid = $User->login(UID, $password, 4);
|
||||
if ($uid == -2) {
|
||||
return $this->error('密码不正确');
|
||||
}
|
||||
|
||||
$Member = model('Member');
|
||||
$data = $Member->create(array('nickname' => $nickname));
|
||||
$data = $Member->create(array('nickname' => $nickname));
|
||||
if (!$data) {
|
||||
return $this->error($Member->getError());
|
||||
}
|
||||
@@ -213,7 +209,7 @@ class User extends Admin {
|
||||
$res = $Member->where(array('uid' => $uid))->save($data);
|
||||
|
||||
if ($res) {
|
||||
$user = session('user_auth');
|
||||
$user = session('user_auth');
|
||||
$user['username'] = $data['nickname'];
|
||||
session('user_auth', $user);
|
||||
session('user_auth_sign', data_auth_sign($user));
|
||||
|
||||
Reference in New Issue
Block a user