summaryrefslogtreecommitdiffstats
path: root/editCharacter.php
diff options
context:
space:
mode:
authorsteckbrief <steckbrief@chefmail.de>2017-12-28 13:46:55 +0100
committersteckbrief <steckbrief@chefmail.de>2017-12-28 13:46:55 +0100
commit391875ea8389d043360961cf2c5a69f2b6d7a91a (patch)
tree7bd8c535cd8c6912f34c193ece35a2efcd73530c /editCharacter.php
parent31ba0cea75b128a664e777a0a2f4180a19501ec3 (diff)
update and delete addedHEADv0.1master
Diffstat (limited to '')
-rw-r--r--editCharacter.php44
1 files changed, 44 insertions, 0 deletions
diff --git a/editCharacter.php b/editCharacter.php
new file mode 100644
index 0000000..eb9bee3
--- /dev/null
+++ b/editCharacter.php
@@ -0,0 +1,44 @@
+<?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');
+
+//print_r($_POST);exit();
+
+$storyName = getMandatoryPostParameter('story-name', NULL, true);
+$charName = getMandatoryPostParameter('char-name', NULL, true);
+$charPassphoto = getOptionalFileParameter('char-passphoto');
+$charDescription = getOptionalPostParameter('char-description');
+$action = getMandatoryPostParameter('char-action');
+
+//$pathToChar = __DIR__.DIRECTORY_SEPARATOR.'stories'.DIRECTORY_SEPARATOR.generateDirectoryName($storyName).DIRECTORY_SEPARATOR.generateDirectoryName($charName);
+
+$pathToChar = generatePath(['stories', $storyName, $charName], __DIR__);
+if ('edit' == $action) {
+ $result = editEntity($pathToChar, $charDescription, $charPassphoto, 'passphoto.png');
+} else {
+ $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);
+}
+
+?>