后台批量操作bug修复
内核更新
This commit is contained in:
@@ -103,23 +103,17 @@ class Action extends Admin {
|
||||
* @author colin <colin@tensent.cn>
|
||||
*/
|
||||
public function del(){
|
||||
if (IS_POST) {
|
||||
$ids = input('ids/a',array());
|
||||
$id = input('id','');
|
||||
array_push($ids, $id);
|
||||
if(empty($ids)){
|
||||
return $this->error("非法操作!",'');
|
||||
}
|
||||
$map['id'] = array('IN',$ids);
|
||||
$result = db('Action')->where($map)->delete();
|
||||
if ($result) {
|
||||
action_log('delete_action', 'Action', $id, session('user_auth.uid'));
|
||||
return $this->success('删除成功!');
|
||||
}else{
|
||||
return $this->error('删除失败!');
|
||||
}
|
||||
$id = array_unique((array)$this->param['id']);
|
||||
if(empty($id)){
|
||||
return $this->error("非法操作!",'');
|
||||
}
|
||||
$map['id'] = array('IN',$id);
|
||||
$result = db('Action')->where($map)->delete();
|
||||
if ($result) {
|
||||
action_log('delete_action', 'Action', $id, session('user_auth.uid'));
|
||||
return $this->success('删除成功!');
|
||||
}else{
|
||||
return $this->error("非法操作!");
|
||||
return $this->error('删除失败!');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,15 +122,13 @@ class Action extends Admin {
|
||||
* @author colin <colin@tensent.cn>
|
||||
*/
|
||||
public function setstatus(){
|
||||
$ids = input('ids/a',array());
|
||||
$id = input('id','');
|
||||
array_push($ids, $id);
|
||||
if(empty($ids)){
|
||||
$id = array_unique((array)$this->param['id']);
|
||||
if(empty($id)){
|
||||
return $this->error("非法操作!",'');
|
||||
}
|
||||
$status = input('get.status','','trim,intval');
|
||||
$message = !$status ? '禁用' : '启用';
|
||||
$map['id'] = array('IN',$ids);
|
||||
$map['id'] = array('IN',$id);
|
||||
$result = db('Action')->where($map)->setField('status',$status);
|
||||
if ($result !== false) {
|
||||
action_log('setstatus_action', 'Action', $id, session('user_auth.uid'));
|
||||
@@ -193,17 +185,15 @@ class Action extends Admin {
|
||||
}
|
||||
/**
|
||||
* 删除日志
|
||||
* @param mixed $ids
|
||||
* @param mixed $id
|
||||
* @author huajie <banhuajie@163.com>
|
||||
*/
|
||||
public function dellog() {
|
||||
$ids = input('ids/a',array());
|
||||
$id = input('id','');
|
||||
array_push($ids, $id);
|
||||
if(empty($ids)){
|
||||
$id = array_unique((array)$this->param['id']);
|
||||
if(empty($id)){
|
||||
return $this->error("非法操作!",'');
|
||||
}
|
||||
$map['id'] = array('IN',$ids);
|
||||
$map['id'] = array('IN',$id);
|
||||
$res = db('ActionLog')->where($map)->delete();
|
||||
if ($res !== false) {
|
||||
action_log('delete_actionlog', 'ActionLog', $id, session('user_auth.uid'));
|
||||
|
||||
@@ -90,9 +90,9 @@ class Ad extends Admin {
|
||||
}
|
||||
|
||||
public function del(){
|
||||
$id = input('id','');
|
||||
$id = array_unique((array)$this->param['id']);
|
||||
|
||||
if (!$id) {
|
||||
if (empty($id)) {
|
||||
return $this->error("非法操作!");
|
||||
}
|
||||
$map['id'] = array('IN',$id);
|
||||
@@ -175,9 +175,9 @@ class Ad extends Admin {
|
||||
}
|
||||
|
||||
public function delad(){
|
||||
$id = input('id','');
|
||||
$id = array_unique((array)$this->param['id']);
|
||||
|
||||
if (!$id) {
|
||||
if (empty($id)) {
|
||||
return $this->error("非法操作!");
|
||||
}
|
||||
$map['id'] = array('IN',$id);
|
||||
|
||||
@@ -127,7 +127,7 @@ class Channel extends Admin{
|
||||
* @author 麦当苗儿 <zuojiazi@vip.qq.com>
|
||||
*/
|
||||
public function del() {
|
||||
$id = array_unique((array)input('id', 0));
|
||||
$id = array_unique((array)$this->param['id']);
|
||||
|
||||
if (empty($id)) {
|
||||
return $this->error('请选择要操作的数据!');
|
||||
|
||||
@@ -145,14 +145,12 @@ class Content extends Admin{
|
||||
* @author molong <ycgpp@126.com>
|
||||
*/
|
||||
public function del(){
|
||||
$id = input('id','','trim');
|
||||
$ids = input('post.ids',array());
|
||||
array_push($ids, $id);
|
||||
if (empty($ids)) {
|
||||
$id = array_unique((array)$this->param['id']);
|
||||
if (empty($id)) {
|
||||
return $this->error("非法操作!");
|
||||
}
|
||||
|
||||
$map['id'] = array('IN',$ids);
|
||||
$map['id'] = array('IN',$id);
|
||||
$result = $this->model->del($map);
|
||||
|
||||
if ($result) {
|
||||
|
||||
@@ -97,11 +97,11 @@ class Group extends Admin {
|
||||
|
||||
//会员分组删除控制器
|
||||
public function del(){
|
||||
$id = input('id','','trim,intval');
|
||||
if (!$id) {
|
||||
$id = array_unique((array)$this->param['id']);
|
||||
if (empty($id)) {
|
||||
return $this->error("非法操作!");
|
||||
}
|
||||
$result = $this->group->where(array('id'=>$id))->delete();
|
||||
$result = $this->group->where(array('id'=>array('IN', $id)))->delete();
|
||||
if ($result) {
|
||||
return $this->success("删除成功!");
|
||||
}else{
|
||||
@@ -113,7 +113,7 @@ class Group extends Admin {
|
||||
public function access($type = 'admin'){
|
||||
$map['module'] = $type;
|
||||
|
||||
$list = db('AuthRule')->where($map)->order('id desc')->paginate(10);
|
||||
$list = db('AuthRule')->where($map)->order('id desc')->paginate(15);
|
||||
|
||||
$data = array(
|
||||
'list' => $list,
|
||||
|
||||
@@ -84,7 +84,11 @@ class Link extends Admin{
|
||||
}
|
||||
|
||||
//删除
|
||||
public function delete($id){
|
||||
public function delete(){
|
||||
$id = array_unique((array)$this->param['id']);
|
||||
if (empty($id)) {
|
||||
return $this->error('非法操作!');
|
||||
}
|
||||
$link = db('Link');
|
||||
|
||||
$map = array('id'=>array('IN',$id));
|
||||
|
||||
@@ -123,7 +123,7 @@ class Menu extends Admin{
|
||||
* @author yangweijie <yangweijiester@gmail.com>
|
||||
*/
|
||||
public function del(){
|
||||
$id = array_unique((array)input('id',0));
|
||||
$id = array_unique((array)$this->param['id']);
|
||||
|
||||
if ( empty($id) ) {
|
||||
return $this->error('请选择要操作的数据!');
|
||||
@@ -133,7 +133,7 @@ class Menu extends Admin{
|
||||
if(db('Menu')->where($map)->delete()){
|
||||
session('admin_menu_list',null);
|
||||
//记录行为
|
||||
action_log('update_menu', 'Menu', $id, UID);
|
||||
action_log('update_menu', 'Menu', $id, session('user_auth.uid'));
|
||||
return $this->success('删除成功');
|
||||
} else {
|
||||
return $this->error('删除失败!');
|
||||
|
||||
@@ -97,11 +97,11 @@ class Seo extends Admin{
|
||||
}
|
||||
|
||||
public function del(){
|
||||
$id = input('id','','trim,intval');
|
||||
if (!$id) {
|
||||
$id = array_unique((array)$this->param['id']);
|
||||
if (empty($id)) {
|
||||
return $this->error("非法操作!");
|
||||
}
|
||||
$result = db('SeoRule')->where(array('id'=>$id))->delete();
|
||||
$result = db('SeoRule')->where(array('id'=>array('IN',$id)))->delete();
|
||||
if ($result) {
|
||||
return $this->success("删除成功!");
|
||||
}else{
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
{volist name="list" id="vo"}
|
||||
<tr>
|
||||
<td>
|
||||
<input class="ids" type="checkbox" name="ids[]" value="{$vo.id}" />
|
||||
<input class="ids" type="checkbox" name="id[]" value="{$vo['id']}" />
|
||||
</td>
|
||||
<td>{$vo.id}</td>
|
||||
<td>{$vo.name}</td>
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
<tbody>
|
||||
{volist name="list" id="vo"}
|
||||
<tr>
|
||||
<td><input class="ids" type="checkbox" name="ids[]" value="{$vo['id']}" /></td>
|
||||
<td><input class="ids" type="checkbox" name="id[]" value="{$vo['id']}" /></td>
|
||||
<td>{$vo['id']} </td>
|
||||
<td>{:get_action($vo['action_id'],'title')}</td>
|
||||
<td>{:get_nickname($vo['user_id'])}</td>
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
<table class="table table-striped table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="30"><input class="checkbox check-all" type="checkbox"></th>
|
||||
<th width="60">ID</th>
|
||||
<th>组名</th>
|
||||
<th>标识</th>
|
||||
@@ -45,6 +46,7 @@
|
||||
<tbody>
|
||||
{volist name="list" id="item"}
|
||||
<tr>
|
||||
<th width="30"><input class="ids row-selected" type="checkbox" name="id[]" value="{$item['id']}"></th>
|
||||
<td>{$item['id']}</td>
|
||||
<td>{$item['title']}</td>
|
||||
<td>{$item['name']}</td>
|
||||
|
||||
@@ -138,6 +138,7 @@ class Base extends \think\Controller{
|
||||
//request信息
|
||||
protected function requestInfo(){
|
||||
$this->request = \think\Request::instance();
|
||||
$this->param = $this->request->param();
|
||||
defined('MODULE_NAME') or define('MODULE_NAME', $this->request->module());
|
||||
defined('CONTROLLER_NAME') or define('CONTROLLER_NAME', $this->request->controller());
|
||||
defined('ACTION_NAME') or define('ACTION_NAME', $this->request->action());
|
||||
@@ -145,5 +146,6 @@ class Base extends \think\Controller{
|
||||
defined('IS_GET') or define('IS_GET', $this->request->isGet());
|
||||
$this->url = $this->request->module() . '/' . $this->request->controller() . '/' . $this->request->action();
|
||||
$this->assign('request',$this->request);
|
||||
$this->assign('param',$this->param);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,14 +14,16 @@ class Upload {
|
||||
public function upload(){
|
||||
$upload_type = input('get.filename','images','trim');
|
||||
$config = $this->$upload_type();
|
||||
$upload = new \org\Upload($config, $config['driver']);
|
||||
$info = $upload->upload($_FILES);
|
||||
if (false !== $info) {
|
||||
$fileinfo = $this->save($config, $upload_type, $info['file']);
|
||||
$return['info'] = $fileinfo;
|
||||
// 获取表单上传文件 例如上传了001.jpg
|
||||
$file = request()->file('file');
|
||||
$info = $file->move($config['rootPath'], true, false);
|
||||
|
||||
if($info){
|
||||
$return['status'] = 1;
|
||||
$return['info'] = $this->save($config, $upload_type, $info);
|
||||
}else{
|
||||
$return['status'] = 0;
|
||||
$return['info'] = $upload->getError();
|
||||
$return['info'] = $file->getError();
|
||||
}
|
||||
|
||||
echo json_encode($return);
|
||||
@@ -68,20 +70,10 @@ class Upload {
|
||||
* @access public
|
||||
*/
|
||||
public function save($config, $type, $file){
|
||||
$file = $this->parse_file($file);
|
||||
$file['status'] = 1;
|
||||
if ($type == 'images') {
|
||||
$dbname = 'picture';
|
||||
$file['path'] = substr($config['rootPath'], 1).$file['savepath'].$file['savename']; //
|
||||
}else{
|
||||
$dbname = 'file';
|
||||
$file['url'] = substr($config['rootPath'], 1).$file['savepath'].$file['savename'];
|
||||
}
|
||||
$data = db($dbname)->where(array('md5'=>$file['md5']))->find();
|
||||
if (!empty($data)) {
|
||||
return $data;
|
||||
}else{
|
||||
$id = db($dbname)->insertGetId($file);
|
||||
}
|
||||
$dbname = ($type == 'images') ? 'picture' : 'file';
|
||||
$id = db($dbname)->insertGetId($file);
|
||||
|
||||
if ($id) {
|
||||
$data = db($dbname)->where(array('id'=>$id))->find();
|
||||
@@ -119,4 +111,24 @@ class Upload {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
protected function parse_file($info){
|
||||
$data['create_time'] = $info->getATime(); //最后访问时间
|
||||
$data['savename'] = $info->getBasename(); //获取无路径的basename
|
||||
$data['c_time'] = $info->getCTime(); //获取inode修改时间
|
||||
$data['ext'] = $info->getExtension(); //文件扩展名
|
||||
$data['name'] = $info->getFilename(); //获取文件名
|
||||
$data['m_time'] = $info->getMTime(); //获取最后修改时间
|
||||
$data['owner'] = $info->getOwner(); //文件拥有者
|
||||
$data['savepath'] = $info->getPath(); //不带文件名的文件路径
|
||||
$data['url'] = $data['path'] = substr($info->getPathname(), 1); //全路径
|
||||
$data['size'] = $info->getSize(); //文件大小,单位字节
|
||||
$data['is_file'] = $info->isFile(); //是否是文件
|
||||
$data['is_execut'] = $info->isExecutable(); //是否可执行
|
||||
$data['is_readable'] = $info->isReadable(); //是否可读
|
||||
$data['is_writable'] = $info->isWritable(); //是否可写
|
||||
$data['md5'] = md5_file($info->getPathname());
|
||||
$data['sha1'] = sha1_file($info->getPathname());
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,7 @@
|
||||
return array(
|
||||
|
||||
// 调试模式
|
||||
'app_debug' => false,
|
||||
'app_debug' => true,
|
||||
|
||||
'charset' => 'UTF-8',
|
||||
'lang_switch_on' => true, // 开启语言包功能
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
return array(
|
||||
|
||||
'alipay' => array(
|
||||
'email' => 'ycgpp@126.com',
|
||||
'partner' => '2088002040431424',
|
||||
'key' => '49ee6pf892uc5p8py4hdfbi2wurnpk0x'
|
||||
),
|
||||
'wechat' => array()
|
||||
);
|
||||
@@ -40,10 +40,10 @@ class Collection implements ArrayAccess, Countable, IteratorAggregate, JsonSeria
|
||||
return empty($this->items);
|
||||
}
|
||||
|
||||
public function toArray($allow = [])
|
||||
public function toArray()
|
||||
{
|
||||
return array_map(function ($value) {
|
||||
return ($value instanceof Model || $value instanceof self) ? $value->toArray($allow) : $value;
|
||||
return ($value instanceof Model || $value instanceof self) ? $value->toArray() : $value;
|
||||
}, $this->items);
|
||||
}
|
||||
|
||||
@@ -225,11 +225,11 @@ class Collection implements ArrayAccess, Countable, IteratorAggregate, JsonSeria
|
||||
|
||||
$result = [];
|
||||
foreach ($this->items as $row) {
|
||||
$key = $value = null;
|
||||
$key = $value = null;
|
||||
$keySet = $valueSet = false;
|
||||
if (null !== $index_key && array_key_exists($index_key, $row)) {
|
||||
$keySet = true;
|
||||
$key = (string) $row[$index_key];
|
||||
$key = (string)$row[$index_key];
|
||||
}
|
||||
if (null === $column_key) {
|
||||
$valueSet = true;
|
||||
@@ -344,13 +344,12 @@ class Collection implements ArrayAccess, Countable, IteratorAggregate, JsonSeria
|
||||
/**
|
||||
* 转换当前数据集为JSON字符串
|
||||
* @access public
|
||||
* @param array $allow 允许输出的属性列表
|
||||
* @param integer $options json参数
|
||||
* @param integer $options json参数
|
||||
* @return string
|
||||
*/
|
||||
public function toJson($allow = [], $options = JSON_UNESCAPED_UNICODE)
|
||||
public function toJson($options = JSON_UNESCAPED_UNICODE)
|
||||
{
|
||||
return json_encode($this->toArray($allow), $options);
|
||||
return json_encode($this->toArray(), $options);
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
@@ -369,6 +368,6 @@ class Collection implements ArrayAccess, Countable, IteratorAggregate, JsonSeria
|
||||
if ($items instanceof self) {
|
||||
return $items->all();
|
||||
}
|
||||
return (array) $items;
|
||||
return (array)$items;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,6 +62,8 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
|
||||
|
||||
// 字段属性
|
||||
protected $field = [];
|
||||
// 显示属性
|
||||
protected $visible = [];
|
||||
// 隐藏属性
|
||||
protected $hidden = [];
|
||||
// 追加属性
|
||||
@@ -469,35 +471,46 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置需要输出的属性
|
||||
* @param array $visible
|
||||
* @return $this
|
||||
*/
|
||||
public function visible($visible = [])
|
||||
{
|
||||
$this->visible = $visible;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换当前模型对象为数组
|
||||
* @access public
|
||||
* @param array $allow 允许输出的属性列表
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($allow = [])
|
||||
public function toArray()
|
||||
{
|
||||
$item = [];
|
||||
if (empty($allow)) {
|
||||
$allow = array_keys($this->data);
|
||||
}
|
||||
$allow = array_diff($allow, $this->hidden);
|
||||
foreach ($this->data as $key => $val) {
|
||||
// 属性过滤输出
|
||||
if (!in_array($key, $allow)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
//过滤属性
|
||||
if (!empty($this->visible)) {
|
||||
$data = array_intersect_key($this->data, array_flip($this->visible));
|
||||
} elseif (!empty($this->hidden)) {
|
||||
$data = array_diff_key($this->data, array_flip($this->hidden));
|
||||
} else {
|
||||
$data = $this->data;
|
||||
}
|
||||
|
||||
foreach ($data as $key => $val) {
|
||||
if ($val instanceof Model || $val instanceof Collection) {
|
||||
// 关联模型对象
|
||||
$item[$key] = $val->toArray();
|
||||
} elseif (is_array($val) && reset($val) instanceof Model) {
|
||||
// 关联模型数据集
|
||||
$data = [];
|
||||
$arr = [];
|
||||
foreach ($val as $k => $value) {
|
||||
$data[$k] = $value->toArray();
|
||||
$arr[$k] = $value->toArray();
|
||||
}
|
||||
$item[$key] = $data;
|
||||
$item[$key] = $arr;
|
||||
} else {
|
||||
// 模型属性
|
||||
$item[$key] = $this->getAttr($key);
|
||||
@@ -515,13 +528,12 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
|
||||
/**
|
||||
* 转换当前模型对象为JSON字符串
|
||||
* @access public
|
||||
* @param array $allow 允许输出的属性列表
|
||||
* @param integer $options json参数
|
||||
* @return string
|
||||
*/
|
||||
public function toJson($allow = [], $options = JSON_UNESCAPED_UNICODE)
|
||||
public function toJson($options = JSON_UNESCAPED_UNICODE)
|
||||
{
|
||||
return json_encode($this->toArray($allow), $options);
|
||||
return json_encode($this->toArray(), $options);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -19,9 +19,6 @@ use think\Route;
|
||||
|
||||
class Url
|
||||
{
|
||||
// 生成URL地址的root
|
||||
protected static $root;
|
||||
|
||||
/**
|
||||
* URL生成 支持路由反射
|
||||
* @param string $url URL表达式,
|
||||
@@ -116,7 +113,7 @@ class Url
|
||||
// 检测域名
|
||||
$domain = self::parseDomain($url, $domain);
|
||||
// URL组装
|
||||
$url = $domain . (self::$root ?: Request::instance()->root()) . '/' . ltrim($url, '/');
|
||||
$url = $domain . Request::instance()->root() . '/' . ltrim($url, '/');
|
||||
return $url;
|
||||
}
|
||||
|
||||
@@ -319,11 +316,4 @@ class Url
|
||||
{
|
||||
Cache::rm('think_route_map');
|
||||
}
|
||||
|
||||
// 指定当前生成URL地址的root
|
||||
public static function root($root)
|
||||
{
|
||||
self::$root = $root;
|
||||
Request::instance()->root($root);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -51,7 +51,7 @@ class Collection extends \think\Collection
|
||||
return $this->paginator;
|
||||
}
|
||||
|
||||
public function toArray($allow = [])
|
||||
public function toArray()
|
||||
{
|
||||
if ($this->paginator) {
|
||||
try {
|
||||
@@ -64,10 +64,10 @@ class Collection extends \think\Collection
|
||||
'total' => $total,
|
||||
'per_page' => $this->listRows(),
|
||||
'current_page' => $this->currentPage(),
|
||||
'data' => parent::toArray($allow)
|
||||
'data' => parent::toArray()
|
||||
];
|
||||
} else {
|
||||
return parent::toArray($allow);
|
||||
return parent::toArray();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user