From a037c1c65d45a785b8c547e8a94ef9819ae3d516 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20Schw=C3=B6rer?= Date: Mon, 16 Jun 2014 19:00:20 +0200 Subject: [PATCH] Added Managing and viewing of ProgramUpdates --- .idea/workspace.xml | 455 ++++++++---------- www/protected/config/main.php | 2 + .../controllers/ProgramUpdatesController.php | 127 +++++ www/protected/models/ProgramUpdates.php | 2 +- www/protected/views/msmain/admin.php | 10 +- www/protected/views/programupdates/_form.php | 37 ++ .../views/programupdates/_search.php | 26 + www/protected/views/programupdates/_view.php | 21 + www/protected/views/programupdates/admin.php | 57 +++ www/protected/views/programupdates/create.php | 20 + www/protected/views/programupdates/index.php | 33 ++ www/protected/views/programupdates/update.php | 23 + www/protected/views/programupdates/view.php | 67 +++ 13 files changed, 607 insertions(+), 273 deletions(-) create mode 100644 www/protected/controllers/ProgramUpdatesController.php create mode 100644 www/protected/views/programupdates/_form.php create mode 100644 www/protected/views/programupdates/_search.php create mode 100644 www/protected/views/programupdates/_view.php create mode 100644 www/protected/views/programupdates/admin.php create mode 100644 www/protected/views/programupdates/create.php create mode 100644 www/protected/views/programupdates/index.php create mode 100644 www/protected/views/programupdates/update.php create mode 100644 www/protected/views/programupdates/view.php diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 8efff53..6cac178 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -4,11 +4,11 @@ - - - + + + @@ -66,16 +66,16 @@ - + - + - + @@ -84,7 +84,7 @@ - + @@ -93,7 +93,34 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -112,9 +139,6 @@ @@ -259,6 +286,20 @@ + + + + + + + + + + @@ -309,6 +350,32 @@ + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -435,28 +446,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -739,7 +688,7 @@ - + @@ -747,12 +696,12 @@ - + - + @@ -780,48 +729,11 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -852,11 +764,6 @@ - - - - - @@ -889,74 +796,52 @@ - - - + - - - + - - - + - - - + - - - + - - - + - - - + - - - - - + - - - + - - - + @@ -966,13 +851,6 @@ - - - - - - - @@ -982,30 +860,22 @@ - - - + - - - + - - - + - - - + @@ -1024,77 +894,128 @@ - - - - - - - - - - + - - - + - - - + - - - + - - - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/www/protected/config/main.php b/www/protected/config/main.php index 88d8f26..f5ccedc 100644 --- a/www/protected/config/main.php +++ b/www/protected/config/main.php @@ -72,6 +72,8 @@ return ArrayX::merge( 'log/' => ['log/index', 'defaultParams' => ['logid' => '-1']], 'log/' => ['log/index', 'defaultParams' => ['logid' => '-1']], + 'programupdates/' => 'programupdates/index', + 'downloads/details.php' => 'programs/index', // Compatibility 'downloads/downloads.php' => 'programs/index', // Compatibility 'downloads/' => 'programs/view', // Compatibility diff --git a/www/protected/controllers/ProgramUpdatesController.php b/www/protected/controllers/ProgramUpdatesController.php new file mode 100644 index 0000000..a577955 --- /dev/null +++ b/www/protected/controllers/ProgramUpdatesController.php @@ -0,0 +1,127 @@ +array('index','view','create','update','admin','delete'), + 'users'=>array('admin'), + ), + array('deny', // deny all users + 'users'=>array('*'), + ), + ); + } + + public function actionView($id) + { + $this->render('view',array( + 'model'=>$this->loadModel($id), + )); + } + + public function actionCreate() + { + $model=new ProgramUpdates; + + // Uncomment the following line if AJAX validation is needed + // $this->performAjaxValidation($model); + + if (isset($_POST['ProgramUpdates'])) { + $model->attributes=$_POST['ProgramUpdates']; + if ($model->save()) { + $this->redirect(array('view','id'=>$model->Name)); + } + } + + $this->render('create',array( + 'model'=>$model, + )); + } + + public function actionUpdate($id) + { + $model=$this->loadModel($id); + + // Uncomment the following line if AJAX validation is needed + // $this->performAjaxValidation($model); + + if (isset($_POST['ProgramUpdates'])) { + $model->attributes=$_POST['ProgramUpdates']; + if ($model->save()) { + $this->redirect(array('view','id'=>$model->Name)); + } + } + + $this->render('update',array( + 'model'=>$model, + )); + } + + 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.'); + } + } + + public function actionIndex() + { + $dataProvider=new CActiveDataProvider('ProgramUpdates'); + $this->render('index',array( + 'dataProvider'=>$dataProvider, + )); + } + + public function actionAdmin() + { + $model=new ProgramUpdates('search'); + $model->unsetAttributes(); // clear any default values + if (isset($_GET['ProgramUpdates'])) { + $model->attributes=$_GET['ProgramUpdates']; + } + + $this->render('admin',array( + 'model'=>$model, + )); + } + + public function loadModel($id) + { + $model=ProgramUpdates::model()->findByPk($id); + if ($model===null) { + throw new CHttpException(404,'The requested page does not exist.'); + } + return $model; + } + + protected function performAjaxValidation($model) + { + if (isset($_POST['ajax']) && $_POST['ajax']==='program-updates-form') { + echo CActiveForm::validate($model); + Yii::app()->end(); + } + } +} \ No newline at end of file diff --git a/www/protected/models/ProgramUpdates.php b/www/protected/models/ProgramUpdates.php index 329beda..36f035b 100644 --- a/www/protected/models/ProgramUpdates.php +++ b/www/protected/models/ProgramUpdates.php @@ -8,7 +8,7 @@ * @property string $Version * @property string $Link * - * @property ProgramUpdatesLog $log + * @property ProgramUpdatesLog[] $log */ class ProgramUpdates extends CActiveRecord { diff --git a/www/protected/views/msmain/admin.php b/www/protected/views/msmain/admin.php index 29c0fdd..4eda1e6 100644 --- a/www/protected/views/msmain/admin.php +++ b/www/protected/views/msmain/admin.php @@ -42,15 +42,15 @@ $this->breadcrumbs = ); ?> -