Skip to content

Commit

Permalink
Merge branch 'master' into Issue#521-send-owner-notification-after-su…
Browse files Browse the repository at this point in the history
…ccessful-payment
  • Loading branch information
nishant-bhorodia authored Dec 28, 2020
2 parents d185010 + e4e20a1 commit 923d84b
Show file tree
Hide file tree
Showing 104 changed files with 2,951 additions and 1,529 deletions.
66 changes: 64 additions & 2 deletions CRM/Activity/Import/Parser/Activity.php
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,7 @@ public function import($onDuplicate, &$values) {
}
}
// Date-Format part ends.
require_once 'CRM/Utils/DeprecatedUtils.php';
$formatError = _civicrm_api3_deprecated_activity_formatted_param($params, $params, TRUE);
$formatError = $this->deprecated_activity_formatted_param($params, $params, TRUE);

if ($formatError) {
array_unshift($values, $formatError['error_message']);
Expand Down Expand Up @@ -374,4 +373,67 @@ public function import($onDuplicate, &$values) {
return CRM_Import_Parser::VALID;
}

/**
* take the input parameter list as specified in the data model and
* convert it into the same format that we use in QF and BAO object
*
* @param array $params
* Associative array of property name/value.
* pairs to insert in new contact.
* @param array $values
* The reformatted properties that we can use internally.
*
* @param array|bool $create Is the formatted Values array going to
* be used for CRM_Activity_BAO_Activity::create()
*
* @return array|CRM_Error
*/
protected function deprecated_activity_formatted_param(&$params, &$values, $create = FALSE) {
// copy all the activity fields as is
$fields = CRM_Activity_DAO_Activity::fields();
_civicrm_api3_store_values($fields, $params, $values);

require_once 'CRM/Core/OptionGroup.php';
$customFields = CRM_Core_BAO_CustomField::getFields('Activity');

foreach ($params as $key => $value) {
// ignore empty values or empty arrays etc
if (CRM_Utils_System::isNull($value)) {
continue;
}

//Handling Custom Data
if ($customFieldID = CRM_Core_BAO_CustomField::getKeyID($key)) {
$values[$key] = $value;
$type = $customFields[$customFieldID]['html_type'];
if (CRM_Core_BAO_CustomField::isSerialized($customFields[$customFieldID])) {
$values[$key] = CRM_Import_Parser::unserializeCustomValue($customFieldID, $value, $type);
}
elseif ($type == 'Select' || $type == 'Radio') {
$customOption = CRM_Core_BAO_CustomOption::getCustomOption($customFieldID, TRUE);
foreach ($customOption as $customFldID => $customValue) {
$val = $customValue['value'] ?? NULL;
$label = $customValue['label'] ?? NULL;
$label = strtolower($label);
$value = strtolower(trim($value));
if (($value == $label) || ($value == strtolower($val))) {
$values[$key] = $val;
}
}
}
}

if ($key == 'target_contact_id') {
if (!CRM_Utils_Rule::integer($value)) {
return civicrm_api3_create_error("contact_id not valid: $value");
}
$contactID = CRM_Core_DAO::singleValueQuery("SELECT id FROM civicrm_contact WHERE id = $value");
if (!$contactID) {
return civicrm_api3_create_error("Invalid Contact ID: There is no contact record with contact_id = $value.");
}
}
}
return NULL;
}

}
7 changes: 3 additions & 4 deletions CRM/Campaign/Form/Survey/Results.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,11 @@ public function buildQuickForm() {
}

// form fields of Custom Option rows
$defaultOption = [];
$defaultOptionValues = [];
$_showHide = new CRM_Core_ShowHideBlocks('', '');

$optionAttributes = CRM_Core_DAO::getAttribute('CRM_Core_DAO_OptionValue');
$optionAttributes['label']['size'] = $optionAttributes['value']['size'] = 25;

for ($i = 1; $i <= self::NUM_OPTION; $i++) {
//the show hide blocks
$showBlocks = 'optionField_' . $i;
Expand Down Expand Up @@ -161,11 +160,11 @@ public function buildQuickForm() {
CRM_Core_DAO::getAttribute('CRM_Campaign_DAO_Survey', 'release_frequency')
);

$defaultOption[$i] = $this->createElement('radio', NULL, NULL, NULL, $i);
$defaultOptionValues[$i] = NULL;
}

//default option selection
$this->addGroup($defaultOption, 'default_option');
$this->addRadio('default_option', '', $defaultOptionValues);

$_showHide->addToTemplate();

Expand Down
4 changes: 3 additions & 1 deletion CRM/Contact/Form/Search/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ public function preProcess() {
// Initialize new form
if (!$this->_blockCount) {
$this->_blockCount = 4;
$this->set('newBlock', 1);
if (!$this->_ssID) {
$this->set('newBlock', 1);
}
}

//get the column count
Expand Down
Loading

0 comments on commit 923d84b

Please sign in to comment.