Merge pull request #21575 from agh1/5.42.0-releasenotes-initial
authorEileen McNaughton <emcnaughton@wikimedia.org>
Wed, 22 Sep 2021 19:30:30 +0000 (07:30 +1200)
committerGitHub <noreply@github.com>
Wed, 22 Sep 2021 19:30:30 +0000 (07:30 +1200)
5.42.0 release notes initial run

CRM/Activity/Task.php
CRM/Contribute/Form/AdditionalInfo.php
CRM/Contribute/Page/Tab.php
CRM/Core/ClassLoader.php
CRM/Utils/Recent.php
ext/greenwich/scss/_greenwich.scss
ext/search_kit/Civi/Api4/Action/SearchDisplay/Run.php
ext/search_kit/ang/crmSearchAdmin/crmSearchAdmin.component.js
tests/phpunit/CRM/Activity/Form/SearchTest.php
tests/phpunit/api/v4/Action/RecentItemsTest.php

index a2305a2c55b5b0a5c09e103177b7c71274522d0d..d1689bdb7fcce53e2caf02b4788a9e3ec0d02b3d 100644 (file)
@@ -157,7 +157,7 @@ class CRM_Activity_Task extends CRM_Core_Task {
       $value = self::TASK_PRINT;
     }
     if (isset(self::$_tasks[$value])) {
-      return [[self::$_tasks[$value]['class']], self::$_tasks[$value]['result']];
+      return [(array) self::$_tasks[$value]['class'], self::$_tasks[$value]['result']];
     }
     return [[], NULL];
   }
