Ejemplo n.º 1
0
if (isset($_REQUEST['seedLanguage']) and isset($langs[$_REQUEST['seedLanguage']])) {
    $seedLanguage = $_REQUEST['seedLanguage'];
    $tsLocale = $_REQUEST['seedLanguage'];
}
$config = CRM_Core_Config::singleton(FALSE);
$GLOBALS['civicrm_default_error_scope'] = NULL;
// The translation files are in the parent directory (l10n)
$i18n = CRM_Core_I18n::singleton();
// Support for Arabic, Hebrew, Farsi, etc.
// Used in the template.html
$short_lang_code = CRM_Core_I18n_PseudoConstant::shortForLong($tsLocale);
$text_direction = CRM_Core_I18n::isLanguageRTL($tsLocale) ? 'rtl' : 'ltr';
global $cmsPath;
if ($installType == 'drupal') {
    //CRM-6840 -don't force to install in sites/all/modules/
    $object = new CRM_Utils_System_Drupal();
    $cmsPath = $object->cmsRootPath();
    $siteDir = getSiteDir($cmsPath, $_SERVER['SCRIPT_FILENAME']);
    $alreadyInstalled = file_exists($cmsPath . CIVICRM_DIRECTORY_SEPARATOR . 'sites' . CIVICRM_DIRECTORY_SEPARATOR . $siteDir . CIVICRM_DIRECTORY_SEPARATOR . 'civicrm.settings.php');
} elseif ($installType == 'wordpress') {
    $cmsPath = WP_PLUGIN_DIR . DIRECTORY_SEPARATOR . 'civicrm';
    $upload_dir = wp_upload_dir();
    $files_dirname = $upload_dir['basedir'] . DIRECTORY_SEPARATOR . 'civicrm';
    $wp_civi_settings = $upload_dir['basedir'] . DIRECTORY_SEPARATOR . 'civicrm' . DIRECTORY_SEPARATOR . 'civicrm.settings.php';
    $wp_civi_settings_deprectated = CIVICRM_PLUGIN_DIR . 'civicrm.settings.php';
    if (file_exists($wp_civi_settings_deprectated)) {
        $alreadyInstalled = $wp_civi_settings_deprectated;
    } elseif (file_exists($wp_civi_settings)) {
        $alreadyInstalled = $wp_civi_settings;
    }
}
Ejemplo n.º 2
0
 static function updateCategories()
 {
     $config = CRM_Core_Config::singleton();
     if ($config->userFramework == 'Drupal') {
         require_once 'CRM/Utils/System/Drupal.php';
         CRM_Utils_System_Drupal::updateCategories();
     }
 }
