Example #1
0
/**
 * Implementation of hook_civicrm_install
 */
function hrprofile_civicrm_install()
{
    $groups = CRM_Core_PseudoConstant::get('CRM_Core_BAO_UFField', 'uf_group_id', array('labelColumn' => 'name'));
    $profileId = array_search('hrstaffdir_listing', $groups);
    $path = array('url' => "civicrm/profile?reset=1&gid={$profileId}&force=1");
    $navigationPath = CRM_Core_BAO_Navigation::retrieve($path, $defaultpath);
    if ($profileId && $navigationPath) {
        $originalUrl = "civicrm/profile?reset=1&gid={$profileId}&force=1";
        $updatedUrl = "civicrm/profile/table?reset=1&gid={$profileId}&force=1";
        hrprofile_updateNavigation($originalUrl, $updatedUrl);
    } elseif ($profileId && !$navigationPath) {
        // add to navigation
        $navigationParams = array('label' => 'Directory', 'url' => "civicrm/profile/table?reset=1&gid={$profileId}&force=1", 'is_active' => 1);
        $navigation = CRM_Core_BAO_Navigation::add($navigationParams);
        CRM_Core_BAO_Navigation::resetNavigation();
        // set the profile as search view
        $params = array();
        CRM_Core_BAO_ConfigSetting::retrieve($params);
        if (!empty($params)) {
            $params['defaultSearchProfileID'] = $profileId;
            CRM_Core_BAO_ConfigSetting::create($params);
        }
    }
    return _hrprofile_civix_civicrm_install();
}
Example #2
0
 /**
  * Store multiple items in the setting table. Note that this will also store config keys
  * the storage is determined by the metdata and is affected by
  *  'name' setting's name
  *  'prefetch' = store in config
  *  'config_only' = don't store in settings
  *  'config_key' = the config key is different to the settings key - e.g. debug where there was a conflict
  *  'legacy_key' = rename from config or setting with this name
  *
  * _setItem() is the common logic shared by setItem() and setItems().
  *
  * @param array $params
  *   (required) An api formatted array of keys and values.
  * @param null $domains
  *
  * @throws api_Exception
  * @domains array an array of domains to get settings for. Default is the current domain
  * @return array
  */
 public static function setItems(&$params, $domains = NULL)
 {
     $originalDomain = CRM_Core_Config::domainID();
     if (empty($domains)) {
         $domains[] = $originalDomain;
     }
     $reloadConfig = FALSE;
     $fields = $config_keys = array();
     $fieldsToSet = self::validateSettingsInput($params, $fields);
     foreach ($fieldsToSet as $settingField => &$settingValue) {
         self::validateSetting($settingValue, $fields['values'][$settingField]);
     }
     foreach ($domains as $domainID) {
         if ($domainID != CRM_Core_Config::domainID()) {
             $reloadConfig = TRUE;
             CRM_Core_BAO_Domain::setDomain($domainID);
         }
         $result[$domainID] = array();
         foreach ($fieldsToSet as $name => $value) {
             if (empty($fields['values'][$name]['config_only'])) {
                 CRM_Core_BAO_Setting::_setItem($fields['values'][$name], $value, $fields['values'][$name]['group_name'], $name, CRM_Utils_Array::value('component_id', $params), CRM_Utils_Array::value('contact_id', $params), CRM_Utils_Array::value('created_id', $params), $domainID);
             }
             if (!empty($fields['values'][$name]['prefetch'])) {
                 if (!empty($fields['values'][$name]['config_key'])) {
                     $name = $fields['values'][$name]['config_key'];
                 }
                 $config_keys[$name] = $value;
             }
             $result[$domainID][$name] = $value;
         }
         if ($reloadConfig) {
             CRM_Core_Config::singleton($reloadConfig, $reloadConfig);
         }
         if (!empty($config_keys)) {
             CRM_Core_BAO_ConfigSetting::create($config_keys);
         }
         if ($reloadConfig) {
             CRM_Core_BAO_Domain::resetDomain();
         }
     }
     return $result;
 }
