public function postUpdate(PropelPDO $con = null) { $objectDeleted = false; if ($this->isColumnModified(categoryPeer::DELETED_AT) && !is_null($this->getDeletedAt())) { $objectDeleted = true; } $ret = parent::postUpdate($con); if ($objectDeleted) { kEventsManager::raiseEvent(new kObjectDeletedEvent($this)); } return $ret; }
public function postUpdate(PropelPDO $con = null) { if ($this->alreadyInSave) { return parent::postUpdate($con); } $objectUpdated = $this->isModified(); $objectDeleted = false; if ($this->isColumnModified(categoryPeer::DELETED_AT) && !is_null($this->getDeletedAt())) { $objectDeleted = true; } $categoryGroupSize = kConf::get('max_number_of_memebrs_to_be_indexed_on_entry'); $partner = $this->getPartner(); if ($partner && $partner->getCategoryGroupSize()) { $categoryGroupSize = $partner->getCategoryGroupSize(); } //re-index entries if ($this->isColumnModified(categoryPeer::INHERITANCE_TYPE) || $this->isColumnModified(categoryPeer::PRIVACY) || $this->isColumnModified(categoryPeer::PRIVACY_CONTEXTS) || $this->isColumnModified(categoryPeer::FULL_NAME) || $this->isColumnModified(categoryPeer::MEMBERS_COUNT) && $this->members_count <= $categoryGroupSize && $this->entries_count <= kConf::get('category_entries_count_limit_to_be_indexed')) { $this->addIndexEntryJob($this->getId(), true); } $oldParentCategoryToResetSubCategories = null; $parentCategoryToResetSubCategories = null; if ($this->isColumnModified(categoryPeer::PARENT_ID)) { $this->addRecalcCategoriesCount($this->getId()); $this->addRecalcCategoriesCount($this->old_parent_id); $oldParentCategoryToResetSubCategories = categoryPeer::retrieveByPK($this->old_parent_id); $parentCategoryToResetSubCategories = $this->getParentCategory(); } if (kCurrentContext::getCurrentPartnerId() != Partner::BATCH_PARTNER_ID && ($this->isColumnModified(categoryPeer::PARENT_ID) || $this->isColumnModified(categoryPeer::INHERITANCE_TYPE) || $this->isColumnModified(categoryPeer::NAME) || $this->isColumnModified(categoryPeer::PRIVACY_CONTEXTS) || $this->isColumnModified(categoryPeer::MEMBERS) || $this->isColumnModified(categoryPeer::MEMBERS_COUNT))) { $lock = false; if ($this->isColumnModified(categoryPeer::PARENT_ID)) { $lock = true; } $fullIds = $this->getFullIds(); if ($this->isColumnModified(categoryPeer::FULL_IDS)) { $fullIds = $this->getColumnsOldValue(categoryPeer::FULL_IDS); } $fullIds .= categoryPeer::CATEGORY_SEPARATOR; $this->addIndexCategoryJob($fullIds, null, $lock); } if ($this->isColumnModified(categoryPeer::STATUS) && ($this->getStatus() == CategoryStatus::PURGED || $this->getStatus() == CategoryStatus::DELETED) && ($this->getColumnsOldValue(categoryPeer::STATUS) == CategoryStatus::ACTIVE || $this->getColumnsOldValue(categoryPeer::STATUS) == CategoryStatus::UPDATING)) { $parentCategoryToResetSubCategories = $this->getParentCategory(); } // check if parnet is deleted and could be purged if ($this->isColumnModified(categoryPeer::STATUS) && $this->getStatus() == CategoryStatus::PURGED) { $parentCategory = $this->getParentCategory(); //TODO - all logic for purge is not right if ($parentCategory && $parentCategory->isReadyForPurge()) { $parentCategory->setStatus(CategoryStatus::PURGED); $parentCategory->save(); } } $ret = parent::postUpdate($con); if ($objectDeleted) { kEventsManager::raiseEvent(new kObjectDeletedEvent($this)); } if ($objectUpdated) { kEventsManager::raiseEvent(new kObjectUpdatedEvent($this)); } kEventsManager::flushEvents(); if ($oldParentCategoryToResetSubCategories) { $oldParentCategoryToResetSubCategories->reSetDirectSubCategoriesCount(); $oldParentCategoryToResetSubCategories->save(); } if ($parentCategoryToResetSubCategories) { $parentCategoryToResetSubCategories->reSetDirectSubCategoriesCount(); $parentCategoryToResetSubCategories->save(); } return $ret; }
public function postUpdate(PropelPDO $con = null) { if ($this->alreadyInSave) { return parent::postUpdate($con); } $objectUpdated = $this->isModified(); $objectDeleted = false; if ($this->isColumnModified(categoryPeer::DELETED_AT) && !is_null($this->getDeletedAt())) { $objectDeleted = true; } $categoryGroupSize = category::MAX_NUMBER_OF_MEMBERS_TO_BE_INDEXED_ON_ENTRY; $partner = $this->getPartner(); if ($partner && $partner->getCategoryGroupSize()) { $categoryGroupSize = $partner->getCategoryGroupSize(); } //re-index entries if ($this->isColumnModified(categoryPeer::INHERITANCE_TYPE) || $this->isColumnModified(categoryPeer::PRIVACY) || $this->isColumnModified(categoryPeer::PRIVACY_CONTEXTS) || $this->isColumnModified(categoryPeer::FULL_NAME) || $this->isColumnModified(categoryPeer::MEMBERS_COUNT) && $this->members_count <= $categoryGroupSize && $this->entries_count <= entry::CATEGORY_ENTRIES_COUNT_LIMIT_TO_BE_INDEXED) { $this->addIndexEntryJob($this->getId(), true); } $oldParentCategoryToResetSubCategories = null; $parentCategoryToResetSubCategories = null; if ($this->isColumnModified(categoryPeer::PARENT_ID)) { $this->addRecalcCategoriesCount($this->getId()); $this->addRecalcCategoriesCount($this->old_parent_id); $oldParentCategoryToResetSubCategories = categoryPeer::retrieveByPK($this->old_parent_id); $parentCategoryToResetSubCategories = $this->getParentCategory(); } if ($this->isColumnModified(categoryPeer::STATUS) && ($this->getStatus() == CategoryStatus::PURGED || $this->getStatus() == CategoryStatus::DELETED) && ($this->getColumnsOldValue(categoryPeer::STATUS) == CategoryStatus::ACTIVE || $this->getColumnsOldValue(categoryPeer::STATUS) == CategoryStatus::UPDATING)) { $parentCategoryToResetSubCategories = $this->getParentCategory(); } // check if parnet is deleted and could be purged if ($this->isColumnModified(categoryPeer::STATUS) && $this->getStatus() == CategoryStatus::PURGED) { $parentCategory = $this->getParentCategory(); //TODO - all logic for purge is not right if ($parentCategory && $parentCategory->isReadyForPurge()) { $parentCategory->setStatus(CategoryStatus::PURGED); $parentCategory->save(); } } $ret = parent::postUpdate($con); if ($objectDeleted) { kEventsManager::raiseEvent(new kObjectDeletedEvent($this)); } if ($objectUpdated) { kEventsManager::raiseEvent(new kObjectUpdatedEvent($this)); } kEventsManager::flushEvents(); if ($oldParentCategoryToResetSubCategories) { $oldParentCategoryToResetSubCategories->reSetDirectSubCategoriesCount(); $oldParentCategoryToResetSubCategories->save(); } if ($parentCategoryToResetSubCategories) { $parentCategoryToResetSubCategories->reSetDirectSubCategoriesCount(); $parentCategoryToResetSubCategories->save(); } return $ret; }