From db968c8d0eb4665b322429aec0573cb2f33a5881 Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Wed, 6 Jun 2012 13:57:13 +0200 Subject: [PATCH] fix bug #10: error when nothing submitted --- src/phorkie/Repository/Post.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/phorkie/Repository/Post.php b/src/phorkie/Repository/Post.php index d104a8c..fe2372f 100644 --- a/src/phorkie/Repository/Post.php +++ b/src/phorkie/Repository/Post.php @@ -20,6 +20,9 @@ class Repository_Post if (!isset($postData['files'])) { return false; } + if (!$this->hasContent($postData)) { + return false; + } if (!$this->repo) { $this->repo = $this->createRepo(); @@ -137,6 +140,19 @@ class Repository_Post return true; } + protected function hasContent($postData) + { + foreach ($postData['files'] as $num => $arFile) { + if ($_FILES['files']['error'][$num]['upload'] == 0) { + return true; + } + if ($arFile['content'] != '') { + return true; + } + } + return false; + } + public function createRepo() { $rs = new Repositories(); -- 2.30.2