Remove some calls to deprecated function
authorEileen McNaughton <emcnaughton@wikimedia.org>
Thu, 30 Nov 2023 20:34:01 +0000 (09:34 +1300)
committerEileen McNaughton <emcnaughton@wikimedia.org>
Thu, 30 Nov 2023 21:54:47 +0000 (10:54 +1300)
https://github.com/civicrm/civicrm-core/pull/23880 is
thoroughly stale so I'm closing it - but just thought I'd rescue a couple of changes

These are in the barely maintained legacycustomsearches so of marginal risk &
marginal benefit but since I looked maybe no-one else has to ever again...

ext/legacycustomsearches/CRM/Contact/Form/Search/Custom/ActivitySearch.php
ext/legacycustomsearches/CRM/Contact/Form/Search/Custom/FullText.php

index 79ed1049520f5b294af9b5f0404c6e0507564cc4..159577b173fee18c8c4758e76cc0887d2270567d 100644 (file)
@@ -96,7 +96,7 @@ class CRM_Contact_Form_Search_Custom_ActivitySearch extends CRM_Contact_Form_Sea
     );
 
     // Select box for Activity Type
-    $activityType = ['' => ts(' - select activity - ')] + CRM_Core_PseudoConstant::activityType();
+    $activityType = ['' => ts(' - select activity - ')] + CRM_Activity_BAO_Activity::buildOptions('activity_type_id', 'search');
 
     $form->add('select', 'activity_type_id', ts('Activity Type'),
       $activityType,
@@ -104,7 +104,7 @@ class CRM_Contact_Form_Search_Custom_ActivitySearch extends CRM_Contact_Form_Sea
     );
 
     // textbox for Activity Status
-    $activityStatus = ['' => ts(' - select status - ')] + CRM_Core_PseudoConstant::activityStatus();
+    $activityStatus = ['' => ts(' - select status - ')] + CRM_Activity_BAO_Activity::buildOptions('status_id', 'search');
 
     $form->add('select', 'activity_status_id', ts('Activity Status'),
       $activityStatus,
index ae6eeec70cf2be1f72e3fcc8414144f7685ab871..d19435aaa6bd276bdee4243d55fb93642838d885 100644 (file)
@@ -112,8 +112,8 @@ class CRM_Contact_Form_Search_Custom_FullText extends CRM_Contact_Form_Search_Cu
       // 1. this custom search has slightly different structure ,
       // 2. we are in constructor right now,
       // we 'll use a small hack -
-      $rowCount = CRM_Utils_Array::value('crmRowCount', $_REQUEST, Civi::settings()->get('default_pager_size'));
-      $pageId = CRM_Utils_Array::value('crmPID', $_REQUEST, 1);
+      $rowCount = $_REQUEST['crmRowCount'] ?? Civi::settings()->get('default_pager_size');
+      $pageId = $_REQUEST['crmPID'] ?? 1;
       $offset = ($pageId - 1) * $rowCount;
       $this->_limitClause = NULL;
       $this->_limitRowClause = [$rowCount, NULL];
@@ -137,7 +137,7 @@ class CRM_Contact_Form_Search_Custom_FullText extends CRM_Contact_Form_Search_Cu
   public function getFieldValue(array $formValues, string $field, $type, $default = NULL) {
     $value = $formValues[$field] ?? NULL;
     if (!$value) {
-      return CRM_Utils_Request::retrieve($field, $type, CRM_Core_DAO::$_nullObject, FALSE, $default);
+      return CRM_Utils_Request::retrieve($field, $type, NULL, FALSE, $default);
     }
     return $value;
   }
@@ -377,8 +377,6 @@ WHERE      t.table_name = 'Activity' AND
     }
     $dao = CRM_Core_DAO::executeQuery($sql);
 
-    $activityTypes = CRM_Core_PseudoConstant::activityType(TRUE, TRUE);
-    $roleIds = CRM_Event_PseudoConstant::participantRole();
     while ($dao->fetch()) {
       $row = [];
       foreach ($this->_tableFields as $name => $dontCare) {
@@ -386,14 +384,14 @@ WHERE      t.table_name = 'Activity' AND
           $row[$name] = $dao->$name;
         }
         else {
-          $row['activity_type'] = $activityTypes[$dao->$name] ?? NULL;
+          $row['activity_type'] = CRM_Core_PseudoConstant::getLabel('CRM_Activity_BAO_Activity', 'activity_type_id', $dao->$name);
         }
       }
       if (isset($row['participant_role'])) {
         $participantRole = explode(CRM_Core_DAO::VALUE_SEPARATOR, $row['participant_role']);
         $viewRoles = [];
         foreach ($participantRole as $v) {
-          $viewRoles[] = $roleIds[$v];
+          $viewRoles[] = CRM_Core_PseudoConstant::getLabel('CRM_Event_BAO_Participant', 'role_id', $v);
         }
         $row['participant_role'] = implode(', ', $viewRoles);
       }