You are here

function bat_api_services_add_unit in Booking and Availability Management API 7

Same name and namespace in other branches
  1. 7.2 bat_api.module \bat_api_services_add_unit()

Create a new unit.

Parameters

$name:

$type:

$default_state:

$bookable:

$status:

1 string reference to 'bat_api_services_add_unit'
bat_api_services_resources in ./bat_api.module
Implements hook_services_resources().

File

./bat_api.module, line 428

Code

function bat_api_services_add_unit($name, $type, $default_state, $bookable, $status) {
  $return = new stdClass();
  $return->sessid = session_id();
  if (rooms_unit_type_load($type) !== FALSE && $name != '') {
    $unit = rooms_unit_create(array(
      'name' => $name,
      'type' => $type,
      'default_state' => $default_state,
      'bookable' => $bookable,
      'status' => $status,
      'uid' => 0,
      'created' => REQUEST_TIME,
      'changed' => REQUEST_TIME,
    ));
    rooms_unit_save($unit);
    $return->unit_id = $unit->unit_id;
    $return->status = 1;
  }
  else {
    $return->status = 0;
  }
  return $return;
}