/** * Implementing callback to react on user-delete events * * Called whenever a record was deleted using the common methods. * Implement this method to be notified when a record is deleted, e.g. to to additional cleanups afterwards. * There's no need to register the listener, this is done automatically. * * Make sure to return a matching boolean-value, otherwise the transaction may be rolled back. * * @param string $strEventName * @param array $arrArguments * * @return bool */ public function handleEvent($strEventName, array $arrArguments) { //unwrap arguments list($strSystemid, $strSourceClass) = $arrArguments; if ($strSourceClass == "class_module_user_user" && validateSystemid($strSystemid)) { $objORM = new class_orm_objectlist(); $objORM->addWhereRestriction(new class_orm_objectlist_property_restriction("strUser", class_orm_comparator_enum::Equal(), $strSystemid)); $objORM->setObjHandleLogicalDeleted(class_orm_deletedhandling_enum::INCLUDED()); $arrWidgets = $objORM->getObjectList("class_module_dashboard_widget"); foreach ($arrWidgets as $objWidget) { $objWidget->deleteObjectFromDatabase(); } } return true; }
/** * Called whenever a records was deleted using the common methods. * Implement this method to be notified when a record is deleted, e.g. to to additional cleanups afterwards. * There's no need to register the listener, this is done automatically. * * Make sure to return a matching boolean-value, otherwise the transaction may be rolled back. * * @param string $strEventName * @param array $arrArguments * * @return bool */ public function handleEvent($strEventName, array $arrArguments) { //unwrap arguments list($strSystemid, $strSourceClass) = $arrArguments; $bitReturn = true; //module installed? if ($strSourceClass == "class_module_postacomment_post" || class_module_system_module::getModuleByName("postacomment") == null) { return true; } $objOrm = new class_orm_objectlist(); $objOrm->setObjHandleLogicalDeleted(class_orm_deletedhandling_enum::INCLUDED()); $objOrm->addWhereRestriction(new class_orm_objectlist_restriction(" AND (postacomment_page = ? OR postacomment_systemid = ? ) ", array($strSystemid, $strSystemid))); $arrComments = $objOrm->getObjectList("class_module_postacomment_post"); foreach ($arrComments as $objPost) { if ($strEventName == class_system_eventidentifier::EVENT_SYSTEM_RECORDDELETED_LOGICALLY) { $objPost->deleteObject(); } if ($strEventName == class_system_eventidentifier::EVENT_SYSTEM_RECORDDELETED) { $objPost->deleteObjectFromDatabase(); } } return $bitReturn; }
/** * Searches for workflows assigned to the systemid to be deleted. * * @param string $strEventName * @param array $arrArguments * * @return bool */ public function handleEvent($strEventName, array $arrArguments) { //unwrap arguments list($strSystemid, $strSourceClass) = $arrArguments; $bitReturn = true; $objORM = new class_orm_objectlist(); $objORM->setObjHandleLogicalDeleted(class_orm_deletedhandling_enum::INCLUDED()); $objORM->addWhereRestriction(new class_orm_objectlist_restriction(" AND workflows_systemid = ?", $strSystemid)); if ($objORM->getObjectCount("class_module_workflows_workflow") == 0) { return true; } class_orm_base::setObjHandleLogicalDeletedGlobal(class_orm_deletedhandling_enum::INCLUDED()); $arrWorkflows = class_module_workflows_workflow::getWorkflowsForSystemid($strSystemid, false); foreach ($arrWorkflows as $objOneWorkflow) { if ($strEventName == class_system_eventidentifier::EVENT_SYSTEM_RECORDDELETED_LOGICALLY) { $bitReturn = $bitReturn && $objOneWorkflow->deleteObject(); } if ($strEventName == class_system_eventidentifier::EVENT_SYSTEM_RECORDDELETED) { $bitReturn = $bitReturn && $objOneWorkflow->deleteObjectFromDatabase(); } } class_orm_base::setObjHandleLogicalDeletedGlobal(class_orm_deletedhandling_enum::EXCLUDED()); return $bitReturn; }