getProperty('rooms', array());
if (!is_array($rooms_booked) || !count($rooms_booked)) {
return false;
}
$allowed_rooms = $this->getParam('rooms', array());
$one_found = false;
foreach ($rooms_booked as $rb) {
if (!isset($rb['idroom'])) {
continue;
}
if (in_array($rb['idroom'], $allowed_rooms)) {
$one_found = true;
break;
}
}
// check sub-units
$use_sub_units = (int)$this->getParam('use_sub_units', 0);
if ($use_sub_units) {
$sub_unit_matched = false;
// parse again the rooms booked
foreach ($rooms_booked as $rb) {
// grab the sub-unit index for this room id
$room_sub_unit_filt = (int)$this->getParam('sub_unit_' . $rb['idroom'], 0);
if (empty($room_sub_unit_filt)) {
// no sub-unit defined for this room ID
continue;
}
if ($rb['roomindex'] == $room_sub_unit_filt) {
// the index of the room booked matched the one in the params
$sub_unit_matched = true;
}
}
return $one_found && $sub_unit_matched;
}
// return true if at least one room booked is in the parameters
return $one_found;
}
/**
* Internal function for this rule only.
*
* @return array
*/
protected function loadRooms()
{
$rooms = array();
$dbo = JFactory::getDbo();
$q = "SELECT `id`, `name`, `units`, `params` FROM `#__vikbooking_rooms` ORDER BY `name` ASC;";
$dbo->setQuery($q);
$dbo->execute();
if ($dbo->getNumRows()) {
$rooms = $dbo->loadAssocList();
}
return $rooms;
}
/**
* Internal function for this rule only.
*
* @param int $i the room unit index to get.
* @param array $features the list of room features.
*
* @return array
*/
protected function getFirstFeature($i, $features = [])
{
if (!is_array($features) || !isset($features[$i])) {
return $i;
}
foreach ($features[$i] as $fkey => $fval) {
if (!empty($fkey) && !empty($fval)) {
return "#$i - " . JText::translate($fkey) . ': ' . $fval;
}
}
return "#$i";
}
}