Ignore:
Timestamp:
Jun 4, 2013, 12:55:59 PM (11 years ago)
Author:
plg
Message:

manage quota (number of photos, disk usage)

File:
1 edited

Legend:

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

    r10770 r23037  
    5252    'upload_categories' => array(),
    5353    'permission_ids' => array(),
     54    'nb_photos' => 0,
     55    'storage' => 0,
    5456    );
    5557 
     
    6870    category_id,
    6971    recursive,
    70     create_subcategories
     72    create_subcategories,
     73    nb_photos,
     74    storage
    7175  FROM '.COMMUNITY_PERMISSIONS_TABLE.'
    7276  WHERE (type = \'any_visitor\')';
     
    120124      }
    121125    }
     126
     127    if ($return['nb_photos'] != -1)
     128    {
     129      if (empty($row['nb_photos']) or -1 == $row['nb_photos'])
     130      {
     131        // that means "no limit"
     132        $return['nb_photos'] = -1;
     133      }
     134      elseif ($row['nb_photos'] > $return['nb_photos'])
     135      {
     136        $return['nb_photos'] = $row['nb_photos'];
     137      }
     138    }
     139   
     140    if ($return['storage'] != -1)
     141    {
     142      if (empty($row['storage']) or -1 == $row['storage'])
     143      {
     144        // that means "no limit"
     145        $return['storage'] = -1;
     146      }
     147      elseif ($row['storage'] > $return['storage'])
     148      {
     149        $return['storage'] = $row['storage'];
     150      }
     151    }
    122152  }
    123153
     
    126156    $return ['upload_whole_gallery'] = true;
    127157    $return ['create_whole_gallery'] = true;
     158    $return['nb_photos'] = -1;
     159    $return['storage'] = -1;
    128160  }
    129161
     
    270302  }
    271303}
     304
     305function community_get_user_limits($user_id)
     306{
     307  // how many photos and storage for this user?
     308  $query = '
     309SELECT
     310    COUNT(id) AS nb_photos,
     311    IFNULL(FLOOR(SUM(filesize)/1024), 0) AS storage
     312  FROM '.IMAGES_TABLE.'
     313  WHERE added_by = '.$user_id.'
     314;';
     315  return pwg_db_fetch_assoc(pwg_query($query));
     316}
    272317?>
Note: See TracChangeset for help on using the changeset viewer.