News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Expired Attachments

Started by Suki, March 14, 2014, 01:36:37 PM

Previous topic - Next topic

Suki

Link to Mod

The software is licensed under [MPL 1.1 license](http://www.mozilla.org/MPL/MPL-1.1.html).

######Expire Attachments:

A simple modification to allow users to set a predefined date for their attachments to be deleted. some features:

- There are 4 hard-coded expiration dates: 'Day', 'Week', 'Month', 'Year' and "NEVER".  The admin can enable/disable each specific date.
- You must enable at least 1 period, otherwise the mod will not store any expiration date. Each date period sets a unique permission, you can assign that permission to each membergroup.
Apply all permissions if you want the user to have all the possible option dates available.
- Each attachment will get its unique expiration date.
- After the attachment has been deleted, a text on its related message will be added stating the attachment has been deleted.
- This mod does not modify old attachments, it will only work with new attachments uploaded after the installation of this mod.
Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.

OCJ

I like the idea of this one... thanks.

To my surprise 2.0.7 is giving me few error in the log these days. But this mod  shows up.
I'm not sure if important or worth correcting though. Here are the details from smf error log.

Mod is set to expire attachments at 3 months.
   
Quote
   
/index.php?action=post2;start=0;board=39
Undefined index: expire_date
/public_html/Sources/Subs-Post.php Line: 2247
   

(int) $attachmentOptions['size'], (empty($attachmentOptions['width']) ? 0 : (int) $attachmentOptions['width']), (empty($attachmentOptions['height']) ? '0' : (int) $attachmentOptions['height']),
==>2247:    

(!empty($attachmentOptions['mime_type']) ? $attachmentOptions['mime_type'] : ''), (int) $attachmentOptions['approved'], (int) $attachmentOptions['expire_date'],

Suki

Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.

OCJ

Attached.
I guess it could also be an effect from another mod too.


Suki

The var shouldn't have to be null since I explicitly set it as an integer and only filled it if there is some data, make sure you have this code on your /Sources/Post.php file:


// Expire Attachments mod
if (!empty($modSettings['ExAt_setting_enable']) && !empty($_REQUEST['expire_date'. $n]))
{
// Set the var
$attachmentOptions['expire_date'] = 0;

// Do this only if the selected option wasn't "forever"
if ($_REQUEST['expire_date'. $n] != 'forever')
{
// One last extra check, just to be sure...
if (empty($modSettings['ExAt_setting_periods'. $_REQUEST['expire_date'. $n] .'_number']))
$modSettings['ExAt_setting_periods'. $_REQUEST['expire_date'. $n] .'_number'] = 1;

// Calculate the time ahead, strtotime() makes things easy, for me, not the server...
$expire_date = strtotime('+'. $modSettings['ExAt_setting_periods'. $_REQUEST['expire_date'. $n] .'_number'] .' '. strtolower($_REQUEST['expire_date'. $n]));

// Fill up the var
if (!empty($expire_date))
$attachmentOptions['expire_date'] = (int) $expire_date;
}
}
// Expire Attachments mod end

if (createAttachment($attachmentOptions))


where exactly does this happen?  is the user actually uploading an attachment?

Alternatively, you can just move the var declaration

$attachmentOptions['expire_date'] = 0;

outside the if conditional

// Set the var
$attachmentOptions['expire_date'] = 0;

if (!empty($modSettings['ExAt_setting_enable']) && !empty($_REQUEST['expire_date'. $n]))
         {
            
Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.

OCJ

Ok, thanks. Im not so bothered about the errors - not many. I just thought I would report it.

mnn2

Feature request.  :)


Please add optional total download limit. I mean we limit a particular attachment to be available for certain number of downloads, e.g. free ebook for first 50 downloads.

Thankyou.

Suki

Sorry, thats beyond the scope of this mod.  I recall there are other mods that limit the amount of attachment downloads.
Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.

OCJ

On reinstalling my site and mods I get an error trying to install this mod again. It will not complete install.

Duplicate entry 'attachments_expire_date' for key 'task' File: /***/****/public_html/Packages/temp/install.php Line: 56

I do not want to go in the database and delete tables just to get it to install again. Would be better if fixed.

Andy

Suki

I've update the mod to fix that error and a few other ones.

But you still need to go to your scheduled_tasks table and manually delete the "attachments_expire_date" entry  before installing the mod again.

If you don't want to do that manually then download the mod, get the removeScheduledTask.php file, upload it to your forum's root folder and call it with your browser:  myforum/removeScheduledTask.php

Then install the mod.
Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.

OCJ

#10
Ok, thanks very much, that was quick!

And it installed ok this time.

Snrj

very good mod thanks
turkish translate pack

-Rock Lee-

Very good modification @Suki Here I leave the Spanish translation Latin I hope you will be useful ;D


Regards!
¡Regresando como cual Fenix! ~ Bomber Code
Ayudas - Aportes - Tutoriales - Y mucho mas!!!

Advertisement: