# HG changeset patch # User HIROSE Yuuji # Date 1438502708 -32400 # Node ID 39e69daa20718769b127caef636590b744f081fe # Parent f088d45dfdf23e7dff6a2c6f4eb791da18a2db6d New feature "lsmyfile" added diff -r f088d45dfdf2 -r 39e69daa2071 s4-blog.sh --- a/s4-blog.sh Sun Aug 02 10:58:58 2015 +0900 +++ b/s4-blog.sh Sun Aug 02 17:05:08 2015 +0900 @@ -12,11 +12,12 @@ [ x"$blogowner" = x"$2" ] || isuser "$blogowner" || ismember "$2" "$blogowner" ) blog_notify_reply() ( - # $1=articleid $2=ReplyingUser $3=WrittenText + # $1=articleid $2=ReplyingUser $3=WrittenText $4(optional)=Action blogowner=`getvalbyid blog owner "$1"` [ x"$2" = x"$blogowner" ] && return # If author=blogowner, unnecessary blogtitle=`getvalbyid blog title "$1"` blogurl="$urlbase?replyblog+$1" + action=${4:-書き込み} mode=`getvalbyid blog notify "$1"` case $mode in admin) @@ -33,8 +34,8 @@ *) emails=`collectemail $blogowner` ;; esac err notify: user=$user Admins=`getgroupadmins $blogowner` Mode=$mode Emails="[$emails]" - smail "$emails" "書込通知 $urlbase"< +
EOF @@ -202,8 +203,7 @@ $textform EOF - echo "" - + echo "

" # Record access log acclog blog $rowid } @@ -291,6 +291,66 @@ echo cat $arc } +lsmyfile() { # $1(optional)=SortBy + case "$1" in + ""|CTIME-DESC) + by="CTIME" ord="DESC" ;; + CTIME*) by="CTIME" ;; + FILE*) by="FILE" ;; + OWNER*) by="OWNER" ;; + TITLE*) by="TITLE" ;; + esac + case "$1" in + *DESC) ord="DESC" ;; + esac + case "$ord" in + DESC) lkod="" jord="降順" ;; + *) lkod="-DESC" jord="昇順" ;; + esac + sql="select m.val||'/'||m.rowid FILE, + coalesce( + case when (select name from user where name=bs.owner) + is not null + then (select val from user_s where name=bs.owner + and key='gecos') + when (select gname from grp where gname=bs.owner) + is not null + then (select val from grp_s where gname=bs.owner + and key='gecos') + else + null + end, + bs.owner + ) OWNER, + a_s.val CTIME, + ',t,'||bs.title||':'||b.rowid||'#'||a.id TITLE + from (select rowid,id,val from article_m where id + in (select id from article where author='$user') + and type like 'file:%') + m left join article a on m.id=a.id + left join article_s a_s on a.id=a_s.id and a_s.key='ctime' + left join (select id, + max(case key when 'owner' then val end) as owner, + max(case key when 'title' then val end) as title + from blog_s group by id) + bs on a.blogid=bs.id + left join blog b on bs.id=b.id + where m.val is not null order by $by $ord;" + err lshandoutbyauthor: sql=`echo "$sql"` + title="個人提出ファイル" + m4 -D_TITLE_=$title $layout/html.m4.html + hra="' + echo "$sql"|sq -html -header $db ) \ + | sed -e "s|\(\)|$hrc\2\">\1\3|" \ + -e "s|\(\)|\1$hra\2$lkod\">\2|" \ + | m4 -D_TITLE_=$title -D_FORM_="

($by$jord)

