You are here

function imagepicker_get_all_groups in Image Picker 6.2

Same name and namespace in other branches
  1. 7 imagepicker.module \imagepicker_get_all_groups()
2 calls to imagepicker_get_all_groups()
imagepicker_block_form in ./imagepicker.module
imagepicker_settings_form in ./imagepicker.admin.inc
Function to display the imagepicker admin settings form

File

./imagepicker.module, line 812
Enables permitted roles to upload images for insertion into configured nodes.

Code

function imagepicker_get_all_groups($override = NULL) {
  $public = FALSE;
  if ($override == NULL) {
    $public = variable_get('imagepicker_galleryblocks_public', 0);
  }
  else {
    $public = $override;
  }
  $data = FALSE;
  $sql = "SELECT gid, group_name FROM {imagepicker_user_groups}";
  if ($public) {
    $sql .= " WHERE public=1";
  }
  $result = db_query($sql);
  while ($row = db_fetch_array($result)) {
    $result2 = db_query("SELECT count(DISTINCT gi.img_id) AS ct FROM {imagepicker_group_images} gi, {imagepicker_user_groups} g WHERE g.gid = gi.gid AND g.gid = %d", array(
      $row['gid'],
    ));
    $row2 = db_fetch_array($result2);
    $totcount = $row2['ct'];
    $data[$row['gid']] = $row['group_name'] . ' - ' . format_plural($totcount, '1 image', '@count images');
  }
  return $data;
}