Ejemplo n.º 3
0
 /**
  * Function to set the default values
  *
  * @param array   $defaults  associated array of form elements
  * @param boolena $formMode  this funtion is called to set default
  *                           values in an empty db, also called when setting component using GUI
  *                           this variable is set true for GUI
  *                           mode (eg: Global setting >> Components)    
  *
  * @access public
  */
 public function setValues(&$defaults, $formMode = false)
 {
     $config = CRM_Core_Config::singleton();
     $baseURL = $config->userFrameworkBaseURL;
     // CRM-6216: Drupal’s $baseURL might have a trailing LANGUAGE_NEGOTIATION_PATH,
     // which needs to be stripped before we start basing ResourceURL on it
     if ($config->userFramework == 'Drupal') {
         global $language;
         if (isset($language->prefix) and $language->prefix) {
             if (substr($baseURL, -(strlen($language->prefix) + 1)) == $language->prefix . '/') {
                 $baseURL = substr($baseURL, 0, -(strlen($language->prefix) + 1));
             }
         }
     }
     $baseCMSURL = CRM_Utils_System::baseCMSURL();
     if ($config->templateCompileDir) {
         $path = CRM_Utils_File::baseFilePath($config->templateCompileDir);
     }
     //set defaults if not set in db
     if (!isset($defaults['userFrameworkResourceURL'])) {
         $testIMG = "i/tracker.gif";
         if ($config->userFramework == 'Joomla') {
             if (CRM_Utils_System::checkURL("{$baseURL}components/com_civicrm/civicrm/{$testIMG}")) {
                 $defaults['userFrameworkResourceURL'] = $baseURL . "components/com_civicrm/civicrm/";
             }
         } else {
             if ($config->userFramework == 'Standalone') {
                 // potentially sane default for standalone;
                 // could probably be smarter about this, but this
                 // should work in many cases
                 $defaults['userFrameworkResourceURL'] = str_replace('standalone/', '', $baseURL);
             } else {
                 // Drupal setting
                 // check and see if we are installed in sites/all (for D5 and above)
                 // we dont use checkURL since drupal generates an error page and throws
                 // the system for a loop on lobo's macosx box
                 // or in modules
                 global $civicrm_root;
                 require_once "CRM/Utils/System/Drupal.php";
                 $cmsPath = CRM_Utils_System_Drupal::cmsRootPath();
                 $defaults['userFrameworkResourceURL'] = $baseURL . str_replace("{$cmsPath}/", '', str_replace('\\', '/', $civicrm_root));
                 if (strpos($civicrm_root, DIRECTORY_SEPARATOR . 'sites' . DIRECTORY_SEPARATOR . 'all' . DIRECTORY_SEPARATOR . 'modules') === false) {
                     $startPos = strpos($civicrm_root, DIRECTORY_SEPARATOR . 'sites' . DIRECTORY_SEPARATOR);
                     $endPos = strpos($civicrm_root, DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR);
                     if ($startPos && $endPos) {
                         // if component is in sites/SITENAME/modules
                         $siteName = substr($civicrm_root, $startPos + 7, $endPos - $startPos - 7);
                         $civicrmDirName = trim(basename($civicrm_root));
                         $defaults['userFrameworkResourceURL'] = $baseURL . "sites/{$siteName}/modules/{$civicrmDirName}/";
                         if (!isset($defaults['imageUploadURL'])) {
                             $defaults['imageUploadURL'] = $baseURL . "sites/{$siteName}/files/civicrm/persist/contribute/";
                         }
                     }
                 }
             }
         }
     }
     if (!isset($defaults['imageUploadURL'])) {
         if ($config->userFramework == 'Joomla') {
             // gross hack
             // we need to remove the administrator/ from the end
             $tempURL = str_replace("/administrator/", "/", $baseURL);
             $defaults['imageUploadURL'] = $tempURL . "media/civicrm/persist/contribute/";
         } else {
             if ($config->userFramework == 'Standalone') {
                 //for standalone no need of sites/defaults directory
                 $defaults['imageUploadURL'] = $baseURL . "files/civicrm/persist/contribute/";
             } else {
                 $defaults['imageUploadURL'] = $baseURL . "sites/default/files/civicrm/persist/contribute/";
             }
         }
     }
     if (!isset($defaults['imageUploadDir']) && is_dir($config->templateCompileDir)) {
         $imgDir = $path . "persist/contribute/";
         CRM_Utils_File::createDir($imgDir);
         $defaults['imageUploadDir'] = $imgDir;
     }
     if (!isset($defaults['uploadDir']) && is_dir($config->templateCompileDir)) {
         $uploadDir = $path . "upload/";
         CRM_Utils_File::createDir($uploadDir);
         CRM_Utils_File::restrictAccess($uploadDir);
         $defaults['uploadDir'] = $uploadDir;
     }
     if (!isset($defaults['customFileUploadDir']) && is_dir($config->templateCompileDir)) {
         $customDir = $path . "custom/";
         CRM_Utils_File::createDir($customDir);
         $defaults['customFileUploadDir'] = $customDir;
     }
     /* FIXME: hack to bypass the step for generating defaults for components, 
        while running upgrade, to avoid any serious non-recoverable error 
        which might hinder the upgrade process. */
     $args = array();
     if (isset($_GET[$config->userFrameworkURLVar])) {
         $args = explode('/', $_GET[$config->userFrameworkURLVar]);
     }
     if (isset($defaults['enableComponents'])) {
         foreach ($defaults['enableComponents'] as $key => $name) {
             $comp = $config->componentRegistry->get($name);
             if ($comp) {
                 $co = $comp->getConfigObject();
                 $co->setDefaults($defaults);
             }
         }
     }
 }
