You are here

function _imagepicker_user_has_grouped_img in Image Picker 7

Same name and namespace in other branches
  1. 5.2 imagepicker.module \_imagepicker_user_has_grouped_img()
  2. 6.2 imagepicker.functions.inc \_imagepicker_user_has_grouped_img()
1 call to _imagepicker_user_has_grouped_img()
imagepicker_group_stats in ./imagepicker.functions.inc
statistics

File

./imagepicker.functions.inc, line 1309
@author Bob Hutchinson http://drupal.org/user/52366 @copyright GNU GPL

Code

function _imagepicker_user_has_grouped_img($public = 'all', $account = FALSE) {
  if ($account) {
    $user = $account;
  }
  else {
    global $user;
  }
  $query = db_select('imagepicker_group_images', 'i');
  $query
    ->addExpression('COUNT(DISTINCT i.img_id)', 'ct');
  $query
    ->join('imagepicker_user_groups', 'g', 'i.gid = g.gid');
  $query
    ->condition('g.uid', $user->uid);
  if ($public == 'yes') {
    $query
      ->condition('g.public', 1);
  }
  elseif ($public == 'no') {
    $query
      ->condition('g.public', 0);
  }
  $row = $query
    ->execute()
    ->fetchObject();
  return $row->ct;
}