View Issue Details

IDProjectCategoryView StatusLast Update
1789Composrcore_abstract_interfacespublic2021-11-03 01:20
ReporterChris Graham Assigned To 
PrioritynormalSeverityfeature 
Status newResolutionopen 
Summary1789: Consistent "move when delete" for category deletion
DescriptionAlways allow selection of a new target category for whatever is inside the category being deleted.
TagsRoadmap: Over the horizon, Type: Cross-cutting feature , Type: Usability (major)
Attach Tags
Attached Files
Time estimation (hours)10
Sponsorship open

Sponsor

Date Added Member Amount Sponsored

Relationships

related to 416 Not Assigned Mass move / delete 

Activities

Chris Graham

2016-04-20 16:47

administrator   ~3627

Current and idealised behaviour with respect to category contents, when a category is deleted...

zone:
    CURRENT BEHAVIOUR:
        deletes pages within
        does not allow deletion of welcome zone
    IDEAL BEHAVIOUR:
        asks whether to delete, or where to reassign to
        does not allow deletion of welcome zone

news category:
    CURRENT BEHAVIOUR:
        reassigns to lowest ID category
        does not allow deletion of final category
    IDEAL BEHAVIOUR:
        asks whether to delete, or where to reassign to
        if the final category no choice can be given so UI gives a clear click-through warning that all entries will be deleted

gallery:
    CURRENT BEHAVIOUR:
        deletes images and videos within
        reassigns subgalleries to parent gallery
        does not allow deletion of root gallery
    IDEAL BEHAVIOUR:
        asks whether to delete, or where to reassign to; default to move to parent gallery
        does not allow deletion of root gallery

download category
    CURRENT BEHAVIOUR:
        reassigns downloads to parent category
        reassigns subcategories to parent category
        does not allow deletion of root category
    IDEAL BEHAVIOUR:
        asks whether to delete, or where to reassign to; default to move to parent category
        does not allow deletion of root category

forum grouping:
    CURRENT BEHAVIOUR:
        asks where to reassign to
        does not allow deletion of final forum grouping
    IDEAL BEHAVIOUR:
        (no change)

forum:
    CURRENT BEHAVIOUR:
        asks whether to delete, or where to reassign to
        does not allow deletion of root forum
    IDEAL BEHAVIOUR:
        asks whether to delete, or where to reassign to; default to move to parent forum
        does not allow deletion of root forum

catalogue category:
    CURRENT BEHAVIOUR:
        asks whether to delete; if not:
            if in a tree catalogue:
                reassigns entries to parent category
                reassigns subcategories to parent category
                does not allow deletion of root category
            if not in tree catalogue:
                deletes entries
    IDEAL BEHAVIOUR:
        asks whether to delete; if not:
            if in a tree catalogue:
                asks whether to delete, or where to reassign to; default to move to parent category
                does not allow deletion of root category
            if not in tree catalogue:
                asks whether to delete, or where to reassign to
                if the final category no choice can be given so UI gives a clear click-through warning that all entries will be deleted

catalogue:
    CURRENT BEHAVIOUR:
        deletes all categories and entries (necessarily so, not logical to move to another catalogue)
    IDEAL BEHAVIOUR:
        (no change)


When fixed, this functionality expectation should be generalised and added to the Code Book, and referenced in our standards checklist.

Chris Graham

2016-04-20 16:50

administrator   ~3628

Note also we have these language strings...

DESCRIPTION_DELETE=Tick (check) this if this is to be deleted. This is immediate and irreversible.
DESCRIPTION_DELETE_LOSE_CONTENTS=Tick (check) this if this is to be deleted. This is immediate and irreversible. The contents of this category will also be deleted.
DESCRIPTION_DELETE_PARENT_CONTENTS=Tick (check) this if this is to be deleted. This is immediate and irreversible. The contents of this category will be moved to the parent category.

They should be used/adjusted to be completely accurate.

Chris Graham

2016-04-20 16:53

administrator   ~3629

Also note how galleries currently has an option to leave files on-disk. Probably we should just remove that, as the era of people being expected to mess around with on-disk files to this extent is rather outdated. I'd rather it all be consistent.

Chris Graham

2016-04-20 16:55

administrator   ~3630

Also see the issue reference I'm adding in sources/crud_module.php, relating to the description of the deletion checkbox.

