Skip to content

Commit

Permalink
Merge branch 'hotfix' into hotfix-37248
Browse files Browse the repository at this point in the history
  • Loading branch information
Chang Shu-Huai committed Nov 8, 2023
2 parents 51388cd + 498590d commit 3d61828
Show file tree
Hide file tree
Showing 27 changed files with 372 additions and 118 deletions.
9 changes: 8 additions & 1 deletion CRM/Admin/Form/Mapping.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@
*
*/
class CRM_Admin_Form_Mapping extends CRM_Admin_Form {
/**
* mapping object
*
* @var obj
*/
public $_mapping;

/**
* Function to build the form
Expand All @@ -52,6 +58,7 @@ public function preProcess() {
$mapping = new CRM_Core_DAO_Mapping();
$mapping->id = $this->_id;
$mapping->find(TRUE);
$this->_mapping = $mapping;
$this->assign('mappingName', $mapping->name);
}

Expand All @@ -75,7 +82,7 @@ public function buildQuickForm() {
require_once 'CRM/Core/PseudoConstant.php';
$mappingType = $this->addElement('select', 'mapping_type_id', ts('Mapping Type'), CRM_Core_PseudoConstant::mappingTypes());

if ($this->_action == CRM_Core_Action::UPDATE) {
if ($this->_action == CRM_Core_Action::UPDATE && !empty($this->_mapping->mapping_type_id)) {
$mappingType->freeze();
}
}
Expand Down
24 changes: 17 additions & 7 deletions CRM/Contact/BAO/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -2823,14 +2823,25 @@ function notes(&$values) {
function age(&$values) {
list($name, $op, $value, $grouping, $wildcard) = $values;

$val = CRM_Utils_Type::escape($value, 'Integer');
if ($val && $name) {
$this->_where[$grouping][999] = "( contact_a.is_deceased = 0 )";
$this->_qill[$grouping][999] = ts('Contact is deceased') . ' ' . ts("IS NULL");
$val = CRM_Utils_Type::escape($value, 'Integer', false);
if (strstr($op, 'NULL') && $name) {
if (strstr($op, 'NOT')) {
$this->_where[$grouping][999] = "( contact_a.is_deceased = 0 OR contact_a.is_deceased IS NULL )";
$this->_qill[$grouping][999] = ts('Contact is deceased') . ' = ' . ts("No");
$this->_where[$grouping][] = " ( YEAR(CURRENT_TIMESTAMP) - YEAR(contact_a.birth_date) - (RIGHT(CURRENT_DATE, 5) < RIGHT(contact_a.birth_date, 5)) $op) ";
}
else {
$this->_where[$grouping][] = " ( NULLIF(contact_a.birth_date, '') IS NULL) ";
}
$this->_qill[$grouping][] = ts('Age') . ' ' .ts($op);
}
elseif (!empty($val) && $name) {
$this->_where[$grouping][999] = "( contact_a.is_deceased = 0 OR contact_a.is_deceased IS NULL )";
$this->_qill[$grouping][999] = ts('Contact is deceased') . ' = ' . ts("No");

if ($name == 'age') {
$this->_where[$grouping][] = " ( YEAR(CURRENT_TIMESTAMP) - YEAR(contact_a.birth_date) - (RIGHT(CURRENT_DATE, 5) < RIGHT(contact_a.birth_date, 5)) = '$val' ) ";
$this->_qill[$grouping][] = ts('Age') . " = $val";
$this->_where[$grouping][] = " ( YEAR(CURRENT_TIMESTAMP) - YEAR(contact_a.birth_date) - (RIGHT(CURRENT_DATE, 5) < RIGHT(contact_a.birth_date, 5)) $op '$val' ) ";
$this->_qill[$grouping][] = ts('Age') . ' '.ts($op). " $val";
}
elseif($name == 'age_low') {
$this->_where[$grouping][] = " ( YEAR(CURRENT_TIMESTAMP) - YEAR(contact_a.birth_date) - (RIGHT(CURRENT_DATE, 5) < RIGHT(contact_a.birth_date, 5)) >= '$val' ) ";
Expand All @@ -2840,7 +2851,6 @@ function age(&$values) {
$this->_where[$grouping][] = " ( YEAR(CURRENT_TIMESTAMP) - YEAR(contact_a.birth_date) - (RIGHT(CURRENT_DATE, 5) < RIGHT(contact_a.birth_date, 5)) <= '$value' ) ";
$this->_qill[$grouping][] = ts('Age') . " <= $val";
}

self::$_openedPanes['Demographics'] = TRUE;
}
}
Expand Down
26 changes: 26 additions & 0 deletions CRM/Contribute/BAO/ContributionPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,32 @@ static function copy($id) {
}
}

//copy custom data
require_once 'CRM/Core/BAO/CustomGroup.php';
$extends = array('contributionPage');
$groupTree = CRM_Core_BAO_CustomGroup::getGroupDetail(NULL, NULL, $extends);
if ($groupTree) {
foreach ($groupTree as $groupID => $group) {
$table[$groupTree[$groupID]['table_name']] = array('entity_id');
foreach ($group['fields'] as $fieldID => $field) {
if ($field['data_type'] == 'File') {
continue;
}
$table[$groupTree[$groupID]['table_name']][] = $groupTree[$groupID]['fields'][$fieldID]['column_name'];
}
}

foreach ($table as $tableName => $tableColumns) {
$insert = 'INSERT INTO ' . $tableName . ' (' . CRM_Utils_Array::implode(', ', $tableColumns) . ') ';
$tableColumns[0] = $copy->id;
$select = 'SELECT ' . CRM_Utils_Array::implode(', ', $tableColumns);
$from = ' FROM ' . $tableName;
$where = " WHERE {$tableName}.entity_id = {$id}";
$query = $insert . $select . $from . $where;
$dao = CRM_Core_DAO::executeQuery($query, CRM_Core_DAO::$_nullArray);
}
}

$copy->save();
$copy->originId = $id;

Expand Down
17 changes: 4 additions & 13 deletions CRM/Contribute/Form/ContributionBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -639,9 +639,11 @@ public function preProcess() {
$this->set('style', 'origin');
}
if($this->_values['is_active'] & CRM_Contribute_BAO_ContributionPage::IS_SPECIAL && $_GET['snippet'] != 4 && $this->get('style') != 'origin'){
$bgFile = basename($this->_values['background_URL']);
$bgFileMobile = basename($this->_values['mobile_background_URL']);
$this->assign('intro_text', $this->_values['intro_text']);
$this->assign('backgroundImageUrl', $this->_values['background_URL']);
$this->assign('mobileBackgroundImageUrl', $this->_values['mobile_background_URL']);
$this->assign('backgroundImageUrl', str_replace($bgFile, urlencode($bgFile), $this->_values['background_URL']));
$this->assign('mobileBackgroundImageUrl', str_replace($bgFileMobil, urlencode($bgFileMobile), $this->_values['mobile_background_URL']));
$this->assign('special_style', 1);
$this->assign('min_amount', (float) $this->_values['min_amount']);
$this->assign('max_amount', (float) $this->_values['max_amount']);
Expand All @@ -653,17 +655,6 @@ public function preProcess() {
),
);
CRM_Utils_System::addHTMLHead($object);

/** civicrm_instrument is not the table included by civicrm, and afraid of it ban the contributor.
$query_params = array(
1 => array($this->_id, 'Integer'),
);
$payment_instruments = CRM_Core_DAO::singleValueQuery("SELECT payment_instruments FROM civicrm_instrument WHERE entity_id = %1 AND entity_table = 'civicrm_contribution_page'", $query_params);
$active_instruments = unserialize($payment_instruments);
if(count($active_instruments) == 1 && isset($active_instruments['credit_card'])){
$this->assign('credit_card_only', 1);
}
*/
}


