Merge pull request #15321 from yashodha/dev_1065
[civicrm-core.git] / CRM / Core / BAO / UFGroup.php
index 2aabfc253b8c29f64360591aa4a3d87958ff1840..5c5ab2a478c927a09cba82f2e354d2ddf996ed6f 100644 (file)
@@ -283,7 +283,8 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup {
    *
    * @return array
    *   The fields that belong to this ufgroup(s)
-   * @throws \Exception
+   *
+   * @throws \CRM_Core_Exception
    */
   public static function getFields(
     $id,
@@ -366,7 +367,7 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup {
     }
 
     if (empty($fields) && !$validGroup) {
-      CRM_Core_Error::fatal(ts('The requested Profile (gid=%1) is disabled OR it is not configured to be used for \'Profile\' listings in its Settings OR there is no Profile with that ID OR you do not have permission to access this profile. Please contact the site administrator if you need assistance.',
+      throw new CRM_Core_Exception(ts('The requested Profile (gid=%1) is disabled OR it is not configured to be used for \'Profile\' listings in its Settings OR there is no Profile with that ID OR you do not have permission to access this profile. Please contact the site administrator if you need assistance.',
         [1 => implode(',', $profileIds)]
       ));
     }
@@ -2122,7 +2123,7 @@ AND    ( entity_id IS NULL OR entity_id <= 0 )
       );
     }
     elseif ($fieldName === 'contribution_status_id') {
-      $contributionStatuses = CRM_Contribute_PseudoConstant::contributionStatus();
+      $contributionStatuses = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'label');
       $statusName = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
       foreach (['In Progress', 'Overdue', 'Refunded'] as $suppress) {
         unset($contributionStatuses[CRM_Utils_Array::key($suppress, $statusName)]);
@@ -3626,4 +3627,18 @@ SELECT  group_id
     }
   }
 
+  /**
+   * Get the frontend_title for the profile, falling back on 'title' if none.
+   *
+   * @param int $profileID
+   *
+   * @return string
+   *
+   * @throws \CiviCRM_API3_Exception
+   */
+  public static function getFrontEndTitle(int $profileID) {
+    $profile = civicrm_api3('UFGroup', 'getsingle', ['id' => $profileID, 'return' => ['title', 'frontend_title']]);
+    return $profile['frontend_title'] ?? $profile['title'];
+  }
+
 }