s4
changeset 80:39e69daa2071
New feature "lsmyfile" added
author | HIROSE Yuuji <yuuji@gentei.org> |
---|---|
date | Sun, 02 Aug 2015 17:05:08 +0900 |
parents | f088d45dfdf2 |
children | ddc8a4c0b8d9 |
files | s4-blog.sh s4-funcs.sh s4.cgi |
diffstat | 3 files changed, 127 insertions(+), 39 deletions(-) [+] |
line diff
1.1 --- a/s4-blog.sh Sun Aug 02 10:58:58 2015 +0900 1.2 +++ b/s4-blog.sh Sun Aug 02 17:05:08 2015 +0900 1.3 @@ -12,11 +12,12 @@ 1.4 [ x"$blogowner" = x"$2" ] || isuser "$blogowner" || ismember "$2" "$blogowner" 1.5 ) 1.6 blog_notify_reply() ( 1.7 - # $1=articleid $2=ReplyingUser $3=WrittenText 1.8 + # $1=articleid $2=ReplyingUser $3=WrittenText $4(optional)=Action 1.9 blogowner=`getvalbyid blog owner "$1"` 1.10 [ x"$2" = x"$blogowner" ] && return # If author=blogowner, unnecessary 1.11 blogtitle=`getvalbyid blog title "$1"` 1.12 blogurl="$urlbase?replyblog+$1" 1.13 + action=${4:-書き込み} 1.14 mode=`getvalbyid blog notify "$1"` 1.15 case $mode in 1.16 admin) 1.17 @@ -33,8 +34,8 @@ 1.18 *) emails=`collectemail $blogowner` ;; 1.19 esac 1.20 err notify: user=$user Admins=`getgroupadmins $blogowner` Mode=$mode Emails="[$emails]" 1.21 - smail "$emails" "書込通知 $urlbase"<<EOF 1.22 -[$blogtitle]板に書き込みがありました。 1.23 + smail "$emails" "${action}通知 $urlbase"<<EOF 1.24 +[$blogtitle]板に${action}がありました。 1.25 場所: $blogurl 1.26 題目: $blogtitle 1.27 筆者: `gecos $2` 1.28 @@ -73,7 +74,7 @@ 1.29 1.30 #(1)Display root article 1.31 cat<<EOF 1.32 -<form class="replyblog" action="$myname?replyblog+$rowid" method="POST" enctype="multipart/form-data"> 1.33 +<form class="replyblog" action="$myname?replyblog+${rowid}#bottom" method="POST" enctype="multipart/form-data"> 1.34 <table class="bloghead"> 1.35 EOF 1.36 1.37 @@ -202,8 +203,7 @@ 1.38 $textform 1.39 </div> 1.40 EOF 1.41 - echo "</form>" 1.42 - 1.43 + echo "</form><p id=\"bottom\"></p>" 1.44 # Record access log 1.45 acclog blog $rowid 1.46 } 1.47 @@ -291,6 +291,66 @@ 1.48 echo 1.49 cat $arc 1.50 } 1.51 +lsmyfile() { # $1(optional)=SortBy 1.52 + case "$1" in 1.53 + ""|CTIME-DESC) 1.54 + by="CTIME" ord="DESC" ;; 1.55 + CTIME*) by="CTIME" ;; 1.56 + FILE*) by="FILE" ;; 1.57 + OWNER*) by="OWNER" ;; 1.58 + TITLE*) by="TITLE" ;; 1.59 + esac 1.60 + case "$1" in 1.61 + *DESC) ord="DESC" ;; 1.62 + esac 1.63 + case "$ord" in 1.64 + DESC) lkod="" jord="降順" ;; 1.65 + *) lkod="-DESC" jord="昇順" ;; 1.66 + esac 1.67 + sql="select m.val||'/'||m.rowid FILE, 1.68 + coalesce( 1.69 + case when (select name from user where name=bs.owner) 1.70 + is not null 1.71 + then (select val from user_s where name=bs.owner 1.72 + and key='gecos') 1.73 + when (select gname from grp where gname=bs.owner) 1.74 + is not null 1.75 + then (select val from grp_s where gname=bs.owner 1.76 + and key='gecos') 1.77 + else 1.78 + null 1.79 + end, 1.80 + bs.owner 1.81 + ) OWNER, 1.82 + a_s.val CTIME, 1.83 + ',t,'||bs.title||':'||b.rowid||'#'||a.id TITLE 1.84 + from (select rowid,id,val from article_m where id 1.85 + in (select id from article where author='$user') 1.86 + and type like 'file:%') 1.87 + m left join article a on m.id=a.id 1.88 + left join article_s a_s on a.id=a_s.id and a_s.key='ctime' 1.89 + left join (select id, 1.90 + max(case key when 'owner' then val end) as owner, 1.91 + max(case key when 'title' then val end) as title 1.92 + from blog_s group by id) 1.93 + bs on a.blogid=bs.id 1.94 + left join blog b on bs.id=b.id 1.95 + where m.val is not null order by $by $ord;" 1.96 + err lshandoutbyauthor: sql=`echo "$sql"` 1.97 + title="個人提出ファイル" 1.98 + m4 -D_TITLE_=$title $layout/html.m4.html 1.99 + hra="<a href=\"?lsmyfile+" 1.100 + hrb="<a href=\"?showattc+article_m+" 1.101 + hrc="<a href=\"?replyblog+" 1.102 + (echo '<table class="b">' 1.103 + echo "$sql"|sq -html -header $db ) \ 1.104 + | sed -e "s|\(<TR><TD>\)\([^/]*\)/\([0-9]*\)|\1$hrb\3\">\2</a>|" \ 1.105 + -e "s|,t,\(.*\):\([^<]*\)\(</TD>\)|$hrc\2\">\1</a>\3|" \ 1.106 + -e "s|\(<TH>\)\([A-Z]*\)\(</TH>\)|\1$hra\2$lkod\">\2</a>|" \ 1.107 + | m4 -D_TITLE_=$title -D_FORM_="<p>($by$jord)</p>" \ 1.108 + -D_DUMPTABLE_="syscmd(cat)" $layout/form+dump.m4.html 1.109 + echo '</table>' 1.110 +} 1.111 searchart() { 1.112 kwd=`getpar kwd` 1.113 if [ -z "$kwd" ]; then 1.114 @@ -348,35 +408,30 @@ 1.115 # $1=GRPname(if it is a group) 1.116 grprowid=$1 1.117 rowid=`getpar rowid` 1.118 -err ba: rowid=$rowid 1.119 - #if [ -z "$rowid" ]; then 1.120 - # When rowid is SET, it is updation of existing entry 1.121 - if [ -z "$1" ]; then 1.122 - listing=$user guide="[個人]" 1.123 -#listing代入は rowid 時でもするべき 1.124 - else 1.125 - grp=`getgroupbyid $grprowid` 1.126 - if [ -n "$grp" ]; then 1.127 - listing=$grp guide="[${grp}]" GF_OWNER=$grp 1.128 - else 1.129 - echo "無効なグループ指定です。" | html p 1.130 - return 1.131 - fi 1.132 - fi 1.133 - #fi 1.134 + err blog_addentry0: rowid=$rowid 1.135 + if [ -n "$grprowid" ]; then 1.136 + owner=`getgroupbyid $grprowid` 1.137 + else 1.138 + owner=`getpar owner` 1.139 + fi 1.140 + if isgroup $owner; then 1.141 + groupmode=1 listing=$owner guide="[${owner}]" GF_OWNER=$owner 1.142 + else 1.143 + usermode=1 listing=$user guide="[個人]" 1.144 + fi 1.145 + 1.146 if [ -n "`getpar title`" ]; then 1.147 - owner=`getpar owner` 1.148 - if isuser $owner; then 1.149 + if [ "$usermode" ]; then 1.150 if [ x"$user" != x"$owner" ]; then 1.151 echo "他人の日記は書けません" | html p 1.152 - return 1.153 + return 2 1.154 fi 1.155 - elif isgroup $owner; then # if write to group log 1.156 + elif [ "$groupmode" ]; then # if write to group log 1.157 grp=$owner #\`getpar grp\` 1.158 err ismember: $user $grp 1.159 if ! ismember "$user" "$grp"; then 1.160 echo "(話題作成はこのグループに加入してから)" | html p 1.161 - return 1.162 + return 3 1.163 fi 1.164 fi 1.165 par2table $formdir/blog.def 1.166 @@ -389,6 +444,7 @@ 1.167 elif [ -n "$serial" ]; then 1.168 # If new blog leader created, traverse to its head. 1.169 id=`query "select rowid from blog where id='$serial';"` 1.170 + err new-Leader: "select rowid from blog where id='$serial';" id=$id 1.171 fi 1.172 if [ -n "$id" ]; then 1.173 ## If new aritcle is entered, JUMP to blog_reply 1.174 @@ -429,9 +485,13 @@ 1.175 text=`getpar text` 1.176 if [ -n "$text" ]; then 1.177 if blog_writable $rowid $user; then 1.178 - if par2table $formdir/article.def; then 1.179 - blog_notify_reply $rowid $user "$text" 1.180 - fi 1.181 + par2table $formdir/article.def 1.182 + st=$? # ; err par2t-st=$st 1.183 + case $st in 1.184 + 0|4) 1.185 + [ "$st" = "4" ] && act="書込削除" 1.186 + blog_notify_reply $rowid $user "$text" $act ;; 1.187 + esac 1.188 else 1.189 title="$title(加入してないので書き込み不可)" 1.190 fi
2.1 --- a/s4-funcs.sh Sun Aug 02 10:58:58 2015 +0900 2.2 +++ b/s4-funcs.sh Sun Aug 02 17:05:08 2015 +0900 2.3 @@ -1232,7 +1232,7 @@ 2.4 m4 -D_TITLE_="グループ一覧" -D_BODYCLASS_=listgroup $layout/html.m4.html 2.5 kwd=`getpar kwd` 2.6 listgroup $kwd \ 2.7 - | m4 -D_DUMPTABLE_="syscmd(\`cat')" \ 2.8 + | m4 -D_DUMPTABLE_="syscmd(cat)" \ 2.9 -D_TITLE_="グループ関連操作" \ 2.10 -D_FORM_="<a href=\"?groupman\">新規グループ作成</a>" \ 2.11 $layout/form+dump.m4.html 2.12 @@ -1267,6 +1267,17 @@ 2.13 if [ x"$user" = x"$uname" ]; then 2.14 conflink="<a href=\"?userconf\">プロフィールの編集</a> / 2.15 <a href=\"?blog\">新規話題の作成</a>" 2.16 + # Display folders 2.17 + sql="select count(id) from article_m where id 2.18 + in (select id from article where author='$user') 2.19 + and type like 'file:%';" 2.20 + err nfile-sql=`echo "$sql"` 2.21 + nfile=`query "$sql"` 2.22 + err nfile=$nfile 2.23 + if [ $nfile -gt 0 ]; then 2.24 + conflink="$conflink / 2.25 + <a href=\"?lsmyfile\">過去の提出ファイル</a>" 2.26 + fi 2.27 fi 2.28 . ./s4-blog.sh 2.29 2.30 @@ -1277,6 +1288,7 @@ 2.31 $layout/html.m4.html $layout/home.m4.html 2.32 2.33 if [ x"$user" = x"$uname" ]; then 2.34 + # Display NEWS 2.35 cond="where 新着 > 0 order by 新着 desc,ctime desc limit 10" 2.36 new10=`DT_CHLD=article:blogid \ 2.37 DT_VIEW=replyblog dumptable html blog "ctime title gecos" "$cond"` 2.38 @@ -1470,7 +1482,7 @@ 2.39 if isgroup "$grp"; then 2.40 showgroupsub $formdir/grp.def "$1" | \ 2.41 m4 -D_TITLE_="グループ $grp" \ 2.42 - -D_FORM_="syscmd(\`cat')" \ 2.43 + -D_FORM_="syscmd(cat)" \ 2.44 -D_DUMPTABLE_="" \ 2.45 $layout/form+dump.m4.html 2.46 else # if $grp is removed at par2table 2.47 @@ -1879,6 +1891,16 @@ 2.48 # copy current parameters of par into destination table 2.49 # $1=definition-file 2.50 # Using $user and $session 2.51 + # Return value: 2.52 + # 0: Stored successfully 2.53 + # 1: Insufficient fillings 2.54 + # 2: No permission to modify the record 2.55 + # 3: Invalid rowid 2.56 + # 4: SUCCESS to delete 2.57 + # 5: Stop deletion for lack of confirm check 2.58 + # 6: Password length too short 2.59 + # 7: Password mismatch 2.60 + # 8: Old password incorrect 2.61 rowid=`getpar rowid` 2.62 err ...........rowid=$rowid 2.63 if [ ! -e $1 ]; then 2.64 @@ -1902,20 +1924,20 @@ 2.65 ### err rowowner=$rowowner 2.66 if [ x"$user" != x"$rowowner" ]; then 2.67 echo "他人のレコードはいじれないの" | html p 2.68 - return 2.69 + return 2 2.70 elif [ -z "$rowowner" ]; then 2.71 echo "指定したレコードはないみたい" | html p 2.72 - return 2.73 + return 3 2.74 fi 2.75 rm=`getpar rm` cfm=`getpar confirm` 2.76 # Editing existent entry 2.77 if [ x"$rm" = x"yes" ]; then 2.78 if [ x"$rm$cfm" = x"yesyes" ]; then 2.79 query "delete from $tbl where rowid=$rowid;" 2.80 - return 2.81 + return 4 2.82 else 2.83 echo "消去確認のチェックがないので消さなかったの..." | html p 2.84 - return 2.85 + return 5 2.86 fi 2.87 fi 2.88 fi 2.89 @@ -2055,16 +2077,16 @@ 2.90 case "$p1" in 2.91 ??????????*) ;; 2.92 *) echo "10字以上にしてください。" | html p 2.93 - return ;; 2.94 + return 6;; 2.95 esac 2.96 val="\"`echo $p1|mypwhash`\"" 2.97 else 2.98 echo "2つの新パスワード不一致" | html p 2.99 - return 2.100 + return 7 2.101 fi 2.102 else 2.103 echo "旧パスワード違います" | html p 2.104 - return 2.105 + return 8 2.106 fi 2.107 fi 2.108 ;;
3.1 --- a/s4.cgi Sun Aug 02 10:58:58 2015 +0900 3.2 +++ b/s4.cgi Sun Aug 02 17:05:08 2015 +0900 3.3 @@ -73,6 +73,12 @@ 3.4 . ./s4-blog.sh 3.5 $stage $rowid 3.6 ;; 3.7 + lsmyfile) 3.8 + contenttype; echo 3.9 + . ./s4-blog.sh 3.10 + shift 3.11 + $stage "$@" 3.12 + ;; 3.13 "searchart") # $2=blogowner 3.14 contenttype; echo 3.15 m4 -D_TITLE_="検索結果" $layout/html.m4.html