Дипломная работа: Автоматизация и обеспечение информационной безопасности процесса ведения документации и отчетности в компании ООО "Игровед-4"

Внимание! Если размещение файла нарушает Ваши авторские права, то обязательно сообщите нам
119
$dataProvider->query->andWhere (['id_folder' =>
$id_folder]);
return $this->render('index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
'folder' => $folder,
]);
}
/**
* Displays a single Document model.
* @param integer $id
* @return mixed
*/
public function actionView($id)
{
$model = $this->findModel($id);
$model->TestAccessByFlag('flag_view');
$folder = FolderController::findModel($model->id_folder);
return $this->render('view', [
'model' => $model,
'folder' => $folder,
]);
}
/**
* Creates a new Document model.
120
* If creation is successful, the browser will be redirected to the 'view'
page.
* @return mixed
*/
public function actionCreate($id_folder)
{
$folder = FolderController::findModel($id_folder);
$model = new Document();
if ($model->load(Yii::$app->request->post()) && $model->save()) {
$model->registration_date = date('Y-m-d h:i:s');
$model->id_user = Yii::$app->user->identity->id;
$model->save();
return $this->redirect(['view', 'id' => $model->id]);
} else {
$model->id_document_status = 1;
$model->id_folder = $folder->id;
return $this->render('create', [
'model' => $model,
'folder' => $folder,
]);
}
}
/**
* Updates an existing Document model.
* If update is successful, the browser will be redirected to the 'view'
page.
* @param integer $id
* @return mixed
121
*/
public function actionUpdate($id)
{
$model = $this->findModel($id);
$model->TestAccessByFlag('flag_edit');
$folder = FolderController::findModel($model->id_folder);
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id]);
} else {
return $this->render('update', [
'model' => $model,
'folder' => $folder,
]);
}
}
/**
* Deletes an existing Document model.
* If deletion is successful, the browser will be redirected to the 'index'
page.
* @param integer $id
* @return mixed
*/
public function actionDelete($id)
{
$model = $this->findModel($id);
$model->TestAccessByFlag('flag_delete');
$folder = FolderController::findModel($model->id_folder);
$model->delete();
return $this->redirect(['index', 'id_folder' => $folder->id]);
122
}
/**
* Finds the Document model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown.
* @param integer $id
* @return Document the loaded model
* @throws NotFoundHttpException if the model cannot be found
*/
public static function findModel($id)
{
if (($model = Document::findOne($id)) !== null) {
return $model;
} else {
throw new NotFoundHttpException('The requested page does not
exist.');
}
}
}
<?php
namespace app\controllers;
use Yii;
use app\models\Folder;
use app\models\FolderSearch;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
use yii\filters\AccessControl;
123
/**
* FolderController implements the CRUD actions for Folder model.
*/
class FolderController extends Controller
{
/**
* @inheritdoc
*/
public function behaviors()
{
return [
'access' => [
'class' => AccessControl::className(),
'rules' =>
[
[
'actions' => ['index', 'view', 'create',
'update', 'delete'],
'allow' => true,
'roles' => ['@'],
],
],
],
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'delete' => ['POST'],
Источник: https://baza.diplomsite.ru/previewfile/1794