Index: branches/RC/core/install/upgrades.sql
===================================================================
diff -u -r8964 -r9040
--- branches/RC/core/install/upgrades.sql (.../upgrades.sql) (revision 8964)
+++ branches/RC/core/install/upgrades.sql (.../upgrades.sql) (revision 9040)
@@ -120,4 +120,6 @@
UPDATE ConfigurationAdmin SET `element_type` = 'textarea' WHERE `VariableName` = 'Category_MetaDesc';
INSERT INTO ConfigurationValues VALUES (DEFAULT, 'UseToolbarLabels', '1', 'In-Portal', 'in-portal:configure_general');
-INSERT INTO ConfigurationAdmin VALUES ('UseToolbarLabels', 'la_Text_Website', 'la_UseToolbarLabels', 'checkbox', NULL , NULL , 10.20, 0, 0);
\ No newline at end of file
+INSERT INTO ConfigurationAdmin VALUES ('UseToolbarLabels', 'la_Text_Website', 'la_UseToolbarLabels', 'checkbox', NULL , NULL , 10.20, 0, 0);
+INSERT INTO ConfigurationValues VALUES (DEFAULT, 'AllowDeleteRootCats', '0', 'In-Portal', 'in-portal:configure_categories');
+INSERT INTO ConfigurationAdmin VALUES ('AllowDeleteRootCats', 'la_Text_General', 'la_AllowDeleteRootCats', 'checkbox', NULL , NULL , 10.08, 0, 0);
\ No newline at end of file
Index: branches/RC/core/kernel/db/db_event_handler.php
===================================================================
diff -u -r8929 -r9040
--- branches/RC/core/kernel/db/db_event_handler.php (.../db_event_handler.php) (revision 8929)
+++ branches/RC/core/kernel/db/db_event_handler.php (.../db_event_handler.php) (revision 9040)
@@ -929,8 +929,9 @@
* @param kEvent $event
*/
function customProcessing(&$event, $type)
- {
-
+ {
+
+
}
/* Edit Events mostly used in Admin */
@@ -2091,8 +2092,8 @@
readfile($path);
exit();
- }
-
+ }
+
}
Index: branches/RC/core/units/categories/categories_event_handler.php
===================================================================
diff -u -r8929 -r9040
--- branches/RC/core/units/categories/categories_event_handler.php (.../categories_event_handler.php) (revision 8929)
+++ branches/RC/core/units/categories/categories_event_handler.php (.../categories_event_handler.php) (revision 9040)
@@ -464,7 +464,51 @@
parent::OnPreSaveCreated($event);
}
+
+
+ /**
+ * Exclude root categories from deleting
+ *
+ * @param kEvent $event
+ */
+ function customProcessing(&$event, $type)
+ {
+ if (!$this->Application->ConfigValue('m_AllowDeleteRootCats')) {
+
+ if ($event->Name == 'OnMassDelete' && $type == 'before') {
+ $ids = $event->getEventParam('ids');
+
+ if ($ids) {
+
+ // get module roots and exclude them
+ foreach ($this->Application->ModuleInfo as $module_name => $module_data) {
+ if ((int)$module_data['RootCat'])
+ $ids_exclude[] = (int)$module_data['RootCat'];
+ }
+
+ if ($ids_exclude && array_intersect($ids, $ids_exclude))
+ {
+ $ids = array_diff($ids, $ids_exclude);
+ $this->Application->StoreVar('root_delete_error', 1);
+ }
+
+ /*
+ $id_field = $this->Application->getUnitOption($event->Prefix, 'IDField');
+ $table_name = $this->Application->getUnitOption($event->Prefix, 'TableName');
+
+ $sql = 'SELECT '.$id_field.'
+ FROM '.$table_name.'
+ WHERE '.$id_field.' IN ('.implode(',', $ids).').';
+ $event->setEventParam('ids', $this->Conn->GetCol($sql));
+ */
+
+ $event->setEventParam('ids', $ids);
+ }
+ }
+ }
+ }
+
/**
* Deletes all selected items.
* Automatically recurse into sub-items using temp handler, and deletes sub-items
@@ -477,10 +521,16 @@
if ($this->Application->CheckPermission('SYSTEM_ACCESS.READONLY', 1)) {
return;
}
+
// $event->status = erSUCCESS;
$ids = $this->StoreSelectedIDs($event);
+
+ $event->setEventParam('ids', $ids);
+ $this->customProcessing($event, 'before');
+ $ids = $event->getEventParam('ids');
+
if ($ids) {
$recursive_helper =& $this->Application->recallObject('RecursiveHelper');
/* @var $recursive_helper kRecursiveHelper */
Index: branches/RC/core/admin_templates/catalog/catalog.tpl
===================================================================
diff -u -r8966 -r9040
--- branches/RC/core/admin_templates/catalog/catalog.tpl (.../catalog.tpl) (revision 8966)
+++ branches/RC/core/admin_templates/catalog/catalog.tpl (.../catalog.tpl) (revision 9040)
@@ -9,6 +9,7 @@