Ejemplo n.º 4
0
 /**
  * function to return relative path
  *
  * @param String $absPath absolute path
  * @return String $relativePath Relative url of uploaded image
  */
 public static function getRelativePath($absolutePath)
 {
     $relativePath = null;
     $config = CRM_Core_Config::singleton();
     if ($config->userFramework == 'Joomla') {
         $userFrameworkBaseURL = trim(str_replace('/administrator/', '', $config->userFrameworkBaseURL));
         $customFileUploadDirectory = strstr(str_replace('\\', '/', $absolutePath), '/media');
         $relativePath = $userFrameworkBaseURL . $customFileUploadDirectory;
     } else {
         if ($config->userFramework == 'Drupal') {
             require_once 'CRM/Utils/System/Drupal.php';
             $rootPath = CRM_Utils_System_Drupal::cmsRootPath();
             $baseUrl = $config->userFrameworkBaseURL;
             if (module_exists('locale') && ($mode = variable_get('language_negotiation', LANGUAGE_NEGOTIATION_NONE))) {
                 global $language;
                 if (isset($language->prefix)) {
                     $baseUrl = str_replace($language->prefix . '/', '', $config->userFrameworkBaseURL);
                 }
             }
             $relativePath = str_replace("{$rootPath}/", $baseUrl, str_replace('\\', '/', $absolutePath));
         } else {
             if ($config->userFramework == 'Standalone') {
                 $absolutePathStr = strstr($absolutePath, 'files');
                 $relativePath = $config->userFrameworkBaseURL . str_replace('\\', '/', $absolutePathStr);
             }
         }
     }
     return $relativePath;
 }
Ejemplo n.º 5
0
    if ($locale == 'en_US') {
        continue;
    }
    if (!file_exists(implode(CIVICRM_DIRECTORY_SEPARATOR, array($crmPath, 'sql', "civicrm_data.{$locale}.mysql")))) {
        unset($langs[$locale]);
    }
}
$seedLanguage = 'en_US';
if (isset($_REQUEST['seedLanguage']) and isset($langs[$_REQUEST['seedLanguage']])) {
    $seedLanguage = $_REQUEST['seedLanguage'];
}
if ($installType == 'drupal') {
    global $cmsPath;
    //CRM-6840 -don't force to install in sites/all/modules/
    require_once "{$crmPath}/CRM/Utils/System/Drupal.php";
    $cmsPath = CRM_Utils_System_Drupal::cmsRootPath();
    $siteDir = getSiteDir($cmsPath, $_SERVER['SCRIPT_FILENAME']);
    $alreadyInstalled = file_exists($cmsPath . CIVICRM_DIRECTORY_SEPARATOR . 'sites' . CIVICRM_DIRECTORY_SEPARATOR . $siteDir . CIVICRM_DIRECTORY_SEPARATOR . 'civicrm.settings.php');
} elseif ($installType == 'standalone') {
    $alreadyInstalled = file_exists($crmPath . CIVICRM_DIRECTORY_SEPARATOR . 'standalone' . CIVICRM_DIRECTORY_SEPARATOR . 'civicrm.settings.php');
}
// Exit with error if CiviCRM has already been installed.
if ($alreadyInstalled) {
    $errorTitle = "Oops! CiviCRM is Already Installed";
    if ($installType == 'drupal') {
        $errorMsg = "CiviCRM has already been installed in this Drupal site. <ul><li>To <strong>start over</strong>, you must delete or rename the existing CiviCRM settings file - <strong>civicrm.settings.php</strong> - from <strong>" . implode(CIVICRM_DIRECTORY_SEPARATOR, array('[your Drupal root directory]', 'sites', $siteDir)) . "</strong>.</li><li>To <strong>upgrade an existing installation</strong>, refer to the online " . $docLink . ".</li></ul>";
    } elseif ($installType == 'standalone') {
        $errorMsg = "Standalone CiviCRM has already been installed. <ul><li>To <strong>start over</strong>, you must delete or rename the existing CiviCRM settings file - <strong>civicrm.settings.php</strong> - from <strong>[your CiviCRM root directory]" . CIVICRM_DIRECTORY_SEPARATOR . "standalone</strong>.</li><li>To <strong>upgrade an existing installation</strong>, refer to the online " . $docLink . ".</li></ul>";
    }
    errorDisplayPage($errorTitle, $errorMsg);
}