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(); }
/** * Smarty function for checking change in a property's value, for example * when looping through an array. * * Smarty param: string $key unique identifier for this property (REQUIRED) * Smarty param: mixed $value the current value of the property * Smarty param: string $assign name of template variable to which to assign result * * * @param array $params * Template call's parameters. * @param CRM_Core_Smarty $smarty * The Smarty object. * * @return NULL */ function smarty_function_isValueChange($params, &$smarty) { static $values = array(); if (empty($params['key'])) { $smarty->trigger_error("Missing required parameter, 'key', in isValueChange plugin."); return NULL; } $is_changed = FALSE; if (!array_key_exists($params['key'], $values) || strcasecmp($params['value'], $values[$params['key']]) !== 0) { // if we have a new value $is_changed = TRUE; $values[$params['key']] = $params['value']; // clear values on all properties added below/after this property $clear = FALSE; foreach ($values as $k => $dontcare) { if ($clear) { unset($values[$k]); } elseif ($params['key'] == $k) { $clear = TRUE; } } } if ($params['assign']) { $smarty->assign($params['assign'], $is_changed); } return NULL; }
/** * Get details for the target and assignee contact of an activity. * * This is "simple" in that it is only appropriate for activities in which the business-process * guarantees that there is only one target and one assignee. If the business-process permits * multiple targets or multiple assignees, then consider the more versatile (but less sugary) * function "crmAPI". * * Note: This will perform like a dog, but who cares -- at most, we deal with O(100) iterations * as part of a background task. * * @param array $params * , Array with keys: * - activity_id: int, required * - target_var: string, optional; name of a variable which will store the first/only target contact; default "target" * - assignee_var: string, optional; name of a variable which will store the first/only assignee contact; default "assignee" * - return: string, optional; comma-separated list of fields to return for each contact * * @param CRM_Core_Smarty $smarty * * @return string */ function smarty_function_simpleActivityContacts($params, &$smarty) { if (empty($params['activity_id'])) { $smarty->trigger_error('assign: missing \'activity_id\' parameter'); } if (!isset($params['target_var'])) { $params['target_var'] = 'target'; } if (!isset($params['assignee_var'])) { $params['assignee_var'] = 'assignee'; } if (!isset($params['return'])) { $params['return'] = 'contact_id,contact_type,display_name,sort_name,first_name,last_name'; } require_once 'api/api.php'; require_once 'api/v3/utils.php'; $activity = civicrm_api('activity', 'getsingle', array('version' => 3, 'id' => $params['activity_id'], 'return.target_contact_id' => 1, 'return.assignee_contact_id' => 1)); $baseContactParams = array('version' => 3); foreach (explode(',', $params['return']) as $field) { $baseContactParams['return.' . $field] = 1; } foreach (array('target', 'assignee') as $role) { $contact = array(); if (!empty($activity[$role . '_contact_id'])) { $contact_id = array_shift($activity[$role . '_contact_id']); $contact = civicrm_api('contact', 'getsingle', $baseContactParams + array('contact_id' => $contact_id)); } $smarty->assign($params[$role . '_var'], $contact); } return ''; }
/** * Smarty block function providing gettext support * * See CRM_Core_I18n class documentation for details. * * @param array $params * Template call's parameters. * @param string $text * {ts} block contents from the template. * @param CRM_Core_Smarty $smarty * The Smarty object. * * @return string * the string, translated by gettext */ function smarty_block_ts($params, $text, &$smarty) { if (!isset($params['domain'])) { $params['domain'] = $smarty->get_template_vars('extensionKey'); } return ts($text, $params); }
/** * Fetch an attribute from html * * @param array $params * @param CRM_Core_Smarty $smarty * * @return string */ function smarty_function_crmGetAttribute($params, &$smarty) { $ret = ''; if (preg_match('#\\W' . $params['attr'] . '="([^"]+)#', $params['html'], $matches)) { $ret = $matches[1]; } if (!empty($params['assign'])) { $smarty->assign($params['assign'], $ret); } else { return $ret; } }
/** * Smarty block function to temporarily define variables. * * Example: * * @code * {tsScope x=1} * Expect {$x}==1 * {tsScope x=2} * Expect {$x}==2 * {/tsScope} * Expect {$x}==1 * {/tsScope} * @endcode * * @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_crmScope($params, $content, &$smarty, &$repeat) { /** @var CRM_Core_Smarty $smarty */ if ($repeat) { // open crmScope $smarty->pushScope($params); } else { // close crmScope $smarty->popScope(); } return $content; }
/** * 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(); }
function run() { $upgrade = new CRM_Upgrade_Form(); $message = ts('CiviCRM upgrade successful'); if ($upgrade->checkVersion($upgrade->latestVersion)) { $message = ts('Your database has already been upgraded to CiviCRM %1', array(1 => $upgrade->latestVersion)); } elseif ($upgrade->checkVersion('2.1.2') || $upgrade->checkVersion('2.1.3') || $upgrade->checkVersion('2.1.4') || $upgrade->checkVersion('2.1.5')) { // do nothing, db version is changed for all upgrades } elseif ($upgrade->checkVersion('2.1.0') || $upgrade->checkVersion('2.1') || $upgrade->checkVersion('2.1.1')) { // 2.1 to 2.1.2 $this->runTwoOneTwo(); } else { // 2.0 to 2.1 for ($i = 1; $i <= 4; $i++) { $this->runForm($i); } // 2.1 to 2.1.2 $this->runTwoOneTwo(); } // just change the ver in the db, since nothing to upgrade $upgrade->setVersion($upgrade->latestVersion); // also cleanup the templates_c directory $config = CRM_Core_Config::singleton(); $config->cleanup(1); $template = CRM_Core_Smarty::singleton(); $template->assign('message', $message); $template->assign('pageTitle', ts('Upgrade CiviCRM to Version %1', array(1 => $upgrade->latestVersion))); $template->assign('menuRebuildURL', CRM_Utils_System::url('civicrm/menu/rebuild', 'reset=1')); $contents = $template->fetch('CRM/common/success.tpl'); echo $contents; }
function run() { list($ext, $suite) = $this->getRequestExtAndSuite(); if (empty($ext) || empty($suite)) { throw new CRM_Core_Exception("FIXME: Not implemented: QUnit browser"); } if (!preg_match('/^[a-zA-Z0-9_\\-\\.]+$/', $suite) || strpos($suite, '..') !== FALSE) { throw new CRM_Core_Exception("Malformed suite name"); } $path = CRM_Extension_System::singleton()->getMapper()->keyToBasePath($ext); if (!is_dir("{$path}/tests/qunit/{$suite}")) { throw new CRM_Core_Exception("Failed to locate test suite"); } // Load the test suite -- including any PHP, TPL, or JS content if (file_exists("{$path}/tests/qunit/{$suite}/test.php")) { // e.g. load resources require_once "{$path}/tests/qunit/{$suite}/test.php"; } if (file_exists("{$path}/tests/qunit/{$suite}/test.tpl")) { // e.g. setup markup and/or load resources CRM_Core_Smarty::singleton()->addTemplateDir("{$path}/tests"); $this->assign('qunitTpl', "qunit/{$suite}/test.tpl"); } if (file_exists("{$path}/tests/qunit/{$suite}/test.js")) { CRM_Core_Resources::singleton()->addScriptFile($ext, "tests/qunit/{$suite}/test.js", 1000); } CRM_Utils_System::setTitle(ts('QUnit: %2 (%1)', array(1 => $ext, 2 => $suite))); CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'packages/qunit/qunit.js')->addStyleFile('civicrm', 'packages/qunit/qunit.css'); parent::run(); }
function run() { $smarty= CRM_Core_Smarty::singleton( ); $dummy = NULL; 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); //TODO: sql escape the params too unset($param['q']); $smarty->assign_by_ref("request", $param); CRM_Core_Resources::singleton() ->addScriptFile('eu.tttp.civisualize', 'js/d3.v3.js', 110, 'html-header', FALSE) ->addScriptFile('eu.tttp.civisualize', 'js/dc/dc.js', 110, 'html-header', FALSE) ->addScriptFile('eu.tttp.civisualize', 'js/dc/crossfilter.js', 110, 'html-header', FALSE) ->addStyleFile('eu.tttp.civisualize', 'js/dc/dc.css') ->addStyleFile('eu.tttp.civisualize', 'css/style.css'); require_once 'CRM/Core/Smarty/plugins/function.crmSQL.php'; $smarty->register_function("crmSQL", "smarty_function_crmSQL"); require_once 'CRM/Core/Smarty/plugins/function.crmRetrieve.php'; $smarty->register_function("crmRetrieve", "smarty_function_crmRetrieve"); require_once 'CRM/Core/Smarty/plugins/function.crmTitle.php'; $smarty->register_function("crmTitle", "smarty_function_crmTitle"); return parent::run(); }
/** * colours. * @var array * @static */ function buildChart(&$params, $chart) { $openFlashChart = array(); if ($chart && is_array($params) && !empty($params)) { $chartInstance = new $chart($params); $chartInstance->buildChart(); $chartObj = $chartInstance->getChart(); $openFlashChart = array(); if ($chartObj) { // calculate chart size. $xSize = CRM_Utils_Array::value('xSize', $params, 400); $ySize = CRM_Utils_Array::value('ySize', $params, 300); if ($chart == 'barChart') { $ySize = CRM_Utils_Array::value('ySize', $params, 250); $xSize = 60 * count($params['values']); //hack to show tooltip. if ($xSize < 200) { $xSize = count($params['values']) > 1 ? 100 * count($params['values']) : 170; } elseif ($xSize > 600 && count($params['values']) > 1) { $xSize = (count($params['values']) + 400 / count($params['values'])) * count($params['values']); } } // generate unique id for this chart instance $uniqueId = md5(uniqid(rand(), TRUE)); $openFlashChart["chart_{$uniqueId}"]['size'] = array('xSize' => $xSize, 'ySize' => $ySize); $openFlashChart["chart_{$uniqueId}"]['object'] = $chartObj; // assign chart data to template $template = CRM_Core_Smarty::singleton(); $template->assign('uniqueId', $uniqueId); $template->assign("openFlashChartData", json_encode($openFlashChart)); } } return $openFlashChart; }
/** * 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(); }
/** * 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); }
/** * @param $rev */ public function upgrade_4_1_alpha1($rev) { $config = CRM_Core_Config::singleton(); if (in_array('CiviCase', $config->enableComponents)) { if (!CRM_Case_BAO_Case::createCaseViews()) { $template = CRM_Core_Smarty::singleton(); $afterUpgradeMessage = ''; if ($afterUpgradeMessage = $template->get_template_vars('afterUpgradeMessage')) { $afterUpgradeMessage .= "<br/><br/>"; } $afterUpgradeMessage .= '<div class="crm-upgrade-case-views-error" style="background-color: #E43D2B; padding: 10px;">' . ts("There was a problem creating CiviCase database views. Please create the following views manually before using CiviCase:"); $afterUpgradeMessage .= '<div class="crm-upgrade-case-views-query"><div>' . CRM_Case_BAO_Case::createCaseViewsQuery('upcoming') . '</div><div>' . CRM_Case_BAO_Case::createCaseViewsQuery('recent') . '</div>' . '</div></div>'; $template->assign('afterUpgradeMessage', $afterUpgradeMessage); } } $upgrade = new CRM_Upgrade_Form(); $upgrade->processSQL($rev); $this->transferPreferencesToSettings(); $this->createNewSettings(); // now modify the config so that the directories are now stored in the settings table // CRM-8780 $params = array(); CRM_Core_BAO_ConfigSetting::add($params); // also reset navigation CRM_Core_BAO_Navigation::resetNavigation(); }
function generatexml($id) { $xml = ""; $template = CRM_Core_Smarty::singleton(); $this->get((int) $id); $template->assign("file", $this->toArray()); $txgroup = new CRM_Sepa_BAO_SEPATransactionGroup(); $txgroup->sdd_file_id = $this->id; $txgroup->find(); $total = 0; $nbtransactions = 0; $fileFormats = array(); while ($txgroup->fetch()) { $xml .= $txgroup->generateXML(); $total += $txgroup->total; $nbtransactions += $txgroup->nbtransactions; $fileFormats[] = $txgroup->fileFormat; } if (count(array_unique($fileFormats)) > 1) { throw new Exception('Creditors with mismatching File Formats cannot be mixed in same File'); } else { $fileFormatName = CRM_Utils_SepaOptionGroupTools::sanitizeFileFormat(reset($fileFormats)); } $template->assign("file", $this->toArray()); $template->assign("total", $total); $template->assign("nbtransactions", $nbtransactions); $head = $template->fetch('../formats/' . $fileFormatName . '/transaction-header.tpl'); $footer = $template->fetch('../formats/' . $fileFormatName . '/transaction-footer.tpl'); return $head . $xml . $footer; }
function add_participant_to_cart() { require 'CRM/Core/Transaction.php'; $transaction = new CRM_Core_Transaction(); $cart_id = $_GET['cart_id']; $event_id = $_GET['event_id']; $cart = CRM_Event_Cart_BAO_Cart::find_by_id($_GET['cart_id']); $params_array = array('cart_id' => $cart->id, 'contact_id' => CRM_Event_Cart_Form_Cart::find_or_create_contact(), 'event_id' => $event_id); //XXX security? $participant = CRM_Event_Cart_BAO_MerParticipant::create($params_array); $participant->save(); $form = new CRM_Core_Form(); $pform = new CRM_Event_Cart_Form_MerParticipant($participant); $pform->appendQuickForm($form); $renderer = $form->getRenderer(); $config = CRM_Core_Config::singleton(); $templateDir = $config->templateDir; if (is_array($templateDir)) { $templateDir = array_pop($templateDir); } $requiredTemplate = file_get_contents($templateDir . '/CRM/Form/label.tpl'); $renderer->setRequiredTemplate($requiredTemplate); $form->accept($renderer); $template = CRM_Core_Smarty::singleton(); $template->assign('form', $renderer->toArray()); $template->assign('participant', $participant); $output = $template->fetch("CRM/Event/Cart/Form/Checkout/Participant.tpl"); $transaction->commit(); echo $output; CRM_Utils_System::civiExit(); }
/** * Add an ics attachment to the input array. * * @param array $attachments * Reference to array in same format returned from CRM_Core_BAO_File::getEntityFile(). * @param array $contacts * Array of contacts (attendees). * * @return string|null * Array index of the added attachment in the $attachments array, else NULL. */ public function addAttachment(&$attachments, $contacts) { // Check preferences setting if (Civi::settings()->get('activity_assignee_notification_ics')) { $config =& CRM_Core_Config::singleton(); $this->icsfile = tempnam($config->customFileUploadDir, 'ics'); if ($this->icsfile !== FALSE) { rename($this->icsfile, $this->icsfile . '.ics'); $this->icsfile .= '.ics'; $icsFileName = basename($this->icsfile); // get logged in user's primary email // TODO: Is there a better way to do this? $organizer = $this->getPrimaryEmail(); $template = CRM_Core_Smarty::singleton(); $template->assign('activity', $this->activity); $template->assign('organizer', $organizer); $template->assign('contacts', $contacts); $template->assign('timezone', date_default_timezone_get()); $calendar = $template->fetch('CRM/Activity/Calendar/ICal.tpl'); if (file_put_contents($this->icsfile, $calendar) !== FALSE) { if (empty($attachments)) { $attachments = array(); } $attachments['activity_ics'] = array('mime_type' => 'text/calendar', 'fileName' => $icsFileName, 'cleanName' => $icsFileName, 'fullPath' => $this->icsfile); return 'activity_ics'; } } } return NULL; }
function run() { CRM_Utils_System::setTitle(ts('Public Vacancy List')); global $civicrm_root; global $base_url; //fetch listing $row = self::vacancyListDisplay(); $output = ''; $output .= '(function() {'; $output .= file_get_contents("{$civicrm_root}packages/backbone/lodash.compat.min.js"); //Add js file $templateDir = array("{$civicrm_root}packages/jquery/", "{$civicrm_root}packages/jquery/jquery-ui/js/"); foreach ($templateDir as $templateDir) { $files = (array) glob($templateDir . '*.min.js', GLOB_BRACE); foreach ($files as $file) { $output .= file_get_contents($file); } } //Add css files $scan = scandir("{$civicrm_root}packages/jquery/jquery-ui/css/theme/"); foreach ($scan as $file) { if (!is_dir("{$civicrm_root}packages/jquery/jquery-ui/css/theme/{$file}")) { $output .= "var link = document.createElement('link');\n link.rel = 'stylesheet';\n link.type = 'text/css';\n link.href = '{$base_url}/sites/all/modules/civicrm/packages/jquery/jquery-ui/css/theme/{$file}';\n link.media = 'all';\n document.getElementsByTagName('head')[0].appendChild(link);"; } } //Add template $output .= "var \$ = jQuery.noConflict();var c_ = _.noConflict();c_.templateSettings.variable = 'rc';"; $output .= CRM_Core_Smarty::singleton()->fetch('CRM/HRRecruitment/Page/WidgetJs.tpl'); $output .= "document.write('<div id=\\'vacancyPublicList\\'></div>');\n var div = document.getElementById('vacancyPublicList');\n div.innerHTML = listTemplate({$row});\n document.write('<div id=\\'vacancyListDialog\\'></div>');"; //Dialog box to display vacancy information $output .= '$(".hr-job-position-link").bind("click",function(e){ e.preventDefault(); var infourl = $(this).attr("href") + "&callback=?"; $.getJSON(infourl).done(function(result) { c_.templateSettings.variable = \'rc\'; $("#vacancyListDialog").html(infoTemplate(result)); $("#vacancyListDialog").dialog({ modal: true, width: 600, title: result.position, buttons: [ { text: result.applyButton, click: function () { window.location = result.apply; } }, { text: result.close, click: function () { $(this).dialog("close"); } } ] }); }); });'; $output .= '})();'; header('Content-type: text/javascript'); echo $output; exit; }
public static function getNavigationMenu() { $contactID = CRM_Core_Session::singleton()->get('userID'); if ($contactID) { CRM_Core_Page_AJAX::setJsHeaders(); print CRM_Core_Smarty::singleton()->fetchWith('CRM/Menufontawesome/Page/navigation.js.tpl', array('navigation' => CRM_Menufontawesome_BAO_Navigation::createNavigation($contactID))); } CRM_Utils_System::civiExit(); }
function generateXML($id = null) { $template = CRM_Core_Smarty::singleton(); if ($id) { $this->id = $id; } if (empty($this->id)) { CRM_Core_Error::fatal("missing id of the transaction group"); } $r = array(); $this->total = 0; $this->nbtransactions = 0; $group = civicrm_api("SepaTransactionGroup", "getsingle", array("sequential" => 1, "version" => 3, "id" => $this->id)); $creditor_id = $group["sdd_creditor_id"]; $template->assign("group", $group); $creditor = civicrm_api("SepaCreditor", "getsingle", array("sequential" => 1, "version" => 3, "id" => $creditor_id)); $template->assign("creditor", $creditor); $this->fileFormat = CRM_Core_OptionGroup::getValue('sepa_file_format', $creditor['sepa_file_format_id'], 'value', 'Integer', 'name'); $this->fileFormat = CRM_Utils_SepaOptionGroupTools::sanitizeFileFormat($this->fileFormat); $template->assign("fileFormat", $this->fileFormat); $queryParams = array(1 => array($this->id, 'Positive')); $query = "\n SELECT\n c.id,\n civicrm_contact.display_name,\n invoice_id,\n currency,\n total_amount,\n receive_date,\n contribution_recur_id,\n contribution_status_id,\n mandate.*\n FROM civicrm_contribution AS c\n JOIN civicrm_sdd_contribution_txgroup AS g ON g.contribution_id=c.id\n JOIN civicrm_sdd_mandate AS mandate ON mandate.id = IF(c.contribution_recur_id IS NOT NULL,\n (SELECT id FROM civicrm_sdd_mandate WHERE entity_table = 'civicrm_contribution_recur' AND entity_id = c.contribution_recur_id),\n (SELECT id FROM civicrm_sdd_mandate WHERE entity_table = 'civicrm_contribution' AND entity_id = c.id)\n )\n JOIN civicrm_contact ON c.contact_id = civicrm_contact.id\n WHERE g.txgroup_id = %1\n AND contribution_status_id != 3\n AND mandate.is_enabled = true\n "; //and not cancelled $contrib = CRM_Core_DAO::executeQuery($query, $queryParams); setlocale(LC_CTYPE, 'en_US.utf8'); //dear dear, it might work, but seems to be highly dependant of the system running it, without any way to know what is available, or if the setting was done properly #phpeature while ($contrib->fetch()) { $t = $contrib->toArray(); $t["iban"] = str_replace(array(' ', '-'), '', $t["iban"]); // try to convert the name into a more acceptable format if (function_exists("iconv")) { $t["display_name"] = iconv("UTF-8", "ASCII//TRANSLIT", $t["display_name"]); //french banks like utf8 as long as it's ascii7 only } // ...but to be sure, replace any remainig illegit characters with '?' $t["display_name"] = preg_replace("/[^ 0-9a-zA-Z':?,\\-(+.)\\/\"]/", '?', $t["display_name"]); // create an individual transaction message $t["message"] = CRM_Sepa_Logic_Settings::getTransactionMessage($t, $creditor); $r[] = $t; if ($creditor_id == null) { $creditor_id = $contrib->creditor_id; } elseif ($contrib->creditor_id == null) { // it shouldn't happen. $contrib->creditor_id = $creditor_id; } elseif ($creditor_id != $contrib->creditor_id) { CRM_Core_Error::fatal("mixed creditors ({$creditor_id} != {$contrib->creditor_id}) in the group - contribution {$contrib->id}"); //to fix the mandate: update civicrm_sdd_mandate set creditor_id=1; } $this->total += $contrib->total_amount; $this->nbtransactions++; } $template->assign("total", $this->total); $template->assign("nbtransactions", $this->nbtransactions); $template->assign("contributions", $r); return $template->fetch('../formats/' . $this->fileFormat . '/transaction-details.tpl'); }
/** * sets the title of the page * * @param string $title title to set * * @return void * @access public */ function setTitle($title) { $template =& CRM_Core_Smarty::singleton(); $template->assign('pageTitle', $title); global $mainframe; if ($mainframe) { $mainframe->setPageTitle($title); } return; }
/** * Static instance provider. * * Method providing static instance of SmartTemplate, as * in Singleton pattern. */ public static function &singleton() { if (version_compare(CRM_Utils_System::version(), '4.6', '<')) { // < 4.6: we need to create a wrapper $smarty = CRM_Core_Smarty::singleton(); $smarty_wrapper = new CRM_Banking_Helpers_Smarty($smarty); return $smarty_wrapper; } else { // >= 4.6: just use the core smarty implementation return CRM_Core_Smarty::singleton(); } }
/** * Build the widget * * @param array $args Widget arguments. * @param array $instance Widget instance. */ public function widget($args, $instance) { $widget = new CRM_Contribute_BAO_Widget(); $widget->contribution_page_id = $instance['cpageId']; if (!$widget->find(true)) { $widget = 'test here'; } $widgetVals = array('url_logo' => array('value' => $widget->url_logo), 'color_title' => array('value' => $widget->color_title), 'color_button' => array('value' => $widget->color_button), 'color_bar' => array('value' => $widget->color_bar), 'color_main_text' => array('value' => $widget->color_main_text), 'color_main' => array('value' => $widget->color_main), 'color_main_bg' => array('value' => $widget->color_main_bg), 'color_bg' => array('value' => $widget->color_bg), 'color_about_link' => array('value' => $widget->color_about_link), 'color_homepage_link' => array('value' => $widget->color_homepage_link)); $template = CRM_Core_Smarty::singleton()->fetchWith('CRM/Contribute/Page/Widget.tpl', array('widgetId' => $widget->id, 'cpageId' => $widget->contribution_page_id, 'form' => $widgetVals)); $classes = 'widget civicontribute-widget civicontribute-widget-' . $widget->contribution_page_id; echo "<div class=\"{$classes}\">{$template}</div>"; }
/** * (Delegated) Implementation of hook_civicrm_config * @param $config */ function _demoqueue_civix_civicrm_config(&$config) { $template =& CRM_Core_Smarty::singleton(); $extRoot = dirname(__FILE__) . DIRECTORY_SEPARATOR; $extDir = $extRoot . 'templates'; if (is_array($template->template_dir)) { array_unshift($template->template_dir, $extDir); } else { $template->template_dir = array($extDir, $template->template_dir); } $include_path = $extRoot . PATH_SEPARATOR . get_include_path(); set_include_path($include_path); }
/** * 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)); } } }
/** * Reuse drupal blocks into a left sidebar. Assign the generated template * to the smarty instance * * @return void * @access public * @static */ function sidebarLeft() { $blockIds = array(1, 2, 4, 8); $blocks = array(); foreach ($blockIds as $id) { require_once 'CRM/Core/Block.php'; $blocks[] = CRM_Core_Block::getContent($id); } require_once 'CRM/Core/Smarty.php'; $template =& CRM_Core_Smarty::singleton(); $template->assign_by_ref('blocks', $blocks); $sidebarLeft = $template->fetch('CRM/Block/blocks.tpl'); $template->assign_by_ref('sidebarLeft', $sidebarLeft); }
public function cleanup425() { $rows = CRM_Upgrade_Incremental_php_FourTwo::deleteInvalidPairs(); $template = CRM_Core_Smarty::singleton(); $columnHeaders = array("Contact ID", "ContributionID", "Contribution Status", "MembershipID", "Membership Type", "Start Date", "End Date", "Membership Status", "Action"); $template->assign('columnHeaders', $columnHeaders); $template->assign('rows', $rows); $preMessage = !empty($rows) ? ts('The following records have been processed. Membership records with action = Un-linked have been disconnected from the listed contribution record:') : ts('Could not find any records to process.'); $template->assign('preMessage', $preMessage); $postMessage = ts('You can <a href="%1">click here</a> to try running the 4.2 upgrade script again. <a href="%2" target="_blank">(Review upgrade documentation)</a>', array(1 => CRM_Utils_System::url('civicrm/upgrade', 'reset=1'), 2 => 'http://wiki.civicrm.org/confluence/display/CRMDOC/Installation+and+Upgrades')); $template->assign('postMessage', $postMessage); $content = $template->fetch('CRM/common/upgradeCleanup.tpl'); echo CRM_Utils_System::theme($content, FALSE, TRUE); }
function run() { $params = array(); $fields = array('version', 'TPE', 'date', 'montant', 'reference', 'url_retour', 'url_retour_ok', 'url_retour_err', 'lgue', 'societe', 'texte-libre', 'mail', 'MAC'); foreach ($fields as $field) { $params[$field] = CRM_Utils_Request::retrieve($field, 'String'); } $this->assign('fields', $params); $this->assign('url', CRM_Utils_Request::retrieve('submit_to', 'String')); $smarty = CRM_Core_Smarty::singleton(); echo $smarty->fetch("string:" . $this->getText()); die; parent::run(); }
function gocardless_dd_civicrm_config(&$config) { $template =& CRM_Core_Smarty::singleton(); $batchingRoot = dirname(__FILE__); $batchingDir = $batchingRoot . DIRECTORY_SEPARATOR . 'templates'; if (is_array($template->template_dir)) { array_unshift($template->template_dir, $batchingDir); } else { $template->template_dir = array($batchingDir, $template->template_dir); } // also fix php include path $include_path = $batchingRoot . PATH_SEPARATOR . get_include_path(); set_include_path($include_path); }
function civimobile_civicrm_config(&$config) { $tabRoot = dirname(__FILE__) . DIRECTORY_SEPARATOR; // fix php include path $include_path = $tabRoot . 'code' . PATH_SEPARATOR . get_include_path(); set_include_path($include_path); $template =& CRM_Core_Smarty::singleton(); $extRoot = dirname(__FILE__) . DIRECTORY_SEPARATOR; $extDir = $extRoot . 'templates'; if (is_array($template->template_dir)) { array_unshift($template->template_dir, $extDir); } else { $template->template_dir = array($extDir, $template->template_dir); } }