You are here

function imagepicker_admin_groups_list in Image Picker 6.2

Same name and namespace in other branches
  1. 5.2 imagepicker.module \imagepicker_admin_groups_list()
  2. 7 imagepicker.admin.inc \imagepicker_admin_groups_list()
1 call to imagepicker_admin_groups_list()
imagepicker_admin_groups in ./imagepicker.admin.inc

File

./imagepicker.admin.inc, line 818
admin settings functions

Code

function imagepicker_admin_groups_list($label = "") {
  $how_many = variable_get('imagepicker_rows_per_page', 25);
  $use_icons = variable_get('imagepicker_use_icons', 1);
  $header = array(
    array(
      'data' => t('Group Name'),
      'field' => 'g.group_name',
    ),
    array(
      'data' => t('User Name'),
      'field' => 'u.name',
    ),
    array(
      'data' => t('Status'),
      'field' => 'g.public',
    ),
    array(
      'data' => t('Images'),
      'field' => 'ct',
    ),
    array(
      'data' => t('Actions'),
      'colspan' => 2,
    ),
  );
  $cols = 6;
  $rowcount = 0;
  $rows = '';
  $countsql = "SELECT COUNT(g.gid) FROM {imagepicker_user_groups} g JOIN {users} u USING(uid)";
  $sql = "SELECT g.gid, g.uid, g.group_name, g.group_description, g.state, g.public, u.name\n    FROM {imagepicker_user_groups} g JOIN  {users} u USING(uid)";
  $sql .= tablesort_sql($header);
  $result = pager_query($sql, $how_many, 0, $countsql);
  while ($row = db_fetch_array($result)) {
    $editpath = IMAGEPICKER_ADMIN_PATH . '/groups/user/' . $row['uid'] . '/edit/' . $row['gid'];
    $deletepath = IMAGEPICKER_ADMIN_PATH . '/groups/user/' . $row['uid'] . '/delete/' . $row['gid'];
    $imgct = imagepicker_group_images_count($row['gid']);
    $row_data = array(
      $row['group_name'],
      l($row['name'], IMAGEPICKER_ADMIN_PATH . '/groups/user/' . $row['uid']),
      $row['public'] ? t('Public') : t('Private'),
      $imgct ? l(format_plural($imgct, '1 image', '@count images'), IMAGEPICKER_ADMIN_PATH . '/groups/user/' . $row['uid'] . '/browse/' . $row['gid']) : t('No images'),
      $use_icons ? _imagepicker_get_icon('edit', $editpath, array(
        'title' => t('Edit'),
      )) : l(t('Edit'), $editpath),
      $use_icons ? _imagepicker_get_icon('delete', $deletepath, array(
        'title' => t('Delete'),
      )) : l(t('Delete'), $deletepath),
    );
    $rows[] = $row_data;
    $rowcount++;
  }
  $pref = '';
  $suff = '';
  return theme('imagepicker_list', $header, $rows, $how_many, t('No groups found.'), $pref, $suff, $label, $cols);
}