本文整理汇总了PHP中CActiveRecordBehavior::afterDelete方法的典型用法代码示例。如果您正苦于以下问题:PHP CActiveRecordBehavior::afterDelete方法的具体用法?PHP CActiveRecordBehavior::afterDelete怎么用?PHP CActiveRecordBehavior::afterDelete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CActiveRecordBehavior
的用法示例。
在下文中一共展示了CActiveRecordBehavior::afterDelete方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: afterDelete
/**
* @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);
}
示例2: afterDelete
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);
}
示例3: afterDelete
/**
* @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);
}
示例4: afterDelete
function afterDelete($event)
{
// removing all model's comments
$comments = $this->getComments();
foreach ($comments as $comment) {
$comment->delete();
}
parent::afterDelete($event);
}
示例5: afterDelete
/**
* 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);
}
示例6: afterDelete
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);
}
示例7: afterDelete
/**
* @param CEvent
* @return void
*/
public function afterDelete($event)
{
// Delete all attributes.
$this->deleteEavAttributes(array(), TRUE);
// Call parent method for convenience.
parent::afterDelete($event);
}
示例8: afterDelete
/**
* 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);
}
示例9: afterDelete
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);
}
示例10: afterDelete
public function afterDelete($event)
{
try {
$username = Yii::app()->user->Name;
$userid = Yii::app()->user->id;
} catch (Exception $e) {
$username = "NO_USER";
$userid = null;
}
if (empty($username)) {
$username = "NO_USER";
}
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);
}
示例11: afterDelete
public function afterDelete($event)
{
MetaTag::model()->deleteAllByAttributes(array('object_id' => $this->owner->id, 'model_id' => get_class($this->owner)));
return parent::afterDelete($event);
}
示例12: afterDelete
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;
}
示例13: afterDelete
public function afterDelete($event)
{
$this->leaveTrail('DELETE');
return parent::afterDelete($event);
}
示例14: afterDelete
/**
* @param CEvent $event
*/
public function afterDelete($event)
{
$this->elasticDelete();
parent::afterDelete($event);
}
示例15: afterDelete
/**
* 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);
}