1
0

Added Visible & Enabled to BlogPost

This commit is contained in:
2014-09-13 17:37:47 +02:00
parent 5c940826de
commit ff5ecbc144
10 changed files with 69 additions and 13 deletions

View File

@@ -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]);

View File

@@ -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',