function bat_api_services_edit_unit in Booking and Availability Management API 7
Same name and namespace in other branches
- 7.2 bat_api.module \bat_api_services_edit_unit()
Update an existing unit.
Parameters
$unit_id:
$rooms_unit_data:
1 string reference to 'bat_api_services_edit_unit'
- bat_api_services_resources in ./
bat_api.module - Implements hook_services_resources().
File
- ./
bat_api.module, line 464
Code
function bat_api_services_edit_unit($unit_id, $rooms_unit_data) {
$return = new stdClass();
$return->sessid = session_id();
$unit = rooms_unit_load($unit_id);
if ($unit !== FALSE) {
$unit->name = isset($rooms_unit_data['name']) ? $rooms_unit_data['name'] : $unit->name;
$unit->default_state = isset($rooms_unit_data['default_state']) ? $rooms_unit_data['default_state'] : $unit->default_state;
$unit->bookable = isset($rooms_unit_data['bookable']) ? $rooms_unit_data['bookable'] : $unit->bookable;
$unit->status = isset($rooms_unit_data['status']) ? $rooms_unit_data['status'] : $unit->status;
$unit->uid = isset($rooms_unit_data['uid']) ? $rooms_unit_data['uid'] : $unit->uid;
$unit->changed = REQUEST_TIME;
rooms_unit_save($unit);
$return->status = 1;
}
else {
$return->status = 0;
}
return $return;
}