Exemplo n.º 1
0
 protected function afterSave()
 {
     if (parent::afterSave()) {
         //die($this->id);
         //return $this->id;
     }
 }
Exemplo n.º 2
0
 public function afterSave()
 {
     if (!$this->isNewRecord) {
         Syslog::add(Logs::LOG_EDITED, 'Изменен комментарий к бану № <strong>' . $this->bid . '</strong>, написанный пользователем <strong>' . $this->name . '</strong>');
     }
     return parent::afterSave();
 }
Exemplo n.º 3
0
 protected function afterSave()
 {
     parent::afterSave();
     $this->validateServerFile('serverFile', null);
     require_once 'Image.php';
     // 保存图片
     if ($this->hasErrors('serverFile') == false && $this->serverFile instanceof CUploadedFile) {
         // 保存原图
         $file = $this->serverFile;
         $fileName = md5($file->tempName . uniqid()) . '.' . $file->extensionName;
         $filePath = Helper::mediaPath(Server::UPLOAD_ORIGINAL_FILE_PATH . $fileName, FRONTEND);
         $file->saveAs($filePath);
         // 如果是图片需要进行裁切
         if (strtolower($file->extensionName) != 'swf') {
             // 裁切大图
             // 位置不同图片尺寸不同
             $image = new Image($filePath);
             $image->resize(350, 230)->save(Helper::mediaPath(Server::UPLOAD_THUMBNAIL_IMAGE_PATH . $fileName, FRONTEND));
         }
         // 更新数据
         $this->updateByPk($this->primaryKey, array('image_path' => $fileName));
     } else {
         if ($this->deleteServerFile) {
             // 删除图片
             @unlink(Helper::mediaPath(Server::UPLOAD_ORIGINAL_FILE_PATH . $this->image_path, FRONTEND));
             @unlink(Helper::mediaPath(Server::UPLOAD_THUMBNAIL_IMAGE_PATH . $this->image_path, FRONTEND));
             // 更新数据
             $this->updateByPk($this->primaryKey, array('image_path' => ''));
         }
     }
 }
Exemplo n.º 4
0
 protected function afterSave()
 {
     parent::afterSave();
     $images = CUploadedFile::getInstances($this, 'images');
     if (isset($images) && count($images) > 0) {
         foreach ($images as $k => $img) {
             $imageName = md5(microtime()) . '.jpg';
             if ($img->saveAs($this->getFolder() . $imageName)) {
                 $advImg = new Image();
                 $advImg->goods_id = $this->getPrimaryKey();
                 $advImg->image = $imageName;
                 $advImg->save();
             }
         }
     }
     if ($this->isNewRecord) {
         $count = new Count();
         $count->goods_id = $this->id;
         $count->count = $this->count;
         $count->size = $this->size;
         $count->color = $this->color;
         $count->save();
     } else {
         Count::model()->updateAll(array('goods_id' => $this->id, 'count' => $this->count, 'size' => $this->size, 'color' => $this->color), 'goods_id=:goods_id', array(':goods_id' => $this->id));
     }
 }
Exemplo n.º 5
0
 /**
  * Notify everyone that was @mentioned in this share by email that they were mentioned
  */
 public function afterSave()
 {
     preg_match_all('/@([A-Za-z0-9\\/\\.]*)/', $this->text, $matches);
     $mentions = implode(',', $matches[1]);
     if (!empty($matches[1])) {
         /*			$criteria = new CDbCriteria;
         			$criteria->addInCondition('username', $matches[1]);
         			$users = User::model()->findAll($criteria);
         
         			foreach ($users as $user)
         			{
         				$sendgrid = new SendGrid(Yii::app()->params['includes']['sendgrid']['username'], Yii::app()->params['includes']['sendgrid']['password']);
         				$email    = new SendGrid\Email();
         
         				$email->setFrom(Yii::app()->params['includes']['sendgrid']['from'])
         					->addTo($user->email)
         					->setSubject("You've Been @mentioned!")
         					->setText("You've Been @mentioned!")
         					->setHtml(Yii::app()->controller->renderPartial('//email/mention', array('share' => $this, 'user' => $user), true));
         
         				// Send the email
         				$sendgrid->send($email);
         			}*/
     }
     return parent::afterSave();
 }
