Here's a simple patch to delete a saved search. It's very fundemental, but if anyone else needs the functionality, then try it out.

@Update, correct patch file (2527864.patch) supplied.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

infinito’s picture

infinito’s picture

Issue summary: View changes
FileSize
1.52 KB
herd45’s picture

Another solution is to use VBO which allows you to delete entities. Each saved view is an entity.
https://www.drupal.org/project/views_bulk_operations

infinito’s picture

Yes, but i'm providing page where they can see their listings along with a delete button. I've also created an administration page for the module which I will submit after testing. It allows the user to customize the modal size and the redirect url after deleting along with some other minor updates.

drunken monkey’s picture

Status: Patch (to be ported) » Needs work

Thanks a lot for your patch!
I guess even if we don't use it at the moment, providing this as a help for site builders who would want this functionality makes sense, so I'd also be inclined to commit a patch providing this.

However, your patch has still some problems which I'd ask you to address first:

  • The access checks shouldn't be in the page callback. Instead, provide a proper access callback which checks all necessary permissions, etc. (It should also allow users with the administer views_save permission to delete all saved views, I'd say.
  • Then, this code would be very susceptible to XSRF attacks. GET requests should almost never change any data, and especially "delete" operations should always come with confirmation forms. (See Core for many examples.)
  • Also, the documentation of the page callback (or now the new access and form callbacks) should keep to the Drupal coding standards.

(Also, when there's a patch for the correct version, the right issue status is "Needs review".)

alansaviolobo’s picture

Status: Needs work » Needs review
FileSize
4.76 KB

have updated the patch with your suggestions.

drunken monkey’s picture

Status: Needs review » Needs work

Thanks for your work!

This patch gives me:

fatal: corrupt patch at line 76

And I can't really figure out, why.

Also, patches you post in the issue queue should always be relative to the module directory, not to the site root. (Same goes for the patch in #2 by infinito, btw.)

alansaviolobo’s picture

Status: Needs work » Needs review
FileSize
4.85 KB

sorry about that. Have recreated the patch via git diff.

drunken monkey’s picture

Ah, thanks, looks pretty good!
There were just a few coding standards issues, should all be fixed in the attached patch. Please test again and review, then I can commit.

Also, normally, please refrain from including unrelated code cleanup changes in your patches, those should go into separate issues. (But since this module is pretty low-frequency, we can leave them in this time.)

drunken monkey’s picture

Anyone wants to test and/or review the latest patch? Then I could commit it.

drunken monkey’s picture

Status: Needs review » Fixed

Committed. Thanks again!

infinito’s picture

Sorry for not getting back. And great work alansaviolob! It was a quick fix for development project, glad someone else saw the need for this!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.