You are here

function merci_load_item_settings in MERCI (Manage Equipment Reservations, Checkout and Inventory) 7.2

Same name and namespace in other branches
  1. 6.2 includes/api.inc \merci_load_item_settings()
  2. 7.3 merci_migrate/merci_items.inc \merci_load_item_settings()
8 calls to merci_load_item_settings()
merci_add_reservation_items in includes/api.inc
Adds items to reservation on creation/update.
merci_add_settings_form in ./merci.module
merci_check_content_type_restrictions in includes/api.inc
Checks for reservation restrictions for a content type.
merci_form_alter in ./merci.module
Implementation of hook_form_alter().
merci_is_item_reservable in includes/database.inc

... See full list

File

includes/api.inc, line 971
MERCI - Managed Equipment Reservation Checkout and Inventory

Code

function merci_load_item_settings($object) {

  // Allow either a node object or type name to be passed in.
  if (is_string($object)) {
    $type = $object;
  }
  else {
    $node = (array) $object;
    $type = $node['type'];
  }

  // Initialize here in case there is no nid.
  $item_settings = array();

  // Settings from the content type edit page.
  $content_settings = merci_content_types($type);
  if (isset($node['nid'])) {

    // Settings common to all merci item nodes.
    // resource or bucket.
    $merci_type = isset($content_settings['merci_type_setting']) ? $content_settings['merci_type_setting'] : '';
    $vid = $node['vid'];
    $item_settings = merci_reservation_item_node_settings($vid);
    switch ($merci_type) {
      case 'bucket':

        // TODO: move to seperate module.
        if ($item_settings['merci_sub_type'] == MERCI_SUB_TYPE_RESERVATION) {
          unset($item_settings['merci_default_availability']);
          unset($item_settings['merci_item_status']);
          $item_settings += merci_bucket_node_settings($vid);
        }
        break;
      case 'resource':

        // TODO: move to seperate module.
        $item_settings += merci_resource_node_settings($vid);
        break;
    }
  }
  return (object) ($item_settings + $content_settings);
}