Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - mentrid

Pages: [1]
1
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:
Code: [Select]
$lang['no_permission'] = "You are not logged in or do not have permissions to enter this site!";
add after:
Code: [Select]
$lang['uploadlimit_exceeded'] ="You can not upload more images!";

member.php

search for:
Code: [Select]
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:
Code: [Select]
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:
Code: [Select]
  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:
Code: [Select]
$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:
Code: [Select]
$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:
Code: [Select]
show_table_separator($permission_headline, 2);
  foreach ($access_field_array as $key => $val) {
    show_access_select($lang[$key], $key, $val);
  }

add after:
Code: [Select]
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 :
Code: [Select]
$auth_postcomment = $HTTP_POST_VARS['auth_postcomment'];
add after:
Code: [Select]
$auth_uploadlimit = $HTTP_POST_VARS['auth_uploadlimit'];
search for:
Code: [Select]
$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:
Code: [Select]
    $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:
Code: [Select]
$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:
Code: [Select]
$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:
Code: [Select]
$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:
Code: [Select]
$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:
Code: [Select]
foreach ($access_field_array as $key => $val) {
    show_access_select($lang[$key], $key, $cat_row[$key]);
  }

add after:
Code: [Select]
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:
Code: [Select]
$lang['auth_postcomment'] = "Post Comment";
add after:
Code: [Select]
$lang['auth_uploadlimit'] = "Picture uploadlimit for User";

Add Field in the Database:
Code: [Select]
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.

2
I tried this mod in combination with
http://www.4homepages.de/forum/index.php?topic=20496.0
and it works just great on version 1.76.

If you use this mod http://www.4homepages.de/forum/index.php?topic=7700.msg22313#msg22313
to upload the big images into a seperate folder you should consider making this update, too:


admin/images.php
Search for:
Code: [Select]
if (@unlink(MEDIA_PATH."/".$image_row['cat_id']."/".$image_row['image_media_file'])) {
Replace with:
Code: [Select]
if (@unlink(MEDIA_PATH."/".$image_row['cat_id']."/".$image_row['image_media_file']) &&
            @unlink(MEDIA_PATH."/".$image_row['cat_id']."/big/".$image_row['image_media_file'])) {

This will also delete the big image from your server when you delete an image in the ACP.
Else you just delete the small file.

Pages: [1]