Pre Merge pull request !503 from mrcdh/1.x-dev

pull/503/MERGE
mrcdh 2025-09-03 09:56:28 +00:00 committed by Gitee
commit 4e47b6586b
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
15 changed files with 56 additions and 67 deletions

View File

@ -3,7 +3,6 @@
namespace app\admin\controller; namespace app\admin\controller;
use app\common\controller\Backend; use app\common\controller\Backend;
use fast\Http;
use think\addons\AddonException; use think\addons\AddonException;
use think\addons\Service; use think\addons\Service;
use think\Cache; use think\Cache;
@ -36,7 +35,7 @@ class Addon extends Backend
public function index() public function index()
{ {
$addons = get_addon_list(); $addons = get_addon_list();
foreach ($addons as $k => &$v) { foreach ($addons as &$v) {
$config = get_addon_config($v['name']); $config = get_addon_config($v['name']);
$v['config'] = $config ? 1 : 0; $v['config'] = $config ? 1 : 0;
$v['url'] = str_replace($this->request->server('SCRIPT_NAME'), '', $v['url']); $v['url'] = str_replace($this->request->server('SCRIPT_NAME'), '', $v['url']);
@ -50,7 +49,7 @@ class Addon extends Backend
*/ */
public function config($name = null) public function config($name = null)
{ {
$name = $name ? $name : $this->request->get("name"); $name = $name ?: $this->request->get("name");
if (!$name) { if (!$name) {
$this->error(__('Parameter %s can not be empty', 'name')); $this->error(__('Parameter %s can not be empty', 'name'));
} }
@ -65,7 +64,7 @@ class Addon extends Backend
if ($this->request->isPost()) { if ($this->request->isPost()) {
$params = $this->request->post("row/a", [], 'trim'); $params = $this->request->post("row/a", [], 'trim');
if ($params) { if ($params) {
foreach ($config as $k => &$v) { foreach ($config as &$v) {
if (isset($params[$v['name']])) { if (isset($params[$v['name']])) {
if ($v['type'] == 'array') { if ($v['type'] == 'array') {
$params[$v['name']] = is_array($params[$v['name']]) ? $params[$v['name']] : (array)json_decode($params[$v['name']], true); $params[$v['name']] = is_array($params[$v['name']]) ? $params[$v['name']] : (array)json_decode($params[$v['name']], true);
@ -179,7 +178,7 @@ class Addon extends Backend
if ($tables) { if ($tables) {
$prefix = Config::get('database.prefix'); $prefix = Config::get('database.prefix');
//删除插件关联表 //删除插件关联表
foreach ($tables as $index => $table) { foreach ($tables as $table) {
//忽略非插件标识的表名 //忽略非插件标识的表名
if (!preg_match("/^{$prefix}{$name}/", $table)) { if (!preg_match("/^{$prefix}{$name}/", $table)) {
continue; continue;
@ -331,7 +330,7 @@ class Addon extends Backend
$filter = (array)json_decode($filter, true); $filter = (array)json_decode($filter, true);
$addons = get_addon_list(); $addons = get_addon_list();
$list = []; $list = [];
foreach ($addons as $k => $v) { foreach ($addons as $v) {
if ($search && stripos($v['name'], $search) === false && stripos($v['title'], $search) === false && stripos($v['intro'], $search) === false) { if ($search && stripos($v['name'], $search) === false && stripos($v['title'], $search) === false && stripos($v['intro'], $search) === false) {
continue; continue;
} }
@ -448,7 +447,7 @@ class Addon extends Backend
} }
$rows = $json['rows'] ?? []; $rows = $json['rows'] ?? [];
foreach ($rows as $index => $row) { foreach ($rows as $row) {
if (!isset($row['name'])) { if (!isset($row['name'])) {
continue; continue;
} }

View File

@ -6,7 +6,6 @@ use app\admin\model\AdminLog;
use app\common\controller\Backend; use app\common\controller\Backend;
use app\common\exception\UploadException; use app\common\exception\UploadException;
use app\common\library\Upload; use app\common\library\Upload;
use fast\Random;
use think\addons\Service; use think\addons\Service;
use think\Cache; use think\Cache;
use think\Config; use think\Config;
@ -14,7 +13,6 @@ use think\Db;
use think\Lang; use think\Lang;
use think\Loader; use think\Loader;
use think\Response; use think\Response;
use think\Validate;
/** /**
* Ajax异步请求接口 * Ajax异步请求接口
@ -231,7 +229,6 @@ class Ajax extends Backend
$type = $this->request->get('type', ''); $type = $this->request->get('type', '');
$pid = $this->request->get('pid', ''); $pid = $this->request->get('pid', '');
$where = ['status' => 'normal']; $where = ['status' => 'normal'];
$categorylist = null;
if ($pid || $pid === '0') { if ($pid || $pid === '0') {
$where['pid'] = $pid; $where['pid'] = $pid;
} }
@ -258,7 +255,6 @@ class Ajax extends Backend
$city = $this->request->get('city'); $city = $this->request->get('city');
} }
$where = ['pid' => 0, 'level' => 1]; $where = ['pid' => 0, 'level' => 1];
$provincelist = null;
if ($province !== null) { if ($province !== null) {
$where['pid'] = $province; $where['pid'] = $province;
$where['level'] = 2; $where['level'] = 2;
@ -277,7 +273,7 @@ class Ajax extends Backend
public function icon() public function icon()
{ {
$suffix = $this->request->request("suffix"); $suffix = $this->request->request("suffix");
$suffix = $suffix ? $suffix : "FILE"; $suffix = $suffix ?: "FILE";
$data = build_suffix_image($suffix); $data = build_suffix_image($suffix);
$header = ['Content-Type' => 'image/svg+xml']; $header = ['Content-Type' => 'image/svg+xml'];
$offset = 30 * 60 * 60 * 24; // 缓存一个月 $offset = 30 * 60 * 60 * 24; // 缓存一个月

View File

@ -16,7 +16,7 @@ class Category extends Backend
{ {
/** /**
* @var \app\common\model\Category * @var CategoryModel
*/ */
protected $model = null; protected $model = null;
protected $categorylist = []; protected $categorylist = [];
@ -31,7 +31,7 @@ class Category extends Backend
$tree->init(collection($this->model->order('weigh desc,id desc')->select())->toArray(), 'pid'); $tree->init(collection($this->model->order('weigh desc,id desc')->select())->toArray(), 'pid');
$this->categorylist = $tree->getTreeList($tree->getTreeArray(0), 'name'); $this->categorylist = $tree->getTreeList($tree->getTreeArray(0), 'name');
$categorydata = [0 => ['type' => 'all', 'name' => __('None')]]; $categorydata = [0 => ['type' => 'all', 'name' => __('None')]];
foreach ($this->categorylist as $k => $v) { foreach ($this->categorylist as $v) {
$categorydata[$v['id']] = $v; $categorydata[$v['id']] = $v;
} }
$typeList = CategoryModel::getTypeList(); $typeList = CategoryModel::getTypeList();
@ -55,7 +55,7 @@ class Category extends Backend
//构造父类select列表选项数据 //构造父类select列表选项数据
$list = []; $list = [];
foreach ($this->categorylist as $k => $v) { foreach ($this->categorylist as $v) {
if ($search) { if ($search) {
if ($v['type'] == $type && stripos($v['name'], $search) !== false || stripos($v['nickname'], $search) !== false) { if ($v['type'] == $type && stripos($v['name'], $search) !== false || stripos($v['nickname'], $search) !== false) {
if ($type == "all" || $type == null) { if ($type == "all" || $type == null) {
@ -114,7 +114,7 @@ class Category extends Backend
$params = $this->preExcludeFields($params); $params = $this->preExcludeFields($params);
if ($params['pid'] != $row['pid']) { if ($params['pid'] != $row['pid']) {
$childrenIds = Tree::instance()->init(collection(\app\common\model\Category::select())->toArray())->getChildrenIds($row['id'], true); $childrenIds = Tree::instance()->init(collection(CategoryModel::select())->toArray())->getChildrenIds($row['id'], true);
if (in_array($params['pid'], $childrenIds)) { if (in_array($params['pid'], $childrenIds)) {
$this->error(__('Can not change the parent to child or itself')); $this->error(__('Can not change the parent to child or itself'));
} }

View File

@ -40,7 +40,7 @@ class Dashboard extends Backend
$time += 86400; $time += 86400;
} }
$userlist = array_fill_keys($column, 0); $userlist = array_fill_keys($column, 0);
foreach ($joinlist as $k => $v) { foreach ($joinlist as $v) {
$userlist[$v['join_date']] = $v['nums']; $userlist[$v['join_date']] = $v['nums'];
} }
@ -48,7 +48,7 @@ class Dashboard extends Backend
$addonList = get_addon_list(); $addonList = get_addon_list();
$totalworkingaddon = 0; $totalworkingaddon = 0;
$totaladdon = count($addonList); $totaladdon = count($addonList);
foreach ($addonList as $index => $item) { foreach ($addonList as $item) {
if ($item['state']) { if ($item['state']) {
$totalworkingaddon += 1; $totalworkingaddon += 1;
} }

View File

@ -109,7 +109,7 @@ class Index extends Backend
$this->success(__('Login successful'), $url, ['url' => $url, 'id' => $this->auth->id, 'username' => $username, 'avatar' => $this->auth->avatar]); $this->success(__('Login successful'), $url, ['url' => $url, 'id' => $this->auth->id, 'username' => $username, 'avatar' => $this->auth->avatar]);
} else { } else {
$msg = $this->auth->getError(); $msg = $this->auth->getError();
$msg = $msg ? $msg : __('Username or password is incorrect'); $msg = $msg ?: __('Username or password is incorrect');
$this->error($msg, $url, ['token' => $this->request->token()]); $this->error($msg, $url, ['token' => $this->request->token()]);
} }
} }

View File

@ -42,16 +42,16 @@ class Admin extends Backend
$groupdata = []; $groupdata = [];
if ($this->auth->isSuperAdmin()) { if ($this->auth->isSuperAdmin()) {
$result = Tree::instance()->getTreeList(Tree::instance()->getTreeArray(0)); $result = Tree::instance()->getTreeList(Tree::instance()->getTreeArray(0));
foreach ($result as $k => $v) { foreach ($result as $v) {
$groupdata[$v['id']] = $v['name']; $groupdata[$v['id']] = $v['name'];
} }
} else { } else {
$result = []; $result = [];
$groups = $this->auth->getGroups(); $groups = $this->auth->getGroups();
foreach ($groups as $m => $n) { foreach ($groups as $n) {
$childlist = Tree::instance()->getTreeList(Tree::instance()->getTreeArray($n['id'])); $childlist = Tree::instance()->getTreeList(Tree::instance()->getTreeArray($n['id']));
$temp = []; $temp = [];
foreach ($childlist as $k => $v) { foreach ($childlist as $v) {
$temp[$v['id']] = $v['name']; $temp[$v['id']] = $v['name'];
} }
$result[__($n['name'])] = $temp; $result[__($n['name'])] = $temp;
@ -83,13 +83,13 @@ class Admin extends Backend
->select(); ->select();
$adminGroupName = []; $adminGroupName = [];
foreach ($authGroupList as $k => $v) { foreach ($authGroupList as $v) {
if (isset($groupName[$v['group_id']])) { if (isset($groupName[$v['group_id']])) {
$adminGroupName[$v['uid']][$v['group_id']] = $groupName[$v['group_id']]; $adminGroupName[$v['uid']][$v['group_id']] = $groupName[$v['group_id']];
} }
} }
$groups = $this->auth->getGroups(); $groups = $this->auth->getGroups();
foreach ($groups as $m => $n) { foreach ($groups as $n) {
$adminGroupName[$this->auth->id][$n['id']] = $n['name']; $adminGroupName[$this->auth->id][$n['id']] = $n['name'];
} }
list($where, $sort, $order, $offset, $limit) = $this->buildparams(); list($where, $sort, $order, $offset, $limit) = $this->buildparams();
@ -101,8 +101,8 @@ class Admin extends Backend
->order($sort, $order) ->order($sort, $order)
->paginate($limit); ->paginate($limit);
foreach ($list as $k => &$v) { foreach ($list as &$v) {
$groups = isset($adminGroupName[$v['id']]) ? $adminGroupName[$v['id']] : []; $groups = $adminGroupName[$v['id']] ?? [];
$v['groups'] = implode(',', array_keys($groups)); $v['groups'] = implode(',', array_keys($groups));
$v['groups_text'] = implode(',', array_values($groups)); $v['groups_text'] = implode(',', array_values($groups));
} }
@ -227,7 +227,7 @@ class Admin extends Backend
} }
$grouplist = $this->auth->getGroups($row['id']); $grouplist = $this->auth->getGroups($row['id']);
$groupids = []; $groupids = [];
foreach ($grouplist as $k => $v) { foreach ($grouplist as $v) {
$groupids[] = $v['id']; $groupids[] = $v['id'];
} }
$this->view->assign("row", $row); $this->view->assign("row", $row);
@ -243,7 +243,7 @@ class Admin extends Backend
if (!$this->request->isPost()) { if (!$this->request->isPost()) {
$this->error(__("Invalid parameters")); $this->error(__("Invalid parameters"));
} }
$ids = $ids ? $ids : $this->request->post("ids"); $ids = $ids ?: $this->request->post("ids");
if ($ids) { if ($ids) {
$ids = array_intersect($this->childrenAdminIds, array_filter(explode(',', $ids))); $ids = array_intersect($this->childrenAdminIds, array_filter(explode(',', $ids)));
// 避免越权删除管理员 // 避免越权删除管理员
@ -253,7 +253,7 @@ class Admin extends Backend
})->select(); })->select();
if ($adminList) { if ($adminList) {
$deleteIds = []; $deleteIds = [];
foreach ($adminList as $k => $v) { foreach ($adminList as $v) {
$deleteIds[] = $v->id; $deleteIds[] = $v->id;
} }
$deleteIds = array_values(array_diff($deleteIds, [$this->auth->id])); $deleteIds = array_values(array_diff($deleteIds, [$this->auth->id]));

View File

@ -2,7 +2,6 @@
namespace app\admin\controller\auth; namespace app\admin\controller\auth;
use app\admin\model\AuthGroup;
use app\common\controller\Backend; use app\common\controller\Backend;
/** /**
@ -100,7 +99,7 @@ class Adminlog extends Backend
if (!$this->request->isPost()) { if (!$this->request->isPost()) {
$this->error(__("Invalid parameters")); $this->error(__("Invalid parameters"));
} }
$ids = $ids ? $ids : $this->request->post("ids"); $ids = $ids ?: $this->request->post("ids");
if ($ids) { if ($ids) {
$isSuperAdmin = $this->auth->isSuperAdmin(); $isSuperAdmin = $this->auth->isSuperAdmin();
$childrenAdminIds = $this->childrenAdminIds; $childrenAdminIds = $this->childrenAdminIds;

View File

@ -3,7 +3,6 @@
namespace app\admin\controller\auth; namespace app\admin\controller\auth;
use app\admin\model\AuthGroup; use app\admin\model\AuthGroup;
use app\admin\model\AuthGroupAccess;
use app\common\controller\Backend; use app\common\controller\Backend;
use fast\Tree; use fast\Tree;
use think\Db; use think\Db;
@ -19,7 +18,7 @@ class Group extends Backend
{ {
/** /**
* @var \app\admin\model\AuthGroup * @var AuthGroup
*/ */
protected $model = null; protected $model = null;
//当前登录管理员所有子组别 //当前登录管理员所有子组别
@ -59,7 +58,7 @@ class Group extends Backend
$groupList = $tree->getTreeList($tree->getTreeArray(0)); $groupList = $tree->getTreeList($tree->getTreeArray(0));
} }
$groupName = []; $groupName = [];
foreach ($groupList as $k => $v) { foreach ($groupList as $v) {
$groupName[$v['id']] = $v['name']; $groupName[$v['id']] = $v['name'];
} }
@ -191,7 +190,7 @@ class Group extends Backend
if (!$this->request->isPost()) { if (!$this->request->isPost()) {
$this->error(__("Invalid parameters")); $this->error(__("Invalid parameters"));
} }
$ids = $ids ? $ids : $this->request->post("ids"); $ids = $ids ?: $this->request->post("ids");
if ($ids) { if ($ids) {
$ids = explode(',', $ids); $ids = explode(',', $ids);
$grouplist = $this->auth->getGroups(); $grouplist = $this->auth->getGroups();
@ -215,7 +214,6 @@ class Group extends Backend
$groupone = $this->model->get(['pid' => $v['id']]); $groupone = $this->model->get(['pid' => $v['id']]);
if ($groupone) { if ($groupone) {
$ids = array_diff($ids, [$v['id']]); $ids = array_diff($ids, [$v['id']]);
continue;
} }
} }
if (!$ids) { if (!$ids) {
@ -257,7 +255,7 @@ class Group extends Backend
$currentGroupModel = $model->get($id); $currentGroupModel = $model->get($id);
} }
if (($pid || $parentGroupModel) && (!$id || $currentGroupModel)) { if (($pid || $parentGroupModel) && (!$id || $currentGroupModel)) {
$id = $id ? $id : null; $id = $id ?: null;
$ruleList = collection(model('AuthRule')->order('weigh', 'desc')->order('id', 'asc')->select())->toArray(); $ruleList = collection(model('AuthRule')->order('weigh', 'desc')->order('id', 'asc')->select())->toArray();
//读取父类角色所有节点列表 //读取父类角色所有节点列表
$parentRuleList = []; $parentRuleList = [];
@ -265,7 +263,7 @@ class Group extends Backend
$parentRuleList = $ruleList; $parentRuleList = $ruleList;
} else { } else {
$parentRuleIds = explode(',', $parentGroupModel->rules); $parentRuleIds = explode(',', $parentGroupModel->rules);
foreach ($ruleList as $k => $v) { foreach ($ruleList as $v) {
if (in_array($v['id'], $parentRuleIds)) { if (in_array($v['id'], $parentRuleIds)) {
$parentRuleList[] = $v; $parentRuleList[] = $v;
} }
@ -289,7 +287,7 @@ class Group extends Backend
if (!$id || !in_array($pid, $this->childrenGroupIds) || !in_array($pid, $groupTree->getChildrenIds($id, true))) { if (!$id || !in_array($pid, $this->childrenGroupIds) || !in_array($pid, $groupTree->getChildrenIds($id, true))) {
$parentRuleList = $ruleTree->getTreeList($ruleTree->getTreeArray(0), 'name'); $parentRuleList = $ruleTree->getTreeList($ruleTree->getTreeArray(0), 'name');
$hasChildrens = []; $hasChildrens = [];
foreach ($parentRuleList as $k => $v) { foreach ($parentRuleList as $v) {
if ($v['haschild']) { if ($v['haschild']) {
$hasChildrens[] = $v['id']; $hasChildrens[] = $v['id'];
} }
@ -306,7 +304,7 @@ class Group extends Backend
continue; continue;
} }
$state = array('selected' => in_array($v['id'], $currentRuleIds) && !in_array($v['id'], $hasChildrens)); $state = array('selected' => in_array($v['id'], $currentRuleIds) && !in_array($v['id'], $hasChildrens));
$nodeList[] = array('id' => $v['id'], 'parent' => $v['pid'] ? $v['pid'] : '#', 'text' => __($v['title']), 'type' => 'menu', 'state' => $state); $nodeList[] = array('id' => $v['id'], 'parent' => $v['pid'] ?: '#', 'text' => __($v['title']), 'type' => 'menu', 'state' => $state);
} }
$this->success('', null, $nodeList); $this->success('', null, $nodeList);
} else { } else {

View File

@ -6,8 +6,6 @@ use app\admin\model\AuthRule;
use app\common\controller\Backend; use app\common\controller\Backend;
use fast\Tree; use fast\Tree;
use think\Cache; use think\Cache;
use think\db\Query;
use think\exception\HttpResponseException;
/** /**
* 规则管理 * 规则管理
@ -19,7 +17,7 @@ class Rule extends Backend
{ {
/** /**
* @var \app\admin\model\AuthRule * @var AuthRule
*/ */
protected $model = null; protected $model = null;
protected $rulelist = []; protected $rulelist = [];
@ -34,14 +32,14 @@ class Rule extends Backend
$this->model = model('AuthRule'); $this->model = model('AuthRule');
// 必须将结果集转换为数组 // 必须将结果集转换为数组
$ruleList = \think\Db::name("auth_rule")->field('type,condition,remark,menutype,extend,pinyin,py,createtime,updatetime', true)->order('weigh DESC,id ASC')->select(); $ruleList = \think\Db::name("auth_rule")->field('type,condition,remark,menutype,extend,pinyin,py,createtime,updatetime', true)->order('weigh DESC,id ASC')->select();
foreach ($ruleList as $k => &$v) { foreach ($ruleList as &$v) {
$v['title'] = __($v['title']); $v['title'] = __($v['title']);
} }
unset($v); unset($v);
Tree::instance()->init($ruleList)->icon = ['    ', '    ', '    ']; Tree::instance()->init($ruleList)->icon = ['    ', '    ', '    '];
$this->rulelist = Tree::instance()->getTreeList(Tree::instance()->getTreeArray(0), 'title'); $this->rulelist = Tree::instance()->getTreeList(Tree::instance()->getTreeArray(0), 'title');
$ruledata = [0 => __('None')]; $ruledata = [0 => __('None')];
foreach ($this->rulelist as $k => &$v) { foreach ($this->rulelist as &$v) {
if (!$v['ismenu']) { if (!$v['ismenu']) {
continue; continue;
} }
@ -141,10 +139,10 @@ class Rule extends Backend
if (!$this->request->isPost()) { if (!$this->request->isPost()) {
$this->error(__("Invalid parameters")); $this->error(__("Invalid parameters"));
} }
$ids = $ids ? $ids : $this->request->post("ids"); $ids = $ids ?: $this->request->post("ids");
if ($ids) { if ($ids) {
$delIds = []; $delIds = [];
foreach (explode(',', $ids) as $k => $v) { foreach (explode(',', $ids) as $v) {
$delIds = array_merge($delIds, Tree::instance()->getChildrenIds($v, true)); $delIds = array_merge($delIds, Tree::instance()->getChildrenIds($v, true));
} }
$delIds = array_unique($delIds); $delIds = array_unique($delIds);

View File

@ -66,7 +66,7 @@ class Attachment extends Backend
->paginate($limit); ->paginate($limit);
$cdnurl = preg_replace("/\/(\w+)\.php$/i", '', $this->request->root(true)); $cdnurl = preg_replace("/\/(\w+)\.php$/i", '', $this->request->root(true));
foreach ($list as $k => &$v) { foreach ($list as &$v) {
$v['fullurl'] = ($v['storage'] == 'local' ? $cdnurl : $this->view->config['upload']['cdnurl']) . $v['url']; $v['fullurl'] = ($v['storage'] == 'local' ? $cdnurl : $this->view->config['upload']['cdnurl']) . $v['url'];
} }
unset($v); unset($v);
@ -111,7 +111,7 @@ class Attachment extends Backend
if (!$this->request->isPost()) { if (!$this->request->isPost()) {
$this->error(__("Invalid parameters")); $this->error(__("Invalid parameters"));
} }
$ids = $ids ? $ids : $this->request->post("ids"); $ids = $ids ?: $this->request->post("ids");
if ($ids) { if ($ids) {
\think\Hook::add('upload_delete', function ($params) { \think\Hook::add('upload_delete', function ($params) {
if ($params['storage'] == 'local') { if ($params['storage'] == 'local') {

View File

@ -5,7 +5,6 @@ namespace app\admin\controller\general;
use app\common\controller\Backend; use app\common\controller\Backend;
use app\common\library\Email; use app\common\library\Email;
use app\common\model\Config as ConfigModel; use app\common\model\Config as ConfigModel;
use think\Cache;
use think\Db; use think\Db;
use think\Exception; use think\Exception;
use think\Validate; use think\Validate;
@ -20,7 +19,7 @@ class Config extends Backend
{ {
/** /**
* @var \app\common\model\Config * @var ConfigModel
*/ */
protected $model = null; protected $model = null;
protected $noNeedRight = ['check', 'rulelist', 'selectpage', 'get_fields_list']; protected $noNeedRight = ['check', 'rulelist', 'selectpage', 'get_fields_list'];
@ -62,7 +61,7 @@ class Config extends Backend
$value['content'] = json_decode($value['content'], true); $value['content'] = json_decode($value['content'], true);
if (in_array($value['name'], ['categorytype', 'configgroup', 'attachmentcategory'])) { if (in_array($value['name'], ['categorytype', 'configgroup', 'attachmentcategory'])) {
$dictValue = (array)json_decode($value['value'], true); $dictValue = (array)json_decode($value['value'], true);
foreach ($dictValue as $index => &$item) { foreach ($dictValue as &$item) {
$item = __($item); $item = __($item);
} }
unset($item); unset($item);
@ -76,8 +75,8 @@ class Config extends Backend
$siteList[$v['group']]['list'][] = $value; $siteList[$v['group']]['list'][] = $value;
} }
$index = 0; $index = 0;
foreach ($siteList as $k => &$v) { foreach ($siteList as &$v) {
$v['active'] = !$index ? true : false; $v['active'] = !$index;
$index++; $index++;
} }
$this->view->assign('siteList', $siteList); $this->view->assign('siteList', $siteList);
@ -222,7 +221,7 @@ class Config extends Backend
$keyValue = $this->request->request("keyValue", ""); $keyValue = $this->request->request("keyValue", "");
$keyValueArr = array_filter(explode(',', $keyValue)); $keyValueArr = array_filter(explode(',', $keyValue));
$regexList = \app\common\model\Config::getRegexList(); $regexList = ConfigModel::getRegexList();
$list = []; $list = [];
foreach ($regexList as $k => $v) { foreach ($regexList as $k => $v) {
if ($keyValueArr) { if ($keyValueArr) {
@ -268,7 +267,7 @@ class Config extends Backend
public function selectpage() public function selectpage()
{ {
$id = $this->request->get("id/d"); $id = $this->request->get("id/d");
$config = \app\common\model\Config::get($id); $config = ConfigModel::get($id);
if (!$config) { if (!$config) {
$this->error(__('Invalid parameters')); $this->error(__('Invalid parameters'));
} }

View File

@ -78,6 +78,5 @@ class Profile extends Backend
} }
$this->error(); $this->error();
} }
return;
} }
} }

View File

@ -27,7 +27,7 @@ class Rule extends Backend
$this->view->assign("statusList", $this->model->getStatusList()); $this->view->assign("statusList", $this->model->getStatusList());
// 必须将结果集转换为数组 // 必须将结果集转换为数组
$ruleList = collection($this->model->order('weigh', 'desc')->select())->toArray(); $ruleList = collection($this->model->order('weigh', 'desc')->select())->toArray();
foreach ($ruleList as $k => &$v) { foreach ($ruleList as &$v) {
$v['title'] = __($v['title']); $v['title'] = __($v['title']);
$v['remark'] = __($v['remark']); $v['remark'] = __($v['remark']);
} }
@ -35,7 +35,7 @@ class Rule extends Backend
Tree::instance()->init($ruleList)->icon = ['    ', '    ', '    ']; Tree::instance()->init($ruleList)->icon = ['    ', '    ', '    '];
$this->rulelist = Tree::instance()->getTreeList(Tree::instance()->getTreeArray(0), 'title'); $this->rulelist = Tree::instance()->getTreeList(Tree::instance()->getTreeArray(0), 'title');
$ruledata = [0 => __('None')]; $ruledata = [0 => __('None')];
foreach ($this->rulelist as $k => &$v) { foreach ($this->rulelist as &$v) {
if (!$v['ismenu']) { if (!$v['ismenu']) {
continue; continue;
} }
@ -90,10 +90,10 @@ class Rule extends Backend
if (!$this->request->isPost()) { if (!$this->request->isPost()) {
$this->error(__("Invalid parameters")); $this->error(__("Invalid parameters"));
} }
$ids = $ids ? $ids : $this->request->post("ids"); $ids = $ids ?: $this->request->post("ids");
if ($ids) { if ($ids) {
$delIds = []; $delIds = [];
foreach (explode(',', $ids) as $k => $v) { foreach (explode(',', $ids) as $v) {
$delIds = array_merge($delIds, Tree::instance()->getChildrenIds($v, true)); $delIds = array_merge($delIds, Tree::instance()->getChildrenIds($v, true));
} }
$delIds = array_unique($delIds); $delIds = array_unique($delIds);

View File

@ -2,6 +2,7 @@
namespace app\admin\controller\user; namespace app\admin\controller\user;
use app\admin\model\UserGroup;
use app\common\controller\Backend; use app\common\controller\Backend;
use app\common\library\Auth; use app\common\library\Auth;
@ -44,12 +45,12 @@ class User extends Backend
->where($where) ->where($where)
->order($sort, $order) ->order($sort, $order)
->paginate($limit); ->paginate($limit);
foreach ($list as $k => $v) { foreach ($list as $v) {
$v->avatar = $v->avatar ? cdnurl($v->avatar, true) : letter_avatar($v->nickname); $v->avatar = $v->avatar ? cdnurl($v->avatar, true) : letter_avatar($v->nickname);
$v->hidden(['password', 'salt']); $v->hidden(['password', 'salt']);
} }
$rows = $list->items(); $rows = $list->items();
addtion($rows, [['field' => 'group_id', 'display' => 'group_name', 'model' => \app\admin\model\UserGroup::class]]); addtion($rows, [['field' => 'group_id', 'display' => 'group_name', 'model' => UserGroup::class]]);
$result = array("total" => $list->total(), "rows" => $rows); $result = array("total" => $list->total(), "rows" => $rows);
return json($result); return json($result);
@ -81,7 +82,7 @@ class User extends Backend
if (!$row) { if (!$row) {
$this->error(__('No Results were found')); $this->error(__('No Results were found'));
} }
$this->view->assign('groupList', build_select('row[group_id]', \app\admin\model\UserGroup::column('id,name'), $row['group_id'], ['class' => 'form-control selectpicker'])); $this->view->assign('groupList', build_select('row[group_id]', UserGroup::column('id,name'), $row['group_id'], ['class' => 'form-control selectpicker']));
return parent::edit($ids); return parent::edit($ids);
} }
@ -93,7 +94,7 @@ class User extends Backend
if (!$this->request->isPost()) { if (!$this->request->isPost()) {
$this->error(__("Invalid parameters")); $this->error(__("Invalid parameters"));
} }
$ids = $ids ? $ids : $this->request->post("ids"); $ids = $ids ?: $this->request->post("ids");
$row = $this->model->get($ids); $row = $this->model->get($ids);
$this->modelValidate = true; $this->modelValidate = true;
if (!$row) { if (!$row) {

View File

@ -521,7 +521,7 @@ trait Backend
$database = \think\Config::get('database.database'); $database = \think\Config::get('database.database');
$fieldArr = []; $fieldArr = [];
$list = db()->query("SELECT COLUMN_NAME,COLUMN_COMMENT FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = ? AND TABLE_SCHEMA = ?", [$table, $database]); $list = db()->query("SELECT COLUMN_NAME,COLUMN_COMMENT FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = ? AND TABLE_SCHEMA = ?", [$table, $database]);
foreach ($list as $k => $v) { foreach ($list as $v) {
if ($importHeadType == 'comment') { if ($importHeadType == 'comment') {
$v['COLUMN_COMMENT'] = explode(':', $v['COLUMN_COMMENT'])[0]; //字段备注有:时截取 $v['COLUMN_COMMENT'] = explode(':', $v['COLUMN_COMMENT'])[0]; //字段备注有:时截取
$fieldArr[$v['COLUMN_COMMENT']] = $v['COLUMN_NAME']; $fieldArr[$v['COLUMN_COMMENT']] = $v['COLUMN_NAME'];
@ -575,7 +575,7 @@ trait Backend
try { try {
//是否包含admin_id字段 //是否包含admin_id字段
$has_admin_id = false; $has_admin_id = false;
foreach ($fieldArr as $name => $key) { foreach ($fieldArr as $key) {
if ($key == 'admin_id') { if ($key == 'admin_id') {
$has_admin_id = true; $has_admin_id = true;
break; break;