blob: f3c5666af3538f0b8bcdb05b2c392ba2f8c36cfe (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
<?php
/*
*
* createStory.php
*
*/
require_once(__DIR__.DIRECTORY_SEPARATOR.'lib'.DIRECTORY_SEPARATOR.'commons'.DIRECTORY_SEPARATOR.'functions.common.inc.php');
require_once(__DIR__.DIRECTORY_SEPARATOR.'lib'.DIRECTORY_SEPARATOR.'commons'.DIRECTORY_SEPARATOR.'functions.http.inc.php');
require_once(__DIR__.DIRECTORY_SEPARATOR.'lib'.DIRECTORY_SEPARATOR.'functions.stories.inc.php');
$storyName = getMandatoryPostParameter('story-name', '', true);
$storyLogoFile = getOptionalFileParameter('story-logo');
$storyDescription = getOptionalPostParameter('story-description');
$pathToStory = generatePath(['stories', $storyName], __DIR__);
$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);
}
?>
|