diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/wiki.php | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/include/wiki.php b/include/wiki.php index f97036c29..e01cc12c3 100644 --- a/include/wiki.php +++ b/include/wiki.php @@ -232,4 +232,26 @@ function wiki_get_page_content($arr) { // TODO: Check that the files are all text files return array('content' => json_encode($content), 'message' => '', 'success' => true); } +} + + +function wiki_save_page($arr) { + $pagename = ((array_key_exists('name',$arr)) ? $arr['name'] : ''); + $content = ((array_key_exists('content',$arr)) ? $arr['content'] : ''); + $resource_id = ((array_key_exists('resource_id',$arr)) ? $arr['resource_id'] : ''); + $w = wiki_get_wiki($resource_id); + if (!$w['path']) { + return array('message' => 'Error reading wiki', 'success' => false); + } + $page_path = $w['path'].'/'.$pagename; + if (is_writable($page_path) === true) { + if(!file_put_contents($page_path, $content)) { + return array('message' => 'Error writing to page file', 'success' => false); + } + return array('message' => '', 'success' => true); + } else { + return array('message' => 'Page file not writable', 'success' => false); + } + + }
\ No newline at end of file |