You are here

function library_get_action_links in Library 6

Same name and namespace in other branches
  1. 5.2 library.module \library_get_action_links()
  2. 6.2 library.module \library_get_action_links()
  3. 7 library.module \library_get_action_links()
3 calls to library_get_action_links()
library_history in ./library.pages.inc
Menu callback; show the transaction history of a single node.
library_overdue_items in ./library.pages.inc
theme_library_items in ./library.theme.inc

File

./library.module, line 1150

Code

function library_get_action_links($item) {
  global $user;
  $aids = array();
  $secondary_aids = array();
  $actions = array();
  $secondary_actions = array();
  if ($item['in_circulation'] == LIBRARY_REFERENCE_ONLY) {
    $reference_actions = variable_get('library_links_display_reference', array());
    foreach ($reference_actions as $aid) {
      $aids[] = $aid;
    }
  }
  elseif ($item['library_status'] == LIBRARY_ITEM_AVAILABLE) {
    $available_actions = variable_get('library_links_display_available', array());
    foreach ($available_actions as $aid) {
      $aids[] = $aid;
    }
  }
  else {
    $unavailable_actions = variable_get('library_links_display_unavailable', array());
    foreach ($unavailable_actions as $aid) {
      $aids[] = $aid;
    }
  }
  $actions = library_actions($aids, $user);
  $action_links = array();
  $patron_id = '';
  if (!user_access('view patron content')) {
    $user_patron = patron_load_by_uid($user->uid);
    if (is_object($user_patron)) {
      $patron_id = $user_patron->nid;
    }
  }
  foreach ($actions as $aid => $action) {
    if (($action['status_change'] == LIBRARY_ACTION_TYPE_AVAILABLE || $item['library_status'] == LIBRARY_ITEM_UNAVAILABLE) && !empty($item['last_patron_id'])) {
      if (empty($patron_id) || $item['last_patron_id'] == $patron_id) {
        $action_links[] = l($action['name'], 'library-items/transaction/' . $aid . '/' . $item['id'] . '/' . $item['last_patron_id']);
      }
    }
    else {
      $action_links[] = l($action['name'], 'library-items/transaction/' . $aid . '/' . $item['id']);
    }
  }
  return $action_links;
}