Changeset 9452 for extensions


Ignore:
Timestamp:
Mar 1, 2011, 3:37:14 PM (13 years ago)
Author:
plg
Message:

bug fixed: deleting a user also deletes upload permissions linked to this user and reject pending photos added by this user

Location:
extensions/community
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • extensions/community/include/functions_community.inc.php

    r9444 r9452  
    118118}
    119119
     120function community_reject_pendings($image_ids)
     121{
     122  if (count($image_ids) == 0)
     123  {
     124    return;
     125  }
     126 
     127  $query = '
     128DELETE
     129  FROM '.COMMUNITY_PENDINGS_TABLE.'
     130  WHERE image_id IN ('.implode(',', $image_ids).')
     131;';
     132  pwg_query($query);
     133
     134  // needs to be in administration panel
     135  delete_elements($image_ids, true);
     136}
     137
     138function community_reject_user_pendings($user_id)
     139{
     140  $query = '
     141SELECT
     142    image_id
     143  FROM '.COMMUNITY_PENDINGS_TABLE.' AS cp
     144    INNER JOIN '.IMAGES_TABLE.' AS i ON i.id = cp.image_id
     145  WHERE state != \'validated\'
     146    AND added_by = '.$user_id.'
     147;';
     148  $result = pwg_query($query);
     149  $image_ids = array();
     150  while ($row = pwg_db_fetch_assoc($result))
     151  {
     152    array_push($image_ids, $row['image_id']);
     153  }
     154
     155  community_reject_pendings($image_ids);
     156}
     157
    120158?>
  • extensions/community/main.inc.php

    r9444 r9452  
    1717
    1818global $prefixeTable;
    19 define('COMMUNITY_TABLE', $prefixeTable.'community');
    2019define('COMMUNITY_PERMISSIONS_TABLE', $prefixeTable.'community_permissions');
    2120define('COMMUNITY_PENDINGS_TABLE', $prefixeTable.'community_pendings');
     
    148147  $query = '
    149148DELETE
    150   FROM '.COMMUNITY_TABLE.'
     149  FROM '.COMMUNITY_PERMISSIONS_TABLE.'
    151150  WHERE user_id = '.$user_id.'
    152151;';
    153152  pwg_query($query);
     153
     154  community_reject_user_pendings($user_id);
    154155}
    155156
Note: See TracChangeset for help on using the changeset viewer.