You are here

function _imagepicker_get_img in Image Picker 5.2

Same name and namespace in other branches
  1. 5 imagepicker.module \_imagepicker_get_img()
  2. 6.2 imagepicker.functions.inc \_imagepicker_get_img()
  3. 7 imagepicker.functions.inc \_imagepicker_get_img()
9 calls to _imagepicker_get_img()
imagepicker_admin_images in ./imagepicker.module
imagepicker_admin_view in ./imagepicker.module
imagepicker_edit_form_submit in ./imagepicker.module
Submit edit form
imagepicker_image_delete in ./imagepicker.module
imagepicker_image_select in ./imagepicker.module

... See full list

File

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

Code

function _imagepicker_get_img($img_id, $checkuser = TRUE, $account = FALSE) {
  if ($account) {
    $user = $account;
  }
  else {
    global $user;
  }
  $result = db_query_range("SELECT * FROM {imagepicker} WHERE img_id = '%d'", $img_id, 0, 1);
  $img = db_fetch_array($result);
  if (count($img)) {
    if ($img['uid'] != $user->uid && $checkuser) {
      drupal_set_message(t('This image does not belong to you.'), 'error');
      watchdog('imagepicker', t('User uid !uid1 attempted to edit image belonging to user uid !uid2', array(
        '!uid1' => $user->uid,
        '!uid2' => $img['uid'],
      )), WATCHDOG_WARNING);
      return FALSE;
    }
    return $img;
  }
  return FALSE;
}