forum.coppermine-gallery.net

Support => cpg1.6 plugins => cpg1.6.x Support => cpg1.6 plugin contributions => Topic started by: Αndré on November 27, 2018, 04:59:25 pm

Title: Limit upload plugin for cpg1.6.x
Post by: Αndré on November 27, 2018, 04:59:25 pm
This is the cpg1.6.x and PHP7 compatible version of the Limit upload plugin.

This plugin allows you to limit the number of uploads for your users. You can choose a total number of files, or a certain amount of files for different periods of time.
Title: Re: Limit upload plugin for cpg1.6.x
Post by: lurkalot on November 28, 2018, 01:08:38 am
Thank you Andre.  I uninstalled the old one, and went to install this new one, unfortunately it gives me this error when I try. 

Critical error

There was an error while processing a database query.


While executing query 'INSERT INTO cpg_config (name, value) VALUES ('limit_upload_upload_limit', '-1')' in plugins/limit_upload/codebase.php on line 96

database error: 1062 : Duplicate entry 'limit_upload_upload_limit' for key 'PRIMARY'

File: /hxxxx/cxxxxxxx/public_html/gallery/include/functions.inc.php - Line: 250 
Title: Re: Limit upload plugin for cpg1.6.x
Post by: Αndré on November 28, 2018, 09:18:37 am
I'll fix that soon.
Title: Re: Re: Limit upload plugin for cpg1.6.x
Post by: lurkalot on November 28, 2018, 09:25:10 am
I'll fix that soon.

Thanks Andre.
Title: Re: Limit upload plugin for cpg1.6.x
Post by: Αndré on November 28, 2018, 10:48:35 am
There's nothing to fix in the plugin, as the config values will be deleted when uninstalling the plugin (that function existed since the very first version):
Code: [Select]
$thisplugin->add_action('plugin_uninstall', 'limit_upload_uninstall');

function limit_upload_uninstall () {
    global $CONFIG;
    cpg_db_query("DELETE FROM {$CONFIG['TABLE_CONFIG']} WHERE name = 'limit_upload_upload_limit'");
    cpg_db_query("DELETE FROM {$CONFIG['TABLE_CONFIG']} WHERE name = 'limit_upload_time_limit'");

    return true;
}

For whatever reason they haven't been deleted in your gallery (maybe missing permissions to use the DELETE command?). To get the plugin installed, either delete the rows "limit_upload_upload_limit" and "limit_upload_time_limit" from your config table with phpMyAdmin, or adjust those lines in codebase.php:
Code: [Select]
    cpg_db_query("INSERT INTO {$CONFIG['TABLE_CONFIG']} (name, value) VALUES ('limit_upload_upload_limit', '-1')");
    cpg_db_query("INSERT INTO {$CONFIG['TABLE_CONFIG']} (name, value) VALUES ('limit_upload_time_limit', 'total')");
(either commend them out or replace INSERT with REPLACE).
Title: Re: Limit upload plugin for cpg1.6.x
Post by: lurkalot on November 28, 2018, 08:59:02 pm
Thanks, I went with the delete table option, and now installed fine.  Not idea why it wouldn't delete those table when I uninstalled the old plugin though, I haven't had this problem with anything else I'm aware of.

One of those little mysteries I guess.  Anyway with your help it's sorted.  ;)