Example #3
0
 /**
  * Common Process.
  *
  * @todo Document what I do.
  *
  * @param array $params
  */
 public function commonProcess(&$params)
 {
     // save autocomplete search options
     if (!empty($params['autocompleteContactSearch'])) {
         $value = CRM_Core_DAO::VALUE_SEPARATOR . implode(CRM_Core_DAO::VALUE_SEPARATOR, array_keys($params['autocompleteContactSearch'])) . CRM_Core_DAO::VALUE_SEPARATOR;
         CRM_Core_BAO_Setting::setItem($value, CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'contact_autocomplete_options');
         unset($params['autocompleteContactSearch']);
     }
     // save autocomplete contact reference options
     if (!empty($params['autocompleteContactReference'])) {
         $value = CRM_Core_DAO::VALUE_SEPARATOR . implode(CRM_Core_DAO::VALUE_SEPARATOR, array_keys($params['autocompleteContactReference'])) . CRM_Core_DAO::VALUE_SEPARATOR;
         CRM_Core_BAO_Setting::setItem($value, CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'contact_reference_options');
         unset($params['autocompleteContactReference']);
     }
     // save components to be enabled
     if (array_key_exists('enableComponents', $params)) {
         civicrm_api3('setting', 'create', array('enable_components' => $params['enableComponents']));
         unset($params['enableComponents']);
     }
     // save checksum timeout
     if (!empty($params['checksumTimeout'])) {
         CRM_Core_BAO_Setting::setItem($params['checksumTimeout'], CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'checksum_timeout');
     }
     // update time for date formats when global time is changed
     if (!empty($params['timeInputFormat'])) {
         $query = "\nUPDATE civicrm_preferences_date\nSET    time_format = %1\nWHERE  time_format IS NOT NULL\nAND    time_format <> ''\n";
         $sqlParams = array(1 => array($params['timeInputFormat'], 'String'));
         CRM_Core_DAO::executeQuery($query, $sqlParams);
     }
     // verify ssl peer option
     if (isset($params['verifySSL'])) {
         CRM_Core_BAO_Setting::setItem($params['verifySSL'], CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'verifySSL');
         unset($params['verifySSL']);
     }
     // force secure URLs
     if (isset($params['enableSSL'])) {
         CRM_Core_BAO_Setting::setItem($params['enableSSL'], CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'enableSSL');
         unset($params['enableSSL']);
     }
     $settings = array_intersect_key($params, $this->_settings);
     $result = civicrm_api('setting', 'create', $settings + array('version' => 3));
     foreach ($settings as $setting => $settingGroup) {
         //@todo array_diff this
         unset($params[$setting]);
     }
     CRM_Core_BAO_ConfigSetting::create($params);
     CRM_Core_Config::clearDBCache();
     CRM_Utils_System::flushCache();
     CRM_Core_Resources::singleton()->resetCacheCode();
     CRM_Core_Session::setStatus(" ", ts('Changes Saved'), "success");
 }
Example #4
0
 /**
  * Common Process.
  *
  * @todo Document what I do.
  *
  * @param array $params
  */
 public function commonProcess(&$params)
 {
     // save autocomplete search options
     if (!empty($params['autocompleteContactSearch'])) {
         $value = CRM_Core_DAO::VALUE_SEPARATOR . implode(CRM_Core_DAO::VALUE_SEPARATOR, array_keys($params['autocompleteContactSearch'])) . CRM_Core_DAO::VALUE_SEPARATOR;
         CRM_Core_BAO_Setting::setItem($value, CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'contact_autocomplete_options');
         unset($params['autocompleteContactSearch']);
     }
     // save autocomplete contact reference options
     if (!empty($params['autocompleteContactReference'])) {
         $value = CRM_Core_DAO::VALUE_SEPARATOR . implode(CRM_Core_DAO::VALUE_SEPARATOR, array_keys($params['autocompleteContactReference'])) . CRM_Core_DAO::VALUE_SEPARATOR;
         CRM_Core_BAO_Setting::setItem($value, CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'contact_reference_options');
         unset($params['autocompleteContactReference']);
     }
     // save components to be enabled
     if (array_key_exists('enableComponents', $params)) {
         civicrm_api3('setting', 'create', array('enable_components' => $params['enableComponents']));
         unset($params['enableComponents']);
     }
     // save checksum timeout
     if (!empty($params['checksumTimeout'])) {
         CRM_Core_BAO_Setting::setItem($params['checksumTimeout'], CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'checksum_timeout');
     }
     // verify ssl peer option
     if (isset($params['verifySSL'])) {
         CRM_Core_BAO_Setting::setItem($params['verifySSL'], CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'verifySSL');
         unset($params['verifySSL']);
     }
     // force secure URLs
     if (isset($params['enableSSL'])) {
         CRM_Core_BAO_Setting::setItem($params['enableSSL'], CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'enableSSL');
         unset($params['enableSSL']);
     }
     $settings = array_intersect_key($params, $this->_settings);
     $result = civicrm_api('setting', 'create', $settings + array('version' => 3));
     foreach ($settings as $setting => $settingGroup) {
         //@todo array_diff this
         unset($params[$setting]);
     }
     if (!empty($result['error_message'])) {
         CRM_Core_Session::setStatus($result['error_message'], ts('Save Failed'), 'error');
     }
     CRM_Core_BAO_ConfigSetting::create($params);
     CRM_Core_Config::clearDBCache();
     CRM_Utils_System::flushCache();
     CRM_Core_Resources::singleton()->resetCacheCode();
     CRM_Core_Session::setStatus(" ", ts('Changes Saved'), "success");
 }
 /**
  * @param array $params
  *   - mailerBatchLimit
  *   - mailerJobSize
  *   - mailerJobsMax
  *   - mailThrottleTime
  */
 protected function setSettings($params)
 {
     // FIXME: These settings are not available via Setting API.
     // When they become available, use that instead.
     CRM_Core_BAO_ConfigSetting::create($params);
 }
 /**
 * Function to process the form
 *
 * @access public
 * @return None
 */
 public function postProcess()
 {
     $params = $this->controller->exportValues($this->_name);
     $config = CRM_Core_Config::singleton();
     $configParams = array();
     require_once 'CRM/Event/PseudoConstant.php';
     $event_type = CRM_Event_PseudoConstant::eventType();
     $colorevents = $event_type;
     foreach ($event_type as $k => $v) {
         $v = str_replace(" ", "_", $v);
         $evnt_color = 'eventcolor_' . $k;
         $eventname = 'eventtype_' . $k;
         if (!empty($params[$evnt_color]) && !empty($params[$eventname])) {
             $configParams[$v] = $params[$evnt_color];
             $configParams[$eventname] = $params[$eventname];
         } else {
             $configParams[$v] = '3366CC';
             $configParams[$eventname] = 0;
         }
         $event_type[$k] = $v;
     }
     foreach ($event_type as $k => $v) {
         $evnt_key = 'eventtype_' . $k;
         if (!array_key_exists($evnt_key, $params)) {
             unset($event_type[$k]);
         }
     }
     $configParams['civicrm_events_event_types'] = $event_type;
     if (isset($params['event_calendar_title'])) {
         $configParams['civicrm_event_calendar_title'] = $params['event_calendar_title'];
     } else {
         $configParams['civicrm_event_calendar_title'] = 'Event Calendar';
     }
     if (isset($params['show_past_event']) && $params['show_past_event'] == 1) {
         $configParams['civicrm_events_event_past'] = $params['show_past_event'];
     } else {
         $configParams['civicrm_events_event_past'] = 0;
     }
     if (isset($params['show_end_date']) && $params['show_end_date'] == 1) {
         $configParams['civicrm_events_event_end_date'] = $params['show_end_date'];
     } else {
         $configParams['civicrm_events_event_end_date'] = 0;
     }
     if (isset($params['event_is_public']) && $params['event_is_public'] == 1) {
         $configParams['civicrm_events_event_is_public'] = $params['event_is_public'];
     } else {
         $configParams['civicrm_events_event_is_public'] = 0;
     }
     if (isset($params['events_event_month']) && $params['events_event_month'] == 1) {
         $configParams['civicrm_events_event_months'] = $params['show_event_from_month'];
     } else {
         $configParams['civicrm_events_event_months'] = 0;
     }
     if (isset($params['show_event_from_month'])) {
         $configParams['show_event_from_month'] = $params['show_event_from_month'];
     } else {
         $configParams['show_event_from_month'] = '';
     }
     CRM_Core_BAO_ConfigSetting::create($configParams);
     CRM_Core_Session::setStatus(" ", ts('The value has been saved.'), "success");
 }
 public function postProcess()
 {
     // store the submitted values in an array
     $config = CRM_Core_Config::singleton();
     $params = $this->controller->exportValues($this->_name);
     // update upload max size in DB
     $params['maxImportFileSize'] = CRM_Core_Config_Defaults::formatUnitSize(ini_get('upload_max_filesize'));
     CRM_Core_BAO_ConfigSetting::create($params);
     // get current logging status
     $values = $this->exportValues();
     parent::postProcess();
     if ($config->logging != $values['logging']) {
         $logging = new CRM_Logging_Schema();
         if ($values['logging']) {
             $logging->enableLogging();
         } else {
             $logging->disableLogging();
         }
     }
 }
