Skip to content

Commit

Permalink
bug
Browse files Browse the repository at this point in the history
  • Loading branch information
star7th committed Jul 10, 2024
1 parent c5e7eff commit 33662f4
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 15 deletions.
11 changes: 9 additions & 2 deletions server/Application/Api/Controller/ItemController.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,10 @@ private function _show_regular_item($item)
if ($keyword) {
$keyword = strtolower($keyword);
$keyword = \SQLite3::escapeString($keyword);
$pages = D("Page")->where("item_id = '$item_id' and is_del = 0 and ( lower(page_title) like '%{$keyword}%' or lower(page_content) like '%{$keyword}%' ) ")->order(" s_number asc ")->field("page_id,author_uid,cat_id,page_title,addtime")->select();
$where = "item_id = '$item_id' and is_del = 0 and ( lower(page_title) like '%{$keyword}%' or lower(page_content) like '%{$keyword}%' ) " ;
// 如果用户被分配了 目录权限 ,则获取他在该项目下拥有权限的目录id
$cat_id = D("Member")->getCatId($item_id, $uid);
$menu['pages'] = $pages = D("Page")->search($item_id, $cat_id, $keyword);
$menu['pages'] = $pages ? $pages : array();
$menu['catalogs'] = array();
} else {
Expand Down Expand Up @@ -568,6 +571,8 @@ public function pwd()
}
}

$item_id = \SQLite3::escapeString($item_id);

if ($page_id > 0) {
$page = M("Page")->where(" page_id = '$page_id' ")->find();
if ($page) {
Expand Down Expand Up @@ -742,7 +747,9 @@ public function search()
}
$item = D("Item")->where("item_id = '%d' and is_del = 0 ", array($item_id))->find();
$keyword = \SQLite3::escapeString($keyword);
$pages = D("Page")->search($item_id, $keyword);
// 如果用户被分配了 目录权限 ,则获取他在该项目下拥有权限的目录id
$cat_id = D("Member")->getCatId($item_id, $uid);
$pages = D("Page")->search($item_id, $cat_id, $keyword);
if ($pages) {
foreach ($pages as $key => $value) {
$page_content = htmlspecialchars_decode($value['page_content']);
Expand Down
12 changes: 2 additions & 10 deletions server/Application/Api/Model/CatalogModel.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,16 +151,8 @@ public function filteMemberCat($uid, $catData)
}
$item_id = $catData[0]['item_id'];
$cat_id = 0;
//首先看是否被添加为项目成员
$itemMember = D("ItemMember")->where("uid = '%d' and item_id = '%d' ", array($uid, $item_id))->find();
if ($itemMember && $itemMember['cat_id'] > 0) {
$cat_id = $itemMember['cat_id'];
}
//再看是否添加为团队-项目成员
$teamItemMember = D("TeamItemMember")->where("member_uid = '%d' and item_id = '%d' ", array($uid, $item_id))->find();
if ($teamItemMember && $teamItemMember['cat_id'] > 0) {
$cat_id = $teamItemMember['cat_id'];
}
// 如果用户被分配了 目录权限 ,则获取他在该项目下拥有权限的目录id
$cat_id = D("Member")->getCatId($item_id, $uid);
//开始根据cat_id过滤
if ($cat_id > 0) {
foreach ($catData as $key => $value) {
Expand Down
20 changes: 20 additions & 0 deletions server/Application/Api/Model/MemberModel.class.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace Api\Model;

use Api\Model\BaseModel;

class MemberModel extends BaseModel
{
protected $autoCheckFields = false; //一定要关闭字段缓存,不然会报找不到表的错误

// 如果用户被分配了 目录权限 ,则获取他在该项目下拥有权限的目录id
public function getCatId($item_id, $uid)
{
$cat_id1 = D("ItemMember")->where(" item_id = '%d' and uid = '%d' ", array($item_id, $uid))->getField('cat_id');
$cat_id2 = D("TeamItemMember")->where(" item_id = '%d' and member_uid = '%d' ", array($item_id, $uid))->getField('cat_id');
// 尝试给 $cat_id 赋值 $cat_id1,如果 $cat_id1 未空,则尝试 $cat_id2,如果 $cat_id2 也未空,则最终给 $cat_id 赋值 0。
$cat_id = $cat_id1 ?? $cat_id2 ?? 0;
return $cat_id;
}
}
8 changes: 6 additions & 2 deletions server/Application/Api/Model/PageModel.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,15 @@ class PageModel extends BaseModel


//搜索某个项目下的页面
public function search($item_id, $keyword)
public function search($item_id,$cat_id = 0 , $keyword)
{
$return_pages = array();
$item = D("Item")->where("item_id = '%d' and is_del = 0 ", array($item_id))->find();
$pages = $this->where("item_id = '$item_id' and is_del = 0")->order(" s_number asc ")->select();
$where = "item_id = '$item_id' and is_del = 0";
if ($cat_id > 0) {
$where .= " and cat_id = '$cat_id' ";
}
$pages = $this->where($where)->order(" s_number asc ")->select();
if (!empty($pages)) {
foreach ($pages as $key => &$value) {
$page_content = $value['page_content'];
Expand Down
2 changes: 1 addition & 1 deletion web_src/build/webpack.prod.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ const webpackConfig = merge(baseWebpackConfig, {
minify: {
removeComments: true,
collapseWhitespace: true,
removeAttributeQuotes: true
removeAttributeQuotes: false
// more options:
// https://github.com/kangax/html-minifier#options-quick-reference
},
Expand Down

0 comments on commit 33662f4

Please sign in to comment.