更新
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 插件管理
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user