You are here

function _photos_ajax_helper in Album Photos 7.3

Ajax helper, perform different ajax requests.

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

File

./photos.module, line 306
Implementation of photos.module.

Code

function _photos_ajax_helper($action) {
  switch ($action) {
    case 'sort':
      $nid = isset($_POST['pid']) ? $_POST['pid'] : 0;
      $uid = isset($_POST['uid']) ? $_POST['uid'] : 0;
      $type = isset($_POST['type']) ? $_POST['type'] : 0;
      $new_order = isset($_POST['order']) ? $_POST['order'] : array();
      module_load_include('inc', 'photos', 'inc/photos.edit');
      $message = '';
      if (!empty($new_order) && is_array($new_order)) {
        if ($type == 'images') {
          if ($nid) {
            $message = photos_edit_sort_save($new_order, $nid);
          }
        }
        elseif ($type == 'albums') {
          if ($uid) {

            // Save sort order for albums.
            $message = photos_edit_sort_albums_save($new_order, $uid);
          }
        }
        elseif ($type == 'sub_album') {

          // Save sort order for images in sub-albums.
          if ($nid) {
            $message = photos_edit_sort_subalbums_save($new_order, $nid);
          }
        }
      }
      print $message;
      drupal_exit();
      break;
  }

  // If no action is set go to front page.
  drupal_goto('<front>');
}