$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];
}
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;
}
}
}
- $dao->save();
+ // only add/update contribution product when a product is selected
+ if (!empty($selectedProductID)) {
+ $dao->save();
+ }
+
//CRM-11106
if ($premiumID == NULL || $isDeleted) {
$premiumParams = [
];
$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')
'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;
}
'.',
$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());
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;
});
}
//** 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%);
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;
} 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) {
];
}
+ /**
+ * 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],
+ ];
+ }
+
}
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) {