You are here

function _imagepicker_browse in Image Picker 5.2

Same name and namespace in other branches
  1. 5 imagepicker.module \_imagepicker_browse()
  2. 6.2 imagepicker.functions.inc \_imagepicker_browse()
  3. 7 imagepicker.functions.inc \_imagepicker_browse()
3 calls to _imagepicker_browse()
imagepicker_admin_images in ./imagepicker.module
imagepicker_browse in ./imagepicker.module
imagepicker_user_browse in ./imagepicker.module
main thumbnails page in my imagepicker

File

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

Code

function _imagepicker_browse($src = "iframe", $account = FALSE) {
  if ($account) {
    $user = $account;
    $userdir = array(
      'uid' => $user->uid,
      'name' => $user->name,
    );
  }
  else {
    global $user;
    $userdir = FALSE;
  }

  // if there are groups
  $gid = 0;
  if (_imagepicker_has_groups($user)) {
    $gids = imagepicker_get_user_group_state(1, $user);
    $gid = $gids[0];
    if ($account) {
      $gid = variable_get('imagepicker_currentgroup', 0);
    }
  }
  $how_many = variable_get('imagepicker_advanced_browser_page', 25);
  $default_order = variable_get('imagepicker_default_browser_order', 'img_id DESC');
  if ($account && $src == 'admin') {
    $order = variable_get('imagepicker_browser_order', $default_order);
  }
  else {
    $order = $user->imagepicker_browser_order ? $user->imagepicker_browser_order : $default_order;
  }

  // filter by selected group
  if ($gid) {
    $sql = "SELECT i.img_id, i.uid, i.img_name, i.img_title, i.img_description, i.img_date\n      FROM {imagepicker} i, {imagepicker_group_images} g\n      WHERE i.uid = %d AND i.img_id = g.img_id AND g.gid = %d\n      ORDER BY i.{$order}";
    $result = pager_query($sql, $how_many, 0, NULL, array(
      $user->uid,
      $gid,
    ));
  }
  else {
    $sql = "SELECT * FROM {imagepicker} WHERE uid=%d ORDER BY {$order}";
    $result = pager_query($sql, $how_many, 0, NULL, array(
      $user->uid,
    ));
  }
  $content_main = _imagepicker_thumbs_display($result, FALSE, $src);
  if (empty($content_main)) {
    return '<div class="messages">' . t('You do not have any uploaded images') . '</div>';
  }
  $content_head = "";
  if (variable_get('imagepicker_show_browse_order_form', 1)) {
    $content_head .= drupal_get_form('imagepicker_browse_order_form', $user, $src == 'admin' ? TRUE : FALSE);
  }
  if (_imagepicker_has_groups($user) && imagepicker_has_grouplist($user)) {

    // add groups select here
    $content_head .= drupal_get_form('imagepicker_browse_groups_form', $account ? $user : FALSE);
  }
  if ($src == "account" || $src == "admin") {
    $content_head .= '<div class="imgp_help">' . t('Hold the mouse over an image to view Name, Title and Description, Click on it to view.') . '</div>';
  }
  else {
    $content_head .= '<div class="imgp_help">' . t('Hold the mouse over an image to view Name, Title and Description, Click on it to use.') . '</div>';
  }
  $content = $content_head . $content_main;
  return $content;
}