summaryrefslogtreecommitdiffstats
path: root/lib/functions.stories.inc.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 /lib/functions.stories.inc.php
parent31ba0cea75b128a664e777a0a2f4180a19501ec3 (diff)
update and delete addedHEADv0.1master
Diffstat (limited to 'lib/functions.stories.inc.php')
-rw-r--r--lib/functions.stories.inc.php30
1 files changed, 20 insertions, 10 deletions
diff --git a/lib/functions.stories.inc.php b/lib/functions.stories.inc.php
index 5e0527e..8f35e27 100644
--- a/lib/functions.stories.inc.php
+++ b/lib/functions.stories.inc.php
@@ -13,20 +13,30 @@ function generateDirectoryName($name) {
return urlencode($name);
}
+function saveEntity($path, $description, $file, $filename) {
+ // create description file
+ if (file_put_contents($path.DIRECTORY_SEPARATOR.'description.txt', $description) === FALSE) {
+ // Error on writing description file
+ }
+ // move uploaded logo
+ if (NULL === $file || move_uploaded_file($file['tmp_name'], $path.DIRECTORY_SEPARATOR.$filename) || $file['error'] == UPLOAD_ERR_NO_FILE) {
+ return TRUE;
+ } else {
+ return 3;
+ }
+}
+
+function editEntity($path, $description, $file, $filename) {
+ if (dir_exists($path)) {
+ return saveEntity($path, $description, $file, $filename);
+ }
+}
+
function createEntity($path, $description, $file, $filename) {
if (!dir_exists($path)) {
// create directory for story
if (mkdir($path)) {
- // create description file
- if (file_put_contents($path.DIRECTORY_SEPARATOR.'description.txt', $description) === FALSE) {
- // Error on writing description file
- }
- // move uploaded logo
- if (NULL === $file || move_uploaded_file($file['tmp_name'], $path.DIRECTORY_SEPARATOR.$filename) || $file['error'] == UPLOAD_ERR_NO_FILE) {
- return TRUE;
- } else {
- return 3;
- }
+ return saveEntity($path, $description, $file, $filename);
} else {
// Error on directory creation
// return 'Could not create directory "'.$path;