[drupal-devel] [feature] let admins mass delete nodes

Bèr Kessels drupal-devel at drupal.org
Sat Jan 15 00:46:02 UTC 2005


 Project:      Drupal
 Version:      cvs
 Component:    node system
 Category:     feature requests
 Priority:     critical
 Assigned to:  Bèr Kessels
 Reported by:  killes at www.drop.org
 Updated by:   Bèr Kessels
 Status:       patch
 Attachment:   http://drupal.org/files/issues/batch_delete_4-6.patch (6.66 KB)

Updated for 4.6. (hint, hint)

Bèr Kessels



Previous comments:
------------------------------------------------------------------------

May 12, 2004 - 16:44 : killes at www.drop.org

Attachment: http://drupal.org/files/issues/node_2.patch (1.41 KB)

It would be nice if admins could mass delete unpublished nodes. The
attached patch allows this. It also improved error handling.

------------------------------------------------------------------------

May 12, 2004 - 20:48 : Kjartan

Looks good to me. Since it only allows deletion of unpublished nodes
there probably isn't need for an approval page? Thats the only thing I
can think of as a critism. Everything else is reversable, but delete is
permanent (unless the site has some form of backup).

------------------------------------------------------------------------

May 12, 2004 - 23:43 : killes at www.drop.org

Well, I found I'd need this capability and therefore coded it. I don't
know how to fit a "are you sure" page in that filter mechanism.

------------------------------------------------------------------------

May 13, 2004 - 00:34 : killes at www.drop.org

Teh patch also does not call the neccessary delete hooks thu sleaving
data in additional tables like event or flexinode.

------------------------------------------------------------------------

May 13, 2004 - 20:08 : Dries

Setting the status to 'active' until it works like it should.

------------------------------------------------------------------------

June 29, 2004 - 22:01 : killes at www.drop.org

Ber is developing a better patch.

------------------------------------------------------------------------

June 29, 2004 - 22:33 : Bèr Kessels

Attachment: http://drupal.org/files/issues/batch_delete_easy_coding.patch (4.16 KB)

Extracting the bits and bytes from http://drupal.org/node/view/5162.
Hope it might help bring life into this feature.

Overall my comment is that that part of node.module is quite messy.
There's html hardcoded and the function handling this part is one big
bloat of code. 

That makes it kinda hard to fix this issue in a more elegant way,
without cleaning up that mess before. I would like to use a nicer
method of confirmation once this part is cleaned. But as it currently
stands thats a quite hard task.

------------------------------------------------------------------------

June 29, 2004 - 22:46 : Bèr Kessels

Moshe had some better ideas. Those need a lot more coding however. 

moshe_work>I think you can give a confrim screen just like we do for
nodes, comments, etc.
moshe_work>"You are about to delete ..." and then do a theme(item_list,
$items) showing all the titles
moshe_work>you would want to stick all the nids about to be deleted in
a hidden form field

the problem with this is, that somehow you need to bypass the update
and filter form generation. Since that whole admin part is gernerated
in one big (120 + lines.) function node_admin_nodes() this needs some
work too, if you wnat to apply moshe's idea. 

For now i am satisfied with the above attached patch. And I would like
to hear feedback about the UI for confirmation. 

Regards

------------------------------------------------------------------------

June 30, 2004 - 09:09 : stefan nagtegaal

Can you show us some screenshots Ber?

------------------------------------------------------------------------

June 30, 2004 - 10:20 : Bèr Kessels

Attachment: http://drupal.org/files/issues/batch_delete_step1.png (18.8 KB)

Screenshot: first you select the nodes you want to have deleted.
Than from the dropdown you select "delete selected nodes".

------------------------------------------------------------------------

June 30, 2004 - 10:22 : Bèr Kessels

Attachment: http://drupal.org/files/issues/batch_delete_step2.png (26.77 KB)

After pressing [update]  you see the screen back, and in the "update
actions dropdown" you get a confirmation.

------------------------------------------------------------------------

June 30, 2004 - 10:22 : Bèr Kessels

Attachment: http://drupal.org/files/issues/batch_delete_step3.png (15.72 KB)

after pressing [update] again the nodes are actually deleted.

------------------------------------------------------------------------

June 30, 2004 - 14:59 : Dries

Wouldn't a dedicated confirmation page be a lot better usability-wise? 
At least, that's what one would expect.

------------------------------------------------------------------------

June 30, 2004 - 15:52 : kika

Attachment: http://drupal.org/files/issues/typepad_multiitem_deletion.png (54.11 KB)

please, resign step 2 in you patch and build a proper confimation page.

Have look at the screenshot included, this is the Typepad
multi-item-deletion workflow (scroll down)

------------------------------------------------------------------------

June 30, 2004 - 15:57 : Bèr Kessels

