Skip to content
This repository has been archived by the owner on Apr 4, 2022. It is now read-only.

Commit

Permalink
v0.3.15
Browse files Browse the repository at this point in the history
  • Loading branch information
lesha724 committed Dec 25, 2019
1 parent 1412f12 commit 891438d
Show file tree
Hide file tree
Showing 10 changed files with 349 additions and 13 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
_v0.3.15_ - Декабрь 25, 2019
------------------------

- Добавление в потрфолио для фарма.

_v0.3.14_ - Декабрь 19, 2019
------------------------

Expand Down
2 changes: 1 addition & 1 deletion index.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
mb_internal_encoding("UTF-8");
ini_set('expose_php', 'Off');

define('ASU_PORTAL_VERSION', '0.3.14');
define('ASU_PORTAL_VERSION', '0.3.15');

// Debug is on when remote address is localhost
defined('YII_DEBUG') or $_SERVER['REMOTE_ADDR'] === '127.0.0.1' and define('YII_DEBUG', true);
Expand Down
80 changes: 79 additions & 1 deletion protected/controllers/PortfolioFarmController.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ public function accessRules() {
'addStpeduwork',
'updateStpeduwork',
'deleteStpeduwork',
'print'
'print',
'saveStpfwork'
),
'expression' => 'Yii::app()->user->isTch ||Yii::app()->user->isStd || Yii::app()->user->isAdmin',
),
Expand All @@ -45,12 +46,32 @@ public function accessRules() {
),
'expression' => 'Yii::app()->user->isTch || Yii::app()->user->isAdmin',
),
array('allow',
'actions' => array(
'acceptEnter',
),
'expression' => 'Yii::app()->user->isStd',
),
array('deny',
'users' => array('*'),
),
);
}

/**
* @return bool
*/
public function beforeAction($action)
{
if (Yii::app()->user->isStd && empty(Yii::app()->user->model->u16))
{
if($action->id != 'acceptEnter')
$this->redirect(['acceptEnter']);

}
return parent::beforeAction($action);
}

/**
* Дополнительная проверка
* @param $filterChain
Expand All @@ -74,6 +95,26 @@ public function filterCheckPermission($filterChain)
$filterChain->run();
}

/**
* Согласие на обработку персональных данных
*/
public function actionAcceptEnter(){
if(!empty(Yii::app()->user->model->u16))
$this->redirect('index');

$model=new AcceptProgressDataForm(Yii::app()->user->model, '');
$model->unsetAttributes();

if(isset($_POST['AcceptProgressDataForm']))
{
$model->attributes=$_POST['AcceptProgressDataForm'];
if($model->save()) {
$this->redirect('index');
}
}
$this->render('acceptEnter',array('model'=>$model));
}

/**
* @param $id int
* @throws CException
Expand Down Expand Up @@ -201,6 +242,43 @@ private function _checkPermission($st1){
return false;
}

/**
* дизменение stpfwork
* @throws CException
* @throws CHttpException
*/
public function actionSaveStpfwork(){
if (!Yii::app()->request->isAjaxRequest)
throw new CHttpException(405, 'Invalid request. Please do not repeat this request again.');

$st1 = Yii::app()->request->getParam('st1', null);
$field = Yii::app()->request->getParam('field', null);
$value = Yii::app()->request->getParam('value', null);

if(empty($field) || empty($st1))
throw new CHttpException(400, tt('Не все данные переданны'));

if($value === null)
throw new CHttpException(400, tt('Введите значение'));

if(!in_array($field, ['stpfwork2', 'stpfwork3']))
throw new CHttpException(400, tt('Неверные входящие данные'));

if(!$this->_checkPermission($st1))
throw new CHttpException(403, tt('Нет доступа к данному студенту'));

$student = St::model()->findByPk($st1);
$model = $student->getStpfwork();

$p = new CHtmlPurifier();
$model->$field = $p->purify($value);

if(!$model->save())
throw new CHttpException(500, tt('Ошибка сохранения'));

Yii::app()->end(CJSON::encode(array('error' => false)));
}

