summaryrefslogtreecommitdiffstats
path: root/editStory.php
diff options
context:
space:
mode:
Diffstat (limited to 'editStory.php')
-rw-r--r--editStory.php40
1 files changed, 40 insertions, 0 deletions
diff --git a/editStory.php b/editStory.php
new file mode 100644
index 0000000..2e8284d
--- /dev/null
+++ b/editStory.php
@@ -0,0 +1,40 @@
+<?php
+/*
+ *
+ * createStory.php
+ *
+ */
+
+require_once(__DIR__.'/lib/commons/functions.common.inc.php');
+require_once(__DIR__.'/lib/commons/functions.http.inc.php');
+require_once(__DIR__.'/lib/commons/functions.files.inc.php');
+require_once(__DIR__.'/lib/functions.stories.inc.php');
+
+$storyName = getMandatoryPostParameter('story-name', '', true);
+$storyLogoFile = getOptionalFileParameter('story-logo');
+$storyDescription = getOptionalPostParameter('story-description');
+$action = getMandatoryPostParameter('story-action');
+
+$pathToStory = generatePath(['stories', $storyName], __DIR__);
+
+if ('edit' == $action) {
+ $result = editEntity($pathToStory, $storyDescription, $storyLogoFile, 'logo.png');
+} else {
+ $result = createEntity($pathToStory, $storyDescription, $storyLogoFile, 'logo.png');
+}
+if (TRUE !== $result) {
+ switch ($result) {
+ case 1:
+ sendHttpReturnCodeAndJson(409, 'Story exists already');
+ break;
+ case 2:
+ sendHttpReturnCodeAndJson(500, 'Could not create directory for story');
+ break;
+ default:
+ sendHttpReturnCodeAndJson(500, 'Unexpected error');
+ }
+} else {
+ sendHttpReturnCodeAndMessage(201);
+}
+
+?>