diff options
author | steckbrief <steckbrief@chefmail.de> | 2017-12-28 13:46:55 +0100 |
---|---|---|
committer | steckbrief <steckbrief@chefmail.de> | 2017-12-28 13:46:55 +0100 |
commit | 391875ea8389d043360961cf2c5a69f2b6d7a91a (patch) | |
tree | 7bd8c535cd8c6912f34c193ece35a2efcd73530c /editStory.php | |
parent | 31ba0cea75b128a664e777a0a2f4180a19501ec3 (diff) |
Diffstat (limited to 'editStory.php')
-rw-r--r-- | editStory.php | 40 |
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); +} + +?> |