/** * @param CEvent $event * @return mixed */ public function afterDelete($event) { Yii::import('application.modules.comments.models.Comment'); $pk = $this->getObjectPkAttribute(); Comment::model()->deleteAllByAttributes(array('class_name' => $this->getClassName(), 'object_pk' => $this->getOwner()->{$pk})); return parent::afterDelete($event); }
public function afterDelete($event) { if (Yii::app() instanceof CWebApplication) { if (Yii::app()->user->getState(UserIdentity::STATE_AUDIT_TRAIL, true)) { UserActivityLog::model()->addRecord(array('user_id' => Yii::app()->user->id, 'ip' => Common::getIp(), 'action' => 'delete', 'activity' => $this->prepareString($this->deleteTemplate))); } } return parent::afterDelete($event); }
/** * @param CEvent $event * @return mixed */ public function afterDelete($event) { if (Yii::app()->hasModule('comments')) { Yii::import('mod.comments.models.Comments'); $pk = $this->getObjectPkAttribute(); Comments::model()->deleteAllByAttributes(array('model' => $this->getModelName(), 'object_id' => $this->getOwner()->{$pk})); } return parent::afterDelete($event); }
function afterDelete($event) { // removing all model's comments $comments = $this->getComments(); foreach ($comments as $comment) { $comment->delete(); } parent::afterDelete($event); }
/** * Responds to {@link CActiveRecord::onBeforeDelete} event. * Update records order field in a manner that their values are still successively increased by one (so, there is no gap caused by the deleted record) * @param CEvent $event event parameter */ public function afterDelete($event) { $sender = $event->sender; $model = call_user_func(array(get_class($sender), 'model')); $following_records = $model->findAll(array('order' => '`' . $this->orderField . '` ASC', 'condition' => '`' . $this->orderField . '` > ' . $sender->{$this->orderField})); foreach ($following_records as $record) { $record->{$this->orderField}--; $record->update(); } return parent::afterDelete($event); }
public function afterDelete($event) { $condition = '(`firstType`=:ft AND `firstId`=:fid) OR (`secondType`=:st AND `secondId`=:sid)'; Relationships::model()->deleteAll($condition, array(':ft' => get_class($this->owner), ':fid' => $this->owner->id, ':st' => get_class($this->owner), ':sid' => $this->owner->id)); parent::afterDelete($event); }
/** * @param CEvent * @return void */ public function afterDelete($event) { // Delete all attributes. $this->deleteEavAttributes(array(), TRUE); // Call parent method for convenience. parent::afterDelete($event); }
/** * Deletes tag bindings on model delete. * @param CModelEvent $event * @return void */ public function afterDelete($event) { // delete all present tag bindings $this->deleteTags(); $this->cache->delete($this->getCacheKey()); $this->resetAllTagsWithModelsCountCache(); parent::afterDelete($event); }
public function afterDelete($event) { if ($this->owner->contact_id && get_class($this->owner) != 'ContactLocation') { Address::model()->deleteAll('contact_id = :contact_id', array(':contact_id' => $this->owner->contact_id)); Contact::model()->deleteByPk($this->owner->contact_id); } parent::afterDelete($event); }
public function afterDelete($event) { try { $username = Yii::app()->user->Name; $userid = Yii::app()->user->id; } catch (Exception $e) { $username = "******"; $userid = null; } if (empty($username)) { $username = "******"; } if (empty($userid)) { $userid = null; } $log = new AuditTrail(); $log->old_value = ''; $log->new_value = ''; $log->action = 'DELETE'; $log->model = get_class($this->Owner); $log->model_id = $this->Owner->getPrimaryKey(); $log->field = 'N/A'; $log->stamp = date('Y-m-d H:i:s'); $log->user_id = $userid; $log->save(); return parent::afterDelete($event); }
public function afterDelete($event) { MetaTag::model()->deleteAllByAttributes(array('object_id' => $this->owner->id, 'model_id' => get_class($this->owner))); return parent::afterDelete($event); }
public function afterDelete($event) { parent::afterDelete($event); foreach ($this->fields as $field) { if (isset($this->owner->{$field})) { $img = $this->getImagePath($this->owner->{$field}); $thumb = $this->getImagePath($this->owner->{$field}, true); if (file_exists($img)) { unlink($img); } if (file_exists($thumb)) { unlink($thumb); } } } return true; }
public function afterDelete($event) { $this->leaveTrail('DELETE'); return parent::afterDelete($event); }
/** * @param CEvent $event */ public function afterDelete($event) { $this->elasticDelete(); parent::afterDelete($event); }
/** * Find changes to the model and save them as AuditField records. * Do not call this method directly, it will be called after the model is deleted. * @param CModelEvent $event */ public function afterDelete($event) { if (!$this->enableAuditField) { parent::afterDelete($event); return; } $date = time(); $auditModels = $this->getAuditModels(); $auditRequestId = $this->getAuditRequestId(); $userId = Yii::app()->user && Yii::app()->user->id ? Yii::app()->user->id : 0; $auditFields = array(); // prepare the logs $pk = $this->getPrimaryKeyString($this->auditModel); foreach ($auditModels as $auditModel) { $prefix = isset($auditModel['prefix']) ? $auditModel['prefix'] . '.' . $pk : ''; $auditFields[] = array('old_value' => '', 'new_value' => '', 'action' => 'DELETE', 'model_name' => $auditModel['model_name'], 'model_id' => $auditModel['model_id'], 'field' => $prefix . '*', 'created' => $date, 'user_id' => $userId, 'audit_request_id' => $auditRequestId); } // insert the audit_field records $this->addAuditFields($auditFields); parent::afterDelete($event); }
/** * 删除事件处理 * @param type $event */ public function afterDelete($event) { parent::afterDelete($event); DataLog::model()->deleteAll(TUtil::qc('pk') . "=:pk and " . TUtil::qc('model') . "=:model", array(":pk" => $this->owner->attributes[$this->pk], ":model" => $this->owner->tableName())); }
/** * @param CModelEvent $event */ public function afterDelete($event) { $this->clearCache(); parent::afterDelete($event); }