3 +--------------------------------------------------------------------+
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2020 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
31 * @copyright CiviCRM LLC (c) 2004-2020
35 * Backdrop-specific logic that differs from Drupal.
37 class CRM_Utils_System_Backdrop
extends CRM_Utils_System_DrupalBase
{
42 public function createUser(&$params, $mail) {
43 $form_state = form_state_defaults();
45 $form_state['input'] = [
46 'name' => $params['cms_name'],
47 'mail' => $params[$mail],
48 'op' => 'Create new account',
51 $admin = user_access('administer users');
52 if (!config_get('system.core', 'user_email_verification') ||
$admin) {
53 $form_state['input']['pass'] = ['pass1' => $params['cms_pass'], 'pass2' => $params['cms_pass']];
56 if (!empty($params['notify'])) {
57 $form_state['input']['notify'] = $params['notify'];
60 $form_state['rebuild'] = FALSE;
61 $form_state['programmed'] = TRUE;
62 $form_state['complete form'] = FALSE;
63 $form_state['method'] = 'post';
64 $form_state['build_info']['args'] = [];
66 * if we want to submit this form more than once in a process (e.g. create more than one user)
67 * we must force it to validate each time for this form. Otherwise it will not validate
68 * subsequent submissions and the manner in which the password is passed in will be invalid
70 $form_state['must_validate'] = TRUE;
71 $config = CRM_Core_Config
::singleton();
73 // we also need to redirect b
74 $config->inCiviCRM
= TRUE;
76 $form = backdrop_retrieve_form('user_register_form', $form_state);
77 $form_state['process_input'] = 1;
78 $form_state['submitted'] = 1;
79 $form['#array_parents'] = [];
80 $form['#tree'] = FALSE;
81 backdrop_process_form('user_register_form', $form, $form_state);
83 $config->inCiviCRM
= FALSE;
85 if (form_get_errors()) {
88 return $form_state['user']->uid
;
94 public function updateCMSName($ufID, $email) {
96 if (function_exists('user_load')) {
97 $user = user_load($ufID);
98 if ($user->mail
!= $email) {
106 * Check if username and email exists in the Backdrop db.
108 * @param array $params
109 * Array of name and mail values.
110 * @param array $errors
112 * @param string $emailName
113 * Field label for the 'email'.
115 public static function checkUserNameEmailExists(&$params, &$errors, $emailName = 'email') {
116 $errors = form_get_errors();
118 // unset Backdrop messages to avoid twice display of errors
119 unset($_SESSION['messages']);
122 if (!empty($params['name'])) {
123 if ($nameError = user_validate_name($params['name'])) {
124 $errors['cms_name'] = $nameError;
127 $uid = db_query("SELECT uid FROM {users} WHERE name = :name", [':name' => $params['name']])->fetchField();
129 $errors['cms_name'] = ts('The username %1 is already taken. Please select another username.', [1 => $params['name']]);
134 if (!empty($params['mail'])) {
135 if (!valid_email_address($params['mail'])) {
136 $errors[$emailName] = ts('The e-mail address %1 is not valid.', [1 => $params['mail']]);
139 $uid = db_query("SELECT uid FROM {users} WHERE mail = :mail", [':mail' => $params['mail']])->fetchField();
141 $resetUrl = url('user/password');
142 $errors[$emailName] = ts('The email address %1 already has an account associated with it. <a href="%2">Have you forgotten your password?</a>',
143 [1 => $params['mail'], 2 => $resetUrl]
153 public function getLoginURL($destination = '') {
154 $query = $destination ?
['destination' => $destination] : [];
155 return url('user/login', ['query' => $query, 'absolute' => TRUE]);
161 public function setTitle($title, $pageTitle = NULL) {
162 if (arg(0) == 'civicrm') {
167 backdrop_set_title($pageTitle, PASS_THROUGH
);
174 public function appendBreadCrumb($breadCrumbs) {
175 $breadCrumb = backdrop_get_breadcrumb();
177 if (is_array($breadCrumbs)) {
178 foreach ($breadCrumbs as $crumbs) {
179 if (stripos($crumbs['url'], 'id%%')) {
180 $args = ['cid', 'mid'];
181 foreach ($args as $a) {
182 $val = CRM_Utils_Request
::retrieve($a, 'Positive', CRM_Core_DAO
::$_nullObject,
186 $crumbs['url'] = str_ireplace("%%{$a}%%", $val, $crumbs['url']);
190 $breadCrumb[] = "<a href=\"{$crumbs['url']}\">{$crumbs['title']}</a>";
193 backdrop_set_breadcrumb($breadCrumb);
199 public function resetBreadCrumb() {
201 backdrop_set_breadcrumb($bc);
207 public function addHTMLHead($header) {
209 if (!empty($header)) {
210 $key = 'civi_' . ++
$count;
213 '#markup' => $header,
215 backdrop_add_html_head($data, $key);
222 public function addScriptUrl($url, $region) {
223 $params = ['group' => JS_LIBRARY
, 'weight' => 10];
227 $params['scope'] = substr($region, 5);
233 // If the path is within the Backdrop directory we can use the more efficient 'file' setting
234 $params['type'] = $this->formatResourceUrl($url) ?
'file' : 'external';
235 backdrop_add_js($url, $params);
242 public function addScript($code, $region) {
243 $params = ['type' => 'inline', 'group' => JS_LIBRARY
, 'weight' => 10];
247 $params['scope'] = substr($region, 5);
253 backdrop_add_js($code, $params);
260 public function addStyleUrl($url, $region) {
261 if ($region != 'html-header') {
265 // If the path is within the Backdrop directory we can use the more efficient 'file' setting
266 $params['type'] = $this->formatResourceUrl($url) ?
'file' : 'external';
267 backdrop_add_css($url, $params);
274 public function addStyle($code, $region) {
275 if ($region != 'html-header') {
278 $params = ['type' => 'inline'];
279 backdrop_add_css($code, $params);
286 public function mapConfigToSSL() {
288 $base_url = str_replace('http://', 'https://', $base_url);
292 * Get the name of the table that stores the user details.
296 protected function getUsersTableName() {
297 $userFrameworkUsersTableName = Civi
::settings()->get('userFrameworkUsersTableName');
298 if (empty($userFrameworkUsersTableName)) {
299 $userFrameworkUsersTableName = 'users';
301 return $userFrameworkUsersTableName;
307 public function authenticate($name, $password, $loadCMSBootstrap = FALSE, $realPath = NULL) {
308 $config = CRM_Core_Config
::singleton();
310 $dbBackdrop = DB
::connect($config->userFrameworkDSN
);
311 if (DB
::isError($dbBackdrop)) {
312 throw new CRM_Core_Exception("Cannot connect to Backdrop database via $config->userFrameworkDSN, " . $dbBackdrop->getMessage());
315 $account = $userUid = $userMail = NULL;
316 if ($loadCMSBootstrap) {
317 $bootStrapParams = [];
318 if ($name && $password) {
324 CRM_Utils_System
::loadBootStrap($bootStrapParams, TRUE, TRUE, $realPath);
328 $userUid = $user->uid
;
329 $userMail = $user->mail
;
334 // SOAP cannot load Backdrop bootstrap and hence we do it the old way
335 // Contact CiviSMTP folks if we run into issues with this :)
336 $cmsPath = $this->cmsRootPath();
337 if (!defined('BACKDROP_ROOT')) {
338 define(BACKDROP_ROOT
, $cmsPath);
340 require_once "$cmsPath/core/includes/bootstrap.inc";
341 require_once "$cmsPath/core/includes/password.inc";
343 $strtolower = function_exists('mb_strtolower') ?
'mb_strtolower' : 'strtolower';
344 $name = $dbBackdrop->escapeSimple($strtolower($name));
345 $userFrameworkUsersTableName = $this->getUsersTableName();
347 // LOWER in query below roughly translates to 'hurt my database without deriving any benefit' See CRM-19811.
350 FROM {$userFrameworkUsersTableName} u
351 WHERE LOWER(u.name) = '$name'
355 $query = $dbBackdrop->query($sql);
356 $row = $query->fetchRow(DB_FETCHMODE_ASSOC
);
359 $fakeAccount = backdrop_anonymous_user();
360 $fakeAccount->name
= $name;
361 $fakeAccount->pass
= $row['pass'];
362 $passwordCheck = user_check_password($password, $fakeAccount);
363 if ($passwordCheck) {
364 $userUid = $row['uid'];
365 $userMail = $row['mail'];
370 if ($userUid && $userMail) {
371 CRM_Core_BAO_UFMatch
::synchronizeUFMatch($account, $userUid, $userMail, 'Backdrop');
372 $contactID = CRM_Core_BAO_UFMatch
::getContactId($userUid);
376 return [$contactID, $userUid, mt_rand()];
384 public function loadUser($username) {
387 $user = user_load_by_name($username);
389 if (empty($user->uid
)) {
394 $contact_id = CRM_Core_BAO_UFMatch
::getContactId($uid);
396 // lets store contact id and user id in session
397 $session = CRM_Core_Session
::singleton();
398 $session->set('ufID', $uid);
399 $session->set('userID', $contact_id);
404 * Perform any post login activities required by the UF -
405 * For Backdrop this could mean recording a watchdog message about the new
406 * session, saving the login timestamp, calling hook_user_login(), etc.
408 * @param array $params
409 * The array of form values submitted by the user.
411 public function userLoginFinalize($params = []) {
412 user_login_finalize($params);
418 public function isUserRegistrationPermitted() {
419 if (config_get('system.core', 'user_register') == 'admin_only') {
428 public function isPasswordUserGenerated() {
429 if (config_get('system.core', 'user_email_verification') == TRUE) {
438 public function getUFLocale() {
439 // return CiviCRM’s xx_YY locale that either matches Backdrop’s Chinese locale
440 // (for CRM-6281), Backdrop’s xx_YY or is retrieved based on Backdrop’s xx
441 // sometimes for CLI based on order called, this might not be set and/or empty
444 if (empty($language)) {
448 if ($language->langcode
== 'zh-hans') {
452 if ($language->langcode
== 'zh-hant') {
456 if (preg_match('/^.._..$/', $language->langcode
)) {
457 return $language->langcode
;
460 return CRM_Core_I18n_PseudoConstant
::longForShort(substr($language->langcode
, 0, 2));
466 public function setUFLocale($civicrm_language) {
469 $langcode = substr($civicrm_language, 0, 2);
470 $languages = language_list(FALSE, TRUE);
472 if (isset($languages[$langcode])) {
473 $language = $languages[$langcode];
475 // Config must be re-initialized to reset the base URL
476 // otherwise links will have the wrong language prefix/domain.
477 $config = CRM_Core_Config
::singleton();
487 * Determine the native ID of the CMS user.
489 * @param string $username
492 public function getUfId($username) {
493 $user = user_load_by_name($username);
494 if (empty($user->uid
)) {
503 public function logout() {
504 module_load_include('inc', 'user', 'user.pages');
509 * Get the default location for CiviCRM blocks.
513 public function getDefaultBlockLocation() {
514 return 'sidebar_first';
518 * Load Backdrop bootstrap.
520 * @param array $params
521 * Either uid, or name & pass.
522 * @param bool $loadUser
523 * Boolean Require CMS user load.
524 * @param bool $throwError
525 * If true, print error on failure and exit.
526 * @param bool|string $realPath path to script
530 public function loadBootStrap($params = [], $loadUser = TRUE, $throwError = TRUE, $realPath = NULL) {
531 $cmsPath = $this->cmsRootPath($realPath);
533 if (!file_exists("$cmsPath/core/includes/bootstrap.inc")) {
535 echo '<br />Sorry, could not locate bootstrap.inc\n';
540 // load Backdrop bootstrap
542 define('BACKDROP_ROOT', $cmsPath);
544 // For Backdrop multi-site CRM-11313
545 if ($realPath && strpos($realPath, 'sites/all/modules/') === FALSE) {
546 preg_match('@sites/([^/]*)/modules@s', $realPath, $matches);
547 if (!empty($matches[1])) {
548 $_SERVER['HTTP_HOST'] = $matches[1];
551 require_once "$cmsPath/core/includes/bootstrap.inc";
552 require_once "$cmsPath/core/includes/config.inc";
553 backdrop_bootstrap(BACKDROP_BOOTSTRAP_FULL
);
555 // Explicitly setting error reporting, since we cannot handle Backdrop
558 if (!function_exists('module_exists') ||
!module_exists('civicrm')) {
560 echo '<br />Sorry, could not load Backdrop bootstrap.';
566 // Backdrop successfully bootstrapped.
567 $config = CRM_Core_Config
::singleton();
569 // lets also fix the clean url setting
571 $config->cleanURL
= (int) config_get('system.core', 'clean_url');
573 // we need to call the config hook again, since we now know
574 // all the modules that are listening on it, does not apply
575 // to J! and WP as yet
577 CRM_Utils_Hook
::config($config);
583 $uid = CRM_Utils_Array
::value('uid', $params);
585 // Load the user we need to check Backdrop permissions.
586 $name = CRM_Utils_Array
::value('name', $params, FALSE) ?
$params['name'] : trim(CRM_Utils_Array
::value('name', $_REQUEST));
587 $pass = CRM_Utils_Array
::value('pass', $params, FALSE) ?
$params['pass'] : trim(CRM_Utils_Array
::value('pass', $_REQUEST));
590 $uid = user_authenticate($name, $pass);
593 echo '<br />Sorry, unrecognized username or password.';
602 $account = user_load($uid);
603 if ($account && $account->uid
) {
611 echo '<br />Sorry, can not load CMS user account.';
615 // CRM-6948: When using loadBootStrap, it's implicit that CiviCRM has already loaded its settings
616 // which means that define(CIVICRM_CLEANURL) was correctly set.
618 $config = CRM_Core_Config
::singleton();
619 $config->cleanURL
= (int) config_get('system.core', 'clean_url');
621 // CRM-8655: Backdrop wasn't available during bootstrap, so
622 // hook_civicrm_config() never executes.
623 CRM_Utils_Hook
::config($config);
631 public function cmsRootPath($scriptFilename = NULL) {
632 global $civicrm_paths;
633 if (!empty($civicrm_paths['cms.root']['path'])) {
634 return $civicrm_paths['cms.root']['path'];
640 if (!is_null($scriptFilename)) {
641 $path = $scriptFilename;
644 $path = $_SERVER['SCRIPT_FILENAME'];
648 $pathVars = explode('/',
649 str_replace('//', '/',
650 str_replace('\\', '/', $path)
654 // Keep the first directory name for later.
655 $firstVar = array_shift($pathVars);
657 // Remove script name to reduce one iteration.
658 array_pop($pathVars);
660 // CRM-7429 -- do check for uppermost 'includes' dir, which would
661 // work for multisite installation.
663 $cmsRoot = $firstVar . '/' . implode('/', $pathVars);
664 // Stop if we find backdrop signature file.
665 if (file_exists("$cmsRoot/core/misc/backdrop.js")) {
669 // Remove one directory level.
670 array_pop($pathVars);
671 } while (count($pathVars));
673 return ($valid) ?
$cmsRoot : NULL;
679 public function isUserLoggedIn() {
681 if (function_exists('user_is_logged_in')) {
682 $isloggedIn = user_is_logged_in();
691 public function getLoggedInUfID() {
693 if (function_exists('user_is_logged_in') &&
694 user_is_logged_in() &&
695 function_exists('user_uid_optional_to_arg')
697 $ufID = user_uid_optional_to_arg([]);
706 public function languageNegotiationURL($url, $addLanguagePart = TRUE, $removeLanguagePart = FALSE) {
711 if (function_exists('config_get') &&
712 module_exists('locale') &&
713 function_exists('language_negotiation_get')
717 // Check if language support from the URL (Path prefix or domain) is set.
718 if (language_negotiation_get('language') == 'locale-url') {
719 $urlType = config_get('locale.settings', 'locale_language_negotiation_url_part');
721 // URL prefix negotiation.
722 if ($urlType == LANGUAGE_NEGOTIATION_URL_PREFIX
) {
723 if (isset($language->prefix
) && $language->prefix
) {
724 if ($addLanguagePart) {
725 $url .= $language->prefix
. '/';
727 if ($removeLanguagePart) {
728 $url = str_replace("/{$language->prefix}/", '/', $url);
732 // Domain negotiation.
733 if ($urlType == LANGUAGE_NEGOTIATION_URL_DOMAIN
) {
734 if (isset($language->domain
) && $language->domain
) {
735 if ($addLanguagePart) {
736 $cleanedUrl = preg_replace('#^https?://#', '', $language->domain
);
737 // Backdrop function base_path() adds a "/" to the beginning and
738 // end of the returned path.
739 if (substr($cleanedUrl, -1) == '/') {
740 $cleanedUrl = substr($cleanedUrl, 0, -1);
742 $url = (CRM_Utils_System
::isSSL() ?
'https' : 'http') . '://' . $cleanedUrl . base_path();
744 if ($removeLanguagePart && defined('CIVICRM_UF_BASEURL')) {
745 $url = str_replace('\\', '/', $url);
746 $parseUrl = parse_url($url);
748 //kinda hackish but not sure how to do it right
749 //hope http_build_url() will help at some point.
750 if (is_array($parseUrl) && !empty($parseUrl)) {
751 $urlParts = explode('/', $url);
752 $hostKey = array_search($parseUrl['host'], $urlParts);
753 $ufUrlParts = parse_url(CIVICRM_UF_BASEURL
);
754 $urlParts[$hostKey] = $ufUrlParts['host'];
755 $url = implode('/', $urlParts);
767 * Find any users/roles/security-principals with the given permission
768 * and replace it with one or more permissions.
770 * @param string $oldPerm
771 * @param array $newPerms
774 public function replacePermission($oldPerm, $newPerms) {
775 $roles = user_roles(FALSE, $oldPerm);
776 if (!empty($roles)) {
777 foreach (array_keys($roles) as $rid) {
778 user_role_revoke_permissions($rid, [$oldPerm]);
779 user_role_grant_permissions($rid, $newPerms);
785 * Wrapper for og_membership creation.
792 public function og_membership_create($ogID, $userID) {
793 if (function_exists('og_entity_query_alter')) {
794 // sort-of-randomly chose a function that only exists in the // 7.x-2.x branch
796 // @TODO Find more solid way to check - try system_get_info('module', 'og').
798 // Also, since we don't know how to get the entity type of the // group, we'll assume it's 'node'
799 og_group('node', $ogID, ['entity' => user_load($userID)]);
802 // Works for the OG 7.x-1.x branch
803 og_group($ogID, ['entity' => user_load($userID)]);
808 * Wrapper for og_membership deletion.
815 public function og_membership_delete($ogID, $userID) {
816 if (function_exists('og_entity_query_alter')) {
817 // sort-of-randomly chose a function that only exists in the 7.x-2.x branch
818 // TODO: Find a more solid way to make this test
819 // Also, since we don't know how to get the entity type of the group, we'll assume it's 'node'
820 og_ungroup('node', $ogID, 'user', user_load($userID));
823 // Works for the OG 7.x-1.x branch
824 og_ungroup($ogID, 'user', user_load($userID));
831 public function getTimeZoneString() {
833 // Note that 0 is a valid timezone (GMT) so we use strlen not empty to check.
834 if (config_get('system.date', 'user_configurable_timezones') && $user->uid
&& isset($user->timezone
) && strlen($user->timezone
)) {
835 $timezone = $user->timezone
;
838 $timezone = config_get('system.date', 'default_timezone');
841 $timezone = parent
::getTimeZoneString();
849 public function setHttpHeader($name, $value) {
850 backdrop_add_http_header($name, $value);
856 public function synchronizeUsers() {
857 $config = CRM_Core_Config
::singleton();
858 if (PHP_SAPI
!= 'cli') {
865 $result = db_query("SELECT uid, mail, name FROM {users} where mail != ''");
867 $user = new StdClass();
868 $uf = $config->userFramework
;
871 $contactMatching = 0;
872 foreach ($result as $row) {
873 $user->$id = $row->$id;
874 $user->$mail = $row->$mail;
875 $user->$name = $row->$name;
877 if ($match = CRM_Core_BAO_UFMatch
::synchronizeUFMatch($user, $row->$id, $row->$mail, $uf, 1, 'Individual', TRUE)) {
886 'contactCount' => $contactCount,
887 'contactMatching' => $contactMatching,
888 'contactCreated' => $contactCreated,
895 public function clearResourceCache() {
896 _backdrop_flush_css_js();
900 * Get all the contact emails for users that have a specific permission.
902 * @param string $permissionName
903 * Name of the permission we are interested in.
906 * a comma separated list of email addresses
908 public function permissionEmails($permissionName) {
916 public function getDefaultFileStorage() {
917 $config = CRM_Core_Config
::singleton();
918 $baseURL = CRM_Utils_System
::languageNegotiationURL($config->userFrameworkBaseURL
, FALSE, TRUE);
920 $siteName = $this->parseBackdropSiteNameFromRequest('/files/civicrm');
922 $filesURL = $baseURL . "sites/$siteName/files/civicrm/";
925 $filesURL = $baseURL . "files/civicrm/";
930 'path' => CRM_Utils_File
::baseFilePath(),
935 * Check if a resource url is within the Backdrop directory and format appropriately.
937 * @param $url (reference)
940 * TRUE for internal paths, FALSE for external. The backdrop_add_js fn is able to add js more
941 * efficiently if it is known to be in the Backdrop site
943 public function formatResourceUrl(&$url) {
945 $base = CRM_Core_Config
::singleton()->resourceBase
;
947 // Handle absolute urls
948 // compares $url (which is some unknown/untrusted value from a third-party dev) to the CMS's base url (which is independent of civi's url)
949 // to see if the url is within our Backdrop dir, if it is we are able to treated it as an internal url
950 if (strpos($url, $base_url) === 0) {
951 $file = trim(str_replace($base_url, '', $url), '/');
952 // CRM-18130: Custom CSS URL not working if aliased or rewritten
953 if (file_exists(BACKDROP_ROOT
. $file)) {
958 // Handle relative urls that are within the CiviCRM module directory
959 elseif (strpos($url, $base) === 0) {
961 $url = $this->appendCoreDirectoryToResourceBase(dirname(backdrop_get_path('module', 'civicrm')) . '/') . trim(substr($url, strlen($base)), '/');
963 // Strip query string
964 $q = strpos($url, '?');
965 if ($q && $internal) {
966 $url = substr($url, 0, $q);
974 public function setMessage($message) {
975 backdrop_set_message($message);
981 public function permissionDenied() {
982 backdrop_access_denied();
988 public function flush() {
989 backdrop_flush_all_caches();
993 * Determine if Backdrop multi-site applies to the current request -- and,
994 * specifically, determine the name of the multisite folder.
996 * @param string $flagFile
997 * Check if $flagFile exists inside the site dir.
998 * @return null|string
999 * string, e.g. `bar.example.com` if using multisite.
1000 * NULL if using the default site.
1002 private function parseBackdropSiteNameFromRequest($flagFile = '') {
1003 $phpSelf = array_key_exists('PHP_SELF', $_SERVER) ?
$_SERVER['PHP_SELF'] : '';
1004 $httpHost = array_key_exists('HTTP_HOST', $_SERVER) ?
$_SERVER['HTTP_HOST'] : '';
1005 if (empty($httpHost)) {
1006 $httpHost = parse_url(CIVICRM_UF_BASEURL
, PHP_URL_HOST
);
1007 if (parse_url(CIVICRM_UF_BASEURL
, PHP_URL_PORT
)) {
1008 $httpHost .= ':' . parse_url(CIVICRM_UF_BASEURL
, PHP_URL_PORT
);
1012 $confdir = $this->cmsRootPath() . '/sites';
1014 if (file_exists($confdir . "/sites.php")) {
1015 include $confdir . "/sites.php";
1021 $uri = explode('/', $phpSelf);
1022 $server = explode('.', implode('.', array_reverse(explode(':', rtrim($httpHost, '.')))));
1023 for ($i = count($uri) - 1; $i > 0; $i--) {
1024 for ($j = count($server); $j > 0; $j--) {
1025 $dir = implode('.', array_slice($server, -$j)) . implode('.', array_slice($uri, 0, $i));
1026 if (file_exists("$confdir/$dir" . $flagFile)) {
1027 \Civi
::$statics[__CLASS__
]['drupalSiteName'] = $dir;
1028 return \Civi
::$statics[__CLASS__
]['drupalSiteName'];
1031 if (isset($sites[$dir]) && file_exists("$confdir/{$sites[$dir]}" . $flagFile)) {
1032 \Civi
::$statics[__CLASS__
]['drupalSiteName'] = $sites[$dir];
1033 return \Civi
::$statics[__CLASS__
]['drupalSiteName'];
1040 * Append Backdrop CSS and JS to coreResourcesList.
1042 * @param \Civi\Core\Event\GenericHookEvent $e
1044 public function appendCoreResources(\Civi\Core\Event\GenericHookEvent
$e) {
1045 $e->list[] = 'css/backdrop.css';
1046 $e->list[] = 'js/crm.backdrop.js';