]> git.plutz.net Git - shellwiki/blobdiff - page_edit.sh
use acls in edit processing
[shellwiki] / page_edit.sh
index 9bb9f5f2d4c1f758bef9f982c04b685bf650c329..ca70c676c505df342ad4c989dd1fc79524309c89 100755 (executable)
@@ -21,35 +21,35 @@ edit_page="${PATH_INFO%\[edit\]}"
 edit_file="$_DATA/pages/$edit_page/#page.md"
 [ "$REQUEST_METHOD" = POST ] && edit_action="$(POST action)"
 
-debug "RM: $REQUEST_METHOD ea: $edit_action"
-
 if [ "$edit_page" = "$PATH_INFO" ]; then
   unset edit_page edit_action edit_file
   # END EDIT SCRIPT, continue in index.cgi
 
 elif [ "$edit_action" = update ]; then
-  mkdir -p -- "${edit_file%/#page.md}"
-
-  if S_LOCK "$edit_file"; then
+  if mkdir -p -- "${edit_file%/#page.md}" \
+       && S_LOCK "$edit_file"; then
     POST pagetext >"$edit_file"
     S_RELEASE "$edit_file"
-    REDIRECT "${_BASE}${PATH_INFO%\[edit\]}" |debug
+    REDIRECT "${_BASE}${PATH_INFO%\[edit\]}"
   else
     export ERRMSG="ERR_NOLOCK"
-    REDIRECT "${_BASE}${PATH_INFO%\[edit\]}/[edit]" |debug
+    REDIRECT "${_BASE}${PATH_INFO%\[edit\]}/[edit]"
   fi
 
 elif [ "$edit_action" = cancel ]; then
   S_RELEASE "$edit_file"
-  REDIRECT "${_BASE}${PATH_INFO%\[edit\]}" |debug
+  REDIRECT "${_BASE}${PATH_INFO%\[edit\]}"
+
+elif ! acl_write "$edit_page"; then
+  theme_403
 
-elif mkdir -p -- "${edit_file%/#page.md}" && S_LOCK "$edit_file"; then
-  # Display editor page
-  SESSION_COOKIE
+elif mkdir -p -- "${edit_file%/#page.md}" \
+     && S_LOCK "$edit_file"; then
   theme_editor "$edit_page"
 
 else
-  export ERRMSG="ERR_NOLOCK"
-  theme_page "$edit_page"
+  printf 'Refresh: %i; url=%s\r\n' 4 ../
+  export ERROR_MSG="Unable to lock page for editing"
+  theme_409
 
 fi