/**
* удаление поля
* @param $id
Expand Down
64 changes: 64 additions & 0 deletions protected/forms/AcceptProgressDataForm.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?php

/**
* Форма согласия на обработку персональных данных
* Class AcceptProgressDataForm
*/
class AcceptProgressDataForm extends CFormModel
{
/**
* @var boolean
*/
public $accept;

/**
* @var Users
*/
protected $_user;

/**
* AcceptProgressDataForm constructor.
* @param $user Users
* @param string $scenario
*/
public function __construct($user, $scenario = '')
{
parent::__construct($scenario);
$this->_user = $user;
}

/**
* Declares the validation rules.
*/
public function rules()
{
return array(
array('accept', 'boolean','allowEmpty'=>false, 'message' => tt('Вы должны дать согласие на обработку ваших персональных данных')),
array('accept','compare','compareValue'=>true, 'message' => tt('Вы должны дать согласие на обработку ваших персональных данных')),
);
}

/**
* @return array
*/
public function attributeLabels()
{
return [
'accept' => tt('Я даю согласие на обработку моих персональных данных')
];
}

/**
* Сохрарение
* @return bool
* @throws CDbException
*/
public function save(){
if(!$this->validate())
return false;

return $this->_user->saveAttributes([
'u16' => date('Y-m-d H:i:s')
]);
}
}
15 changes: 15 additions & 0 deletions protected/models/St.php
Original file line number Diff line number Diff line change
Expand Up @@ -1345,4 +1345,19 @@ public function getSredniyBall(){
$command->bindValue(':st1_', $this->st1);
return $command->queryScalar();
}

/**
* Данные о будущем трудоустройестве для портфолио фарма
* @return Stpfwork
*/
public function getStpfwork(){
$model = Stpfwork::model()->findByPk($this->st1);
if(empty($model)) {
$model = new Stpfwork();
$model->stpfwork1 = $this->st1;
$model->stpfwork2 = $model->stpfwork3 = '';
}

return $model;
}
}
6 changes: 2 additions & 4 deletions protected/models/Users.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
* @property string $u12
* @property string $u13
* @property string $u15
* @property string $u16
*
* @property bool isStudent
* @property bool isAdmin
Expand Down Expand Up @@ -57,14 +58,11 @@ public function rules()
array('u1, u5, u6, u7,u8', 'numerical', 'integerOnly'=>true),
array('u6', 'default', 'value'=>0, 'setOnEmpty'=>TRUE),
array('u10', 'default', 'value'=>'', 'setOnEmpty'=>TRUE),
//array('u2, u3','length', 'min' => 8,'max'=>30),
array('u3', 'match', 'pattern'=>'/^[a-zA-Z0-9-_\.,\/$|]{7,}$/','message'=>tt('В password могут быть только строчные и прописные латинские буквы, цифры, спецсимволы. Минимум 8 символов')),
array('u4', 'length', 'max'=>400),
array('u9, u10, u12', 'length', 'max'=>45),
array('u13', 'length', 'max'=>20),
array('u15', 'length', 'max'=>20),
array('u15, u13, u16', 'length', 'max'=>20),
array('u2, u4', 'checkIfUnique'),
//array('u2', 'length', 'min'=>5, 'max'=>30),
// Логин должен соответствовать шаблону
array('u2', 'match', 'pattern'=>'/^[a-zA-Z][a-zA-Z0-9-_.]{7,30}$/','message'=>tt('В login могут быть только латинские символы и цифры, а так же символы "." и "_", длиной от 8 до 30 символов. Также логин должен начинаться с латинской буквы')),
array('u2, u3, u4, password', 'required', 'on'=>'admin-create,admin-update'),
Expand Down
71 changes: 71 additions & 0 deletions protected/models/farm-portfolio/Stpfwork.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?php

/**
* This is the model class for table "stpfwork".
*
* The followings are the available columns in table 'stpfwork':
* @property integer $stpfwork1
* @property string $stpfwork2
* @property string $stpfwork3
*
* The followings are the available model relations:
* @property St $stpfwork10
*/
class Stpfwork extends CActiveRecord
{
/**
* @return string the associated database table name
*/
public function tableName()
{
return 'stpfwork';
}

/**
* @return array validation rules for model attributes.
*/
public function rules()
{
// NOTE: you should only define rules for those attributes that
// will receive user inputs.
return array(
array('stpfwork1', 'numerical', 'integerOnly'=>true),
array('stpfwork2, stpfwork3', 'length', 'max'=>400),
);
}

/**
* @return array relational rules.
*/
public function relations()
{
// NOTE: you may need to adjust the relation name and the related
// class name for the relations automatically generated below.
return array(
'stpfwork10' => array(self::BELONGS_TO, 'St', 'stpfwork1'),
);
}

/**
* @return array customized attribute labels (name=>label)
*/
public function attributeLabels()
{
return array(
'stpfwork1' => tt('Студент'),
'stpfwork2' => tt('Будущее место проведения интернатуры'),
'stpfwork3' => tt('Будущее место трудоустройства'),
);
}

/**
* Returns the static model of the specified AR class.
* Please note that you should have this exact method in all your CActiveRecord descendants!
* @param string $className active record class name.
* @return Stpfwork the static model class
*/
public static function model($className=__CLASS__)
{
return parent::model($className);
}
}
Loading

0 comments on commit 891438d

Please sign in to comment.