summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Wagner2011-08-02 17:06:59 +0200
committerSebastian Wagner2011-08-02 17:06:59 +0200
commite1ab1cb79068c4c46aa547cefc24da9c83cf1dd0 (patch)
treeddf75a38df4dc78320b74dad9eeef1b493fa049a
parentactions added to database (diff)
downloadpoolctrl-e1ab1cb79068c4c46aa547cefc24da9c83cf1dd0.tar.gz
poolctrl-e1ab1cb79068c4c46aa547cefc24da9c83cf1dd0.tar.xz
poolctrl-e1ab1cb79068c4c46aa547cefc24da9c83cf1dd0.zip
some database changes, actions in eventform implemented, testevents are now displayed in the calendar
-rw-r--r--application/controllers/EventController.php46
-rw-r--r--application/controllers/GearmanController.php2
-rw-r--r--application/forms/EventAdd.php35
-rw-r--r--application/models/Event.php12
-rw-r--r--application/models/EventcategoryMapper.php3
-rw-r--r--application/views/scripts/event/index.phtml7
-rw-r--r--setup/poolctrl.sql4
-rw-r--r--setup/poolctrl_data.sql22
8 files changed, 97 insertions, 34 deletions
diff --git a/application/controllers/EventController.php b/application/controllers/EventController.php
index 5801052..553ab95 100644
--- a/application/controllers/EventController.php
+++ b/application/controllers/EventController.php
@@ -14,6 +14,7 @@ class EventController extends Zend_Controller_Action
{
protected $eventMapper;
protected $eventcategoryMapper;
+ protected $eventactionMapper;
protected $membershipMapper;
protected $personMapper;
protected $config;
@@ -27,6 +28,7 @@ class EventController extends Zend_Controller_Action
if($this->userIDsNamespace['membershipID'] !='') {
$this->eventMapper = new Application_Model_EventMapper();
$this->eventcategoryMapper = new Application_Model_EventcategoryMapper();
+ $this->eventactionMapper = new Application_Model_EventactionMapper();
$this->membershipMapper = new Application_Model_MembershipMapper();
$this->personMapper = new Application_Model_PersonMapper();
$bootstrap = $this->getInvokeArg('bootstrap');
@@ -93,8 +95,11 @@ class EventController extends Zend_Controller_Action
$this->personMapper->find($membership->getPersonID(), $person);
$event['pbs_person_name'] = $person->getFirstname() . " " . $person->getName();
$eventcategory = new Application_Model_Eventcategory();
+ $eventaction = new Application_Model_Eventaction();
$this->eventcategoryMapper->find($event['category'], $eventcategory);
+ $this->eventactionMapper->find($event['action'], $eventaction);
$event['category'] = $eventcategory->getTitle();
+ $event['action'] = $eventaction->getTitle();
$eventlist[$event['pbs_poolID']][] = $event;
}
}
@@ -107,6 +112,7 @@ class EventController extends Zend_Controller_Action
public function addAction()
{
$eventcategorylist = $this->eventcategoryMapper->fetchAll();
+ $eventactionlist = $this->eventactionMapper->fetchAll();
$bootOsApiResult = PostToHost($this->pbs2host, $this->config['pbs2']['getbootoss'] . $this->userIDsNamespace['apikey'], 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'], 'poolctrl', '');
$bootOsXMLString = $bootOsApiResult['http-body'];
if(strlen($bootOsXMLString) > 0) {
@@ -146,9 +152,9 @@ class EventController extends Zend_Controller_Action
}
$add = $this->getRequest()->getParam("add");
if (!isset($add)){
- $addForm = new Application_Form_EventAdd(array('eventcategorylist' => $eventcategorylist, 'bootoslist' => $bootoslist, 'poollist' => $poollist));
+ $addForm = new Application_Form_EventAdd(array('eventcategorylist' => $eventcategorylist, 'eventactionlist' => $eventactionlist, 'bootoslist' => $bootoslist, 'poollist' => $poollist));
} else {
- $addForm = new Application_Form_EventAdd(array('eventcategorylist' => $eventcategorylist, 'bootoslist' => $bootoslist, 'poollist' => $poollist, $this->getRequest()->getParams()));
+ $addForm = new Application_Form_EventAdd(array('eventcategorylist' => $eventcategorylist, 'eventactionlist' => $eventactionlist, 'bootoslist' => $bootoslist, 'poollist' => $poollist, $this->getRequest()->getParams()));
if ($addForm->isValid($this->getRequest()->getParams())) {
$this->getRequest()->setParam('start', date ('Y-m-d H:i', strtotime($this->getRequest()->getParam('start'))));
$this->getRequest()->setParam('end', date ('Y-m-d H:i', strtotime($this->getRequest()->getParam('end'))));
@@ -208,6 +214,7 @@ class EventController extends Zend_Controller_Action
public function editAction()
{
$eventcategorylist = $this->eventcategoryMapper->fetchAll();
+ $eventactionlist = $this->eventactionMapper->fetchAll();
$bootOsApiResult = PostToHost($this->pbs2host, $this->config['pbs2']['getbootoss'] . $this->userIDsNamespace['apikey'], 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'], 'poolctrl', '');
$bootOsXMLString = $bootOsApiResult['http-body'];
if(strlen($bootOsXMLString) > 0) {
@@ -252,7 +259,7 @@ class EventController extends Zend_Controller_Action
} else {
$save = $this->getRequest()->getParam("save");
if (isset($save)){
- $editForm = new Application_Form_EventEdit(array('eventcategorylist' => $eventcategorylist, 'bootoslist' => $bootoslist, 'poollist' => $poollist, $this->getRequest()->getParams()));
+ $editForm = new Application_Form_EventEdit(array('eventcategorylist' => $eventcategorylist, 'eventactionlist' => $eventactionlist, 'bootoslist' => $bootoslist, 'poollist' => $poollist, $this->getRequest()->getParams()));
if ($editForm->isValid($this->getRequest()->getParams())) {
$this->getRequest()->setParam('start', date ('Y-m-d H:i', strtotime($this->getRequest()->getParam('start'))));
$this->getRequest()->setParam('end', date ('Y-m-d H:i', strtotime($this->getRequest()->getParam('end'))));
@@ -290,6 +297,7 @@ class EventController extends Zend_Controller_Action
$event = new Application_Model_Event();
$this->eventMapper->find($eventID, $event);
$this->getRequest()->setParam('title', $event->getTitle());
+ $this->getRequest()->setParam('action', $event->getAction());
$this->getRequest()->setParam('immediate', $event->getImmediate());
$this->getRequest()->setParam('start', $event->getStart());
$this->getRequest()->setParam('end', $event->getEnd());
@@ -301,10 +309,40 @@ class EventController extends Zend_Controller_Action
$this->getRequest()->setParam('pbs_bootosID', $event->getPbs_bootosID());
$this->getRequest()->setParam('pbs_membershipID', $event->getPbs_membershipID());
$params = $this->getRequest()->getParams();
- $editForm = new Application_Form_EventEdit(array('eventcategorylist' => $eventcategorylist, 'bootoslist' => $bootoslist, 'poollist' => $poollist , 'params' => $params));
+ $editForm = new Application_Form_EventEdit(array('eventcategorylist' => $eventcategorylist, 'eventactionlist' => $eventactionlist, 'bootoslist' => $bootoslist, 'poollist' => $poollist , 'params' => $params));
}
$this->view->editForm = $editForm;
$this->view->params = $params;
}
}
+
+ public function listAction() {
+
+ $this->_helper->layout->disableLayout();
+ $this->_helper->viewRenderer->setNoRender();
+
+ $year = date('Y');
+ $month = date('m');
+
+ echo json_encode(array(
+
+ array(
+ 'id' => 111,
+ 'title' => "Event1",
+ 'start' => "$year-$month-10",
+ 'end' => "$year-$month-11",
+ 'url' => "http://yahoo.com/"
+ ),
+
+ array(
+ 'id' => 222,
+ 'title' => "Event2",
+ 'start' => "$year-$month-20",
+ 'end' => "$year-$month-22",
+ 'url' => "http://yahoo.com/"
+ )
+
+ ));
+ return;
+ }
} \ No newline at end of file
diff --git a/application/controllers/GearmanController.php b/application/controllers/GearmanController.php
index 8e053d9..97b3c35 100644
--- a/application/controllers/GearmanController.php
+++ b/application/controllers/GearmanController.php
@@ -86,7 +86,7 @@ class GearmanController extends Zend_Controller_Action
'eventName' => $eventName,
'updateRate' => $updateRate,
'clients' => array(
- 0 => array('id' => '1', 'ip' =>'132.230.4.127', 'mac' =>'00:1e:0b:a6:d5:d4'),
+ 0 => array('id' => '1', 'ip' =>'132.230.4.24', 'mac' =>'00:13:72:C7:FD:A1'), //PC im HiWi-Raum rechts auf dem Tisch
/* 1 => array('id' => '2', 'ip' =>'132.230.4.2', 'mac' =>''),
2 => array('id' => '3', 'ip' =>'132.230.4.3', 'mac' =>''),
3 => array('id' => '4', 'ip' =>'132.230.4.4', 'mac' =>''),
diff --git a/application/forms/EventAdd.php b/application/forms/EventAdd.php
index 17b8f88..32108e0 100644
--- a/application/forms/EventAdd.php
+++ b/application/forms/EventAdd.php
@@ -6,6 +6,7 @@ class Application_Form_EventAdd extends Zend_Form
private $bootoslist;
private $poollist;
private $eventcategorylist;
+ private $eventactionlist;
public function setMembershiplist($membershiplist){
$this->membershiplist = $membershiplist;
@@ -43,6 +44,16 @@ class Application_Form_EventAdd extends Zend_Form
{
$this->eventcategorylist = $eventcategorylist;
}
+
+ public function getEventactionlist()
+ {
+ return $this->eventactionlist;
+ }
+
+ public function setEventactionlist($eventactionlist)
+ {
+ $this->eventactionlist = $eventactionlist;
+ }
public function init()
{
@@ -57,6 +68,18 @@ class Application_Form_EventAdd extends Zend_Form
'required' => true,
'label' => 'Title:',
));
+
+ $eventactionfield = $this->createElement('select','action');
+ $eventactionfield ->setLabel('Action:');
+
+ if(count($this->eventactionlist)>0){
+ foreach($this->eventactionlist as $action => $a){
+ $eventactionfield->addMultiOption($a->getID(), $a->getTitle());
+ }
+ }
+
+ $eventactionfield->setRegisterInArrayValidator(false);
+ $this->addElement($eventactionfield);
$this->addElement('checkbox', 'immediate', array(
'required' => false,
@@ -137,18 +160,6 @@ class Application_Form_EventAdd extends Zend_Form
$poolfield->setRegisterInArrayValidator(false);
$this->addElement($poolfield);
- // $membershipfield = $this->createElement('select','pbs_membershipID');
- // $membershipfield ->setLabel('Membership:');
- //
- // if(count($this->membershiplist)>0){
- // foreach($this->membershiplist as $membership => $m){
- // $membershipfield->addMultiOption($m->getID(), $m->getPersonID());
- // }
- // }
- //
- // $membershipfield->setRegisterInArrayValidator(false);
- // $this->addElement($membershipfield);
-
$bootosfield = $this->createElement('select','pbs_bootosID');
$bootosfield ->setLabel('BootOS:');
diff --git a/application/models/Event.php b/application/models/Event.php
index 0cde232..b69412e 100644
--- a/application/models/Event.php
+++ b/application/models/Event.php
@@ -14,6 +14,7 @@ class Application_Model_Event
{
protected $_eventID;
protected $_title;
+ protected $_action;
protected $_start;
protected $_end;
protected $_participants;
@@ -165,6 +166,17 @@ class Application_Model_Event
return $this;
}
+ public function getAction()
+ {
+ return $this->_action;
+ }
+
+ public function setAction($_action)
+ {
+ $this->_action = $_action;
+ return $this;
+ }
+
public function getPbs_poolID()
{
return $this->_pbs_poolID;
diff --git a/application/models/EventcategoryMapper.php b/application/models/EventcategoryMapper.php
index bfc4fd1..2a2e069 100644
--- a/application/models/EventcategoryMapper.php
+++ b/application/models/EventcategoryMapper.php
@@ -145,5 +145,4 @@ class Application_Model_EventcategoryMapper
-}
-
+} \ No newline at end of file
diff --git a/application/views/scripts/event/index.phtml b/application/views/scripts/event/index.phtml
index 33a93e9..cb591fe 100644
--- a/application/views/scripts/event/index.phtml
+++ b/application/views/scripts/event/index.phtml
@@ -62,7 +62,7 @@ $(document).ready(function() {iniCalendar();});
header: {
left: 'title',
center: 'prev,next today',
- right: 'month,agendaWeek,agendaDay'
+ right: 'agendaWeek,agendaDay'
},
editable: true,
// disableDragging: false,
@@ -70,7 +70,7 @@ $(document).ready(function() {iniCalendar();});
selectable: true,
selectHelper: true,
- events: "calendarEvents.php",
+ events: "/event/list",
dayClick: function(date, allDay, jsEvent, view) {
self.location="/event/add/";
@@ -133,6 +133,9 @@ if(count($this->eventlist)>0) {
<?php
}
?>
+ <div class='details'><label>Action:</label>
+ <div class='item'><?php echo $event['action']; ?>&nbsp;</div>
+ </div>
<div class='details'><label>Start Time:</label>
<div class='item'><?php echo date ('d F Y - H:i', strtotime($event['start'])); ?>&nbsp;</div>
</div>
diff --git a/setup/poolctrl.sql b/setup/poolctrl.sql
index a6dfbe0..e395ac6 100644
--- a/setup/poolctrl.sql
+++ b/setup/poolctrl.sql
@@ -7,7 +7,7 @@ SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
CREATE TABLE IF NOT EXISTS `poolctrl_event` (
`eventID` int(11) NOT NULL AUTO_INCREMENT,
`title` varchar(30) COLLATE utf8_unicode_ci NOT NULL UNIQUE,
- `action` varchar(30) COLLATE utf8_unicode_ci,
+ `action` int(11) NOT NULL DEFAULT '1',
`start` timestamp COLLATE utf8_unicode_ci NOT NULL DEFAULT CURRENT_TIMESTAMP(),
`end` timestamp COLLATE utf8_unicode_ci NOT NULL,
`participants` int(4) NOT NULL DEFAULT 50 CHECK (participants > 0),
@@ -227,6 +227,6 @@ ALTER TABLE `poolctrl_event`
-- ADD CONSTRAINT `poolctrl_event_bootmenuidC` FOREIGN KEY (`pbs_bootmenuID`) REFERENCES `pbs_bootmenu` (`bootmenuID`) ON DELETE CASCADE,
-- ADD CONSTRAINT `poolctrl_event_filteridC` FOREIGN KEY (`pbs_filterID`) REFERENCES `pbs_filter` (`filterID`) ON DELETE CASCADE,
ADD CONSTRAINT `poolctrl_event_categoryC` FOREIGN KEY (`category`) REFERENCES `poolctrl_eventcategory` (`eventcategoryID`) ON DELETE CASCADE,
- ADD CONSTRAINT `poolctrl_event_actionC` FOREIGN KEY (`action`) REFERENCES `poolctrl_eventaction` (`title`) ON DELETE CASCADE,
+ ADD CONSTRAINT `poolctrl_event_actionC` FOREIGN KEY (`action`) REFERENCES `poolctrl_eventaction` (`eventactionID`) ON DELETE CASCADE,
ADD CONSTRAINT `poolctrl_event_startC` CHECK (start > CURRENT_TIMESTAMP()),
ADD CONSTRAINT `poolctrl_event_endC` CHECK (end > start);
diff --git a/setup/poolctrl_data.sql b/setup/poolctrl_data.sql
index 6ffb017..c802a56 100644
--- a/setup/poolctrl_data.sql
+++ b/setup/poolctrl_data.sql
@@ -120,21 +120,21 @@ INSERT INTO `poolctrl_eventcategory` (`eventcategoryID`, `title`) VALUES
(3, 'Private'),
(4, 'Public');
+-- Adding eventactions
+INSERT INTO `poolctrl_eventaction` (`eventactionID`, `title`) VALUES
+(1, 'None'),
+(2, 'Boot'),
+(3, 'Shutdown'),
+(4, 'Maintenance');
+
-- Adding events
-INSERT INTO `poolctrl_event` (`eventID`, `title`, `start`, `end`, `category`, `pbs_poolID`, `pbs_membershipID`, `pbs_bootosID`, `note`, `pbs_bootmenuID`, `pbs_filterID`) VALUES
-(1, 'Systeme I', '2011-06-24 12:10:00', '2011-06-24 14:00:00', '1', 1, 1, 1, 'Systeme I Vorlesung', 1, 1),
-(2, 'Systeme II', '2011-06-24 14:10:00', '2011-06-24 16:00:00', '1', 1, 1, 1, 'Systeme II Vorlesung', 1, 1),
-(3, 'Systeme III', '2011-06-24 16:10:00', '2011-06-24 18:00:00', '1', 1, 1, 1, 'Systeme III Vorlesung', 1, 1);
+INSERT INTO `poolctrl_event` (`eventID`, `title`, `action`, `start`, `end`, `category`, `pbs_poolID`, `pbs_membershipID`, `pbs_bootosID`, `note`, `pbs_bootmenuID`, `pbs_filterID`) VALUES
+(1, 'Systeme I', DEFAULT, '2011-06-24 12:10:00', '2011-06-24 14:00:00', '1', 1, 1, 1, 'Systeme I Vorlesung', 1, 1),
+(2, 'Systeme II', 2, '2011-06-24 14:10:00', '2011-06-24 16:00:00', '1', 1, 1, 1, 'Systeme II Vorlesung', 1, 1),
+(3, 'Systeme III', 3, '2011-06-24 16:10:00', '2011-06-24 18:00:00', '1', 1, 1, 1, 'Systeme III Vorlesung', 1, 1);
-- Adding eventreports
INSERT INTO `poolctrl_eventreport` (`reportID`, `report`, `eventID`) VALUES
(1, DEFAULT, 1),
(2, DEFAULT, 2),
(3, 'wake-on-lan failed', 3);
-
--- Adding eventactions
-INSERT INTO `poolctrl_eventaction` (`eventactionID`, `title`) VALUES
-(1, 'Boot'),
-(2, 'Shutdown'),
-(3, 'Maintenance');
-