You are here

function photos_edit_update in Album Photos 7.3

Same name and namespace in other branches
  1. 6.2 inc/photos.edit.inc \photos_edit_update()

Ajax edit image.

1 string reference to 'photos_edit_update'
photos_menu in ./photos.module
Implements hook_menu().

File

inc/photos.edit.inc, line 1020
Handles uploading and editing images.

Code

function photos_edit_update($fid = NULL) {
  drupal_add_http_header('Content-Type', 'text/plain;');
  $value = trim($_POST['value']);
  $id = check_plain($_POST['id']);
  if (strstr($id, 'title')) {
    $switch = 'title';
    $fid = str_replace('photos-image-edit-title-', '', $id);
  }
  elseif (strstr($id, 'des')) {
    $switch = 'des';
    $fid = str_replace('photos-image-edit-des-', '', $id);
  }

  // Validate token and check user image edit permissions.
  if (drupal_valid_token($_POST['token'], 'image_edit_token') && _photos_access('imageEdit', $fid)) {
    switch ($switch) {
      case 'title':
        db_update('photos_image')
          ->fields(array(
          'title' => $value,
        ))
          ->condition('fid', $fid)
          ->execute();
        echo check_plain($value);
        break;
      case 'des':
        db_update('photos_image')
          ->fields(array(
          'des' => $value,
        ))
          ->condition('fid', $fid)
          ->execute();
        echo check_plain($value);
        break;
      case 'del':
    }
  }
}