s4

changeset 331:1a60dfc56bb0

Search form in other user's home restrict author to that one.
author HIROSE Yuuji <yuuji@gentei.org>
date Fri, 21 Oct 2016 18:53:46 +0859
parents 37fd6d9d5d9b
children 9dc6f9e60f6a
files s4-blog.sh s4-funcs.sh
diffstat 2 files changed, 27 insertions(+), 7 deletions(-) [+]
line diff
     1.1 --- a/s4-blog.sh	Fri Oct 21 18:14:10 2016 +0859
     1.2 +++ b/s4-blog.sh	Fri Oct 21 18:53:46 2016 +0859
     1.3 @@ -229,7 +229,7 @@
     1.4  	  #err "usecache=$usecache `ls -l $outfile`" 
     1.5  	  #err tm=$tm
     1.6  	  #err tsfile=$tsfile=`cat $tsfile`
     1.7 -	  if [ -s $outfile ] &&	# $outfile should be > 0
     1.8 +	  if [ -s "$outfile" ] &&	# $outfile should be > 0
     1.9  		 { [ "$usecache" ] ||	# And usecache flag is true, or...
    1.10  		       { [ -s "$tsfile" ] && [ x"`cat $tsfile`" = x"$tm" ]
    1.11  		       };}; then
    1.12 @@ -470,7 +470,7 @@
    1.13  	ctime=${k#@}
    1.14  	# Not sure GROUP BY a.blogid is comfortable for searchers...?
    1.15  	kc=$kc${kc:+" AND "}"s.ctime GLOB '${ctime}*'"
    1.16 -	##### kwdgrp=" GROUP BY a.blogid"
    1.17 +	##### kwdgrp=" GROUP BY a.blogid"   ## Add this to lessen results
    1.18        elif [ x"$k" = x"@today" -o x"$k" = x"@今日" ]; then
    1.19  	ctime=`date +%F`
    1.20  	kc=$kc${kc:+" AND "}"s.ctime GLOB '${ctime}*'"
    1.21 @@ -491,13 +491,19 @@
    1.22        linkhome $owner 1>&3
    1.23        echo "(`linkhome $owner` グループからの検索)" | html p
    1.24      fi
    1.25 +  elif { author=`getpar author`; test -n "$author"; }; then
    1.26 +    atptn=`sqlquotestr $author`
    1.27 +    kc="$kc${kc:+ AND }author=$atptn"
    1.28 +    if isuser $author; then
    1.29 +      echo "(`linkhome $author` さんの書き込みからの検索)" | html p
    1.30 +    fi
    1.31    fi
    1.32    # article_s:	id=article-id, key='text', val='TEXT'
    1.33    # article:	id=article-id, blogid=blogkd
    1.34    # blog:		id=blog-id, author=LeaderAuthor
    1.35    # blog_s:		id=blog-id, key='title', val='BLOG-TITLE'
    1.36    # WANT: blog-ROWid,article-id,val(TEXT)
    1.37 -    sql="`sql4readableblogs`		-- Extract user-readable blogs
    1.38 +  sql="`sql4readableblogs`		-- Extract user-readable blogs
    1.39         SELECT b.rid||'#'||x.id as '',
    1.40  		  b.title as TITLE,
    1.41  		  substr(x.ctime, 0, 11) as DATE,
     2.1 --- a/s4-funcs.sh	Fri Oct 21 18:14:10 2016 +0859
     2.2 +++ b/s4-funcs.sh	Fri Oct 21 18:53:46 2016 +0859
     2.3 @@ -1490,11 +1490,22 @@
     2.4  (1)と(2)は組み合わせOK
     2.5    例: @2016-10-0[1-9] 芋煮
     2.6    → 2016年10月上旬でキーワード「芋煮」を含む記事検索"
     2.7 +  auth=""
     2.8 +  placeholder="全記事からの検索"
     2.9 +  case "$1" in
    2.10 +    author=*)
    2.11 +      a=`echo "${1#author=}"|htmlescape`
    2.12 +      g=`gecos ${1#author=}`
    2.13 +      auth="<input type=\"hidden\" name=\"author\" value=\"$a\">"
    2.14 +      placeholder="このユーザの書込検索"
    2.15 +      help="★★ $g さんの書き込みから検索します$nl$help"
    2.16 +      ;;
    2.17 +  esac
    2.18    cat<<-EOF
    2.19  	<div class="fr">
    2.20 -	<form action="$myname">
    2.21 +	<form action="$myname">$auth
    2.22  	<input type="text" name="kwd" value="" title="$help"
    2.23 -	 placeholder=" 全記事からの検索 " width="10">
    2.24 +	 placeholder=" $placeholder " width="10">
    2.25  	<input type="hidden" name="stage" value="searchart">
    2.26  	</form>
    2.27  	</div>
    2.28 @@ -1582,6 +1593,7 @@
    2.29    err SH:gecos=$gecos
    2.30    GF_VIEWONLY=1
    2.31    cond="gname in (select gname from grp_mem where user='$uname')"
    2.32 +  search_form_args=""
    2.33    if [ x"$user" = x"$uname" ]; then
    2.34      conflink="<a href=\"?userconf\">プロフィールの編集</a> /
    2.35  	<a href=\"?blog\">新規話題の作成</a>"
    2.36 @@ -1596,12 +1608,14 @@
    2.37        conflink="$conflink /
    2.38  	<a href=\"?lsmyfile\">過去の提出ファイル</a>"
    2.39      fi
    2.40 +  else
    2.41 +    search_form_args="author=$uname"
    2.42    fi
    2.43    . ./s4-blog.sh
    2.44  
    2.45    tf=$tmpd/title.$$ pf=$tmpd/profile.$$ bf=$tmpd/blogs.$$ sf=$tmpd/search.$$
    2.46 -  search_form		> $sf
    2.47 -  echo "$gecos さん"	> $tf
    2.48 +  search_form $search_form_args		> $sf
    2.49 +  echo "$gecos さん"			> $tf
    2.50    { echo "<div class=\"noprofimg\">"
    2.51      viewtable $formdir/user.def user $1
    2.52      echo "</div>"