" \ + -D_DUMPTABLE_="syscmd(cat)" $layout/form+dump.m4.html + echo '
\)\([^/]*\)/\([0-9]*\)|\1$hrb\3\">\2|" \ + -e "s|,t,\(.*\):\([^<]*\)\(\)\([A-Z]*\)\(
' +} searchart() { kwd=`getpar kwd` if [ -z "$kwd" ]; then @@ -348,35 +408,30 @@ # $1=GRPname(if it is a group) grprowid=$1 rowid=`getpar rowid` -err ba: rowid=$rowid - #if [ -z "$rowid" ]; then - # When rowid is SET, it is updation of existing entry - if [ -z "$1" ]; then - listing=$user guide="[個人]" -#listing代入は rowid 時でもするべき - else - grp=`getgroupbyid $grprowid` - if [ -n "$grp" ]; then - listing=$grp guide="[${grp}]" GF_OWNER=$grp - else - echo "無効なグループ指定です。" | html p - return - fi - fi - #fi + err blog_addentry0: rowid=$rowid + if [ -n "$grprowid" ]; then + owner=`getgroupbyid $grprowid` + else + owner=`getpar owner` + fi + if isgroup $owner; then + groupmode=1 listing=$owner guide="[${owner}]" GF_OWNER=$owner + else + usermode=1 listing=$user guide="[個人]" + fi + if [ -n "`getpar title`" ]; then - owner=`getpar owner` - if isuser $owner; then + if [ "$usermode" ]; then if [ x"$user" != x"$owner" ]; then echo "他人の日記は書けません" | html p - return + return 2 fi - elif isgroup $owner; then # if write to group log + elif [ "$groupmode" ]; then # if write to group log grp=$owner #\`getpar grp\` err ismember: $user $grp if ! ismember "$user" "$grp"; then echo "(話題作成はこのグループに加入してから)" | html p - return + return 3 fi fi par2table $formdir/blog.def @@ -389,6 +444,7 @@ elif [ -n "$serial" ]; then # If new blog leader created, traverse to its head. id=`query "select rowid from blog where id='$serial';"` + err new-Leader: "select rowid from blog where id='$serial';" id=$id fi if [ -n "$id" ]; then ## If new aritcle is entered, JUMP to blog_reply @@ -429,9 +485,13 @@ text=`getpar text` if [ -n "$text" ]; then if blog_writable $rowid $user; then - if par2table $formdir/article.def; then - blog_notify_reply $rowid $user "$text" - fi + par2table $formdir/article.def + st=$? # ; err par2t-st=$st + case $st in + 0|4) + [ "$st" = "4" ] && act="書込削除" + blog_notify_reply $rowid $user "$text" $act ;; + esac else title="$title(加入してないので書き込み不可)" fi diff -r f088d45dfdf2 -r 39e69daa2071 s4-funcs.sh --- a/s4-funcs.sh Sun Aug 02 10:58:58 2015 +0900 +++ b/s4-funcs.sh Sun Aug 02 17:05:08 2015 +0900 @@ -1232,7 +1232,7 @@ m4 -D_TITLE_="グループ一覧" -D_BODYCLASS_=listgroup $layout/html.m4.html kwd=`getpar kwd` listgroup $kwd \ - | m4 -D_DUMPTABLE_="syscmd(\`cat')" \ + | m4 -D_DUMPTABLE_="syscmd(cat)" \ -D_TITLE_="グループ関連操作" \ -D_FORM_="新規グループ作成" \ $layout/form+dump.m4.html @@ -1267,6 +1267,17 @@ if [ x"$user" = x"$uname" ]; then conflink="プロフィールの編集 / 新規話題の作成" + # Display folders + sql="select count(id) from article_m where id + in (select id from article where author='$user') + and type like 'file:%';" + err nfile-sql=`echo "$sql"` + nfile=`query "$sql"` + err nfile=$nfile + if [ $nfile -gt 0 ]; then + conflink="$conflink / + 過去の提出ファイル" + fi fi . ./s4-blog.sh @@ -1277,6 +1288,7 @@ $layout/html.m4.html $layout/home.m4.html if [ x"$user" = x"$uname" ]; then + # Display NEWS 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"` @@ -1470,7 +1482,7 @@ if isgroup "$grp"; then showgroupsub $formdir/grp.def "$1" | \ m4 -D_TITLE_="グループ $grp" \ - -D_FORM_="syscmd(\`cat')" \ + -D_FORM_="syscmd(cat)" \ -D_DUMPTABLE_="" \ $layout/form+dump.m4.html else # if $grp is removed at par2table @@ -1879,6 +1891,16 @@ # copy current parameters of par into destination table # $1=definition-file # Using $user and $session + # Return value: + # 0: Stored successfully + # 1: Insufficient fillings + # 2: No permission to modify the record + # 3: Invalid rowid + # 4: SUCCESS to delete + # 5: Stop deletion for lack of confirm check + # 6: Password length too short + # 7: Password mismatch + # 8: Old password incorrect rowid=`getpar rowid` err ...........rowid=$rowid if [ ! -e $1 ]; then @@ -1902,20 +1924,20 @@ ### err rowowner=$rowowner if [ x"$user" != x"$rowowner" ]; then echo "他人のレコードはいじれないの" | html p - return + return 2 elif [ -z "$rowowner" ]; then echo "指定したレコードはないみたい" | html p - return + return 3 fi rm=`getpar rm` cfm=`getpar confirm` # Editing existent entry if [ x"$rm" = x"yes" ]; then if [ x"$rm$cfm" = x"yesyes" ]; then query "delete from $tbl where rowid=$rowid;" - return + return 4 else echo "消去確認のチェックがないので消さなかったの..." | html p - return + return 5 fi fi fi @@ -2055,16 +2077,16 @@ case "$p1" in ??????????*) ;; *) echo "10字以上にしてください。" | html p - return ;; + return 6;; esac val="\"`echo $p1|mypwhash`\"" else echo "2つの新パスワード不一致" | html p - return + return 7 fi else echo "旧パスワード違います" | html p - return + return 8 fi fi ;; diff -r f088d45dfdf2 -r 39e69daa2071 s4.cgi --- a/s4.cgi Sun Aug 02 10:58:58 2015 +0900 +++ b/s4.cgi Sun Aug 02 17:05:08 2015 +0900 @@ -73,6 +73,12 @@ . ./s4-blog.sh $stage $rowid ;; + lsmyfile) + contenttype; echo + . ./s4-blog.sh + shift + $stage "$@" + ;; "searchart") # $2=blogowner contenttype; echo m4 -D_TITLE_="検索結果" $layout/html.m4.html