summaryrefslogtreecommitdiffstats
path: root/application
diff options
context:
space:
mode:
authorSebastian Wagner2011-09-08 14:09:42 +0200
committerSebastian Wagner2011-09-08 14:09:42 +0200
commitaa9b83424abd2ed63798c624481c76a599dc8365 (patch)
tree2ec23349ab0bdb0cedc1530ae6d5176111eee1f8 /application
parentedit events by dblclick (diff)
parentweitere Korrektur (diff)
downloadpoolctrl-aa9b83424abd2ed63798c624481c76a599dc8365.tar.gz
poolctrl-aa9b83424abd2ed63798c624481c76a599dc8365.tar.xz
poolctrl-aa9b83424abd2ed63798c624481c76a599dc8365.zip
Merge branch 'master' of git.openslx.org:lsfks/projekte/poolctrl
Diffstat (limited to 'application')
-rw-r--r--application/Bootstrap.php73
-rw-r--r--application/Functions.php64
-rw-r--r--application/controllers/EventController.php25
-rw-r--r--application/controllers/GearmanController.php13
-rw-r--r--application/forms/EventAdd.php27
-rw-r--r--application/forms/EventEdit.php2
-rw-r--r--application/models/Event.php2
7 files changed, 81 insertions, 125 deletions
diff --git a/application/Bootstrap.php b/application/Bootstrap.php
index c238a12..0f62350 100644
--- a/application/Bootstrap.php
+++ b/application/Bootstrap.php
@@ -13,27 +13,27 @@
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
protected function _initAutoloader()
- {
- setlocale(LC_ALL, "de_DE.UTF-8");
- date_default_timezone_set('Europe/Berlin');
- $moduleLoader = new Zend_Application_Module_Autoloader
+ {
+ setlocale(LC_ALL, "de_DE.UTF-8");
+ date_default_timezone_set('Europe/Berlin');
+ $moduleLoader = new Zend_Application_Module_Autoloader
+ (
+ array
(
- array
- (
'namespace' => '',
'basePath' => APPLICATION_PATH,
'resourceTypes' => array(
'form' => array(
'path' => 'forms',
'namespace' => 'Form',
- )
- )
- )
- );
- }
- protected function _initAutoloaders()
+ )
+ )
+ )
+ );
+ }
+ protected function _initAutoloaders()
{
- $this->getApplication()->setAutoloaderNamespaces(array('Poolctrl_'));
+ $this->getApplication()->setAutoloaderNamespaces(array('Poolctrl_' => 'Poolctrl', 'Poolctrl_Validate_' => 'Poolctrl/Validator/'));
return $this;
}
@@ -42,36 +42,35 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
$auth->setStorage(new Zend_Auth_Storage_Session('auth'));
}
protected function _initDocType(){
- $this->bootstrap('View');
- $view = $this->getResource('View');
- $view->doctype('XHTML1_STRICT');
-
- }
+ $this->bootstrap('View');
+ $view = $this->getResource('View');
+ $view->doctype('XHTML1_STRICT');
+
+ }
function _initViewHelpers()
- {
-
- $this->bootstrap('layout');
-
- $layout = $this->getResource('layout');
- $view = $layout->getView();
- $view->doctype('XHTML1_STRICT');
- $view->headMeta()->appendHttpEquiv('Content-Type', 'text/html;charset=utf-8');
- $view->headLink()->appendStylesheet('/media/css/jquery-ui-1.8.16.custom.css');
- $view->headLink()->appendStylesheet('/media/css/jquery-ui-timepicker.css');
- $view->headLink()->appendStylesheet('/media/css/style.css');
-
- $view->headTitle('poolctrl')
- ->setSeparator(' :: ');
- Zend_Registry::set('dateformat' , 'Y-m-d H:i:s');
- }
- protected function _initPlugins()
+ {
+
+ $this->bootstrap('layout');
+
+ $layout = $this->getResource('layout');
+ $view = $layout->getView();
+ $view->doctype('XHTML1_STRICT');
+ $view->headMeta()->appendHttpEquiv('Content-Type', 'text/html;charset=utf-8');
+ $view->headLink()->appendStylesheet('/media/css/jquery-ui-1.8.16.custom.css');
+ $view->headLink()->appendStylesheet('/media/css/jquery-ui-timepicker.css');
+ $view->headLink()->appendStylesheet('/media/css/style.css');
+
+ $view->headTitle('poolctrl')
+ ->setSeparator(' :: ');
+ Zend_Registry::set('dateformat' , 'Y-m-d H:i:s');
+ }
+ protected function _initPlugins()
{
$this->bootstrap('autoloaders');
$this->bootstrap('frontController');
$plugin = new Poolctrl_Controller_Plugin_Modularlayout();
$this->frontController->registerPlugin($plugin);
-
}
}
-include 'Functions.php';
+include '../library/Poolctrl/Functions.php'; \ No newline at end of file
diff --git a/application/Functions.php b/application/Functions.php
deleted file mode 100644
index 0b89390..0000000
--- a/application/Functions.php
+++ /dev/null
@@ -1,64 +0,0 @@
-<?php
-/*
- * Copyright (c) 2011 - OpenSLX GmbH, RZ Uni Freiburg
- * This program is free software distributed under the GPL version 2.
- * See http://gpl.openslx.org/
- *
- * If you have any feedback please consult http://feedback.openslx.org/ and
- * send your suggestions, praise, or complaints to feedback@openslx.org
- *
- * General information about OpenSLX can be found at http://openslx.org/
- */
-function randomString($name_laenge = 16) {
- $zeichen = "abcedfghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRTSUVWXYZ0123456789";
- $name_neu = "";
-
- mt_srand ((double) microtime() * 1000000);
- for ($i = 0; $i < $name_laenge; $i++ ) {
- $name_neu .= $zeichen{mt_rand (0,strlen($zeichen) - 1)};
- }
- return $name_neu;
-}
-
-function print_a(){
- $numargs = func_num_args();
- if($numargs>1){
- $out = '';
- ob_start();
- echo "<div style='background-color:#FFCC33;border:1px solid black;margin:3px;padding:5px;'>";
- for($a=0;$a<$numargs;$a++)
- print_a(func_get_arg($a));
- echo "</div>";
- $out .= ob_get_contents();
- ob_end_clean();
- echo $out;
- }else{
- echo "<pre style='background-color:#FFDF80;border:1px solid #000;margin:3px;padding:5px;'>";
- $a = func_get_arg(0);
- $a = (is_bool($a))?(($a)?'true':'false'):$a;
- print_r($a);
- echo "</pre>";
- }
-}
-
-function PostToHost($host, $path, $referer, $userAgent, $dataToSend) {
- $fp = @ fsockopen($host, 80);
- @ fputs($fp, "POST $path HTTP/1.1\r\n");
- @ fputs($fp, "Host: $host\r\n");
- @ fputs($fp, "User-Agent: $userAgent\r\n");
- @ fputs($fp, "Referer: $referer\r\n");
- @ fputs($fp, "Content-type: application/x-www-form-urlencoded\r\n");
- @ fputs($fp, "Content-length: ". strlen($dataToSend) ."\r\n");
- @ fputs($fp, "Connection: close\r\n\r\n");
- @ fputs($fp, $dataToSend);
- $res = "";
- while(!@ feof($fp)) {
- $res .= @ fgets($fp, 128);
- }
- @ fclose($fp);
-
- $res = @ explode("\r\n\r\n",$res);
- $result['http-header'] = $res[0];
- $result['http-body'] = $res[1];
- return $result;
-} \ No newline at end of file
diff --git a/application/controllers/EventController.php b/application/controllers/EventController.php
index 4edabab..5a5e92e 100644
--- a/application/controllers/EventController.php
+++ b/application/controllers/EventController.php
@@ -227,18 +227,31 @@ class EventController extends Zend_Controller_Action
$add = $this->getRequest()->getParam("add");
if($this->getRequest()->getParam('evstart')) {
$evstart = date ('m/d/Y H:i', strtotime(substr($this->getRequest()->getParam('evstart'), 0, 24)));
+ } else if($this->getRequest()->getParam('start')) {
+ $evstart = $this->getRequest()->getParam('start');
}
if($this->getRequest()->getParam('evend')) {
$evend = date ('m/d/Y H:i', strtotime(substr($this->getRequest()->getParam('evend'), 0, 24)));
+ } else if($this->getRequest()->getParam('end')) {
+ $evend = $this->getRequest()->getParam('end');
}
if (!isset($add)){
- $addForm = new Application_Form_EventAdd(array('eventcategorylist' => $eventcategorylist, 'bootoslist' => $bootoslist, 'poollist' => $poollist, 'start' => $evstart, 'end' => $evend, 'defaultEventCategory' => $this->config['event']['category']['default']));
+ $defaultEventCategory = $this->config['event']['category']['default'];
+ foreach($eventcategorylist as $eventcategory) {
+ if($eventcategory->getTitle() == $defaultEventCategory) {
+ $defaultEventCategoryID = $eventcategory->getID();
+ break;
+ }
+ }
+ $addForm = new Application_Form_EventAdd(array('eventcategorylist' => $eventcategorylist, 'bootoslist' => $bootoslist, 'poollist' => $poollist, 'start' => $evstart, 'end' => $evend, 'defaultEventCategoryID' => $defaultEventCategoryID));
} else {
- $addForm = new Application_Form_EventAdd(array('eventcategorylist' => $eventcategorylist, 'bootoslist' => $bootoslist, 'poollist' => $poollist, 'defaultEventCategory' => $this->config['event']['category']['default'], $this->getRequest()->getParams()));
+ $addForm = new Application_Form_EventAdd(array('eventcategorylist' => $eventcategorylist, 'bootoslist' => $bootoslist, 'poollist' => $poollist, 'start' => $evstart, 'end' => $evend, $this->getRequest()->getParams()));
if ($addForm->isValid($this->getRequest()->getParams())) {
- $this->getRequest()->setParam('start', date ('Y-m-d H:i', strtotime($this->getRequest()->getParam('start'))));
+ $startTimestamp = strtotime($this->getRequest()->getParam('start'));
+ $this->getRequest()->setParam('start', date ('Y-m-d H:i', $startTimestamp));
if($this->getRequest()->getParam('end')) {
- $this->getRequest()->setParam('end', date ('Y-m-d H:i', strtotime($this->getRequest()->getParam('end'))));
+ $endTimestamp = strtotime($this->getRequest()->getParam('end'));
+ $this->getRequest()->setParam('end', date ('Y-m-d H:i', $endTimestamp));
}
$event = new Application_Model_Event($this->getRequest()->getParams());
$event->setPbs_membershipID($this->userIDsNamespace['membershipID']);
@@ -601,9 +614,9 @@ class EventController extends Zend_Controller_Action
}
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender();
- $startTime = time();
+ $startTime = time() - 60;
$updatePeriod = $this->config['event']['updatePeriod'];
- $endTime = $startTime + $updatePeriod * 60;
+ $endTime = $startTime + 60 + $updatePeriod * 60;
$eventlist = $this->eventMapper->fetchAll();
$eventcategoryMapper = new Application_Model_EventcategoryMapper();
$result = $eventcategoryMapper->fetchAll();
diff --git a/application/controllers/GearmanController.php b/application/controllers/GearmanController.php
index e959c42..b4b8f6c 100644
--- a/application/controllers/GearmanController.php
+++ b/application/controllers/GearmanController.php
@@ -14,13 +14,17 @@ class GearmanController extends Zend_Controller_Action
public function init()
{
- /*if (Zend_Auth::getInstance()->hasIdentity()) {
+ 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']);
+ $this->acl = new Poolctrl_Acl($this->pbs2host, $this->config['pbs2']['checkright'] . $this->userIDsNamespace['apikey'], 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
+ }
+ if(!$this->acl->checkRight('er')) {
+ header('HTTP/1.0 403 No Right to run events');
+ die();
}
$this->gearmanServerPort = $this->config['gearman']['server']['port'];
$this->gearmanServerHost = $this->config['gearman']['server']['host'];
@@ -28,11 +32,10 @@ class GearmanController extends Zend_Controller_Action
$this->gearmanWorkerUpdateRate = $this->config['gearman']['worker']['updateRate'];
$this->gearmanClient = new GearmanClient();
$this->gearmanClient->addServer($this->gearmanServerHost);
- } else {
+ } else {
$this->_helper->redirector('login', 'auth');
return;
- }*/
- $this->_redirect('/');
+ }
}
public function indexAction()
diff --git a/application/forms/EventAdd.php b/application/forms/EventAdd.php
index b62eed5..af34f84 100644
--- a/application/forms/EventAdd.php
+++ b/application/forms/EventAdd.php
@@ -8,7 +8,7 @@ class Application_Form_EventAdd extends Zend_Form
private $eventcategorylist;
private $start;
private $end;
- private $defaultEventCategory;
+ private $defaultEventCategoryID;
public function setMembershiplist($membershiplist){
$this->membershiplist = $membershiplist;
@@ -69,14 +69,14 @@ class Application_Form_EventAdd extends Zend_Form
return $this;
}
- public function getDefaultEventCategory()
+ public function getDefaultEventCategoryID()
{
- return $this->defaultEventCategory;
+ return $this->defaultEventCategoryID;
}
- public function setDefaultEventCategory($defaultEventCategory)
+ public function setDefaultEventCategoryID($defaultEventCategoryID)
{
- $this->defaultEventCategory = $defaultEventCategory;
+ $this->defaultEventCategoryID = $defaultEventCategoryID;
}
public function init()
@@ -92,15 +92,14 @@ class Application_Form_EventAdd extends Zend_Form
$title = $c->getTitle();
$id = $c->getID();
$eventcategoryfield->addMultiOption($id, $title);
- if($title == $this->defaultEventCategory) {
- $defaultEventCategoryID = $id;
- }
}
}
$eventcategoryfield->setRegisterInArrayValidator(false);
$eventcategoryfield->setAttrib('onchange', "eventcategoryfieldChanged('category');");
- $eventcategoryfield->setValue($defaultEventCategoryID);
+ if(isset($this->defaultEventCategoryID)) {
+ $eventcategoryfield->setValue($this->defaultEventCategoryID);
+ }
$this->addElement($eventcategoryfield);
$this->addElement('text', 'title', array(
@@ -122,21 +121,25 @@ class Application_Form_EventAdd extends Zend_Form
'filters' => array('StringTrim'),
'validators' => array(
array('StringLength', false, array(0, 16)),
+ array('Date', false, array('format' => 'mm/dd/yyyy H:i')),
),
'required' => true,
'label' => 'Start (mm/dd/yyyy H:min):',
- 'value' => $this->start,
+ 'value' => $this->start,
));
$this->addElement('text', 'end', array(
'filters' => array('StringTrim'),
'validators' => array(
array('StringLength', false, array(0, 16)),
+ array('Date', false, array('format' => 'mm/dd/yyyy H:i')),
+ array('DateGreaterThan', false, array('element' => 'End', 'compare' => 'Start', 'min' => $this->getElement('start')->getValue())),
),
'required' => false,
'label' => 'End (mm/dd/yyyy H:min):',
- 'value' => $this->end,
+ 'value' => $this->end,
));
+ $this->getElement('end')->addPrefixPath('Poolctrl_Validate', 'Poolctrl/Validator/', 'validate');
$this->addElement('checkbox', 'repeat', array(
'onchange' => 'repeatChanged("repeat")',
@@ -219,4 +222,4 @@ class Application_Form_EventAdd extends Zend_Form
});
</script>';
}
-}
+} \ No newline at end of file
diff --git a/application/forms/EventEdit.php b/application/forms/EventEdit.php
index 688af4a..379832a 100644
--- a/application/forms/EventEdit.php
+++ b/application/forms/EventEdit.php
@@ -102,6 +102,7 @@ class Application_Form_EventEdit extends Zend_Form
'filters' => array('StringTrim'),
'validators' => array(
array('StringLength', false, array(0, 16)),
+ array('Date', false, array('format' => 'mm/dd/yyyy H:i')),
),
'required' => true,
'label' => 'Start (mm/dd/yyyy H:min):',
@@ -112,6 +113,7 @@ class Application_Form_EventEdit extends Zend_Form
'filters' => array('StringTrim'),
'validators' => array(
array('StringLength', false, array(0, 16)),
+ array('Date', false, array('format' => 'mm/dd/yyyy H:i')),
),
'required' => true,
'label' => 'End (mm/dd/yyyy H:min):',
diff --git a/application/models/Event.php b/application/models/Event.php
index 9033824..10d1f07 100644
--- a/application/models/Event.php
+++ b/application/models/Event.php
@@ -267,7 +267,7 @@ class Application_Model_Event
return $this;
}
- public function getRunning()
+ public function isRunning()
{
return $this->_running;
}