public function import(CFormModel $source)
 {
     $data = $source->getData();
     $markIds = array();
     $isFirstRow = true;
     foreach ($data as $row) {
         if ($isFirstRow) {
             // это первая строка - в не идентификаторы оценок
             $isFirstRow = false;
             $markIds = $row;
         } else {
             // это все остальные строки - здесь уже студенты
             $student = CStaffManager::getStudent($row[0]);
             if (!is_null($student)) {
                 $isFirstCol = true;
                 foreach ($row as $id => $cell) {
                     if (!$isFirstCol) {
                         if ($cell != "") {
                             // если не пустая, то берем дисциплину
                             $subjectId = $markIds[$id];
                             $subject = CTaxonomyManager::getDiscipline($subjectId);
                             if (!is_null($subject)) {
                                 // если дисциплина есть, то происходит маппинг оценок
                                 $marks = array("2" => "4", "3" => "3", "4" => "2", "5" => "1");
                                 // создаем запись об оценке
                                 $activity = new CStudentActivity();
                                 $activity->subject_id = $subject->getId();
                                 $activity->kadri_id = $source->person;
                                 $activity->student_id = $student->getId();
                                 $activity->date_act = date("Y-m-d", strtotime($source->created));
                                 if (mb_strlen($cell) == 2 || strlen($cell) == 2) {
                                     // это курсовой
                                     $cell = mb_substr($cell, 0, 1);
                                     $activity->study_act_id = 43;
                                     if (array_key_exists($cell, $marks)) {
                                         $activity->study_mark = $marks[$cell];
                                     }
                                 } elseif (array_key_exists($cell, $marks)) {
                                     // это экзамен
                                     $activity->study_act_id = 1;
                                     $activity->study_mark = $marks[$cell];
                                 } else {
                                     // это зачет
                                     $activity->study_act_id = 2;
                                     $activity->study_mark = 5;
                                 }
                                 $activity->save();
                             }
                         }
                     } else {
                         // пропускаем первую ячейку - в ней идентификатор студента
                         $isFirstCol = false;
                     }
                 }
             }
         }
     }
     return true;
 }
Пример #2
0
 /**
  * Sends out an email containing instructions and link to the email verification
  * or password recovery page, containing an activation key.
  * @param CFormModel $model it must have a getIdentity() method
  * @param strign $mode 'recovery', 'verify' or 'oneTimePassword'
  * @return boolean if sending the email succeeded
  */
 public function sendEmail(CFormModel $model, $mode)
 {
     $mail = $this->module->mailer;
     $mail->AddAddress($model->getIdentity()->getEmail(), $model->getIdentity()->getName());
     $params = array('siteUrl' => $this->createAbsoluteUrl('/'), 'usuario' => $model->getIdentity()->usuario, 'correo' => $model->getIdentity()->correo);
     switch ($mode) {
         default:
             return false;
         case 'recovery':
         case 'verify':
             $mail->Subject = $mode == 'recovery' ? Yii::t('UsrModule.usr', 'Recuperar la contraseña') : Yii::t('UsrModule.usr', 'Verificación de la dirección de correo electrónico');
             $params['actionUrl'] = $this->createAbsoluteUrl('default/' . $mode, array('llave_activacion' => $model->getIdentity()->getActivationKey(), 'usuario' => $model->getIdentity()->getName()));
             break;
         case 'oneTimePassword':
             $mail->Subject = Yii::t('UsrModule.usr', 'One Time Password');
             $params['code'] = $model->getNewCode();
             break;
     }
     $body = $this->renderPartial($mail->getPathViews() . '.' . $mode, $params, true);
     $full = $this->renderPartial($mail->getPathLayouts() . '.email', array('content' => $body), true);
     $mail->MsgHTML($full);
     if ($mail->Send()) {
         return true;
     } else {
         Yii::log($mail->ErrorInfo, 'error');
         return false;
     }
 }
Пример #3
0
 /**
  * Validation rules
  *
  * @see CModel::rules()
  *
  * @return array
  */
 public function rules()
 {
     $rules = parent::rules();
     $rules[] = array('email', 'email');
     $rules[] = array('email', 'unique');
     return $rules;
 }
Пример #4
0
 public function init()
 {
     $this->folderFiles = Yii::app()->getModule('exchange1c')->folderFiles;
     $this->readFileProducts = Yii::app()->getModule('exchange1c')->readFileProducts;
     $this->readFileCategory = Yii::app()->getModule('exchange1c')->readFileCategory;
     return parent::init();
 }
Пример #5
0
 public function init()
 {
     parent::init();
     $this->GAD_728x90 = SiteVariable::model()->findByPk('GAD_728x90')->value;
     $this->GAD_336x280 = SiteVariable::model()->findByPk('GAD_336x280')->value;
     $this->GAD_728x15 = SiteVariable::model()->findByPk('GAD_728x15')->value;
 }