Example #8
0
 /**
  * @param $params
  */
 public function commonProcess(&$params)
 {
     // save autocomplete search options
     if (!empty($params['autocompleteContactSearch'])) {
         $value = CRM_Core_DAO::VALUE_SEPARATOR . implode(CRM_Core_DAO::VALUE_SEPARATOR, array_keys($params['autocompleteContactSearch'])) . CRM_Core_DAO::VALUE_SEPARATOR;
         CRM_Core_BAO_Setting::setItem($value, CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'contact_autocomplete_options');
         unset($params['autocompleteContactSearch']);
     }
     // save autocomplete contact reference options
     if (!empty($params['autocompleteContactReference'])) {
         $value = CRM_Core_DAO::VALUE_SEPARATOR . implode(CRM_Core_DAO::VALUE_SEPARATOR, array_keys($params['autocompleteContactReference'])) . CRM_Core_DAO::VALUE_SEPARATOR;
         CRM_Core_BAO_Setting::setItem($value, CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'contact_reference_options');
         unset($params['autocompleteContactReference']);
     }
     // save components to be enabled
     if (array_key_exists('enableComponents', $params)) {
         CRM_Core_BAO_Setting::setItem($params['enableComponents'], CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'enable_components');
         // unset params by emptying the values, so while retrieving we can detect and load from settings table
         // instead of config-backend for backward compatibility. We could use unset() in later releases.
         $params['enableComponents'] = $params['enableComponentIDs'] = array();
     }
     // save checksum timeout
     if (!empty($params['checksumTimeout'])) {
         CRM_Core_BAO_Setting::setItem($params['checksumTimeout'], CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'checksum_timeout');
     }
     // update time for date formats when global time is changed
     if (!empty($params['timeInputFormat'])) {
         $query = "\nUPDATE civicrm_preferences_date\nSET    time_format = %1\nWHERE  time_format IS NOT NULL\nAND    time_format <> ''\n";
         $sqlParams = array(1 => array($params['timeInputFormat'], 'String'));
         CRM_Core_DAO::executeQuery($query, $sqlParams);
     }
     // verify ssl peer option
     if (isset($params['verifySSL'])) {
         CRM_Core_BAO_Setting::setItem($params['verifySSL'], CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'verifySSL');
         unset($params['verifySSL']);
     }
     // force secure URLs
     if (isset($params['enableSSL'])) {
         CRM_Core_BAO_Setting::setItem($params['enableSSL'], CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'enableSSL');
         unset($params['enableSSL']);
     }
     $settings = array_intersect_key($params, $this->_settings);
     $result = civicrm_api('setting', 'create', $settings + array('version' => 3));
     foreach ($settings as $setting => $settingGroup) {
         //@todo array_diff this
         unset($params[$setting]);
     }
     CRM_Core_BAO_ConfigSetting::create($params);
     CRM_Core_Session::setStatus(" ", ts('Changes Saved.'), "success");
 }
Example #9
0
/**
 * Implementation of hook_civicrm_install
 */
function hrstaffdir_civicrm_install()
{
    _hrstaffdir_civix_civicrm_install();
    $profileId = hrstaffdir_getUFGroupID();
    $path = array('url' => "civicrm/profile/table?reset=1?gid={$profileId}&force=1");
    $navigationPath = CRM_Core_BAO_Navigation::retrieve($path, $defaultpath);
    if ($profileId && !$navigationPath) {
        // add to navigation
        $navigationParams = array('label' => 'Directory', 'url' => "civicrm/profile?reset=1&gid={$profileId}&force=1", 'is_active' => 1);
        $navigation = CRM_Core_BAO_Navigation::add($navigationParams);
        CRM_Core_BAO_Navigation::resetNavigation();
        // set the profile as search view
        $params = array();
        CRM_Core_BAO_ConfigSetting::retrieve($params);
        if (!empty($params)) {
            $params['defaultSearchProfileID'] = $profileId;
            CRM_Core_BAO_ConfigSetting::create($params);
        }
    }
}