summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Neves2012-01-26 21:39:47 +0100
committerMichael Neves2012-01-26 21:39:47 +0100
commit358665ca7dbc2f47dc0583c4a23114f3332c932f (patch)
tree30dddbc185868dafaa5bbf4761d71650ed74fb02
parentBootiso download fix (diff)
downloadpbs2-358665ca7dbc2f47dc0583c4a23114f3332c932f.tar.gz
pbs2-358665ca7dbc2f47dc0583c4a23114f3332c932f.tar.xz
pbs2-358665ca7dbc2f47dc0583c4a23114f3332c932f.zip
ResourceController querySerials added
-rw-r--r--application/controllers/ResourceController.php59
1 files changed, 59 insertions, 0 deletions
diff --git a/application/controllers/ResourceController.php b/application/controllers/ResourceController.php
index e7b654c..291f8f8 100644
--- a/application/controllers/ResourceController.php
+++ b/application/controllers/ResourceController.php
@@ -191,6 +191,65 @@ class ResourceController extends Zend_Controller_Action {
}
+ public function queryPrebootSerials(){
+ list($rightroles) = $this->rightrolesMapper->findBy(array('rightID' => '40', 'roleID' => $this->membership->getRoleID()));
+ if($rightroles == null) {
+ header('HTTP/1.0 403 No Right to Create Preboots');
+ die();
+ }
+
+ $apikey = $this->_request->getParam('apikey');
+ if($apikey == "") {
+ header('HTTP/1.0 400 No API-Key');
+ die();
+ }
+
+ $membershipMapper = new Application_Model_MembershipMapper();
+ $member = array_shift($membershipMapper->findBy(array('apikey' => $apikey)));
+ $groupID = $member->getGroupID();
+
+ $groupgroupsMapper = new Application_Model_GroupGroupsMapper();
+ $bootisoMapper = new Application_Model_BootIsoMapper();
+ $groupMapper = new Application_Model_GroupMapper();
+ $preboottypeMapper = new Application_Model_PreBootTypeMapper();
+ $personMapper = new Application_Model_PersonMapper();
+
+ $parents = array();
+ $this->view->bootisolist = array();
+ $parents = $groupgroupsMapper->getParentGroups($groupID);
+
+ foreach($parents as $k => $parent) {
+ foreach($parent as $p) {
+ $bootiso = $bootisoMapper->findBy(array("groupID" => $p));
+ foreach ($bootiso as $b)
+ if($b->getPublic() - $k >= 0 )
+ {
+ $bootisolist[] = $b;
+ }
+ elseif($k == 0 && $b->getPublic() == -1 && Pbs_Acl::checkRight('bc'))
+ $bootisolist[] = $b;
+ }
+ }
+ $bootisolist = array_reverse($bootisolist);
+
+ header('Content-Type: text/html');
+ $content_disp = ( ereg('MSIE ([0-9].[0-9]{1,2})', $_SERVER['HTTP_USER_AGENT']) == 'IE') ? 'inline' : 'attachment';
+ header('Content-Disposition: ' . $content_disp . '; filename="serials.txt"');
+ header('Pragma: no-cache');
+ header('Expires: 0');
+
+ $person = $personMapper->find($member->getPersonID());
+
+ $result = "Serials available to Member: ".$person->getFirstname()." ".$person->getName()." in Group: ".$groupMapper->find($member->getGroupID())."\n";
+ foreach($bootisolist as $k => $bootiso){
+ $result .= $groupMapper->find($bootiso->getGroupID())->getTitle()." ".$bootiso->getTitle()." ".$preboottypeMapper->find($bootiso->getPreboottypeID())->getName()." ".$bootiso->getSerialnumber()."\n";
+ }
+
+ header("Content-Length: ".(strlen($result)));
+
+ echo $result;
+
+ }
public function addprebootAction() {