You are here

function imagepicker_groups_list in Image Picker 5

Same name and namespace in other branches
  1. 5.2 imagepicker.module \imagepicker_groups_list()
  2. 6.2 imagepicker.group.inc \imagepicker_groups_list()
  3. 7 imagepicker.group.inc \imagepicker_groups_list()
2 calls to imagepicker_groups_list()
imagepicker_groups in ./imagepicker.module
imagepicker_user_groups in ./imagepicker.module

File

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

Code

function imagepicker_groups_list($myaccount = FALSE, $account = FALSE) {

  // show a table of the lists belonging to the current user
  if ($account) {
    $user = $account;
  }
  else {
    global $user;
  }
  if ($myaccount) {
    $editpath = 'user/' . $user->uid . '/imagepicker/groups/edit/';
    $deletepath = 'user/' . $user->uid . '/imagepicker/groups/delete/';
  }
  else {
    $editpath = "imagepicker/groups/edit/";
    $deletepath = "imagepicker/groups/delete/";
  }
  $output = "";
  $how_many = variable_get('imagepicker_rows_per_page', 25);
  $sql = "SELECT * FROM {imagepicker_user_groups} WHERE uid=" . $user->uid . " ORDER BY group_name";
  $result = pager_query($sql, $how_many);
  $rows = array();
  $totcount = 0;
  $enabledlist = imagepicker_get_enabled_group();
  while ($row = db_fetch_array($result)) {
    $count = imagepicker_get_group_images_count($row['gid']);
    $totcount += $count;
    $row_data = array(
      check_plain($row['group_name']),
      check_plain($row['group_description']),
      $count,
      $enabledlist && in_array($row['gid'], $enabledlist) ? t('selected') : '',
      l(t('Edit'), $editpath . $row['gid']),
      l(t('Delete'), $deletepath . $row['gid']),
    );
    $rows[] = $row_data;
  }
  if (count($rows)) {
    $header = array(
      t('Group name'),
      t('Description'),
      t('No. images'),
      t('State'),
      array(
        'data' => t('Actions'),
        'colspan' => 2,
      ),
    );
    $output .= '<div class="imgp_groups_list">' . theme('table', $header, $rows) . theme('pager', NULL, $how_many) . "</div>";
    $allcount = _imagepicker_user_has_img();
    $output .= '<div class="imgp_groups_info">';
    $output .= t('Total number of images: %allcount', array(
      '%allcount' => $allcount,
    )) . '<br/>';
    $output .= t('Total number of grouped images: %totcount', array(
      '%totcount' => $totcount,
    )) . '<br/>';
    $output .= t('Total number of ungrouped images: %lcount', array(
      '%lcount' => $allcount - $totcount,
    )) . '<br/>';
    $output .= '</div>';
    return $output;
  }
  else {
    return '<div class="messages">' . t('No groups found.') . '</div>';
  }
}