diff --git a/www/css/styles.css b/www/css/styles.css index bbb11a8..fc6b002 100644 --- a/www/css/styles.css +++ b/www/css/styles.css @@ -264,6 +264,13 @@ ul.nav li.dropdown-append:hover > ul.dropdown-menu { position: absolute; } +.collHeaderPseudoLink { + color: #2C3E50; +} + +.collHeaderStroked { + text-decoration: line-through; +} /* FullProgPreview -------------------------------------------------- */ diff --git a/www/protected/components/widgets/BlogLink.php b/www/protected/components/widgets/BlogLink.php index 9032261..c534bce 100644 --- a/www/protected/components/widgets/BlogLink.php +++ b/www/protected/components/widgets/BlogLink.php @@ -4,6 +4,7 @@ class BlogLink extends CWidget { public $date; public $caption = ''; public $link = ''; + public $stroked = false; public function run() { if ($this->date == null) diff --git a/www/protected/components/widgets/views/blogLink.php b/www/protected/components/widgets/views/blogLink.php index 9d1420a..a2f2a38 100644 --- a/www/protected/components/widgets/views/blogLink.php +++ b/www/protected/components/widgets/views/blogLink.php @@ -4,7 +4,7 @@
date->format('d.m.Y'); ?>
-
caption; ?>
+
caption; ?>
 
\ No newline at end of file diff --git a/www/protected/controllers/ApiController.php b/www/protected/controllers/ApiController.php index cef6c40..3ccfb82 100644 --- a/www/protected/controllers/ApiController.php +++ b/www/protected/controllers/ApiController.php @@ -42,11 +42,14 @@ class APIController extends MSController public function actionUpdate2($Name) { + if (! isset($_GET['Name'])) { + throw new CHttpException(404,'Invalid Request - [Name] missing'); + } + $data = ProgramUpdates::model()->findByAttributes(['Name' => $Name]); - if (! isset($_GET['Name'])) { + if (is_null($data)) { throw new CHttpException(404,'Invalid Request - [Name] not found'); - return; } $this->render('update', ['data' => $data]); diff --git a/www/protected/controllers/BlogpostController.php b/www/protected/controllers/BlogpostController.php index d833ec8..6ca3cd3 100644 --- a/www/protected/controllers/BlogpostController.php +++ b/www/protected/controllers/BlogpostController.php @@ -43,12 +43,19 @@ class BlogPostController extends MSController /** * Displays a particular model. * @param integer $id the ID of the model to be displayed + * @throws CHttpException if Enabled is false */ public function actionView($id) { - $this->render('view',array( - 'model'=>$this->loadModel($id), - )); + $model = $this->loadModel($id); + + if (! $model->Enabled && Yii::app()->user->name != 'admin') + throw new CHttpException(403, 'This Blogpost is locked'); + + $this->render('view', + [ + 'model' => $model, + ]); } /** @@ -128,6 +135,12 @@ class BlogPostController extends MSController $criteria = new CDbCriteria; $criteria->order = "Date DESC"; + if (Yii::app()->user->name != 'admin') + { + $criteria->addCondition('Visible = 1'); + $criteria->addCondition('Enabled = 1'); + } + $all = BlogPost::model()->findAll($criteria); $this->render('index', diff --git a/www/protected/models/BlogPost.php b/www/protected/models/BlogPost.php index c26012f..d8091d6 100644 --- a/www/protected/models/BlogPost.php +++ b/www/protected/models/BlogPost.php @@ -8,6 +8,8 @@ * @property string $Date * @property string $Title * @property string $Content + * @property string $Visible + * @property string $Enabled */ class BlogPost extends CActiveRecord { @@ -27,10 +29,10 @@ class BlogPost extends CActiveRecord // NOTE: you should only define rules for those attributes that // will receive user inputs. return array( - array('Date, Title, Content', 'required'), - // The following rule is used by search(). - // @todo Please remove those attributes that should not be searched. - array('ID, Date, Title, Content', 'safe', 'on'=>'search'), + array('Date, Title, Content, Visible, Enabled', 'required'), + array('Visible, Enabled', 'numerical', 'integerOnly'=>true), + + array('ID, Date, Title, Content, Visible, Enabled', 'safe', 'on'=>'search'), ); } @@ -55,6 +57,8 @@ class BlogPost extends CActiveRecord 'Date' => 'Date', 'Title' => 'Title', 'Content' => 'Content', + 'Visible' => 'Visible', + 'Enabled' => 'Enabled', ); } @@ -72,14 +76,14 @@ class BlogPost extends CActiveRecord */ public function search() { - // @todo Please modify the following code to remove attributes that should not be searched. - $criteria=new CDbCriteria; $criteria->compare('ID',$this->ID); $criteria->compare('Date',$this->Date,true); $criteria->compare('Title',$this->Title,true); $criteria->compare('Content',$this->Content,true); + $criteria->compare('Visible',$this->Visible,true); + $criteria->compare('Enabled',$this->Enabled,true); return new CActiveDataProvider($this, array( 'criteria'=>$criteria, diff --git a/www/protected/views/blogpost/_form.php b/www/protected/views/blogpost/_form.php index 94859a6..01faf87 100644 --- a/www/protected/views/blogpost/_form.php +++ b/www/protected/views/blogpost/_form.php @@ -30,6 +30,20 @@ textAreaControlGroup($model,'Content',array('rows'=>30,'span'=>8)); ?> + isNewRecord) + echo $form->textFieldControlGroup($model,'Visible',array('span'=>5, 'value' => '1')); + else + echo $form->textFieldControlGroup($model,'Visible',array('span'=>5, )); + ?> + + isNewRecord) + echo $form->textFieldControlGroup($model,'Enabled',array('span'=>5, 'value' => '1')); + else + echo $form->textFieldControlGroup($model,'Enabled',array('span'=>5, )); + ?> + 'POST', diff --git a/www/protected/views/blogpost/_search.php b/www/protected/views/blogpost/_search.php index e4119e3..2e415df 100644 --- a/www/protected/views/blogpost/_search.php +++ b/www/protected/views/blogpost/_search.php @@ -17,7 +17,12 @@ textAreaControlGroup($model,'Content',array('rows'=>6,'span'=>8)); ?> -
+ textFieldControlGroup($model,'Visible',array('span'=>5)); ?> + + textFieldControlGroup($model,'Enabled',array('span'=>5)); ?> + + +
TbHtml::BUTTON_COLOR_PRIMARY,));?>
diff --git a/www/protected/views/blogpost/_view.php b/www/protected/views/blogpost/_view.php index c6f5d75..d46e429 100644 --- a/www/protected/views/blogpost/_view.php +++ b/www/protected/views/blogpost/_view.php @@ -21,5 +21,13 @@ Content); ?>
+ getAttributeLabel('Visible')); ?>: + Visible); ?> +
+ + getAttributeLabel('Enabled')); ?>: + Enabled); ?> +
+
\ No newline at end of file diff --git a/www/protected/views/blogpost/index.php b/www/protected/views/blogpost/index.php index 36ebb6f..e093b65 100644 --- a/www/protected/views/blogpost/index.php +++ b/www/protected/views/blogpost/index.php @@ -29,6 +29,7 @@ $this->selectedNav = 'blog'; 'date' => new DateTime($blogpost->Date), 'caption' => $blogpost->Title, 'link' => $blogpost->getLink(), + 'stroked' => !($blogpost->Enabled && $blogpost->Visible), ]); } ?>