index c1ce9bfd7e736b8d7905945cf4a7bd6d8842107a..442bc286c46532dbf4d8b7057020523583374cc8 100644 (file)
@@ -190,10 +190,16 @@ class CRM_Contribute_Form_AdditionalInfo {
     if (!empty($options[$selectedProductID])) {
       $dao->product_option = $options[$selectedProductID][$selectedProductOptionID];
     }
-    if ($premiumID) {
+
+    // This IF condition codeblock does the following:
+    // 1. If premium is present then get previous contribution-product mapping record (if any) based on contribtuion ID.
+    //   If found and the product chosen doesn't matches with old done, then delete or else set the ID for update
+    // 2. If no product is chosen theb delete the previous contribution-product mapping record based on contribtuion ID.
+    if ($premiumID || empty($selectedProductID)) {
       $ContributionProduct = new CRM_Contribute_DAO_ContributionProduct();
-      $ContributionProduct->id = $premiumID;
+      $ContributionProduct->contribution_id = $contributionID;
       $ContributionProduct->find(TRUE);
+      // here $selectedProductID can be 0 in case one unselect the premium product on backoffice update form
       if ($ContributionProduct->product_id == $selectedProductID) {
         $dao->id = $premiumID;
       }
@@ -203,7 +209,11 @@ class CRM_Contribute_Form_AdditionalInfo {
       }
     }
 
-    $dao->save();
+    // only add/update contribution product when a product is selected
+    if (!empty($selectedProductID)) {
+      $dao->save();
+    }
+
     //CRM-11106
     if ($premiumID == NULL || $isDeleted) {
       $premiumParams = [
index 695ebfc6e7c7845ae57098f780400283c96e1e74..ebbf05e714deb567add4fc2c5b20c187b3686b66 100644 (file)
@@ -59,16 +59,6 @@ class CRM_Contribute_Page_Tab extends CRM_Core_Page {
     ];
 
     $templateContribution = CRM_Contribute_BAO_ContributionRecur::getTemplateContribution($recurID);
-    if (!empty($templateContribution['id']) && $paymentProcessorObj->supportsEditRecurringContribution()) {
-      // Use constant CRM_Core_Action::PREVIEW as there is no such thing as view template.
-      // And reusing view will mangle the actions.
-      $links[CRM_Core_Action::PREVIEW] = [
-        'name' => ts('View Template'),
-        'title' => ts('View Template Contribution'),
-        'url' => 'civicrm/contact/view/contribution',
-        'qs' => "reset=1&id={$templateContribution['id']}&cid=%%cid%%&action=view&context={$context}&force_create_template=1",
-      ];
-    }
     if (
       (CRM_Core_Permission::check('edit contributions') || $context !== 'contribution') &&
       ($paymentProcessorObj->supports('ChangeSubscriptionAmount')
@@ -102,6 +92,16 @@ class CRM_Contribute_Page_Tab extends CRM_Core_Page {
         'qs' => "reset=1&crid=%%crid%%&cid=%%cid%%&context={$context}",
       ];
     }
+    if (!empty($templateContribution['id']) && $paymentProcessorObj->supportsEditRecurringContribution()) {
+      // Use constant CRM_Core_Action::PREVIEW as there is no such thing as view template.
+      // And reusing view will mangle the actions.
+      $links[CRM_Core_Action::PREVIEW] = [
+        'name' => ts('View Template'),
+        'title' => ts('View Template Contribution'),
+        'url' => 'civicrm/contact/view/contribution',
+        'qs' => "reset=1&id={$templateContribution['id']}&cid=%%cid%%&action=view&context={$context}&force_create_template=1",
+      ];
+    }
 
     return $links;
   }
index 688470b9d9b70a2f2758acf75f6691b93aa5354e..a8479481d48649dc4d8a9b651e498a3bdd78bd09 100644 (file)
@@ -133,6 +133,8 @@ class CRM_Core_ClassLoader {
       '.',
       $civicrm_base_path,
       $packages_path,
+      // dev/core#2812 Ensure that the database upgrade script can run if dataprocessor extension is enabled. It relies on the legacy custom searches which have been moved into this extension
+      implode(DIRECTORY_SEPARATOR, [$civicrm_base_path, 'ext', 'legacycustomsearches']),
     ];
     $include_paths = implode(PATH_SEPARATOR, $include_paths);
     set_include_path($include_paths . PATH_SEPARATOR . get_include_path());
index 64636385199d5823f834027febf1c17d49d119fe..d4fcf923ec698f0b17e6a53d69bfd552db8e4130 100644 (file)
@@ -152,11 +152,11 @@ class CRM_Utils_Recent {
 
     self::$_recent = array_filter(self::$_recent, function($item) use ($props) {
       foreach ($props as $key => $val) {
-        if (isset($item[$key]) && $item[$key] == $val) {
-          return FALSE;
+        if (isset($item[$key]) && $item[$key] != $val) {
+          return TRUE;
         }
       }
-      return TRUE;
+      return FALSE;
     });
   }
 
index 0bf1a362769e8b07f232a23406115640f5ec25ed..556d64b02e6360c988d4b3b60005144c3057f8d0 100644 (file)
@@ -566,7 +566,7 @@ $popover-arrow-color: $popover-bg;
 //** Popover outer arrow width
 $popover-arrow-outer-width: ($popover-arrow-width + 1);
 //** Popover outer arrow color
-$popover-arrow-outer-color: fadein($popover-border-color, 5%);
+$popover-arrow-outer-color: fade_in($popover-border-color, 0.05);
 //** Popover outer arrow fallback color
 $popover-arrow-outer-fallback-color: darken($popover-fallback-border-color, 20%);
 
index ce4a06d7a0736d9de97a53046a5e5d5136aae522..3ba06edbd3fb770288e116ca47cfd7f2f666f242 100644 (file)
@@ -45,7 +45,7 @@ class Run extends AbstractRunAction {
         break;
 
       default:
-        if (!empty($settings['pager']) && preg_match('/^page:\d+$/', $this->return)) {
+        if (($settings['pager'] ?? FALSE) !== FALSE && preg_match('/^page:\d+$/', $this->return)) {
           $page = explode(':', $this->return)[1];
         }
         $limit = !empty($settings['pager']['expose_limit']) && $this->limit ? $this->limit : NULL;
index c53ffc7e3a509aa467e2faf69e4079a7c5e911b8..822f2556eedb979dc48c16cbb50727d06636073a 100644 (file)
@@ -99,6 +99,7 @@
         } else if (params.id) {
           apiCalls.deleteGroup = ['Group', 'delete', {where: [['saved_search_id', '=', params.id]]}];
         }
+        _.remove(params.displays, {trashed: true});
         if (params.displays && params.displays.length) {
           chain.displays = ['SearchDisplay', 'replace', {where: [['saved_search_id', '=', '$id']], records: params.displays}];
         } else if (params.id) {
index 324ce667d923183cba4481fbc7843e410d4fb17e..e2a4f956b83a9e6844e3022c81893612bc6f1ff4 100644 (file)
@@ -120,4 +120,45 @@ class CRM_Activity_Form_SearchTest extends CiviUnitTestCase {
     ];
   }
 
+  /**
+   * This just checks there's no errors. It doesn't perform any tasks.
+   * It's a little bit like choosing an action from the dropdown.
+   * @dataProvider taskControllerProvider
+   * @param int $task
+   */
+  public function testTaskController(int $task) {
+    // It gets the task from the POST var
+    $oldtask = $_POST['task'] ?? NULL;
+    $_POST['task'] = $task;
+
+    // yes it's the string 'null'
+    new CRM_Activity_Controller_Search('Find Activities', TRUE, 'null');
+
+    // clean up
+    if (is_null($oldtask)) {
+      unset($_POST['task']);
+    }
+    else {
+      $_POST['task'] = $oldtask;
+    }
+  }
+
+  /**
+   * dataprovider for testTaskController
+   * @return array
+   */
+  public function taskControllerProvider(): array {
+    return [
+      [CRM_Activity_Task::TASK_DELETE],
+      [CRM_Activity_Task::TASK_PRINT],
+      [CRM_Activity_Task::TASK_EXPORT],
+      [CRM_Activity_Task::BATCH_UPDATE],
+      [CRM_Activity_Task::TASK_EMAIL],
+      [CRM_Activity_Task::PDF_LETTER],
+      [CRM_Activity_Task::TASK_SMS],
+      [CRM_Activity_Task::TAG_ADD],
+      [CRM_Activity_Task::TAG_REMOVE],
+    ];
+  }
+
 }
index 1ea4a0b2292c5395bed54c74ff97dcdabf190090..4c81a618e13b23b490b331777a733e0a6f8cbbcb 100644 (file)
@@ -30,21 +30,32 @@ class RecentItemsTest extends UnitTestCase {
   public function testAddDeleteActivity(): void {
     $cid = $this->createLoggedInUser();
 
-    $aid = Activity::create(FALSE)
+    $aid1 = Activity::create(FALSE)
       ->addValue('activity_type_id:name', 'Meeting')
       ->addValue('source_contact_id', $cid)
       ->addValue('subject', 'Hello recent!')
       ->execute()->first()['id'];
-
-    $this->assertEquals(1, $this->getRecentItemCount(['type' => 'Activity', 'id' => $aid]));
-
+    $this->assertEquals(1, $this->getRecentItemCount(['type' => 'Activity', 'id' => $aid1]));
     $this->assertStringContainsString('Hello recent!', \CRM_Utils_Recent::get()[0]['title']);
 
-    Activity::delete(FALSE)->addWhere('id', '=', $aid)->execute();
+    $aid2 = Activity::create(FALSE)
+      ->addValue('activity_type_id:name', 'Meeting')
+      ->addValue('source_contact_id', $cid)
+      ->addValue('subject', 'Goodbye recent!')
+      ->execute()->first()['id'];
+    $this->assertEquals(1, $this->getRecentItemCount(['type' => 'Activity', 'id' => $aid2]));
+    $this->assertStringContainsString('Goodbye recent!', \CRM_Utils_Recent::get()[0]['title']);
+
+    Activity::delete(FALSE)->addWhere('id', '=', $aid1)->execute();
 
-    $this->assertEquals(0, $this->getRecentItemCount(['type' => 'Activity', 'id' => $aid]));
+    $this->assertEquals(0, $this->getRecentItemCount(['type' => 'Activity', 'id' => $aid1]));
+    $this->assertEquals(1, $this->getRecentItemCount(['type' => 'Activity', 'id' => $aid2]));
   }
 
+  /**
+   * @param array $props
+   * @return int
+   */
   private function getRecentItemCount($props) {
     $count = 0;
     foreach (\CRM_Utils_Recent::get() as $item) {