Author Topic: [1.7 - 1.7.6] User comments count not updated when image(s) deleted  (Read 11338 times)

0 Members and 1 Guest are viewing this topic.

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
When images deleted along with the comments the comments count per user is not being updated. Thanks to alekinna for finding and providing the fix.

In admin/categories.php
Find TWO times:
$sql "DELETE FROM ".COMMENTS_TABLE."

Insert above EACH:
  global $user_table_fields;
  if (!empty(
$user_table_fields['user_comments']))
  {
    
$sql "SELECT user_id
            FROM "
.COMMENTS_TABLE."
            WHERE image_id IN (
$image_ids_sql) AND user_id <> ".GUEST;
    
$result $site_db->query($sql);
  
    while (
$row $site_db->fetch_array($result))
    {
      
$sql "UPDATE ".USERS_TABLE."
              SET "
.get_user_table_field("""user_comments")." = ".get_user_table_field("""user_comments")." - 1
              WHERE "
.get_user_table_field("""user_id")." = ".$row['user_id'];
      
$site_db->query($sql);
    }
  }



Open admin/images.php
Find:function delete_images($image_ids$delfromserver 1) {
Insert below:
  global $user_table_fields;
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)