public function beforeDelete() { if (!empty($this->jobs)) { return false; } return parent::beforeDelete(); }
/** * Before-delete hook * * @return type */ protected function beforeDelete() { if (!$this->canBeDeleted) { return false; } return parent::beforeDelete(); }
public function beforeDelete() { $item = InventoryItems::model()->findByPk($this->item_id); $item->qty += $this->qty; $item->save(); return parent::beforeDelete(); }
/** * Make sure we delete any comments */ public function beforeDelete() { foreach ($this->comments as $comment) { $comment->delete(); } return parent::beforeDelete(); }
/** * **/ protected function beforeDelete() { if (parent::beforeDelete()) { unlink(Yii::app()->params->imageBasePath . DIRECTORY_SEPARATOR . $this->filename); } return true; }
protected function beforeDelete() { foreach ($this->candidates() as $candidate) { $candidate->delete(); } return parent::beforeDelete(); }
public function beforeDelete() { parent::beforeDelete(); foreach ($this->points as $point) { $point->delete(); } return true; }
protected function beforeDelete() { if (parent::beforeDelete()) { if ($this->demo_real && @unlink(Yii::getPathOfAlias('webroot.include.files') . DIRECTORY_SEPARATOR . $this->demo_file)) { return true; } } return false; }
public function beforeDelete() { $this->cacheId = $this->attribute_group_id; // delete relations foreach ($this->attributes as $attribute) { $attribute->delete(); } return parent::beforeDelete(); }
protected function beforeDelete() { foreach ($this->seats() as $seat) { $seat->delete(); } foreach ($this->tokens() as $token) { $token->delete(); } return parent::beforeDelete(); }
/** * Make sure we delete any posts */ public function beforeDelete() { foreach ($this->posts as $post) { $post->delete(); } foreach ($this->subs as $sub) { $sub->delete(); } return parent::beforeDelete(); }
protected function beforeDelete() { $result = parent::beforeDelete(); if (!$result) { return false; } if ($this->album && $this->album->isCover($this)) { $this->coverShouldBeUpdated = true; } return $result; }
protected function beforeDelete() { if (parent::beforeDelete()) { foreach ($this->catalogProducts as $product) { $product->delete(); } return true; } else { return false; } }
public function beforeDelete() { /* remove all nodes attached to this mindmap */ $sql = strtr('DELETE FROM {table} WHERE mindmap_id=:mindmap_id', array('{table}' => Node::model()->tableName())); try { Yii::app()->db->createCommand($sql)->bindValue(':mindmap_id', $this->id)->execute(); } catch (Exception $e) { echo $e->getMessage(); } return parent::beforeDelete(); }
/** * Custom actions before deleting a record * @return boolean */ protected function beforeDelete() { if (parent::beforeDelete()) { if ($childs = $this->childs) { foreach ($childs as $child) { $child->delete(); } } return true; } return false; }
public function beforeDelete() { $sql = 'SELECT file_path FROM {{messages_files}} WHERE id="' . $this->id . '"'; $item = Yii::app()->db->createCommand($sql)->queryScalar(); $message = new Messages(); if ($item) { if (file_exists($message->uploadPath . '/' . $item)) { unlink($message->uploadPath . '/' . $item); } } return parent::beforeDelete(); }
protected function beforeDelete() { try { foreach ($this->micrositio_x_genero as $micrositio_x_genero) { $mxg = MicrositioXGenero::model()->findByPk($micrositio_x_genero->id); $mxg->delete(); } return parent::beforeDelete(); } catch (Exception $e) { return false; } }
public function beforeDelete() { //DebugBreak(); $db = $this->getDbConnection(); if ($db->getCurrentTransaction() === null) { //if do not exists current... $this->_transaction = $db->beginTransaction(); // ... start new transaction } return parent::beforeDelete(); //run parent event handler... IT MUST BE!!! }
public function beforeDelete() { if (!$this->alias->isLeaf()) { echo '<div class="flash-error">' . Yii::t('contentModule.admin', 'Vous devez relocaliser les sous-pages avant de supprimer celle-ci.') . '</div>'; return false; } else { foreach ($this->blocs as $bloc) { $bloc->delete(); } $this->alias->deleteNode(); } return parent::beforeDelete(); }
public function beforeDelete() { //DebugBreak(); $tagposts = Tagpost::model()->findAll('post_id = :post_id', array(':post_id' => $this->post_id)); if (!empty($tagposts)) { foreach ($tagposts as $tagpost) { //delete all tags relations $tagpost->delete(); } } return parent::beforeDelete(); //run parent event handler... IT MUST BE!!! }
protected function beforeDelete() { if (!parent::beforeDelete()) { return false; } $file = $_SERVER['DOCUMENT_ROOT'] . Yii::app()->getBaseUrl() . '/Image/AttachmentProject/' . $this->img; $fileMini = $_SERVER['DOCUMENT_ROOT'] . Yii::app()->getBaseUrl() . '/Image/AttachmentProject/mini-' . $this->img; if (file_exists($file) and $this->img != '') { unlink($file); } if (file_exists($fileMini) and $this->img != '') { unlink($fileMini); } return true; }
protected function beforeDelete() { if (parent::beforeDelete() === true) { if (isset(Yii::app()->params) && isset(Yii::app()->params->isDemo)) { $this->isDemo = Yii::app()->params->isDemo; } if ($this->isDemo) { Yii::app()->user->setFlash('demo_mode', $this->errorDelete); return false; } return true; } else { return false; } }
protected function beforeDelete() { try { foreach ($this->menuItems as $menuItem) { $mi = MenuItem::model()->findByPk($menuItem->id); $mi->delete(); } foreach ($this->micrositios as $micrositio) { $m = $micrositio->findByPk($micrositio->id); $m->menu_id = NULL; $m->save(); } return parent::beforeDelete(); } catch (Exception $e) { return false; } }
public function beforeDelete() { $modelsSamePage = self::model()->multilang()->findAllByAttributes(array('parent_id' => $this->parent_id)); foreach ($modelsSamePage as $model) { if ($model->rank > $this->rank) { $model->rank--; $model->save(); } } $className = 'Bloc' . ucfirst($this->bloc_type); $bloc = $className::model()->findByPk($this->bloc_id); foreach ($bloc->behaviors() as $behaviorName => $behavior) { if ($behavior['class'] == 'application.components.behaviors.BlocBehavior') { $bloc->{$behaviorName}->deleting = true; } } $bloc->delete(); return parent::beforeDelete(); }
protected function beforeDelete() { if (!parent::beforeDelete()) { return false; } foreach ($this->attachment as $key => $value) { $model = AttachmentProject::model()->findByPk($value->id); $model->delete(); } $file = $_SERVER['DOCUMENT_ROOT'] . Yii::app()->getBaseUrl() . '/Image/Project/' . $this->img; $fileMini = $_SERVER['DOCUMENT_ROOT'] . Yii::app()->getBaseUrl() . '/Image/Project/mini-' . $this->img; if (file_exists($file) and $this->img != '') { unlink($file); } if (file_exists($fileMini) and $this->img != '') { unlink($fileMini); } return true; }
/** * This method is called before deleting AR model from database table. * In this method, we delete file attachment. */ protected function beforeDelete() { // First call the base class if (!parent::beforeDelete()) { return false; } // Remove related comment if ($this->comment) { $this->comment->delete(); } // Delete related file attachments foreach ($this->attachments as $attachment) { $attachment->delete(); } // Delete related bug status change if (isset($this->statuschange)) { $this->statuschange->delete(); } return true; }
public function beforeDelete() { $this->deleteRecursive(); return parent::beforeDelete(); }
public function beforeDelete() { parent::beforeDelete(); $sql = "SELECT COUNT(*) FROM vote WHERE review={$this->review} and vote={$this->vote}"; $numClients = Yii::app()->db->createCommand($sql)->queryScalar(); if($this->vote == 1){ $review = Article::model()->updateByPk($this->review,array('yes'=>($numClients-1))); } else { $review = Article::model()->updateByPk($this->review,array('no'=>($numClients-1))); } return true; }
/** * Before deleting a SIContent try to delete all corresponding SIContentAddons. */ public function beforeDelete() { // delete also all wall entries foreach ($this->getWallEntries() as $entry) { $entry->delete(); } // remove from search index if ($this->object_model instanceof ISearchable) { HSearch::getInstance()->deleteModel($this->getContentObject()); } // Remove From User Content UserContent::model()->deleteAllByAttributes(array('object_model' => $this->object_model, 'object_id' => $this->object_id)); // Try delete the underlying object (Post, Question, Task, ...) if ($this->getUnderlyingObject() !== null) { $this->getUnderlyingObject()->delete(); } return parent::beforeDelete(); }
protected function beforeDelete() { parent::beforeDelete(); $servers = AdminsServers::model()->findByAttributes(array('admin_id' => $this->id)); if ($servers !== null) { $servers->deleteAllByAttributes(array('admin_id' => $this->id)); } return true; }