Chris Graham

2021-11-03 01:20

administrator   ~7159

Attached is a patch I wrote to allow configuring (via hidden option) the target news category for news to be moved to when said news' category is deleted.
I don't like how piecemeal this is, so I don't plan to merge it. It should be an option with the delete fields on the edit form.
delete_news_category_behavior.diff (2,139 bytes)   
diff --git a/sources/news2.php b/sources/news2.php
index 9dca6ee..b7ce6ee 100644
--- a/sources/news2.php
+++ b/sources/news2.php
@@ -157,11 +157,15 @@ function delete_news_category($id)
     }
     $myrow = $rows[0];
 
-    $min = $GLOBALS['SITE_DB']->query_value_if_there('SELECT c.id FROM ' . get_table_prefix() . 'news_categories c WHERE c.id<>' . strval($id) . ' AND ' . db_string_equal_to($GLOBALS['SITE_DB']->translate_field_ref('nc_title'), do_lang('news:NC_general')), false, false, array('nc_title' => 'SHORT_TRANS'));
-    if (is_null($min)) {
-        $min = $GLOBALS['SITE_DB']->query_value_if_there('SELECT MIN(id) FROM ' . get_table_prefix() . 'news_categories WHERE id<>' . strval($id));
+    $_default_category_id = get_value('default_news_category');
+    $default_category_id = empty($_default_category_id) ? null : intval($_default_category_id);
+    if ($default_category_id === null) {
+        $default_category_id = $GLOBALS['SITE_DB']->query_value_if_there('SELECT c.id FROM ' . get_table_prefix() . 'news_categories c WHERE c.id<>' . strval($id) . ' AND ' . db_string_equal_to($GLOBALS['SITE_DB']->translate_field_ref('nc_title'), do_lang('news:NC_general')), false, false, array('nc_title' => 'SHORT_TRANS'));
+        if (is_null($default_category_id)) {
+            $default_category_id = $GLOBALS['SITE_DB']->query_value_if_there('SELECT MIN(id) FROM ' . get_table_prefix() . 'news_categories WHERE id<>' . strval($id));
+        }
     }
-    if (is_null($min)) {
+    if (is_null($default_category_id)) {
         warn_exit(do_lang_tempcode('YOU_MUST_KEEP_ONE_NEWS_CAT'));
     }
 
@@ -173,7 +177,7 @@ function delete_news_category($id)
 
     delete_lang($myrow['nc_title']);
 
-    $GLOBALS['SITE_DB']->query_update('news', array('news_category' => $min), array('news_category' => $id));
+    $GLOBALS['SITE_DB']->query_update('news', array('news_category' => $default_category_id), array('news_category' => $id));
     $GLOBALS['SITE_DB']->query_delete('news_categories', array('id' => $id), '', 1);
     $GLOBALS['SITE_DB']->query_delete('news_category_entries', array('news_entry_category' => $id));
 

Add Note

View Status
Note
Upload Files
Maximum size: 32,768 KiB

Attach files by dragging & dropping, selecting or pasting them.
You are not logged in You are not logged in. This means you will not get any e-mail notifications. And if you reply, we will not know for sure you are the original poster of the issue.

Issue History

Date Modified Username Field Change
2016-04-20 16:47 Chris Graham Note Added: 0003627
2016-04-20 16:50 Chris Graham Note Added: 0003628
2016-04-20 16:53 Chris Graham Note Added: 0003629
2016-04-20 16:55 Chris Graham Note Added: 0003630
2016-12-08 00:45 Chris Graham Tag Attached: Type: Cross-cutting feature
2016-12-08 16:16 Chris Graham Tag Attached: Type: Usability (major)
2017-05-01 16:48 Chris Graham Category core => core_abstract_interfaces
2019-06-27 18:52 Chris Graham Tag Attached: Roadmap: v11
2019-06-27 18:52 Chris Graham Tag Detached: Roadmap: v11
2019-06-27 18:52 Chris Graham Tag Attached: Roadmap: v12
2021-11-03 01:20 Chris Graham File Added: delete_news_category_behavior.diff
2021-11-03 01:20 Chris Graham Note Added: 0007159
2024-03-26 00:58 PDStig Tag Renamed Roadmap: v12 => Roadmap: Over the horizon