/** * Output navigation script tag * * @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) { $config = CRM_Core_Config::singleton(); //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 ($config->userFrameworkFrontend) { $buildNavigation = FALSE; } if ($buildNavigation) { $session = CRM_Core_Session::singleton(); $contactID = $session->get('userID'); if ($contactID) { // These params force the browser to refresh the js file when switching user, domain, or language // We don't put them as a query string because some browsers will refuse to cache a page with a ? in the url // We end the string with .js to trick apache mods into sending pro-caching headers // @see CRM_Admin_Page_AJAX::getNavigationMenu $lang = $config->lcMessages; $domain = CRM_Core_Config::domainID(); $key = CRM_Core_BAO_Navigation::getCacheKey($contactID); $src = CRM_Utils_System::url("civicrm/ajax/menujs/{$contactID}/{$lang}/{$domain}/{$key}.js"); return '<script type="text/javascript" src="' . $src . '"></script>'; } } return ''; }
/** * Implements hook_civicrm_navigationMenu(). */ function eventpermissions_civicrm_navigationMenu(&$params) { $searchParams = array('url' => 'civicrm/eventpermissions?reset=1'); $menuItems = array(); CRM_Core_BAO_Navigation::retrieve($searchParams, $menuItems); if (!empty($menuItems)) { return; } $searchParams = array('url' => 'civicrm/admin/options/participant_role?reset=1'); $menuItems = array(); CRM_Core_BAO_Navigation::retrieve($searchParams, $menuItems); $parent = CRM_Utils_Array::value('parent_id', $menuItems); $navId = CRM_Core_DAO::singleValueQuery("SELECT max(id) FROM civicrm_navigation"); if (is_int($navId)) { $navId++; } $basicAttrs = array('label' => ts('Event Permissions', array('domain' => 'com.aghstrategies.eventpermissions')), 'name' => 'Event Permissions', 'url' => 'civicrm/eventpermissions?reset=1', 'permission' => 'administer CiviCRM', 'active' => 1, 'navID' => $navId, 'parentID' => $parent); $searchParams = array('id' => $parent); $menuItems = array(); CRM_Core_BAO_Navigation::retrieve($searchParams, $menuItems); if (empty($menuItems['parent_id'])) { $params[$parent]['child'][$navId] = $basicAttrs; } else { $params[$menuItems['parent_id']]['child'][$parent]['child'][$navId] = array('attributes' => $basicAttrs); } }
/** * Output navigation script tag * * @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 CRM_Core_Smarty $smarty * The Smarty object. * * @return string * HTML */ function smarty_function_crmNavigationMenu($params, &$smarty) { $config = CRM_Core_Config::singleton(); //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 ($config->userFrameworkFrontend) { $buildNavigation = FALSE; } if ($buildNavigation) { $session = CRM_Core_Session::singleton(); $contactID = $session->get('userID'); if ($contactID) { // These params force the browser to refresh the js file when switching user, domain, or language // We don't put them as a query string because some browsers will refuse to cache a page with a ? in the url // @see CRM_Admin_Page_AJAX::getNavigationMenu $lang = $config->lcMessages; $domain = CRM_Core_Config::domainID(); $key = CRM_Core_BAO_Navigation::getCacheKey($contactID); $src = CRM_Utils_System::url("civicrm/ajax/menujs/{$contactID}/{$lang}/{$domain}/{$key}"); // CRM-15493 QFkey needed for quicksearch bar - must be unique on each page refresh so adding it directly to markup $qfKey = CRM_Core_Key::get('CRM_Contact_Controller_Search', TRUE); return '<script id="civicrm-navigation-menu" type="text/javascript" src="' . $src . '" data-qfkey=' . json_encode($qfKey) . '></script>'; } } return ''; }
/** * Reset navigation. * * @param array $params * Array of name/value pairs. * * @return array * API result array. */ function civicrm_api3_navigation_reset($params) { if ($params['for'] == 'report') { CRM_Core_BAO_Navigation::rebuildReportsNavigation($params['domain_id']); } CRM_Core_BAO_Navigation::resetNavigation(); return civicrm_api3_create_success(1, $params, 'navigation', 'reset'); }
/** * Run this page (figure out the action needed and perform it). */ public function run() { $instanceId = CRM_Report_Utils_Report::getInstanceID(); if (!$instanceId) { $instanceId = CRM_Report_Utils_Report::getInstanceIDForPath(); } if (is_numeric($instanceId)) { $instanceURL = CRM_Utils_System::url("civicrm/report/instance/{$instanceId}", 'reset=1'); CRM_Core_Session::singleton()->replaceUserContext($instanceURL); } $action = CRM_Utils_Request::retrieve('action', 'String', $this); $optionVal = CRM_Report_Utils_Report::getValueFromUrl($instanceId); $reportUrl = CRM_Utils_System::url('civicrm/report/list', "reset=1"); if ($action & CRM_Core_Action::DELETE) { if (!CRM_Core_Permission::check('administer Reports')) { $statusMessage = ts('You do not have permission to Delete Report.'); CRM_Core_Error::statusBounce($statusMessage, $reportUrl); } $navId = CRM_Core_DAO::getFieldValue('CRM_Report_DAO_ReportInstance', $instanceId, 'navigation_id', 'id'); CRM_Report_BAO_ReportInstance::del($instanceId); //delete navigation if exists if ($navId) { CRM_Core_BAO_Navigation::processDelete($navId); CRM_Core_BAO_Navigation::resetNavigation(); } CRM_Core_Session::setStatus(ts('Selected report has been deleted.'), ts('Deleted'), 'success'); } else { $templateInfo = CRM_Core_OptionGroup::getRowValues('report_template', "{$optionVal}", 'value'); if (empty($templateInfo)) { CRM_Core_Error::statusBounce('You have tried to access a report that does not exist.'); } $extKey = strpos($templateInfo['name'], '.'); $reportClass = NULL; if ($extKey !== FALSE) { $ext = CRM_Extension_System::singleton()->getMapper(); $reportClass = $ext->keyToClass($templateInfo['name'], 'report'); $templateInfo['name'] = $reportClass; } if (strstr($templateInfo['name'], '_Form') || !is_null($reportClass)) { $instanceInfo = array(); CRM_Report_BAO_ReportInstance::retrieve(array('id' => $instanceId), $instanceInfo); if (!empty($instanceInfo['title'])) { CRM_Utils_System::setTitle($instanceInfo['title']); $this->assign('reportTitle', $instanceInfo['title']); } else { CRM_Utils_System::setTitle($templateInfo['label']); $this->assign('reportTitle', $templateInfo['label']); } $wrapper = new CRM_Utils_Wrapper(); return $wrapper->run($templateInfo['name'], NULL, NULL); } CRM_Core_Session::setStatus(ts('Could not find template for the instance.'), ts('Template Not Found'), 'error'); } return CRM_Utils_System::redirect($reportUrl); }
/** * Add the given menu item to the CiviCRM navigation menu if it does not exist yet. * @param array parent_params the params array into whose 'child' attribute the new item will be added. * @param array $attributes the attributes array to be added to the navigation menu */ static function addNavigationMenuEntry(&$parent_params, $menu_entry_attributes) { // see if it is already in the menu... $menu_item_search = array('url' => $menu_entry_attributes['url']); $menu_items = array(); CRM_Core_BAO_Navigation::retrieve($menu_item_search, $menu_items); if (empty($menu_items)) { // it's not already contained, so we want to add it to the menu // insert at the bottom $parent_params['child'][] = array('attributes' => $menu_entry_attributes); } }
/** * Test that a navigation item can be retrieved by it's url. */ public function testGetNavItemByUrl() { $random_string = substr(sha1(rand()), 0, 7); $name = "Test Menu Link {$random_string}"; $url = "civicrm/test/{$random_string}"; $url_params = "reset=1"; $params = array('name' => $name, 'label' => ts($name), 'url' => "{$url}?{$url_params}", 'parent_id' => NULL, 'is_active' => TRUE, 'permission' => array('access CiviCRM')); CRM_Core_BAO_Navigation::add($params); $new_nav = CRM_Core_BAO_Navigation::getNavItemByUrl($url, $url_params); $this->assertObjectHasAttribute('id', $new_nav); $this->assertNotNull($new_nav->id); $new_nav->delete(); }
function queryrunner_civicrm_navigationMenu(&$params) { $menu_item_search = array('url' => 'civicrm/query-runner'); $menu_items = array(); CRM_Core_BAO_Navigation::retrieve($menu_item_search, $menu_items); if (!empty($menu_items)) { return; } $navId = CRM_Core_DAO::singleValueQuery('SELECT MAX(id) FROM civicrm_navigation') + 1; $adminID = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Navigation', 'Administer', 'id', 'name'); $systemID = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Navigation', 'System settings', 'id', 'name'); $params[$adminID]['child'][$systemID]['child'][$navId] = array('attributes' => array('label' => ts('Query Runner'), 'name' => 'Query Runner', 'url' => 'civicrm/query-runner', 'permission' => 'administer CiviCRM', 'operator' => 'AND', 'separator' => null, 'parentID' => $systemID, 'navID' => $navId, 'active' => 1)); }
function mailchimpsync_civicrm_navigationMenu(&$params) { // get the id of Administer Menu $administerMenuId = CRM_Core_DAO::getFieldValue('CRM_Core_BAO_Navigation', 'Administer', 'id', 'name'); CRM_Core_Error::debug_var('$administerMenuId', $administerMenuId); // skip adding menu if there is no administer menu if ($administerMenuId) { // get the maximum key under adminster menu $maxKey = max(array_keys($params[$administerMenuId]['child'])); $params[$administerMenuId]['child'][$maxKey + 1] = array('attributes' => array('label' => 'MailChimp Settings', 'name' => 'MailChimp Settings', 'url' => 'civicrm/mailchimp/apikeyregister', 'permission' => 'administer CiviCRM', 'operator' => NULL, 'separator' => TRUE, 'parentID' => $administerMenuId, 'navID' => $maxKey + 1, 'active' => 1)); CRM_Core_BAO_Navigation::add($params); } }
/** * run this page (figure out the action needed and perform it). * * @return void */ function run() { $instanceId = CRM_Report_Utils_Report::getInstanceID(); if (!$instanceId) { $instanceId = CRM_Report_Utils_Report::getInstanceIDForPath(); } $action = CRM_Utils_Request::retrieve('action', 'String', $this); $optionVal = CRM_Report_Utils_Report::getValueFromUrl($instanceId); $reportUrl = CRM_Utils_System::url('civicrm/report/list', "reset=1"); if ($action & CRM_Core_Action::DELETE) { if (!CRM_Core_Permission::check('administer Reports')) { $statusMessage = ts('Your do not have permission to Delete Report.'); CRM_Core_Error::statusBounce($statusMessage, $reportUrl); } $navId = CRM_Core_DAO::getFieldValue('CRM_Report_DAO_Instance', $instanceId, 'navigation_id', 'id'); CRM_Report_BAO_Instance::delete($instanceId); //delete navigation if exists if ($navId) { require_once 'CRM/Core/BAO/Navigation.php'; CRM_Core_BAO_Navigation::processDelete($navId); CRM_Core_BAO_Navigation::resetNavigation(); } CRM_Core_Session::setStatus(ts('Selected Instance has been deleted.')); } else { require_once 'CRM/Core/OptionGroup.php'; $templateInfo = CRM_Core_OptionGroup::getRowValues('report_template', "{$optionVal}", 'value'); $extKey = strpos($templateInfo['name'], '.'); $reportClass = null; if ($extKey !== FALSE) { require_once 'CRM/Core/Extensions.php'; $ext = new CRM_Core_Extensions(); $reportClass = $ext->keyToClass($templateInfo['name'], 'report'); $templateInfo['name'] = $reportClass; } if (strstr($templateInfo['name'], '_Form') || !is_null($reportClass)) { $instanceInfo = array(); CRM_Report_BAO_Instance::retrieve(array('id' => $instanceId), $instanceInfo); if (!empty($instanceInfo['title'])) { CRM_Utils_System::setTitle($instanceInfo['title']); $this->assign('reportTitle', $instanceInfo['title']); } else { CRM_Utils_System::setTitle($templateInfo['label']); $this->assign('reportTitle', $templateInfo['label']); } $wrapper = new CRM_Utils_Wrapper(); return $wrapper->run($templateInfo['name'], null, null); } CRM_Core_Session::setStatus(ts('Could not find template for the instance.')); } return CRM_Utils_System::redirect($reportUrl); }
/** * Implementation of hook_civicrm_uninstall * * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_uninstall */ function maxadditionalparticipants_civicrm_uninstall() { require_once "CRM/Core/DAO.php"; $maxparticipantMenuItem = array('Participant_Settings'); foreach ($maxparticipantMenuItem as $name) { $itemId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Navigation', $name, 'id', 'name', TRUE); if ($itemId) { CRM_Core_BAO_Navigation::processDelete($itemId); } } CRM_Core_BAO_Navigation::resetNavigation(); CRM_Core_DAO::executeQuery("DELETE FROM civicrm_setting WHERE group_name = 'Event Preferences' AND name = 'max_participants'"); return _maxadditionalparticipants_civix_civicrm_uninstall(); }
/** * 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 ''; }
/** * Implementation of hook_civicrm_install */ function simpledonate_civicrm_install() { //Add menu for donation page link under Contribution parent navigation //And Configuration link under Admin navigation $civiContributeParentId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Navigation', 'CiviContribute', 'id', 'name'); $params = array('domain_id' => CRM_Core_Config::domainID(), 'label' => 'Simple Donate Configuration', 'name' => 'Simple Donate Configuration', 'url' => 'civicrm/simple/donation/configuration?reset=1', 'permission' => 'access CiviContribute', 'parent_id' => $civiContributeParentId, 'has_separator' => 1, 'is_active' => 1); CRM_Core_BAO_Navigation::add($params); $contributionsParentId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Navigation', 'Contributions', 'id', 'name'); $donationNavigation = new CRM_Core_DAO_Navigation(); $params = array('domain_id' => CRM_Core_Config::domainID(), 'label' => 'Simple Donate', 'name' => 'Simple Donate', 'url' => NULL, 'permission' => 'access CiviContribute', 'parent_id' => $contributionsParentId, 'has_separator' => 1, 'is_active' => 1, 'weight' => 100); $donationNavigation->copyValues($params); $donationNavigation->save(); $donationMenuTree = array(array('label' => ts('Test mode'), 'name' => 'Test Donation', 'url' => 'civicrm/simple?test=1#/donation', 'permission' => 'access CiviContribute'), array('label' => ts('Live mode'), 'name' => 'Live Donation', 'url' => 'civicrm/simple/#/donation', 'permission' => 'access CiviContribute')); foreach ($donationMenuTree as $key => $menuItems) { $menuItems['is_active'] = 1; $menuItems['parent_id'] = $donationNavigation->id; $menuItems['weight'] = $key; CRM_Core_BAO_Navigation::add($menuItems); } return _simpledonate_civix_civicrm_install(); }
/** * Create instance. * takes an associative array and creates a instance object and does any related work like permissioning, adding to dashboard etc. * * This function is invoked from within the web form layer and also from the api layer * * @param array $params * (reference ) an assoc array of name/value pairs. * * @return CRM_Report_BAO_ReportInstance */ public static function &create(&$params) { if (isset($params['report_header'])) { $params['header'] = CRM_Utils_Array::value('report_header', $params); } if (isset($params['report_footer'])) { $params['footer'] = CRM_Utils_Array::value('report_footer', $params); } // build navigation parameters if (!empty($params['is_navigation'])) { if (!array_key_exists('navigation', $params)) { $params['navigation'] = array(); } $navigationParams =& $params['navigation']; $navigationParams['permission'] = array(); $navigationParams['label'] = $params['title']; $navigationParams['name'] = $params['title']; $navigationParams['current_parent_id'] = CRM_Utils_Array::value('parent_id', $navigationParams); $navigationParams['parent_id'] = CRM_Utils_Array::value('parent_id', $params); $navigationParams['is_active'] = 1; if ($permission = CRM_Utils_Array::value('permission', $params)) { $navigationParams['permission'][] = $permission; } // unset the navigation related elements, not used in report form values unset($params['parent_id']); unset($params['is_navigation']); } // add to dashboard $dashletParams = array(); if (!empty($params['addToDashboard'])) { $dashletParams = array('label' => $params['title'], 'is_active' => 1); if ($permission = CRM_Utils_Array::value('permission', $params)) { $dashletParams['permission'][] = $permission; } } $transaction = new CRM_Core_Transaction(); $instance = self::add($params); if (is_a($instance, 'CRM_Core_Error')) { $transaction->rollback(); return $instance; } // add / update navigation as required if (!empty($navigationParams)) { if (empty($params['id']) && empty($params['instance_id']) && !empty($navigationParams['id'])) { unset($navigationParams['id']); } $navigationParams['url'] = "civicrm/report/instance/{$instance->id}?reset=1"; $navigation = CRM_Core_BAO_Navigation::add($navigationParams); if (!empty($navigationParams['is_active'])) { //set the navigation id in report instance table CRM_Core_DAO::setFieldValue('CRM_Report_DAO_ReportInstance', $instance->id, 'navigation_id', $navigation->id); } else { // has been removed from the navigation bar CRM_Core_DAO::setFieldValue('CRM_Report_DAO_ReportInstance', $instance->id, 'navigation_id', 'NULL'); } //reset navigation CRM_Core_BAO_Navigation::resetNavigation(); } // add to dashlet if (!empty($dashletParams)) { $section = 2; $chart = ''; if (!empty($params['charts'])) { $section = 1; $chart = "&charts=" . $params['charts']; } $limitResult = NULL; if (!empty($params['row_count'])) { $limitResult = '&rowCount=' . $params['row_count']; } $dashletParams['name'] = "report/{$instance->id}"; $dashletParams['url'] = "civicrm/report/instance/{$instance->id}?reset=1§ion={$section}&snippet=5{$chart}&context=dashlet" . $limitResult; $dashletParams['fullscreen_url'] = "civicrm/report/instance/{$instance->id}?reset=1§ion={$section}&snippet=5{$chart}&context=dashletFullscreen" . $limitResult; $dashletParams['instanceURL'] = "civicrm/report/instance/{$instance->id}"; CRM_Core_BAO_Dashboard::addDashlet($dashletParams); } $transaction->commit(); return $instance; }
/** * Post process function. * * @param CRM_Core_Form $form * @param bool $redirect */ public static function postProcess(&$form, $redirect = TRUE) { $params = $form->getVar('_params'); $instanceID = $form->getVar('_id'); if ($isNew = $form->getVar('_createNew')) { // set the report_id since base template is going to be same, and we going to unset $instanceID // which will make it difficult later on, to compute report_id $params['report_id'] = CRM_Report_Utils_Report::getValueFromUrl($instanceID); // Unset $instanceID so a new copy would be created. $instanceID = NULL; } $params['instance_id'] = $instanceID; if (!empty($params['is_navigation'])) { $params['navigation'] = $form->_navigation; } elseif ($instanceID) { // Delete navigation if exists. $navId = CRM_Core_DAO::getFieldValue('CRM_Report_DAO_ReportInstance', $instanceID, 'navigation_id', 'id'); if ($navId) { CRM_Core_BAO_Navigation::processDelete($navId); CRM_Core_BAO_Navigation::resetNavigation(); } } // make a copy of params $formValues = $params; // unset params from $formValues that doesn't match with DB columns of instance tables, and also not required in form-values for sure $unsetFields = array('title', 'to_emails', 'cc_emails', 'header', 'footer', 'qfKey', 'id', '_qf_default', 'report_header', 'report_footer', 'grouprole'); foreach ($unsetFields as $field) { unset($formValues[$field]); } $view_mode = $formValues['view_mode']; // pass form_values as string $params['form_values'] = serialize($formValues); $instance = CRM_Report_BAO_ReportInstance::create($params); $form->set('id', $instance->id); if ($instanceID && !$isNew) { // updating existing instance $statusMsg = ts('"%1" report has been updated.', array(1 => $instance->title)); } elseif ($form->getVar('_id') && $isNew) { $statusMsg = ts('Your report has been successfully copied as "%1". You are currently viewing the new copy.', array(1 => $instance->title)); } else { $statusMsg = ts('"%1" report has been successfully created. You are currently viewing the new report instance.', array(1 => $instance->title)); } CRM_Core_Session::setStatus($statusMsg); if ($redirect) { $urlParams = array('reset' => 1); if ($view_mode == 'view') { $urlParams['force'] = 1; } else { $urlParams['output'] = 'criteria'; } CRM_Utils_System::redirect(CRM_Utils_System::url("civicrm/report/instance/{$instance->id}", $urlParams)); } }
public function testFixNavigationMenu_inferIDs_deep() { $input[10] = array('attributes' => array('label' => 'Custom Menu Entry', 'parentID' => NULL, 'navID' => 10, 'active' => 1), 'child' => array('0' => array('attributes' => array('label' => 'Custom Child Menu'), 'child' => array('100' => array('attributes' => array('label' => 'Custom Child Menu 2', 'navID' => 100), 'child' => NULL))))); $output = $input; CRM_Core_BAO_Navigation::fixNavigationMenu($output); $this->assertEquals('Custom Menu Entry', $output[10]['attributes']['label']); $this->assertEquals(NULL, $output[10]['attributes']['parentID']); $this->assertEquals(10, $output[10]['attributes']['navID']); $this->assertEquals('Custom Child Menu', $output[10]['child'][101]['attributes']['label']); $this->assertEquals(10, $output[10]['child'][101]['attributes']['parentID']); $this->assertEquals(101, $output[10]['child'][101]['attributes']['navID']); $this->assertEquals('Custom Child Menu 2', $output[10]['child'][101]['child'][100]['attributes']['label']); $this->assertEquals(101, $output[10]['child'][101]['child'][100]['attributes']['parentID']); $this->assertEquals(100, $output[10]['child'][101]['child'][100]['attributes']['navID']); }
/** * @param bool $triggerRebuild * @param bool $sessionReset * * @throws Exception */ public static function rebuildMenuAndCaches($triggerRebuild = FALSE, $sessionReset = FALSE) { $config = CRM_Core_Config::singleton(); $config->clearModuleList(); // also cleanup all caches $config->cleanupCaches($sessionReset || CRM_Utils_Request::retrieve('sessionReset', 'Boolean', CRM_Core_DAO::$_nullObject, FALSE, 0, 'GET')); CRM_Core_Menu::store(); // also reset navigation CRM_Core_BAO_Navigation::resetNavigation(); // also cleanup module permissions $config->cleanupPermissions(); // rebuild word replacement cache - pass false to prevent operations redundant with this fn CRM_Core_BAO_WordReplacement::rebuild(FALSE); Civi::service('settings_manager')->flush(); // Clear js caches CRM_Core_Resources::singleton()->flushStrings()->resetCacheCode(); CRM_Case_XMLRepository::singleton(TRUE); // also rebuild triggers if requested explicitly if ($triggerRebuild || CRM_Utils_Request::retrieve('triggerRebuild', 'Boolean', CRM_Core_DAO::$_nullObject, FALSE, 0, 'GET')) { CRM_Core_DAO::triggerRebuild(); } CRM_Core_DAO_AllCoreTables::reinitializeCache(TRUE); CRM_Core_ManagedEntities::singleton(TRUE)->reconcile(); //CRM-16257 update Config.IDS.ini might be an old copy CRM_Core_IDS::createConfigFile(TRUE); }
/** * This hook is used to add the web tracking report link to the navigation menu * */ function webtracking_civicrm_navigationMenu(&$params) { // Check that our item doesn't already exist $menu_item_search = array('url' => 'civicrm/report/webtracking'); $menu_items = array(); CRM_Core_BAO_Navigation::retrieve($menu_item_search, $menu_items); if (!empty($menu_items)) { return; } $navId = CRM_Core_DAO::singleValueQuery("SELECT max(id) FROM civicrm_navigation"); if (is_integer($navId)) { $navId++; } // Find the Report menu $reportID = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Navigation', 'Reports', 'id', 'name'); $params[$reportID]['child'][$navId] = array('attributes' => array('label' => ts('Web Tracking Report', array('domain' => 'org.civicrm.webtracking')), 'name' => 'Web Tracking Report', 'url' => 'civicrm/report/webtracking', 'permission' => 'access CiviReport,access CiviEvent', 'operator' => 'OR', 'separator' => 1, 'parentID' => $reportID, 'navID' => $navId, 'active' => 1)); }
/** * Function to process drag/move action for menu tree */ static function menuTree() { CRM_Core_BAO_Navigation::processNavigation($_GET); }
/** * Function to process drag/move action for menu tree */ static function menuTree() { echo CRM_Core_BAO_Navigation::processNavigation($_GET); CRM_Utils_System::civiExit(); }
/** * Function to process the form * * @access public * @return None */ public function postProcess() { // get the submitted form values. $params = $this->controller->exportValues($this->_name); if (isset($this->_id)) { $params['id'] = $this->_id; $params['current_parent_id'] = $this->_currentParentID; } $navigation = CRM_Core_BAO_Navigation::add($params); // also reset navigation require_once 'CRM/Core/BAO/Navigation.php'; CRM_Core_BAO_Navigation::resetNavigation(); CRM_Core_Session::setStatus(ts('Menu \'%1\' has been saved.', array(1 => $navigation->label))); }
/** * Implementation of hook_civicrm_disable */ function hrabsence_civicrm_disable() { //Disable the Navigation menu and submenus $sql = "UPDATE civicrm_navigation SET is_active=0 WHERE name IN ('Absences','my_absences', 'calendar', 'new_absence', 'publicHolidays', 'absencePeriods', 'absenceTypes', 'absence_report','absenceReport')"; CRM_Core_DAO::executeQuery($sql); CRM_Core_BAO_Navigation::resetNavigation(); CRM_Core_DAO::executeQuery("UPDATE civicrm_msg_template SET is_active=0 WHERE msg_title = 'Absence Email'"); _hrabsence_setActiveFields(0); return _hrabsence_civix_civicrm_disable(); }
function _hrjob_setActiveFields($setActive) { $sql = "UPDATE civicrm_navigation SET is_active= {$setActive} WHERE name IN ('jobs','jobImport','hoursType')"; CRM_Core_DAO::executeQuery($sql); CRM_Core_BAO_Navigation::resetNavigation(); //disable/enable customgroup and customvalue $sql = "UPDATE civicrm_custom_field JOIN civicrm_custom_group ON civicrm_custom_group.id = civicrm_custom_field.custom_group_id SET civicrm_custom_field.is_active = {$setActive} WHERE civicrm_custom_group.name = 'HRJob_Summary'"; CRM_Core_DAO::executeQuery($sql); CRM_Core_DAO::executeQuery("UPDATE civicrm_custom_group SET is_active = {$setActive} WHERE name = 'HRJob_Summary'"); //disable/enable optionGroup and optionValue $query = "UPDATE civicrm_option_value JOIN civicrm_option_group ON civicrm_option_group.id = civicrm_option_value.option_group_id SET civicrm_option_value.is_active = {$setActive} WHERE civicrm_option_group.name IN ('hrjob_contract_type', 'hrjob_level_type', 'hrjob_department', 'hrjob_hours_type', 'hrjob_pay_grade', 'hrjob_health_provider', 'hrjob_life_provider', 'hrjob_location', 'hrjob_pension_type', 'hrjob_region', 'hrjob_pay_scale')"; CRM_Core_DAO::executeQuery($query); CRM_Core_DAO::executeQuery("UPDATE civicrm_option_group SET is_active = {$setActive} WHERE name IN ('hrjob_contract_type', 'hrjob_level_type', 'hrjob_department', 'hrjob_hours_type', 'hrjob_pay_grade', 'hrjob_health_provider', 'hrjob_life_provider', 'hrjob_location', 'hrjob_pension_type', 'hrjob_region', 'hrjob_pay_scale')"); }
/** * Rebuild. * * @param bool $clearCaches * * @return bool */ public static function rebuild($clearCaches = TRUE) { $id = CRM_Core_Config::domainID(); self::_setLocaleCustomStrings($id, self::getAllAsConfigArray($id)); // Partially mitigate the inefficiency introduced in CRM-13187 by doing this conditionally if ($clearCaches) { // Reset navigation CRM_Core_BAO_Navigation::resetNavigation(); // Clear js localization CRM_Core_Resources::singleton()->flushStrings()->resetCacheCode(); } return TRUE; }
public function postProcess() { $params = $this->controller->exportValues($this->_name); $params['enableComponentIDs'] = array(); foreach ($params['enableComponents'] as $name) { $params['enableComponentIDs'][] = $this->_components[$name]->componentID; } parent::commonProcess($params); // reset navigation when components are enabled / disabled require_once 'CRM/Core/BAO/Navigation.php'; CRM_Core_BAO_Navigation::resetNavigation(); }
public function upgrade_1300() { $this->ctx->log->info('Applying update 1300'); $sql = "Update civicrm_case_type SET is_active = 0 where name IN ('AdultDayCareReferral', 'HousingSupport', 'adult_day_care_referral', 'housing_support')"; CRM_Core_DAO::executeQuery($sql); $values = NULL; $caseTypes = CRM_Case_PseudoConstant::caseType('name', FALSE); foreach (array('Exiting', 'Joining', 'Probation', 'Hrdata') as $caseName) { if ($caseID = array_search($caseName, $caseTypes)) { $values .= " WHEN '{$caseName}' THEN '{$caseID}'"; } } if ($values) { $query = "UPDATE civicrm_managed\n SET entity_id = CASE name\n {$values}\n END, entity_type = 'caseType' WHERE name IN ('Exiting', 'Joining', 'Probation', 'Hrdata');"; CRM_Core_DAO::executeQuery($query); CRM_Core_BAO_Navigation::resetNavigation(); } return TRUE; }
public function postProcess() { $params = $this->controller->exportValues($this->_name); parent::commonProcess($params); // reset navigation when components are enabled / disabled CRM_Core_BAO_Navigation::resetNavigation(); }
/** * Update the is_active flag in the db. * * @param int $id * Id of the database record. * @param bool $is_active * Value we want to set the is_active field. * * @return Object * DAO object on success, null otherwise */ public static function setIsActive($id, $is_active) { $params = array('id' => $id); self::retrieve($params, $contactinfo); $params = array('name' => "New {$contactinfo['name']}"); $newParams = array('is_active' => $is_active); CRM_Core_BAO_Navigation::processUpdate($params, $newParams); CRM_Core_BAO_Navigation::resetNavigation(); return CRM_Core_DAO::setFieldValue('CRM_Contact_DAO_ContactType', $id, 'is_active', $is_active); }
static function rebuildMenuAndCaches($triggerRebuild = FALSE, $sessionReset = FALSE) { $config = CRM_Core_Config::singleton(); $config->clearModuleList(); // also cleanup all caches $config->cleanupCaches($sessionReset || CRM_Utils_Request::retrieve('sessionReset', 'Boolean', CRM_Core_DAO::$_nullObject, FALSE, 0, 'GET')); CRM_Core_Menu::store(); // also reset navigation CRM_Core_BAO_Navigation::resetNavigation(); // also cleanup module permissions $config->cleanupPermissions(); // also rebuild word replacement cache CRM_Core_BAO_WordReplacement::rebuild(); CRM_Core_BAO_Setting::updateSettingsFromMetaData(); CRM_Core_Resources::singleton()->resetCacheCode(); // also rebuild triggers if requested explicitly if ($triggerRebuild || CRM_Utils_Request::retrieve('triggerRebuild', 'Boolean', CRM_Core_DAO::$_nullObject, FALSE, 0, 'GET')) { CRM_Core_DAO::triggerRebuild(); } CRM_Core_DAO_AllCoreTables::reinitializeCache(TRUE); CRM_Core_ManagedEntities::singleton(TRUE)->reconcile(); }
/** * 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); }