Example #1
0
 /**
  * @param array $params
  * @param bool $setInConfig
  */
 public static function retrieveDirectoryAndURLPreferences(&$params, $setInConfig = FALSE)
 {
     if (CRM_Core_Config::isUpgradeMode()) {
         $isJoomla = defined('CIVICRM_UF') && CIVICRM_UF == 'Joomla' ? TRUE : FALSE;
         // hack to set the resource base url so that js/ css etc is loaded correctly
         if ($isJoomla) {
             $params['userFrameworkResourceURL'] = CRM_Utils_File::addTrailingSlash(CIVICRM_UF_BASEURL, '/') . str_replace('administrator', '', CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionValue', 'userFrameworkResourceURL', 'value', 'name'));
         }
         if (self::isUpgradeFromPreFourOneAlpha1()) {
             return;
         }
     }
     if ($setInConfig) {
         $config = CRM_Core_Config::singleton();
     }
     $sql = "\nSELECT name, group_name, value\nFROM   civicrm_setting\nWHERE  ( group_name = %1\nOR       group_name = %2 )\nAND domain_id = %3\n";
     $sqlParams = array(1 => array(self::DIRECTORY_PREFERENCES_NAME, 'String'), 2 => array(self::URL_PREFERENCES_NAME, 'String'), 3 => array(CRM_Core_Config::domainID(), 'Integer'));
     $dao = CRM_Core_DAO::executeQuery($sql, $sqlParams, TRUE, NULL, FALSE, TRUE, TRUE);
     if (is_a($dao, 'DB_Error')) {
         echo "Fatal DB error, exiting, seems like your schema does not have civicrm_setting table\n";
         exit;
     }
     while ($dao->fetch()) {
         $value = self::getOverride($dao->group_name, $dao->name, NULL);
         if ($value === NULL && $dao->value) {
             $value = unserialize($dao->value);
             if ($dao->group_name == self::DIRECTORY_PREFERENCES_NAME) {
                 $value = CRM_Utils_File::absoluteDirectory($value);
             } else {
                 // CRM-7622: we need to remove the language part
                 $value = CRM_Utils_System::absoluteURL($value, TRUE);
             }
         }
         // CRM-10931, If DB doesn't have any value, carry on with any default value thats already available
         if (!isset($value) && !empty($params[$dao->name])) {
             $value = $params[$dao->name];
         }
         $params[$dao->name] = $value;
         if ($setInConfig) {
             $config->{$dao->name} = $value;
         }
     }
 }
 static function retrieveDirectoryAndURLPreferences(&$params, $setInConfig = false)
 {
     if ($setInConfig) {
         $config =& CRM_Core_Config::singleton();
     }
     $sql = "\nSELECT v.name as valueName, v.value, g.name as optionName\nFROM   civicrm_option_value v,\n       civicrm_option_group g\nWHERE  ( g.name = 'directory_preferences'\nOR       g.name = 'url_preferences' )\nAND    v.option_group_id = g.id\nAND    v.is_active = 1\n";
     require_once 'CRM/Utils/File.php';
     $dao = CRM_Core_DAO::executeQuery($sql);
     while ($dao->fetch()) {
         if (!$dao->value) {
             continue;
         }
         if ($dao->optionName == 'directory_preferences') {
             $value = CRM_Utils_File::absoluteDirectory($dao->value);
         } else {
             $value = CRM_Utils_System::absoluteURL($dao->value);
         }
         $params[$dao->valueName] = $value;
         if ($setInConfig) {
             $config->{$dao->valueName} = $value;
         }
     }
 }