Expand Down
47 changes: 32 additions & 15 deletions CRM/Contribute/Form/PCP/PCPAccount.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,23 +56,51 @@ class CRM_Contribute_Form_PCP_PCPAccount extends CRM_Core_Form {
*/
public $_single;

public $_contactID;

private $_context;

public function preProcess() {
$session = CRM_Core_Session::singleton();
$this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE);
$this->_pageId = CRM_Utils_Request::retrieve('pageId', 'Positive', $this);
$this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
$this->_contactID = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
$this->_contactID = CRM_Utils_Request::retrieve('cid', 'Integer', $this);
$this->_context = CRM_Utils_Request::retrieve('context', 'String', $this);
$isManager = CRM_Core_Permission::check('access CiviContribute');
$userID = CRM_Core_Session::singleton()->get('userID');
if ($this->_context) {
$this->controller->set('context', $this->_context);
}

// update exists pcp contact info
if ($this->_id) {
$this->_contactID = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_PCP', $this->_id, 'contact_id');
$pcpContactID = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_PCP', $this->_id, 'contact_id');
if ($isManager || $userID == $pcpContactID) {
$this->_contactID = $pcpContactID;
if (!empty($userID)) {
$this->assign('readonly_profile', 1);
}
}
else {
CRM_Utils_System::permissionDenied();
}
}
// add new pcp contact
else {
$userID = CRM_Core_Session::singleton()->get('userID');
$this->assign('is_manager', $isManager);
$this->assign('page_id', $this->_pageId);
if (!empty($userID)) {
$this->_contactID = $userID;
if ($this->_contactID === '0' && $isManager) {
$this->assign('create_pcp_for_others', TRUE);
}
else {
$this->assign('readonly_profile', 1);
$this->_contactID = $userID;
}
}
else {
$this->_contactID = '0';
}
}
$this->set('contactID', $this->_contactID);
Expand All @@ -86,17 +114,6 @@ public function preProcess() {
$this->_pageId = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_PCP', $this->_id, 'contribution_page_id');
}
}
$config = CRM_Core_Config::singleton();
//redirect back to online Contribution page, we allow only logged in
//user to configure the PCP account and Page in standalone installation.
if ($config->userFramework == 'Standalone' && !$this->_contactID) {
return CRM_Core_Error::statusBounce(ts("You must login with your OpenID provider before you can create a Personal Campaign Page."),
CRM_Utils_System::url('civicrm/contribute/transact',
"reset=1&id={$this->_pageId}",
FALSE, NULL, FALSE, TRUE
)
);
}
$this->_single = $this->get('single');

