You are here

function _imagepicker_get_img in Image Picker 7

Same name and namespace in other branches
  1. 5.2 imagepicker.module \_imagepicker_get_img()
  2. 5 imagepicker.module \_imagepicker_get_img()
  3. 6.2 imagepicker.functions.inc \_imagepicker_get_img()
11 calls to _imagepicker_get_img()
imagepicker_adminview in ./imagepicker.admin.inc
imagepicker_admin_images in ./imagepicker.admin.inc
imagepicker_copy_form_submit in ./imagepicker.functions.inc
Function to submit the copy form
imagepicker_copy_form_validate in ./imagepicker.functions.inc
Function to validate the copy form
imagepicker_image_select in ./imagepicker.functions.inc

... See full list

File

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

Code

function _imagepicker_get_img($img_id, $checkuser = TRUE, $account = FALSE) {
  if (is_object($account)) {
    $user = $account;
  }
  else {
    global $user;
  }
  $query = db_select('imagepicker', 'i');
  $query
    ->fields('i', array(
    'img_id',
    'uid',
    'img_name',
    'img_title',
    'img_description',
    'img_date',
  ));
  $query
    ->range(0, 1);
  $query
    ->condition('img_id', $img_id);
  $img = $query
    ->execute()
    ->fetchObject();
  if (count($img)) {
    if ($img->uid != $user->uid && $checkuser) {
      drupal_set_message(t('This image does not belong to you.'), 'error');
      watchdog('imagepicker', 'User uid %d attempted to edit image belonging to user uid %d', array(
        $user->uid,
        $img->uid,
      ), WATCHDOG_WARNING);
      return FALSE;
    }

    // get user name
    $query = db_select('users', 'u');
    $query
      ->fields('u', array(
      'name',
    ));
    $query
      ->condition('uid', $img->uid);
    $name = $query
      ->execute()
      ->fetchObject();
    $img->name = $name;
    return $img;
  }
  return FALSE;
}