function run() { // Add our template CRM_Core_Smarty::singleton()->assign('isModulePermissionSupported', CRM_Core_Config::singleton()->userPermissionClass->isModulePermissionSupported()); CRM_Core_Region::instance('page-header')->add(array('template' => 'CRM/Volunteer/Form/Manage.tpl')); parent::run(); }
/** * if we are using a theming system, invoke theme, else just print the * content * * @param string $content the content that will be themed * @param boolean $print are we displaying to the screen or bypassing theming? * @param boolean $maintenance for maintenance mode * * @return void prints content on stdout * @access public */ function theme(&$content, $print = FALSE, $maintenance = FALSE) { $ret = FALSE; // TODO: Split up; this was copied verbatim from CiviCRM 4.0's multi-UF theming function // but the parts should be copied into cleaner subclass implementations $config = CRM_Core_Config::singleton(); if ($config->userSystem->is_drupal && function_exists('theme') && !$print) { if ($maintenance) { drupal_set_breadcrumb(''); drupal_maintenance_theme(); if ($region = CRM_Core_Region::instance('html-header', FALSE)) { CRM_Utils_System::addHTMLHead($region->render('')); } print theme('maintenance_page', array('content' => $content)); exit; } $ret = TRUE; // TODO: Figure out why D7 returns but everyone else prints } $out = $content; $config =& CRM_Core_Config::singleton(); if (!$print && $config->userFramework == 'WordPress') { if (is_admin()) { require_once ABSPATH . 'wp-admin/admin-header.php'; } else { // FIX ME: we need to figure out to replace civicrm content on the frontend pages } } if ($ret) { return $out; } else { print $out; } }
function buildForm(&$form) { // check if we're in test mode if ($this->_mode == 'test') { $test = ' Test'; } else { $test = ''; } // we don't need the default stuff: $form->_paymentFields = array(); $form->add('text', 'bank_account_number', ts('IBAN'), array('size' => 34, 'maxlength' => 34), TRUE); $form->add('text', 'bank_identification_number', ts('BIC'), array('size' => 11, 'maxlength' => 11), TRUE); $form->add('text', 'bank_name', ts('Bank Name'), array('size' => 20, 'maxlength' => 64), FALSE); $form->add('text', 'account_holder', ts('Account Holder'), array('size' => 20, 'maxlength' => 64), FALSE); $form->add('select', 'cycle_day', ts('Collection Day'), CRM_Sepa_Logic_Settings::getListSetting("cycledays", range(1, 28), $this->_creditorId), FALSE); $form->addDate('start_date', ts('start date'), TRUE, array()); $form->registerRule('sepa_iban_valid', 'callback', 'rule_valid_IBAN', 'CRM_Sepa_Logic_Verification'); $form->registerRule('sepa_bic_valid', 'callback', 'rule_valid_BIC', 'CRM_Sepa_Logic_Verification'); $form->addRule('bank_account_number', ts('This is not a correct IBAN.'), 'sepa_iban_valid'); $form->addRule('bank_identification_number', ts('This is not a correct BIC.'), 'sepa_bic_valid'); $rcur_notice_days = (int) CRM_Sepa_Logic_Settings::getSetting("batching.RCUR.notice", $this->_creditorId); $ooff_notice_days = (int) CRM_Sepa_Logic_Settings::getSetting("batching.OOFF.notice", $this->_creditorId); $timestamp_rcur = strtotime("now + {$rcur_notice_days} days"); $timestamp_ooff = strtotime("now + {$ooff_notice_days} days"); $earliest_rcur_date = array(date('Y', $timestamp_rcur), date('m', $timestamp_rcur), date('d', $timestamp_rcur)); $earliest_ooff_date = array(date('Y', $timestamp_ooff), date('m', $timestamp_ooff), date('d', $timestamp_ooff)); $form->assign('earliest_rcur_date', $earliest_rcur_date); $form->assign('earliest_ooff_date', $earliest_ooff_date); CRM_Core_Region::instance('billing-block')->add(array('template' => 'CRM/Core/Payment/SEPA/SDD.tpl', 'weight' => -1)); }
/** * Load needed JS, CSS and settings for the backend Volunteer Management UI */ public static function addResources($entity_id, $entity_table) { static $loaded = FALSE; $ccr = CRM_Core_Resources::singleton(); if ($loaded || $ccr->isAjaxMode()) { return; } $loaded = TRUE; $config = CRM_Core_Config::singleton(); // Vendor libraries $ccr->addScriptFile('civicrm', 'packages/backbone/json2.js', 100, 'html-header', FALSE); $ccr->addScriptFile('civicrm', 'packages/backbone/backbone-min.js', 120, 'html-header', FALSE); $ccr->addScriptFile('civicrm', 'packages/backbone/backbone.marionette.min.js', 125, 'html-header', FALSE); // Our stylesheet $ccr->addStyleFile('org.civicrm.volunteer', 'css/volunteer_app.css'); // Add all scripts for our js app $weight = 0; $baseDir = CRM_Extension_System::singleton()->getMapper()->keyToBasePath('org.civicrm.volunteer') . '/'; // This glob pattern will recurse the js directory up to 4 levels deep foreach (glob($baseDir . 'js/backbone/{*,*/*,*/*/*,*/*/*/*}.js', GLOB_BRACE) as $file) { $fileName = substr($file, strlen($baseDir)); $ccr->addScriptFile('org.civicrm.volunteer', $fileName, $weight++); } // Add our template CRM_Core_Smarty::singleton()->assign('isModulePermissionSupported', CRM_Core_Config::singleton()->userPermissionClass->isModulePermissionSupported()); CRM_Core_Region::instance('page-header')->add(array('template' => 'CRM/Volunteer/Form/Manage.tpl')); // Fetch event so we can set the default start time for needs // FIXME: Not the greatest for supporting non-events $entity = civicrm_api3(str_replace('civicrm_', '', $entity_table), 'getsingle', array('id' => $entity_id)); // Static variables $ccr->addSetting(array('pseudoConstant' => array('volunteer_need_visibility' => array_flip(CRM_Volunteer_BAO_Need::buildOptions('visibility_id', 'validate')), 'volunteer_role' => CRM_Volunteer_BAO_Need::buildOptions('role_id', 'get'), 'volunteer_status' => CRM_Activity_BAO_Activity::buildOptions('status_id', 'validate')), 'volunteer' => array('default_date' => CRM_Utils_Array::value('start_date', $entity)), 'config' => array('timeInputFormat' => $config->timeInputFormat), 'constants' => array('CRM_Core_Action' => array('NONE' => 0, 'ADD' => 1, 'UPDATE' => 2, 'VIEW' => 4, 'DELETE' => 8, 'BROWSE' => 16, 'ENABLE' => 32, 'DISABLE' => 64, 'EXPORT' => 128, 'BASIC' => 256, 'ADVANCED' => 512, 'PREVIEW' => 1024, 'FOLLOWUP' => 2048, 'MAP' => 4096, 'PROFILE' => 8192, 'COPY' => 16384, 'RENEW' => 32768, 'DETACH' => 65536, 'REVERT' => 131072, 'CLOSE' => 262144, 'REOPEN' => 524288, 'MAX_ACTION' => 1048575)))); // Check for problems _volunteer_checkResourceUrl(); }
function buildForm(&$form) { // Change the label on the "name" fields, and make mandatory // (they are mandatory for CC transactions, but not shown as such in the form by default // because of the 'pay later' option) $fields = array('billing_first_name' => ts('First Name'), 'billing_last_name' => ts('Last Name'), 'billing_individual_prefix' => ts('Title')); foreach ($fields as $field => $title) { if ($form->elementExists($field)) { $e =& $form->getElement($field); $e->setLabel($title); $form->addRule($field, ts('%1 is a required field.', array(1 => $title)), 'required'); } } $fields = array('billing_street_address-5', 'billing_city-5', 'billing_country_id-5', 'billing_state_province_id-5', 'billing_postal_code-5'); foreach ($fields as $field) { if ($form->elementExists($field)) { $e =& $form->getElement($field); $title = $e->getLabel(); $form->addRule($field, ts('%1 is a required field.', array(1 => $title)), 'required'); } } CRM_Core_Region::instance('page-body')->add(array('template' => 'CRM/Symbioticux/Contribute/Form/Contribution/Main.validate.tpl')); // Preview & demo sites should encourage to use a test CC number // otherwise users do not know what CC to use, and sometimes use their own. if (CRM_Utils_Array::value('action', $_REQUEST) == 'preview' || !empty($GLOBALS['symbioticux_demo']) || CRM_Utils_Array::value('name', $form->_paymentProcessors[1]) == 'Dummy') { CRM_Core_Region::instance('page-body')->add(array('template' => 'CRM/Symbioticux/Contribute/Form/Contribution/Main.billing-explain.tpl')); $js = "cj('#credit_card_number').click(function(event) {\n if (! cj(this).val()) {\n cj(this).val('4111111111111111').trigger('change');\n cj('#cvv2').val('123').trigger('change');\n cj('#credit_card_exp_date_m').val('5').trigger('change');\n cj('#credit_card_exp_date_Y').val('2018').trigger('change');\n\n cj('.symbioticux-billing-explain-cc').prependTo('.credit_card_info-section').slideDown();\n }\n });"; CRM_Core_Resources::singleton()->addScript($js); } CRM_Core_Region::instance('page-body')->add(array('template' => 'CRM/Symbioticux/Contribute/Form/Contribution/Main.hide-other-amount.tpl')); // Remove some CSS classes on the 'submit' button. $js = "cj('.crm-submit-buttons .crm-form-submit').addClass('btn btn-primary').removeClass('crm-form-submit').parent().removeClass('crm-button');"; CRM_Core_Resources::singleton()->addScript($js); }
/** * Implementation of hook_civicrm_pageRun * * Handler for pageRun hook. */ function mailjet_civicrm_pageRun(&$page) { if (get_class($page) == 'CRM_Mailing_Page_Report') { $mailingId = $page->_mailing_id; $mailingJobs = civicrm_api3('MailingJob', 'get', $params = array('mailing_id' => $mailingId)); $stats = array('BlockedCount' => 0, 'BouncedCount' => 0, 'ClickedCount' => 0, 'DeliveredCount' => 0, 'OpenedCount' => 0, 'ProcessedCount' => 0, 'QueuedCount' => 0, 'SpamComplaintCount' => 0, 'UnsubscribedCount' => 0); foreach ($mailingJobs['values'] as $key => $job) { if ($job['job_type'] == 'child') { $jobId = $key; require_once 'packages/mailjet-0.3/php-mailjet-v3-simple.class.php'; // Create a new Mailjet Object $mj = new Mailjet(MAILJET_API_KEY, MAILJET_SECRET_KEY); $mj->debug = 0; $mailJetParams = array('method' => 'VIEW', 'unique' => CRM_Mailjet_BAO_Event::getMailjetCustomCampaignId($jobId)); $response = $mj->campaign($mailJetParams); $page->assign('mailjet_params', $mailJetParams); if (!empty($response)) { if ($response->Count == 1) { $campaign = $response->Data[0]; $mailJetParams = array('method' => 'VIEW', 'unique' => $campaign->ID); $response = $mj->campaignstatistics($mailJetParams); if ($response->Count == 1) { $stats = sumUpStats($stats, get_object_vars($response->Data[0])); } } } } } $page->assign('mailjet_stats', $stats); CRM_Core_Region::instance('page-header')->add(array('template' => 'CRM/Mailjet/Page/Report.tpl')); } }
/** * Load needed JS, CSS and settings for the backend Volunteer Management UI */ public static function addResources($entity_id, $entity_table) { static $loaded = FALSE; if ($loaded) { return; } $loaded = TRUE; $config = CRM_Core_Config::singleton(); $ccr = CRM_Core_Resources::singleton(); // Vendor libraries $ccr->addScriptFile('civicrm', 'packages/backbone/json2.js', 100, 'html-header', FALSE); $ccr->addScriptFile('civicrm', 'packages/backbone/backbone-min.js', 120, 'html-header'); $ccr->addScriptFile('civicrm', 'packages/backbone/backbone.marionette.min.js', 125, 'html-header', FALSE); // Our stylesheet $ccr->addStyleFile('org.civicrm.volunteer', 'css/volunteer_app.css'); // Add all scripts for our js app $weight = 0; $baseDir = CRM_Extension_System::singleton()->getMapper()->keyToBasePath('org.civicrm.volunteer') . '/'; // This glob pattern will recurse the js directory up to 4 levels deep foreach (glob($baseDir . 'js/{*,*/*,*/*/*,*/*/*/*}.js', GLOB_BRACE) as $file) { $fileName = substr($file, strlen($baseDir)); $ccr->addScriptFile('org.civicrm.volunteer', $fileName, $weight++); } // Add our template CRM_Core_Smarty::singleton()->assign('isModulePermissionSupported', CRM_Core_Config::singleton()->userPermissionClass->isModulePermissionSupported()); CRM_Core_Region::instance('page-header')->add(array('template' => 'CRM/Volunteer/Form/Manage.tpl')); // Fetch event so we can set the default start time for needs // FIXME: Not the greatest for supporting non-events $entity = civicrm_api3(str_replace('civicrm_', '', $entity_table), 'getsingle', array('id' => $entity_id)); // Static variables $ccr->addSetting(array('pseudoConstant' => array('volunteer_need_visibility' => array_flip(CRM_Volunteer_BAO_Need::buildOptions('visibility_id', 'validate')), 'volunteer_role' => CRM_Volunteer_BAO_Need::buildOptions('role_id', 'get'), 'volunteer_status' => CRM_Activity_BAO_Activity::buildOptions('status_id', 'validate')), 'volunteer' => array('default_date' => CRM_Utils_Array::value('start_date', $entity)), 'config' => array('timeInputFormat' => $config->timeInputFormat))); // Check for problems _volunteer_civicrm_check_resource_url(); }
public function buildForm($formName, &$form) { if ($formName != 'CRM_Contribute_Form_Contribution') { return; } if (!CRM_Core_Permission::check('edit memberships')) { return; } $contact_id = $form->getVar('_contactID'); if (!$contact_id) { return; } $current_membership_id = false; $contribution_id = $form->getVar('_id'); if ($contribution_id) { $current_membership_id = CRM_Core_DAO::singleValueQuery("SELECT membership_id FROM civicrm_membership_payment where contribution_id = %1", array(1 => array($contribution_id, 'Integer'))); } $memberships = array('' => ts('-- None --')) + $this->getMembershipsForContact($contact_id); $snippet['template'] = 'CRM/Membershippayment/Contribution/Form.tpl'; $snippet['contact_id'] = $contact_id; $form->add('select', 'membership_id', ts('Membership'), $memberships); if ($current_membership_id) { $defaults['membership_id'] = $current_membership_id; $form->setDefaults($defaults); } CRM_Core_Region::instance('page-body')->add($snippet); }
/** * Method to process civicrm buildForm hook * * User can only manage group settings for non-protected groups or if user has permissions */ public static function buildForm($formName, $form) { if ($formName == 'CRM_Group_Form_Edit') { $protectGroupAllowed = CRM_Core_Permission::check('manage protected groups'); if (!$protectGroupAllowed) { CRM_Core_Region::instance('page-body')->add(array('template' => 'GroupProtect.tpl')); } } }
/** * @param $text * @param string $fileName * @param bool $output * @param null $pdfFormat * * @return string|void */ public static function html2pdf(&$text, $fileName = 'civicrm.pdf', $output = FALSE, $pdfFormat = NULL) { if (is_array($text)) { $pages =& $text; } else { $pages = array($text); } // Get PDF Page Format $format = CRM_Core_BAO_PdfFormat::getDefaultValues(); if (is_array($pdfFormat)) { // PDF Page Format parameters passed in $format = array_merge($format, $pdfFormat); } else { // PDF Page Format ID passed in $format = CRM_Core_BAO_PdfFormat::getById($pdfFormat); } $paperSize = CRM_Core_BAO_PaperSize::getByName($format['paper_size']); $paper_width = self::convertMetric($paperSize['width'], $paperSize['metric'], 'pt'); $paper_height = self::convertMetric($paperSize['height'], $paperSize['metric'], 'pt'); // dompdf requires dimensions in points $paper_size = array(0, 0, $paper_width, $paper_height); $orientation = CRM_Core_BAO_PdfFormat::getValue('orientation', $format); $metric = CRM_Core_BAO_PdfFormat::getValue('metric', $format); $t = CRM_Core_BAO_PdfFormat::getValue('margin_top', $format); $r = CRM_Core_BAO_PdfFormat::getValue('margin_right', $format); $b = CRM_Core_BAO_PdfFormat::getValue('margin_bottom', $format); $l = CRM_Core_BAO_PdfFormat::getValue('margin_left', $format); $stationery_path_partial = CRM_Core_BAO_PdfFormat::getValue('stationery', $format); $stationery_path = NULL; if (strlen($stationery_path_partial)) { $doc_root = $_SERVER['DOCUMENT_ROOT']; $stationery_path = $doc_root . "/" . $stationery_path_partial; } $margins = array($metric, $t, $r, $b, $l); $config = CRM_Core_Config::singleton(); // Add a special region for the HTML header of PDF files: $pdfHeaderRegion = CRM_Core_Region::instance('export-document-header', FALSE); $htmlHeader = $pdfHeaderRegion ? $pdfHeaderRegion->render('', FALSE) : ''; $html = "\n<html>\n <head>\n <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/>\n <style>@page { margin: {$t}{$metric} {$r}{$metric} {$b}{$metric} {$l}{$metric}; }</style>\n <style type=\"text/css\">@import url({$config->userFrameworkResourceURL}css/print.css);</style>\n {$htmlHeader}\n </head>\n <body>\n <div id=\"crm-container\">\n"; // Strip <html>, <header>, and <body> tags from each page $htmlElementstoStrip = array('@<head[^>]*?>.*?</head>@siu', '@<script[^>]*?>.*?</script>@siu', '@<body>@siu', '@</body>@siu', '@<html[^>]*?>@siu', '@</html>@siu', '@<!DOCTYPE[^>]*?>@siu'); $htmlElementsInstead = array('', '', '', '', '', ''); foreach ($pages as &$page) { $page = preg_replace($htmlElementstoStrip, $htmlElementsInstead, $page); } // Glue the pages together $html .= implode("\n<div style=\"page-break-after: always\"></div>\n", $pages); $html .= "\n </div>\n </body>\n</html>"; if ($config->wkhtmltopdfPath) { return self::_html2pdf_wkhtmltopdf($paper_size, $orientation, $margins, $html, $output, $fileName); } else { return self::_html2pdf_dompdf($paper_size, $orientation, $html, $output, $fileName); //return self::_html2pdf_tcpdf($paper_size, $orientation, $margins, $html, $output, $fileName, $stationery_path); } }
public static function registerProfileScripts() { static $loaded = FALSE; if ($loaded || CRM_Core_Resources::isAjaxMode()) { return; } $loaded = TRUE; CRM_Core_Resources::singleton()->addSettingsFactory(function () { return array('PseudoConstant' => array('locationType' => CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id'), 'websiteType' => CRM_Core_PseudoConstant::get('CRM_Core_DAO_Website', 'website_type_id'), 'phoneType' => CRM_Core_PseudoConstant::get('CRM_Core_DAO_Phone', 'phone_type_id')), 'initialProfileList' => civicrm_api('UFGroup', 'get', array('version' => 3, 'sequential' => 1, 'is_active' => 1, 'rowCount' => 1000)), 'contactSubTypes' => CRM_Contact_BAO_ContactType::subTypes(), 'profilePreviewKey' => CRM_Core_Key::get('CRM_UF_Form_Inline_Preview', TRUE)); })->addScriptFile('civicrm', 'packages/backbone/json2.js', 100, 'html-header', FALSE)->addScriptFile('civicrm', 'packages/backbone/backbone.js', 120, 'html-header')->addScriptFile('civicrm', 'packages/backbone/backbone.marionette.js', 125, 'html-header', FALSE)->addScriptFile('civicrm', 'packages/backbone/backbone.collectionsubset.js', 125, 'html-header', FALSE)->addScriptFile('civicrm', 'packages/backbone-forms/distribution/backbone-forms.js', 130, 'html-header', FALSE)->addScriptFile('civicrm', 'packages/backbone-forms/distribution/adapters/backbone.bootstrap-modal.min.js', 140, 'html-header', FALSE)->addScriptFile('civicrm', 'packages/backbone-forms/distribution/editors/list.min.js', 140, 'html-header', FALSE)->addStyleFile('civicrm', 'packages/backbone-forms/distribution/templates/default.css', 140, 'html-header')->addScriptFile('civicrm', 'packages/jquery/plugins/jstree/jquery.jstree.js', 0, 'html-header', FALSE)->addStyleFile('civicrm', 'packages/jquery/plugins/jstree/themes/default/style.css', 0, 'html-header')->addStyleFile('civicrm', 'css/crm.designer.css', 140, 'html-header')->addScriptFile('civicrm', 'js/crm.backbone.js', 150)->addScriptFile('civicrm', 'js/model/crm.schema-mapped.js', 200)->addScriptFile('civicrm', 'js/model/crm.uf.js', 200)->addScriptFile('civicrm', 'js/model/crm.designer.js', 200)->addScriptFile('civicrm', 'js/model/crm.profile-selector.js', 200)->addScriptFile('civicrm', 'js/view/crm.designer.js', 200)->addScriptFile('civicrm', 'js/view/crm.profile-selector.js', 200)->addScriptFile('civicrm', 'js/jquery/jquery.crmProfileSelector.js', 250)->addScriptFile('civicrm', 'js/crm.designerapp.js', 250); CRM_Core_Region::instance('page-header')->add(array('template' => 'CRM/UF/Page/ProfileTemplates.tpl')); }
/** * Delegated implementation of hook_civicrm_buildForm * * Customizes the UI for adding custom fields to allow the user to specify whether * a multi-select field should use the slider widget or not */ function _volunteer_civicrm_buildForm_CRM_Custom_Form_Field($formName, CRM_Core_Form &$form) { // set default value for the checkbox $field_id = $form->getVar('_id'); $widgetized_fields = _volunteer_get_slider_fields(); $form->_defaultValues['is_slider_widget'] = in_array($field_id, $widgetized_fields); // add checkbox to the form object $form->add('checkbox', 'is_slider_widget', ts('Use Slider Selector?')); // add checkbox to the display CRM_Core_Region::instance('page-body')->add(array('template' => 'Slider/CRM/Custom/Form/Field.tpl')); // reposition and show/hide checkbox CRM_Core_Resources::singleton()->addScriptFile('org.civicrm.volunteer', 'js/CRM_Custom_Form_Field.js'); }
/** * Implementation of hook_civicrm_buildProfile */ function hrvisa_civicrm_buildProfile($name) { if ($name == 'hrvisa_tab') { // To fix validation alert issue $smarty = CRM_Core_Smarty::singleton(); $smarty->assign('urlIsPublic', FALSE); $contactID = CRM_Utils_Request::retrieve('id', 'Positive', $this); $config = CRM_Core_Config::singleton(); if ($config->logging && 'multiProfileDialog' !== CRM_Utils_Request::retrieve('context', 'String', CRM_Core_DAO::$_nullObject)) { CRM_Core_Region::instance('profile-form-hrvisa_tab')->add(array('template' => 'CRM/common/logButton.tpl', 'instance_id' => CRM_Report_Utils_Report::getInstanceIDForValue('logging/contact/summary'), 'css_class' => 'hrvisa-revision-link', 'table_name' => CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup', 'Immigration', 'table_name', 'name'), 'contact_id' => $contactID, 'weight' => -2)); } } }
/** * Smarty block function for defining content-regions which can be dynamically-altered * * @see CRM_Core_Regions * * @param array $params must define 'name' * @param string $content Default content * @param object $smarty the Smarty object * * @return string */ function smarty_block_crmRegion($params, $content, &$smarty, &$repeat) { if ($repeat) { return; } require_once 'CRM/Core/Region.php'; $region = CRM_Core_Region::instance($params['name'], FALSE); if ($region) { $result = $region->render($content); return $result; } else { return $content; } }
/** * Smarty block function for defining content-regions which can be dynamically-altered * * @see CRM_Core_Regions * * @param array $params * Must define 'name'. * @param string $content * Default content. * @param CRM_Core_Smarty $smarty * The Smarty object. * * @param $repeat * * @return string */ function smarty_block_crmRegion($params, $content, &$smarty, &$repeat) { if ($repeat) { return NULL; } require_once 'CRM/Core/Region.php'; $region = CRM_Core_Region::instance($params['name'], FALSE); if ($region) { $result = $region->render($content, CRM_Utils_Array::value('allowCmsOverride', $params, TRUE)); return $result; } else { return $content; } }
/** * Implementation of hook_civicrm_buildProfile */ function hrqual_civicrm_buildProfile($name) { if ($name == 'hrqual_tab') { // To fix validation alert issue $smarty = CRM_Core_Smarty::singleton(); $smarty->assign('urlIsPublic', FALSE); $action = CRM_Utils_Request::retrieve('multiRecord', 'String', $this); // display the select box only in add and update mode if (in_array($action, array("add", "update"))) { $regionParams = array('markup' => "<select id='category_name' name='category_name' style='display:none' class='form-select required'></select>"); CRM_Core_Region::instance('profile-form-hrqual_tab')->add($regionParams); } $config = CRM_Core_Config::singleton(); if ($config->logging && 'multiProfileDialog' !== CRM_Utils_Request::retrieve('context', 'String', CRM_Core_DAO::$_nullObject)) { $contactID = CRM_Utils_Request::retrieve('id', 'Positive', $this); CRM_Core_Region::instance('profile-form-hrqual_tab')->add(array('template' => 'CRM/common/logButton.tpl', 'instance_id' => CRM_Report_Utils_Report::getInstanceIDForValue('logging/contact/summary'), 'css_class' => 'hrqual-revision-link', 'table_name' => CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup', 'Qualifications', 'table_name', 'name'), 'contact_id' => $contactID, 'weight' => -2)); } } }
/** * Implementation of hook_civicrm_buildForm(). * * Used to add a 'Export to Excel' button in the Report forms. */ function civiexportexcel_civicrm_buildForm($formName, &$form) { // Reports extend the CRM_Report_Form class. // We use that to check whether we should inject the Excel export buttons. if (is_subclass_of($form, 'CRM_Report_Form')) { $smarty = CRM_Core_Smarty::singleton(); $vars = $smarty->get_template_vars(); $form->_excelButtonName = $form->getButtonName('submit', 'excel'); $label = !empty($vars['instanceId']) ? ts('Export to Excel') : ts('Preview Excel'); $form->addElement('submit', $form->_excelButtonName, $label); CRM_Core_Region::instance('page-body')->add(array('template' => 'CRM/Report/Form/Actions-civiexportexcel.tpl')); // This hook also gets called when we click on a submit button, // so we can handle that part here too. $buttonName = $form->controller->getButtonName(); $output = CRM_Utils_Request::retrieve('output', 'String', CRM_Core_DAO::$_nullObject); if ($form->_excelButtonName == $buttonName || $output == 'excel2007') { $form->assign('printOnly', TRUE); $printOnly = TRUE; $form->assign('outputMode', 'excel2007'); // FIXME: this duplicates part of CRM_Report_Form::postProcess() // since we do not have a place to hook into, we hi-jack the form process // before it gets into postProcess. // get ready with post process params $form->beginPostProcess(); // build query $sql = $form->buildQuery(FALSE); // build array of result based on column headers. This method also allows // modifying column headers before using it to build result set i.e $rows. $rows = array(); $form->buildRows($sql, $rows); // format result set. // This seems to cause more problems than it fixes. // $form->formatDisplay($rows); // Show stats on a second Excel page. $stats = $form->statistics($rows); // assign variables to templates $form->doTemplateAssignment($rows); // FIXME: END. CRM_CiviExportExcel_Utils_Report::export2excel2007($form, $rows, $stats); } } }
/** * * POST Param 'qrid': string, usually the name of the queue */ public function run() { $qrid = CRM_Utils_Request::retrieve('qrid', 'String', $this, TRUE); $runner = CRM_Queue_Runner::instance($qrid); if (!is_object($runner)) { CRM_Core_Error::fatal('Queue runner must be configured before execution.'); } CRM_Utils_System::setTitle($runner->title); $this->assign('queueRunnerData', array('qrid' => $runner->qrid, 'runNextAjax' => CRM_Utils_System::url($runner->pathPrefix . '/ajax/runNext', NULL, FALSE, NULL, FALSE), 'skipNextAjax' => CRM_Utils_System::url($runner->pathPrefix . '/ajax/skipNext', NULL, FALSE, NULL, FALSE), 'onEndAjax' => CRM_Utils_System::url($runner->pathPrefix . '/ajax/onEnd', NULL, FALSE, NULL, FALSE), 'completed' => 0, 'numberOfItems' => $runner->queue->numberOfItems(), 'buttons' => $runner->buttons)); if ($runner->isMinimal) { // Render page header if (!defined('CIVICRM_UF_HEAD') && ($region = CRM_Core_Region::instance('html-header', FALSE))) { CRM_Utils_System::addHTMLHead($region->render('')); } $smarty = CRM_Core_Smarty::singleton(); $content = $smarty->fetch('CRM/Queue/Page/Runner.tpl'); echo CRM_Utils_System::theme($content, $this->_print, TRUE); } else { parent::run(); } }
/** * Delegated implementation of hook_civicrm_buildForm * * Customizes the UI for adding custom fields to allow the user to specify whether * this field should be handled by the secure file extension */ function _securefiles_civicrm_buildForm_CRM_Custom_Form_Field($formName, CRM_Core_Form &$form) { // set default value for the checkbox $field_id = $form->getVar('_id'); $enabled_fields = _securefiles_get_secure_enabled_fields(); $form->_defaultValues['use_securefiles'] = in_array($field_id, $enabled_fields); // add checkbox to the form object $form->add('checkbox', 'use_securefiles', ts('Store using SecureFiles')); // add checkbox/settings form to the display CRM_Core_Region::instance('page-body')->add(array('template' => 'CRM/Securefiles/Form/CustomField.tpl')); $secureFileElements = array(); //Let the Backend service add fields if it wants/needs to $backendService = CRM_Securefiles_Backend::getBackendService(); if ($backendService) { $backendService->buildFieldSettingsForm($form, $secureFileElements); } //Assign our custom field names to the form so the template can render them. $form->assign("secureFileElements", $secureFileElements); // reposition and show/hide checkbox CRM_Core_Resources::singleton()->addScriptFile('com.ginkgostreet.securefiles', 'js/CRM_Custom_Form_Field.js'); }
function hrui_civicrm_buildForm($formName, &$form) { CRM_Core_Resources::singleton()->addStyleFile('org.civicrm.hrui', 'css/hrui.css')->addScriptFile('org.civicrm.hrui', 'js/hrui.js'); if ($form instanceof CRM_Contact_Form_Contact) { CRM_Core_Resources::singleton()->addSetting(array('formName' => 'contactForm')); //HR-358 - Set default values //set default value to phone location and type $locationId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_LocationType', 'Main', 'id', 'name'); $result = civicrm_api3('LocationType', 'create', array('id' => $locationId, 'is_default' => 1, 'is_active' => 1)); if ($form->elementExists('phone[2][phone_type_id]') && $form->elementExists('phone[2][phone_type_id]')) { $phoneType = $form->getElement('phone[2][phone_type_id]'); $phoneValue = CRM_Core_OptionGroup::values('phone_type'); $phoneKey = CRM_Utils_Array::key('Mobile', $phoneValue); $phoneType->setSelected($phoneKey); $phoneLocation = $form->getElement('phone[2][location_type_id]'); $phoneLocation->setSelected($locationId); } } $ogID = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', 'type_20130502144049', 'id', 'name'); //HR-355 -- Add Government ID if ($formName == 'CRM_Contact_Form_Contact' && $ogID && $form->_contactType == 'Individual') { //add government fields $contactID = CRM_Utils_Request::retrieve('cid', 'Integer', $form); $templatePath = CRM_Extension_System::singleton()->getMapper()->keyToBasePath('org.civicrm.hrui') . '/templates'; $form->add('text', 'GovernmentId', ts('Government ID')); $form->addElement('select', "govTypeOptions", '', CRM_Core_BAO_OptionValue::getOptionValuesAssocArray($ogID)); CRM_Core_Region::instance('page-body')->add(array('template' => "{$templatePath}/CRM/HRUI/Form/contactField.tpl")); $action = CRM_Utils_Request::retrieve('action', 'String', $form); $govVal = CRM_HRIdent_Page_HRIdent::retreiveContactFieldValue($contactID); //set default to government type option $default = array(); $default['govTypeOptions'] = CRM_Core_BAO_CustomField::getOptionGroupDefault($ogID, 'select'); if ($action == CRM_Core_Action::UPDATE && !empty($govVal)) { //set key for updating specific record of contact id in custom value table $default['govTypeOptions'] = CRM_Utils_Array::value('type', $govVal); $default['GovernmentId'] = CRM_Utils_Array::value('typeNumber', $govVal); } $form->setDefaults($default); } }
/** * Implements hook_civicrm_buildForm(). * * Set a default value for an event price set field. * * @param string $formName * @param CRM_Core_Form $form */ function menufontawesome_civicrm_buildForm($formName, &$form) { if ($formName == 'CRM_Admin_Form_Navigation') { CRM_Core_Resources::singleton()->addStyleFile('com.opetmar.menufontawesome', 'resources/plugins/bootstrap/css/bootstrap.css', 0, 'html-header'); CRM_Core_Resources::singleton()->addStyleFile('com.opetmar.menufontawesome', 'resources/plugins/fontawesome-iconpicker/css/fontawesome-iconpicker.min.css', 0, 'html-header'); CRM_Core_Resources::singleton()->addScriptFile('com.opetmar.menufontawesome', 'resources/plugins/jquery-1.11.3.min.js', 0); CRM_Core_Resources::singleton()->addScriptFile('com.opetmar.menufontawesome', 'resources/plugins/bootstrap/js/bootstrap.min.js', 1); CRM_Core_Resources::singleton()->addScriptFile('com.opetmar.menufontawesome', 'resources/plugins/fontawesome-iconpicker/js/fontawesome-iconpicker.min.js', 2); CRM_Core_Resources::singleton()->addScriptFile('com.opetmar.menufontawesome', 'resources/main.js', 3); // Add the field element in the form if ($form->getAction() == CRM_Core_Action::UPDATE) { $id = $form->getVar('_id'); $fa_icon = CRM_Menufontawesome_BAO_Navigation::getIcon($id); $form->add('text', 'fa_icon', ts('Icon'), array('value' => $fa_icon)); } else { $form->add('text', 'fa_icon', ts('Icon'), array('value' => '')); } $templatePath = realpath(dirname(__FILE__) . "/templates/CRM/Menufontawesome/Page"); // dynamically insert a template block in the page CRM_Core_Region::instance('page-body')->add(array('template' => "{$templatePath}/fa_icon.tpl")); } }
/** * Register profile scripts. */ public static function registerProfileScripts() { static $loaded = FALSE; if ($loaded || CRM_Core_Resources::isAjaxMode()) { return; } $loaded = TRUE; CRM_Core_Resources::singleton()->addSettingsFactory(function () { $ufGroups = civicrm_api3('UFGroup', 'get', array('sequential' => 1, 'is_active' => 1, 'options' => array('limit' => 0))); //CRM-16915 - insert 'module' param for the profile used by CiviEvent. if (CRM_Core_Permission::check('manage event profiles') && !CRM_Core_Permission::check('administer CiviCRM')) { foreach ($ufGroups['values'] as $key => $value) { $ufJoin = CRM_Core_BAO_UFGroup::getUFJoinRecord($value['id']); if (in_array('CiviEvent', $ufJoin) || in_array('CiviEvent_Additional', $ufJoin)) { $ufGroups['values'][$key]['module'] = 'CiviEvent'; } } } return array('PseudoConstant' => array('locationType' => CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id'), 'websiteType' => CRM_Core_PseudoConstant::get('CRM_Core_DAO_Website', 'website_type_id'), 'phoneType' => CRM_Core_PseudoConstant::get('CRM_Core_DAO_Phone', 'phone_type_id')), 'initialProfileList' => $ufGroups, 'contactSubTypes' => CRM_Contact_BAO_ContactType::subTypes(), 'profilePreviewKey' => CRM_Core_Key::get('CRM_UF_Form_Inline_Preview', TRUE)); })->addScriptFile('civicrm', 'packages/backbone/json2.js', 100, 'html-header', FALSE)->addScriptFile('civicrm', 'packages/backbone/backbone.js', 120, 'html-header')->addScriptFile('civicrm', 'packages/backbone/backbone.marionette.js', 125, 'html-header', FALSE)->addScriptFile('civicrm', 'packages/backbone/backbone.collectionsubset.js', 125, 'html-header', FALSE)->addScriptFile('civicrm', 'packages/backbone-forms/distribution/backbone-forms.js', 130, 'html-header', FALSE)->addScriptFile('civicrm', 'packages/backbone-forms/distribution/adapters/backbone.bootstrap-modal.min.js', 140, 'html-header', FALSE)->addScriptFile('civicrm', 'packages/backbone-forms/distribution/editors/list.min.js', 140, 'html-header', FALSE)->addStyleFile('civicrm', 'packages/backbone-forms/distribution/templates/default.css', 140, 'html-header')->addScriptFile('civicrm', 'packages/jquery/plugins/jstree/jquery.jstree.js', 0, 'html-header', FALSE)->addStyleFile('civicrm', 'packages/jquery/plugins/jstree/themes/default/style.css', 0, 'html-header')->addStyleFile('civicrm', 'css/crm.designer.css', 140, 'html-header')->addScriptFile('civicrm', 'js/crm.backbone.js', 150)->addScriptFile('civicrm', 'js/model/crm.schema-mapped.js', 200)->addScriptFile('civicrm', 'js/model/crm.uf.js', 200)->addScriptFile('civicrm', 'js/model/crm.designer.js', 200)->addScriptFile('civicrm', 'js/model/crm.profile-selector.js', 200)->addScriptFile('civicrm', 'js/view/crm.designer.js', 200)->addScriptFile('civicrm', 'js/view/crm.profile-selector.js', 200)->addScriptFile('civicrm', 'js/jquery/jquery.crmProfileSelector.js', 250)->addScriptFile('civicrm', 'js/crm.designerapp.js', 250); CRM_Core_Region::instance('page-header')->add(array('template' => 'CRM/UF/Page/ProfileTemplates.tpl')); }
static function registerScripts() { static $loaded = FALSE; if ($loaded) { return; } $loaded = TRUE; CRM_Core_Resources::singleton()->addSettingsFactory(function () { $config = CRM_Core_Config::singleton(); return array('PseudoConstant' => array('locationType' => CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id'), 'job_hours_time' => CRM_HRJob_Page_JobsTab::getJobHoursTime(), 'working_days' => CRM_HRJob_Page_JobsTab::getDaysPerTime()), 'FieldOptions' => CRM_HRJob_Page_JobsTab::getFieldOptions(), 'jobTabApp' => array('contact_id' => CRM_Utils_Request::retrieve('cid', 'Integer'), 'domain_id' => CRM_Core_Config::domainID(), 'isLogEnabled' => (bool) $config->logging, 'loggingReportId' => CRM_Report_Utils_Report::getInstanceIDForValue('logging/contact/summary'), 'currencies' => CRM_HRJob_Page_JobsTab::getCurrencyFormats(), 'defaultCurrency' => $config->defaultCurrency)); })->addScriptFile('civicrm', 'packages/backbone/json2.js', 100, 'html-header', FALSE)->addScriptFile('civicrm', 'packages/backbone/backbone.js', 120, 'html-header')->addScriptFile('civicrm', 'packages/backbone/backbone.marionette.js', 125, 'html-header', FALSE)->addScriptFile('civicrm', 'packages/backbone/backbone.modelbinder.js', 125, 'html-header', FALSE)->addScriptFile('civicrm', 'js/jquery/jquery.crmRevisionLink.js', 125, 'html-header', FALSE)->addScriptFile('org.civicrm.hrjob', 'js/jquery/jquery.hrContactLink.js', 125, 'html-header', FALSE)->addScriptFile('org.civicrm.hrjob', 'js/jquery/jquery.hrFileLink.js', 125, 'html-header', FALSE)->addScriptFile('org.civicrm.hrjob', 'js/jquery/jquery.lockButton.js', 125, 'html-header', FALSE)->addScriptFile('civicrm', 'js/crm.backbone.js', 130, 'html-header', FALSE)->addStyleFile('org.civicrm.hrjob', 'css/hrjob.css', 140, 'html-header')->addScriptFile('org.civicrm.hrjob', 'js/hrapp.js', 150, 'html-header')->addScriptFile('org.civicrm.hrjob', 'js/renderutil.js', 155, 'html-header')->addScriptFile('org.civicrm.hrjob', 'js/entities/hrjob.js', 155, 'html-header')->addScriptFile('org.civicrm.hrjob', 'js/common/navigation.js', 155, 'html-header')->addScriptFile('org.civicrm.hrjob', 'js/common/mbind.js', 155, 'html-header')->addScriptFile('org.civicrm.hrjob', 'js/common/views.js', 155, 'html-header')->addScriptFile('org.civicrm.hrjob', 'js/jobtabapp.js', 160, 'html-header')->addScriptFile('org.civicrm.hrjob', 'js/jobtabapp/intro/show_controller.js', 160, 'html-header')->addScriptFile('org.civicrm.hrjob', 'js/jobtabapp/intro/show_views.js', 160, 'html-header')->addScriptFile('org.civicrm.hrjob', 'js/jobtabapp/tree/tree_controller.js', 160, 'html-header')->addScriptFile('org.civicrm.hrjob', 'js/jobtabapp/tree/tree_views.js', 160, 'html-header')->addScriptFile('org.civicrm.hrjob', 'js/jobtabapp/summary/summary_controller.js', 160, 'html-header')->addScriptFile('org.civicrm.hrjob', 'js/jobtabapp/summary/summary_views.js', 160, 'html-header'); foreach (array('general', 'funding', 'health', 'hour', 'leave', 'pay', 'pension', 'role') as $module) { CRM_Core_Resources::singleton()->addScriptFile('org.civicrm.hrjob', "js/jobtabapp/{$module}/edit_controller.js", 160, 'html-header')->addScriptFile('org.civicrm.hrjob', "js/jobtabapp/{$module}/edit_views.js", 160, 'html-header')->addScriptFile('org.civicrm.hrjob', "js/jobtabapp/{$module}/summary_views.js", 160, 'html-header'); } $templateDir = CRM_Extension_System::singleton()->getMapper()->keyToBasePath('org.civicrm.hrjob') . '/templates/'; $region = CRM_Core_Region::instance('page-header'); foreach (glob($templateDir . 'CRM/HRJob/Underscore/*.tpl') as $file) { $fileName = substr($file, strlen($templateDir)); $region->add(array('template' => $fileName)); } $region->add(array('template' => 'CRM/Form/validate.tpl')); }
function sepa_civicrm_pageRun(&$page) { if (get_class($page) == "CRM_Contact_Page_View_Summary") { // mods for summary view CRM_Core_Region::instance('page-body')->add(array('template' => 'CRM/Contact/Page/View/Summary.sepa.tpl')); } elseif (get_class($page) == "CRM_Contribute_Page_Tab") { // single contribuion view if (!CRM_Sepa_Logic_Settings::isSDD(array('payment_instrument_id' => $page->getTemplate()->get_template_vars('payment_instrument_id')))) { return; } if ($page->getTemplate()->get_template_vars('contribution_recur_id')) { // This is an installment of a recurring contribution. $mandate = civicrm_api3('SepaMandate', 'getsingle', array('entity_table' => 'civicrm_contribution_recur', 'entity_id' => $page->getTemplate()->get_template_vars('contribution_recur_id'))); } else { // this is a OOFF contribtion $mandate = civicrm_api3('SepaMandate', 'getsingle', array('entity_table' => 'civicrm_contribution', 'entity_id' => $page->getTemplate()->get_template_vars('id'))); } $page->assign('sepa', $mandate); CRM_Core_Region::instance('page-body')->add(array('template' => 'Sepa/Contribute/Form/ContributionView.tpl')); } elseif (get_class($page) == "CRM_Contribute_Page_ContributionRecur") { // recurring contribuion view $recur = $page->getTemplate()->get_template_vars("recur"); // This is a one-off contribution => try to show mandate data. $template_vars = $page->getTemplate()->get_template_vars('recur'); $payment_instrument_id = $template_vars['payment_instrument_id']; if (!CRM_Sepa_Logic_Settings::isSDD(array('payment_instrument_id' => $payment_instrument_id))) { return; } $mandate = civicrm_api("SepaMandate", "getsingle", array("version" => 3, "entity_table" => "civicrm_contribution_recur", "entity_id" => $recur["id"])); if (!array_key_exists("id", $mandate)) { CRM_Core_Error::fatal(ts("Can't find the sepa mandate")); } $page->assign("sepa", $mandate); CRM_Core_Region::instance('page-body')->add(array('template' => 'Sepa/Contribute/Page/ContributionRecur.tpl')); } }
static function _showHTMLHead() { $region = CRM_Core_Region::instance('wp_head', FALSE); if ($region) { echo $region->render(''); } }
/** * 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; }
/** * Add a CSS content to the current page using <STYLE>. * * @param string $code * CSS source code. * @param int $weight * relative weight within a given region. * @param string $region * location within the file; 'html-header', 'page-header', 'page-footer'. * @return CRM_Core_Resources */ public function addStyle($code, $weight = self::DEFAULT_WEIGHT, $region = self::DEFAULT_REGION) { CRM_Core_Region::instance($region)->add(array('type' => 'style', 'style' => $code, 'weight' => $weight, 'region' => $region)); return $this; }
/** * Display any final messages, clear caches, etc */ public function runFinish() { $upgrade = new CRM_Upgrade_Form(); $template = CRM_Core_Smarty::singleton(); // If we're redirected from queue-runner, then isUpgradePending=true. // If user then reloads the finish page, the isUpgradePending will be unset. (Because the session has been cleared.) if ($this->get('isUpgradePending')) { // TODO: Use structured message store $postUpgradeMessage = file_get_contents($this->get('postUpgradeMessageFile')); // This destroys $session, so do it after get('postUpgradeMessageFile') CRM_Upgrade_Form::doFinish(); } else { $postUpgradeMessage = ''; // Session was destroyed! Can't recover messages. } // do a version check - after doFinish() sets the final version list($currentVer, $latestVer) = $upgrade->getUpgradeVersions(); if ($error = $upgrade->checkCurrentVersion($currentVer, $latestVer)) { CRM_Core_Error::fatal($error); } $template->assign('message', $postUpgradeMessage); $template->assign('upgraded', TRUE); $template->assign('sid', CRM_Utils_System::getSiteID()); // Render page header if (!defined('CIVICRM_UF_HEAD') && ($region = CRM_Core_Region::instance('html-header', FALSE))) { CRM_Utils_System::addHTMLHead($region->render('')); } $content = $template->fetch('CRM/common/success.tpl'); echo CRM_Utils_System::theme($content, $this->_print, TRUE); }
/** * Shared pre-process function. * * If overriding preProcess function this should still be called. * * @throws \Exception */ public function preProcessCommon() { $this->_force = CRM_Utils_Request::retrieve('force', 'Boolean', CRM_Core_DAO::$_nullObject); $this->_dashBoardRowCount = CRM_Utils_Request::retrieve('rowCount', 'Integer', CRM_Core_DAO::$_nullObject); $this->_section = CRM_Utils_Request::retrieve('section', 'Integer', CRM_Core_DAO::$_nullObject); $this->assign('section', $this->_section); CRM_Core_Region::instance('page-header')->add(array('markup' => sprintf('<!-- Report class: [%s] -->', htmlentities(get_class($this))))); if (!$this->noController) { $this->setID($this->get('instanceId')); if (!$this->_id) { $this->setID(CRM_Report_Utils_Report::getInstanceID()); if (!$this->_id) { $this->setID(CRM_Report_Utils_Report::getInstanceIDForPath()); } } // set qfkey so that pager picks it up and use it in the "Next > Last >>" links. // FIXME: Note setting it in $_GET doesn't work, since pager generates link based on QUERY_STRING $_SERVER['QUERY_STRING'] .= "&qfKey={$this->controller->_key}"; } if ($this->_id) { $this->assign('instanceId', $this->_id); $params = array('id' => $this->_id); $this->_instanceValues = array(); CRM_Core_DAO::commonRetrieve('CRM_Report_DAO_ReportInstance', $params, $this->_instanceValues); if (empty($this->_instanceValues)) { CRM_Core_Error::fatal("Report could not be loaded."); } $this->_title = $this->_instanceValues['title']; if (!empty($this->_instanceValues['permission']) && !(CRM_Core_Permission::check($this->_instanceValues['permission']) || CRM_Core_Permission::check('administer Reports'))) { CRM_Utils_System::permissionDenied(); CRM_Utils_System::civiExit(); } $formValues = CRM_Utils_Array::value('form_values', $this->_instanceValues); if ($formValues) { $this->_formValues = unserialize($formValues); } else { $this->_formValues = NULL; } $this->setOutputMode(); if ($this->_outputMode == 'copy') { $this->_createNew = TRUE; $this->_params = $this->_formValues; $this->_params['view_mode'] = 'criteria'; $this->_params['title'] = ts('(copy)') . $this->getTitle(); // Do not pass go. Do not collect another chance to re-run the same query. CRM_Report_Form_Instance::postProcess($this); } // lets always do a force if reset is found in the url. // Hey why not? see CRM-17225 for more about this. The use of reset to be force is historical for reasons stated // in the comment line above these 2. if (!empty($_REQUEST['reset']) && !in_array(CRM_Utils_Request::retrieve('output', 'String'), array('save', 'criteria'))) { $this->_force = 1; } // set the mode $this->assign('mode', 'instance'); } elseif (!$this->noController) { list($optionValueID, $optionValue) = CRM_Report_Utils_Report::getValueIDFromUrl(); $instanceCount = CRM_Report_Utils_Report::getInstanceCount($optionValue); if ($instanceCount > 0 && $optionValueID) { $this->assign('instanceUrl', CRM_Utils_System::url('civicrm/report/list', "reset=1&ovid={$optionValueID}")); } if ($optionValueID) { $this->_description = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionValue', $optionValueID, 'description'); } // set the mode $this->assign('mode', 'template'); } // lets display the Report Settings section $this->_instanceForm = $this->_force || $this->_id || !empty($_POST); // Do not display Report Settings section if administer Reports permission is absent OR // if report instance is reserved and administer reserved reports absent if (!CRM_Core_Permission::check('administer Reports') || $this->_instanceValues['is_reserved'] && !CRM_Core_Permission::check('administer reserved reports')) { $this->_instanceForm = FALSE; } $this->assign('criteriaForm', FALSE); // Display Report Criteria section if user has access Report Criteria OR administer Reports AND report instance is not reserved if (CRM_Core_Permission::check('administer Reports') || CRM_Core_Permission::check('access Report Criteria')) { if (!$this->_instanceValues['is_reserved'] || CRM_Core_Permission::check('administer reserved reports')) { $this->assign('criteriaForm', TRUE); $this->_criteriaForm = TRUE; } } $this->_instanceButtonName = $this->getButtonName('submit', 'save'); $this->_createNewButtonName = $this->getButtonName('submit', 'next'); $this->_printButtonName = $this->getButtonName('submit', 'print'); $this->_pdfButtonName = $this->getButtonName('submit', 'pdf'); $this->_csvButtonName = $this->getButtonName('submit', 'csv'); $this->_groupButtonName = $this->getButtonName('submit', 'group'); $this->_chartButtonName = $this->getButtonName('submit', 'chart'); }