/** * Implementation of hook_civicrm_enable */ function booking_civicrm_enable() { // rebuild the menu so our path is picked up require_once 'CRM/Core/Invoke.php'; CRM_Core_Invoke::rebuildMenuAndCaches(); return _booking_civix_civicrm_enable(); }
/** * Implementation of hook_civicrm_uninstall */ function eventcalendar_civicrm_uninstall() { $cividiscountRoot = dirname(__FILE__) . DIRECTORY_SEPARATOR; $cividiscountSQL = $cividiscountRoot . DIRECTORY_SEPARATOR . 'uninstall.sql'; CRM_Utils_File::sourceSQLFile(CIVICRM_DSN, $cividiscountSQL); // rebuild the menu so our path is picked up CRM_Core_Invoke::rebuildMenuAndCaches(); //return _eventcalendar_civix_civicrm_uninstall(); }
/** * Implementation of hook_civicrm_install */ function civigiftaid_civicrm_install() { require_once 'CRM/Utils/Migrate/Import.php'; $import = new CRM_Utils_Migrate_Import(); $extRoot = dirname(__FILE__) . DIRECTORY_SEPARATOR; $op = $extRoot . 'xml' . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR . 'CustomGroupData.xml'; $import->run($op); // rebuild the menu so our path is picked up require_once 'CRM/Core/Invoke.php'; CRM_Core_Invoke::rebuildMenuAndCaches(); return _civigiftaid_civix_civicrm_install(); }
function postProcess() { $values = $this->exportValues(); // process menu entry $old_menu_position = (int) CRM_Core_BAO_Setting::getItem('CiviBanking', 'menu_position'); $new_menu_position = (int) $values['menu_position']; if ($old_menu_position != $new_menu_position) { CRM_Core_BAO_Setting::setItem($new_menu_position, 'CiviBanking', 'menu_position'); CRM_Core_Invoke::rebuildMenuAndCaches(); } parent::postProcess(); }
/** * Example: Run a simple query when a module is disabled. */ public function disable() { //~ CRM_Core_DAO::executeQuery('UPDATE foo SET is_active = 0 WHERE bar = "whiz"'); $this->executeSqlFile('sql/disable.sql'); CRM_Core_Invoke::rebuildMenuAndCaches(); try { $dashlet = civicrm_api3('Dashboard', 'get', array('name' => 'eventcalendardashlet')); if (!empty($dashlet['id'])) { civicrm_api3('Dashboard', 'create', array('id' => $dashlet['id'], 'is_active' => 0)); } } catch (Exception $e) { die(__METHOD__ . ' error: ' . $e->getMessage()); } }
function postProcess() { $values = $this->exportValues(); // process menu entry $old_menu_position = (int) CRM_Core_BAO_Setting::getItem('CiviBanking', 'menu_position'); $new_menu_position = (int) $values['menu_position']; if ($old_menu_position != $new_menu_position) { CRM_Core_BAO_Setting::setItem($new_menu_position, 'CiviBanking', 'menu_position'); CRM_Core_Invoke::rebuildMenuAndCaches(); } // process reference normalisation / validation CRM_Core_BAO_Setting::setItem(!empty($values['reference_normalisation']), 'CiviBanking', 'reference_normalisation'); CRM_Core_BAO_Setting::setItem(!empty($values['reference_validation']), 'CiviBanking', 'reference_validation'); parent::postProcess(); }
/** * Upgrade an extension - runs upgrade_N hooks and system.flush. * * @return array * API result */ function civicrm_api3_extension_upgrade() { CRM_Core_Invoke::rebuildMenuAndCaches(TRUE); $queue = CRM_Extension_Upgrades::createQueue(); $runner = new CRM_Queue_Runner(array('title' => 'Extension Upgrades', 'queue' => $queue, 'errorMode' => CRM_Queue_Runner::ERROR_ABORT)); try { $result = $runner->runAll(); } catch (CRM_Extension_Exception $e) { return civicrm_api3_create_error($e->getMessage()); } if ($result === TRUE) { return civicrm_api3_create_success(); } else { return $result; } }
/** * Remove all database references to an extension. * * Add records of the extension to the database -- and enable it * * @param array $keys * List of extension keys. * @throws CRM_Extension_Exception */ public function uninstall($keys) { $origStatuses = $this->getStatuses(); // TODO: to mitigate the risk of crashing during installation, scan // keys/statuses/types before doing anything foreach ($keys as $key) { switch ($origStatuses[$key]) { case self::STATUS_INSTALLED: case self::STATUS_INSTALLED_MISSING: throw new CRM_Extension_Exception("Cannot uninstall extension; disable it first: {$key}"); case self::STATUS_DISABLED: list($info, $typeManager) = $this->_getInfoTypeHandler($key); // throws Exception $typeManager->onPreUninstall($info); $this->_removeExtensionEntry($info); $typeManager->onPostUninstall($info); break; case self::STATUS_DISABLED_MISSING: list($info, $typeManager) = $this->_getMissingInfoTypeHandler($key); // throws Exception $typeManager->onPreUninstall($info); $this->_removeExtensionEntry($info); $typeManager->onPostUninstall($info); break; case self::STATUS_UNINSTALLED: // ok, nothing to do break; case self::STATUS_UNKNOWN: default: throw new CRM_Extension_Exception("Cannot disable unknown extension: {$key}"); } } $this->statuses = NULL; $this->mapper->refresh(); CRM_Core_Invoke::rebuildMenuAndCaches(TRUE); }
public function upgrade_1400() { $this->ctx->log->info('Applying update 1400'); $i = 3; foreach (array('Joining', 'Probation') as $caseName) { CRM_Core_DAO::executeQuery("UPDATE civicrm_case_type SET weight = {$i} WHERE name = '{$caseName}'"); $i++; } CRM_Core_DAO::executeQuery("UPDATE civicrm_case_type SET weight = 6 WHERE name = 'Exiting'"); $this->executeSqlFile('sql/activities_install.sql'); require_once 'hrcase.php'; $scheduleActions = hrcase_getActionsSchedule(); foreach ($scheduleActions as $actionName => $scheduleAction) { $result = civicrm_api3('action_schedule', 'get', array('name' => $actionName)); if (empty($result['id'])) { $result = civicrm_api3('action_schedule', 'create', $scheduleAction); } } $existingCaseType = array('Appraisal'); $this->manageCaseTypes($existingCaseType); CRM_Core_Invoke::rebuildMenuAndCaches(TRUE); //update query to replace Case with Assignment $optionGroupID = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', 'activity_type', 'id', 'name'); $sql = "UPDATE civicrm_option_value SET label= replace(label,'Case','Assignment') WHERE label like '%Case%' and option_group_id={$optionGroupID} and label <> 'Open Case'"; CRM_Core_DAO::executeQuery($sql); $sql = "UPDATE civicrm_option_value SET label= replace(label,'Open Case','Created New Assignment') WHERE label like '%Case%' and option_group_id={$optionGroupID}"; CRM_Core_DAO::executeQuery($sql); return TRUE; }
/** * Flush all system caches * * @param array $params input parameters * - triggers: bool, whether to drop/create SQL triggers; default: FALSE * - session: bool, whether to reset the CiviCRM session data; defaul: FALSE * * @return boolean true if success, else false * @static void * @access public * @example SystemFlush.php * */ function civicrm_api3_system_flush($params) { CRM_Core_Invoke::rebuildMenuAndCaches(CRM_Utils_Array::value('triggers', $params, FALSE), CRM_Utils_Array::value('session', $params, FALSE)); return civicrm_api3_create_success(); }
/** * Process the form submission. * * @return void */ public function postProcess() { $params = $this->controller->exportValues($this->_name); $permissionsArray = self::getPermissionArray(); // Function to get Wordpress roles global $wp_roles; if (!isset($wp_roles)) { $wp_roles = new WP_Roles(); } foreach ($wp_roles->role_names as $role => $name) { $roleObj = $wp_roles->get_role($role); //Remove all civicrm capabilities for the role, as there may be some capabilities checkbox unticked foreach ($permissionsArray as $key => $capability) { $roleObj->remove_cap($key); } //Add the selected wordpress capabilities for the role $rolePermissions = $params[$role]; if (!empty($rolePermissions)) { foreach ($rolePermissions as $key => $capability) { $roleObj->add_cap($key); } } if ($role == 'anonymous_user') { // Get the permissions into a format that matches what we get from WP $allWarningPermissions = CRM_Core_Permission::getAnonymousPermissionsWarnings(); foreach ($allWarningPermissions as $key => $permission) { $allWarningPermissions[$key] = CRM_utils_String::munge(strtolower($permission)); } $warningPermissions = array_intersect($allWarningPermissions, array_keys($rolePermissions)); $warningPermissionNames = array(); foreach ($warningPermissions as $permission) { $warningPermissionNames[$permission] = $permissionsArray[$permission]; } if (!empty($warningPermissionNames)) { CRM_Core_Session::setStatus(ts('The %1 role was assigned one or more permissions that may prove dangerous for users of that role to have. Please reconsider assigning %2 to them.', array(1 => $wp_roles->role_names[$role], 2 => implode(', ', $warningPermissionNames))), ts('Unsafe Permission Settings')); } } } // FIXME // Changed the 'access_civicrm_nav_link' capability in civicrm.php file // But for some reason, if i remove 'Access CiviCRM' administrator and save, it is showing // 'You do not have sufficient permissions to access this page' // which should not happen for Super Admin and Administrators, as checking permissions for Super // Admin and Administrators always gives TRUE wp_civicrm_capability(); CRM_Core_Session::setStatus("", ts('Wordpress Access Control Updated'), "success"); // rebuild the menus to comply with the new permisssions/capabilites CRM_Core_Invoke::rebuildMenuAndCaches(); CRM_Utils_System::redirect('admin.php?page=CiviCRM&q=civicrm/admin/access&reset=1'); CRM_Utils_System::civiExit(); }
/** * Function to process the form * * @access public * @return void */ public function postProcess() { $params = $this->controller->exportValues($this->_name); $permissionsArray = self::getPermissionArray(); // Function to get Wordpress roles global $wp_roles; if (!isset($wp_roles)) { $wp_roles = new WP_Roles(); } foreach ($wp_roles->role_names as $role => $name) { $roleObj = $wp_roles->get_role($role); //Remove all civicrm capabilities for the role, as there may be some capabilities checkbox unticked foreach ($permissionsArray as $key => $capability) { $roleObj->remove_cap($key); } //Add the selected wordpress capabilities for the role $rolePermissions = $params[$role]; if (!empty($rolePermissions)) { foreach ($rolePermissions as $key => $capability) { $roleObj->add_cap($key); } } } // FIXME // Changed the 'access_civicrm_nav_link' capability in civicrm.php file // But for some reason, if i remove 'Access CiviCRM' administrator and save, it is showing // 'You do not have sufficient permissions to access this page' // which should not happen for Super Admin and Administrators, as checking permissions for Super // Admin and Administrators always gives TRUE wp_civicrm_capability(); CRM_Core_Session::setStatus("", ts('Wordpress Access Control Updated'), "success"); // rebuild the menus to comply with the new permisssions/capabilites CRM_Core_Invoke::rebuildMenuAndCaches(); CRM_Utils_System::redirect('admin.php?page=CiviCRM&q=civicrm/admin/access&reset=1'); CRM_Utils_System::civiExit(); }
public function disable() { if ($this->type == 'payment' && $this->status != 'missing') { $this->_runPaymentHook('disable'); } $this->_setActiveByType(0); CRM_Core_DAO::setFieldValue('CRM_Core_DAO_Extension', $this->id, 'is_active', 0); CRM_Core_Invoke::rebuildMenuAndCaches(TRUE); }
/** * Perform the actual rebuild */ public function doCivicrmRebuild() { // dump($this, 'doCivicrmRebuild'); $this->bootstrap(); CRM_Core_Invoke::rebuildMenuAndCaches(TRUE); }