From f517cae44da5b55e7f94300fa64d2e3cf2569a6b Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Thu, 14 Apr 2022 19:33:03 -0400 Subject: [PATCH] Remove code only needed by Drupal6 Followup from https://github.com/civicrm/civicrm-core/pull/22960 --- CRM/Core/Permission/Drupal6.php | 204 ----- CRM/Utils/Hook/Drupal6.php | 18 - CRM/Utils/Hook/WordPress.php | 2 - CRM/Utils/System/Drupal6.php | 823 ------------------ civicrm-version.php | 3 - distmaker/dists/repo-report.sh | 1 - install/civicrm.php | 7 - install/index.php | 2 +- .../CRM/common/civicrm.settings.php.template | 3 - .../CRM/Core/Permission/GenericTest.php | 1 - 10 files changed, 1 insertion(+), 1063 deletions(-) delete mode 100644 CRM/Core/Permission/Drupal6.php delete mode 100644 CRM/Utils/Hook/Drupal6.php delete mode 100644 CRM/Utils/System/Drupal6.php diff --git a/CRM/Core/Permission/Drupal6.php b/CRM/Core/Permission/Drupal6.php deleted file mode 100644 index 5bae3568bdfa..000000000000 --- a/CRM/Core/Permission/Drupal6.php +++ /dev/null @@ -1,204 +0,0 @@ -translatePermission($str, 'Drupal6', [ - 'view user account' => 'access user profiles', - 'administer users' => 'administer users', - ]); - if ($str == CRM_Core_Permission::ALWAYS_DENY_PERMISSION) { - return FALSE; - } - if ($str == CRM_Core_Permission::ALWAYS_ALLOW_PERMISSION) { - return TRUE; - } - if (function_exists('user_access')) { - $account = NULL; - if ($userId || $userId === 0) { - $account = user_load($userId); - } - return user_access($str, $account); - } - return TRUE; - } - - /** - * Given a roles array, check for access requirements - * - * @param array $array - * The roles to check. - * - * @return bool - * true if yes, else false - */ - public function checkGroupRole($array) { - if (function_exists('user_load') && isset($array)) { - $user = user_load(['uid' => $GLOBALS['user']->uid]); - //if giver roles found in user roles - return true - foreach ($array as $key => $value) { - if (in_array($value, $user->roles)) { - return TRUE; - } - } - } - return FALSE; - } - - /** - * Get all the contact emails for users that have a specific role. - * - * @param string $roleName - * Name of the role we are interested in. - * - * @return string - * a comma separated list of email addresses - */ - public function roleEmails($roleName) { - static $_cache = []; - - if (isset($_cache[$roleName])) { - return $_cache[$roleName]; - } - - $uids = []; - $sql = " - SELECT {users}.uid - FROM {users} - LEFT JOIN {users_roles} ON {users}.uid = {users_roles}.uid - INNER JOIN {role} ON ( {role}.rid = {users_roles}.rid OR {role}.rid = 2 ) - WHERE {role}. name LIKE '%%{$roleName}%%' - AND {users}.status = 1 - "; - - $query = db_query($sql); - while ($result = db_fetch_object($query)) { - $uids[] = $result->uid; - } - - $_cache[$roleName] = self::getContactEmails($uids); - return $_cache[$roleName]; - } - - /** - * Get all the contact emails for users that have a specific permission. - * - * @param string $permissionName - * Name of the permission we are interested in. - * - * @return string - * a comma separated list of email addresses - */ - public function permissionEmails($permissionName) { - static $_cache = []; - - if (isset($_cache[$permissionName])) { - return $_cache[$permissionName]; - } - - $uids = []; - $sql = " - SELECT {users}.uid, {permission}.perm - FROM {users} - LEFT JOIN {users_roles} ON {users}.uid = {users_roles}.uid - INNER JOIN {permission} ON ( {permission}.rid = {users_roles}.rid OR {permission}.rid = 2 ) - WHERE {permission}.perm LIKE '%%{$permissionName}%%' - AND {users}.status = 1 - "; - - $query = db_query($sql); - while ($result = db_fetch_object($query)) { - $uids[] = $result->uid; - } - - $_cache[$permissionName] = self::getContactEmails($uids); - return $_cache[$permissionName]; - } - - /** - * @inheritDoc - */ - public function isModulePermissionSupported() { - return TRUE; - } - - /** - * @inheritDoc - * - * Does nothing in Drupal 6. - */ - public function upgradePermissions($permissions) { - // D6 allows us to be really lazy... things get cleaned up when the admin form is next submitted... - } - - /** - * Get the permissions defined in the hook_civicrm_permission implementation - * of the given module. - * - * @param $module - * - * @return array - * Array of permissions, in the same format as CRM_Core_Permission::getCorePermissions(). - */ - public function getModulePermissions($module):array { - $return_permissions = []; - $fn_name = "{$module}_civicrm_permission"; - if (function_exists($fn_name)) { - $fn_name($return_permissions); - } - return $return_permissions; - } - -} diff --git a/CRM/Utils/Hook/Drupal6.php b/CRM/Utils/Hook/Drupal6.php deleted file mode 100644 index 18f83c11272c..000000000000 --- a/CRM/Utils/Hook/Drupal6.php +++ /dev/null @@ -1,18 +0,0 @@ -isBuilt === FALSE) { diff --git a/CRM/Utils/System/Drupal6.php b/CRM/Utils/System/Drupal6.php deleted file mode 100644 index 18f737761daa..000000000000 --- a/CRM/Utils/System/Drupal6.php +++ /dev/null @@ -1,823 +0,0 @@ - $params['cms_name'], - 'mail' => $params[$mail], - 'op' => 'Create new account', - ]; - - $admin = user_access('administer users'); - if (!variable_get('user_email_verification', TRUE) || $admin) { - $form_state['values']['pass']['pass1'] = $params['cms_pass']; - $form_state['values']['pass']['pass2'] = $params['cms_pass']; - } - - $config = CRM_Core_Config::singleton(); - - // we also need to redirect b - $config->inCiviCRM = TRUE; - - $form = drupal_retrieve_form('user_register', $form_state); - $form['#post'] = $form_state['values']; - drupal_prepare_form('user_register', $form, $form_state); - - // remove the captcha element from the form prior to processing - unset($form['captcha']); - - drupal_process_form('user_register', $form, $form_state); - - $config->inCiviCRM = FALSE; - - if (form_get_errors() || !isset($form_state['user'])) { - return FALSE; - } - return $form_state['user']->uid; - } - - /** - * @inheritDoc - */ - public function updateCMSName($ufID, $ufName) { - // CRM-5555 - if (function_exists('user_load')) { - $user = user_load(['uid' => $ufID]); - if ($user->mail != $ufName) { - user_save($user, ['mail' => $ufName]); - $user = user_load(['uid' => $ufID]); - } - } - } - - /** - * Check if username and email exists in the drupal db. - * - * @param array $params - * Array of name and mail values. - * @param array $errors - * Array of errors. - * @param string $emailName - * Field label for the 'email'. - */ - public function checkUserNameEmailExists(&$params, &$errors, $emailName = 'email') { - $config = CRM_Core_Config::singleton(); - - $dao = new CRM_Core_DAO(); - $name = $dao->escape(CRM_Utils_Array::value('name', $params)); - $email = $dao->escape(CRM_Utils_Array::value('mail', $params)); - _user_edit_validate(NULL, $params); - $errors = form_get_errors(); - if ($errors) { - if (!empty($errors['name'])) { - $errors['cms_name'] = $errors['name']; - } - if (!empty($errors['mail'])) { - $errors[$emailName] = $errors['mail']; - } - // also unset drupal messages to avoid twice display of errors - unset($_SESSION['messages']); - } - - // Do the name check manually. - $nameError = user_validate_name($params['name']); - if ($nameError) { - $errors['cms_name'] = $nameError; - } - - // LOWER in query below roughly translates to 'hurt my database without deriving any benefit' See CRM-19811. - $sql = " - SELECT name, mail - FROM {users} - WHERE (LOWER(name) = LOWER('$name')) OR (LOWER(mail) = LOWER('$email')) - "; - - $result = db_query($sql); - $row = db_fetch_array($result); - if (!$row) { - return; - } - - $user = NULL; - - if (!empty($row)) { - $dbName = $row['name'] ?? NULL; - $dbEmail = $row['mail'] ?? NULL; - if (strtolower($dbName) == strtolower($name)) { - $errors['cms_name'] = ts('The username %1 is already taken. Please select another username.', - [1 => $name] - ); - } - if (strtolower($dbEmail) == strtolower($email)) { - if (empty($email)) { - $errors[$emailName] = ts('You cannot create an email account for a contact with no email', - [1 => $email] - ); - } - else { - $errors[$emailName] = ts('This email %1 already has an account associated with it. Please select another email.', - [1 => $email] - ); - } - } - } - } - - /** - * @inheritDoc - */ - public function setTitle($title, $pageTitle = NULL) { - if (!$pageTitle) { - $pageTitle = $title; - } - if (arg(0) == 'civicrm') { - //set drupal title - drupal_set_title($pageTitle); - } - } - - /** - * @inheritDoc - */ - public function appendBreadCrumb($breadCrumbs) { - $breadCrumb = drupal_get_breadcrumb(); - - if (is_array($breadCrumbs)) { - foreach ($breadCrumbs as $crumbs) { - if (stripos($crumbs['url'], 'id%%')) { - $args = ['cid', 'mid']; - foreach ($args as $a) { - $val = CRM_Utils_Request::retrieve($a, 'Positive', CRM_Core_DAO::$_nullObject, - FALSE, NULL, $_GET - ); - if ($val) { - $crumbs['url'] = str_ireplace("%%{$a}%%", $val, $crumbs['url']); - } - } - } - $breadCrumb[] = "{$crumbs['title']}"; - } - } - drupal_set_breadcrumb($breadCrumb); - } - - /** - * @inheritDoc - */ - public function resetBreadCrumb() { - $bc = []; - drupal_set_breadcrumb($bc); - } - - /** - * Append a string to the head of the html file. - * - * @param string $head - * The new string to be appended. - */ - public function addHTMLHead($head) { - drupal_set_html_head($head); - } - - /** - * Add a css file. - * - * @param string $url - * absolute path to file - * @param string $region - * location within the document: 'html-header', 'page-header', 'page-footer'. - * - * Note: This function is not to be called directly - * @see CRM_Core_Region::render() - * - * @return bool - * TRUE if we support this operation in this CMS, FALSE otherwise - */ - public function addStyleUrl($url, $region) { - if ($region != 'html-header' || !$this->formatResourceUrl($url)) { - return FALSE; - } - drupal_add_css($url); - return TRUE; - } - - /** - * @inheritDoc - */ - public function mapConfigToSSL() { - global $base_url; - $base_url = str_replace('http://', 'https://', $base_url); - } - - /** - * Get the name of the table that stores the user details. - * - * @return string - */ - protected function getUsersTableName() { - $userFrameworkUsersTableName = Civi::settings()->get('userFrameworkUsersTableName'); - if (empty($userFrameworkUsersTableName)) { - $userFrameworkUsersTableName = 'users'; - } - return $userFrameworkUsersTableName; - } - - /** - * @inheritDoc - */ - public function authenticate($name, $password, $loadCMSBootstrap = FALSE, $realPath = NULL) { - //@todo this 'PEAR-y' stuff is only required when bookstrap is not being loaded which is rare - // if ever now. - // probably if bootstrap is loaded this call - // CRM_Utils_System::loadBootStrap($bootStrapParams, TRUE, TRUE, $realPath); would be - // sufficient to do what this fn does. It does exist as opposed to return which might need some hanky-panky to make - // safe in the unknown situation where authenticate might be called & it is important that - // false is returned - require_once 'DB.php'; - - $config = CRM_Core_Config::singleton(); - - $ufDSN = CRM_Utils_SQL::autoSwitchDSN($config->userFrameworkDSN); - try { - $dbDrupal = DB::connect($ufDSN); - } - catch (Exception $e) { - throw new CRM_Core_Exception("Cannot connect to drupal db via $ufDSN, " . $e->getMessage()); - } - - $strtolower = function_exists('mb_strtolower') ? 'mb_strtolower' : 'strtolower'; - $dbpassword = md5($password); - $name = $dbDrupal->escapeSimple($strtolower($name)); - $userFrameworkUsersTableName = $this->getUsersTableName(); - $sql = 'SELECT u.* FROM ' . $userFrameworkUsersTableName . " u WHERE LOWER(u.name) = '$name' AND u.pass = '$dbpassword' AND u.status = 1"; - $query = $dbDrupal->query($sql); - - $user = NULL; - // need to change this to make sure we matched only one row - while ($row = $query->fetchRow(DB_FETCHMODE_ASSOC)) { - CRM_Core_BAO_UFMatch::synchronizeUFMatch($user, $row['uid'], $row['mail'], 'Drupal'); - $contactID = CRM_Core_BAO_UFMatch::getContactId($row['uid']); - if (!$contactID) { - return FALSE; - } - else { - //success - if ($loadCMSBootstrap) { - $bootStrapParams = []; - if ($name && $password) { - $bootStrapParams = [ - 'name' => $name, - 'pass' => $password, - ]; - } - CRM_Utils_System::loadBootStrap($bootStrapParams, TRUE, TRUE, $realPath); - } - return [$contactID, $row['uid'], mt_rand()]; - } - } - return FALSE; - } - - /** - * @inheritDoc - */ - public function loadUser($username) { - global $user; - $user = user_load(['name' => $username]); - if (empty($user->uid)) { - return FALSE; - } - - $uid = $user->uid; - $contact_id = CRM_Core_BAO_UFMatch::getContactId($uid); - - // lets store contact id and user id in session - $session = CRM_Core_Session::singleton(); - $session->set('ufID', $uid); - $session->set('userID', $contact_id); - return TRUE; - } - - /** - * Perform any post login activities required by the UF - - * e.g. for drupal : records a watchdog message about the new session, - * saves the login timestamp, calls hook_user op 'login' and generates a new session. - * - * @param array $params - * - * FIXME: Document values accepted/required by $params - */ - public function userLoginFinalize($params = []) { - user_authenticate_finalize($params); - } - - /** - * Determine the native ID of the CMS user. - * - * @param string $username - * @return int|null - */ - public function getUfId($username) { - $user = user_load(['name' => $username]); - if (empty($user->uid)) { - return NULL; - } - return $user->uid; - } - - /** - * @inheritDoc - */ - public function logout() { - module_load_include('inc', 'user', 'user.pages'); - return user_logout(); - } - - /** - * Load drupal bootstrap. - * - * @param array $params - * Either uid, or name & pass. - * @param bool $loadUser - * Boolean Require CMS user load. - * @param bool $throwError - * If true, print error on failure and exit. - * @param bool|string $realPath path to script - * - * @return bool - */ - public function loadBootStrap($params = [], $loadUser = TRUE, $throwError = TRUE, $realPath = NULL) { - //take the cms root path. - $cmsPath = $this->cmsRootPath($realPath); - - if (!file_exists("$cmsPath/includes/bootstrap.inc")) { - if ($throwError) { - echo '
Sorry, could not locate bootstrap.inc\n'; - exit(); - } - return FALSE; - } - // load drupal bootstrap - chdir($cmsPath); - define('DRUPAL_ROOT', $cmsPath); - - // For drupal multi-site CRM-11313 - if ($realPath && strpos($realPath, 'sites/all/modules/') === FALSE) { - preg_match('@sites/([^/]*)/modules@s', $realPath, $matches); - if (!empty($matches[1])) { - $_SERVER['HTTP_HOST'] = $matches[1]; - } - } - require_once 'includes/bootstrap.inc'; - // @ to suppress notices eg 'DRUPALFOO already defined'. - @drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); - - // explicitly setting error reporting, since we cannot handle drupal related notices - error_reporting(1); - if (!function_exists('module_exists') || !module_exists('civicrm')) { - if ($throwError) { - echo '
Sorry, could not load drupal bootstrap.'; - exit(); - } - return FALSE; - } - - // seems like we've bootstrapped drupal - $config = CRM_Core_Config::singleton(); - - // lets also fix the clean url setting - // CRM-6948 - $config->cleanURL = (int) variable_get('clean_url', '0'); - - // we need to call the config hook again, since we now know - // all the modules that are listening on it, does not apply - // to J! and WP as yet - // CRM-8655 - CRM_Utils_Hook::config($config); - - if (!$loadUser) { - return TRUE; - } - global $user; - // If $uid is passed in, authentication has been done already. - $uid = $params['uid'] ?? NULL; - if (!$uid) { - //load user, we need to check drupal permissions. - $name = CRM_Utils_Array::value('name', $params, FALSE) ? $params['name'] : trim(CRM_Utils_Array::value('name', $_REQUEST)); - $pass = CRM_Utils_Array::value('pass', $params, FALSE) ? $params['pass'] : trim(CRM_Utils_Array::value('pass', $_REQUEST)); - - if ($name) { - $user = user_authenticate(['name' => $name, 'pass' => $pass]); - if (!$user->uid) { - if ($throwError) { - echo '
Sorry, unrecognized username or password.'; - exit(); - } - return FALSE; - } - else { - return TRUE; - } - } - } - - if ($uid) { - $account = user_load($uid); - if ($account && $account->uid) { - $user = $account; - return TRUE; - } - } - - if ($throwError) { - echo '
Sorry, can not load CMS user account.'; - exit(); - } - - // CRM-6948: When using loadBootStrap, it's implicit that CiviCRM has already loaded its settings - // which means that define(CIVICRM_CLEANURL) was correctly set. - // So we correct it - $config = CRM_Core_Config::singleton(); - $config->cleanURL = (int) variable_get('clean_url', '0'); - - // CRM-8655: Drupal wasn't available during bootstrap, so hook_civicrm_config never executes - CRM_Utils_Hook::config($config); - - return FALSE; - } - - /** - * Get CMS root path. - * - * @param string $scriptFilename - * - * @return null|string - */ - public function cmsRootPath($scriptFilename = NULL) { - $cmsRoot = $valid = NULL; - - if (!is_null($scriptFilename)) { - $path = $scriptFilename; - } - else { - $path = $_SERVER['SCRIPT_FILENAME']; - } - - if (function_exists('drush_get_context')) { - // drush anyway takes care of multisite install etc - return drush_get_context('DRUSH_DRUPAL_ROOT'); - } - - global $civicrm_paths; - if (!empty($civicrm_paths['cms.root']['path'])) { - return $civicrm_paths['cms.root']['path']; - } - - // CRM-7582 - $pathVars = explode('/', - str_replace('//', '/', - str_replace('\\', '/', $path) - ) - ); - - //lets store first var, - //need to get back for windows. - $firstVar = array_shift($pathVars); - - //lets remove sript name to reduce one iteration. - array_pop($pathVars); - - //CRM-7429 --do check for upper most 'includes' dir, - //which would effectually work for multisite installation. - do { - $cmsRoot = $firstVar . '/' . implode('/', $pathVars); - $cmsIncludePath = "$cmsRoot/includes"; - // Stop if we found bootstrap. - if (file_exists("$cmsIncludePath/bootstrap.inc")) { - $valid = TRUE; - break; - } - //remove one directory level. - array_pop($pathVars); - } while (count($pathVars)); - - return ($valid) ? $cmsRoot : NULL; - } - - /** - * @inheritDoc - */ - public function isUserLoggedIn() { - $isloggedIn = FALSE; - if (function_exists('user_is_logged_in')) { - $isloggedIn = user_is_logged_in(); - } - - return $isloggedIn; - } - - /** - * @inheritDoc - */ - public function getLoggedInUfID() { - $ufID = NULL; - if (function_exists('user_is_logged_in') && - user_is_logged_in() && - function_exists('user_uid_optional_to_arg') - ) { - $ufID = user_uid_optional_to_arg([]); - } - - return $ufID; - } - - /** - * @inheritDoc - */ - public function languageNegotiationURL($url, $addLanguagePart = TRUE, $removeLanguagePart = FALSE) { - if (empty($url)) { - return $url; - } - - //up to d6 only, already we have code in place for d7 - $config = CRM_Core_Config::singleton(); - if (function_exists('variable_get') && - module_exists('locale') - ) { - global $language; - - //get the mode. - $mode = variable_get('language_negotiation', LANGUAGE_NEGOTIATION_NONE); - - //url prefix / path. - if (isset($language->prefix) && - $language->prefix && - in_array($mode, [ - LANGUAGE_NEGOTIATION_PATH, - LANGUAGE_NEGOTIATION_PATH_DEFAULT, - ]) - ) { - - if ($addLanguagePart) { - $url .= $language->prefix . '/'; - } - if ($removeLanguagePart) { - $url = str_replace("/{$language->prefix}/", '/', $url); - } - } - if (isset($language->domain) && - $language->domain && - $mode == LANGUAGE_NEGOTIATION_DOMAIN - ) { - - if ($addLanguagePart) { - $url = CRM_Utils_File::addTrailingSlash($language->domain, '/'); - } - if ($removeLanguagePart && defined('CIVICRM_UF_BASEURL')) { - $url = str_replace('\\', '/', $url); - $parseUrl = parse_url($url); - - //kinda hackish but not sure how to do it right - //hope http_build_url() will help at some point. - if (is_array($parseUrl) && !empty($parseUrl)) { - $urlParts = explode('/', $url); - $hostKey = array_search($parseUrl['host'], $urlParts); - $ufUrlParts = parse_url(CIVICRM_UF_BASEURL); - $urlParts[$hostKey] = $ufUrlParts['host']; - $url = implode('/', $urlParts); - } - } - } - } - - return $url; - } - - /** - * Find any users/roles/security-principals with the given permission - * and replace it with one or more permissions. - * - * @param string $oldPerm - * @param array $newPerms - * Array, strings. - */ - public function replacePermission($oldPerm, $newPerms) { - $roles = user_roles(FALSE, $oldPerm); - foreach ($roles as $rid => $roleName) { - $permList = db_result(db_query('SELECT perm FROM {permission} WHERE rid = %d', $rid)); - $perms = drupal_map_assoc(explode(', ', $permList)); - unset($perms[$oldPerm]); - $perms = $perms + drupal_map_assoc($newPerms); - $permList = implode(', ', $perms); - db_query('UPDATE {permission} SET perm = "%s" WHERE rid = %d', $permList, $rid); - /* @codingStandardsIgnoreStart - if ( ! empty( $roles ) ) { - $rids = implode(',', array_keys($roles)); - db_query( 'UPDATE {permission} SET perm = CONCAT( perm, \', edit all events\') WHERE rid IN (' . implode(',', array_keys($roles)) . ')' ); - db_query( "UPDATE {permission} SET perm = REPLACE( perm, '%s', '%s' ) WHERE rid IN ($rids)", - $oldPerm, implode(', ', $newPerms) ); - @codingStandardsIgnoreEnd */ - } - } - - /** - * @inheritDoc - */ - public function getModules() { - $result = []; - $q = db_query('SELECT name, status FROM {system} WHERE type = \'module\' AND schema_version <> -1'); - while ($row = db_fetch_object($q)) { - $result[] = new CRM_Core_Module('drupal.' . $row->name, $row->status == 1); - } - return $result; - } - - /** - * @inheritDoc - */ - public function getLoginURL($destination = '') { - $config = CRM_Core_Config::singleton(); - $loginURL = $config->userFrameworkBaseURL; - $loginURL .= 'user'; - if (!empty($destination)) { - // append destination so user is returned to form they came from after login - $loginURL .= '?destination=' . urlencode($destination); - } - return $loginURL; - } - - /** - * Wrapper for og_membership creation. - * - * @param int $ogID - * Organic Group ID. - * @param int $drupalID - * Drupal User ID. - */ - public function og_membership_create($ogID, $drupalID) { - og_save_subscription($ogID, $drupalID, ['is_active' => 1]); - } - - /** - * Wrapper for og_membership deletion. - * - * @param int $ogID - * Organic Group ID. - * @param int $drupalID - * Drupal User ID. - */ - public function og_membership_delete($ogID, $drupalID) { - og_delete_subscription($ogID, $drupalID); - } - - /** - * @inheritDoc - */ - public function getTimeZoneString() { - global $user; - // Note that 0 is a valid timezone (GMT) so we use strlen not empty to check. - if (variable_get('configurable_timezones', 1) && $user->uid && isset($user->timezone) && strlen($user->timezone)) { - $timezone = $user->timezone; - } - else { - $timezone = variable_get('date_default_timezone', NULL); - } - - // Retrieved timezone will be represented as GMT offset in seconds but, according - // to the doc for the overridden method, ought to be returned as a region string - // (e.g., America/Havana). - if (strlen($timezone)) { - $timezone = timezone_name_from_abbr("", (int) $timezone); - } - - if (!$timezone) { - $timezone = parent::getTimeZoneString(); - } - - return $timezone; - } - - /** - * @inheritDoc - */ - public function setHttpHeader($name, $value) { - drupal_set_header("$name: $value"); - } - - /** - * @inheritDoc - */ - public function synchronizeUsers() { - $config = CRM_Core_Config::singleton(); - if (PHP_SAPI != 'cli') { - set_time_limit(300); - } - $rows = []; - $id = 'uid'; - $mail = 'mail'; - $name = 'name'; - - $result = db_query("SELECT uid, mail, name FROM {users} where mail != ''"); - - while ($row = db_fetch_array($result)) { - $rows[] = $row; - } - - $user = new StdClass(); - $uf = $config->userFramework; - $contactCount = 0; - $contactCreated = 0; - $contactMatching = 0; - foreach ($rows as $row) { - $user->$id = $row[$id]; - $user->$mail = $row[$mail]; - $user->$name = $row[$name]; - $contactCount++; - if ($match = CRM_Core_BAO_UFMatch::synchronizeUFMatch($user, $row[$id], $row[$mail], $uf, 1, 'Individual', TRUE)) { - $contactCreated++; - } - else { - $contactMatching++; - } - } - - return [ - 'contactCount' => $contactCount, - 'contactMatching' => $contactMatching, - 'contactCreated' => $contactCreated, - ]; - } - - /** - * Return the CMS-specific url for its permissions page - * @return array - */ - public function getCMSPermissionsUrlParams() { - return ['ufAccessURL' => url('admin/user/permissions')]; - } - -} diff --git a/civicrm-version.php b/civicrm-version.php index 2209ab924062..243416452f3e 100644 --- a/civicrm-version.php +++ b/civicrm-version.php @@ -29,9 +29,6 @@ public static function findCMS() { elseif (defined('BACKDROP_VERSION')) { return 'Backdrop'; } - elseif (function_exists('drupal_bootstrap') && version_compare(VERSION, '6.0', '>=') && version_compare(VERSION, '7.0', '<')) { - return 'Drupal6'; - } elseif (function_exists('drupal_bootstrap') && version_compare(VERSION, '7.0', '>=') && version_compare(VERSION, '8.0', '<')) { return 'Drupal'; } diff --git a/distmaker/dists/repo-report.sh b/distmaker/dists/repo-report.sh index 32402bb570d6..8b745b6fdf37 100755 --- a/distmaker/dists/repo-report.sh +++ b/distmaker/dists/repo-report.sh @@ -19,7 +19,6 @@ env \ DM_SOURCEDIR="$DM_SOURCEDIR" \ DM_REF_CORE="$DM_REF_CORE" \ DM_REF_BACKDROP="$DM_REF_BACKDROP" \ - DM_REF_DRUPAL6="$DM_REF_DRUPAL6" \ DM_REF_DRUPAL="$DM_REF_DRUPAL" \ DM_REF_DRUPAL8="$DM_REF_DRUPAL8" \ DM_REF_JOOMLA="$DM_REF_JOOMLA" \ diff --git a/install/civicrm.php b/install/civicrm.php index 5179735d0825..6d08fcf94fa9 100644 --- a/install/civicrm.php +++ b/install/civicrm.php @@ -227,13 +227,6 @@ function civicrm_config(&$config) { $params['CMSdbHost'] = $config['drupal']['server']; $params['CMSdbName'] = addslashes($config['drupal']['database']); } - elseif (version_compare(VERSION, '6.0') >= 0) { - $params['cms'] = 'Drupal6'; - $params['CMSdbUser'] = addslashes($config['drupal']['username']); - $params['CMSdbPass'] = addslashes($config['drupal']['password']); - $params['CMSdbHost'] = $config['drupal']['server']; - $params['CMSdbName'] = addslashes($config['drupal']['database']); - } } elseif ($installType == 'drupal') { $params['cms'] = $config['cms']; diff --git a/install/index.php b/install/index.php index 0c6b62c2c92d..a7c96f1f2e00 100644 --- a/install/index.php +++ b/install/index.php @@ -254,7 +254,7 @@ if ($installType == 'drupal') { // Ensure that they have downloaded the correct version of CiviCRM - if ($civicrm_version['cms'] != 'Drupal' && $civicrm_version['cms'] != 'Drupal6') { + if ($civicrm_version['cms'] != 'Drupal') { $errorTitle = ts("Oops! Incorrect CiviCRM version"); $errorMsg = ts("This installer can only be used for the Drupal version of CiviCRM."); errorDisplayPage($errorTitle, $errorMsg); diff --git a/templates/CRM/common/civicrm.settings.php.template b/templates/CRM/common/civicrm.settings.php.template index 2ee27829d9b4..d7019b1e93f2 100644 --- a/templates/CRM/common/civicrm.settings.php.template +++ b/templates/CRM/common/civicrm.settings.php.template @@ -41,9 +41,6 @@ global $civicrm_root, $civicrm_setting, $civicrm_paths; * Settings for Drupal 7.x: * define( 'CIVICRM_UF' , 'Drupal'); * - * Settings for Drupal 6.x: - * define( 'CIVICRM_UF' , 'Drupal6'); - * * Settings for Joomla 1.7.x - 2.5.x: * define( 'CIVICRM_UF' , 'Joomla'); * diff --git a/tests/phpunit/CRM/Core/Permission/GenericTest.php b/tests/phpunit/CRM/Core/Permission/GenericTest.php index 97aa95c16732..e506475c414f 100644 --- a/tests/phpunit/CRM/Core/Permission/GenericTest.php +++ b/tests/phpunit/CRM/Core/Permission/GenericTest.php @@ -14,7 +14,6 @@ public function permissionClasses() { $cases = []; $cases[] = ['CRM_Core_Permission_Drupal']; - $cases[] = ['CRM_Core_Permission_Drupal6']; $cases[] = ['CRM_Core_Permission_Joomla']; $cases[] = ['CRM_Core_Permission_WordPress'];