ruleName = JText::translate('VBOCHANNELS');
$this->ruleDescr = JText::translate('VBO_CONDTEXT_RULE_CHANNELS_DESCR');
$this->ruleId = basename(__FILE__);
}
/**
* Displays the rule parameters.
*
* @return void
*/
public function renderParams()
{
$this->vbo_app->loadSelect2();
$channels = $this->loadChannels();
$current_channels = $this->getParam('channels', array());
?>
getPropVal('booking', 'channel');
$allowed_channels = $this->getParam('channels', array());
$sales_customer = (strpos($book_channel, 'customer') === 0 && strpos($book_channel, '_') !== false);
if (empty($book_channel) || $sales_customer) {
if (in_array('website', $allowed_channels)) {
// website (or sales customer) booking allowed
return true;
}
// useless to proceed
return false;
}
$full_source = $book_channel;
if (strpos($book_channel, '_') !== false) {
$parts = explode('_', $book_channel);
$full_source = $parts[0];
}
return in_array(strtolower($full_source), $allowed_channels);
}
/**
* Internal function for this rule only.
*
* @return array
*/
protected function loadChannels()
{
$channels = array(
'website' => JText::translate('VBORDFROMSITE')
);
if (!is_file(VCM_SITE_PATH . DIRECTORY_SEPARATOR . 'helpers' . DIRECTORY_SEPARATOR . 'lib.vikchannelmanager.php')) {
return $channels;
}
$dbo = JFactory::getDbo();
try {
$q = "SELECT `name` FROM `#__vikchannelmanager_channel` ORDER BY `name` ASC;";
$dbo->setQuery($q);
$dbo->execute();
if ($dbo->getNumRows()) {
$records = $dbo->loadAssocList();
foreach ($records as $ch) {
$channels[$ch['name']] = ucwords($ch['name']);
}
}
} catch (Exception $e) {
// do nothing
}
return $channels;
}
}