changeset 236:19b92549b5b7

Add button to clear all unread article list
author HIROSE Yuuji <yuuji@gentei.org>
date Sun, 26 Jun 2016 20:56:01 +0859
parents 014f459543d5
children ba4efe0b53e0
files s4-funcs.sh
diffstat 1 files changed, 26 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/s4-funcs.sh	Sat Jun 25 09:49:02 2016 +0859
+++ b/s4-funcs.sh	Sun Jun 26 20:56:01 2016 +0859
@@ -28,6 +28,7 @@
 maximagexy=1600x1600
 ### maximagexy=400x400
 file_accept='accept="image/*,text/*,audio/*,application/vnd.oasis.*,application/pdf,application/x-*"'
+blogreadflagrowid=0
 
 tconfs=""
 imgcached=cache/img.`date +%Y/%m`
@@ -1378,16 +1379,24 @@
         max(case key when 'owner' then val end) owner
  from blog, blog_s using(id) group by id
 ), acclog_user as (
-  select * from acclog where user='$user' and tbl='blog'
+  -- select * from acclog where user='$user' and tbl='blog'
+  -- GET (user,tbl,tblrowid,max(time,DEFAULTtime))
+  SELECT user, tbl, tblrowid,
+         max(time,
+             coalesce((SELECT time FROM acclog
+		       WHERE user='$user' and tbl='blog'
+		       AND tblrowid=$blogreadflagrowid), 0)) time
+	 FROM acclog
+	 WHERE user='$user' AND  tbl='blog'
 ), blogall as (
  select b.id, b.rowid, b.owner, b.title, ctime, ac.author
  from blog_title_owner b, article_ctime ac
       on b.id=ac.blogid
 )
  select rowid LINK, 
-        sum(case when l.time is null then 1
-                 when l.time < ctime then 1
-                 else 0
+        sum(case when l.time is not null
+                 then l.time < ctime
+                 else 1
             end) "新着",
  count(id) "総数", ctime, title,
  /* owner gecos */
@@ -1497,6 +1506,11 @@
       new10=`DT_CHLD=article:blogid \
 	  DT_VIEW=replyblog dumptable html blog "ctime title gecos" "$cond"`
     else
+      # 2016-06-26
+      if [ x"`getpar readchk``getpar read`" = x"yesyes" ]; then
+	acclog blog $blogreadflagrowid
+	# echo "全部既読にしました" | html p
+      fi
       # 2016-02-19 Counting NEWS without using dumptable.
       sql=`listnewblogsql "$user"`
       new10=`DT_SQL="$sql" DT_VIEW=replyblog dumptable html blog`
@@ -1507,6 +1521,14 @@
     if [ $cont -gt 0 ]; then
       echo "全体の新着記事${cont}傑" | html h2
       echo "$new10"
+      cat<<-EOF | html form 'action="?home"'
+	<div class="fold noborder">
+	`cgi_checkbox readchk yes 'id="read"'`<label
+	 for="read">新着ふくめて全部読んだことにする</label>
+	 <div>`cgi_submit '確定'`</div>
+	 `cgi_hidden read yes`
+	</div>
+	EOF
     fi
     cat<<EOF
 <div class="fold">

yatex.org