summaryrefslogtreecommitdiffstats
path: root/bl
diff options
context:
space:
mode:
authorBernhard Posselt <nukeawhale@gmail.com>2013-03-20 21:48:22 +0100
committerBernhard Posselt <nukeawhale@gmail.com>2013-03-21 00:31:18 +0100
commit6dab27a668b33f91efe5905d0bcb83d4b212ee86 (patch)
tree129ee8329c90eed20aa02c7bcfef5bd39c6425da /bl
parentb9d98e336c29d15cbf669d7d735eff7c80b02414 (diff)
be nice
Diffstat (limited to 'bl')
-rw-r--r--bl/bl.php59
-rw-r--r--bl/blexception.php39
-rw-r--r--bl/folderbl.php55
3 files changed, 143 insertions, 10 deletions
diff --git a/bl/bl.php b/bl/bl.php
new file mode 100644
index 000000000..eeabdcb17
--- /dev/null
+++ b/bl/bl.php
@@ -0,0 +1,59 @@
+<?php
+
+/**
+* ownCloud - News
+*
+* @author Alessandro Cosentino
+* @author Bernhard Posselt
+* @copyright 2012 Alessandro Cosentino cosenal@gmail.com
+* @copyright 2012 Bernhard Posselt nukeawhale@gmail.com
+*
+* This library is free software; you can redistribute it and/or
+* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+* License as published by the Free Software Foundation; either
+* version 3 of the License, or any later version.
+*
+* This library is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+*
+* You should have received a copy of the GNU Affero General Public
+* License along with this library. If not, see <http://www.gnu.org/licenses/>.
+*
+*/
+
+namespace OCA\News\Bl;
+
+use \OCA\AppFramework\Db\DoesNotExistException;
+use \OCA\AppFramework\Db\MultipleObjectsReturnedException;
+
+use \OCA\News\Db\NewsMapper;
+
+
+abstract class Bl {
+
+ protected $mapper;
+
+ public function __construct(NewsMapper $mapper){
+ $this->mapper = $mapper;
+ }
+
+
+ public function delete($id, $userId){
+ $entity = $this->find($id, $userId);
+ $this->mapper->delete($entity);
+ }
+
+
+ public function find($id, $userId){
+ try {
+ return $this->mapper->find($id, $userId);
+ } catch(DoesNotExistException $ex){
+ throw new BLException($ex->getMessage());
+ } catch(MultipleObjectsReturnedException $ex){
+ throw new BLException($ex->getMessage());
+ }
+ }
+
+} \ No newline at end of file
diff --git a/bl/blexception.php b/bl/blexception.php
new file mode 100644
index 000000000..fca362ea7
--- /dev/null
+++ b/bl/blexception.php
@@ -0,0 +1,39 @@
+<?php
+
+/**
+* ownCloud - News
+*
+* @author Alessandro Cosentino
+* @author Bernhard Posselt
+* @copyright 2012 Alessandro Cosentino cosenal@gmail.com
+* @copyright 2012 Bernhard Posselt nukeawhale@gmail.com
+*
+* This library is free software; you can redistribute it and/or
+* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+* License as published by the Free Software Foundation; either
+* version 3 of the License, or any later version.
+*
+* This library is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+*
+* You should have received a copy of the GNU Affero General Public
+* License along with this library. If not, see <http://www.gnu.org/licenses/>.
+*
+*/
+
+namespace OCA\News\Bl;
+
+
+class BLException extends \Exception {
+
+ /**
+ * Constructor
+ * @param string $msg the error message
+ */
+ public function __construct($msg){
+ parent::__construct($msg);
+ }
+
+} \ No newline at end of file
diff --git a/bl/folderbl.php b/bl/folderbl.php
index 85c386d90..9f9c09d15 100644
--- a/bl/folderbl.php
+++ b/bl/folderbl.php
@@ -1,27 +1,61 @@
<?php
-namespace OCA\News;
+/**
+* ownCloud - News
+*
+* @author Alessandro Cosentino
+* @author Bernhard Posselt
+* @copyright 2012 Alessandro Cosentino cosenal@gmail.com
+* @copyright 2012 Bernhard Posselt nukeawhale@gmail.com
+*
+* This library is free software; you can redistribute it and/or
+* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+* License as published by the Free Software Foundation; either
+* version 3 of the License, or any later version.
+*
+* This library is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+*
+* You should have received a copy of the GNU Affero General Public
+* License along with this library. If not, see <http://www.gnu.org/licenses/>.
+*
+*/
-class FolderBl {
+namespace OCA\News\Bl;
+
+use \OCA\News\Db\Folder;
+
+
+class FolderBl extends Bl {
public function __construct($folderMapper){
- $this->folderMapper = $folderMapper;
+ parent::__construct($folderMapper);
}
- public function getAll() {
- return $this->folderMapper->getAll();
+
+ public function getAll($userId) {
+ return $this->mapper->findAllFromUser($userId);
}
+
public function create($name, $parentId) {
- //TODO: change the setparentid in the model class Folder
- $folder = new Folder($name, null, null);
- return $this->folderMapper->save($folder);
+ $folder = new Folder();
+ $folder->setName($name);
+ $folder->setParentId($parentId);
+ return $this->mapper->insert($folder);
}
- public function delete($folderid) {
- return $this->folderMapper->deleteById($folderid);
+
+ public function setOpened($folderId, $opened, $userId){
+ $folder = $this->find($folderId, $userId);
+ $folder->setOpened($opened);
+ $this->mapper->update($folder);
}
+
+/*
public function modify($folderid, $name = null, $parent = null, $opened = null) {
$folder = $this->folderMapper->find($folderid);
if(!$folder)
@@ -35,4 +69,5 @@ class FolderBl {
$folder->setOpened($opened);
return $this->folderMapper->update($folder);
}
+*/
}