From cd8c60b7e27589af52ddde3b609ea7c5dd67bdc4 Mon Sep 17 00:00:00 2001 From: Björn Geiger Date: Thu, 4 Aug 2011 16:33:40 +0200 Subject: Group und Person API --- application/controllers/ResourceController.php | 96 +++++++++++++++++++++++++- 1 file changed, 95 insertions(+), 1 deletion(-) (limited to 'application/controllers/ResourceController.php') diff --git a/application/controllers/ResourceController.php b/application/controllers/ResourceController.php index 0943d2a..a6ed440 100644 --- a/application/controllers/ResourceController.php +++ b/application/controllers/ResourceController.php @@ -904,6 +904,99 @@ class ResourceController extends Zend_Controller_Action echo $xml; } + public function getpersonAction() { + $apikey = $this->_request->getParam('apikey'); + if($apikey == ""){ + header('HTTP/1.0 400 No API-Key'); + die(); + } + + if(isset($this->_request->getParam('personid'))) { + list($rightroles) = $this->rightrolesMapper->findBy(array('rightID' => '6', 'roleID' => $this->membership->getRoleID())); + if($rightroles == null){ + header('HTTP/1.0 403 No Right to Show Details of other Person'); + die(); + } + $personid = $this->_request->getParam('personid'); + } else { + $personid = $this->membership->getPersonID(); + } + + $personMapper = new Application_Model_PersonMapper(); + $person = new Application_Model_Person(); + $personMapper->find($personid,$person); + + $xml = "\n"; + $xml .= "\n"; + $xml .= "\t\n"; + $xml .= "\t\t" . $person->getID() . "\n"; + $xml .= "\t\t" . $person->getCity() . "\n"; + $xml .= "\t\t" . $person->getEmail() . "\n"; + $xml .= "\t\t" . $person->getFirstname() . "\n"; + $xml .= "\t\t" . $person->getHousenumber() . "\n"; + $xml .= "\t\t" . $person->getLogin() . "\n"; + $xml .= "\t\t" . $person->getLogindate() . "\n"; + $xml .= "\t\t" . $person->getName() . "\n"; + $xml .= "\t\t" . $person->getPostalcode() . "\n"; + $xml .= "\t\t" . $person->getRegisterdate() . "\n"; + $xml .= "\t\t" . $person->getStreet() . "\n"; + $xml .= "\t\t" . $person->getSuspend() . "\n"; + $xml .= "\t\t" . $person->getTitle() . "\n"; + $xml .= "\t\n"; + $xml .= ""; + + header('Content-Type: text/xml'); + header('Content-Disposition: inline; filename="person.xml"'); + header('Pragma: no-cache'); + header('Expires: 0'); + echo $xml; + } + + public function getgroupAction() { + list($rightroles1) = $this->rightrolesMapper->findBy(array('rightID' => '79', 'roleID' => $this->membership->getRoleID())); + if($rightroles1 == null){ + header('HTTP/1.0 403 No Right to Show Groups'); + die(); + } + + $apikey = $this->_request->getParam('apikey'); + if($apikey == ""){ + header('HTTP/1.0 400 No API-Key'); + die(); + } + + $groupMapper = new Application_Model_GroupMapper(); + + if(isset($this->_request->getParam('groupid'))) { + list($rightroles2) = $this->rightrolesMapper->findBy(array('rightID' => '11', 'roleID' => $this->membership->getRoleID())); + if($rightroles2 == null){ + header('HTTP/1.0 403 No Right to Show Details of other Group'); + die(); + } + $groupid = $this->_request->getParam('groupid'); + } else { + $groupid = $this->membership->getGroupID(); + } + + $group = new Application_Model_Group(); + $groupMapper->find($groupid, $group); + + $xml = "\n"; + $xml .= "\n"; + $xml .= "\t\n"; + $xml .= "\t\t" . $group->getID() . "\n"; + $xml .= "\t\t" . $group->getDescription() . "\n"; + $xml .= "\t\t" . $group->getTitle() . "\n"; + $xml .= "\t\n"; + $xml .= ""; + + header('Content-Type: text/xml'); + header('Content-Disposition: inline; filename="group.xml"'); + header('Pragma: no-cache'); + header('Expires: 0'); + echo $xml; + } + public function loginAction() { $xml = "\n"; $xml .= "\n"; @@ -929,6 +1022,7 @@ class ResourceController extends Zend_Controller_Action if($person->getSuspend()) { $xml .= "\t\tfalse\n"; + $xml .= "\t\t" . $person->getID() . ""; $xml .= "\t\tperson suspended\n"; } else { $xml .= "\t\ttrue\n"; @@ -959,7 +1053,7 @@ class ResourceController extends Zend_Controller_Action $xml .= ""; header('Content-Type: text/xml'); - header('Content-Disposition: inline; filename="pool.xml"'); + header('Content-Disposition: inline; filename="login.xml"'); header('Pragma: no-cache'); header('Expires: 0'); echo $xml; -- cgit v1.2.3-55-g7522