I searched the board for this MOD, but all Versions I found where allready outdated and not working,
so I decided to write it myself.
This MOD adds an additional field to the Category forms in the Admin Panel in which you can insert
a number(Integer). This number is the picture upload limit for all users, who try to upload in this category.
The default Limit is 1000 so you don't need to worry about existent categories.
I am using Version 1.7.6 and haven't tested it with other environments.
I don't think that this is the best way to program this feature but it works just fine with me. So
feel free to use or modify it to your needs.
Here we go!
lang/english/main.php
search for:
$lang['no_permission'] = "You are not logged in or do not have permissions to enter this site!";
add after:
$lang['uploadlimit_exceeded'] ="You can not upload more images!";
member.php
search for:
if ($action == "uploadform") {
if ($cat_id != 0 && (!isset($cat_cache[$cat_id]) || !check_permission("auth_upload", $cat_id))) {
show_error_page($lang['no_permission']);
exit;
}
add before:
function check_picture_limit($cat_cache, $cat_id, $user_id) {
$uploadlimit=$cat_cache[$cat_id]['auth_uploadlimit'];
echo $uploadlimit;
//Count validated pictures
$sql = "SELECT image_id FROM ".IMAGES_TABLE." WHERE cat_id=".$cat_id." AND user_id=".$user_id."";
$result = mysql_query($sql);
$images_user = mysql_num_rows($result);
//Count not validated pictures
$sql = "SELECT image_id FROM ".IMAGES_TEMP_TABLE." WHERE cat_id=".$cat_id." AND user_id=".$user_id."";
$result = mysql_query($sql);
$images_user_temp = mysql_num_rows($result);
$images_user_total=$images_user+$images_user_temp;
if($images_user_total >= $uploadlimit)
{
return false;
}
else
{
return true;
}
}
add after:
if( $user_info['user_level'] != ADMIN && !check_picture_limit($cat_cache, $cat_id, $user_info['user_id']))
{
show_error_page($lang['uploadlimit_exceeded']);
exit;
}
global.php
search for:
$sql = "SELECT cat_id, cat_name, cat_description, cat_parent_id, cat_hits, cat_order, auth_viewcat, auth_viewimage, auth_download, auth_upload, auth_directupload, auth_vote, auth_sendpostcard, auth_readcomment, auth_postcomment
replace with:
$sql = "SELECT cat_id, cat_name, cat_description, cat_parent_id, cat_hits, cat_order, auth_viewcat, auth_viewimage, auth_download, auth_upload, auth_directupload, auth_vote, auth_sendpostcard, auth_readcomment, auth_postcomment, auth_uploadlimit
admin/categories.php
search for:
show_table_separator($permission_headline, 2);
foreach ($access_field_array as $key => $val) {
show_access_select($lang[$key], $key, $val);
}
add after:
echo "<tr class=\"".get_row_bg()."\" valign=\"top\">\n<td><p class=\"rowtitle\">".$lang['auth_uploadlimit']."</p></td>\n";
echo"<td><input type=\"text\" value=\"\" name=\"auth_uploadlimit\" size=\"30\"/></td>";
search 2x (savecat and updatecat) for :
$auth_postcomment = $HTTP_POST_VARS['auth_postcomment'];
add after:
$auth_uploadlimit = $HTTP_POST_VARS['auth_uploadlimit'];
search for:
$sql = "INSERT INTO ".CATEGORIES_TABLE."
(cat_name, cat_description, cat_parent_id, cat_order, auth_viewcat, auth_viewimage, auth_download, auth_upload, auth_directupload, auth_vote, auth_sendpostcard, auth_readcomment, auth_postcomment)
VALUES
('$cat_name', '$cat_description', $cat_parent_id, $cat_order, $auth_viewcat, $auth_viewimage, $auth_download, $auth_upload, $auth_directupload, $auth_vote, $auth_sendpostcard, $auth_readcomment, $auth_postcomment)";
replace with:
$sql = "INSERT INTO ".CATEGORIES_TABLE."
(cat_name, cat_description, cat_parent_id, cat_order, auth_viewcat, auth_viewimage, auth_download, auth_upload, auth_directupload, auth_vote, auth_sendpostcard, auth_readcomment, auth_postcomment, auth_uploadlimit)
VALUES
('$cat_name', '$cat_description', $cat_parent_id, $cat_order, $auth_viewcat, $auth_viewimage, $auth_download, $auth_upload, $auth_directupload, $auth_vote, $auth_sendpostcard, $auth_readcomment, $auth_postcomment, $auth_uploadlimit)";
search for:
$sql = "UPDATE ".CATEGORIES_TABLE."
SET cat_name = '$cat_name', cat_description = '$cat_description', cat_parent_id = $cat_parent_id, cat_order = $cat_order, cat_hits = $cat_hits, auth_viewcat = $auth_viewcat, auth_viewimage = $auth_viewimage, auth_download = $auth_download, auth_upload = $auth_upload, auth_directupload = $auth_directupload, auth_vote = $auth_vote, auth_sendpostcard = $auth_sendpostcard, auth_readcomment = $auth_readcomment, auth_postcomment = $auth_postcomment
WHERE cat_id = $cat_id";
replace with:
$sql = "UPDATE ".CATEGORIES_TABLE."
SET cat_name = '$cat_name', cat_description = '$cat_description', cat_parent_id = $cat_parent_id, cat_order = $cat_order, cat_hits = $cat_hits, auth_viewcat = $auth_viewcat, auth_viewimage = $auth_viewimage, auth_download = $auth_download, auth_upload = $auth_upload, auth_directupload = $auth_directupload, auth_vote = $auth_vote, auth_sendpostcard = $auth_sendpostcard, auth_readcomment = $auth_readcomment, auth_postcomment = $auth_postcomment, auth_uploadlimit=$auth_uploadlimit
WHERE cat_id = $cat_id";
search for:
$sql = "SELECT cat_name, cat_description, cat_parent_id, cat_hits, cat_order, auth_viewcat, auth_viewimage, auth_download, auth_upload, auth_directupload, auth_vote, auth_sendpostcard, auth_readcomment, auth_postcomment
FROM ".CATEGORIES_TABLE."
WHERE cat_id = $cat_id";
replace with:
$sql = "SELECT cat_name, cat_description, cat_parent_id, cat_hits, cat_order, auth_viewcat, auth_viewimage, auth_download, auth_upload, auth_directupload, auth_vote, auth_sendpostcard, auth_readcomment, auth_postcomment, auth_uploadlimit
FROM ".CATEGORIES_TABLE."
WHERE cat_id = $cat_id";
search for:
foreach ($access_field_array as $key => $val) {
show_access_select($lang[$key], $key, $cat_row[$key]);
}
add after:
echo "<tr class=\"".get_row_bg()."\" valign=\"top\">\n<td><p class=\"rowtitle\">".$lang['auth_uploadlimit']."</p></td>\n";
echo"<td><input type=\"text\" value=\"".$cat_row['auth_uploadlimit']."\" name=\"auth_uploadlimit\" size=\"30\"/></td>";
lang/englisch/admin.php
search for:
$lang['auth_postcomment'] = "Post Comment";
add after:
$lang['auth_uploadlimit'] = "Picture uploadlimit for User";
Add Field in the Database:
ALTER TABLE `4images_categories` ADD `auth_uploadlimit` INT( 10 ) NOT NULL DEFAULT '1000';
or take the Installation script
I hope I didn't miss anything and hope this works for you as well.