Exemplo n.º 6
0
 protected function afterSave()
 {
     parent::afterSave();
     $this->validateBannerFile('bannerFile', null);
     require_once 'Image.php';
     // 保存图片
     if ($this->hasErrors('bannerFile') == false && $this->bannerFile instanceof CUploadedFile) {
         // 保存原图
         $file = $this->bannerFile;
         $fileName = md5($file->tempName . uniqid()) . '.' . $file->extensionName;
         $filePath = Helper::mediaPath(Banner::UPLOAD_LARGE_IMAGE_PATH . $fileName, FRONTEND);
         $file->saveAs($filePath);
         // 如果是图片需要进行裁切
         // 右侧底图
         if (strtolower($file->extensionName) != 'swf') {
             $image = new Image($filePath);
             $image->save(Helper::mediaPath(Banner::UPLOAD_LARGE_IMAGE_PATH . $fileName, FRONTEND));
         }
         // 更新数据
         $this->updateByPk($this->primaryKey, array('banner_path' => $fileName));
     } else {
         if ($this->deleteBannerFile) {
             @unlink(Helper::mediaPath(Banner::UPLOAD_LARGE_IMAGE_PATH . $this->banner_path, FRONTEND));
             // 更新数据
             $this->updateByPk($this->primaryKey, array('banner_path' => ''));
         }
     }
 }
Exemplo n.º 7
0
 public function afterSave()
 {
     if ($this->isNewRecord) {
         $this->created_date = new CDbExpression('NOW()');
     }
     parent::afterSave();
 }
Exemplo n.º 8
0
 public function afterSave()
 {
     if ($this->_newRecord) {
         Yii::app()->authManager->assign('Member', 'Member-' . $this->id);
     }
     return parent::afterSave();
 }
Exemplo n.º 9
0
 protected function afterSave()
 {
     parent::afterSave();
     if (!$this->textarea) {
         $this->info = $this->unparse($this->info);
     }
 }
Exemplo n.º 10
0
 public function AfterSave()
 {
     $this->refresh();
     if ($this->activo == '1') {
         $this->activacion($this->hcodimpuesto);
     }
     return parent::afterSave();
 }
Exemplo n.º 11
0
 public function afterSave()
 {
     $pk = (empty($this->primaryKey) or is_array($this->primaryKey)) ? 'id' : $this->primaryKey;
     if (isset($this->{$pk}) and empty($this->{$pk})) {
         $this->{$pk} = Yii::app()->db->lastInsertID;
     }
     return parent::afterSave();
 }
Exemplo n.º 12
0
 public function afterSave()
 {
     if ($this->isNewRecord) {
         $this->created_date = new CDbExpression('NOW()');
         $this->core_user_id = Yii::app()->user->id;
     }
     parent::afterSave();
 }
Exemplo n.º 13
0
 public function afterSave()
 {
     /* insert default nodes */
     if ($this->isNewRecord) {
         Node::model()->insertDefaultNodes($this->id);
     }
     return parent::afterSave();
 }
Exemplo n.º 14
0
 public function afterSave()
 {
     parent::afterSave();
     if ($this->isNewRecord) {
         $this->book->n_chapters++;
         $this->book->save(false, array("n_chapters"));
     }
 }
Exemplo n.º 15
0
 public function afterSave()
 {
     if ($this->dateDBformat) {
         $this->dateDBformat = false;
         $this->date = date(Yii::app()->locale->getDateFormat('phpshort'), strtotime($this->date));
     }
     return parent::afterSave();
 }
Exemplo n.º 16
0
 public function afterSave()
 {
     if ($this->isNewRecord) {
         Syslog::add(Logs::LOG_ADDED, 'Добавлена причина банов <strong>' . $this->reason . '</strong>');
     } else {
         Syslog::add(Logs::LOG_EDITED, 'Изменена причина банов <strong>' . $this->reason . '</strong>');
     }
     return parent::afterSave();
 }
Exemplo n.º 17
0
 public function afterSave()
 {
     parent::afterSave();
     if (empty($this->profile)) {
         $profile = new Profile();
         $profile->user_id = $this->id;
         $profile->save();
     }
 }
