Merge pull request #17732 from civicrm/5.27
[civicrm-core.git] / CRM / Contact / Page / AJAX.php
index 334925e6af939e7fde784749714312d81b5845fa..4b91252858b3dd1877334767b67bf765abef44dd 100644 (file)
@@ -37,7 +37,7 @@ class CRM_Contact_Page_AJAX {
    * Todo: Migrate contact reference fields to use EntityRef
    */
   public static function contactReference() {
-    $name = CRM_Utils_Array::value('term', $_GET);
+    $name = $_GET['term'] ?? NULL;
     $name = CRM_Utils_Type::escape($name, 'String');
     $cfID = CRM_Utils_Type::escape($_GET['id'], 'Positive');
 
@@ -54,7 +54,7 @@ class CRM_Contact_Page_AJAX {
       $filterParams = [];
       parse_str($cf['filter'], $filterParams);
 
-      $action = CRM_Utils_Array::value('action', $filterParams);
+      $action = $filterParams['action'] ?? NULL;
       if (!empty($action) && !in_array($action, ['get', 'lookup'])) {
         CRM_Utils_System::civiExit(1);
       }
@@ -146,7 +146,7 @@ class CRM_Contact_Page_AJAX {
    * Fetch PCP ID by PCP Supporter sort_name, also displays PCP title and associated Contribution Page title
    */
   public static function getPCPList() {
-    $name = CRM_Utils_Array::value('term', $_GET);
+    $name = $_GET['term'] ?? NULL;
     $name = CRM_Utils_Type::escape($name, 'String');
     $limit = $max = Civi::settings()->get('search_autocomplete_count');
 
@@ -347,7 +347,7 @@ class CRM_Contact_Page_AJAX {
    */
   public static function getContactEmail() {
     $queryStrings = [];
-    $name = CRM_Utils_Array::value('name', $_GET);
+    $name = $_GET['name'] ?? NULL;
     if ($name) {
       $name = CRM_Utils_Type::escape($name, 'String');
       $wildCard = Civi::settings()->get('includeWildCardInName') ? '%' : '';
@@ -401,7 +401,7 @@ LIMIT {$rowCount}
     $sqlParmas = [];
     //check for mobile type
     $phoneTypes = CRM_Core_OptionGroup::values('phone_type', TRUE, FALSE, FALSE, NULL, 'name');
-    $mobileType = CRM_Utils_Array::value('Mobile', $phoneTypes);
+    $mobileType = $phoneTypes['Mobile'] ?? NULL;
 
     $name = CRM_Utils_Request::retrieveValue('name', 'String', NULL, FALSE, 'GET');
     if ($name) {
@@ -506,12 +506,12 @@ LIMIT {$offset}, {$rowCount}
   public static function dashboard() {
     switch ($_REQUEST['op']) {
       case 'save_columns':
-        CRM_Core_BAO_Dashboard::saveDashletChanges($_REQUEST['columns']);
+        CRM_Core_BAO_Dashboard::saveDashletChanges($_REQUEST['columns'] ?? NULL);
         break;
 
       case 'delete_dashlet':
         $dashletID = CRM_Utils_Type::escape($_REQUEST['dashlet_id'], 'Positive');
-        CRM_Core_BAO_Dashboard::deleteDashlet($dashletID);
+        CRM_Core_DAO_Dashboard::deleteRecord(['id' => $dashletID]);
     }
 
     CRM_Utils_System::civiExit();
@@ -651,7 +651,7 @@ LIMIT {$offset}, {$rowCount}
           $dir = CRM_Utils_Type::escape($orderInfo['dir'], 'MysqlOrderByDirection', FALSE);
         }
       }
-      $columnDetails = CRM_Utils_Array::value($orderColumnNumber, $_REQUEST['columns']);
+      $columnDetails = $_REQUEST['columns'][$orderColumnNumber] ?? NULL;
     }
     if (!empty($columnDetails)) {
       switch ($columnDetails['data']) {
@@ -699,8 +699,8 @@ LIMIT {$offset}, {$rowCount}
     $count = 0;
     foreach ($dupePairs as $key => $pairInfo) {
       $pair = $pairInfo['data'];
-      $srcContactSubType  = CRM_Utils_Array::value('src_contact_sub_type', $pairInfo);
-      $dstContactSubType  = CRM_Utils_Array::value('dst_contact_sub_type', $pairInfo);
+      $srcContactSubType  = $pairInfo['src_contact_sub_type'] ?? NULL;
+      $dstContactSubType  = $pairInfo['dst_contact_sub_type'] ?? NULL;
       $srcTypeImage = CRM_Contact_BAO_Contact_Utils::getImage($srcContactSubType ?
         $srcContactSubType : $pairInfo['src_contact_type'],
         FALSE,
@@ -716,16 +716,16 @@ LIMIT {$offset}, {$rowCount}
       $searchRows[$count]['is_selected_input'] = "<input type='checkbox' class='crm-dedupe-select' name='pnid_{$pairInfo['prevnext_id']}' value='{$pairInfo['is_selected']}' onclick='toggleDedupeSelect(this)'>";
       $searchRows[$count]['src_image'] = $srcTypeImage;
       $searchRows[$count]['src'] = CRM_Utils_System::href($pair['srcName'], 'civicrm/contact/view', "reset=1&cid={$pairInfo['entity_id2']}");
-      $searchRows[$count]['src_email'] = CRM_Utils_Array::value('src_email', $pairInfo);
-      $searchRows[$count]['src_street'] = CRM_Utils_Array::value('src_street', $pairInfo);
-      $searchRows[$count]['src_postcode'] = CRM_Utils_Array::value('src_postcode', $pairInfo);
+      $searchRows[$count]['src_email'] = $pairInfo['src_email'] ?? NULL;
+      $searchRows[$count]['src_street'] = $pairInfo['src_street'] ?? NULL;
+      $searchRows[$count]['src_postcode'] = $pairInfo['src_postcode'] ?? NULL;
       $searchRows[$count]['dst_image'] = $dstTypeImage;
       $searchRows[$count]['dst'] = CRM_Utils_System::href($pair['dstName'], 'civicrm/contact/view', "reset=1&cid={$pairInfo['entity_id1']}");
-      $searchRows[$count]['dst_email'] = CRM_Utils_Array::value('dst_email', $pairInfo);
-      $searchRows[$count]['dst_street'] = CRM_Utils_Array::value('dst_street', $pairInfo);
-      $searchRows[$count]['dst_postcode'] = CRM_Utils_Array::value('dst_postcode', $pairInfo);
+      $searchRows[$count]['dst_email'] = $pairInfo['dst_email'] ?? NULL;
+      $searchRows[$count]['dst_street'] = $pairInfo['dst_street'] ?? NULL;
+      $searchRows[$count]['dst_postcode'] = $pairInfo['dst_postcode'] ?? NULL;
       $searchRows[$count]['conflicts'] = str_replace("',", "',<br/>", CRM_Utils_Array::value('conflicts', $pair));
-      $searchRows[$count]['weight'] = CRM_Utils_Array::value('weight', $pair);
+      $searchRows[$count]['weight'] = $pair['weight'] ?? NULL;
 
       if (!empty($pairInfo['data']['canMerge'])) {
         $mergeParams = [
@@ -769,8 +769,8 @@ LIMIT {$offset}, {$rowCount}
    */
   public static function getSearchOptionsFromRequest() {
     $searchParams = [];
-    $searchData = CRM_Utils_Array::value('search', $_REQUEST);
-    $searchData['value'] = CRM_Utils_Type::escape($searchData['value'], 'String');
+    $searchData = $_REQUEST['search'] ?? NULL;
+    $searchData['value'] = CRM_Utils_Type::escape($searchData['value'] ?? NULL, 'String');
     $selectorElements = [
       'is_selected',
       'is_selected_input',
@@ -814,7 +814,7 @@ LIMIT {$offset}, {$rowCount}
    * @return bool
    */
   public static function isOrQuery() {
-    $searchData = CRM_Utils_Array::value('search', $_REQUEST);
+    $searchData = $_REQUEST['search'] ?? NULL;
     return !empty($searchData['value']);
   }
 
@@ -909,8 +909,8 @@ LIMIT {$offset}, {$rowCount}
    * Used to store selected contacts across multiple pages in advanced search.
    */
   public static function selectUnselectContacts() {
-    $name = CRM_Utils_Array::value('name', $_REQUEST);
-    $cacheKey = CRM_Utils_Array::value('qfKey', $_REQUEST);
+    $name = $_REQUEST['name'] ?? NULL;
+    $cacheKey = $_REQUEST['qfKey'] ?? NULL;
     $state = CRM_Utils_Array::value('state', $_REQUEST, 'checked');
     $variableType = CRM_Utils_Array::value('variableType', $_REQUEST, 'single');