summaryrefslogtreecommitdiffstats
path: root/application
diff options
context:
space:
mode:
authorBjörn Geiger2011-06-19 02:31:56 +0200
committerBjörn Geiger2011-06-19 02:31:56 +0200
commitce63d54aaf41a334427cc6ab6dc743525e85c544 (patch)
treeef8a71d65c1e8be9e7d0d76fd7ea7fd70063d4f7 /application
parentFilter API beim Delete prüfen ob Apikey berechtigt (diff)
downloadpbs2-ce63d54aaf41a334427cc6ab6dc743525e85c544.tar.gz
pbs2-ce63d54aaf41a334427cc6ab6dc743525e85c544.tar.xz
pbs2-ce63d54aaf41a334427cc6ab6dc743525e85c544.zip
Bootmenu API Test
Diffstat (limited to 'application')
-rw-r--r--application/controllers/ResourceController.php85
1 files changed, 82 insertions, 3 deletions
diff --git a/application/controllers/ResourceController.php b/application/controllers/ResourceController.php
index ed9ed6f..37d8edc 100644
--- a/application/controllers/ResourceController.php
+++ b/application/controllers/ResourceController.php
@@ -191,7 +191,7 @@ class ResourceController extends Zend_Controller_Action
$xml .= "<xml>\n";
$xml .= "\t<filterid>" . $filter->getID() . "</filterid>\n";
$xml .= "</xml>";
-
+
header('Content-Type: text/xml');
header('Content-Disposition: inline; filename="bootos.xml"');
header('Pragma: no-cache');
@@ -217,8 +217,6 @@ class ResourceController extends Zend_Controller_Action
$filterid = $params['filterid'];
$filterMapper = new Application_Model_FilterMapper();
- $filterentriesMapper = new Application_Model_FilterEntriesMapper();
-
$filter = new Application_Model_Filter();
$filterMapper->find($filterid, $filter);
if(isset($filter)) {
@@ -236,6 +234,87 @@ class ResourceController extends Zend_Controller_Action
}
}
+ public function addbootmenuAction()
+ {
+ list($rightroles) = $this->rightrolesMapper->findBy(array('rightID' => '65', 'roleID' => $this->membership->getRoleID()));
+ if($rightroles == null){
+ header('HTTP/1.0 403 No Right to Create Bootmenus');
+ die();
+ }
+
+ $apikey = $this->_request->getParam('apikey');
+ if($apikey == ""){
+ header('HTTP/1.0 400 No API-Key');
+ die();
+ }
+
+ $params = $this->_request->getParams();
+ $groupID = $this->membership->getGroupID();
+
+ $bootmenuMapper = new Application_Model_BootMenuMapper();
+ $bootmenuEntriesMapper = new Application_Model_BootMenuEntriesMapper();
+
+ $bootmenu = new Application_Model_BootMenu();
+ $bootmenu->setOptions($params);
+ $bootmenu->setGroupID($groupID);
+ $bootmenu->setMembershipID($this->membership->getID());
+ $bootmenu->setCreated(time());
+ $bootmenuid = $bootmenuMapper->save($bootmenu);
+ $bootmenu->setID($filterid);
+
+ $bootmenuentries = new Application_Model_BootMenuEntries();
+ $bootmenuentries->setOptions($params);
+ $bootmenuentries->setBootmenuID($bootmenu->getID());
+ $bootmenuentriesID = $bootmenuMapper->save($filterentries);
+ $bootmenuentries->setID($bootmenuentriesID);
+
+ $xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
+ $xml .= "<xml>\n";
+ $xml .= "\t<bootmenuid>" . $bootmenu->getID() . "</bootmenuid>\n";
+ $xml .= "</xml>";
+
+ header('Content-Type: text/xml');
+ header('Content-Disposition: inline; filename="bootmenu.xml"');
+ header('Pragma: no-cache');
+ header('Expires: 0');
+ echo $xml;
+ }
+
+ public function deletebootmenuAction() {
+ list($rightroles) = $this->rightrolesMapper->findBy(array('rightID' => '66', 'roleID' => $this->membership->getRoleID()));
+ if($rightroles == null){
+ header('HTTP/1.0 403 No Right to delete Bootmenus');
+ die();
+ }
+
+ $apikey = $this->_request->getParam('apikey');
+ if($apikey == ""){
+ header('HTTP/1.0 400 No API-Key');
+ die();
+ }
+
+ $params = $this->_request->getParams();
+ $groupID = $this->membership->getGroupID();
+ $bootmenuid = $params['bootmenuid'];
+
+ $bootmenuMapper = new Application_Model_BootMenuMapper();
+ $bootmenu = new Application_Model_Filter();
+ $bootmenuMapper->find($bootmenuid, $bootmenu);
+ if(isset($bootmenu)) {
+ if($bootmenu->getMembershipID() == $this->membership->getID()) {
+ $bootmenuMapper->delete($bootmenu);
+
+ header('HTTP/1.0 201 Bootmenu deleted');
+ } else {
+ header('HTTP/1.0 403 No Right to delete this Bootmenu');
+ die();
+ }
+ } else {
+ header('HTTP/1.0 400 Filter not found');
+ die();
+ }
+ }
+
public function editbootosAction()
{