Skip to content

Commit

Permalink
Merge branch 'hotfix' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
jimyhuang committed Feb 8, 2025
2 parents 1950017 + 1721746 commit b035775
Show file tree
Hide file tree
Showing 40 changed files with 508 additions and 94 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ jobs:
- name: Frontend - Report Page Checking - Playwright
run: docker exec neticrm-ci bash -c "cd \$DRUPAL_ROOT/sites/all/modules/civicrm/tests/playwright/ && npx playwright test tests/report_check.spec.js"

- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
if: always()
with:
name: playwright-report-test7
Expand Down Expand Up @@ -212,7 +212,7 @@ jobs:
- name: Frontend - Report Page Checking - Playwright
run: docker exec neticrm-ci bash -c "cd \$DRUPAL_ROOT/sites/all/modules/civicrm/tests/playwright/ && npx playwright test tests/report_check.spec.js"

- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
if: always()
with:
name: playwright-report-test8
Expand Down Expand Up @@ -325,7 +325,7 @@ jobs:



- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
if: always()
with:
name: playwright-report-test8-d10
Expand Down
11 changes: 3 additions & 8 deletions CRM/Activity/BAO/Activity.php
Original file line number Diff line number Diff line change
Expand Up @@ -1721,12 +1721,7 @@ public static function sendSMSTemplate(
'display_name' => 1,
);
$getDetails = array($toId);
if (is_numeric($fromId)) {
$fromId = $fromId;
$getDetails[] = $fromId;
$from = NULL;
}
else {
if (!is_numeric($fromId)) {
$fromId = NULL;
}
list($details) = CRM_Mailing_BAO_Mailing::getDetails($getDetails, $returnProperties, FALSE, FALSE, NULL, TRUE);
Expand Down Expand Up @@ -1755,14 +1750,14 @@ public static function sendSMSTemplate(
);
$contactDetails = array($toId => $toDetails);
$contactIds = array($toId);
list($sent) = self::sendSMS(
$result = self::sendSMS(
$contactDetails,
$activityParams,
$smsParams,
$contactIds,
$fromId
);
if ($sent) {
if (!empty($result['sent'])) {
return TRUE;
}
}
Expand Down
91 changes: 79 additions & 12 deletions CRM/Contact/Form/Search/Custom/Group.php
Original file line number Diff line number Diff line change
Expand Up @@ -258,14 +258,47 @@ function from() {
foreach ($this->_excludeGroups as $keys => $values) {
if (in_array($values, $smartGroup)) {
$contactIdField = "contact_a.id";
$ssId = CRM_Utils_Array::key($values, $smartGroup);

$smartSql = CRM_Contact_BAO_SavedSearch::contactIDsSQL($ssId);
if (strstr($smartSql, "contact_a.contact_id")) {
$contactIdField = "contact_a.contact_id";
// $ssId = CRM_Utils_Array::key($values, $smartGroup);
$joinTable = "contact_a";
$groupIds = $values;
$group = new CRM_Contact_DAO_Group();
$group->id = $values;
$group->find(TRUE);
$smartSql = <<<EOT
SELECT contact_a.id
FROM civicrm_contact contact_a
WHERE
EOT;

if (!$this->_smartGroupCache || $group->cache_date == NULL) {
if (!empty($group->cache_date)) {
// refs #31308, do not refresh smart group too often
$config = CRM_Core_Config::singleton();
$minimalCacheTime = CRM_Contact_BAO_GroupContactCache::SMARTGROUP_CACHE_TIMEOUT_MINIMAL;
if (CRM_REQUEST_TIME - $minimalCacheTime > strtotime($group->cache_date)) {
CRM_Contact_BAO_GroupContactCache::load($group);
}
}
else {
CRM_Contact_BAO_GroupContactCache::load($group);
}
}

$smartSql = $smartSql . " AND $contactIdField NOT IN (
if (!empty($groupIds)) {
if ($tableAlias == NULL) {
$alias = '`cgcc`';
}
else {
$alias = $tableAlias;
}
}
$whereSql = <<<EOT
EXISTS (
SELECT 1 FROM civicrm_group_contact_cache {$alias}
WHERE {$alias}.contact_id = {$joinTable}.id AND {$alias}.group_id IN ({$groupIds})
)
EOT;

$smartSql .= $whereSql . " AND $contactIdField NOT IN (
SELECT contact_id FROM civicrm_group_contact
WHERE civicrm_group_contact.group_id = {$values} AND civicrm_group_contact.status = 'Removed')";

Expand Down Expand Up @@ -322,14 +355,48 @@ function from() {
if (in_array($values, $smartGroup)) {

$contactIdField = "contact_a.id";
$ssId = CRM_Utils_Array::key($values, $smartGroup);
$joinTable = "contact_a";
$groupIds = $values;
$group = new CRM_Contact_DAO_Group();
$group->id = $values;
$group->find(TRUE);
$smartSql = <<<EOT
SELECT contact_a.id
FROM civicrm_contact contact_a
WHERE
EOT;

if (!$this->_smartGroupCache || $group->cache_date == NULL) {
if (!empty($group->cache_date)) {
// refs #31308, do not refresh smart group too often
$config = CRM_Core_Config::singleton();
$minimalCacheTime = CRM_Contact_BAO_GroupContactCache::SMARTGROUP_CACHE_TIMEOUT_MINIMAL;
if (CRM_REQUEST_TIME - $minimalCacheTime > strtotime($group->cache_date)) {
CRM_Contact_BAO_GroupContactCache::load($group);
}
}
else {
CRM_Contact_BAO_GroupContactCache::load($group);
}
}

$smartSql = CRM_Contact_BAO_SavedSearch::contactIDsSQL($ssId);
if (strstr($smartSql, "contact_a.contact_id")) {
$contactIdField = "contact_a.contact_id";
if (!empty($groupIds)) {
if ($tableAlias == NULL) {
$alias = '`cgcc`';
}
else {
$alias = $tableAlias;
}
}

$smartSql .= " AND $contactIdField NOT IN (
$whereSql = <<<EOT
EXISTS (
SELECT 1 FROM civicrm_group_contact_cache {$alias}
WHERE {$alias}.contact_id = {$joinTable}.id AND {$alias}.group_id IN ({$groupIds})
)
EOT;

$smartSql .= $whereSql." AND $contactIdField NOT IN (
SELECT contact_id FROM civicrm_group_contact
WHERE civicrm_group_contact.group_id = {$values} AND civicrm_group_contact.status = 'Removed')";

Expand Down
11 changes: 11 additions & 0 deletions CRM/Contact/Form/Search/Custom/PriceSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ class CRM_Contact_Form_Search_Custom_PriceSet extends CRM_Contact_Form_Search_Cu

protected $_eventID = NULL;

protected $_filled = NULL;

protected $_tableName = NULL;

public static $_primaryIDName = 'id';
Expand Down Expand Up @@ -263,6 +265,15 @@ function summary() {
return NULL;
}

function count(){
if(!$this->_filled){
$this->fillTable();
$this->_filled = TRUE;
}
$value = CRM_Core_DAO::singleValueQuery("SELECT count(*) FROM {$this->_tableName}");
return $value;
}

function all($offset = 0, $rowcount = 0, $sort = NULL,
$includeContactIDs = FALSE
) {
Expand Down
13 changes: 13 additions & 0 deletions CRM/Contact/Form/Search/Custom/PriceSetContribution.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@
require_once 'CRM/Contribute/PseudoConstant.php';
class CRM_Contact_Form_Search_Custom_PriceSetContribution extends CRM_Contact_Form_Search_Custom_Base implements CRM_Contact_Form_Search_Interface {

public static $_primaryIDName = 'entity_id';

protected $_filled = NULL;

protected $_price_set_id = NULL;

protected $_tableName = NULL;
Expand Down Expand Up @@ -265,6 +269,15 @@ function summary() {
return NULL;
}

function count(){
if(!$this->_filled){
$this->fillTable();
$this->_filled = TRUE;
}
$value = CRM_Core_DAO::singleValueQuery("SELECT count(*) FROM {$this->_tableName}");
return $value;
}

function all($offset = 0, $rowcount = 0, $sort = NULL, $includeContactIDs = FALSE) {
$selectClause = "
contact_a.id as contact_id ,
Expand Down
6 changes: 3 additions & 3 deletions CRM/Contact/Form/Search/Custom/RecurSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ function tempWhere(){
$clauses[] = "(r.installments IS NULL OR r.installments = 0)";
}

$contributionPage = $this->_formValues['contribution_page'];
$contributionPage = $this->_formValues['contribution_page_id'];
if (!empty($contributionPage)) {
$clauses[] = "c.contribution_page_id IN (".CRM_Utils_Array::implode(",", $contributionPage).")";
}
Expand Down Expand Up @@ -316,13 +316,13 @@ function buildForm(&$form){

$contributionPage = $this->_cpage;
$attrs = array('multiple' => 'multiple');
$form->addElement('select', 'contribution_page', ts('Contribution Page'), $contributionPage, $attrs);
$form->addElement('select', 'contribution_page_id', ts('Contribution Page'), $contributionPage, $attrs);

/**
* If you are using the sample template, this array tells the template fields to render
* for the search form.
*/
$form->assign('elements', array('status', 'installments', 'sort_name', 'email', 'contribution_page'));
$form->assign('elements', array('status', 'installments', 'sort_name', 'email', 'contribution_page_id'));
}

function setDefaultValues() {
Expand Down
2 changes: 1 addition & 1 deletion CRM/Contact/Form/Search/Custom/TaiwanACHSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ function templateFile(){
return 'CRM/Contact/Form/Search/Custom/TaiwanACHSearch.tpl';
}

function tasks() {
public static function tasks() {
return array(
1001 => array(
'title' => ts('Export ACH Stamp Verification File'),
Expand Down
2 changes: 1 addition & 1 deletion CRM/Contact/Form/Task/TaiwanACHExport.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public function buildQuickForm() {
}
}

public function formRule($fields, $files, $self) {
public static function formRule($fields, $files, $self) {
$errors = array();
if (!empty($fields['payment_type'])) {
$paymentType = $fields['payment_type'];
Expand Down
2 changes: 1 addition & 1 deletion CRM/Contact/Form/Task/TaiwanACHExportTransaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function setDefaultValues() {
return $defaults;
}

public function formRule($fields, $files, $self) {
public static function formRule($fields, $files, $self) {
return parent::formRule($fields, $files, $self);
}
public function postProcess() {
Expand Down
2 changes: 1 addition & 1 deletion CRM/Contact/Form/Task/TaiwanACHExportVerification.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ function setDefaultValues() {
return $defaults;
}

public function formRule($fields, $files, $self) {
public static function formRule($fields, $files, $self) {
return parent::formRule($fields, $files, $self);
}

Expand Down
3 changes: 2 additions & 1 deletion CRM/Contribute/BAO/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -358,12 +358,13 @@ static function whereClauseSingle(&$values, &$query) {
return;

case 'contribution_page_id':
case 'contribution_page':
require_once 'CRM/Contribute/PseudoConstant.php';
$cPage = $value;
$pages = CRM_Contribute_PseudoConstant::contributionPage();
if (is_array($cPage)) {
foreach ($cPage as $k => $v) {
if ($v) {
if (is_numeric($v)) {
$val[$v] = $v;
}
}
Expand Down
9 changes: 6 additions & 3 deletions CRM/Contribute/BAO/TaiwanACH.php
Original file line number Diff line number Diff line change
Expand Up @@ -1138,7 +1138,8 @@ static function getRegexpFromFormatString($formatString) {

static function doProcessVerification($recurId, $parsedData, $isPreview = TRUE) {
// Consider type is Bank or Post
$arrayLen = max(array_keys($parsedData))+1;
$keys = array_filter(array_keys($parsedData), 'is_numeric');
$arrayLen = !empty($parsedData) && !empty($keys) ? (intval(max($keys)) + 1) : 0;
if ($arrayLen == 18 ) {
$processType = self::BANK;
}
Expand Down Expand Up @@ -1223,7 +1224,8 @@ static function doProcessVerification($recurId, $parsedData, $isPreview = TRUE)

static function doProcessTransaction($contributionId, $parsedData, $isPreview = TRUE) {
// Consider type is Bank or Post
$arrayLen = max(array_keys($parsedData))+1;
$keys = array_filter(array_keys($parsedData), 'is_numeric');
$arrayLen = !empty($parsedData) && !empty($keys) ? (intval(max($keys)) + 1) : 0;
if ($arrayLen == 20 ) {
$processType = self::POST;
$errorCode = $parsedData[15];
Expand Down Expand Up @@ -1340,6 +1342,7 @@ static function doProcessTransaction($contributionId, $parsedData, $isPreview =
if($pass){
// Solve the contribution.
$result['executed'] = TRUE;
$note = '';
if ($isSuccess) {
// Run completeTrransaction.

Expand Down Expand Up @@ -1371,7 +1374,7 @@ static function doProcessTransaction($contributionId, $parsedData, $isPreview =
$note = $result['cancel_reason'];
}
// Finish or not, add note.
self::addNote($note, $objects['contribution']);
self::addNote($note, '');
}
else {
$result['executed'] = FALSE;
Expand Down
26 changes: 24 additions & 2 deletions CRM/Contribute/Page/ContributionPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,15 @@ function &actionLinks() {
$deleteExtra = ts('Are you sure you want to delete this Contribution page?');
$copyExtra = ts('Are you sure you want to make a copy of this Contribution page?');

$session = CRM_Core_Session::singleton();
$pageKey = $this->_scope;
$qfKey = $session->get('qfKey', $pageKey);

self::$_actionLinks = array(
CRM_Core_Action::COPY => array(
'name' => ts('Make a Copy'),
'url' => CRM_Utils_System::currentPath(),
'qs' => 'action=copy&gid=%%id%%',
'qs' => 'action=copy&gid=%%id%%&key=%%key%%',
'title' => ts('Make a Copy of CiviCRM Contribution Page'),
'extra' => 'onclick = "return confirm(\'' . $copyExtra . '\');"',
),
Expand Down Expand Up @@ -423,6 +427,15 @@ function run() {
* @access public
*/
function copy() {
$key = CRM_Utils_Request::retrieve('key', 'String',
CRM_Core_DAO::$_nullObject, TRUE, NULL, 'REQUEST'
);

$name = get_class($this);
if (!CRM_Core_Key::validate($key, $name)) {
return CRM_Core_Error::statusBounce(ts('Sorry, we cannot process this request for security reasons. The request may have expired or is invalid. Please return to the contribution page list and try again.'));
}

$gid = CRM_Utils_Request::retrieve('gid', 'Positive',
$this, TRUE, 0, 'GET'
);
Expand Down Expand Up @@ -498,6 +511,12 @@ function browse($action = NULL) {

$contributionTypes = CRM_Contribute_PseudoConstant::contributionType(NULl, NULL, TRUE);
$contributionPage = array();

// Add key for action validation.
$name = get_class($this);
$key = CRM_Core_Key::get($name);
$this->assign('key', $key);

while ($dao->fetch()) {
$contributionPage[$dao->id] = array();
CRM_Core_DAO::storeValues($dao, $contributionPage[$dao->id]);
Expand Down Expand Up @@ -536,7 +555,10 @@ function browse($action = NULL) {
//build the normal action links.
$contributionPage[$dao->id]['action'] = CRM_Core_Action::formLink(self::actionLinks(),
$action,
array('id' => $dao->id),
array(
'id' => $dao->id,
'key' => $key
),
ts('more'),
TRUE
);
Expand Down
Loading

0 comments on commit b035775

Please sign in to comment.