summaryrefslogtreecommitdiffstats
path: root/application
diff options
context:
space:
mode:
authorBjörn Geiger2011-09-12 15:35:55 +0200
committerBjörn Geiger2011-09-12 15:35:55 +0200
commit4a2c3a82869adb6a6bae83a73f9c1ce8ec941424 (patch)
tree71bbf6bfabeba9675a5c512549bade20c4741546 /application
parentweitere Korrektur (diff)
downloadpoolctrl-4a2c3a82869adb6a6bae83a73f9c1ce8ec941424.tar.gz
poolctrl-4a2c3a82869adb6a6bae83a73f9c1ce8ec941424.tar.xz
poolctrl-4a2c3a82869adb6a6bae83a73f9c1ce8ec941424.zip
Immediate Event funktioniert jetzt
Diffstat (limited to 'application')
-rwxr-xr-xapplication/controllers/EventController.php67
1 files changed, 45 insertions, 22 deletions
diff --git a/application/controllers/EventController.php b/application/controllers/EventController.php
index d758702..f5266b1 100755
--- a/application/controllers/EventController.php
+++ b/application/controllers/EventController.php
@@ -26,6 +26,17 @@ class EventController extends Zend_Controller_Action
public function init()
{
+ $bootstrap = $this->getInvokeArg('bootstrap');
+ $this->config = $bootstrap->getOptions();
+ $this->pbs2host = $this->config['pbs2']['host'];
+ $this->gearmanServerHost = $this->config['gearman']['server']['host'];
+ $this->gearmanServerPort = $this->config['gearman']['server']['port'];
+ $this->gearmanWorkerWaitTime = $this->config['gearman']['worker']['waitTime'];
+ $this->gearmanWorkerUpdateRate = $this->config['gearman']['worker']['updateRate'];
+ $this->gearmanClient = new GearmanClient();
+ $this->gearmanClient->addServer($this->gearmanServerHost);
+ $this->eventMapper = new Application_Model_EventMapper();
+ $this->eventcategoryMapper = new Application_Model_EventcategoryMapper();
$actionName = $this->getRequest()->getActionName();
if($actionName == "report" || $actionName == "run") {
$this->userIDsNamespace = Zend_Session::namespaceGet('userIDs');
@@ -35,34 +46,17 @@ class EventController extends Zend_Controller_Action
$apikey = $this->_request->getParam('apikey');
}
if($apikey != ""){
- $bootstrap = $this->getInvokeArg('bootstrap');
- $this->config = $bootstrap->getOptions();
- $this->pbs2host = $this->config['pbs2']['host'];
- $this->gearmanServerHost = $this->config['gearman']['server']['host'];
- $this->gearmanServerPort = $this->config['gearman']['server']['port'];
- $this->gearmanWorkerWaitTime = $this->config['gearman']['worker']['waitTime'];
- $this->gearmanWorkerUpdateRate = $this->config['gearman']['worker']['updateRate'];
- $this->gearmanClient = new GearmanClient();
- $this->gearmanClient->addServer($this->gearmanServerHost);
- $this->eventMapper = new Application_Model_EventMapper();
- $this->eventcategoryMapper = new Application_Model_EventcategoryMapper();
$this->acl = new Poolctrl_Acl($this->pbs2host, $this->config['pbs2']['checkright'] . $apikey, 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
} else {
header('HTTP/1.0 401 No apikey is set');
die();
}
} else if (Zend_Auth::getInstance()->hasIdentity()) {
- $bootstrap = $this->getInvokeArg('bootstrap');
- $this->config = $bootstrap->getOptions();
- $this->pbs2host = $this->config['pbs2']['host'];
$this->userIDsNamespace = Zend_Session::namespaceGet('userIDs');
if(isset($this->userIDsNamespace['apikey'])) {
$this->acl = new Poolctrl_Acl($this->pbs2host, $this->config['pbs2']['checkright'] . $this->userIDsNamespace['apikey'], 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
}
- if($this->userIDsNamespace['membershipID'] !='') {
- $this->eventMapper = new Application_Model_EventMapper();
- $this->eventcategoryMapper = new Application_Model_EventcategoryMapper();
- } else {
+ if(!$this->userIDsNamespace['membershipID'] !='') {
$this->_helper->redirector('selectmembership', 'person');
return;
}
@@ -318,8 +312,18 @@ class EventController extends Zend_Controller_Action
$filterentriesXML3 = new SimpleXMLElement($filterentriesXMLString3);
$filterentriesID3 = sprintf("%s", $filterentriesXML3->filterentry->id);
}
- if($params['immediate']) {
+ if($event->getImmediate()) {
+ $eventcategoryMapper = new Application_Model_EventcategoryMapper();
+ $result = $eventcategoryMapper->fetchAll();
+ $eventcategories = array();
+ foreach($result as $category) {
+ $eventcategories[$category->getID()] = $category->getTitle();
+ }
+ $eventCategory = $eventcategories[$event->getCategory()];
+ $eventtypeMapper = new Application_Model_EventtypeMapper();
+ $eventtype = $eventtypeMapper->findBy(array("title" => $eventCategory));
$event->setRunning(true);
+ $event->setRunningtype($eventtype[0]->getID());
} else {
$event->setRunning(false);
}
@@ -331,8 +335,8 @@ class EventController extends Zend_Controller_Action
echo "Message: " . $e->getMessage() . "<br/>";
return;
}
- if($params['immediate']) {
- $this->runEvent($event);
+ if($event->getImmediate()) {
+ $this->runEvent($event, $this->userIDsNamespace['apikey']);
}
$this->_redirect('/event/');
}
@@ -1007,7 +1011,7 @@ class EventController extends Zend_Controller_Action
echo $resultString;
}
- private function runEvent(Application_Model_Event $event) {
+ private function runEvent(Application_Model_Event $event, $apikey) {
$data = array(
'eventName' => $event->getTitle(),
);
@@ -1037,6 +1041,25 @@ class EventController extends Zend_Controller_Action
}
}
$data['clients'] = $clients;
+ $eventcategoryMapper = new Application_Model_EventcategoryMapper();
+ $result = $eventcategoryMapper->fetchAll();
+ foreach($result as $category) {
+ $eventcategories[$category->getTitle()] = $category->getID();
+ }
+ $boot = false;
+ $shutdown = false;
+ switch($event->getCategory()) {
+ case $eventcategories['Boot']:
+ $boot = true;
+
+ break;
+
+ case $eventcategories['Shutdown']:
+ $shutdown = true;
+
+ break;
+ }
+ $eventtypeMapper = new Application_Model_EventtypeMapper();
if($boot) {
$bootOsRequest = "bootosid=" . $event->getPbs_bootosID();
$bootOsApiResult = PostToHost($this->pbs2host, $this->config['pbs2']['getbootoss'] . $apikey, 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'], 'poolctrl', $bootOsRequest);