s4
changeset 957:4961963431f9
Exclude quiz/enquete articles from new posts list of other users
author | HIROSE Yuuji <yuuji@gentei.org> |
---|---|
date | Thu, 09 Dec 2021 08:40:17 +0900 |
parents | b8ce08814228 |
children | a0b1e62df613 |
files | s4-funcs.sh |
diffstat | 1 files changed, 17 insertions(+), 5 deletions(-) [+] |
line diff
1.1 --- a/s4-funcs.sh Thu Nov 25 11:18:25 2021 +0900 1.2 +++ b/s4-funcs.sh Thu Dec 09 08:40:17 2021 +0900 1.3 @@ -72,6 +72,7 @@ 1.4 " 1.5 file_warn="$file_accept_help 1.6 [編集]リンクから修正してください。" 1.7 +hidden_mode="('quiz', 'enquete')" 1.8 blogreadflagrowid=0 1.9 blogcutoffflagrowid=-1 1.10 nonewgroupworld=${NONEWGROUPWORLD:-*archive*} 1.11 @@ -2104,7 +2105,7 @@ 1.12 NATURAL JOIN 1.13 (SELECT id, val owner FROM blog_s WHERE key='owner') bs 1.14 WHERE CASE WHEN (SELECT name FROM user where name=bs.owner) IS NOT NULL 1.15 - THEN 1 -- blog owner is an user, READABLE 1.16 + THEN 1 -- blog owner is an user, READABLE when 1.17 WHEN (SELECT user FROM grp_mem 1.18 WHERE gname=bs.owner AND user='$user') IS NULL 1.19 THEN 0 1.20 @@ -2358,6 +2359,7 @@ 1.21 shortval=${shortval:-val} 1.22 1.23 # The m.aid in the next line is suspicious. But works fine in SQLite3... 1.24 + # $hidden_mode is defined in global section 1.25 DT_SQL="SELECT b.rowid || '#' || m.aid LINK, 1.26 ctime, 1.27 (SELECT $shortval FROM blog_s WHERE key='title' AND id=b.id) title, 1.28 @@ -2372,7 +2374,13 @@ 1.29 ON a.id=s.id AND a.author='$uname' AND s.key='ctime' 1.30 GROUP BY blogid ORDER BY val DESC LIMIT 50 1.31 ) m 1.32 - ON b.id=m.blogid;" 1.33 + ON b.id=m.blogid 1.34 + AND 1.35 + ('$uname' = '$user' -- user can read all own posts 1.36 + OR 1.37 + -- exclude posts of others in quiz/enquete blogs 1.38 + NOT EXISTS (SELECT * FROM blog_s 1.39 + WHERE id=b.id AND key='mode' AND val IN $hidden_mode));" 1.40 # This should be as follows 1.41 : <<EOF 1.42 WITH arts AS( 1.43 @@ -3324,12 +3332,15 @@ 1.44 EOF 1.45 } 1.46 sql4readableblogs() { 1.47 - # Create view of blogs that can be readable to $user 1.48 + # Create view of blogs that can be readable by $user 1.49 # Blog is readable when: 1.50 # 1: blog owner is an user 1.51 # 2: else, 2.1: owner-group where the $user belongs 1.52 # 2.2: else, owner-group is not moderated 1.53 # blog(id, author), blog_s(id, key='owner', val= ->owner) 1.54 + 1.55 + # $hidden_mode is defined in global section at head 1.56 + 1.57 cat<<EOF ## | tee tmp/sql.out 1.58 CREATE TEMPORARY VIEW readableblogs AS 1.59 SELECT blog.rowid rid, id, author 1.60 @@ -3340,14 +3351,15 @@ 1.61 max(CASE key WHEN 'mode' THEN val END) mode 1.62 FROM blog_s GROUP by id) bs 1.63 WHERE CASE WHEN (SELECT name FROM user where name=bs.owner) IS NOT NULL 1.64 - THEN 1 -- blog owner is an user, READABLE 1.65 + THEN -- blog owner is an user, READABLE 1.66 + NOT mode IN $hidden_mode 1.67 WHEN (SELECT val FROM grp_s 1.68 WHERE gname=bs.owner AND key='regmode') = 'moderated' 1.69 AND 1.70 (SELECT user FROM grp_mem 1.71 WHERE gname=bs.owner AND user='$user') IS NULL 1.72 THEN 0 1.73 - WHEN mode IN ('quiz', 'enquete') 1.74 + WHEN mode IN $hidden_mode 1.75 THEN 0 -- "quiz" mode blog cannot be searched 1.76 ELSE 1 1.77 END;