function CascadeDeleteSubdivision($SubdivisionID) { global $nc_core, $db, $MODULE_FOLDER; $CatalogueID = $db->get_var("SELECT `Catalogue_ID` FROM `Subdivision` WHERE `Subdivision_ID` = '" . (int) $SubdivisionID . "'"); // execute core action $nc_core->event->execute("dropSubdivisionPrep", $CatalogueID, $SubdivisionID); if (0 && nc_module_check_by_keyword("comments")) { include_once $MODULE_FOLDER . "comments/function.inc.php"; // delete comment rules nc_comments::dropRule($db, array($CatalogueID, $SubdivisionID)); // delete comments nc_comments::dropComments($db, $SubdivisionID, "Subdivision"); } DeleteMessages($SubdivisionID); DeleteFromSubClass($SubdivisionID); DeleteSubdivisionDir($SubdivisionID); $db->query("DELETE FROM `Subdivision` WHERE `Subdivision_ID` = '" . (int) $SubdivisionID . "'"); // execute core action $nc_core->event->execute("dropSubdivision", $CatalogueID, $SubdivisionID); return; }
function CascadeDeleteCatalogue($catalogueId) { global $nc_core, $db, $MODULE_FOLDER; $catalogueId = (int) $catalogueId; $subClasses = (array) $db->get_results("SELECT `Subdivision_ID`, `Sub_Class_ID`, `Class_ID` FROM `Sub_Class` WHERE `Catalogue_ID` = {$catalogueId}", ARRAY_A); // execute core action $nc_core->event->execute("dropCataloguePrep", $catalogueId); $subdivisionsToDelete = array(); //delete messages foreach ($subClasses as $subClass) { $subdivisionId = (int) $subClass['Subdivision_ID']; $subClassId = (int) $subClass['Sub_Class_ID']; $classId = (int) $subClass['Class_ID']; $subdivisionsToDelete[] = $subdivisionId; $subClassesToDelete[] = $subClassId; $messages = (array) $db->get_results("SELECT `Message_ID` FROM `Message{$classId}` WHERE `Sub_Class_ID` = {$subClassId}", ARRAY_A); $messagesToDelete = array(); foreach ($messages as $message) { $messagesToDelete[] = (int) $message['Message_ID']; } if (count($messagesToDelete) > 0) { // execute core action $nc_core->event->execute("dropMessagePrep", $catalogueId, $subdivisionId, $subClassId, $classId, $messagesToDelete); // delete messages foreach ($messagesToDelete as $messageId) { DeleteMessageFiles($classId, $messageId); $db->query("DELETE FROM `Message{$classId}` WHERE `Message_ID` = {$messageId}"); } // execute core action $nc_core->event->execute("dropMessage", $catalogueId, $subdivisionId, $subClassId, $classId, $messagesToDelete); } //delete subclass // execute core action $nc_core->event->execute("dropSubClassPrep", $catalogueId, $subdivisionId, $subClassId); $db->query("DELETE FROM `Sub_Class` WHERE `Sub_Class_ID` = {$subClassId}"); DeleteSubClassDirAlways($subdivisionId, $subClassId); // execute core action $nc_core->event->execute("dropSubClass", $catalogueId, $subdivisionId, $subClassId); } if (count($subdivisionsToDelete) > 0) { // execute core action $nc_core->event->execute("dropSubdivisionPrep", $catalogueId, $subdivisionsToDelete); foreach ($subdivisionsToDelete as $subdivisionId) { $db->query("DELETE FROM `Subdivision` WHERE `Subdivision_ID` = {$subdivisionId}"); DeleteSubdivisionDir($subdivisionId); } // execute core action $nc_core->event->execute("dropSubdivision", $catalogueId, $subdivisionsToDelete); } if (nc_module_check_by_keyword("comments")) { include_once $MODULE_FOLDER . "comments/function.inc.php"; // delete comment rules nc_comments::dropRule($db, array($catalogueId)); // delete comments nc_comments::dropComments($db, $catalogueId, "Catalogue"); } // delete catalogue $db->query("DELETE FROM `Catalogue` WHERE `Catalogue_ID` = {$catalogueId}"); // execute core action $nc_core->event->execute("dropCatalogue", $catalogueId); return; }