Exemplo n.º 18
0
 public function afterSave()
 {
     if (!empty($_POST[__CLASS__]['options'])) {
         SummaryQuestionOption::model()->deleteAll('question =:id', [':id' => $this->id]);
         foreach ($_POST[__CLASS__]['options'] as $option) {
             Yii::app()->db->createCommand()->insert('summary_question_option', ['question' => $this->id, 'option' => $option]);
         }
     }
     return parent::afterSave();
 }
Exemplo n.º 19
0
 protected function afterSave()
 {
     if ($this->scenario == 'selectEvaAttributes') {
         $evaAttribsArray = json_decode($this->evaAttributes);
         $assMethodsCriteria = new CDbCriteria();
         $assMethodsCriteria->condition = 'evaluationId=' . $this->evalId;
         $assMethodsCriteria->addNotInCondition('evaAttribute', $evaAttribsArray);
         EvaAssessmentMethods::model()->deleteAll($assMethodsCriteria);
         return parent::afterSave();
     }
 }
Exemplo n.º 20
0
 protected function afterSave()
 {
     parent::afterSave();
     if (!file_exists($this->imagePath)) {
         Yii::app()->file->set($this->imagePath)->createDir(0777);
     }
     $linkPath = $this->getLinkImagePath();
     if (!file_exists($linkPath)) {
         Yii::app()->file->set($linkPath)->createDir(0777);
     }
 }
Exemplo n.º 21
0
 public function afterSave()
 {
     if ($this->_wasNewRecord) {
         $ids = Yii::app()->db->createCommand("SELECT id FROM member")->queryColumn();
         foreach ($ids as $id) {
             Yii::app()->db->createCommand("INSERT INTO message_assoc (member_id, message_id, seen) VALUES (" . $id . ", " . $this->id . ", 0)")->execute();
         }
         $this->_wasNewRecord = false;
     }
     return parent::afterSave();
 }
Exemplo n.º 22
0
 protected function afterSave()
 {
     parent::afterSave();
     $id = $this->getIdByTitle($this->title);
     if (!file_exists('images/' . Yii::app()->user->id . '/' . $id)) {
         if (!mkdir('images/' . Yii::app()->user->id . '/' . $id, 0777)) {
             Yii::log('Папка не создана', CLogger::LEVEL_ERROR);
         }
     } else {
         Yii::log('Такая папка уже есть', CLogger::LEVEL_ERROR);
     }
 }
Exemplo n.º 23
0
 protected function afterSave()
 {
     parent::afterSave();
     $users = DisciplineToUser::model()->findAllByAttributes(array('id_discipline' => $this->id_discipline));
     if ($this->isNewRecord) {
         foreach ($users as $user) {
             $model = new Progress();
             $model->id_user = $user->id_user;
             $model->id_lesson = $this->id_lesson;
             $model->save();
         }
     }
 }
Exemplo n.º 24
0
 public function afterSave()
 {
     parent::afterSave();
     $sql = array();
     $params = array();
     $chap_update = array();
     $book_update = array();
     if ($this->isNewRecord) {
         $is_first = count(Yii::app()->db->createCommand("SELECT 1 FROM translate WHERE orig_id = :orig_id LIMIT 2")->queryAll(true, array(":orig_id" => $this->orig_id))) == 1;
         $sql[] = "UPDATE users SET n_trs = n_trs + 1 WHERE id = :user_id;";
         $params[":user_id"] = $this->user_id;
         if ($this->hasRelated("user")) {
             $this->user->n_trs++;
         }
         $sql[] = "UPDATE orig SET n_trs = n_trs + 1 WHERE id = :orig_id;";
         $params[":orig_id"] = $this->orig_id;
         if ($this->hasRelated("orig")) {
             $this->orig->n_trs++;
         }
         $chap_update[] = "n_vars = n_vars + 1";
         $book_update[] = "n_vars = n_vars + 1";
         if ($this->hasRelated("chap")) {
             $this->chap->n_vars++;
         }
         if ($this->hasRelated("book")) {
             $this->book->n_vars++;
         }
         if ($is_first) {
             $chap_update[] = "d_vars = d_vars + 1";
             $book_update[] = "d_vars = d_vars + 1";
             if ($this->hasRelated("chap")) {
                 $this->chap->d_vars++;
             }
             if ($this->hasRelated("book")) {
                 $this->book->d_vars++;
             }
         }
     }
     $chap_update[] = "last_tr = now()";
     $book_update[] = "last_tr = now()";
     if (count($chap_update) > 0) {
         $sql[] = "UPDATE chapters SET " . join(", ", $chap_update) . " WHERE id = :chap_id;";
         $params[":chap_id"] = $this->chap_id;
     }
     if (count($book_update) > 0) {
         $sql[] = "UPDATE books SET " . join(", ", $book_update) . " WHERE id = :book_id;";
         $params[":book_id"] = $this->book_id;
     }
     $sql = "BEGIN;\n" . join("\n", $sql) . "\nCOMMIT;";
     Yii::app()->db->createCommand($sql)->execute($params);
 }
