Beispiel #1
0
 /**
  * CRM-12337 Output navigation menu as executable javascript
  * @see smarty_function_crmNavigationMenu
  */
 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/common/navigation.js.tpl', array('navigation' => CRM_Core_BAO_Navigation::createNavigation($contactID)));
     }
     CRM_Utils_System::civiExit();
 }
Beispiel #2
0
 /**
  * CRM-12337 Output navigation menu as executable javascript.
  *
  * @see smarty_function_crmNavigationMenu
  */
 public static function getNavigationMenu()
 {
     $contactID = CRM_Core_Session::singleton()->get('userID');
     if ($contactID) {
         CRM_Core_Page_AJAX::setJsHeaders();
         $smarty = CRM_Core_Smarty::singleton();
         $smarty->assign('includeEmail', civicrm_api3('setting', 'getvalue', array('name' => 'includeEmailInName', 'group' => 'Search Preferences')));
         print $smarty->fetchWith('CRM/common/navigation.js.tpl', array('navigation' => CRM_Core_BAO_Navigation::createNavigation($contactID)));
     }
     CRM_Utils_System::civiExit();
 }
Beispiel #3
0
 /**
  * CRM-12337 Output navigation menu as executable javascript
  * @see smarty_function_crmNavigationMenu
  */
 static function getNavigationMenu()
 {
     $contactID = CRM_Core_Session::singleton()->get('userID');
     if ($contactID) {
         // Set headers to encourage browsers to cache for a long time
         $year = 60 * 60 * 24 * 364;
         header('Expires: ' . gmdate('D, d M Y H:i:s \\G\\M\\T', time() + $year));
         header('Content-Type:	application/javascript');
         header("Cache-Control: max-age={$year}, public");
         print CRM_Core_Smarty::singleton()->fetchWith('CRM/common/navigation.js.tpl', array('navigation' => CRM_Core_BAO_Navigation::createNavigation($contactID)));
     }
     CRM_Utils_System::civiExit();
 }
/**
 * Generate the nav menu
 *
 * @param array $params
 *   - is_default: bool, true if this is normal/default instance of the menu (which may be subject to CIVICRM_DISABLE_DEFAULT_MENU)
 * @param object $smarty the Smarty object
 *
 * @return string HTML
 */
function smarty_function_crmNavigationMenu($params, &$smarty)
{
    //check if logged in user has access CiviCRM permission and build menu
    $buildNavigation = !CRM_Core_Config::isUpgradeMode() && CRM_Core_Permission::check('access CiviCRM');
    if (defined('CIVICRM_DISABLE_DEFAULT_MENU') && CRM_Utils_Array::value('is_default', $params, FALSE)) {
        $buildNavigation = FALSE;
    }
    if ($buildNavigation) {
        $session = CRM_Core_Session::singleton();
        $contactID = $session->get('userID');
        if ($contactID) {
            $navigation = CRM_Core_BAO_Navigation::createNavigation($contactID);
            $smarty->assign('navigation', $navigation);
            return $smarty->fetch('CRM/common/Navigation.tpl');
        }
    }
    return '';
}
Beispiel #5
0
 /**
  * CRM-12337 Output navigation menu as executable javascript
  * @see smarty_function_crmNavigationMenu
  */
 static function getNavigationMenu()
 {
     $session = CRM_Core_Session::singleton();
     $contactID = $session->get('userID');
     if ($contactID) {
         // Set headers to encourage browsers to cache for a long time
         // If we want to refresh the menu we will send a different url
         $year = 60 * 60 * 24 * 364;
         header('Expires: ' . gmdate('D, d M Y H:i:s \\G\\M\\T', time() + $year));
         header('Content-Type:	application/javascript');
         header("Cache-Control: max-age={$year}, public");
         // Render template as a javascript file
         $smarty = CRM_Core_Smarty::singleton();
         $navigation = CRM_Core_BAO_Navigation::createNavigation($contactID);
         $smarty->assign('timeGenerated', date('d M Y H:i:s'));
         $smarty->assign('navigation', $navigation);
         print $smarty->fetch('CRM/common/Navigation.tpl');
     }
     CRM_Utils_System::civiExit();
 }
Beispiel #6
0
 /**
  * class constructor
  *
  * @return CRM_Core_Smarty
  * @access private
  */
 function __construct()
 {
     parent::__construct();
     $config =& CRM_Core_Config::singleton();
     if (isset($config->customTemplateDir) && $config->customTemplateDir) {
         $this->template_dir = array($config->customTemplateDir, $config->templateDir);
     } else {
         $this->template_dir = $config->templateDir;
     }
     $this->compile_dir = $config->templateCompileDir;
     //Check for safe mode CRM-2207
     if (ini_get('safe_mode')) {
         $this->use_sub_dirs = false;
     } else {
         $this->use_sub_dirs = true;
     }
     $this->plugins_dir = array($config->smartyDir . 'plugins', $config->pluginsDir);
     // add the session and the config here
     $session =& CRM_Core_Session::singleton();
     $this->assign_by_ref('config', $config);
     $this->assign_by_ref('session', $session);
     // check default editor and assign to template, store it in session to reduce db calls
     $defaultWysiwygEditor = $session->get('defaultWysiwygEditor');
     if (!$defaultWysiwygEditor && !CRM_Core_Config::isUpgradeMode()) {
         require_once 'CRM/Core/BAO/Preferences.php';
         $defaultWysiwygEditor = CRM_Core_BAO_Preferences::value('editor_id');
         $session->set('defaultWysiwygEditor', $defaultWysiwygEditor);
     }
     $this->assign('defaultWysiwygEditor', $defaultWysiwygEditor);
     global $tsLocale;
     $this->assign('langSwitch', CRM_Core_I18n::languages(true));
     $this->assign('tsLocale', $tsLocale);
     //check if logged in use has access CiviCRM permission and build menu
     require_once 'CRM/Core/Permission.php';
     $buildNavigation = CRM_Core_Permission::check('access CiviCRM');
     $this->assign('buildNavigation', $buildNavigation);
     if (!CRM_Core_Config::isUpgradeMode() && $buildNavigation) {
         require_once 'CRM/Core/BAO/Navigation.php';
         $contactID = $session->get('userID');
         if ($contactID) {
             $navigation =& CRM_Core_BAO_Navigation::createNavigation($contactID);
             $this->assign('navigation', $navigation);
         }
     }
     $this->register_function('crmURL', array('CRM_Utils_System', 'crmURL'));
     $printerFriendly = CRM_Utils_System::makeURL('snippet', false, false) . '2';
     $this->assign('printerFriendly', $printerFriendly);
 }