Advertisement:

Author Topic: Expired Attachments  (Read 5176 times)

Offline Suki

  • Customizer
  • SMF Super Hero
  • *
  • Posts: 15,084
  • Kaizoku Jotei
    • MissAllSunday on GitHub
    • SMF mods
Expired Attachments
« on: March 14, 2014, 01:36:37 PM »
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.
Look at them. They're just asking for it. Maybe the human race deserves to be wiped out.

Offline OCJ

  • Full Member
  • ***
  • Posts: 481
  • Gender: Male
Re: Expired Attachments
« Reply #1 on: April 23, 2014, 06:07:44 AM »
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'],

Offline Suki

  • Customizer
  • SMF Super Hero
  • *
  • Posts: 15,084
  • Kaizoku Jotei
    • MissAllSunday on GitHub
    • SMF mods
Re: Expired Attachments
« Reply #2 on: April 23, 2014, 04:03:51 PM »
Attach that file here.
Look at them. They're just asking for it. Maybe the human race deserves to be wiped out.

Offline OCJ

  • Full Member
  • ***
  • Posts: 481
  • Gender: Male
Re: Expired Attachments
« Reply #3 on: May 09, 2014, 05:58:59 AM »
Attached.
I guess it could also be an effect from another mod too.


Offline Suki

  • Customizer
  • SMF Super Hero
  • *
  • Posts: 15,084
  • Kaizoku Jotei
    • MissAllSunday on GitHub
    • SMF mods
Re: Expired Attachments
« Reply #4 on: May 09, 2014, 08:26:06 AM »
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:

Code: [Select]
// 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]))
         {
            
Look at them. They're just asking for it. Maybe the human race deserves to be wiped out.

Offline OCJ

  • Full Member
  • ***
  • Posts: 481
  • Gender: Male
Re: Expired Attachments
« Reply #5 on: May 11, 2014, 11:36:47 AM »
Ok, thanks. Im not so bothered about the errors - not many. I just thought I would report it.

Offline mnn2

  • Semi-Newbie
  • *
  • Posts: 74
Re: Expired Attachments
« Reply #6 on: May 20, 2014, 01:12:41 PM »
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.

Offline Suki

  • Customizer
  • SMF Super Hero
  • *
  • Posts: 15,084
  • Kaizoku Jotei
    • MissAllSunday on GitHub
    • SMF mods
Re: Expired Attachments
« Reply #7 on: May 23, 2014, 11:24:59 AM »
Sorry, thats beyond the scope of this mod.  I recall there are other mods that limit the amount of attachment downloads.
Look at them. They're just asking for it. Maybe the human race deserves to be wiped out.

Offline OCJ

  • Full Member
  • ***
  • Posts: 481
  • Gender: Male
Re: Expired Attachments
« Reply #8 on: October 22, 2014, 12:12:18 AM »
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

Offline Suki

  • Customizer
  • SMF Super Hero
  • *
  • Posts: 15,084
  • Kaizoku Jotei
    • MissAllSunday on GitHub
    • SMF mods
Re: Expired Attachments
« Reply #9 on: October 22, 2014, 10:14:32 AM »
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.
Look at them. They're just asking for it. Maybe the human race deserves to be wiped out.

Offline OCJ

  • Full Member
  • ***
  • Posts: 481
  • Gender: Male
Re: Expired Attachments
« Reply #10 on: October 22, 2014, 10:18:40 AM »
Ok, thanks very much, that was quick!

And it installed ok this time.
« Last Edit: October 22, 2014, 10:29:26 AM by igirisjin »

Offline Snrj

  • Jr. Member
  • **
  • Posts: 274
  • Gender: Male
  • smf forum
    • Smf Destek
Re: Expired Attachments
« Reply #11 on: April 09, 2016, 01:13:40 PM »
very good mod thanks
turkish translate pack

Offline Rock Lee

  • Sophist Member
  • *****
  • Posts: 1,179
  • Gender: Male
  • Digitalizando un nuevo mundo :D
    • BomberCode.Oficial on Facebook
    • RockLee-BC on GitHub
    • @Bomber_Code on Twitter
    • Bomber Code ~ La nueva era del conocimiento
Re: Expired Attachments
« Reply #12 on: April 09, 2016, 02:33:25 PM »
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 © 2017
Ayudas - Aportes - Tutoriales - Y mucho mas!!!