Show correct CMS name for profile uf group types
[civicrm-core.git] / CRM / Utils / System / Backdrop.php
index ded63e216442af1d0c5a0a9d3cbba3e4831cc201..692669e82f75b3c522c7705ec2139bacb5f489a3 100644 (file)
@@ -292,9 +292,11 @@ class CRM_Utils_System_Backdrop extends CRM_Utils_System_DrupalBase {
     $config = CRM_Core_Config::singleton();
 
     $ufDSN = CRM_Utils_SQL::autoSwitchDSN($config->userFrameworkDSN);
-    $dbBackdrop = DB::connect($ufDSN);
-    if (DB::isError($dbBackdrop)) {
-      throw new CRM_Core_Exception("Cannot connect to Backdrop database via $ufDSN, " . $dbBackdrop->getMessage());
+    try {
+      $dbBackdrop = DB::connect($ufDSN);
+    }
+    catch (Exception $e) {
+      throw new CRM_Core_Exception("Cannot connect to Backdrop database via $ufDSN, " . $e->getMessage());
     }
 
     $account = $userUid = $userMail = NULL;
@@ -539,9 +541,6 @@ AND    u.status = 1
     require_once "$cmsPath/core/includes/config.inc";
     backdrop_bootstrap(BACKDROP_BOOTSTRAP_FULL);
 
-    // Explicitly setting error reporting, since we cannot handle Backdrop
-    // related notices.
-    error_reporting(1);
     if (!function_exists('module_exists') || !module_exists('civicrm')) {
       if ($throwError) {
         echo '<br />Sorry, could not load Backdrop bootstrap.';
@@ -1057,4 +1056,27 @@ AND    u.status = 1
     return ['ufAccessURL' => url('admin/config/people/permissions')];
   }
 
+  /**
+   * Get the CRM database as a 'prefix'.
+   *
+   * This returns a string that can be prepended to a query to include a CRM table.
+   *
+   * However, this string should contain backticks, or not, in accordance with the
+   * CMS's drupal views expectations, if any.
+   */
+  public function getCRMDatabasePrefix(): string {
+    return str_replace(parent::getCRMDatabasePrefix(), '`', '');
+  }
+
+  /**
+   * Return the CMS-specific UF Group Types for profiles.
+   * @return array
+   */
+  public function getUfGroupTypes() {
+    return [
+      'User Registration' => ts('Backdrop User Registration'),
+      'User Account' => ts('View/Edit Backdrop User Account'),
+    ];
+  }
+
 }