Пример #6
0
 /**
  * Renders form properties utilizing the appropriate
  * @param  CActiveForm   $form     The form we're working with
  * @param  Property Name $property The property name from Reflection
  */
 private function renderProperties(&$form, $property)
 {
     $htmlOptions = array('class' => 'pure-input-2-3');
     $validators = $this->model->getValidators($property->name);
     $stringValidators = $this->model->getStringValidator($property->name, $validators);
     if (in_array('required', $stringValidators)) {
         $htmlOptions['required'] = true;
     }
     echo CHtml::openTag('div', array('class' => 'pure-control-group'));
     if (in_array('boolean', $stringValidators)) {
         $form->toggleButtonRow($this->model, $property->name, $htmlOptions, $validators);
     } else {
         if (in_array('number', $stringValidators) && isset($validators[0]->max) && isset($validators[0]->min)) {
             $form->rangeFieldRow($this->model, $property->name, $htmlOptions, $validators);
         } else {
             if (in_array('number', $stringValidators) && (isset($validators[0]->max) || isset($validators[0]->min))) {
                 $form->numberFieldRow($this->model, $property->name, $htmlOptions, $validators);
             } else {
                 if (in_array('password', $stringValidators)) {
                     echo $form->passwordFieldRow($this->model, $property->name, $htmlOptions, $validators);
                 } else {
                     echo $form->textFieldRow($this->model, $property->name, $htmlOptions, $validators);
                 }
             }
         }
     }
     echo CHtml::closeTag('div');
 }
Пример #7
0
 public function __construct()
 {
     $this->object_id = isset($_REQUEST['object_id']) ? $_REQUEST['object_id'] : parent::addError("ObjectId", "Object ID should not be null");
     $this->benutzer_id = isset($_REQUEST['benutzer_id']) ? $_REQUEST['benutzer_id'] : parent::addError("benutzer_id", "User ID should not be null");
     $this->agentSine = Yii::app()->params['agentSine'];
     $this->agentDutyCode = Yii::app()->params['agentDutyCode'];
 }
Пример #8
0
 public function init() {
     if (file_exists(Yii::app()->basePath . '/data/version'))
         $this->_sversion = file_get_contents(Yii::app()->basePath . '/data/version');
     else
         $this->_sversion = "3.0";
     return parent::init();
 }
Пример #9
0
 public function init()
 {
     if (file_exists($this->getSavePath() . $this->fileName)) {
         $this->setAttributes(unserialize(file_get_contents($this->getSavePath() . $this->fileName)));
     }
     return parent::init();
 }
Пример #10
0
 public function beforeValidate()
 {
     if (parent::beforeValidate()) {
         return true;
     }
     return false;
 }
Пример #11
0
 /**
  * Validation rules
  *
  * @see CModel::rules()
  *
  * @return array
  */
 public function rules()
 {
     $rules = parent::rules();
     $rules[] = array('amount', 'in', 'range' => range(0, 10000));
     $rules[] = array('id_bank', 'safe');
     return $rules;
 }
Пример #12
0
 public function __set($name, $value)
 {
     if (isset($this->_data[$name])) {
         return $this->_data[$name] = $value;
     }
     parent::__set($name, $value);
 }
Пример #13
0
 public function init()
 {
     foreach ($this->getConfig() as $config) {
         $this->config[$config->key] = $config->value;
     }
     parent::init();
 }
Пример #14
0
 public function beforeValidate()
 {
     if (parent::beforeValidate()) {
         $cams = array_map('trim', explode(',', $this->hcams));
         $c = count($cams);
         foreach ($cams as $cam) {
             $this->camBuff[] = Cams::model()->findByPK(Cams::model()->getRealId($cam));
         }
         $this->camBuff = array_filter($this->camBuff);
         if (empty($this->camBuff) || count($this->camBuff) != $c) {
             $this->addError('cams', $c > 1 ? Yii::t('errors', 'One of cam is wrong') : Yii::t('errors', 'There is no such cam'));
             return false;
         }
         if (!is_array($this->emails)) {
             $emails = array_map('trim', explode(',', $this->emails));
         } else {
             $emails = array_map('trim', $this->emails);
         }
         $c = count($emails);
         $this->emailBuff = Users::model()->findAllByAttributes(array('email' => $emails));
         if (empty($this->emailBuff) || count($this->emailBuff) != $c) {
             $this->addError('emails', $c > 1 ? Yii::t('errors', 'One of user is wrong') : Yii::t('errors', 'There is no such user'));
             return false;
         }
         return true;
     }
     return false;
 }
Пример #15
0
 public function __get($name)
 {
     if (Yii::app()->user->data->hasAttribute($name)) {
         return Yii::app()->user->data->{$name};
     }
     return parent::__get($name);
 }
