diff options
Diffstat (limited to 'protected/controllers')
| -rw-r--r-- | protected/controllers/KategorieController.php | 163 | ||||
| -rw-r--r-- | protected/controllers/SpeisTrankController.php | 163 | ||||
| -rw-r--r-- | protected/controllers/StandortController.php | 190 | ||||
| -rw-r--r-- | protected/controllers/UserController.php (renamed from protected/controllers/CmsPageController.php) | 34 | ||||
| -rw-r--r-- | protected/controllers/VeranstaltungController.php | 169 | ||||
| -rw-r--r-- | protected/controllers/VereinController.php | 164 |
6 files changed, 862 insertions, 21 deletions
diff --git a/protected/controllers/KategorieController.php b/protected/controllers/KategorieController.php new file mode 100644 index 0000000..ceeaf42 --- /dev/null +++ b/protected/controllers/KategorieController.php @@ -0,0 +1,163 @@ +<?php + +class KategorieController extends Controller +{ + /** + * @var string the default layout for the views. Defaults to '//layouts/column2', meaning + * using two-column layout. See 'protected/views/layouts/column2.php'. + */ + public $layout='//layouts/column2'; + + public function init() { + Yii::app()->format->numberFormat = array('decimals'=>1, 'decimalSeparator'=>",", 'thousandSeparator'=>"."); + } + + /** + * @return array action filters + */ + public function filters() + { + return array( + 'accessControl', // perform access control for CRUD operations + ); + } + + /** + * Specifies the access control rules. + * This method is used by the 'accessControl' filter. + * @return array access control rules + */ + public function accessRules() + { + return array( + array('allow', // allow admin user to perform 'admin' and 'delete' actions + 'actions'=>array('index','create','update','delete','view'), + 'users'=>array('admin'), + ), + array('deny', // deny all users + 'users'=>array('*'), + ), + ); + } + + /** + * Displays a particular model. + * @param integer $id the ID of the model to be displayed + */ + public function actionView($id) + { + $this->render('view',array( + 'model'=>$this->loadModel($id), + )); + } + + /** + * Creates a new model. + * If creation is successful, the browser will be redirected to the 'view' page. + */ + public function actionCreate() + { + $model=new Kategorie; + + // Uncomment the following line if AJAX validation is needed + // $this->performAjaxValidation($model); + + if(isset($_POST['Kategorie'])) + { + $model->attributes=$_POST['Kategorie']; + if($model->save()) + $this->redirect(array('view','id'=>$model->id)); + } + + $this->render('create',array( + 'model'=>$model, + )); + } + + /** + * Updates a particular model. + * If update is successful, the browser will be redirected to the 'view' page. + * @param integer $id the ID of the model to be updated + */ + public function actionUpdate($id) + { + $model=$this->loadModel($id); + + // Uncomment the following line if AJAX validation is needed + // $this->performAjaxValidation($model); + + if(isset($_POST['Kategorie'])) + { + $model->attributes=$_POST['Kategorie']; + $model->default_menge = str_replace(",", ".", $model->default_menge); + if($model->save()) { + $this->redirect(array('view','id'=>$model->id)); + } + } + + $this->render('update',array( + 'model'=>$model, + )); + } + + /** + * Deletes a particular model. + * If deletion is successful, the browser will be redirected to the 'admin' page. + * @param integer $id the ID of the model to be deleted + */ + public function actionDelete($id) + { + if(Yii::app()->request->isPostRequest) + { + // we only allow deletion via POST request + $this->loadModel($id)->delete(); + + // if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser + if(!isset($_GET['ajax'])) + $this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('admin')); + } + else + throw new CHttpException(400,'Invalid request. Please do not repeat this request again.'); + } + + /** + * Lists all models. + */ + public function actionIndex() + { + $model=new Kategorie('search'); + $model->unsetAttributes(); // clear any default values + if(isset($_GET['Kategorie'])) + $model->attributes=$_GET['Kategorie']; + + $this->render('index',array( + 'model'=>$model, + )); + } + + /** + * Returns the data model based on the primary key given in the GET variable. + * If the data model is not found, an HTTP exception will be raised. + * @param integer the ID of the model to be loaded + */ + public function loadModel($id) + { + $model=Kategorie::model()->findByPk($id); + if($model===null) + throw new CHttpException(404,'The requested page does not exist.'); + return $model; + } + + /** + * Performs the AJAX validation. + * @param CModel the model to be validated + */ + protected function performAjaxValidation($model) + { + if(isset($_POST['ajax']) && $_POST['ajax']==='kategorie-form') + { + echo CActiveForm::validate($model); + Yii::app()->end(); + } + } +} diff --git a/protected/controllers/SpeisTrankController.php b/protected/controllers/SpeisTrankController.php new file mode 100644 index 0000000..1da7883 --- /dev/null +++ b/protected/controllers/SpeisTrankController.php @@ -0,0 +1,163 @@ +<?php + +class SpeisTrankController extends Controller +{ + /** + * @var string the default layout for the views. Defaults to '//layouts/column2', meaning + * using two-column layout. See 'protected/views/layouts/column2.php'. + */ + public $layout='//layouts/column2'; + + /** + * @return array action filters + */ + public function filters() + { + return array( + 'accessControl', // perform access control for CRUD operations + ); + } + + /** + * Specifies the access control rules. + * This method is used by the 'accessControl' filter. + * @return array access control rules + */ + public function accessRules() + { + return array( + array('allow', // allow admin user to perform 'admin' and 'delete' actions + 'actions'=>array('create','index','delete','update','view'), + 'users'=>array('admin'), + ), + array('deny', // deny all users + 'users'=>array('*'), + ), + ); + } + + /** + * Displays a particular model. + * @param integer $id the ID of the model to be displayed + */ + public function actionView($id) + { + $this->render('view',array( + 'model'=>$this->loadModel($id), + )); + } + + /** + * Creates a new model. + * If creation is successful, the browser will be redirected to the 'view' page. + */ + public function actionCreate() + { + $model=new Angebot; + + // Uncomment the following line if AJAX validation is needed + // $this->performAjaxValidation($model); + + if(isset($_POST['Angebot'])) + { + $model->attributes=$_POST['Angebot']; + if($model->save()) + $this->redirect(array('view','id'=>$model->id)); + } + + $kategorien = Kategorie::model()->findAll(array("condition"=>"published=1")); + + $this->render('create',array( + 'model'=>$model, + 'kategorien'=>$kategorien + )); + } + + /** + * Updates a particular model. + * If update is successful, the browser will be redirected to the 'view' page. + * @param integer $id the ID of the model to be updated + */ + public function actionUpdate($id) + { + $model=$this->loadModel($id); + + // Uncomment the following line if AJAX validation is needed + // $this->performAjaxValidation($model); + + if(isset($_POST['Angebot'])) + { + $model->attributes=$_POST['Angebot']; + if($model->save()) + $this->redirect(array('view','id'=>$model->id)); + } + + $kategorien = Kategorie::model()->findAll(array("condition"=>"published=1")); + + $this->render('update',array( + 'model'=>$model, + 'kategorien'=>$kategorien + )); + } + + /** + * Deletes a particular model. + * If deletion is successful, the browser will be redirected to the 'admin' page. + * @param integer $id the ID of the model to be deleted + */ + public function actionDelete($id) + { + if(Yii::app()->request->isPostRequest) + { + // we only allow deletion via POST request + $this->loadModel($id)->delete(); + + // if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser + if(!isset($_GET['ajax'])) + $this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('admin')); + } + else + throw new CHttpException(400,'Invalid request. Please do not repeat this request again.'); + } + + /** + * Lists all models. + */ + public function actionIndex() + { + $model=new Angebot('search'); + $model->unsetAttributes(); // clear any default values + if(isset($_GET['Angebot'])) + $model->attributes=$_GET['Angebot']; + + $this->render('index',array( + 'model'=>$model, + )); + } + + /** + * Returns the data model based on the primary key given in the GET variable. + * If the data model is not found, an HTTP exception will be raised. + * @param integer the ID of the model to be loaded + */ + public function loadModel($id) + { + $model=Angebot::model()->findByPk($id); + if($model===null) + throw new CHttpException(404,'The requested page does not exist.'); + return $model; + } + + /** + * Performs the AJAX validation. + * @param CModel the model to be validated + */ + protected function performAjaxValidation($model) + { + if(isset($_POST['ajax']) && $_POST['ajax']==='angebot-form') + { + echo CActiveForm::validate($model); + Yii::app()->end(); + } + } +} diff --git a/protected/controllers/StandortController.php b/protected/controllers/StandortController.php new file mode 100644 index 0000000..3fa11df --- /dev/null +++ b/protected/controllers/StandortController.php @@ -0,0 +1,190 @@ +<?php + +class StandortController extends Controller +{ + /** + * @var string the default layout for the views. Defaults to '//layouts/column2', meaning + * using two-column layout. See 'protected/views/layouts/column2.php'. + */ + public $layout='//layouts/column2'; + + /** + * @return array action filters + */ + public function filters() + { + return array( + 'accessControl', // perform access control for CRUD operations + ); + } + + /** + * Specifies the access control rules. + * This method is used by the 'accessControl' filter. + * @return array access control rules + */ + public function accessRules() + { + return array( + array('allow', // allow admin user to perform 'admin' and 'delete' actions + 'actions'=>array('delete','create','update','index','view','ajaxupdate','ajaxcreate','savecoords'), + 'users'=>array('admin'), + ), + array('deny', // deny all users + 'users'=>array('*'), + ), + ); + } + + /** + * Displays a particular model. + * @param integer $id the ID of the model to be displayed + */ + public function actionView($id) + { + $this->render('view',array( + 'model'=>$this->loadModel($id), + )); + } + + /** + * Creates a new model. + * If creation is successful, the browser will be redirected to the 'view' page. + */ + public function actionCreate() + { + $model=new Standort; + + // Uncomment the following line if AJAX validation is needed + // $this->performAjaxValidation($model); + + if(isset($_POST['Standort'])) + { + $model->attributes=$_POST['Standort']; + if($model->save()) + $this->redirect(array('index')); + } + + $this->render('create',array( + 'model'=>$model, + )); + } + + /** + * Updates a particular model. + * If update is successful, the browser will be redirected to the 'view' page. + * @param integer $id the ID of the model to be updated + */ + public function actionUpdate($id) + { + $model=$this->loadModel($id); + + // Uncomment the following line if AJAX validation is needed + // $this->performAjaxValidation($model); + + if(isset($_POST['Standort'])) + { + $model->attributes=$_POST['Standort']; + if($model->save()) + $this->redirect(array('view','id'=>$model->id)); + } + + $this->render('update',array( + 'model'=>$model, + )); + } + + + /** + * Updates the standort with $id. + * This method loads the post parameters + * <ul> + * <li>lat</li> + * <li>lng</li> + * </ul> + * @param integer $id the ID of the standort to be moved + * @throws CHttpException if + * <ul> + * <li>one of the parameters is not set or</li> + * <li>the standort does not exist or</li> + * <li>the save action was unsuccessful</li> + * </ul> + */ + public function actionSavecoords($id) { + $model=$this->loadModel($id); + + if (isset($_POST['lat']) && isset($_POST['lng'])) { + $model->pos_lat = $_POST['lat']; + $model->pos_long = $_POST['lng']; + if($model->save()) { + echo "success"; + } else { + throw new CHttpException(500, "Could not save"); + } + } else { + throw new CHttpException(400, "Wrong parameters"); + } + } + + /** + * Deletes a particular model. + * If deletion is successful, the browser will be redirected to the 'admin' page. + * @param integer $id the ID of the model to be deleted + */ + public function actionDelete($id) + { + if(Yii::app()->request->isPostRequest) + { + // we only allow deletion via POST request + $this->loadModel($id)->delete(); + + // if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser + if(!isset($_GET['ajax'])) + $this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('admin')); + } + else + throw new CHttpException(400,'Invalid request. Please do not repeat this request again.'); + } + + /** + * Manages all models. + */ + public function actionIndex() + { + $model=new Standort('search'); + $model->unsetAttributes(); // clear any default values + if(isset($_GET['Standort'])) + $model->attributes=$_GET['Standort']; + + $this->render('index',array( + 'model'=>$model, + "standorte"=>Standort::model()->findAll() + )); + } + + /** + * Returns the data model based on the primary key given in the GET variable. + * If the data model is not found, an HTTP exception will be raised. + * @param integer the ID of the model to be loaded + */ + public function loadModel($id) + { + $model=Standort::model()->findByPk($id); + if($model===null) + throw new CHttpException(404,'The requested page does not exist.'); + return $model; + } + + /** + * Performs the AJAX validation. + * @param CModel the model to be validated + */ + protected function performAjaxValidation($model) + { + if(isset($_POST['ajax']) && $_POST['ajax']==='standort-form') + { + echo CActiveForm::validate($model); + Yii::app()->end(); + } + } +} diff --git a/protected/controllers/CmsPageController.php b/protected/controllers/UserController.php index 362f991..79fc7e8 100644 --- a/protected/controllers/CmsPageController.php +++ b/protected/controllers/UserController.php @@ -1,6 +1,6 @@ <?php -class CmsPageController extends Controller +class UserController extends Controller { /** * @var string the default layout for the views. Defaults to '//layouts/column2', meaning @@ -26,16 +26,8 @@ class CmsPageController extends Controller public function accessRules() { return array( - array('allow', // allow all users to perform 'index' and 'view' actions - 'actions'=>array('index','view'), - 'users'=>array('*'), - ), - array('allow', // allow authenticated user to perform 'create' and 'update' actions - 'actions'=>array('create','update'), - 'users'=>array('@'), - ), array('allow', // allow admin user to perform 'admin' and 'delete' actions - 'actions'=>array('admin','delete'), + 'actions'=>array('create','update','index','view','admin','delete'), 'users'=>array('admin'), ), array('deny', // deny all users @@ -61,14 +53,14 @@ class CmsPageController extends Controller */ public function actionCreate() { - $model=new CmsPage; + $model=new User; // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); - if(isset($_POST['CmsPage'])) + if(isset($_POST['User'])) { - $model->attributes=$_POST['CmsPage']; + $model->attributes=$_POST['User']; if($model->save()) $this->redirect(array('view','id'=>$model->id)); } @@ -90,9 +82,9 @@ class CmsPageController extends Controller // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); - if(isset($_POST['CmsPage'])) + if(isset($_POST['User'])) { - $model->attributes=$_POST['CmsPage']; + $model->attributes=$_POST['User']; if($model->save()) $this->redirect(array('view','id'=>$model->id)); } @@ -127,7 +119,7 @@ class CmsPageController extends Controller */ public function actionIndex() { - $dataProvider=new CActiveDataProvider('CmsPage'); + $dataProvider=new CActiveDataProvider('User'); $this->render('index',array( 'dataProvider'=>$dataProvider, )); @@ -138,10 +130,10 @@ class CmsPageController extends Controller */ public function actionAdmin() { - $model=new CmsPage('search'); + $model=new User('search'); $model->unsetAttributes(); // clear any default values - if(isset($_GET['CmsPage'])) - $model->attributes=$_GET['CmsPage']; + if(isset($_GET['User'])) + $model->attributes=$_GET['User']; $this->render('admin',array( 'model'=>$model, @@ -155,7 +147,7 @@ class CmsPageController extends Controller */ public function loadModel($id) { - $model=CmsPage::model()->findByPk($id,"status=".CmsPage::STATUS_PUBLISHED); + $model=User::model()->findByPk($id); if($model===null) throw new CHttpException(404,'The requested page does not exist.'); return $model; @@ -167,7 +159,7 @@ class CmsPageController extends Controller */ protected function performAjaxValidation($model) { - if(isset($_POST['ajax']) && $_POST['ajax']==='cms-page-form') + if(isset($_POST['ajax']) && $_POST['ajax']==='user-form') { echo CActiveForm::validate($model); Yii::app()->end(); diff --git a/protected/controllers/VeranstaltungController.php b/protected/controllers/VeranstaltungController.php new file mode 100644 index 0000000..49ec10a --- /dev/null +++ b/protected/controllers/VeranstaltungController.php @@ -0,0 +1,169 @@ +<?php + +class VeranstaltungController extends Controller +{ + /** + * @var string the default layout for the views. Defaults to '//layouts/column2', meaning + * using two-column layout. See 'protected/views/layouts/column2.php'. + */ + public $layout='//layouts/column2'; + + /** + * @return array action filters + */ + public function filters() + { + return array( + 'accessControl', // perform access control for CRUD operations + ); + } + + /** + * Specifies the access control rules. + * This method is used by the 'accessControl' filter. + * @return array access control rules + */ + public function accessRules() + { + return array( + array('allow', // allow admin user to perform 'admin' and 'delete' actions + 'actions'=>array('create','update','index','view','delete'), + 'users'=>array('admin'), + ), + array('deny', // deny all users + 'users'=>array('*'), + ), + ); + } + + /** + * Displays a particular model. + * @param integer $id the ID of the model to be displayed + */ + public function actionView($id) + { + $this->render('view',array( + 'model'=>$this->loadModel($id), + )); + } + + /** + * Creates a new model. + * If creation is successful, the browser will be redirected to the 'view' page. + */ + public function actionCreate() + { + $model=new Veranstaltung; + + // Uncomment the following line if AJAX validation is needed + // $this->performAjaxValidation($model); + + if(isset($_POST['Veranstaltung'])) + { + $model->attributes=$_POST['Veranstaltung']; + Yii::trace(print_r($model, true), "VERANSTALTUNG"); + if($model->save()) + $this->redirect(array('view','id'=>$model->id)); + } + + $standorte = Standort::model()->findAll(array("condition"=>"published=1 and type='Bühne'")); + $vereine = Verein::model()->findAll(array("condition"=>"published=1")); + + $this->render('create',array( + 'model'=>$model, + 'vereine'=>$vereine, + 'standorte'=>$standorte + )); + } + + /** + * Updates a particular model. + * If update is successful, the browser will be redirected to the 'view' page. + * @param integer $id the ID of the model to be updated + */ + public function actionUpdate($id) + { + $model=$this->loadModel($id); + + // Uncomment the following line if AJAX validation is needed + // $this->performAjaxValidation($model); + + if(isset($_POST['Veranstaltung'])) + { + $model->attributes=$_POST['Veranstaltung']; + + if($model->save()) + $this->redirect(array('view','id'=>$model->id)); + } + + $standorte = Standort::model()->findAll(array("condition"=>"published=1 and type='Bühne'")); + $vereine = Verein::model()->findAll(array("condition"=>"published=1")); + + $this->render('update',array( + 'model'=>$model, + 'vereine'=>$vereine, + 'standorte'=>$standorte + )); + } + + /** + * Deletes a particular model. + * If deletion is successful, the browser will be redirected to the 'admin' page. + * @param integer $id the ID of the model to be deleted + */ + public function actionDelete($id) + { + if(Yii::app()->request->isPostRequest) + { + // we only allow deletion via POST request + $this->loadModel($id)->delete(); + + // if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser + if(!isset($_GET['ajax'])) + $this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('admin')); + } + else + throw new CHttpException(400,'Invalid request. Please do not repeat this request again.'); + } + + /** + * Lists all models. + */ + public function actionIndex() + { + $model=new Veranstaltung('search'); + $model->unsetAttributes(); // clear any default values + if(isset($_GET['Veranstaltung'])) + $model->attributes=$_GET['Veranstaltung']; + + $this->render('index',array( + 'model'=>$model, + )); + } + + /** + * Returns the data model based on the primary key given in the GET variable. + * If the data model is not found, an HTTP exception will be raised. + * @param integer the ID of the model to be loaded + */ + public function loadModel($id) + { + $model=Veranstaltung::model()->findByPk($id); + if($model===null) + throw new CHttpException(404,'The requested page does not exist.'); + return $model; + } + + /** + * Performs the AJAX validation. + * @param CModel the model to be validated + */ + protected function performAjaxValidation($model) + { + if(isset($_POST['ajax']) && $_POST['ajax']==='veranstaltung-form') + { + echo CActiveForm::validate($model); + Yii::app()->end(); + } + } +} diff --git a/protected/controllers/VereinController.php b/protected/controllers/VereinController.php new file mode 100644 index 0000000..2be85d6 --- /dev/null +++ b/protected/controllers/VereinController.php @@ -0,0 +1,164 @@ +<?php + +class VereinController extends Controller +{ + /** + * @var string the default layout for the views. Defaults to '//layouts/column2', meaning + * using two-column layout. See 'protected/views/layouts/column2.php'. + */ + public $layout='//layouts/column2'; + + /** + * @return array action filters + */ + public function filters() + { + return array( + 'accessControl', // perform access control for CRUD operations + ); + } + + /** + * Specifies the access control rules. + * This method is used by the 'accessControl' filter. + * @return array access control rules + */ + public function accessRules() + { + return array( + array('allow', // allow admin user to perform 'admin' and 'delete' actions + 'actions'=>array('index','create','view','update','delete'), + 'users'=>array('admin'), + ), + array('deny', // deny all users + 'actions'=>array('create','update','delete'), + 'users'=>array('*'), + ), + ); + } + + /** + * Displays a particular model. + * @param integer $id the ID of the model to be displayed + */ + public function actionView($id) + { + $this->render('view',array( + 'model'=>$this->loadModel($id), + )); + } + + /** + * Creates a new model. + * If creation is successful, the browser will be redirected to the 'view' page. + */ + public function actionCreate() + { + $model=new Verein; + + // Uncomment the following line if AJAX validation is needed + // $this->performAjaxValidation($model); + + if(isset($_POST['Verein'])) + { + $model->attributes=$_POST['Verein']; + if($model->save()) + $this->redirect(array('view','id'=>$model->id)); + } + + $standorte = Standort::model()->findAll(array("condition"=>"published=1 and type='Stand'")); + $this->render('create',array( + 'model'=>$model, + 'standorte'=>$standorte + )); + } + + /** + * Updates a particular model. + * If update is successful, the browser will be redirected to the 'view' page. + * @param integer $id the ID of the model to be updated + */ + public function actionUpdate($id) + { + $model=$this->loadModel($id); + + // Uncomment the following line if AJAX validation is needed + // $this->performAjaxValidation($model); + + if(isset($_POST['Verein'])) + { + $model->attributes=$_POST['Verein']; + if($model->save()) + $this->redirect(array('view','id'=>$model->id)); + } + + $standorte = Standort::model()->findAll(array("condition"=>"published=1 and type='Stand'")); + $slugs = User::model()->findAll(); + $this->render('update',array( + 'model'=>$model, + 'standorte'=>$standorte, + 'slugs'=>$slugs + )); + } + + /** + * Deletes a particular model. + * If deletion is successful, the browser will be redirected to the 'admin' page. + * @param integer $id the ID of the model to be deleted + */ + public function actionDelete($id) + { + if(Yii::app()->request->isPostRequest) + { + // we only allow deletion via POST request + $this->loadModel($id)->delete(); + + // if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser + if(!isset($_GET['ajax'])) + $this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('admin')); + } + else + throw new CHttpException(400,'Invalid request. Please do not repeat this request again.'); + } + + /** + * Lists all models. + */ + public function actionIndex() + { + $model=new Verein('search'); + $model->unsetAttributes(); // clear any default values + if(isset($_GET['Verein'])) + $model->attributes=$_GET['Verein']; + + $this->render('index',array( + 'model'=>$model, + )); + } + + /** + * Returns the data model based on the primary key given in the GET variable. + * If the data model is not found, an HTTP exception will be raised. + * @param integer the ID of the model to be loaded + */ + public function loadModel($id) + { + $model=Verein::model()->findByPk($id); + if($model===null) + throw new CHttpException(404,'The requested page does not exist.'); + return $model; + } + + /** + * Performs the AJAX validation. + * @param CModel the model to be validated + */ + protected function performAjaxValidation($model) + { + if(isset($_POST['ajax']) && $_POST['ajax']==='verein-form') + { + echo CActiveForm::validate($model); + Yii::app()->end(); + } + } +} |