Exemplo n.º 25
0
 public function afterSave()
 {
     $res = BasespecialityRelation::model()->deleteAll("PersonBaseSpecialityID = {$this->idPersonBaseSpeciality}");
     if (!empty($this->speciality) && is_array($this->speciality)) {
         foreach ($this->speciality as $val) {
             $item = new BasespecialityRelation();
             $item->SpecialityID = $val;
             $item->PersonBaseSpecialityID = $this->idPersonBaseSpeciality;
             $item->save();
         }
     }
     //
     return parent::afterSave();
 }
Exemplo n.º 26
0
 public function afterSave()
 {
     if ($this->isNewRecord && !$this->especial) {
         $oFinanceiro = new Financeiro();
         $oFinanceiro->salvar(3, $this);
     } else {
         if ($this->excluido == 1 && !$this->especial) {
             $oFinanceiro = Financeiro::model()->findByAttributes(array('tipo_item' => 3, 'tipo_item_id' => $this->id));
             //            $oFinanceiro->scenario = 'cancelar';
             $oFinanceiro->salvar(3, $this, null, 1);
         }
     }
     parent::afterSave();
 }
Exemplo n.º 27
0
 public function afterSave()
 {
     $retorno = parent::afterSave();
     if (!$this->isNewRecord) {
         return $retorno;
     }
     foreach ($this->_item_combinado as $item_combinado) {
         $modelItemCombinadoPedido = new ItemCombinadoPedido();
         $modelItemCombinadoPedido->attributes = $item_combinado;
         $modelItemCombinadoPedido->combinado_pedido_id = $this->id;
         $modelItemCombinadoPedido->save();
     }
     return $retorno;
 }
Exemplo n.º 28
0
 protected function afterSave()
 {
     parent::afterSave();
     if ($this->oldName != $this->name) {
         $this->model()->updateByPk($this->oldName, array("name" => $this->name));
         $criteria = new CDbCriteria();
         $criteria->condition = "itemname='" . $this->oldName . "'";
         Assignments::model()->updateAll(array('itemname' => $this->name), $criteria);
         $criteria->condition = "parent='" . $this->oldName . "'";
         ItemChildren::model()->updateAll(array('parent' => $this->name), $criteria);
         $criteria->condition = "child='" . $this->oldName . "'";
         ItemChildren::model()->updateAll(array('child' => $this->name), $criteria);
         Yii::app()->user->setFlash('updateName', Helper::translate('srbac', 'Updating list'));
     }
 }
Exemplo n.º 29
0
 public function afterSave()
 {
     parent::afterSave();
     if ($this->id) {
         Catcross::model()->deleteAll('teacherId=:teacherId', array(':teacherId' => $this->id));
         for ($i = 0; $i < sizeof($this->leanerIDs); $i++) {
             if (!isset($this->leanerIDs[$i])) {
                 continue;
             }
             $cat = new Catcross();
             $cat->teacherId = $this->id;
             $cat->learnerId = $this->leanerIDs[$i];
             $cat->save();
         }
     }
 }
Exemplo n.º 30
0
 public function afterSave()
 {
     parent::afterSave();
     if ($this->isNewRecord) {
         if (!empty($this->reasons)) {
             foreach ($this->reasons as $r) {
                 $rts = new ReasonsToSet();
                 $rts->setid = intval($this->id);
                 $rts->reasonid = intval($r);
                 if ($rts->save()) {
                     $rts->unsetAttributes();
                 }
             }
             return TRUE;
         }
     }
     return TRUE;
 }