summaryrefslogtreecommitdiffstats
path: root/createCharacter.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 /createCharacter.php
parent6bf09a069577fa9fcefdb0f92da81001465a50e0 (diff)
create story and character improved
Diffstat (limited to 'createCharacter.php')
-rw-r--r--createCharacter.php39
1 files changed, 39 insertions, 0 deletions
diff --git a/createCharacter.php b/createCharacter.php
new file mode 100644
index 0000000..f5015bb
--- /dev/null
+++ b/createCharacter.php
@@ -0,0 +1,39 @@
+<?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/functions.stories.inc.php');
+
+//print_r($_POST);exit();
+
+$storyName = getMandatoryPostParameter('story-name', NULL, true);
+$charName = getMandatoryPostParameter('char-name', NULL, true);
+$charPassphoto = getOptionalFileParameter('char-passphoto');
+$charDescription = getOptionalPostParameter('char-description');
+
+//$pathToChar = __DIR__.DIRECTORY_SEPARATOR.'stories'.DIRECTORY_SEPARATOR.generateDirectoryName($storyName).DIRECTORY_SEPARATOR.generateDirectoryName($charName);
+
+$pathToChar = generatePath(['stories', $storyName, $charName], __DIR__);
+echo $pathToChar;
+$result = createEntity($pathToChar, $charDescription, $charPassphoto, 'passphoto.png');
+if (TRUE !== $result) {
+ switch ($result) {
+ case 1:
+ sendHttpReturnCodeAndJson(409, 'Character exists already');
+ break;
+ case 2:
+ sendHttpReturnCodeAndJson(500, 'Could not create directory for character');
+ break;
+ default:
+ sendHttpReturnCodeAndJson(500, 'Unexpected error');
+ }
+} else {
+ sendHttpReturnCodeAndMessage(201);
+}
+
+?>