4 If the _APPENDONLY page flag is set, users can further only append
5 text to a page (and not edit the site as whole), while moderators and
10 $ewiki_plugins["edit_hook"][] = "ewiki_edit_hook_appendonly";
11 $ewiki_plugins["edit_save"][] = "ewiki_edit_save_appendonly";
16 function ewiki_edit_hook_appendonly($id, &$data, &$hpdata) {
18 global $ewiki_t, $ewiki_ring;
20 if ((($data["flags"] & EWIKI_DB_F_ACCESS) == EWIKI_DB_F_APPENDONLY) && (!EWIKI_PROTECTED_MODE || ($ewiki_ring >= 2))) {
21 if ($data["version"] && strlen($data["content"])) {
22 if (!$_REQUEST["content"] || !$_REQUEST["version"]) {
24 #-- only show the editable part in the edit box
25 $data["content"] = "----\n\n";
27 #-- change "edit" title to "append"
28 foreach (array_keys($ewiki_t) as $LANG) {
29 if ($ewiki_t[$LANG]["APPENDTOPAGE"]) {
30 $ewiki_t[$LANG]["EDITTHISPAGE"] = &$ewiki_t[$LANG]["APPENDTOPAGE"];
41 function ewiki_edit_save_appendonly(&$save, &$old) {
45 if ((($old["flags"] & EWIKI_DB_F_ACCESS) == EWIKI_DB_F_APPENDONLY) && (!EWIKI_PROTECTED_MODE || ($ewiki_ring >= 2))) {
46 if ($old["version"] && ($old_len=strlen($old_str=&$old["content"]))) {
48 #-- add newlines and a horizontal bar
49 $old_str = rtrim($old_str);
50 if (substr($old_str, $old_len-5, 4) == "----") {
51 $old_str = rtrim(rtrim($old_str, "-"));
54 if (!preg_match("/^\n*----/", $save["content"])) {
55 $save["content"] = "----\n\n" . $save["content"];
58 #-- merge the old not-editable-part with the new append-part
59 $save["content"] = $old["content"]