<?php
/*
+--------------------------------------------------------------------+
- | CiviCRM version 4.7 |
+ | CiviCRM version 5 |
+--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2017 |
+ | Copyright CiviCRM LLC (c) 2004-2018 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
/**
*
* @package CRM
- * @copyright CiviCRM LLC (c) 2004-2017
+ * @copyright CiviCRM LLC (c) 2004-2018
* $Id$
*
*/
$this->supports_form_extensions = TRUE;
}
- /**
- * @inheritDoc
- */
- public function getCiviSourceStorage() {
- global $civicrm_root;
-
- // Don't use $config->userFrameworkBaseURL; it has garbage on it.
- // More generally, we shouldn't be using $config here.
- if (!defined('CIVICRM_UF_BASEURL')) {
- throw new RuntimeException('Undefined constant: CIVICRM_UF_BASEURL');
- }
-
- $cmsUrl = CIVICRM_UF_BASEURL;
- if (CRM_Utils_System::isSSL()) {
- $cmsUrl = str_replace('http://', 'https://', $cmsUrl);
- }
- $civiRelPath = CRM_Utils_File::relativize(realpath($civicrm_root), realpath($this->cmsRootPath()));
- $civiUrl = rtrim($cmsUrl, '/') . '/' . ltrim($civiRelPath, ' /');
- return array(
- 'url' => CRM_Utils_File::addTrailingSlash($civiUrl, '/'),
- 'path' => CRM_Utils_File::addTrailingSlash($civicrm_root),
- );
- }
-
/**
* @inheritdoc
*/
$config = CRM_Core_Config::singleton();
$baseURL = CRM_Utils_System::languageNegotiationURL($config->userFrameworkBaseURL, FALSE, TRUE);
- $siteName = $this->parseDrupalSiteName('/files/civicrm');
+ $siteName = $this->parseDrupalSiteNameFromRequest('/files/civicrm');
if ($siteName) {
$filesURL = $baseURL . "sites/$siteName/files/civicrm/";
}
return defined('VERSION') ? VERSION : 'Unknown';
}
+ /**
+ * @inheritDoc
+ */
+ public function isUserRegistrationPermitted() {
+ if (!variable_get('user_register', TRUE)) {
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function isPasswordUserGenerated() {
+ if (variable_get('user_email_verification', TRUE)) {
+ return FALSE;
+ }
+ return TRUE;
+ }
+
/**
* @inheritDoc
*/
// return CiviCRM’s xx_YY locale that either matches Drupal’s Chinese locale
// (for CRM-6281), Drupal’s xx_YY or is retrieved based on Drupal’s xx
// sometimes for CLI based on order called, this might not be set and/or empty
- global $language;
+ $language = $this->getCurrentLanguage();
if (empty($language)) {
return NULL;
}
- if ($language->language == 'zh-hans') {
+ if ($language == 'zh-hans') {
return 'zh_CN';
}
- if ($language->language == 'zh-hant') {
+ if ($language == 'zh-hant') {
return 'zh_TW';
}
- if (preg_match('/^.._..$/', $language->language)) {
- return $language->language;
+ if (preg_match('/^.._..$/', $language)) {
+ return $language;
}
- return CRM_Core_I18n_PseudoConstant::longForShort(substr($language->language, 0, 2));
+ return CRM_Core_I18n_PseudoConstant::longForShort(substr($language, 0, 2));
}
/**
return user_load($userID);
}
+ /**
+ * Parse the name of the drupal site.
+ *
+ * @param string $civicrm_root
+ *
+ * @return null|string
+ * @deprecated
+ */
+ public function parseDrupalSiteNameFromRoot($civicrm_root) {
+ $siteName = NULL;
+ 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
+ );
+ }
+ }
+ return $siteName;
+ }
+
/**
* Determine if Drupal multi-site applies to the current request -- and,
* specifically, determine the name of the multisite folder.
* string, e.g. `bar.example.com` if using multisite.
* NULL if using the default site.
*/
- private function parseDrupalSiteName($flagFile = '') {
+ private function parseDrupalSiteNameFromRequest($flagFile = '') {
$phpSelf = array_key_exists('PHP_SELF', $_SERVER) ? $_SERVER['PHP_SELF'] : '';
$httpHost = array_key_exists('HTTP_HOST', $_SERVER) ? $_SERVER['HTTP_HOST'] : '';
if (empty($httpHost)) {
}
}
+ /**
+ * Function to return current language of Drupal
+ *
+ * @return string
+ */
+ public function getCurrentLanguage() {
+ global $language;
+ return (!empty($language->language)) ? $language->language : $language;
+ }
+
}