changeset 60:9f4e85181d40

Add new articles digest
author HIROSE Yuuji <yuuji@gentei.org>
date Sun, 26 Jul 2015 00:41:37 +0900
parents 916d81b9c4fc
children 8b2cf4d9ba00
files s4-funcs.sh
diffstat 1 files changed, 31 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/s4-funcs.sh	Sat Jul 25 23:00:58 2015 +0900
+++ b/s4-funcs.sh	Sun Jul 26 00:41:37 2015 +0900
@@ -408,9 +408,13 @@
   u=`sqlquote ${1:-$user}`
   #gecos=`query "select val from user_s where name='$u' and key='gecos';"`
   sql="select case when (select name from user where name=$u) is not null
-		then (select val from user_s where name=$u and key='gecos')
+		then coalesce(
+		  (select val from user_s where name=$u and key='gecos'),
+		  $u)
 		when (select gname from grp where gname=$u) is not null
-		then (select val from grp_s where gname=$u and key='gecos')
+		then coalesce(
+		  (select val from grp_s where gname=$u and key='gecos'),
+		  $u)
 		else $u
 		end;"
   query "$sql"
@@ -1178,6 +1182,7 @@
   esac
 err ShowHome: uname=$uname
   gecos=`gecos "$uname"`
+err SH:gecos=$gecos
   GF_VIEWONLY=1
   cond="gname in (select gname from grp_mem where user='$uname')"
   if [ x"$user" = x"$uname" ]; then
@@ -1192,6 +1197,18 @@
     -D_GROUPS_="`listgroupbytable $formdir/grp.def $cond`" \
     $layout/html.m4.html $layout/home.m4.html
 
+ if [ x"$user" = x"$uname" ]; then
+   cond="where 新着 > 0 order by 新着 desc,ctime desc limit 10"
+   new10=`DT_CHLD=article:blogid \
+	  DT_VIEW=replyblog dumptable html blog "ctime title gecos" "$cond"`
+   cont=`echo "$new10"|grep "^<TR>"|wc -l`
+   cont=$((cont-1))
+err newcount=$cont
+   if [ $cont -gt 0 ]; then
+     echo "全体の新着記事${cont}傑" | html h2
+     echo "$new10"
+   fi
+ fi
      #  
   # Record access log
   [ -n "$1" ] && [ x"$1" != x"$user" ] && acclog user $1
@@ -1441,7 +1458,7 @@
 <label>`cgi_text kwd`という語を含むコメントを検索</label>
 `cgi_hidden owner $grp`
 EOF
-  cond="where a.id in (select id from blog_s where key='owner' and val='$grp') order by ctime desc"
+  cond="where a.id in (select id from blog_s where key='owner' and val=$qgrp) order by ctime desc"
   DT_CHLD=article:blogid \
 	 DT_VIEW=replyblog dumptable html blog 'ctime title heading' "$cond"
 
@@ -1683,8 +1700,8 @@
 	and val > coalesce((select time from acclog where \
 			    user='$user' and tbl='$2' and rowid=a.rowid),\
 		    '1970-01-01'))"
-    cnt="$cntnew||'/'||$cntall as '新着/総数',"
-    dt_class=" td2r"
+    cnt="$cntnew as '新着', $cntall as '総数',"
+    dt_class=" td2r td3r"
   fi
   # Construct join expression
   eav="" scols=""
@@ -1693,6 +1710,8 @@
   substr=${substr:-val}
   for col in ${3:-`gettbl_s_cols $2`}; do
     case $col in
+      gecos)	scols="$scols${scols:+, }${col#}"
+		continue ;;	# built-in column name
       *:*)	col=${col%:*} as=${col#*:} ;;
       *)	as=${col} ;;
     esac
@@ -1703,8 +1722,13 @@
   sql="select \
 a.rowid as ID,\
 $cnt\
-$scols from $2 a left join (select $pk,$eav from ${2}_s group by $pk) b on a.$pk=b.$pk $4;"
-err SQL="$sql"
+$scols from $2 a left join\
+ (select $pk,$eav,
+	max(case key when 'owner'
+	 then coalesce((select val from user_s us
+		 where us.key='gecos' and us.name=c.val), val) end) as gecos
+ from ${2}_s c group by $pk) b on a.$pk=b.$pk $4;"
+err SQL=`echo "$sql"`
   cat<<EOF | sed "s,\(<TR><TD>\)\([1-9][0-9]*\)</TD>,\1$elink$dvlink</TD>,"
 <div class="dumptable">
 <table class="b$dt_class">

yatex.org