summaryrefslogtreecommitdiffstats
path: root/createStory.php
diff options
context:
space:
mode:
authorsteckbrief <steckbrief@chefmail.de>2017-12-10 20:22:33 +0100
committersteckbrief <steckbrief@chefmail.de>2017-12-10 20:22:33 +0100
commit2ec5cbc2aa2fe992d2cccaf6d160950adef521ef (patch)
tree726ff2e5907825469d81ea8af9e900a864ebc4a6 /createStory.php
parent6bf09a069577fa9fcefdb0f92da81001465a50e0 (diff)
create story and character improved
Diffstat (limited to 'createStory.php')
-rw-r--r--createStory.php13
1 files changed, 11 insertions, 2 deletions
diff --git a/createStory.php b/createStory.php
index 83d9000..f3c5666 100644
--- a/createStory.php
+++ b/createStory.php
@@ -13,11 +13,20 @@ $storyName = getMandatoryPostParameter('story-name', '', true);
$storyLogoFile = getOptionalFileParameter('story-logo');
$storyDescription = getOptionalPostParameter('story-description');
-$pathToStory = __DIR__.DIRECTORY_SEPARATOR.'stories'.DIRECTORY_SEPARATOR.generateDirectoryName($storyName);
+$pathToStory = generatePath(['stories', $storyName], __DIR__);
$result = createEntity($pathToStory, $storyDescription, $storyLogoFile, 'logo.png');
if (TRUE !== $result) {
- sendHttpReturnCodeAndJson(500, $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);
}