//Assigning Activity type name
if ($this->_activityTypeId) {
- $activityTName = CRM_Core_OptionGroup::values('activity_type', FALSE, FALSE, FALSE, 'AND v.value = ' . $this->_activityTypeId, 'name');
+ $activityTName = CRM_Core_OptionGroup::values('activity_type', FALSE, FALSE, FALSE, 'AND v.value = ' . $this->_activityTypeId, 'label');
if ($activityTName[$this->_activityTypeId]) {
$this->_activityTypeName = $activityTName[$this->_activityTypeId];
$this->assign('activityTName', $activityTName[$this->_activityTypeId]);
* Ajax callback to display code docs
*/
public static function getDoc() {
- if (!empty($_GET['entity']) && strpos($_GET['entity'], '.') === FALSE) {
- $entity = _civicrm_api_get_camel_name($_GET['entity']);
+ // Verify the API handler we're talking to is valid.
+ $entities = civicrm_api3('Entity', 'get');
+ $entity = CRM_Utils_Array::value('entity', $_GET);
+ if (!empty($entity) && in_array($entity, $entities['values']) && strpos($entity, '.') === FALSE) {
$action = CRM_Utils_Array::value('action', $_GET);
$doc = self::getDocblock($entity, $action);
$result = array(
$paymentParams['contributionRecurID'] = $contribution->contribution_recur_id;
}
- if ($form->_contributeMode) {
+ if ($form->_contributeMode && $form->_amount > 0.0) {
try {
$payment = Civi\Payment\System::singleton()->getByProcessor($form->_paymentProcessor);
if ($form->_contributeMode == 'notify') {
switch ($html_type) {
case 'Radio':
if ($data_type == 'Boolean') {
- // Do not assume that if not yes means no.
- $display = '';
- if ($value) {
- $display = ts('Yes');
- }
- elseif ((string) $value === '0') {
- $display = ts('No');
- }
+ $option = array('No', 'Yes');
}
- elseif (is_array($value)) {
+ if (is_array($value)) {
$display = NULL;
foreach ($value as $data) {
$display .= $display ? ', ' . $option[$data] : $option[$data];
+
}
}
else {
$isSerialized = CRM_Core_BAO_CustomField::isSerialized($field);
- // Handle multi-select search for any data type
- if (is_array($value) && !$field['is_search_range'] && $field['data_type'] != 'String') {
- $wildcard = $isSerialized ? $wildcard : TRUE;
- $options = CRM_Utils_Array::value('values', civicrm_api3('contact', 'getoptions', array(
- 'field' => $name,
- 'context' => 'search',
- ), array()));
- $qillValue = '';
- $sqlOP = $wildcard ? ' OR ' : ' AND ';
- $sqlValue = array();
- foreach ($value as $num => &$v) {
- $sep = count($value) > (1 + $num) ? ', ' : (' ' . ($wildcard ? ts('OR') : ts('AND')) . ' ');
- $qillValue .= ($num ? $sep : '') . $options[$v];
- $v = CRM_Core_DAO::escapeString($v);
- if ($isSerialized) {
- $sqlValue[] = "( $fieldName like '%" . CRM_Core_DAO::VALUE_SEPARATOR . $v . CRM_Core_DAO::VALUE_SEPARATOR . "%' ) ";
- }
- else {
- $v = "'$v'";
- }
- }
- if (!$isSerialized) {
- $sqlValue = array("$fieldName IN (" . implode(',', $value) . ")");
- }
- $this->_where[$grouping][] = ' ( ' . implode($sqlOP, $sqlValue) . ' ) ';
- $this->_qill[$grouping][] = "$field[label] $qillOp $qillValue";
- continue;
- }
-
// fix $value here to escape sql injection attacks
$qillValue = NULL;
if (!is_array($value)) {
$qillValue = CRM_Core_BAO_CustomField::getDisplayValue($value[$op], $id, $this->_options);
}
else {
+ $op = 'IN';
$qillValue = CRM_Core_BAO_CustomField::getDisplayValue($value, $id, $this->_options);
- $value = array('IN' => $value);
}
$qillOp = CRM_Utils_Array::value($op, CRM_Core_SelectValues::getSearchBuilderOperators(), $op);
switch ($field['data_type']) {
case 'String':
- $sql = "$fieldName";
+ case 'StateProvince':
+ case 'Country':
if ($field['is_search_range'] && is_array($value)) {
$this->searchRange($field['id'],
else {
// fix $value here to escape sql injection attacks
if (!is_array($value)) {
- $value = CRM_Utils_Type::escape($strtolower($value), 'String');
+ if ($field['data_type'] == 'String') {
+ $value = CRM_Utils_Type::escape($strtolower($value), 'String');
+ }
+ else {
+ $value = CRM_Utils_Type::escape($value, 'Integer');
+ }
}
elseif ($isSerialized) {
if (in_array(key($value), CRM_Core_DAO::acceptedSQLOperators(), TRUE)) {
}
//FIX for custom data query fired against no value(NULL/NOT NULL)
- $this->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause($sql, $op, $value, $field['data_type']);
+ $this->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause($fieldName, $op, $value, 'String');
$this->_qill[$grouping][] = "$field[label] $qillOp $qillValue";
}
break;
}
else {
$this->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause($fieldName, $op, $value, 'Integer');
- $this->_qill[$grouping][] = $field['label'] . " $qillOp $value";
+ $this->_qill[$grouping][] = ts("%1 %2 %3", array(1 => $field['label'], 2 => $qillOp, 3 => $qillValue));;
}
break;
case 'Boolean':
- if (strtolower($value) == 'yes' || strtolower($value) == strtolower(ts('Yes'))) {
- $value = 1;
- }
- else {
- $value = (int) $value;
+ if (!is_array($value)) {
+ if (strtolower($value) == 'yes' || strtolower($value) == strtolower(ts('Yes'))) {
+ $value = 1;
+ }
+ else {
+ $value = (int) $value;
+ }
+ $value = ($value == 1) ? 1 : 0;
+ $qillValue = $value ? 'Yes' : 'No';
}
- $value = ($value == 1) ? 1 : 0;
$this->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause($fieldName, $op, $value, 'Integer');
- $value = $value ? ts('Yes') : ts('No');
- $this->_qill[$grouping][] = $field['label'] . " $qillOp {$value}";
+ $this->_qill[$grouping][] = ts("%1 %2 %3", array(1 => $field['label'], 2 => $qillOp, 3 => $qillValue));
break;
case 'Link':
+ case 'Memo':
$this->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause($fieldName, $op, $value, 'String');
- $this->_qill[$grouping][] = $field['label'] . " $qillOp $value";
- break;
-
- case 'Float':
- if ($field['is_search_range'] && is_array($value)) {
- $this->searchRange($field['id'], $field['label'], $field['data_type'], $fieldName, $value, $grouping);
- }
- else {
- $this->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause($fieldName, $op, $value, 'Float');
- $this->_qill[$grouping][] = $field['label'] . " $qillOp {$value}";
- }
+ $this->_qill[$grouping][] = ts("%1 %2 %3", array(1 => $field['label'], 2 => $qillOp, 3 => $qillValue));
break;
case 'Money':
- if ($field['is_search_range'] && is_array($value)) {
+ if (is_array($value)) {
+ $value = CRM_Utils_Array::value($op, $value, $value);
foreach ($value as $key => $val) {
$moneyFormat = CRM_Utils_Rule::cleanMoney($value[$key]);
$value[$key] = $moneyFormat;
}
+ }
+ else {
+ $value = CRM_Utils_Rule::cleanMoney($value);
+ }
+
+ case 'Float':
+ if ($field['is_search_range']) {
$this->searchRange($field['id'], $field['label'], $field['data_type'], $fieldName, $value, $grouping);
}
else {
- $moneyFormat = CRM_Utils_Rule::cleanMoney($value);
- $value = $moneyFormat;
$this->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause($fieldName, $op, $value, 'Float');
- $this->_qill[$grouping][] = $field['label'] . " {$qillOp} {$value}";
+ $this->_qill[$grouping][] = ts("%1 %2 %3", array(1 => $field['label'], 2 => $qillOp, 3 => $qillValue));
}
break;
- case 'Memo':
- $this->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause($fieldName, $op, $value, 'String');
- $this->_qill[$grouping][] = "$field[label] $qillOp $value";
- break;
-
case 'Date':
$fromValue = CRM_Utils_Array::value('from', $value);
$toValue = CRM_Utils_Array::value('to', $value);
}
break;
- case 'StateProvince':
- case 'Country':
- $this->_where[$grouping][] = "$fieldName {$op} " . CRM_Utils_Type::escape($value, 'Int');
- $this->_qill[$grouping][] = $field['label'] . " {$qillOp} {$qillValue}";
- break;
-
case 'File':
if ($op == 'IS NULL' || $op == 'IS NOT NULL' || $op == 'IS EMPTY' || $op == 'IS NOT EMPTY') {
switch ($op) {
// early exit for master_id, CRM-12100
// in the DB it is an ID, but in the export, we retrive the display_name of the master record
- if ($fieldName == 'master_id') {
+ // also for current_employer, CRM-16939
+ if ($fieldName == 'master_id' || $fieldName == 'current_employer') {
$sqlColumns[$fieldName] = "$fieldName varchar(128)";
return;
}
'contact_id' => $contactID,
));
- // FIXME: Loading the contents of every template into the dom does not scale well
$mesTemplate = civicrm_api3('MessageTemplate', 'get', $params + array(
'sequential' => 1,
'is_active' => 1,
- 'return' => array("msg_html", "id", "msg_title", "msg_subject", "msg_text"),
+ 'return' => array("id", "msg_title"),
'workflow_id' => array('IS NULL' => ""),
));
$mailTokens = civicrm_api3('Mailing', 'gettokens', array(
'price' => json_encode(array($elementName, $priceVal)),
'data-amount' => $opt[$valueFieldName],
'data-currency' => $currencyName,
+ 'data-price-field-values' => json_encode($customOption),
);
if (!empty($qf->_quickConfig) && $field->name == 'contribution_amount') {
$extra += array('onclick' => 'clearAmountOther();');
'' => ts('- select -'),
) + $selectOption,
$useRequired && $field->is_required,
- array('price' => json_encode($priceVal), 'class' => 'crm-select2')
+ array('price' => json_encode($priceVal), 'class' => 'crm-select2', 'data-price-field-values' => json_encode($customOption))
);
// CRM-6902 - Add "max" option for a price set field
window.tpls = tpls;
var lastModifiedTpl = null;
return {
+ // Get a template
+ // @param id MessageTemplate id (per APIv3)
// @return Promise MessageTemplate (per APIv3)
get: function get(id) {
- id = '' + id; // parseInt(id);
- var dfr = $q.defer();
- var tpl = _.where(tpls, {id: id});
- if (id && tpl && tpl[0]) {
- dfr.resolve(tpl[0]);
- }
- else {
- dfr.reject(id);
- }
- return dfr.promise;
+ return crmApi('MessageTemplate', 'getsingle', {
+ "return": "id,msg_subject,msg_html,msg_title,msg_text",
+ "id": id
+ });
},
// Save a template
// @param tpl MessageTemplate (per APIv3) For new templates, omit "id"
$params['is_active']['api.default'] = 1;
//continue to support component
$params['component_id']['api.aliases'] = array('component');
- $params['name']['api.aliases'] = array('label');
+ // $params['name']['api.aliases'] = array('label');
$params['option_group_id']['api.required'] = TRUE;
}
{include file="CRM/Contribute/Form/Contribution/MembershipBlock.tpl" context="confirmContribution"}
- {if $amount GT 0 OR $minimum_fee GT 0 OR ( $priceSetID and $lineItem ) }
+ {if $amount GTE 0 OR $minimum_fee GTE 0 OR ( $priceSetID and $lineItem ) }
<div class="crm-group amount_display-group">
{if !$useForMember}
<div class="header-dark">
payment_options.hide();
payment_processor.hide();
payment_information.hide();
- // also unset selected payment methods
- cj('input[name="payment_processor"]').removeProp('checked');
}
else {
payment_options.show();
{include file="CRM/Contribute/Form/Contribution/MembershipBlock.tpl" context="thankContribution"}
- {if $amount GT 0 OR $minimum_fee GT 0 OR ( $priceSetID and $lineItem ) }
+ {if $amount GTE 0 OR $minimum_fee GTE 0 OR ( $priceSetID and $lineItem ) }
<div class="crm-group amount_display-group">
{if !$useForMember}
<div class="header-dark">
elseif ($processorType == 'AuthNet') {
// FIXME: we 'll need to make a new separate account for testing
$processorSettings = array(
- 'user_name' => '5ULu56ex',
+ //dummy live username/password are passed to bypass processor validation on live credential
+ 'user_name' => '3HcY62mY',
+ 'password' => '69943NrwaQA92b8J',
'test_user_name' => '5ULu56ex',
'password' => '7ARxW575w736eF5p',
'test_password' => '7ARxW575w736eF5p',
}
elseif ($processorType == 'PayPal_Standard') {
$processorSettings = array(
+ 'user_name' => 'V18ki@9r5Bf.org',
'test_user_name' => 'V18ki@9r5Bf.org',
);
}
* @param $hash
* @param bool $otherAmount
*/
- public function _testOnlineMembershipSignup($pageId, $memTypeId, $firstName, $lastName, $payLater, $hash, $otherAmount = FALSE, $amountSection = TRUE) {
+ public function _testOnlineMembershipSignup($pageId, $memTypeId, $firstName, $lastName, $payLater, $hash, $otherAmount = FALSE, $amountSection = TRUE, $freeMembership = FALSE) {
//Open Live Contribution Page
$this->openCiviPage("contribute/transact", "reset=1&id=$pageId&action=preview", "_qf_Main_upload-bottom");
// Select membership type 1
$this->type("postal_code-1", "94117");
$this->select("country-1", "value=1228");
$this->select("state_province-1", "value=1001");
- if (!$payLater && $amountSection) {
- //Credit Card Info
- $this->select("credit_card_type", "value=Visa");
- $this->type("credit_card_number", "4111111111111111");
- $this->type("cvv2", "000");
- $this->select("credit_card_exp_date[M]", "value=1");
- $this->select("credit_card_exp_date[Y]", "value=2020");
-
- //Billing Info
- $this->waitForElementPresent("billing_first_name");
- $this->type("billing_first_name", $firstName . "billing");
- $this->waitForElementPresent("billing_last_name");
- $this->type("billing_last_name", $lastName . "billing");
- $this->type("billing_street_address-5", "15 Main St.");
- $this->type(" billing_city-5", "San Jose");
- $this->select("billing_country_id-5", "value=1228");
- $this->select("billing_state_province_id-5", "value=1004");
- $this->type("billing_postal_code-5", "94129");
+
+ if ($freeMembership) {
+ $this->waitForElementPresent("xpath=//div[@id='payment_information'][@style='display: none;']");
+ }
+ else {
+ if (!$payLater && $amountSection) {
+ //Credit Card Info
+ $this->select("credit_card_type", "value=Visa");
+ $this->type("credit_card_number", "4111111111111111");
+ $this->type("cvv2", "000");
+ $this->select("credit_card_exp_date[M]", "value=1");
+ $this->select("credit_card_exp_date[Y]", "value=2020");
+
+ //Billing Info
+ $this->waitForElementPresent("billing_first_name");
+ $this->type("billing_first_name", $firstName . "billing");
+ $this->waitForElementPresent("billing_last_name");
+ $this->type("billing_last_name", $lastName . "billing");
+ $this->type("billing_street_address-5", "15 Main St.");
+ $this->type(" billing_city-5", "San Jose");
+ $this->select("billing_country_id-5", "value=1228");
+ $this->select("billing_state_province_id-5", "value=1004");
+ $this->type("billing_postal_code-5", "94129");
+ }
}
$this->click("_qf_Main_upload-bottom");
$this->waitForElementPresent("_qf_Confirm_next-bottom");
$this->clickLink('_qf_MembershipBlock_next', '_qf_MembershipBlock_next-bottom');
$text = "'MembershipBlock' information has been saved.";
$this->waitForText('crm-notification-container', $text);
- $this->click('link=Amounts');
- $this->waitForElementPresent('_qf_Amount_cancel-bottom');
- $this->click('is_monetary');
- $this->clickLink('_qf_Amount_upload_done-bottom');
- $text = "'Amount' information has been saved.";
- $this->waitForText('crm-notification-container', $text);
-
- $firstName = 'Ma' . substr(sha1(rand()), 0, 4);
- $lastName = 'An' . substr(sha1(rand()), 0, 7);
-
- //logout
- $this->webtestLogout();
-
- $this->_testOnlineMembershipSignup($pageId, $memTypeTitle, $firstName, $lastName, $payLater, $hash, $allowOtherAmount, $amountSection);
- // Log in using webtestLogin() method
- $this->webtestLogin();
-
- //Find Contribution
- $this->openCiviPage("contribute/search", "reset=1", "contribution_date_low");
- $this->type("sort_name", "$lastName $firstName");
- $this->clickLink("_qf_Search_refresh", "xpath=//div[@id='contributionSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']");
- $this->clickLink("xpath=//div[@id='contributionSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']", "_qf_ContributionView_cancel-bottom", FALSE);
-
- //View Contribution Record and verify data
- $expected = array(
- 'From' => "{$firstName} {$lastName}",
- 'Financial Type' => 'Member Dues',
- 'Total Amount' => '0.00',
- 'Contribution Status' => 'Completed',
- 'Received Into' => 'Deposit Bank Account',
- 'Source' => "Online Contribution: $contributionTitle",
- 'Online Contribution Page' => $contributionTitle,
+ $processors = array(
+ 'Test Processor',
+ 'AuthNet',
+ 'PayPal',
+ 'PayPal_Standard',
);
- $this->webtestVerifyTabularData($expected);
+ foreach ($processors as $processor) {
+ if ($processor == 'Test Processor') {
+ $processorName = $processor;
+ }
+ else {
+ $processorName = $processor . substr(sha1(rand()), 0, 7);
+ $this->webtestAddPaymentProcessor($processorName, $processor);
+ }
+ $this->openCiviPage("admin/contribute/amount", "reset=1&action=update&id={$pageId}", '_qf_Amount_upload_done-bottom');
+ $this->assertTrue($this->isTextPresent($processorName));
+ $this->check("xpath=//label[text() = '{$processorName}']/preceding-sibling::input[1]");
+ $this->clickLink('_qf_Amount_upload_done-bottom');
+ $this->waitForText('crm-notification-container', "'Amount' information has been saved.");
+
+ $firstName = 'Ma' . substr(sha1(rand()), 0, 4);
+ $lastName = 'An' . substr(sha1(rand()), 0, 7);
+
+ //logout
+ $this->webtestLogout();
+
+ $this->_testOnlineMembershipSignup($pageId, $memTypeTitle, $firstName, $lastName, $payLater, $hash, $allowOtherAmount, $amountSection, TRUE);
+
+ // Log in using webtestLogin() method
+ $this->webtestLogin();
+
+ //Find Contribution
+ $this->openCiviPage("contribute/search", "reset=1", "contribution_date_low");
+ $this->type("sort_name", "$lastName $firstName");
+ $this->clickLink("_qf_Search_refresh", "xpath=//div[@id='contributionSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']");
+ $this->clickLink("xpath=//div[@id='contributionSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']", "_qf_ContributionView_cancel-bottom", FALSE);
+
+ //View Contribution Record and verify data
+ $expected = array(
+ 'From' => "{$firstName} {$lastName}",
+ 'Financial Type' => 'Member Dues',
+ 'Total Amount' => '0.00',
+ 'Contribution Status' => 'Completed',
+ 'Received Into' => 'Payment Processor Account',
+ 'Source' => "Online Contribution: $contributionTitle",
+ 'Online Contribution Page' => $contributionTitle,
+ );
+ $this->webtestVerifyTabularData($expected);
- //Find Member
- $this->openCiviPage("member/search", "reset=1", "member_end_date_high");
+ //Find Member
+ $this->openCiviPage("member/search", "reset=1", "member_end_date_high");
- $this->type("sort_name", "$lastName $firstName");
- $this->clickLink("_qf_Search_refresh", "xpath=//div[@id='memberSearch']/table/tbody/tr");
- $this->click("xpath=//div[@id='memberSearch']/table/tbody/tr/td[11]/span/a[text()='View']");
- $this->waitForElementPresent("_qf_MembershipView_cancel-bottom");
+ $this->type("sort_name", "$lastName $firstName");
+ $this->clickLink("_qf_Search_refresh", "xpath=//div[@id='memberSearch']/table/tbody/tr");
+ $this->click("xpath=//div[@id='memberSearch']/table/tbody/tr/td[11]/span/a[text()='View']");
+ $this->waitForElementPresent("_qf_MembershipView_cancel-bottom");
- //View Membership Record
- $verifyData = array(
- 'Member' => $firstName . ' ' . $lastName,
- 'Membership Type' => $memTypeTitle,
- 'Source' => 'Online Contribution:' . ' ' . $contributionTitle,
- 'Status' => 'New',
- );
+ //View Membership Record
+ $verifyData = array(
+ 'Member' => $firstName . ' ' . $lastName,
+ 'Membership Type' => $memTypeTitle,
+ 'Source' => 'Online Contribution:' . ' ' . $contributionTitle,
+ 'Status' => 'New',
+ );
- $this->webtestVerifyTabularData($verifyData);
+ $this->webtestVerifyTabularData($verifyData);
+ }
}
}