public function afterSave($insert, $changedAttributes) { $this->preview_input = UploadedFile::getInstance($this, 'preview_input'); if (!empty($this->preview_input)) { $this->preview_input->saveAs($this->preview_picture); } parent::afterSave($insert, $changedAttributes); }
/** * —охран¤ем данные в кеш * @param bool $insert * @param array $changedAttributes */ public function afterSave($insert, $changedAttributes) { parent::afterSave($insert, $changedAttributes); //$command = new SaveInCache(); //$command->setData($this->attributes) // ->execute(); }
public function afterSave($insert, $changedAttributes) { if ($insert === true) { Siteinfo::updateCounterInfo('addNode'); } return parent::afterSave($insert, $changedAttributes); }
/** * @param bool $insert * @param array $changedAttributes */ public function afterSave($insert, $changedAttributes) { if ($this->default == 1) { Languages::updateAll(['default' => 0], 'id!=' . $this->id); } Yii::$app->cache->delete('languages'); parent::afterSave($insert, $changedAttributes); }
/** * @inheritdoc */ public function afterSave($insert, $changedAttributes) { parent::afterSave($insert, $changedAttributes); // if onSite was changed in the form if ($this->onSite == empty($this->travel)) { if ($this->onSite) { $this->link('travel', new Travel()); } else { $this->unlink('travel', $this->travel, true); } } // compile an array with [note_id => ticket_id] for each ticket currently attached $note_to_ticket = ArrayHelper::map($this->notes, 'id', 'ticket_id'); // are we updating an existing event? if (!$insert) { // get a list of all tickets that need to be removed from event $removeNotes = array_keys(array_diff($note_to_ticket, $this->ticketIds)); Note::deleteAll(['id' => $removeNotes, 'author_id' => null]); Labor::deleteAll(['schedule_id' => $this->id, 'note_id' => $removeNotes, 'hours' => null]); } // get a list of all the tickets to add and attach them to the event foreach (array_diff($this->ticketIds, $note_to_ticket) as $ticket_id) { $note = new Note(['scenario' => Note::SCENARIO_SCHEDULE, 'ticket_id' => $ticket_id]); $note->save(false); $this->link('notes', $note); // update the ticket status if still submitted if ($note->ticket->status_id == Ticket::STATUS_SUBMITTED) { $note->ticket->status_id = Ticket::STATUS_IN_PROGRESS; $note->ticket->save(false); } } }
public function afterSave($insert, $changedAttributes) { if ($insert) { AttachmentFile::updateAll(['status_id' => AttachmentFile::STATUS_PERMANENT], ['id' => $this->attachment_id]); } parent::afterSave($insert, $changedAttributes); }
public function afterSave($insert, $changedAttributes) { parent::afterSave($insert, $changedAttributes); if (isset($changedAttributes['is_active']) && $changedAttributes['is_active'] != self::FINISHED && $this->is_active == self::FINISHED) { News::updateAll(['archive' => News::ARCHIVE_TRUE], ['id_tournament' => $this->id_tournament]); //assigning Events for winners forecast Top3TeamsForecast::setEventForTournament($this->id_tournament); //adding additional points to the total points field of UserTournaments model $this->assignAdditionalPoints(); } //if setting tournament back to active from finished, need to remove calculated additional points and clean additional forecast events if (isset($changedAttributes['is_active']) && $changedAttributes['is_active'] == self::FINISHED && $this->is_active == self::GOING) { //removing additional points to the total points field of UserTournaments model $this->removeAdditionalPoints(); //assigning Events for winners forecast to NULL Top3TeamsForecast::clearEventForTournament($this->id_tournament); } if ($insert) { $news = new News(); $news->scenario = 'send'; $news->id_tournament = 0; $news->subject = 'Добавлен новый турнир'; $news->body = "<p>Для прогноза доступен новый турнир {$this->tournament_name}, первый тур которого состоится " . date('d.m.y', $this->startsOn) . " </p>" . "<p>Вы также можете попробовать угадать призеров турнира и заработать дополнительные очки! Прогноз на призеров принимается до " . date('d.m.y', $this->wfDueTo) . " </p>" . "<p>Спешите принять участие! Зайдите в <strong>Профиль->Мои турниры</strong> чтобы начать делать прогнозы</p>"; $news->save(); } }
public function afterSave($insert, $changedAttributes) { if ($insert) { // Да это новая запись (insert) $model = new LogReestr(); $model->resstr = 'apteki'; $model->id_resstr = $this->id; $model->address = $this->address; $model->ur_l_id = $this->ur_l_id; $model->action = 'insert'; $model->user = Yii::$app->user->identity->id; $model->save(); } else { // Нет, старая (update) $save = ""; foreach ($changedAttributes as $change => $val) { if (trim($val) != trim($this->{$change})) { $save .= $this->attributeLabels()[$change] . '[' . $val . '->' . $this->{$change} . "]\n"; } } if ($save != "") { $model = new LogReestr(); $model->resstr = 'apteki'; $model->id_resstr = $this->id; $model->address = $this->address; $model->ur_l_id = $this->ur_l_id; $model->action = 'update'; $model->change = $save; $model->user = Yii::$app->user->identity->id; $model->save(); } } parent::afterSave($insert, $changedAttributes); }
public function afterSave($insert, $changedAttributes) { parent::afterSave($insert, $changedAttributes); // CLOB update if ($this->isNewRecord) { $subquery = 'SELECT ID FROM ' . $this->tableName() . ' ORDER BY ID DESC'; $sql = 'SELECT * FROM (' . $subquery . ') WHERE ROWNUM < 2'; $pk = Yii::$app->db->createCommand($sql)->queryScalar(); } else { $pk = $this->getPrimaryKey(); } $n = 1; $numTmpItems = count($this->tmp); if ($numTmpItems > 0) { $sql = 'UPDATE ' . $this->tableName() . ' SET'; foreach ($this->tmp as $id => $value) { $sql .= ' ' . $id . '=:' . $id; if ($n !== $numTmpItems) { $sql .= ','; } $n++; } $sql .= ' WHERE ID=:pk'; $cmd = Yii::$app->db->createCommand($sql); foreach ($this->tmp as $id => $value) { $cmd->bindParam(':' . $id, $this->tmp[$id], PDO::PARAM_STR, strlen($this->tmp[$id])); } $cmd->bindParam(':pk', $pk); $cmd->execute(); } // restore dates foreach ($this->dates() as $attribute) { $this->{$attribute} = str_replace(array("to_date('", "','{$this->dateFormat}')"), '', $this->{$attribute}->expression); } }
public function afterSave($insert, $changedAttributes) { foreach ($this->_saved as $field => $attr) { $this->setAttribute($field, $attr); } parent::afterSave($insert, $changedAttributes); }
public function afterSave($insert, $changedAttributes) { if ($this->default) { Lang::updateAll(['`default`' => 0], '`default` = :default AND id <> :lang_id', [':default' => 1, ':lang_id' => $this->id]); } return parent::afterSave($insert, $changedAttributes); }
public function afterSave($insert, $changedAttributes) { //$oldCategorias = array("0"=>1); $actualAssignments = []; if (($actualAssignments = AuthAssignment::find()->andWhere("user_id = {$this->id}")->asArray()->all()) !== null) { $actualAssignments = ArrayHelper::getColumn($actualAssignments, 'item_name'); } //verifica se é um array $this->assignmentIds = is_array($this->assignmentIds) ? $this->assignmentIds : [$this->assignmentIds]; $inserirAssignments = array_diff($this->assignmentIds, $actualAssignments); if (!empty($inserirAssignments)) { //save the relations foreach ($inserirAssignments as $id) { $r = new AuthAssignment(); $r->user_id = $this->id; $r->item_name = $id; $r->save(); } } $delAssignments = array_diff($actualAssignments, $this->assignmentIds); if (!empty($delAssignments)) { foreach ($delAssignments as $remove) { $r = AuthAssignment::findOne(['item_name' => $remove, 'user_id' => $this->id]); $r->delete(); } } parent::afterSave($insert, $changedAttributes); //don't forget this }
public function afterSave($insert, $changedAttributes) { parent::afterSave($insert, $changedAttributes); if ($this->value == '') { $this->delete(); } }
public function afterSave($insert, $changedAttributes) { parent::afterSave($insert, $changedAttributes); if ($insert) { $this->getProvince(); } }
public function afterSave($insert, $changedAttributes) { foreach ($this->order->items as $item) { $item->save(); } return parent::afterSave($insert, $changedAttributes); }
/** * @inheritdoc */ public function afterSave($insert, $changedAttributes) { if ($this->default) { $this->setLanguageDefault(); } parent::afterSave($insert, $changedAttributes); }
/** * @inheritdoc */ public function afterSave($insert, $changedAttributes) { parent::afterSave($insert, $changedAttributes); $domain = preg_split("/\r\n/isU", trim($this->domain_txt)); $site_id = $this->getPrimaryKey(); $domains = Domain::find()->where(['site_id' => $site_id])->all(); foreach ($domain as $key => $dm) { $dm = trim($dm); if (empty($dm)) { continue; } $domain_model = $this->findModelByDomain($domains, $dm); if (!isset($domain_model)) { $domain_model = new Domain(); } if ($key === 0) { $domain_model->main = 1; } else { $domain_model->main = 0; } $domain_model->domain = $dm; $domain_model->site_id = $this->id; $domain_model->save(); } }
public function afterSave($insert, $changedAttributes) { //$oldCategorias = array("0"=>1); $actualItens = []; if (($actualItens = AuthItemChild::find()->andWhere("parent = '{$this->name}'")->asArray()->all()) !== null) { $actualItens = ArrayHelper::getColumn($actualItens, 'child'); } //verifica se é um array $this->itemIds = is_array($this->itemIds) ? $this->itemIds : [$this->itemIds]; $inserirItens = array_diff($this->itemIds, $actualItens); if (!empty($inserirItens)) { //save the relations foreach ($inserirItens as $id) { $r = new AuthItemChild(); $r->parent = $this->name; $r->child = $id; $r->save(); } } $delItens = array_diff($actualItens, $this->itemIds); if (!empty($delItens)) { foreach ($delItens as $remove) { $r = AuthItemChild::findOne(['child' => $remove, 'parent' => $this->name]); $r->delete(); } } parent::afterSave($insert, $changedAttributes); //don't forget this }
public function afterSave($insert, $changedAttributes) { parent::afterSave($insert, $changedAttributes); // die; /* $priority range low =1 normal =2 high=3*/ //background($name, $data = null, $priority = self::NORMAL, $unique = null) Yii::$app->gearman->getDispatcher()->background('mailJob', new JobWorkload(['params' => ['data' => $this->id]]), $this->priority); }
public function afterSave($insert, $changedAttributes) { parent::afterSave($insert, $changedAttributes); if ($insert) { $up = new UserPlace(); $up->add($this->created_by, $this->id); } }
public function afterSave($insert, $changedAttributes) { if (isset($this->postProcessor) && !$this->postProcessing) { $postprocess = $this->postProcessor; $postprocess($this, $insert, $changedAttributes); } return parent::afterSave($insert, $changedAttributes); }
public function afterSave($insert, $changedAttributes) { \Yii::$app->cache->delete('shippings'); if (parent::afterSave($insert, $changedAttributes)) { return true; } else { return false; } }
/** * @inheritdoc */ public function afterSave($insert, $changedAttributes) { if ($this->topic_id > 0) { /** @var NotifyModule $notify */ $notify = Yii::$app->getModule('notify'); $notify->mentionHandler($this); } parent::afterSave($insert, $changedAttributes); }
public function afterSave($insert, $changedAttributes) { \Yii::$app->cache->delete('product_' . $this->idProduct); if (parent::afterSave($insert, $changedAttributes)) { return true; } else { return false; } }
public function afterSave($insert, $changedAttributes) { if ($insert && $this->object_model == User::className()) { $notification = new \humhub\modules\user\notifications\Followed(); $notification->originator = $this->user; $notification->send($this->getTarget()); } return parent::afterSave($insert, $changedAttributes); }
public function afterSave($insert, $attr) { parent::afterSave($insert, $attr); $wall = new Wall(); $wall->setData(new SubscribeUser(['to' => $this->user_id, 'from' => $this->subscriber_id, 'status' => SubscribeUser::STATUS_SUBSCRIBE])); $wall->publishTo(new WallPost(['target_type' => WallPost::TARGET_TYPE_USER, 'target_id' => $this->user_id, 'personal' => true])); $wall->publishTo(new WallPost(['target_type' => WallPost::TARGET_TYPE_USER, 'target_id' => $this->subscriber_id, 'personal' => false])); $wall->save(); }
public function afterSave($insert) { if ($insert) { $auth = Yii::$app->authManager; $author = $auth->createRole($this->id); $auth->add($author); } return parent::afterSave($insert); }
public function afterSave($insert, $changedAttributes) { if ($this->fileUpload instanceof UploadedFile) { $this->uploadFile($this->fileUpload); } parent::afterSave($insert, $changedAttributes); }
/** * @inheritdoc */ public function afterSave($insert, $changedAttributes) { parent::afterSave($insert, $changedAttributes); $this->value = unserialize(base64_decode($this->value)); if (is_callable($this->afterSave)) { call_user_func_array($this->afterSave, [$this, 'afterSave', $insert, $changedAttributes]); } }
public function afterSave($insert, $changedAttributes) { parent::afterSave($insert, $changedAttributes); if ($insert || empty($this->currentInvoice)) { $invoice = new Invoice(['scenario' => Invoice::SCENARIO_CURRENT, 'location_id' => $this->id]); $invoice->save(); } }