s4

changeset 866:a2e2bf4ee7eb

Archive report files order by uname.
author HIROSE Yuuji <yuuji@gentei.org>
date Sun, 06 Sep 2020 11:24:28 +0859
parents 8c69e0c2e6af
children 1b0669c854cf
files s4-blog.sh scripts/s4-sns.case
diffstat 2 files changed, 19 insertions(+), 7 deletions(-) [+]
line diff
     1.1 --- a/s4-blog.sh	Wed Sep 02 17:09:24 2020 +0900
     1.2 +++ b/s4-blog.sh	Sun Sep 06 11:24:28 2020 +0859
     1.3 @@ -232,7 +232,7 @@
     1.4  	case "$isgrpadmin$blog_mode" in
     1.5  	  false*closed*|false*quiz|false*enquete*) ;;
     1.6  	  *)
     1.7 -	    href3="(<a href=\"?gethandout+$rowid\" accesskey=\"f\" title=\"Shortcut: F${nl}File Retrieval\">ファイル取得</a>)"
     1.8 +	    href3="(ファイル取得[<a href=\"?gethandout+$rowid\" accesskey=\"f\" title=\"Shortcut: F${nl}File Retrieval\">記事順</a>|<a href=\"?gethandout+$rowid+by_uname\" accesskey=\"u\" title=\"Shortcut: F${nl}File Retrieval by User\">著者順</a>])"
     1.9  	    ;;
    1.10  	esac
    1.11  	;;
    1.12 @@ -792,6 +792,7 @@
    1.13  gethandout() {
    1.14    # $1=rowid of blog
    1.15    rid=`numericalize "$1"`
    1.16 +  test x"$2" = x"by_uname" && by_uname="$2"
    1.17    blog_writable $rid $user
    1.18    rc=$?		# =0: writable, $BLOG_NOTMEM bit set => not member
    1.19    if [ $((rc & $BLOG_NOTMEM)) -gt 0 ] ; then
    1.20 @@ -881,23 +882,33 @@
    1.21    query <<-EOF > $midfile		# Using tempfile for quick db-unlock
    1.22  	SELECT a.rowid, a.id artid, a.author, hex(s.val)
    1.23  	FROM article a JOIN article_s s ON a.id=s.id
    1.24 -	WHERE blogid=(SELECT id FROM blog WHERE rowid=$rid);
    1.25 +	WHERE blogid=(SELECT id FROM blog WHERE rowid=$rid)
    1.26 +	ORDER BY a.rowid;
    1.27  	EOF
    1.28    cat $midfile | while IFS='|' read rowid artid author text; do
    1.29      $isgrpowner || $isopenblogauthor \
    1.30        || isfilereadable $user article_s $rowid || continue
    1.31 -    dir=`printf $bd/%d/%06d "$rid" "$rowid"`
    1.32 +    if [ "$by_uname" ]; then
    1.33 +      dir=`printf $bd/%d/%s "$rid" "$author"`
    1.34 +    else
    1.35 +      dir=`printf $bd/%d/%06d "$rid" "$rowid"`
    1.36 +    fi
    1.37 +    txt=`printf %06d $rowid`.txt
    1.38      mkdir -p $dir
    1.39      echo "$author" > $dir/Author
    1.40 -    echo "$text" | unhexize > $dir/Text
    1.41 +    echo "$text" | unhexize > $dir/$txt
    1.42      i=0
    1.43      query "SELECT m.rowid, m.val FROM article_m m \
    1.44  	   WHERE id='$artid' AND m.key IN ('image', 'document', 'binary');" \
    1.45        | while IFS='|' read mrowid filename; do
    1.46            i=$((i+1))
    1.47 -          outfile=`printf "%s/%02d-%s" "$dir" $i "$filename"`
    1.48 +    	  if [ "$by_uname" ]; then
    1.49 +            outfile=`printf "%s/%06d-%s" "$dir" $rowid "$filename"`
    1.50 +	  else
    1.51 +            outfile=`printf "%s/%02d-%s" "$dir" $i "$filename"`
    1.52 +	  fi
    1.53            query "SELECT quote(bin) FROM article_m WHERE rowid=$mrowid;" \
    1.54 -		| unhexize > $outfile
    1.55 +		| unhexize > "$outfile"
    1.56      done
    1.57    done
    1.58    if [ ! -d $bd/$rid ]; then
     2.1 --- a/scripts/s4-sns.case	Wed Sep 02 17:09:24 2020 +0900
     2.2 +++ b/scripts/s4-sns.case	Sun Sep 06 11:24:28 2020 +0859
     2.3 @@ -56,7 +56,8 @@
     2.4        return
     2.5      fi
     2.6      . ./s4-blog.sh
     2.7 -    $stage $rowid
     2.8 +    shift; shift
     2.9 +    $stage $rowid "$@"
    2.10      ;;
    2.11    lsmyfile)
    2.12      contenttype; echo