ruleName = JText::translate('VBO_CONDTEXT_RULE_ATTFILES');
$this->ruleDescr = JText::translate('VBO_CONDTEXT_RULE_ATTFILES_DESCR');
$this->ruleId = basename(__FILE__);
}
/**
* Displays the rule parameters.
*
* @return void
*/
public function renderParams()
{
$serv_base_path = $this->getServerBasePath(true);
?>
vbo_app->getMediaField($this->inputName('attachment'), $this->getParam('attachment')); ?>
getServerBasePath();
if (VBOPlatformDetection::isWordPress())
{
$serv_base_path = ABSPATH;
}
else
{
$serv_base_path = JPATH_SITE;
}
$serv_base_path = rtrim($serv_base_path, DIRECTORY_SEPARATOR);
$attachment = $this->getParam('attachment', '');
if (!empty($attachment)) {
// make sure to convert it to a proper full path
if (strpos($attachment, $serv_base_path) === false && !is_file($attachment)) {
// relative path obtained from the media manager
if (substr($attachment, 0, 1) == DIRECTORY_SEPARATOR) {
$attachment = substr($attachment, 1);
}
$attachment = $serv_base_path . DIRECTORY_SEPARATOR . $attachment;
}
// register a file attachment
VikBooking::addEmailAttachment($attachment);
}
$attachment_local = $this->getParam('attachment_local', '');
if (!empty($attachment_local) && $attachment_local != $serv_base_path) {
// register a file attachment
VikBooking::addEmailAttachment($attachment_local);
}
return;
}
/**
* Internal function for this rule only.
*
* @param bool $trailing whether to add a trailing directory separator.
*
* @return string
*/
protected function getServerBasePath($trailing = false)
{
$base = '';
if (defined('JPATH_SITE')) {
$base = JPATH_SITE;
} elseif (function_exists('wp_upload_dir')) {
$updir = wp_upload_dir();
$base = $updir['basedir'];
}
if ($trailing) {
$base .= DIRECTORY_SEPARATOR;
}
return $base;
}
}