Пример #16
0
 public function __construct($scenario = '', $rec_id = null, $user_id = null, $slotid = null)
 {
     parent::__construct($scenario);
     $this->_recId = $rec_id;
     $this->_userId = $user_id;
     $this->_slotId = $slotid;
 }
Пример #17
0
 protected function beforeValidate()
 {
     $this->message = strip_tags($this->message);
     $this->name = strip_tags($this->name);
     $this->telephone = strip_tags($this->telephone);
     return parent::beforeValidate();
 }
 /**
  * Override to handle use case of $name == 'id'.
  * As this form does not have an 'id', it will return null;
  * @see ModelElement.  This form is used by ModelElement for example
  * and ModelElement expects the model to have an 'id' value.
  */
 public function __get($name)
 {
     if ($name == 'id') {
         return null;
     }
     return parent::__get($name);
 }
Пример #19
0
 public function afterValidate()
 {
     if (!$this->hasErrors()) {
         $path = Yii::getPathOfAlias('webroot') . '/../uploads/in/images/' . $this->image;
         $pathStore = Yii::getPathOfAlias('webroot') . '/uploads/store/product/' . $this->image;
         if (file_exists($path)) {
             // Файл доступен по пути
             $data = @file_get_contents($path);
             $res = @imagecreatefromstring($data);
             if (is_resource($res)) {
                 // Файл коректно открывается
                 if (copy($path, $pathStore)) {
                     // Файл скопировался
                     $this->image = basename($path);
                     @unlink($path);
                     // удалить файл
                 } else {
                     $this->image = null;
                 }
             }
         } else {
             $this->image = null;
         }
     }
     return parent::afterValidate();
 }
Пример #20
0
 /**
  * Метод выполняется перед валидацией
  *
  * @return bool
  */
 public function beforeValidate()
 {
     $module = Yii::app()->getModule('user');
     if ($module->generateNickName) {
         $this->nick_name = 'user' . time();
     }
     return parent::beforeValidate();
 }
Пример #21
0
 /**
  * @inheritdoc
  *
  * Additionally, tracks attached behaviors to allow iterating over them.
  */
 public function detachBehavior($name)
 {
     if (isset($this->_behaviors[$name])) {
         unset($this->_behaviors[$name]);
     }
     unset(self::$_names[get_class($this)]);
     return parent::detachBehavior($name);
 }
Пример #22
0
 /**
  * __set 
  * 
  * @param mixed $name 
  * @param mixed $val 
  * @access public
  * @return void
  */
 public function __set($name, $val)
 {
     if (!empty($this->_dynamicFields[$name])) {
         $this->_dynamicData[$name] = $val;
     } else {
         parent::__set($name, $val);
     }
 }
Пример #23
0
 public function beforeValidate()
 {
     if (parent::beforeValidate()) {
         $this->username = strtolower($this->username);
         return true;
     }
     return false;
 }
Пример #24
0
 public function __construct($model = null)
 {
     parent::__construct();
     if ($model != null) {
         $this->login = $model->login;
         $this->name = $model->nome;
     }
 }
Пример #25
0
 public function validate()
 {
     $year = Yii::app()->dateFormatter->format("yyyy", $ths->date);
     if (!($year >= 1900 && $year <= 2050)) {
         $this->addError('date', 'Данный год не поддерживается системой');
     }
     return parent::validate();
 }
Пример #26
0
 public function validate()
 {
     if (!$this->result->getStatus()) {
         $this->addErrors(array('social_response_error' => $this->result->getResult()));
         return false;
     }
     return parent::validate();
 }
Пример #27
0
 /**
  * Displays errors whether its present.
  * 
  * @see CModel::afterValidate()
  */
 protected function afterValidate()
 {
     if ($this->hasErrors()) {
         $errors = $this->getErrors();
         $this->displayErrors($errors);
     }
     parent::afterValidate();
 }
Пример #28
0
 public function init()
 {
     $yiidatetimesec = Yii::app()->locale->getDateFormat('yiidatetimesec');
     $phpdatetime = Yii::app()->locale->getDateFormat('phpdatetimes');
     $this->from_date = date($phpdatetime, CDateTimeParser::parse('01/01/' . date('Y') . ' 00:00:00', $yiidatetimesec));
     $this->to_date = date($phpdatetime);
     return parent::init();
 }
Пример #29
0
 public function validate($attributes = null, $clearErrors = true)
 {
     $valid = parent::validate($attributes, $clearErrors);
     if (!$valid && $this->throwExceptions) {
         throw new $exceptionClass(400, CJSON::encode($this->getErrors()));
     }
     return $valid;
 }
Пример #30
0
 public function attributeNames()
 {
     $return = parent::attributeNames();
     foreach (array_keys($this->_data) as $name) {
         $return[] = $name;
     }
     return $return;
 }