postcards and postcard messages can't be deleted as postcards. If postcards are deleted as images, their entries in the "postcard" table aren't deleted either. Postcard messages should be automatically delete after x days.

Comments

add1sun’s picture

vph, you're right that this is still something that needs to be done. I need to create a setting where the admin chooses the number of days to keep them and then cron cleans them out. Ultimately I need to really create an admin (and user) interface for managing postcards, but I'll keep that as another issue since it raises other questions as well.

Thanks for creating the issue. I hope to get to this in the next week or two.

add1sun’s picture

Title: Deleting postcards » Deleting postcards with cron
Assigned: Unassigned » add1sun

I've created another issue for an admin interface (http://drupal.org/node/134683) and changing this issue to implement a cron to delete old postcards. I hope to get this done this week with a simple admin field to select the number of days to keep postcards and delete when older than that date using cron.

add1sun’s picture

Status: Active » Needs review
StatusFileSize
new4.2 KB

First go at a patch to do this. Please test and report back if it works properly or not.

add1sun’s picture

StatusFileSize
new4.45 KB

Second patch. All I did was add a variable set update for the cron in postcard.install. Run update.php and make sure it runs OK.

add1sun’s picture

Status: Needs review » Fixed

Committed to the 5 branch.

lufthans’s picture

Thanks for adding a way to automagically expire postcards!

However :), I'd prefer having the option to just unpublish the postcard.

I figure this needs another field in the DB, so I haven't yet attempted it.

The postcard_cron you've implemented looks like it's site wide. Is that correct?

I'd prefer the ability to set publish/unpublish/delete dates per postcard. That would require a new field in the postcard table?

I'll have to setup a test instance before I can try out the new code you posted.

Would having the new postcard_cron variable cause problems for branches made before you added the new variable? In other words, if I update to the most recent code and it doesn't work, could I then just point back at the version I'm currently running?

add1sun’s picture

Hi lufthans, well there is no recent "branch" or "tag" within the current 5 branch in CVS that you can easily pull. I'm not a CVS guru by any means but I believe if you want to pull earlier revisions within a branch you can do so by date. The date of the cron change was Thu Apr 19. Other than that you can always step back, review and get individual files by looking at the viewcvs online. The simplest thing to do is to make a backup of the current version you are using and then simply replace it if things go wrong.

Hm, I hadn't really thought of adding anything for cron on a card by card basis. The idea of unpublish/publish is really a node action and postcards are not nodes so that would require a whole extra layer of complexity I'd have to custom write and frankly I'm not up for that.

If you would have the ability to set a cron delete date per postcard, I'm thinking that would require a new permission that could be assigned to users and if they have the perm, when they create a new postcard they would get an additional box that asks for how many days until it should be deleted. I'd have to say that I don't need this functionality myself and I don't see that being widely needed so I'm willing to consider patches that others provide but I don't have time to work on this myself. I do plan to work on the admin interface (http://drupal.org/node/134683) that will let users review and delete cards on a case by case basis and I think that issue along with the general cron cleanup will hit most use cases. If you do want to keep moving forward on the individual cron idea, please open a new issue so it can be discussed in its own venue.

misty3’s picture

Subscribing.

This is needed for 4.7x too.
If not possible, can this be manually done via phpmyadmin .... eg. empty some table ....
Any instructions for that please.

Best regards

add1sun’s picture

Version: 5.x-1.x-dev » 4.7.x-1.x-dev
Status: Fixed » Patch (to be ported)

hm, yeah you are right, this is important enough that it should be backported. changing the status/version and I'll try to do this in the next week or so. You can do this in the database directly for the time-being. All of the postcards are listed in the postcard table of the database. You can sort by send_time and delete the ones you want or just do an SQL to DELETE * FROM postcard WHERE send_time < whatever_timestamp_you_want. Just keep in mind the send_time is a UNIX time stamp so you'll need to do a little conversion if you are looking for a specific date. There are timestamp converters all over the place on the web.

add1sun’s picture

Status: Patch (to be ported) » Needs review
StatusFileSize
new1.5 KB

Ok, I basically copied this over from the 5 version since the API for this is the same. I ran it through a basic sanity check but I don't have time to really test it right now. Please give this a review and see if it works as advertised.

add1sun’s picture

Status: Needs review » Fixed

this is now in 4.7 dev.

Anonymous’s picture

Status: Fixed » Closed (fixed)