if (!$this->_single) {
Expand Down
11 changes: 10 additions & 1 deletion CRM/Contribute/Import/Form/MapField.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,19 @@ class CRM_Contribute_Import_Form_MapField extends CRM_Core_Form {
* @access public
*/
public function defaultFromHeader($columnName, &$patterns) {
// Validate the column name to ensure it contains only alphanumeric characters
if (!preg_match('/^[0-9a-z]$/i', $columnName)) {
// Escape any special characters and remove parenthesis content
$columnMatch = trim(preg_replace('/([\.\?\+\*\(\)\[\]\{\}\/])/', '\\\\$1', preg_replace('/\(.*\)/', '', $columnName)));

// refs #38980, workaround for first name trailing space
$mapperFields = $this->_mapperFields;
if (isset($mapperFields['first_name'])) {
$mapperFields['first_name'] = trim($mapperFields['first_name']);
}

// Find matching columns in the mapper fields array
$matches = preg_grep('/(^'.$columnMatch.'$)|(^\w+\::'.$columnMatch.'$)/iu', $this->_mapperFields);
$matches = preg_grep('/(^'.$columnMatch.'$)|(^\w+\::'.$columnMatch.'$)/iu', $mapperFields);

// If there is exactly one match, mark the column as used and return its key
if (is_array($matches) && count($matches) == 1) {
Expand Down
6 changes: 4 additions & 2 deletions CRM/Contribute/Page/PCPInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,15 +173,17 @@ function run() {
if ($file_id = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_EntityFile', $this->_id, 'file_id', 'entity_id')) {
list($src) = CRM_Core_BAO_File::url($file_id, $this->_id, 'civicrm_pcp');
if ($src) {
$bgFile = basename($src);
$encodedSrc = str_replace($bgFile, urlencode($bgFile), $src);
$meta = array(
'tag' => 'meta',
'attributes' => array(
'property' => 'og:image',
'content' => $src,
'content' => $encodedSrc,
),
);
CRM_Utils_System::addHTMLHead($meta);
$this->assign('pcpImageSrc', $src);
$this->assign('pcpImageSrc', $encodedSrc);
}
}

Expand Down
2 changes: 1 addition & 1 deletion CRM/Contribute/Selector/Search.php
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ public function &getColumnHeaders($action = NULL, $output = NULL) {
'sort' => 'total_amount',
'direction' => CRM_Utils_Sort::DONTCARE,
),
array('name' => ts('Type'),
array('name' => ts('Contribution Type'),
'sort' => 'contribution_type_id',
'direction' => CRM_Utils_Sort::DONTCARE,
),
Expand Down
5 changes: 4 additions & 1 deletion CRM/Core/BAO/Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,10 @@ static function setItem(&$data, $group, $path, $componentID = NULL, $expired = N
// get a lock so that multiple ajax requests on the same page
// dont trample on each other
// CRM-11234
$lockName = "civicrm.cache.{$group}_{$path}._{$componentID}";
$lockName = "ch.{$group}_{$path}_{$componentID}";
if (strlen($lockName) > 64) {
$lockName = substr($lockName, 0, 64);
}
$lock = new CRM_Core_Lock($lockName);
if (!$lock->isAcquired()) {
CRM_Core_Error::fatal("Trying acquire lock failed: $lockName");
Expand Down
2 changes: 1 addition & 1 deletion CRM/Core/BAO/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ public static function deleteEntityFile($entityTable, $entityID) {
}
}

public function getEntity($fileID) {
public static function getEntity($fileID) {
$entityFileDAO = new CRM_Core_DAO_EntityFile();
$entityFileDAO->file_id = $fileID;

Expand Down
2 changes: 1 addition & 1 deletion CRM/Core/Config/Variables.php
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ class CRM_Core_Config_Variables extends CRM_Core_Config_Defaults {
/**
* The default value for Content Security Policy recover.
*/
public $defaultCSP = "default-src 'self'; img-src 'self' data: https:; script-src 'self' 'unsafe-inline' 'unsafe-eval' https://analytics.neticrm.tw https://*.googletagmanager.com https://*.google-analytics.com https://www.google.com/recaptcha/api.js https://*.facebook.net https://*.facebook.com https://*.twitter.com https://*.tappaysdk.com; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com https://fonts.gstatic.com; font-src 'self' https://fonts.googleapis.com https://fonts.gstatic.com; frame-src 'self' https://neticrm.tw https://*.facebook.net https://*.facebook.com https://*.twitter.com https://*.youtube.com https://*.vimeo.com https://*.tappaysdk.com; object-src 'none'";
public $defaultCSP = "default-src 'self'; img-src 'self' data: https:; script-src 'self' 'unsafe-inline' 'unsafe-eval' https://analytics.neticrm.tw https://*.googletagmanager.com https://*.google-analytics.com https://www.google.com/recaptcha/api.js https://*.facebook.net https://*.facebook.com https://*.twitter.com https://*.tappaysdk.com; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com https://fonts.gstatic.com; font-src 'self' https://fonts.googleapis.com https://fonts.gstatic.com; frame-src 'self' https://neticrm.tw https://*.facebook.net https://*.facebook.com https://*.twitter.com https://*.youtube.com https://*.vimeo.com https://*.tappaysdk.com; object-src 'none'; connect-src 'self' https://neti.cc";

/**
* The default value for Content Security Policy setting.
Expand Down
1 change: 1 addition & 0 deletions CRM/Core/Payment/TapPay.php
Original file line number Diff line number Diff line change
Expand Up @@ -733,6 +733,7 @@ public static function doExecuteAllRecur($time = NULL) {
$cycleDayFilter AND
(SELECT MAX(created_date) FROM civicrm_contribution WHERE contribution_recur_id = r.id GROUP BY r.id) < '$currentDate'
AND r.contribution_status_id = 5
AND r.frequency_unit = 'month'
AND p.payment_processor_type = 'TapPay'
GROUP BY r.id
ORDER BY r.id
Expand Down
12 changes: 7 additions & 5 deletions CRM/Export/Form/Map.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public function buildQuickForm() {
static function formRule($fields, $values, $mappingTypeId) {
$errors = array();

if (CRM_Utils_Array::value('saveMapping', $fields) && $fields['_qf_Map_next']) {
if (CRM_Utils_Array::value('saveMapping', $fields)) {
$nameField = CRM_Utils_Array::value('saveMappingName', $fields);
if (empty($nameField)) {
$errors['saveMappingName'] = ts('Name is required to save Export Mapping');
Expand Down Expand Up @@ -219,12 +219,14 @@ public function postProcess() {
}

if ($buttonName1 == '_qf_Map_next') {
if ($this->get('mappingId') && !empty($params['saveMappingName'])) {
if (!empty($params['saveMapping']) && !empty($params['saveMappingName'])) {
$params['updateMapping'] = 0;
$this->updateAndSaveMapping($params);
}
elseif (!empty($params['updateMapping']) && !empty($this->get('mappingId'))) {
$params['mappingId'] = $this->get('mappingId');
$params['updateMapping'] = 1;
unset($params['saveMapping']);
$this->updateAndSaveMapping($params);
}
$this->updateAndSaveMapping($params);
}

//get the csv file
Expand Down
Loading

0 comments on commit 3d61828

Please sign in to comment.