/** * Send a email to ?? with the mailing report of one mailing * * @param type $mailing_id */ function civicrm_api3_job_rapportagenamailings_mail($mailing_id) { global $base_root; // create a new Cor Page $page = new CRM_Core_Page(); $page->_mailing_id = $mailing_id; // create a new template $template = CRM_Core_Smarty::singleton(); // from CRM/Mailing/Page/Report.php // check that the user has permission to access mailing id CRM_Mailing_BAO_Mailing::checkPermission($mailing_id); $report = CRM_Mailing_BAO_Mailing::report($mailing_id); //get contents of mailing CRM_Mailing_BAO_Mailing::getMailingContent($report, $page); $subject = ts('Mailing Gereed: %1', array(1 => $report['mailing']['name'])); $template->assign('report', $report); // inlcude $base_root $template->assign('base_root', $base_root); $template->assign('subject', $subject); // from CRM/Core/page.php // only print $template->assign('tplFile', 'CRM/Rapportagenamailings/Page/RapportMailing.tpl'); $content = $template->fetch('CRM/common/print.tpl'); CRM_Utils_System::appendTPLFile('CRM/Rapportagenamailings/Page/RapportMailing.tpl', $content, $page->overrideExtraTemplateFileName()); //its time to call the hook. CRM_Utils_Hook::alterContent($content, 'page', 'CRM/Rapportagenamailings/Page/RapportMailing.tpl', $page); //echo $content; // send mail $params = array('from' => '*****@*****.**', 'toName' => 'Front Office VnV', 'toEmail' => '*****@*****.**', 'subject' => $subject, 'text' => $subject, 'html' => $content, 'replyTo' => '*****@*****.**'); CRM_Utils_Mail::send($params); }
/** * used to load a template "inline", eg. for ajax, without having to build a menu for each template */ public static function loadTemplate() { $request = CRM_Utils_Request::retrieve('q', 'String'); if (FALSE !== strpos($request, '..')) { die("SECURITY FATAL: the url can't contain '..'. Please report the issue on the forum at civicrm.org"); } $request = explode('/', $request); $entity = _civicrm_api_get_camel_name($request[2]); $tplfile = _civicrm_api_get_camel_name($request[3]); $tpl = 'CRM/' . $entity . '/Page/Inline/' . $tplfile . '.tpl'; $smarty = CRM_Core_Smarty::singleton(); CRM_Utils_System::setTitle("{$entity}::{$tplfile} inline {$tpl}"); if (!$smarty->template_exists($tpl)) { header("Status: 404 Not Found"); die("Can't find the requested template file templates/{$tpl}"); } if (array_key_exists('id', $_GET)) { // special treatmenent, because it's often used $smarty->assign('id', (int) $_GET['id']); // an id is always positive } $pos = strpos(implode(array_keys($_GET)), '<'); if ($pos !== FALSE) { die("SECURITY FATAL: one of the param names contains <"); } $param = array_map('htmlentities', $_GET); unset($param['q']); $smarty->assign_by_ref("request", $param); if (!array_key_exists('HTTP_X_REQUESTED_WITH', $_SERVER) || $_SERVER['HTTP_X_REQUESTED_WITH'] != "XMLHttpRequest") { $smarty->assign('tplFile', $tpl); $config = CRM_Core_Config::singleton(); $content = $smarty->fetch('CRM/common/' . strtolower($config->userFramework) . '.tpl'); if (!defined('CIVICRM_UF_HEAD') && ($region = CRM_Core_Region::instance('html-header', FALSE))) { CRM_Utils_System::addHTMLHead($region->render('')); } CRM_Utils_System::appendTPLFile($tpl, $content); return CRM_Utils_System::theme($content); } else { $content = "<!-- .tpl file embeded: {$tpl} -->\n"; CRM_Utils_System::appendTPLFile($tpl, $content); echo $content . $smarty->fetch($tpl); CRM_Utils_System::civiExit(); } }
/** * Render the page using a custom templating system. * * @param CRM_Core_Form $page * The CRM_Core_Form page. */ public function renderForm(&$page) { $this->_setRenderTemplates($page); $template = CRM_Core_Smarty::singleton(); $form = $page->toSmarty(); // Deprecated - use snippet=6 instead of json=1 $json = CRM_Utils_Request::retrieve('json', 'Boolean', CRM_Core_DAO::$_nullObject); if ($json) { CRM_Utils_JSON::output($form); } $template->assign('form', $form); $template->assign('isForm', 1); $controller =& $page->controller; // Stop here if we are in embedded mode. Exception: displaying form errors via ajax if ($controller->getEmbedded() && !(!empty($form['errors']) && $controller->_QFResponseType == 'json')) { return; } $template->assign('action', $page->getAction()); $pageTemplateFile = $page->getHookedTemplateFileName(); $template->assign('tplFile', $pageTemplateFile); $content = $template->fetch($controller->getTemplateFile()); if (!defined('CIVICRM_UF_HEAD') && ($region = CRM_Core_Region::instance('html-header', FALSE))) { CRM_Utils_System::addHTMLHead($region->render('')); } CRM_Utils_System::appendTPLFile($pageTemplateFile, $content, $page->overrideExtraTemplateFileName()); //its time to call the hook. CRM_Utils_Hook::alterContent($content, 'form', $pageTemplateFile, $page); $print = $controller->getPrint(); if ($print) { $html =& $content; } else { $html = CRM_Utils_System::theme($content, $print); } if ($controller->_QFResponseType == 'json') { $response = array('content' => $html); if (!empty($page->ajaxResponse)) { $response += $page->ajaxResponse; } if (!empty($form['errors'])) { $response['status'] = 'form_error'; $response['errors'] = $form['errors']; } CRM_Core_Page_AJAX::returnJsonResponse($response); } if ($print) { if ($print == CRM_Core_Smarty::PRINT_PDF) { CRM_Utils_PDF_Utils::html2pdf($content, "{$page->_name}.pdf", FALSE, array('paper_size' => 'a3', 'orientation' => 'landscape')); } else { echo $html; } CRM_Utils_System::civiExit(); } print $html; }
/** * This function takes care of all the things common to all * pages. This typically involves assigning the appropriate smarty * variable :) * * @return void|string * The content generated by running this page */ public function run() { if ($this->_embedded) { return NULL; } self::$_template->assign('mode', $this->_mode); $pageTemplateFile = $this->getHookedTemplateFileName(); self::$_template->assign('tplFile', $pageTemplateFile); // invoke the pagRun hook, CRM-3906 CRM_Utils_Hook::pageRun($this); if ($this->_print) { if (in_array($this->_print, array(CRM_Core_Smarty::PRINT_SNIPPET, CRM_Core_Smarty::PRINT_PDF, CRM_Core_Smarty::PRINT_NOFORM, CRM_Core_Smarty::PRINT_JSON))) { $content = self::$_template->fetch('CRM/common/snippet.tpl'); } else { $content = self::$_template->fetch('CRM/common/print.tpl'); } CRM_Utils_System::appendTPLFile($pageTemplateFile, $content, $this->overrideExtraTemplateFileName()); //its time to call the hook. CRM_Utils_Hook::alterContent($content, 'page', $pageTemplateFile, $this); if ($this->_print == CRM_Core_Smarty::PRINT_PDF) { CRM_Utils_PDF_Utils::html2pdf($content, "{$this->_name}.pdf", FALSE, array('paper_size' => 'a3', 'orientation' => 'landscape')); } elseif ($this->_print == CRM_Core_Smarty::PRINT_JSON) { $this->ajaxResponse['content'] = $content; CRM_Core_Page_AJAX::returnJsonResponse($this->ajaxResponse); } else { echo $content; } CRM_Utils_System::civiExit(); } $config = CRM_Core_Config::singleton(); // Intermittent alert to admins CRM_Utils_Check::singleton()->showPeriodicAlerts(); if ($this->useLivePageJS && CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'ajaxPopupsEnabled', NULL, TRUE)) { CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js', 1, 'html-header'); } $content = self::$_template->fetch('CRM/common/' . strtolower($config->userFramework) . '.tpl'); // Render page header if (!defined('CIVICRM_UF_HEAD') && ($region = CRM_Core_Region::instance('html-header', FALSE))) { CRM_Utils_System::addHTMLHead($region->render('')); } CRM_Utils_System::appendTPLFile($pageTemplateFile, $content); //its time to call the hook. CRM_Utils_Hook::alterContent($content, 'page', $pageTemplateFile, $this); echo CRM_Utils_System::theme($content, $this->_print); }
/** * render the page using a custom templating * system * * @param object $page the CRM_Core_Form page * @param boolean $ret should we echo or return output * * @return void * @access public */ function renderForm(&$page) { $this->_setRenderTemplates($page); $template = CRM_Core_Smarty::singleton(); $form = $page->toSmarty(); $json = CRM_Utils_Request::retrieve('json', 'Boolean', CRM_Core_DAO::$_nullObject); if ($json) { CRM_Utils_JSON::output($form); } $template->assign('form', $form); $template->assign('isForm', 1); $controller =& $page->controller; if ($controller->getEmbedded()) { return; } $template->assign('action', $page->getAction()); $pageTemplateFile = $page->getHookedTemplateFileName(); $template->assign('tplFile', $pageTemplateFile); $content = $template->fetch($controller->getTemplateFile()); if (!defined('CIVICRM_UF_HEAD') && ($region = CRM_Core_Region::instance('html-header', FALSE))) { CRM_Utils_System::addHTMLHead($region->render('')); } CRM_Utils_System::appendTPLFile($pageTemplateFile, $content, $page->overrideExtraTemplateFileName()); //its time to call the hook. CRM_Utils_Hook::alterContent($content, 'form', $pageTemplateFile, $page); $print = $controller->getPrint(); if ($print) { $html =& $content; } else { $html = CRM_Utils_System::theme($content, $print); } if ($controller->_QFResponseType == 'json') { $response = array('content' => $html); // CRM-11831 @see http://www.malsup.com/jquery/form/#file-upload $xhr = isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest'; if (!$xhr) { echo '<textarea>'; } echo json_encode($response); if (!$xhr) { echo '</textarea>'; } CRM_Utils_System::civiExit(); } if ($print) { if ($print == CRM_Core_Smarty::PRINT_PDF) { CRM_Utils_PDF_Utils::html2pdf($content, "{$page->_name}.pdf", FALSE, array('paper_size' => 'a3', 'orientation' => 'landscape')); } else { echo $html; } CRM_Utils_System::civiExit(); } print $html; }
/** * This function takes care of all the things common to all * pages. This typically involves assigning the appropriate * smarty variable :) * * @return string The content generated by running this page */ function run() { if ($this->_embedded) { return; } self::$_template->assign('mode', $this->_mode); $pageTemplateFile = $this->getHookedTemplateFileName(); self::$_template->assign('tplFile', $pageTemplateFile); // invoke the pagRun hook, CRM-3906 CRM_Utils_Hook::pageRun($this); if ($this->_print) { if (in_array($this->_print, array(CRM_Core_Smarty::PRINT_SNIPPET, CRM_Core_Smarty::PRINT_PDF, CRM_Core_Smarty::PRINT_NOFORM, CRM_Core_Smarty::PRINT_JSON))) { $content = self::$_template->fetch('CRM/common/snippet.tpl'); } else { $content = self::$_template->fetch('CRM/common/print.tpl'); } CRM_Utils_System::appendTPLFile($pageTemplateFile, $content, $this->overrideExtraTemplateFileName()); //its time to call the hook. CRM_Utils_Hook::alterContent($content, 'page', $pageTemplateFile, $this); if ($this->_print == CRM_Core_Smarty::PRINT_PDF) { CRM_Utils_PDF_Utils::html2pdf($content, "{$this->_name}.pdf", FALSE, array('paper_size' => 'a3', 'orientation' => 'landscape')); } elseif ($this->_print == CRM_Core_Smarty::PRINT_JSON) { $this->ajaxResponse['content'] = $content; CRM_Core_Page_AJAX::returnJsonResponse($this->ajaxResponse); } else { echo $content; } CRM_Utils_System::civiExit(); } $config = CRM_Core_Config::singleton(); // TODO: Is there a better way to ensure these actions don't happen during AJAX requests? if (empty($_GET['snippet'])) { // Version check and intermittent alert to admins CRM_Utils_VersionCheck::singleton()->versionAlert(); CRM_Utils_Check_Security::singleton()->showPeriodicAlerts(); // Debug msg once per hour if ($config->debug && CRM_Core_Permission::check('administer CiviCRM') && CRM_Core_Session::singleton()->timer('debug_alert', 3600)) { $msg = ts('Warning: Debug is enabled in <a href="%1">system settings</a>. This should not be enabled on production servers.', array(1 => CRM_Utils_System::url('civicrm/admin/setting/debug', 'reset=1'))); CRM_Core_Session::setStatus($msg, ts('Debug Mode')); } } $content = self::$_template->fetch('CRM/common/' . strtolower($config->userFramework) . '.tpl'); // Render page header if (!defined('CIVICRM_UF_HEAD') && ($region = CRM_Core_Region::instance('html-header', FALSE))) { CRM_Utils_System::addHTMLHead($region->render('')); } CRM_Utils_System::appendTPLFile($pageTemplateFile, $content); //its time to call the hook. CRM_Utils_Hook::alterContent($content, 'page', $pageTemplateFile, $this); echo CRM_Utils_System::theme($content, $this->_print); return; }
/** * This function takes care of all the things common to all * pages. This typically involves assigning the appropriate * smarty variable :) * * @return string The content generated by running this page */ function run() { if ($this->_embedded) { return; } self::$_template->assign('mode', $this->_mode); $pageTemplateFile = $this->getTemplateFileName(); self::$_template->assign('tplFile', $pageTemplateFile); // invoke the pagRun hook, CRM-3906 CRM_Utils_Hook::pageRun($this); if ($this->_print) { if (in_array($this->_print, array(CRM_Core_Smarty::PRINT_SNIPPET, CRM_Core_Smarty::PRINT_PDF, CRM_Core_Smarty::PRINT_NOFORM))) { $content = self::$_template->fetch('CRM/common/snippet.tpl'); } else { $content = self::$_template->fetch('CRM/common/print.tpl'); } CRM_Utils_System::appendTPLFile($pageTemplateFile, $content, $this->overrideExtraTemplateFileName()); //its time to call the hook. CRM_Utils_Hook::alterContent($content, 'page', $pageTemplateFile, $this); if ($this->_print == CRM_Core_Smarty::PRINT_PDF) { CRM_Utils_PDF_Utils::html2pdf($content, "{$this->_name}.pdf", FALSE, array('paper_size' => 'a3', 'orientation' => 'landscape')); } else { echo $content; } CRM_Utils_System::civiExit(); } $config = CRM_Core_Config::singleton(); $content = self::$_template->fetch('CRM/common/' . strtolower($config->userFramework) . '.tpl'); if ($region = CRM_Core_Region::instance('html-header', FALSE)) { CRM_Utils_System::addHTMLHead($region->render('')); } CRM_Utils_System::appendTPLFile($pageTemplateFile, $content); //its time to call the hook. CRM_Utils_Hook::alterContent($content, 'page', $pageTemplateFile, $this); echo CRM_Utils_System::theme('page', $content, TRUE, $this->_print); return; }