Skip to content

Commit

Permalink
Further updates to 5.66rc
Browse files Browse the repository at this point in the history
This includes updates I've worked on to allow us to store Bounced emails
as actitivies (we will also need to add is_create_activities to our
fetch_bounces job & create an activity type of Bounce - we can do the
former manually while testing & update our job when all good)

civicrm/civicrm-core#27356

In addition
I reverted the 5.66 change to zeta components in 5.66 since
it caused the problem Elliott plugged - this isn't the final
word but it means we will be running stock
civicrm/civicrm-core#27394

Note the commented out upgrade bits can go now we've done the upgrade
and there are some other minor patches

Bug: T346088
Bug: T345929

Change-Id: I6a27223850b361eacdd76a457963db47b0e9f1f5
  • Loading branch information
eileenmcnaughton committed Sep 12, 2023
1 parent 089e564 commit 39a2d37
Show file tree
Hide file tree
Showing 28 changed files with 352 additions and 216 deletions.
117 changes: 59 additions & 58 deletions drupal/sites/all/modules/civicrm/CRM/ACL/BAO/ACL.php
Original file line number Diff line number Diff line change
Expand Up @@ -222,31 +222,13 @@ public static function check($str, $contactID) {
* @return null|string
*/
public static function whereClause($type, &$tables, &$whereTables, $contactID = NULL) {
$acls = CRM_ACL_BAO_Cache::build($contactID);

$whereClause = NULL;
$allInclude = $allExclude = FALSE;
$clauses = [];

if (!empty($acls)) {
$aclKeys = array_keys($acls);
$aclKeys = implode(',', $aclKeys);
$orderBy = 'a.object_id';
if (array_key_exists('priority', CRM_ACL_BAO_ACL::getSupportedFields())) {
$orderBy .= ',a.priority';
}
$query = "
SELECT a.operation, a.object_id,a.deny
FROM civicrm_acl_cache c, civicrm_acl a
WHERE c.acl_id = a.id
AND a.is_active = 1
AND a.object_table = 'civicrm_group'
AND a.id IN ( $aclKeys )
ORDER BY {$orderBy}
";

$dao = CRM_Core_DAO::executeQuery($query);

$dao = self::getOrderedActiveACLs($contactID, 'civicrm_group');
if ($dao !== NULL) {
// do an or of all the where clauses u see
$ids = $excludeIds = [];
while ($dao->fetch()) {
Expand Down Expand Up @@ -451,54 +433,73 @@ public static function self_hook_civicrm_pre(\Civi\Core\Event\PreEvent $event) {
*/
protected static function loadPermittedIDs(int $contactID, string $tableName, int $type, $allGroups): array {
$ids = [];
$acls = CRM_ACL_BAO_Cache::build($contactID);
$aclKeys = array_keys($acls);
$aclKeys = implode(',', $aclKeys);
$orderBy = 'a.object_id';
if (array_key_exists('priority', CRM_ACL_BAO_ACL::getSupportedFields())) {
$orderBy .= ',a.priority';
}
$query = "
SELECT a.operation,a.object_id,a.deny
FROM civicrm_acl_cache c, civicrm_acl a
WHERE c.acl_id = a.id
AND a.is_active = 1
AND a.object_table = %1
AND a.id IN ( $aclKeys )
ORDER BY {$orderBy}
";
$params = [1 => [$tableName, 'String']];
$dao = CRM_Core_DAO::executeQuery($query, $params);
while ($dao->fetch()) {
if ($dao->object_id) {
if (self::matchType($type, $dao->operation)) {
if (!$dao->deny) {
$ids[] = $dao->object_id;
}
else {
$ids = array_diff($ids, [$dao->object_id]);
$dao = self::getOrderedActiveACLs($contactID, $tableName);
if ($dao !== NULL) {
while ($dao->fetch()) {
if ($dao->object_id) {
if (self::matchType($type, $dao->operation)) {
if (!$dao->deny) {
$ids[] = $dao->object_id;
}
else {
$ids = array_diff($ids, [$dao->object_id]);
}
}
}
}
else {
// this user has got the permission for all objects of this type
// check if the type matches
if (self::matchType($type, $dao->operation)) {
if (!$dao->deny) {
foreach ($allGroups as $id => $dontCare) {
$ids[] = $id;
else {
// this user has got the permission for all objects of this type
// check if the type matches
if (self::matchType($type, $dao->operation)) {
if (!$dao->deny) {
foreach ($allGroups as $id => $dontCare) {
$ids[] = $id;
}
}
else {
$ids = array_diff($ids, array_keys($allGroups));
}
}
else {
$ids = array_diff($ids, array_keys($allGroups));
}
}
break;
}
}
return $ids;
}

/**
* Execute a query to find active ACLs for a contact, ordered by priority (if supported) and object ID.
* The query returns the 'operation', 'object_id' and 'deny' properties.
* Returns NULL if CRM_ACL_BAO_Cache::build (effectively, CRM_ACL_BAO_ACL::getAllByContact)
* returns no ACLs (active or not) for the contact.
*
* @param string $contactID
* @param string $tableName
* @return NULL|CRM_Core_DAO|object
*/
private static function getOrderedActiveACLs(string $contactID, string $tableName) {
$dao = NULL;
$acls = CRM_ACL_BAO_Cache::build($contactID);
if (!empty($acls)) {
$aclKeys = array_keys($acls);
$aclKeys = implode(',', $aclKeys);
$orderBy = 'a.object_id';
if (array_key_exists('priority', CRM_ACL_BAO_ACL::getSupportedFields())) {
$orderBy = "a.priority, $orderBy";
}
$query = "
SELECT a.operation, a.object_id, a.deny
FROM civicrm_acl_cache c, civicrm_acl a
WHERE c.acl_id = a.id
AND a.is_active = 1
AND a.object_table = %1
AND a.id IN ({$aclKeys})
ORDER BY {$orderBy}
";
$params = [1 => [$tableName, 'String']];
$dao = CRM_Core_DAO::executeQuery($query, $params);
}
return $dao;
}

private static function getGroupClause(array $groupIDs, string $operation): string {
$ids = implode(',', $groupIDs);
$query = "
Expand Down
7 changes: 6 additions & 1 deletion drupal/sites/all/modules/civicrm/CRM/Admin/Page/Options.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,33 +157,38 @@ public function &links() {
'url' => 'civicrm/admin/options/' . self::$_gName,
'qs' => 'action=update&id=%%id%%&reset=1',
'title' => ts('Edit %1', [1 => self::$_gName]),
'weight' => CRM_Core_Action::getWeight(CRM_Core_Action::UPDATE),
],
CRM_Core_Action::DISABLE => [
'name' => ts('Disable'),
'ref' => 'crm-enable-disable',
'title' => ts('Disable %1', [1 => self::$_gName]),
'weight' => CRM_Core_Action::getWeight(CRM_Core_Action::DISABLE),
],
CRM_Core_Action::ENABLE => [
'name' => ts('Enable'),
'ref' => 'crm-enable-disable',
'title' => ts('Enable %1', [1 => self::$_gName]),
'weight' => CRM_Core_Action::getWeight(CRM_Core_Action::ENABLE),
],
CRM_Core_Action::DELETE => [
'name' => ts('Delete'),
'url' => 'civicrm/admin/options/' . self::$_gName,
'qs' => 'action=delete&id=%%id%%',
'title' => ts('Delete %1 Type', [1 => self::$_gName]),
'weight' => CRM_Core_Action::getWeight(CRM_Core_Action::DELETE),
],
];

if (self::$_gName == 'custom_search') {
if (self::$_gName === 'custom_search') {
$runLink = [
CRM_Core_Action::FOLLOWUP => [
'name' => ts('Run'),
'url' => 'civicrm/contact/search/custom',
'qs' => 'reset=1&csid=%%value%%',
'title' => ts('Run %1', [1 => self::$_gName]),
'class' => 'no-popup',
'weight' => 10,
],
];
self::$_links = $runLink + self::$_links;
Expand Down
20 changes: 14 additions & 6 deletions drupal/sites/all/modules/civicrm/CRM/Event/Form/Participant.php
Original file line number Diff line number Diff line change
Expand Up @@ -1364,7 +1364,7 @@ public function submit($params) {
}

if (!empty($params['send_receipt'])) {
$result = $this->sendReceipts($params, $contributionParams['total_amount'], $customFields, $participants, $lineItem[0] ?? [], $additionalParticipantDetails);
$result = $this->sendReceipts($params, $customFields, $participants, $lineItem[0] ?? [], $additionalParticipantDetails ?? []);
}

// set the participant id if it is not set
Expand Down Expand Up @@ -2129,7 +2129,6 @@ protected function assignUrlPath() {

/**
* @param $params
* @param $total_amount
* @param array $customFields
* @param array $participants
* @param $lineItem
Expand All @@ -2138,7 +2137,7 @@ protected function assignUrlPath() {
* @return array
* @throws \CRM_Core_Exception
*/
protected function sendReceipts($params, $total_amount, array $customFields, array $participants, $lineItem, $additionalParticipantDetails): array {
protected function sendReceipts($params, array $customFields, array $participants, $lineItem, $additionalParticipantDetails): array {
$sent = [];
$notSent = [];
$this->assign('module', 'Event Registration');
Expand All @@ -2159,10 +2158,9 @@ protected function sendReceipts($params, $total_amount, array $customFields, arr
);
}
}

$this->assign('totalAmount', $params['total_amount'] ?? $total_amount);
$this->assign('checkNumber', CRM_Utils_Array::value('check_number', $params));
}

$this->assign('checkNumber', $params['check_number'] ?? NULL);
if ($this->_mode) {
$this->assignBillingName($params);
$this->assign('address', CRM_Utils_Address::getFormattedBillingAddressFieldsFromParameters(
Expand Down Expand Up @@ -2210,6 +2208,16 @@ protected function sendReceipts($params, $total_amount, array $customFields, arr
$contributionID = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment',
$participants[$num]->id, 'contribution_id', 'participant_id'
);
$totalAmount = 0;
if ($contributionID) {
// @todo - this should be temporary - we are looking to remove this variable from the template
// in favour of the {contribution.total_amount} token.
// In case this needs back-porting I have kept it as simple as possible.
$totalAmount = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_Contribution',
$contributionID, 'id', 'total_amount'
);
}
$this->assign('totalAmount', $params['total_amount'] ?? $totalAmount);
$this->_id = $participants[$num]->id;

if ($this->_isPaidEvent) {
Expand Down
2 changes: 1 addition & 1 deletion drupal/sites/all/modules/civicrm/CRM/Event/Tokens.php
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,6 @@ protected function getEventTokenValues(int $eventID = NULL): array {
'event_type_id:name',
'pay_later_text',
'pay_later_receipt',
'fee_label',
'custom.*',
], $this->getExposedFields()))
->execute()->first();
Expand Down Expand Up @@ -273,6 +272,7 @@ protected function getExposedFields(): array {
'is_public',
'confirm_email_text',
'is_monetary',
'fee_label',
];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public static function updateLogging($ctx): bool {
$dsn = DB::parseDSN($dsn);
$table = '`' . $dsn['database'] . '`.`log_civicrm_uf_group`';
CRM_Core_DAO::executeQuery("ALTER TABLE $table CHANGE `post_URL` `post_url` varchar(255) DEFAULT NULL COMMENT 'Redirect to URL on submit.',
CHANGE `cancel_URL` `cancel_url` varchar(255) DEFAULT NULL COMMENT 'Redirect to URL when Cancel button clicked.'");
CHANGE `cancel_URL` `cancel_url` varchar(255) DEFAULT NULL COMMENT 'Redirect to URL when Cancel button clicked.'", [], TRUE, NULL, FALSE, FALSE);
}
return TRUE;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ public function setPreUpgradeMessage(&$preUpgradeMessage, $rev, $currentVer = NU
*/
public function upgrade_5_66_alpha1($rev): void {
$this->addTask(ts('Upgrade DB to %1: SQL', [1 => $rev]), 'runSql', $rev);
// $this->addTask('Make Contribution.tax_amount required', 'alterColumn', 'civicrm_contribution', 'tax_amount', "decimal(20,2) DEFAULT 0 COMMENT 'Total tax amount of this contribution.'");
// $this->addTask('Make Contribution.tax_amount required', 'alterColumn', 'civicrm_line_item', 'tax_amount', "decimal(20,2) DEFAULT 0 COMMENT 'tax of each item'");
$this->addTask('Make Contribution.tax_amount required', 'alterColumn', 'civicrm_contribution', 'tax_amount', "decimal(20,2) DEFAULT 0 NOT NULL COMMENT 'Total tax amount of this contribution.'");
$this->addTask('Make Contribution.tax_amount required', 'alterColumn', 'civicrm_line_item', 'tax_amount', "decimal(20,2) DEFAULT 0 NOT NULL COMMENT 'tax of each item'");
// These run after the sql file
$this->addTask('Make Discount.entity_table required', 'alterColumn', 'civicrm_discount', 'entity_table', "varchar(64) NOT NULL COMMENT 'Name of the action(reminder)'");
$this->addTask('Make ActionSchedule.name required', 'alterColumn', 'civicrm_action_schedule', 'name', "varchar(64) NOT NULL COMMENT 'physical tablename for entity being joined to discount, e.g. civicrm_event'");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,19 @@ UPDATE civicrm_contribution_page SET `name` = `id`;
-- Add name field, make frontend_title required (in conjunction with php function)
{if $multilingual}
{foreach from=$locales item=locale}
UPDATE `civicrm_contribution_page`
SET `title_{$locale}` = ''
WHERE `title_{$locale}` IS NULL;

UPDATE `civicrm_contribution_page`
SET `frontend_title_{$locale}` = `title_{$locale}`
WHERE `frontend_title_{$locale}` IS NULL OR `frontend_title_{$locale}` = '';
{/foreach}
{else}
UPDATE `civicrm_contribution_page`
SET `title` = ''
WHERE `title` IS NULL;

UPDATE `civicrm_contribution_page`
SET `frontend_title` = `title`
WHERE `frontend_title` IS NULL OR `frontend_title` = '';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ WHERE a2.name = a1.name AND a2.id > a1.id;

{* Set default value for Discount.entity_table *}
UPDATE `civicrm_discount` SET `entity_table` = 'civicrm_event' WHERE `entity_table` IS NULL;

UPDATE civicrm_contribution SET tax_amount = 0 WHERE tax_amount IS NULL;
UPDATE civicrm_line_item SET tax_amount = 0 WHERE tax_amount IS NULL;
Loading

0 comments on commit 39a2d37

Please sign in to comment.