True Dries, kika, thats why I pasted some comments in
http://drupal.org/node/view/7743#comment-9138. 

I see only one big issue in the typepad approach. That will do for
deleting, but our range of updating- actions will not work there, or
you would need 5 columns of selection boxes. IMO thats a no-go. I linke
the current method. My gmx mail uses that, and Ive seen it a lot. 

The dedicated screen for confirmation is a good idea, but kinda hard to
code, in the current state.

The big problem is that I tried that raod first (it seems much more
logical to go for that). But untill the node_admin_nodes() gets a big
cleanup, I think that adding a dedicated UI is a pain, and will make
the mess even worse. :(

So in fact the road to take here (IMO) is:

1) clean up the node.module admin area.
2) split all actions into separate functions (e.g.
node_admin_update_promote($nodelist) )
3) add a function forbatch deleting
4) maybe add some more actions (e.g batch re-taxonomising)

I tried to skip 1 and 2 and go straight for 3, but I ended up with
3-levels deep nested ifs nad foreaches and a 200+ lines big function
node_admin_nodes(). And still it had some bugs. I might have done it
worong there, but that made me decide to use this much simpler
approach.

------------------------------------------------------------------------

June 30, 2004 - 15:59 : kika

to clarify: I am not suggesting to use popup, just a standard
confimation page

------------------------------------------------------------------------

July 1, 2004 - 10:29 : Bèr Kessels

Allright,

All has been said, little done. I think we all agree on the fact that
there should be some confirmation screen. 

But, as i pointed out, that will not be there for a while. Unless
someone else takes this task and does a total revamp of (the code of)
the node admin UI.

So, if we want some batch deletion, I would suggest to either start
coding and come up with a better UI, or use this solution.

Regards,

------------------------------------------------------------------------

July 1, 2004 - 11:58 : Dries

I don't intend to commit this patch as is.  I'll see if I can make a
confirmration screen.  Marking this active in the mean time.

------------------------------------------------------------------------

July 23, 2004 - 19:23 : laird

This patch is wonderful; I install it everywhere I use Drupal (several
sites now).

I'd like to make two feature requests:

1) It leaves behind records in the node-type specific tables. For
example, if you have node 1000 that's an image, this patch will delete
node 1000 from the node table, but won't delete node 1000's entry in
the image table. This isn't a huge problem, since it doesn't cause
anything to break (since they're not linked anywhere, so don't appear
in any selects joined against the node table). But it's a bit messy to
leave these disconnected records around in the database, so it should
be fixed on general principles.

2) If you are deleting a large number of nodes, you have to manually
click on each check box, then delete the batch. It'd be great to have a
'check all' button, to speed the process. It'd be even better to have a
means to 'delete all unpublished nodes' as a one-click way to clean up
the database. I have several automated feeds on one site, and it
accumulates tons of unused nodes that are quite tedious to delete
manually.

- LP

------------------------------------------------------------------------

August 15, 2004 - 21:59 : Anonymous

newbie who needs help

how do you incorporate the patch file into the node.module file?

does it have to be in a certain area or just at the top of the code?

------------------------------------------------------------------------

August 15, 2004 - 22:00 : Anonymous

newbie who needs help

how do you incorporate the patch file into the node.module file?

does it have to be in a certain area of the code?

------------------------------------------------------------------------

August 16, 2004 - 11:49 : Bèr Kessels

please refer to http://drupal.org/book/view/323 for info about patching.
And please be aware that you should be carefull with changing the
category of an issue.

------------------------------------------------------------------------

August 25, 2004 - 11:51 : Bèr Kessels

Attachment: http://drupal.org/files/issues/batch_delete_with_confirm page.patch (6.41 KB)

Final attempt. Now with a default confirmation screen. That confirmation
shows a list with titles of all nodes that are about to be deleted.


------------------------------------------------------------------------

October 29, 2004 - 19:46 : mpamphile

Is this patch 4.5 compliant ?

I would like to add it to a 4.5 site.  

If anyone is intrested, I'm also modifying taxonomy.module so that
multiple terms can be added.  If anyone is interested in this, let me
know... mpamphile  hotmail . com.








------------------------------------------------------------------------

December 9, 2004 - 02:09 : michaelemeyers

can this be added to core?  Very valuable/useful patch... thnx. _m

re - mpamphile on October 29, 2004: Is this patch 4.5 compliant ?

I just patched 4.5.1 and other than line numbers being slightly off,
the only difference was that in the Menu callback function node_admin()
I needed to make the following change:

    case t('Delete'):
      // $output = node_delete($edit); // remove this and add line
below
	  $output = node_admin_nodes($edit);
      break;


-- 
View: http://drupal.org/node/7743
Edit: http://drupal.org/project/comments/add/7743





More information about the drupal-devel mailing list