$groups = self::group($type, $contactID, $tableName, $allGroups, $includedGroups);
$cache[$key] = $groups;
}
+ if (empty($groups)) {
+ return FALSE;
+ }
return in_array($groupID, $groups) ? TRUE : FALSE;
}
*/
protected $_prefix = "activity_";
- protected $_defaults;
-
/**
* The saved search ID retrieved from the GET vars.
*
$this->_formValues["activity_test"] = 0;
}
- CRM_Core_BAO_CustomValue::fixFieldValueOfTypeMemo($this->_formValues);
+ CRM_Core_BAO_CustomValue::fixCustomFieldValue($this->_formValues);
$this->_queryParams = CRM_Contact_BAO_Query::convertFormValues($this->_formValues);
if (!empty($params['target_contact_id']) &&
$params['target_contact_id'] != $targetContactId
) {
- array_unshift($values, 'Mismatch of External identifier :' . $params['external_identifier'] . ' and Contact Id:' . $params['target_contact_id']);
+ array_unshift($values, 'Mismatch of External ID:' . $params['external_identifier'] . ' and Contact Id:' . $params['target_contact_id']);
return CRM_Import_Parser::ERROR;
}
elseif ($targetContactId) {
$params['target_contact_id'] = $targetContactId;
}
else {
- array_unshift($values, 'No Matching Contact for External identifier :' . $params['external_identifier']);
+ array_unshift($values, 'No Matching Contact for External ID:' . $params['external_identifier']);
return CRM_Import_Parser::ERROR;
}
}
*/
protected $_currentParentID = NULL;
- /**
- * Default values.
- */
- protected $_defaults = array();
-
/**
* Build the form object.
*
if ($this->_action & CRM_Core_Action::VIEW) {
$this->freeze();
}
+
+ $this->assign('relationship_type_id', $this->_id);
+
}
/**
*/
class CRM_Admin_Form_Setting extends CRM_Core_Form {
- protected $_defaults;
protected $_settings = array();
/**
protected $_stringName = NULL;
- protected $_defaults = NULL;
-
public $unsavedChangesWarn = TRUE;
/**
'id', $returnURL, $filter
);
- // retrieve financial account name for the payment instrument page
+ // retrieve financial account name for the payment method page
if ($gName = "payment_instrument") {
foreach ($optionValue as $key => $option) {
$optionValue[$key]['financial_account'] = CRM_Financial_BAO_FinancialTypeAccount::getFinancialAccount($key, 'civicrm_option_value');
$errors = array();
$batchTypes = CRM_Core_Pseudoconstant::get('CRM_Batch_DAO_Batch', 'type_id', array('flip' => 1), 'validate');
$fields = array(
- 'total_amount' => 'Amount',
- 'financial_type' => 'Financial Type',
- 'payment_instrument' => 'Paid By',
+ 'total_amount' => ts('Amount'),
+ 'financial_type' => ts('Financial Type'),
+ 'payment_instrument' => ts('Payment Method'),
);
//CRM-16480 if contact is selected, validate financial type and amount field.
'links',
);
}
- header('Content-Type: application/json');
+ CRM_Utils_System::setHttpHeader('Content-Type', 'application/json');
echo CRM_Utils_JSON::encodeDataTableSelector($batches, $sEcho, $iTotal, $iFilteredTotal, $selectorElements);
CRM_Utils_System::civiExit();
}
$form->add('text', 'street_unit', ts('Street Unit'), $attributes['street_unit']);
$form->add('text', 'street_address', ts('Street Address'), $attributes['street_address']);
$form->add('text', 'city', ts('City'), $attributes['city']);
- $form->add('text', 'postal_code', ts('Zip / Postal Code'), $attributes['postal_code']);
+ $form->add('text', 'postal_code', ts('Postal Code'), $attributes['postal_code']);
//@todo FIXME - using the CRM_Core_DAO::VALUE_SEPARATOR creates invalid html - if you can find the form
// this is loaded onto then replace with something like '__' & test
protected $_image_URL;
- protected $_defaults = NULL;
-
/**
*/
public function __construct() {
*/
protected $_limit = NULL;
- protected $_defaults;
-
/**
* Prefix for the controller.
*/
$iFilteredTotal = $iTotal;
- header('Content-Type: application/json');
+ CRM_Utils_System::setHttpHeader('Content-Type', 'application/json');
echo CRM_Utils_JSON::encodeDataTableSelector($searchRows, $sEcho, $iTotal, $iFilteredTotal, $selectorElements);
CRM_Utils_System::civiExit();
}
$iFilteredTotal = $iTotal;
- header('Content-Type: application/json');
+ CRM_Utils_System::setHttpHeader('Content-Type', 'application/json');
echo CRM_Utils_JSON::encodeDataTableSelector($searchRows, $sEcho, $iTotal, $iFilteredTotal, $selectorElements);
CRM_Utils_System::civiExit();
}
$iFilteredTotal = $iTotal;
- header('Content-Type: application/json');
+ CRM_Utils_System::setHttpHeader('Content-Type', 'application/json');
echo CRM_Utils_JSON::encodeDataTableSelector($searchRows, $sEcho, $iTotal, $iFilteredTotal, $selectorElements);
CRM_Utils_System::civiExit();
}
$iFilteredTotal = $iTotal;
- header('Content-Type: application/json');
+ CRM_Utils_System::setHttpHeader('Content-Type', 'application/json');
echo CRM_Utils_JSON::encodeDataTableSelector($searchRows, $sEcho, $iTotal, $iFilteredTotal, $selectorElements);
CRM_Utils_System::civiExit();
}
*/
public $_caseType;
- /**
- * The default values of an activity.
- *
- * @var array
- */
- public $_defaults = array();
-
/**
* The array of releted contact info.
*
*/
protected $_prefix = 'case_';
- protected $_defaults;
-
/**
* Processing needed for buildForm and later.
*
if (empty($this->_formValues['case_deleted'])) {
$this->_formValues['case_deleted'] = 0;
}
- CRM_Core_BAO_CustomValue::fixFieldValueOfTypeMemo($this->_formValues);
+ CRM_Core_BAO_CustomValue::fixCustomFieldValue($this->_formValues);
$this->_queryParams = CRM_Contact_BAO_Query::convertFormValues($this->_formValues);
}
elseif ($fieldName == 'email') {
$data['email'][$loc]['email'] = $value;
+ if (empty($contactID)) {
+ $data['email'][$loc]['is_primary'] = 1;
+ }
}
elseif ($fieldName == 'im') {
if (isset($params[$key . '-provider_id'])) {
civicrm_subscription_history.method as method';
}
- $where = " WHERE contact_a.id = %1 AND civicrm_group.is_active = 1 AND civicrm_group.saved_search_id IS NULL";
+ $where = " WHERE contact_a.id = %1 AND civicrm_group.is_active = 1";
if ($excludeHidden) {
$where .= " AND civicrm_group.is_hidden = 0 ";
$from = CRM_Contact_BAO_Query::fromClause($tables);
+ //CRM-16945: seems hackish but as per CRM-16483 of using group criteria for Search Builder it is mandatory
+ //to include group_contact_cache clause when group table is present, so following code remove duplicacy
+ $from = str_replace("OR civicrm_group.id = civicrm_group_contact_cache.group_id", 'AND civicrm_group.saved_search_id IS NULL', $from);
+
$where .= " AND $permission ";
if ($onlyPublicGroups) {
$options = CRM_Core_PseudoConstant::get(__CLASS__, $fieldName, $params, $context);
- if (($fieldName == 'group' || $fieldName == 'group_id')) {
- // Enforce group visibility permissions
- if (!empty($props['check_permissions'])) {
- $options = CRM_Core_PseudoConstant::group();
- }
- if ($context == 'search' || $context == 'create') {
- // Sort group list by hierarchy
- $options = CRM_Contact_BAO_Group::getGroupsHierarchy($options, NULL, '- ', TRUE);
- }
+ // Sort group list by hierarchy
+ // TODO: This will only work when api.entity is "group_contact". What about others?
+ if (($fieldName == 'group' || $fieldName == 'group_id') && ($context == 'search' || $context == 'create')) {
+ $options = CRM_Contact_BAO_Group::getGroupsHierarchy($options, NULL, '- ', TRUE);
}
return $options;
$customClass = CRM_Contact_BAO_SearchCustom::customClass($ssParams['customSearchID'], $savedSearchID);
$searchSQL = $customClass->contactIDs();
$searchSQL = str_replace('ORDER BY contact_a.id ASC', '', $searchSQL);
+ if (!strstr($searchSQL, 'WHERE')) {
+ $searchSQL .= " WHERE ( 1 ) ";
+ }
$idName = 'contact_id';
}
else {
*
* @param array $params
* (reference ) an assoc array of name/value pairs.
- * @param array $contact
+ * @param CRM $contact
* Contact object.
*
* @return CRM_Contact_BAO_Contact
}
//now set the names.
- $names = array('sortName' => 'sort_name', 'displayName' => 'display_name');
+ $names = array('displayName' => 'display_name', 'sortName' => 'sort_name');
foreach ($names as $value => $name) {
if (empty($$value)) {
if ($email) {
elseif ($uniqId) {
$$value = $uniqId;
}
+ elseif (!empty($params[$name])) {
+ $$value = $params[$name];
+ }
+ // If we have nothing else going on set sort_name to display_name.
+ elseif ($displayName) {
+ $$value = $displayName;
+ }
}
//finally if we could not pass anything lets keep db.
if (!empty($$value)) {
* Check if there is data to create the object.
*
* @param array $params
- * (reference ) an assoc array of name/value pairs.
*
* @return bool
*/
- public static function dataExists(&$params) {
+ public static function dataExists($params) {
if ($params['contact_type'] == 'Individual') {
return TRUE;
}
$clause = " (NULLIF($field, '') IS NOT NULL) ";
return $clause;
+ case 'IN':
+ case 'NOT IN':
+ if (!empty($value) && is_array($value) && !array_key_exists($op, $value)) {
+ $value = array($op => $value);
+ }
+
default:
if (empty($dataType)) {
$dataType = 'String';
*/
class CRM_Contact_Form_DedupeFind extends CRM_Admin_Form {
- /**
- * Defined defaults.
- */
- public $_defaults;
-
/**
* Pre processing.
- *
- * @return void
*/
public function preProcess() {
$this->rgid = CRM_Utils_Request::retrieve('rgid', 'Positive', $this, FALSE, 0);
class CRM_Contact_Form_DedupeRules extends CRM_Admin_Form {
const RULES_COUNT = 5;
protected $_contactType;
- protected $_defaults = array();
protected $_fields = array();
protected $_rgid;
$name = 'name';
}
- $form->addField("address[$blockId][$name]", array('entity' => 'address'));
+ $params = array('entity' => 'address');
+
+ if ($name == 'postal_code_suffix') {
+ $params['label'] = ts('Suffix');
+ }
+
+ $form->addField("address[$blockId][$name]", $params);
}
$entityId = NULL;
*/
public $_contactId;
- /**
- * Form defaults.
- *
- * @var array
- */
- protected $_defaults = array();
-
/**
* Build all the data structures needed to build the form.
*/
| This file is a part of CiviCRM. |
| |
| CiviCRM is free software; you can copy, modify, and distribute it |
-s | under the terms of the GNU Affero General Public License |
+ | under the terms of the GNU Affero General Public License |
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
| |
| CiviCRM is distributed in the hope that it will be useful, but |
$this->_sortByCharacter = NULL;
}
- CRM_Core_BAO_CustomValue::fixFieldValueOfTypeMemo($this->_formValues);
+ CRM_Core_BAO_CustomValue::fixCustomFieldValue($this->_formValues);
$this->_params = CRM_Contact_BAO_Query::convertFormValues($this->_formValues);
$this->_returnProperties = &$this->returnProperties();
'contribution_product_id',
'payment_instrument_id',
);
- $specialParams += preg_grep('/^custom_/', array_keys($this->_formValues));
foreach ($specialParams as $element) {
$value = CRM_Utils_Array::value($element, $this->_formValues);
if ($value) {
}
if ($this->_ssID && empty($_POST)) {
- $fields = array('contact_type', 'group', 'contact_tags');
+ $specialFields = array('contact_type', 'group', 'contact_tags');
- foreach ($fields as $field) {
- $fieldValues = CRM_Utils_Array::value($field, $defaults);
- if ($fieldValues && is_array($fieldValues)) {
- $defaults[$field] = array_keys($fieldValues);
+ foreach ($defaults as $element => $value) {
+ if (!empty($value) && is_array($value)) {
+ if (in_array($element, $specialFields)) {
+ $defaults[$element] = array_keys($value);
+ }
+ // As per the OK (Operator as Key) value format, value array may contain key
+ // as an operator so to ensure the default is always set actual value
+ elseif (in_array(key($value), CRM_Core_DAO::acceptedSQLOperators(), TRUE)) {
+ $defaults[$element] = CRM_Utils_Array::value(key($value), $value);
+ if (is_string($defaults[$element])) {
+ $defaults[$element] = str_replace("%", '', $defaults[$element]);
+ }
+ }
}
}
}
$form->addSelect('preferred_language', array('class' => 'twenty', 'context' => 'search'));
// Phone search
- $form->addElement('text', 'phone_numeric', ts('Phone Number'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_Phone', 'phone'));
+ $form->addElement('text', 'phone_numeric', ts('Phone'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_Phone', 'phone'));
$locationType = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id');
$phoneType = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Phone', 'phone_type_id');
$form->add('select', 'phone_location_type_id', ts('Phone Location'), array('' => ts('- any -')) + $locationType, FALSE, array('class' => 'crm-select2'));
$elements = array(
'street_address' => array(ts('Street Address'), $attributes['street_address'], NULL, NULL),
'city' => array(ts('City'), $attributes['city'], NULL, NULL),
- 'postal_code' => array(ts('Zip / Postal Code'), $attributes['postal_code'], NULL, NULL),
+ 'postal_code' => array(ts('Postal Code'), $attributes['postal_code'], NULL, NULL),
'country' => array(ts('Country'), $attributes['country_id'], 'country', FALSE),
'state_province' => array(ts('State/Province'), $attributes['state_province_id'], 'stateProvince', TRUE),
'county' => array(ts('County'), $attributes['county_id'], 'county', TRUE),
$from = $this->from();
+ $select = $this->select();
if ($justIDs) {
- $select = $this->select();
$select .= ', contact_a.id, display_name';
}
else {
- $select = $this->select();
$select = "
DISTINCT contact_a.id as contact_id,
contact_a.display_name as display_name,
- $select
-";
-
+ $select ";
}
$this->buildACLClause('contact_a');
$sql = "
case 'is_deceased':
if (CRM_Utils_String::strtoboolstr($value) === FALSE) {
- self::addToErrorMsg(ts('Is Deceased'), $errorMessage);
+ self::addToErrorMsg(ts('Deceased'), $errorMessage);
}
break;
}
public static function groupTree() {
- header('Content-Type: application/json');
+ CRM_Utils_System::setHttpHeader('Content-Type', 'application/json');
$gids = CRM_Utils_Type::escape($_GET['gids'], 'String');
echo CRM_Contact_BAO_GroupNestingCache::json($gids);
CRM_Utils_System::civiExit();
* Delete custom value.
*/
public static function deleteCustomValue() {
- header('Content-Type: text/plain');
+ CRM_Utils_System::setHttpHeader('Content-Type', 'text/plain');
$customValueID = CRM_Utils_Type::escape($_REQUEST['valueID'], 'Positive');
$customGroupID = CRM_Utils_Type::escape($_REQUEST['groupID'], 'Positive');
$userEmail
) = CRM_Contact_BAO_Contact_Location::getEmailDetails($contactID);
- header('Content-Type: text/plain');
+ CRM_Utils_System::setHttpHeader('Content-Type', 'text/plain');
if ($userEmail) {
echo $userEmail;
}
}
}
- header('Content-Type: application/json');
+ CRM_Utils_System::setHttpHeader('Content-Type', 'application/json');
echo CRM_Utils_JSON::encodeDataTableSelector($searchRows, $sEcho, $iTotal, $iFilteredTotal, $selectorElements);
CRM_Utils_System::civiExit();
header('HTTP/1.0 403 Forbidden');
return;
}
- header('Expires: ' . gmdate('D, d M Y H:i:s \G\M\T', CRM_Utils_Time::getTimeRaw() + $ttl));
- header("Content-Type: $mimeType");
- header("Content-Disposition: inline; filename=\"" . basename($file) . "\"");
- header("Cache-Control: max-age=$ttl, public");
- header('Pragma: public');
+ CRM_Utils_System::setHttpHeader('Expires', gmdate('D, d M Y H:i:s \G\M\T', CRM_Utils_Time::getTimeRaw() + $ttl));
+ CRM_Utils_System::setHttpHeader("Content-Type", $mimeType);
+ CRM_Utils_System::setHttpHeader("Content-Disposition", "inline; filename=\"" . basename($file) . "\"");
+ CRM_Utils_System::setHttpHeader("Cache-Control", "max-age=$ttl, public");
+ CRM_Utils_System::setHttpHeader('Pragma', 'public');
readfile($file);
}
'name'
);
if (!$activity->find(TRUE)) {
+ if (empty($contribution->contact_id)) {
+ $contribution->find(TRUE);
+ }
CRM_Activity_BAO_Activity::addActivity($contribution, 'Offline');
}
else {
/**
* Update contribution as well as related objects.
*
+ * This function by-passes hooks - to address this - don't use this function.
+ *
+ * @deprecated
+ *
+ * Use api contribute.completetransaction
+ * For failures use failPayment (preferably exposing by api in the process).
+ *
* @param array $params
* @param bool $processContributionObject
*
return CRM_Core_DAO::singleValueQuery($query);
}
+ /**
+ * Repeat a transaction as part of a recurring series.
+ *
+ * Only call this via the api as it is being refactored. The intention is that the repeatTransaction function
+ * (possibly living on the ContributionRecur BAO) would be called first to create a pending contribution with a
+ * subsequent call to the contribution.completetransaction api.
+ *
+ * The completeTransaction functionality has historically been overloaded to both complete and repeat payments.
+ *
+ * @param CRM_Contribute_BAO_Contribution $contribution
+ * @param array $input
+ * @param array $contributionParams
+ *
+ * @return array
+ */
+ protected static function repeatTransaction(&$contribution, &$input, $contributionParams) {
+ if (!empty($contribution->id)) {
+ return FALSE;
+ }
+ if (empty($contribution->id)) {
+ // Unclear why this would only be set for repeats.
+ if (!empty($input['amount'])) {
+ $contribution->total_amount = $contributionParams['total_amount'] = $input['amount'];
+ }
+ $templateContribution = civicrm_api3('Contribution', 'getsingle', array(
+ 'contribution_recur_id' => $contributionParams['contribution_recur_id'],
+ 'options' => array('limit' => 1),
+ ));
+ $contributionParams['skipLineItem'] = TRUE;
+ $contributionParams['status_id'] = 'Pending';
+ $contributionParams['financial_type_id'] = $templateContribution['financial_type_id'];
+ $contributionParams['contact_id'] = $templateContribution['contact_id'];
+ $contributionParams['source'] = empty($templateContribution['source']) ? ts('Recurring contribution') : $templateContribution['source'];
+ $createContribution = civicrm_api3('Contribution', 'create', $contributionParams);
+ $contribution->id = $createContribution['id'];
+ $input['line_item'] = CRM_Contribute_BAO_ContributionRecur::addRecurLineItems($contribution->contribution_recur_id, $contribution);
+ CRM_Contribute_BAO_ContributionRecur::copyCustomValues($contributionParams['contribution_recur_id'], $contribution->id);
+ return TRUE;
+ }
+ }
+
/**
* Get individual id for onbehalf contribution.
*
* Input as delivered from Payment Processor.
* @param array $ids
* Ids as Loaded by Payment Processor.
- * @param bool $required
- * Is Payment processor / contribution page required.
* @param bool $loadAll
* Load all related objects - even where id not passed in? (allows API to call this).
*
* @return bool
* @throws Exception
*/
- public function loadRelatedObjects(&$input, &$ids, $required = FALSE, $loadAll = FALSE) {
+ public function loadRelatedObjects(&$input, &$ids, $loadAll = FALSE) {
if ($loadAll) {
$ids = array_merge($this->getComponentDetails($this->id), $ids);
if (empty($ids['contact']) && isset($this->contact_id)) {
}
}
}
-
- if (!$paymentProcessorID) {
- //fail to load payment processor id.
- // this seems a bit dubious....
- if (empty($ids['pledge_payment'])) {
- $loadObjectSuccess = TRUE;
- if ($required) {
- throw new Exception("Could not find contribution page for contribution record: " . $this->id);
- }
- return $loadObjectSuccess;
- }
- }
}
else {
// we are in event mode
$ids['paymentProcessor'] = $paymentProcessorID;
$this->_relatedObjects['paymentProcessor'] = $paymentProcessor;
}
- elseif ($required) {
- throw new Exception("Could not find payment processor for contribution record: " . $this->id);
- }
-
return TRUE;
}
* @throws Exception
*/
public function composeMessageArray(&$input, &$ids, &$values, $recur = FALSE, $returnMessageText = TRUE) {
- if (empty($this->_relatedObjects)) {
- $this->loadRelatedObjects($input, $ids);
- }
+ $this->loadRelatedObjects($input, $ids);
+
if (empty($this->_component)) {
$this->_component = CRM_Utils_Array::value('component', $input);
}
$entityID = $ids['membership'][0];
}
- $url = $paymentObject->subscriptionURL($entityID, $entity);
- $template->assign('cancelSubscriptionUrl', $url);
-
- $url = $paymentObject->subscriptionURL($entityID, $entity, 'billing');
- $template->assign('updateSubscriptionBillingUrl', $url);
-
- $url = $paymentObject->subscriptionURL($entityID, $entity, 'update');
- $template->assign('updateSubscriptionUrl', $url);
+ $template->assign('cancelSubscriptionUrl', $paymentObject->subscriptionURL($entityID, $entity));
+ $template->assign('updateSubscriptionBillingUrl', $paymentObject->subscriptionURL($entityID, $entity, 'billing'));
+ $template->assign('updateSubscriptionUrl', $paymentObject->subscriptionURL($entityID, $entity, 'update'));
if ($this->_relatedObjects['paymentProcessor']['billing_mode'] & CRM_Core_Payment::BILLING_MODE_FORM) {
//direct mode showing billing block, so use directIPN for temporary
}
// todo remove strtolower - check consistency
if (strtolower($this->_component) == 'event') {
+ $eventParams = array('id' => $this->_relatedObjects['participant']->event_id);
+ $values['event'] = array();
+
+ CRM_Event_BAO_Event::retrieve($eventParams, $values['event']);
+
+ //get location details
+ $locationParams = array('entity_id' => $this->_relatedObjects['participant']->event_id, 'entity_table' => 'civicrm_event');
+ $values['location'] = CRM_Core_BAO_Location::getValues($locationParams);
+
+ $ufJoinParams = array(
+ 'entity_table' => 'civicrm_event',
+ 'entity_id' => $ids['event'],
+ 'module' => 'CiviEvent',
+ );
+
+ list($custom_pre_id,
+ $custom_post_ids
+ ) = CRM_Core_BAO_UFJoin::getUFGroupIds($ufJoinParams);
+
+ $values['custom_pre_id'] = $custom_pre_id;
+ $values['custom_post_id'] = $custom_post_ids;
+ //for tasks 'Change Participant Status' and 'Batch Update Participants Via Profile' case
+ //and cases involving status updation through ipn
+ // whatever that means!
+ // total_amount appears to be the preferred input param & it is unclear why we support amount here
+ // perhaps we should throw an e-notice if amount is set & force total_amount?
+ if (!empty($input['amount'])) {
+ $values['totalAmount'] = $input['amount'];
+ }
+
+ if ($values['event']['is_email_confirm']) {
+ $values['is_email_receipt'] = 1;
+ }
return CRM_Event_BAO_Event::sendMail($ids['contact'], $values,
$this->_relatedObjects['participant']->id, $this->is_test, $returnMessageText
);
* @param int $recur
* @param CRM_Contribute_BAO_Contribution $contribution
* @param bool $isRecurring
- * Duplication of param needs review.
+ * Duplication of param needs review. Only used by AuthorizeNetIPN
* @param int $isFirstOrLastRecurringPayment
+ * Deprecated param only used by AuthorizeNetIPN.
*/
- public static function completeOrder(&$input, &$ids, $objects, &$transaction, $recur, $contribution, $isRecurring,
+ public static function completeOrder(&$input, &$ids, $objects, $transaction, $recur, $contribution, $isRecurring,
$isFirstOrLastRecurringPayment) {
$primaryContributionID = isset($contribution->id) ? $contribution->id : $objects['first_contribution']->id;
+ // The previous details are used when calculating line items so keep it before any code that 'does something'
+ if (!empty($contribution->id)) {
+ $input['prevContribution'] = CRM_Contribute_BAO_Contribution::getValues(array('id' => $contribution->id),
+ CRM_Core_DAO::$_nullArray, CRM_Core_DAO::$_nullArray);
+ }
+ $inputContributionWhiteList = array(
+ 'fee_amount',
+ 'net_amount',
+ 'trxn_id',
+ 'check_number',
+ 'payment_instrument_id',
+ 'is_test',
+ 'campaign_id',
+ 'receive_date',
+ );
+
+ $contributionParams = array_merge(array(
+ 'contribution_status_id' => 'Completed',
+ ), array_intersect_key($input, array_fill_keys($inputContributionWhiteList, 1)
+ ));
$participant = CRM_Utils_Array::value('participant', $objects);
$memberships = CRM_Utils_Array::value('membership', $objects);
$recurContrib = CRM_Utils_Array::value('contributionRecur', $objects);
+ if (!empty($recurContrib->id)) {
+ $contributionParams['contribution_recur_id'] = $recurContrib->id;
+ }
+ self::repeatTransaction($contribution, $input, $contributionParams);
if (is_numeric($memberships)) {
$memberships = array($objects['membership']);
if (isset($input['is_email_receipt'])) {
$values['is_email_receipt'] = $input['is_email_receipt'];
}
- $source = NULL;
+
if ($input['component'] == 'contribute') {
if ($contribution->contribution_page_id) {
CRM_Contribute_BAO_ContributionPage::setValues($contribution->contribution_page_id, $values);
- $source = ts('Online Contribution') . ': ' . $values['title'];
+ $contributionParams['source'] = ts('Online Contribution') . ': ' . $values['title'];
}
elseif ($recurContrib && $recurContrib->id) {
- $contribution->contribution_page_id = NULL;
+ $contributionParams['contribution_page_id'] = NULL;
$values['amount'] = $recurContrib->amount;
$values['financial_type_id'] = $objects['contributionType']->id;
$values['title'] = $source = ts('Offline Recurring Contribution');
$values['is_email_receipt'] = $recurContrib->is_email_receipt;
}
- $contribution->source = $source;
if (!empty($values['is_email_receipt'])) {
- $contribution->receipt_date = $changeDate;
+ $contributionParams['receipt_date'] = $changeDate;
}
if (!empty($memberships)) {
- $membershipsUpdate = array();
foreach ($memberships as $membershipTypeIdKey => $membership) {
if ($membership) {
- $format = '%Y%m%d';
+ $membershipParams = array(
+ 'id' => $membership->id,
+ 'contact_id' => $membership->contact_id,
+ 'is_test' => $membership->is_test,
+ 'membership_type_id' => $membership->membership_type_id,
+ );
- $currentMembership = CRM_Member_BAO_Membership::getContactMembership($membership->contact_id,
- $membership->membership_type_id,
- $membership->is_test, $membership->id
+ $currentMembership = CRM_Member_BAO_Membership::getContactMembership($membershipParams['contact_id'],
+ $membershipParams['membership_type_id'],
+ $membershipParams['is_test'],
+ $membershipParams['id']
);
// CRM-8141 update the membership type with the value recorded in log when membership created/renewed
$sql = "
SELECT membership_type_id
FROM civicrm_membership_log
-WHERE membership_id=$membership->id
+WHERE membership_id={$membershipParams['id']}
ORDER BY id DESC
LIMIT 1;";
- $dao = new CRM_Core_DAO();
- $dao->query($sql);
+ $dao = CRM_Core_DAO::executeQuery($sql);
if ($dao->fetch()) {
if (!empty($dao->membership_type_id)) {
- $membership->membership_type_id = $dao->membership_type_id;
- $membership->save();
+ $membershipParams['membership_type_id'] = $dao->membership_type_id;
}
- // else fall back to using current membership type
}
- // else fall back to using current membership type
$dao->free();
- $num_terms = $contribution->getNumTermsByContributionAndMembershipType($membership->membership_type_id, $primaryContributionID);
+ $membershipParams['num_terms'] = $contribution->getNumTermsByContributionAndMembershipType(
+ $membershipParams['membership_type_id'],
+ $primaryContributionID
+ );
+ $dates = array_fill_keys(array('join_date', 'start_date', 'end_date'), NULL);
if ($currentMembership) {
/*
* Fixed FOR CRM-4433
// @todo - we should pass membership_type_id instead of null here but not
// adding as not sure of testing
- $dates = CRM_Member_BAO_MembershipType::getRenewalDatesForMembershipType($membership->id,
- $changeDate, NULL, $num_terms
+ $dates = CRM_Member_BAO_MembershipType::getRenewalDatesForMembershipType($membershipParams['id'],
+ $changeDate, NULL, $membershipParams['num_terms']
);
- $dates['join_date'] = CRM_Utils_Date::customFormat($currentMembership['join_date'], $format);
- }
- else {
- $dates = CRM_Member_BAO_MembershipType::getDatesForMembershipType($membership->membership_type_id, NULL, NULL, NULL, $num_terms);
+ $dates['join_date'] = $currentMembership['join_date'];
}
//get the status for membership.
$dates['join_date'],
'today',
TRUE,
- $membership->membership_type_id,
- (array) $membership
+ $membershipParams['membership_type_id'],
+ $membershipParams
);
- $formatedParams = array(
- 'status_id' => CRM_Utils_Array::value('id', $calcStatus, 2),
- 'join_date' => CRM_Utils_Date::customFormat(CRM_Utils_Array::value('join_date', $dates), $format),
- 'start_date' => CRM_Utils_Date::customFormat(CRM_Utils_Array::value('start_date', $dates), $format),
- 'end_date' => CRM_Utils_Date::customFormat(CRM_Utils_Array::value('end_date', $dates), $format),
- );
+ $membershipParams['status_id'] = CRM_Utils_Array::value('id', $calcStatus, 'New');
//we might be renewing membership,
//so make status override false.
- $formatedParams['is_override'] = FALSE;
- $membership->copyValues($formatedParams);
- $membership->save();
-
- //updating the membership log
- $membershipLog = array();
- $membershipLog = $formatedParams;
-
- $logStartDate = $formatedParams['start_date'];
- if (!empty($dates['log_start_date'])) {
- $logStartDate = CRM_Utils_Date::customFormat($dates['log_start_date'], $format);
- $logStartDate = CRM_Utils_Date::isoToMysql($logStartDate);
- }
-
- $membershipLog['start_date'] = $logStartDate;
- $membershipLog['membership_id'] = $membership->id;
- $membershipLog['modified_id'] = $membership->contact_id;
- $membershipLog['modified_date'] = date('Ymd');
- $membershipLog['membership_type_id'] = $membership->membership_type_id;
-
- CRM_Member_BAO_MembershipLog::add($membershipLog, CRM_Core_DAO::$_nullArray);
+ $membershipParams['is_override'] = FALSE;
+ civicrm_api3('Membership', 'create', $membershipParams);
//update related Memberships.
- CRM_Member_BAO_Membership::updateRelatedMemberships($membership->id, $formatedParams);
-
- //update the membership type key of membership relatedObjects array
- //if it has changed after membership update
- if ($membershipTypeIdKey != $membership->membership_type_id) {
- $membershipsUpdate[$membership->membership_type_id] = $membership;
- $contribution->_relatedObjects['membership'][$membership->membership_type_id] = $membership;
- unset($contribution->_relatedObjects['membership'][$membershipTypeIdKey]);
- unset($memberships[$membershipTypeIdKey]);
- }
+ CRM_Member_BAO_Membership::updateRelatedMemberships($membership->id, $membershipParams);
}
}
- //update the memberships object with updated membershipTypeId data
- //if membershipTypeId has changed after membership update
- if (!empty($membershipsUpdate)) {
- $memberships = $memberships + $membershipsUpdate;
- }
}
}
else {
- // event
- $eventParams = array('id' => $objects['event']->id);
- $values['event'] = array();
-
- CRM_Event_BAO_Event::retrieve($eventParams, $values['event']);
-
- //get location details
- $locationParams = array('entity_id' => $objects['event']->id, 'entity_table' => 'civicrm_event');
- $values['location'] = CRM_Core_BAO_Location::getValues($locationParams);
-
- $ufJoinParams = array(
- 'entity_table' => 'civicrm_event',
- 'entity_id' => $ids['event'],
- 'module' => 'CiviEvent',
- );
-
- list($custom_pre_id,
- $custom_post_ids
- ) = CRM_Core_BAO_UFJoin::getUFGroupIds($ufJoinParams);
+ if (empty($input['IAmAHorribleNastyBeyondExcusableHackInTheCRMEventFORMTaskClassThatNeedsToBERemoved'])) {
+ $eventDetail = civicrm_api3('Event', 'getsingle', array('id' => $objects['event']->id));
+ $contributionParams['source'] = ts('Online Event Registration') . ': ' . $eventDetail['title'];
- $values['custom_pre_id'] = $custom_pre_id;
- $values['custom_post_id'] = $custom_post_ids;
- //for tasks 'Change Participant Status' and 'Batch Update Participants Via Profile' case
- //and cases involving status updation through ipn
- $values['totalAmount'] = $input['amount'];
-
- $contribution->source = ts('Online Event Registration') . ': ' . $values['event']['title'];
-
- if ($values['event']['is_email_confirm']) {
- $contribution->receipt_date = $changeDate;
- $values['is_email_receipt'] = 1;
- }
- if (empty($input['skipComponentSync'])) {
- $participantStatuses = CRM_Core_PseudoConstant::get('CRM_Event_DAO_Participant', 'status_id', array(
- 'labelColumn' => 'name',
- 'flip' => 1,
- ));
- $participant->status_id = $participantStatuses['Registered'];
- }
- $participant->save();
- }
-
- if (CRM_Utils_Array::value('net_amount', $input, 0) == 0 &&
- CRM_Utils_Array::value('fee_amount', $input, 0) != 0
- ) {
- $input['net_amount'] = $input['amount'] - $input['fee_amount'];
- }
- // This complete transaction function is being overloaded to create new contributions too.
- // here we record if it is a new contribution.
- // @todo separate the 2 more appropriately.
- $isNewContribution = FALSE;
- if (empty($contribution->id)) {
- $isNewContribution = TRUE;
- if (!empty($input['amount']) && $input['amount'] != $contribution->total_amount) {
- $contribution->total_amount = $input['amount'];
- // The BAO does this stuff but we are actually kinda bypassing it here (bad code! go sit in the corner)
- // so we have to handle net_amount in this (naughty) code.
- if (isset($input['fee_amount']) && is_numeric($input['fee_amount'])) {
- $contribution->fee_amount = $input['fee_amount'];
+ if ($eventDetail['is_email_confirm']) {
+ // @todo this should be set by the function that sends the mail after sending.
+ $contributionParams['receipt_date'] = $changeDate;
}
- $contribution->net_amount = $contribution->total_amount - $contribution->fee_amount;
+ $participantParams['id'] = $participant->id;
+ $participantParams['status_id'] = 'Registered';
+ civicrm_api3('Participant', 'create', $participantParams);
}
- if (!empty($input['campaign_id'])) {
- $contribution->campaign_id = $input['campaign_id'];
- }
- }
-
- $contributionStatuses = CRM_Core_PseudoConstant::get('CRM_Contribute_DAO_Contribution', 'contribution_status_id', array(
- 'labelColumn' => 'name',
- 'flip' => 1,
- ));
-
- // @todo this section should call the api in order to have hooks called &
- // because all this 'messiness' setting variables could be avoided
- // by letting the api resolve pseudoconstants & copy set values and format dates.
- $contribution->contribution_status_id = $contributionStatuses['Completed'];
- $contribution->is_test = $input['is_test'];
-
- // CRM-15960 If we don't have a value we 'want' for the amounts, leave it to the BAO to sort out.
- if (isset($input['net_amount'])) {
- $contribution->fee_amount = CRM_Utils_Array::value('fee_amount', $input, 0);
- }
- if (isset($input['net_amount'])) {
- $contribution->net_amount = $input['net_amount'];
- }
-
- $contribution->trxn_id = $input['trxn_id'];
- $contribution->receive_date = CRM_Utils_Date::isoToMysql($contribution->receive_date);
- $contribution->thankyou_date = CRM_Utils_Date::isoToMysql($contribution->thankyou_date);
- $contribution->receipt_date = CRM_Utils_Date::isoToMysql($contribution->receipt_date);
- $contribution->cancel_date = 'null';
-
- if (!empty($input['check_number'])) {
- $contribution->check_number = $input['check_number'];
- }
-
- if (!empty($input['payment_instrument_id'])) {
- $contribution->payment_instrument_id = $input['payment_instrument_id'];
}
- if (!empty($contribution->id)) {
- $input['prevContribution'] = CRM_Contribute_BAO_Contribution::getValues(array('id' => $contribution->id),
- CRM_Core_DAO::$_nullArray, CRM_Core_DAO::$_nullArray);
- }
+ $contributionParams['id'] = $contribution->id;
- $contribution->save();
+ civicrm_api3('Contribution', 'create', $contributionParams);
// Add new soft credit against current $contribution.
if (CRM_Utils_Array::value('contributionRecur', $objects) && $objects['contributionRecur']->id) {
CRM_Contribute_BAO_ContributionRecur::addrecurSoftCredit($objects['contributionRecur']->id, $contribution->id);
}
- //add line items for recurring payments
- if (!empty($contribution->contribution_recur_id)) {
- if ($isNewContribution) {
- $input['line_item'] = CRM_Contribute_BAO_ContributionRecur::addRecurLineItems($contribution->contribution_recur_id, $contribution);
- }
- else {
- // this is just to prevent e-notices when we call recordFinancialAccounts - per comments on that line - intention is somewhat unclear
- $input['line_item'] = array();
- }
- }
-
- //copy initial contribution custom fields for recurring contributions
- if ($recurContrib && $recurContrib->id) {
- CRM_Contribute_BAO_ContributionRecur::copyCustomValues($recurContrib->id, $contribution->id);
- }
-
$paymentProcessorId = '';
if (isset($objects['paymentProcessor'])) {
if (is_array($objects['paymentProcessor'])) {
if (!array_key_exists('is_email_receipt', $values) ||
$values['is_email_receipt'] == 1
) {
- self::sendMail($input, $ids, $objects, $values, $recur, FALSE);
+ self::sendMail($input, $ids, $objects['contribution'], $values, $recur, FALSE);
CRM_Core_Error::debug_log_message("Receipt sent");
}
* Incoming data from Payment processor.
* @param array $ids
* Related object IDs.
- * @param $objects
+ * @param CRM_Contribute_BAO_Contribution $contribution
* @param array $values
* Values related to objects that have already been loaded.
* @param bool $recur
*
* @return array
*/
- public static function sendMail(&$input, &$ids, &$objects, &$values, $recur = FALSE, $returnMessageText = FALSE) {
- $contribution = &$objects['contribution'];
+ public static function sendMail(&$input, &$ids, $contribution, &$values, $recur = FALSE, $returnMessageText = FALSE) {
$input['is_recur'] = $recur;
// set receipt from e-mail and name in value
if (!$returnMessageText) {
);
$this->add('select', 'payment_instrument_id',
- ts('Paid By'),
+ ts('Payment Method'),
array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::paymentInstrument(),
TRUE, array('onChange' => "return showHideByValue('payment_instrument_id','4','checkNumber','table-row','select',false);")
);
$this->add('textarea', 'receipt_text', ts('Confirmation Message'));
// add various dates
- $dateLabel = ($this->_refund) ? ts('Refund Date') : ts('Received Date');
+ $dateLabel = ($this->_refund) ? ts('Refund Date') : ts('Date Received');
$this->addDateTime('trxn_date', $dateLabel, FALSE, array('formatType' => 'activityDateTime'));
if ($this->_contactId && $this->_id) {
*/
public $_priceSet;
- /**
- * Form defaults
- * @todo can we define this a as protected? can we define higher up the chain
- * @var array
- */
- public $_defaults;
-
/**
* User display name
*
$paymentInstrument = FALSE;
if (!$this->_mode) {
$paymentInstrument = $this->add('select', 'payment_instrument_id',
- ts('Paid By'),
+ ts('Payment Method'),
array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::paymentInstrument(),
TRUE, array('onChange' => "return showHideByValue('payment_instrument_id','4','checkNumber','table-row','select',false);")
);
* Line items specifically relating to memberships.
* @param bool $isPayLater
*/
- public function processMembership($membershipParams, $contactID, $customFieldsFormatted, $fieldTypes, $premiumParams, $membershipLineItems, $isPayLater) {
- try {
- $membershipTypeIDs = (array) $membershipParams['selectMembership'];
- $membershipTypes = CRM_Member_BAO_Membership::buildMembershipTypeValues($this, $membershipTypeIDs);
- $membershipType = empty($membershipTypes) ? array() : reset($membershipTypes);
- $isPending = $this->getIsPending();
+ protected function processMembership($membershipParams, $contactID, $customFieldsFormatted, $fieldTypes, $premiumParams,
+ $membershipLineItems, $isPayLater) {
- $this->assign('membership_name', CRM_Utils_Array::value('name', $membershipType));
+ $membershipTypeIDs = (array) $membershipParams['selectMembership'];
+ $membershipTypes = CRM_Member_BAO_Membership::buildMembershipTypeValues($this, $membershipTypeIDs);
+ $membershipType = empty($membershipTypes) ? array() : reset($membershipTypes);
+ $isPending = $this->getIsPending();
- $isPaidMembership = FALSE;
- if ($this->_amount >= 0.0 && isset($membershipParams['amount'])) {
- //amount must be greater than zero for
- //adding contribution record to contribution table.
- //this condition arises when separate membership payment is
- //enabled and contribution amount is not selected. fix for CRM-3010
- $isPaidMembership = TRUE;
- }
- $isProcessSeparateMembershipTransaction = $this->isSeparateMembershipTransaction($this->_id, $this->_values['amount_block_is_active']);
-
- if ($this->_values['amount_block_is_active']) {
- $financialTypeID = $this->_values['financial_type_id'];
- }
- else {
- $financialTypeID = CRM_Utils_Array::value('financial_type_id', $membershipType, CRM_Utils_Array::value('financial_type_id', $membershipParams));
- }
-
- if (CRM_Utils_Array::value('membership_source', $this->_params)) {
- $membershipParams['contribution_source'] = $this->_params['membership_source'];
- }
+ $this->assign('membership_name', CRM_Utils_Array::value('name', $membershipType));
- $this->postProcessMembership($membershipParams, $contactID,
- $this, $premiumParams, $customFieldsFormatted, $fieldTypes, $membershipType, $membershipTypeIDs, $isPaidMembership, $this->_membershipId, $isProcessSeparateMembershipTransaction, $financialTypeID,
- $membershipLineItems, $isPayLater, $isPending);
+ $isPaidMembership = FALSE;
+ if ($this->_amount >= 0.0 && isset($membershipParams['amount'])) {
+ //amount must be greater than zero for
+ //adding contribution record to contribution table.
+ //this condition arises when separate membership payment is
+ //enabled and contribution amount is not selected. fix for CRM-3010
+ $isPaidMembership = TRUE;
+ }
+ $isProcessSeparateMembershipTransaction = $this->isSeparateMembershipTransaction($this->_id, $this->_values['amount_block_is_active']);
- $this->assign('membership_assign', TRUE);
- $this->set('membershipTypeID', $membershipParams['selectMembership']);
+ if ($this->_values['amount_block_is_active']) {
+ $financialTypeID = $this->_values['financial_type_id'];
+ }
+ else {
+ $financialTypeID = CRM_Utils_Array::value('financial_type_id', $membershipType, CRM_Utils_Array::value('financial_type_id', $membershipParams));
}
- catch (CRM_Core_Exception $e) {
- CRM_Core_Session::singleton()->setStatus($e->getMessage());
- CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/contribute/transact', "_qf_Main_display=true&qfKey={$this->_params['qfKey']}"));
+
+ if (CRM_Utils_Array::value('membership_source', $this->_params)) {
+ $membershipParams['contribution_source'] = $this->_params['membership_source'];
}
+
+ $this->postProcessMembership($membershipParams, $contactID,
+ $this, $premiumParams, $customFieldsFormatted, $fieldTypes, $membershipType, $membershipTypeIDs, $isPaidMembership, $this->_membershipId, $isProcessSeparateMembershipTransaction, $financialTypeID,
+ $membershipLineItems, $isPayLater, $isPending);
+
+ $this->assign('membership_assign', TRUE);
+ $this->set('membershipTypeID', $membershipParams['selectMembership']);
}
/**
$form->postProcessHook();
}
$payment = Civi\Payment\System::singleton()->getByProcessor($form->_paymentProcessor);
- $result = $payment->doPayment($form->_params, 'contribute');
+ $paymentActionResult = $payment->doPayment($form->_params, 'contribute');
- if (CRM_Utils_Array::value('payment_status_id', $result) == 1) {
+ if (CRM_Utils_Array::value('payment_status_id', $paymentActionResult) == 1) {
// Refer to CRM-16737. Payment processors 'should' return payment_status_id
// to denote the outcome of the transaction.
try {
civicrm_api3('contribution', 'completetransaction', array(
'id' => $paymentResult['contribution']->id,
- 'trxn_id' => $paymentResult['contribution']->trxn_id,
+ 'trxn_id' => CRM_Utils_Array::value('trxn_id', $paymentActionResult, $paymentResult['contribution']->trxn_id),
'is_transactional' => FALSE,
'payment_processor_id' => $form->_paymentProcessor['id'],
));
}
catch (CiviCRM_API3_Exception $e) {
- // if for any reason it is already completed this will fail - e.g extensions hacking around core not completing transactions prior to CRM-15296
- // so let's be gentle here
- CRM_Core_Error::debug_log_message('contribution ' . $membershipContribution->id . ' not completed with trxn_id ' . $membershipContribution->trxn_id . ' and message ' . $e->getMessage());
+ if ($e->getErrorCode() != 'contribution_completed') {
+ throw new CRM_Core_Exception('Failed to update contribution in database');
+ }
}
}
// Do not send an email if Recurring transaction is done via Direct Mode
// @todo move premium processing to complete transaction if it truly is an 'after' action.
$this->postProcessPremium($premiumParams, $result['contribution']);
if (CRM_Utils_Array::value('payment_status_id', $result) == 1) {
- civicrm_api3('contribution', 'completetransaction', array(
- 'id' => $result['contribution']->id,
- 'trxn_id' => CRM_Utils_Array::value('trxn_id', $result),
- 'payment_processor_id' => $this->_paymentProcessor['id'],
- )
- );
+ try {
+ civicrm_api3('contribution', 'completetransaction', array(
+ 'id' => $result['contribution']->id,
+ 'trxn_id' => CRM_Utils_Array::value('trxn_id', $result),
+ 'payment_processor_id' => $this->_paymentProcessor['id'],
+ 'is_transactional' => FALSE,
+ )
+ );
+ }
+ catch (CiviCRM_API3_Exception $e) {
+ if ($e->getErrorCode() != 'contribution_completed') {
+ throw new CRM_Core_Exception('Failed to update contribution in database');
+ }
+ }
+
}
return $result;
}
}
}
}
- $this->processMembership($membershipParams, $contactID, $customFieldsFormatted, $fieldTypes, $premiumParams, $membershipLineItems, $isPayLater);
+ try {
+ $this->processMembership($membershipParams, $contactID, $customFieldsFormatted, $fieldTypes, $premiumParams, $membershipLineItems, $isPayLater);
+ }
+ catch (CRM_Core_Exception $e) {
+ CRM_Core_Session::singleton()->setStatus($e->getMessage());
+ CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/contribute/transact', "_qf_Main_display=true&qfKey={$this->_params['qfKey']}"));
+ }
if (!$this->_amount > 0.0 || !$membershipParams['amount']) {
// we need to explicitly create a CMS user in case of free memberships
// since it is done under processConfirm for paid memberships
public $_onBehalfRequired = FALSE;
public $_onbehalf = FALSE;
public $_paymentProcessors;
- protected $_defaults;
public $_membershipTypeValues;
* @var bool
*/
protected $_separateMembershipPayment;
- /**
- * The default values for the form
- *
- * @var array
- */
- protected $_defaults;
/**
* The params submitted by the form and computed by the app
*/
protected $_limit = NULL;
- protected $_defaults;
-
/**
* Prefix for the controller.
*/
);
}
- $this->_queryParams = CRM_Contact_BAO_Query::convertFormValues($this->_formValues, 1);
+ $this->_queryParams = CRM_Contact_BAO_Query::convertFormValues($this->_formValues);
$selector = new CRM_Contribute_Selector_Search($this->_queryParams,
$this->_action,
NULL,
}
}
- CRM_Core_BAO_CustomValue::fixFieldValueOfTypeMemo($this->_formValues);
+ CRM_Core_BAO_CustomValue::fixCustomFieldValue($this->_formValues);
$this->_queryParams = CRM_Contact_BAO_Query::convertFormValues($this->_formValues);
'contribution_recur_id' => ts('Contact and Recurring'),
'financial_type_id' => ts('Contact and Financial Type'),
'campaign_id' => ts('Contact and Campaign'),
- 'payment_instrument_id' => 'Contact and Payment Instrument',
+ 'payment_instrument_id' => ts('Contact and Payment Method'),
);
$this->addElement('select', 'group_by', ts('Group contributions by'), $options, array(), "<br/>", FALSE);
// this was going to be free-text but I opted for radio options in case there was a script injection risk
$this->add("text", "check_number_{$row['contribution_id']}", ts('Check Number'));
$defaults["check_number_{$row['contribution_id']}"] = $dao->check_no;
- $this->add("select", "payment_instrument_id_{$row['contribution_id']}", ts('Paid By'), $paidByOptions);
+ $this->add("select", "payment_instrument_id_{$row['contribution_id']}", ts('Payment Method'), $paidByOptions);
$defaults["payment_instrument_id_{$row['contribution_id']}"] = $dao->paid_by;
$this->_rows[] = $row;
$contribID = substr($name, 13);
if ($fields["payment_instrument_id_{$contribID}"] != CRM_Core_OptionGroup::getValue('payment_instrument', 'Check', 'name')) {
- $errors["payment_instrument_id_{$contribID}"] = ts("Paid By should be Check when a check number is entered for a contribution.");
+ $errors["payment_instrument_id_{$contribID}"] = ts("Payment Method should be Check when a check number is entered for a contribution.");
}
}
}
}
$input['trxn_date'] = CRM_Utils_Date::processDate($params["trxn_date_{$row['contribution_id']}"]);
+ // @todo calling baseIPN like this is a pattern in it's last gasps. Call contribute.completetransaction api.
$baseIPN->completeTransaction($input, $ids, $objects, $transaction, FALSE);
// reset template values before processing next transactions
$checkCid->external_identifier = $paramValues['external_identifier'];
$checkCid->find(TRUE);
if ($checkCid->id != $formatted['contact_id']) {
- array_unshift($values, 'Mismatch of External identifier :' . $paramValues['external_identifier'] . ' and Contact Id:' . $formatted['contact_id']);
+ array_unshift($values, 'Mismatch of External ID:' . $paramValues['external_identifier'] . ' and Contact Id:' . $formatted['contact_id']);
return CRM_Import_Parser::ERROR;
}
}
</item>
<item>
<path>civicrm/admin/options/payment_instrument</path>
- <title>Payment Instruments</title>
+ <title>Payment Methods</title>
<page_callback>CRM_Admin_Page_Options</page_callback>
<desc>You may choose to record the payment instrument used for each contribution. Common payment methods are installed by default (e.g. Check, Cash, Credit Card...). If your site requires additional payment methods, add them here.</desc>
<adminGroup>CiviContribute</adminGroup>
}
$v = array();
- $p = array();
foreach ($checkedData as $key => $val) {
- if ($html_type == 'CheckBox') {
- if ($val) {
- $p[] = $key;
- $v[] = CRM_Utils_Array::value($key, $option);
- }
- }
- else {
- $p[] = $val;
- $v[] = CRM_Utils_Array::value($val, $option);
- }
+ $v[] = CRM_Utils_Array::value($val, $option);
}
if (!empty($v)) {
$display = implode(', ', $v);
$op = key($value);
$qillValue = CRM_Core_BAO_CustomField::getDisplayValue($value[$op], $id, $this->_options);
}
+ else {
+ $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);
if (strstr($op, 'NULL') || strstr($op, 'EMPTY')) {
$qillValue = $value = NULL;
}
- elseif ($isSerialized && strstr($op, 'IN')) {
+ elseif ($isSerialized) {
+ if (in_array(key($value), CRM_Core_DAO::acceptedSQLOperators(), TRUE)) {
+ $op = key($value);
+ $value = $value[$op];
+ }
$value = implode(',', $value);
}
// CRM-14563,CRM-16575 : Special handling of multi-select custom fields
- if (!empty($value)) {
- if ($isSerialized) {
- if (strstr($op, 'IN')) {
- $value = str_replace(array('(', ')'), '', str_replace(",", "[[:cntrl:]]|[[:cntrl:]]", $value));
- }
- $op = (strstr($op, '!') || strstr($op, 'NOT')) ? 'NOT RLIKE' : 'RLIKE';
- $value = "[[:cntrl:]]" . $value . "[[:cntrl:]]";
+ if ($isSerialized && !empty($value)) {
+ if (strstr($op, 'IN')) {
+ $value = str_replace(array('(', ')'), '', str_replace(",", "[[:cntrl:]]|[[:cntrl:]]", $value));
}
- elseif ($wildcard) {
- $value = "[[:cntrl:]]%$value%[[:cntrl:]]";
- $op = 'LIKE';
+ $op = (strstr($op, '!') || strstr($op, 'NOT')) ? 'NOT RLIKE' : 'RLIKE';
+ $value = "[[:cntrl:]]" . $value . "[[:cntrl:]]";
+ if (!$wildcard) {
+ $value = str_replace("[[:cntrl:]]|", '', $value);
}
}
* @param array $formValues
* @return null
*/
- public static function fixFieldValueOfTypeMemo(&$formValues) {
+ public static function fixCustomFieldValue(&$formValues) {
if (empty($formValues)) {
return NULL;
}
$htmlType = CRM_Core_DAO::getFieldValue('CRM_Core_BAO_CustomField',
substr($key, 7), 'html_type'
);
- if (($htmlType == 'TextArea') &&
+ $dataType = CRM_Core_DAO::getFieldValue('CRM_Core_BAO_CustomField',
+ substr($key, 7), 'data_type'
+ );
+
+ if (is_array($formValues[$key])) {
+ if (!in_array(key($formValues[$key]), CRM_Core_DAO::acceptedSQLOperators(), TRUE)) {
+ $formValues[$key] = array('IN' => $formValues[$key]);
+ }
+ }
+ elseif (($htmlType == 'TextArea' ||
+ ($htmlType == 'Text' && $dataType == 'String')
+ ) &&
!((substr($formValues[$key], 0, 1) == '%') ||
(substr($formValues[$key], -1, 1) == '%')
)
) {
- $formValues[$key] = '%' . $formValues[$key] . '%';
+ $formValues[$key] = array('LIKE' => '%' . $formValues[$key] . '%');
}
-
}
}
),
'receive_date' => array(
'name' => 'receive_date',
- 'title' => ts('Receive Date'),
+ 'title' => ts('Date Received'),
),
'payment_instrument' => array(
'name' => 'payment_instrument',
- 'title' => ts('Payment Instrument'),
+ 'title' => ts('Payment Method'),
),
'contribution_status_id' => array(
'name' => 'contribution_status_id',
$value['url'] = CRM_Utils_System::url($short['path'], $short['query'], FALSE);
}
$value['title'] = $short['title'];
- $value['ref'] = $short['ref'];
+ $value['ref'] = isset($short['ref']) ? $short['ref'] : '';
if (!empty($short['shortCuts'])) {
foreach ($short['shortCuts'] as $shortCut) {
$value['shortCuts'][] = self::setShortcutValues($shortCut);
*/
public function setWord($fileName = NULL) {
//Mark as a CSV file.
- header('Content-Type: application/vnd.ms-word');
+ CRM_Utils_System::setHttpHeader('Content-Type', 'application/vnd.ms-word');
//Force a download and name the file using the current timestamp.
if (!$fileName) {
$fileName = 'Contacts_' . $_SERVER['REQUEST_TIME'] . '.doc';
}
- header("Content-Disposition: attachment; filename=Contacts_$fileName");
+ CRM_Utils_System::setHttpHeader("Content-Disposition", "attachment; filename=Contacts_$fileName");
}
/**
*/
public function setExcel($fileName = NULL) {
//Mark as an excel file.
- header('Content-Type: application/vnd.ms-excel');
+ CRM_Utils_System::setHttpHeader('Content-Type', 'application/vnd.ms-excel');
//Force a download and name the file using the current timestamp.
if (!$fileName) {
$fileName = 'Contacts_' . $_SERVER['REQUEST_TIME'] . '.xls';
}
- header("Content-Disposition: attachment; filename=Contacts_$fileName");
+ CRM_Utils_System::setHttpHeader("Content-Disposition", "attachment; filename=Contacts_$fileName");
}
/**
}
/**
- * Instead of outputting a fatal error message, we'll just redirect to the entryURL if present
+ * Instead of outputting a fatal error message, we'll just redirect
+ * to the entryURL if present
*
* @return void
*/
public function invalidKeyRedirect() {
- if ($this->_entryURL) {
- CRM_Core_Session::setStatus(ts('Your browser session has expired and we are unable to complete your form submission. We have returned you to the initial step so you can complete and resubmit the form. If you experience continued difficulties, please contact us for assistance.'));
- return CRM_Utils_System::redirect($this->_entryURL);
- }
- else {
- self::invalidKeyCommon();
+ if ($this->_entryURL && $url_parts = parse_url($this->_entryURL)) {
+ // CRM-16832: Ensure local redirects only.
+ if (!empty($url_parts['path'])) {
+ // Prepend a slash, but don't duplicate it.
+ $redirect_url = '/' . ltrim($url_parts['path'], '/');
+ if (!empty($url_parts['query'])) {
+ $redirect_url .= '?' . $url_parts['query'];
+ }
+ CRM_Core_Session::setStatus(ts('Your browser session has expired and we are unable to complete your form submission. We have returned you to the initial step so you can complete and resubmit the form. If you experience continued difficulties, please contact us for assistance.'));
+ return CRM_Utils_System::redirect($redirect_url);
+ }
}
+ self::invalidKeyCommon();
}
}
),
);
+ // CRM-16963 - Permissions for country.
+ $permissions['country'] = array(
+ 'get' => array(
+ 'access CiviCRM',
+ ),
+ 'default' => array(
+ 'administer CiviCRM',
+ ),
+ );
+
// Contact-related data permissions.
// CRM-14094 - Users can edit and delete contact-related objects using inline edit with 'edit all contacts' permission
$permissions['address'] = array(
),
'delete' => array(
'access CiviCRM',
- 'delete contacts',
+ 'edit all contacts',
),
'default' => array(
'access CiviCRM',
*/
protected $_title = NULL;
+ /**
+ * The default values for the form.
+ *
+ * @var array
+ */
+ public $_defaults = array();
+
/**
* The options passed into this form
* @var mixed
$options = $props['options'];
}
else {
- $info = civicrm_api3($props['entity'], 'getoptions', $props + array('check_permissions' => 1));
+ $info = civicrm_api3($props['entity'], 'getoptions', $props);
$options = $info['values'];
}
if (!array_key_exists('placeholder', $props)) {
*
* @return NULL|int
*/
- public function getContactID() {
+ protected function setContactID() {
$tempID = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
if (isset($this->_params) && isset($this->_params['select_contact_id'])) {
$tempID = $this->_params['select_contact_id'];
return is_numeric($userID) ? $userID : NULL;
}
+ public function getContactID() {
+ return $this->setContactID();
+ }
+
/**
* Get the contact id of the logged in user.
*/
--- /dev/null
+<?php
+/*
++--------------------------------------------------------------------+
+| CiviCRM version 4.6 |
++--------------------------------------------------------------------+
+| Copyright CiviCRM LLC (c) 2004-2015 |
++--------------------------------------------------------------------+
+| This file is a part of CiviCRM. |
+| |
+| CiviCRM is free software; you can copy, modify, and distribute it |
+| under the terms of the GNU Affero General Public License |
+| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
+| |
+| CiviCRM is distributed in the hope that it will be useful, but |
+| WITHOUT ANY WARRANTY; without even the implied warranty of |
+| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
+| See the GNU Affero General Public License for more details. |
+| |
+| You should have received a copy of the GNU Affero General Public |
+| License and the CiviCRM Licensing Exception along |
+| with this program; if not, contact CiviCRM LLC |
+| at info[AT]civicrm[DOT]org. If you have questions about the |
+| GNU Affero General Public License or the licensing of CiviCRM, |
+| see the CiviCRM license FAQ at http://civicrm.org/licensing |
++--------------------------------------------------------------------+
+ */
+
+/**
+ *
+ * @package CRM
+ * @copyright CiviCRM LLC (c) 2004-2015
+ *
+ * Generated from schema_structure.tpl
+ * DO NOT EDIT. Generated by CRM_Core_CodeGen
+ */
+class CRM_Core_I18n_SchemaStructure_4_7_alpha1 {
+
+ /**
+ * Get column definition.
+ */
+ public static function &columns() {
+ static $result = NULL;
+ if (!$result) {
+ $result = array(
+ 'civicrm_location_type' => array(
+ 'display_name' => "varchar(64)",
+ ),
+ 'civicrm_option_group' => array(
+ 'title' => "varchar(255)",
+ 'description' => "varchar(255)",
+ ),
+ 'civicrm_contact_type' => array(
+ 'label' => "varchar(64)",
+ 'description' => "text",
+ ),
+ 'civicrm_batch' => array(
+ 'title' => "varchar(64)",
+ 'description' => "text",
+ ),
+ 'civicrm_premiums' => array(
+ 'premiums_intro_title' => "varchar(255)",
+ 'premiums_intro_text' => "text",
+ 'premiums_nothankyou_label' => "varchar(255)",
+ ),
+ 'civicrm_membership_status' => array(
+ 'label' => "varchar(128)",
+ ),
+ 'civicrm_survey' => array(
+ 'title' => "varchar(255)",
+ 'instructions' => "text",
+ 'thankyou_title' => "varchar(255)",
+ 'thankyou_text' => "text",
+ ),
+ 'civicrm_participant_status_type' => array(
+ 'label' => "varchar(255)",
+ ),
+ 'civicrm_case_type' => array(
+ 'title' => "varchar(64)",
+ 'description' => "varchar(255)",
+ ),
+ 'civicrm_tell_friend' => array(
+ 'title' => "varchar(255)",
+ 'intro' => "text",
+ 'suggested_message' => "text",
+ 'thankyou_title' => "varchar(255)",
+ 'thankyou_text' => "text",
+ ),
+ 'civicrm_custom_group' => array(
+ 'title' => "varchar(64)",
+ 'help_pre' => "text",
+ 'help_post' => "text",
+ ),
+ 'civicrm_custom_field' => array(
+ 'label' => "varchar(255)",
+ 'help_pre' => "text",
+ 'help_post' => "text",
+ ),
+ 'civicrm_option_value' => array(
+ 'label' => "varchar(255)",
+ 'description' => "text",
+ ),
+ 'civicrm_group' => array(
+ 'title' => "varchar(64)",
+ ),
+ 'civicrm_contribution_page' => array(
+ 'title' => "varchar(255)",
+ 'intro_text' => "text",
+ 'pay_later_text' => "text",
+ 'pay_later_receipt' => "text",
+ 'initial_amount_label' => "varchar(255)",
+ 'initial_amount_help_text' => "text",
+ 'thankyou_title' => "varchar(255)",
+ 'thankyou_text' => "text",
+ 'thankyou_footer' => "text",
+ 'for_organization' => "text",
+ 'receipt_from_name' => "varchar(255)",
+ 'receipt_text' => "text",
+ 'footer_text' => "text",
+ ),
+ 'civicrm_product' => array(
+ 'name' => "varchar(255)",
+ 'description' => "text",
+ 'options' => "text",
+ ),
+ 'civicrm_membership_type' => array(
+ 'name' => "varchar(128)",
+ 'description' => "varchar(255)",
+ ),
+ 'civicrm_membership_block' => array(
+ 'new_title' => "varchar(255)",
+ 'new_text' => "text",
+ 'renewal_title' => "varchar(255)",
+ 'renewal_text' => "text",
+ ),
+ 'civicrm_price_set' => array(
+ 'title' => "varchar(255)",
+ 'help_pre' => "text",
+ 'help_post' => "text",
+ ),
+ 'civicrm_dashboard' => array(
+ 'label' => "varchar(255)",
+ ),
+ 'civicrm_uf_group' => array(
+ 'title' => "varchar(64)",
+ 'help_pre' => "text",
+ 'help_post' => "text",
+ ),
+ 'civicrm_uf_field' => array(
+ 'help_post' => "text",
+ 'help_pre' => "text",
+ 'label' => "varchar(255)",
+ ),
+ 'civicrm_price_field' => array(
+ 'label' => "varchar(255)",
+ 'help_pre' => "text",
+ 'help_post' => "text",
+ ),
+ 'civicrm_price_field_value' => array(
+ 'label' => "varchar(255)",
+ 'description' => "text",
+ ),
+ 'civicrm_pcp_block' => array(
+ 'link_text' => "varchar(255)",
+ ),
+ 'civicrm_event' => array(
+ 'title' => "varchar(255)",
+ 'summary' => "text",
+ 'description' => "text",
+ 'registration_link_text' => "varchar(255)",
+ 'event_full_text' => "text",
+ 'fee_label' => "varchar(255)",
+ 'intro_text' => "text",
+ 'footer_text' => "text",
+ 'confirm_title' => "varchar(255)",
+ 'confirm_text' => "text",
+ 'confirm_footer_text' => "text",
+ 'confirm_email_text' => "text",
+ 'confirm_from_name' => "varchar(255)",
+ 'thankyou_title' => "varchar(255)",
+ 'thankyou_text' => "text",
+ 'thankyou_footer_text' => "text",
+ 'pay_later_text' => "text",
+ 'pay_later_receipt' => "text",
+ 'initial_amount_label' => "varchar(255)",
+ 'initial_amount_help_text' => "text",
+ 'waitlist_text' => "text",
+ 'approval_req_text' => "text",
+ 'template_title' => "varchar(255)",
+ ),
+ 'civicrm_relationship_type' => array(
+ 'label_a_b' => "varchar(64)",
+ 'label_b_a' => "varchar(64)",
+ 'description' => "varchar(255)",
+ ),
+ );
+ }
+ return $result;
+ }
+
+ /**
+ * Get indices.
+ *
+ * @return array
+ */
+ public static function &indices() {
+ static $result = NULL;
+ if (!$result) {
+ $result = array(
+ 'civicrm_custom_group' => array(
+ 'UI_title_extends' => array(
+ 'name' => 'UI_title_extends',
+ 'field' => array(
+ 'title',
+ 'extends',
+ ),
+ 'unique' => 1,
+ ),
+ ),
+ 'civicrm_custom_field' => array(
+ 'UI_label_custom_group_id' => array(
+ 'name' => 'UI_label_custom_group_id',
+ 'field' => array(
+ 'label',
+ 'custom_group_id',
+ ),
+ 'unique' => 1,
+ ),
+ ),
+ 'civicrm_group' => array(
+ 'UI_title' => array(
+ 'name' => 'UI_title',
+ 'field' => array(
+ 'title',
+ ),
+ 'unique' => 1,
+ ),
+ ),
+ );
+ }
+ return $result;
+ }
+
+ /**
+ * Get tables.
+ *
+ * @return array
+ */
+ public static function &tables() {
+ static $result = NULL;
+ if (!$result) {
+ $result = array_keys(self::columns());
+ }
+ return $result;
+ }
+
+}
$nameTitle = array(
'payment_instrument' => array(
'name' => 'payment_instrument',
- 'title' => ts('Payment Instrument'),
+ 'title' => ts('Payment Method'),
'headerPattern' => '/^payment|(p(ayment\s)?instrument)$/i',
),
);
// CRM-11831 @see http://www.malsup.com/jquery/form/#file-upload
if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest') {
- header('Content-Type: application/json');
+ CRM_Utils_System::setHttpHeader('Content-Type', 'application/json');
}
else {
$output = "<textarea>$output</textarea>";
// Encourage browsers to cache for a long time - 1 year
$ttl = 60 * 60 * 24 * 364;
}
- header('Expires: ' . gmdate('D, d M Y H:i:s \G\M\T', time() + $ttl));
- header('Content-Type: application/javascript');
- header("Cache-Control: max-age=$ttl, public");
+ CRM_Utils_System::setHttpHeader('Expires', gmdate('D, d M Y H:i:s \G\M\T', time() + $ttl));
+ CRM_Utils_System::setHttpHeader('Content-Type', 'application/javascript');
+ CRM_Utils_System::setHttpHeader('Cache-Control', "max-age=$ttl, public");
}
}
if ($isError) {
$sapi_type = php_sapi_name();
if (substr($sapi_type, 0, 3) == 'cgi') {
- header("Status: 500 Internal Server Error");
+ CRM_Utils_System::setHttpHeader("Status", "500 Internal Server Error");
}
else {
header("HTTP/1.1 500 Internal Server Error");
*/
protected $_inputParameters = array();
+ /**
+ * Only used by AuthorizeNetIPN.
+ *
+ * @deprecated
+ *
+ * @var bool
+ */
protected $_isRecurring = FALSE;
+ /**
+ * Only used by AuthorizeNetIPN.
+ *
+ * @deprecated
+ *
+ * @var bool
+ */
protected $_isFirstOrLastRecurringPayment = FALSE;
/**
$objects['contribution'] = &$contribution;
}
try {
- $success = $contribution->loadRelatedObjects($input, $ids, $required);
+ $success = $contribution->loadRelatedObjects($input, $ids);
+ if ($required && empty($contribution->_relatedObjects['paymentProcessor'])) {
+ throw new CRM_Core_Exception("Could not find payment processor for contribution record: " . $contribution->id);
+ }
}
catch (Exception $e) {
$success = FALSE;
CRM_Contribute_BAO_ContributionRecur::copyCustomValues($objects['contributionRecur']->id, $contribution->id);
}
- if (empty($input['skipComponentSync'])) {
+ if (empty($input['IAmAHorribleNastyBeyondExcusableHackInTheCRMEventFORMTaskClassThatNeedsToBERemoved'])) {
if (!empty($memberships)) {
// if transaction is failed then set "Cancelled" as membership status
$membershipStatuses = CRM_Core_PseudoConstant::get('CRM_Member_DAO_Membership', 'status_id', array(
CRM_Contribute_BAO_ContributionRecur::copyCustomValues($objects['contributionRecur']->id, $contribution->id);
}
- if (empty($input['skipComponentSync'])) {
+ if (empty($input['IAmAHorribleNastyBeyondExcusableHackInTheCRMEventFORMTaskClassThatNeedsToBERemoved'])) {
if (!empty($memberships)) {
$membershipStatuses = CRM_Core_PseudoConstant::get('CRM_Member_DAO_Membership', 'status_id', array(
'labelColumn' => 'name',
* @return array
*/
public function sendMail(&$input, &$ids, &$objects, &$values, $recur = FALSE, $returnMessageText = FALSE) {
- return CRM_Contribute_BAO_Contribution::sendMail($input, $ids, $objects, $values, $recur, $returnMessageText);
+ return CRM_Contribute_BAO_Contribution::sendMail($input, $ids, $objects['contribution'], $values, $recur,
+ $returnMessageText);
}
}
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Core_Payment_Form {
/**
- * Add payment fields depending on payment processor. The payment processor can implement the following functions to override the built in fields.
+ * Add payment fields depending on payment processor.
+ *
+ * The payment processor can implement the following functions to override the built in fields.
*
* - getPaymentFormFields()
* - getPaymentFormFieldsMetadata()
return $creditCardTypes;
}
+ /**
+ * Set default values for the form.
+ *
+ * @param CRM_Core_Form $form
+ * @param int $contactID
+ */
+ public static function setDefaultValues(&$form, $contactID) {
+ $billingDefaults = $form->getProfileDefaults('Billing', $contactID);
+ $form->_defaults = array_merge($form->_defaults, $billingDefaults);
+
+ // set default country & state from config if no country set
+ // note the effect of this is to set the billing country to default to the site default
+ // country if the person has an address but no country (for anonymous country is set above)
+ // this could have implications if the billing profile is filled but hidden.
+ // this behaviour has been in place for a while but the use of js to hide things has increased
+ if (empty($form->_defaults["billing_country_id-{$form->_bltID}"])) {
+ $form->_defaults["billing_country_id-{$form->_bltID}"] = CRM_Core_Config::singleton()->defaultContactCountry;
+ }
+ if (empty($form->_defaults["billing_state_province_id-{$form->_bltID}"])) {
+ $form->_defaults["billing_state_province_id-{$form->_bltID}"] = CRM_Core_Config::singleton()
+ ->defaultContactStateProvince;
+ }
+ }
+
/**
* Make sure that credit card number and cvv are valid.
* Called within the scope of a QF formRule function
return $result;
}
+ /**
+ * Get array of fields that should be displayed on the payment form.
+ *
+ * @return array
+ * @throws CiviCRM_API3_Exception
+ */
+ public function getPaymentFormFields() {
+ if ($this->_processorName == ts('PayPal Pro')) {
+ return $this->getCreditCardFormFields();
+ }
+ else {
+ return array();
+ }
+ }
+
/**
* Map the paypal params to CiviCRM params using a field map.
*
$input['fee_amount'] = self::retrieve('mc_fee', 'Money', 'POST', FALSE);
$input['net_amount'] = self::retrieve('settle_amount', 'Money', 'POST', FALSE);
$input['trxn_id'] = self::retrieve('txn_id', 'String', 'POST', FALSE);
- $input['payment_date'] = self::retrieve('payment_date', 'String', 'POST', FALSE);
+ $input['payment_date'] = $input['receive_date'] = self::retrieve('payment_date', 'String', 'POST', FALSE);
}
/**
// Add resources from coreResourceList
$jsWeight = -9999;
- foreach ($this->coreResourceList() as $item) {
+ foreach ($this->coreResourceList($region) as $item) {
if (is_array($item)) {
$this->addSetting($item);
}
*
* Note: non-compressed versions of .min files will be used in debug mode
*
+ * @param string $region
* @return array
*/
- public function coreResourceList() {
+ public function coreResourceList($region) {
$config = CRM_Core_Config::singleton();
// Scripts needed by everyone, everywhere
}
}
- // CMS-specific resources
- $config->userSystem->appendCoreResources($items);
+ // Allow hooks to modify this list
+ CRM_Utils_Hook::coreResourceList($items, $region);
return $items;
}
'{contribution.fee_amount}' => ts('Fee Amount'),
'{contribution.net_amount}' => ts('Net Amount'),
'{contribution.non_deductible_amount}' => ts('Non-deductible Amount'),
- '{contribution.receive_date}' => ts('Contribution Receive Date'),
- '{contribution.payment_instrument}' => ts('Payment Instrument'),
+ '{contribution.receive_date}' => ts('Contribution Date Received'),
+ '{contribution.payment_instrument}' => ts('Payment Method'),
'{contribution.trxn_id}' => ts('Transaction ID'),
'{contribution.invoice_id}' => ts('Invoice ID'),
'{contribution.currency}' => ts('Currency'),
*/
protected $_subtypes = array();
- /**
- * Array of default params.
- *
- * @var array
- */
- protected $_defaults = array();
-
/**
* Set variables up before form is built.
*
'class',
);
- header('Content-Type: application/json');
+ CRM_Utils_System::setHttpHeader('Content-Type', 'application/json');
echo CRM_Utils_JSON::encodeDataTableSelector($options, $sEcho, $iTotal, $iFilteredTotal, $selectorElements);
CRM_Utils_System::civiExit();
}
}
// overwrite - need to delete block which belongs to main-contact.
- if ($mainBlockId && ($operation == 2)) {
+ if (isset($mainBlockId) && $mainBlockId && ($operation == 2)) {
$deleteDAO = new $daoName();
$deleteDAO->id = $mainBlockId;
$deleteDAO->find(TRUE);
// CRM-13890 : NOTE wait list condition need to be given so that
// wait list message is shown properly in email i.e. WRT online event registration template
if (empty($tplParams['participant_status']) && empty($values['params']['isOnWaitlist'])) {
- $statusId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Participant', $participantId, 'status_id', 'id');
+ $statusId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Participant', $participantId, 'status_id', 'id', TRUE);
$tplParams['participant_status'] = CRM_Event_PseudoConstant::participantStatus($statusId, NULL, 'label');
}
//CRM-15754 - if participant_status contains status ID
$form->addDateTime('receive_date', ts('Received'), FALSE, array('formatType' => 'activityDateTime'));
$form->add('select', 'payment_instrument_id',
- ts('Paid By'),
+ ts('Payment Method'),
array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::paymentInstrument(),
FALSE, array('onChange' => "return showHideByValue('payment_instrument_id','4','checkNumber','table-row','select',false);")
);
$errorMsg['financial_type_id'] = ts('Please enter the associated Financial Type');
}
if (empty($values['payment_instrument_id'])) {
- $errorMsg['payment_instrument_id'] = ts('Paid By is a required field.');
+ $errorMsg['payment_instrument_id'] = ts('Payment Method is a required field.');
}
}
*/
class CRM_Event_Form_Registration_AdditionalParticipant extends CRM_Event_Form_Registration {
- /**
- * The defaults involved in this page.
- */
- public $_defaults = array();
-
/**
* Pre-registered additional participant id.
*/
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
*/
public $_fields;
- /**
- * The defaults involved in this page.
- */
- public $_defaults;
-
/**
* The status message that user view.
*/
}
/**
- * Set default values for the form. For edit/view mode
- * the default values are retrieved from the database
- * Adding discussion from CRM-11915 as code comments
- * When multiple payment processors are configured for a event and user does any selection changes for them on online event registeration page :
- * The 'Register' page gets loaded through ajax and following happens :
- * the setDefaults function is called with the variable _ppType set with selected payment processor type,
- * so in the 'if' condition checked whether the selected payment processor's billing mode is of 'billing form mode'. If its not, don't setDefaults for billing form and return instead.
- * - For payment processors of billing mode 'Notify' - return from setDefaults before the code for billing profile population execution .
- * (done this is because for payment processors with 'Notify' mode billing profile form doesn't get rendered on UI)
- *
- * @return void
+ * Set default values for the form.
*/
public function setDefaultValues() {
$this->_defaults = array();
$contactID = $this->getContactID();
- $billingDefaults = $this->getProfileDefaults('Billing', $contactID);
- $this->_defaults = array_merge($this->_defaults, $billingDefaults);
-
- $config = CRM_Core_Config::singleton();
- // set default country from config if no country set
- // note the effect of this is to set the billing country to default to the site default
- // country if the person has an address but no country (for anonymous country is set above)
- // this could have implications if the billing profile is filled but hidden.
- // this behaviour has been in place for a while but the use of js to hide things has increased
- if (empty($this->_defaults["billing_country_id-{$this->_bltID}"])) {
- $this->_defaults["billing_country_id-{$this->_bltID}"] = $config->defaultContactCountry;
- }
-
- // set default state/province from config if no state/province set
- if (empty($this->_defaults["billing_state_province_id-{$this->_bltID}"])) {
- $this->_defaults["billing_state_province_id-{$this->_bltID}"] = $config->defaultContactStateProvince;
- }
+ CRM_Core_Payment_Form::setDefaultValues($this, $contactID);
if ($contactID) {
$fields = array();
*/
protected $_prefix = "event_";
- protected $_defaults;
-
/**
* The saved search ID retrieved from the GET vars.
*
$this->_formValues["participant_test"] = 0;
}
- CRM_Core_BAO_CustomValue::fixFieldValueOfTypeMemo($this->_formValues);
+ CRM_Core_BAO_CustomValue::fixCustomFieldValue($this->_formValues);
$this->_queryParams = CRM_Contact_BAO_Query::convertFormValues($this->_formValues);
'componentName' => 'Event',
'contribution_id' => $contributionId,
'contribution_status_id' => $contributionStatusId,
- 'skipComponentSync' => 1,
+ 'IAmAHorribleNastyBeyondExcusableHackInTheCRMEventFORMTaskClassThatNeedsToBERemoved' => 1,
);
//change related contribution status.
'labelColumn' => 'name',
'flip' => 1,
));
- $input['skipComponentSync'] = CRM_Utils_Array::value('skipComponentSync', $params);
+ $input['IAmAHorribleNastyBeyondExcusableHackInTheCRMEventFORMTaskClassThatNeedsToBERemoved'] = CRM_Utils_Array::value('IAmAHorribleNastyBeyondExcusableHackInTheCRMEventFORMTaskClassThatNeedsToBERemoved', $params);
if ($statusId == $contributionStatuses['Cancelled']) {
$baseIPN->cancelled($objects, $transaction, $input);
$transaction->commit();
$checkCid->external_identifier = $formatValues['external_identifier'];
$checkCid->find(TRUE);
if ($checkCid->id != $formatted['contact_id']) {
- array_unshift($values, 'Mismatch of External identifier :' . $formatValues['external_identifier'] . ' and Contact Id:' . $formatted['contact_id']);
+ array_unshift($values, 'Mismatch of External ID:' . $formatValues['external_identifier'] . ' and Contact Id:' . $formatted['contact_id']);
return CRM_Import_Parser::ERROR;
}
}
$errorFileName = $parserName::errorFileName($type);
$saveFileName = $parserName::saveFileName($type);
if (!empty($errorFileName) && !empty($saveFileName)) {
- header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
- header('Content-Description: File Transfer');
- header('Content-Type: text/csv');
- header('Content-Length: ' . filesize($errorFileName));
- header('Content-Disposition: attachment; filename=' . $saveFileName);
+ CRM_Utils_System::setHttpHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0');
+ CRM_Utils_System::setHttpHeader('Content-Description', 'File Transfer');
+ CRM_Utils_System::setHttpHeader('Content-Type', 'text/csv');
+ CRM_Utils_System::setHttpHeader('Content-Length', filesize($errorFileName));
+ CRM_Utils_System::setHttpHeader('Content-Disposition', 'attachment; filename=' . $saveFileName);
readfile($errorFileName);
}
$componentPaymentFields = array(
'componentPaymentField_total_amount' => ts('Total Amount'),
'componentPaymentField_contribution_status' => ts('Contribution Status'),
- 'componentPaymentField_received_date' => ts('Received Date'),
- 'componentPaymentField_payment_instrument' => ts('Payment Instrument'),
+ 'componentPaymentField_received_date' => ts('Date Received'),
+ 'componentPaymentField_payment_instrument' => ts('Payment Method'),
'componentPaymentField_transaction_id' => ts('Transaction ID'),
);
}
$zip = $config->customFileUploadDir . 'Financial_Transactions_' . date('YmdHis') . '.zip';
$result = $this->createZip($this->_downloadFile, $zip, TRUE);
if ($result) {
- header('Content-Type: application/zip');
- header('Content-Disposition: attachment; filename=' . CRM_Utils_File::cleanFileName(basename($zip)));
- header('Content-Length: ' . filesize($zip));
+ CRM_Utils_System::setHttpHeader('Content-Type', 'application/zip');
+ CRM_Utils_System::setHttpHeader('Content-Disposition', 'attachment; filename=' . CRM_Utils_File::cleanFileName(basename($zip)));
+ CRM_Utils_System::setHttpHeader('Content-Length', '' . filesize($zip));
ob_clean();
flush();
readfile($config->customFileUploadDir . CRM_Utils_File::cleanFileName(basename($zip)));
}
}
else {
- header('Content-Type: text/plain');
- header('Content-Disposition: attachment; filename=' . CRM_Utils_File::cleanFileName(basename($this->_downloadFile[0])));
- header('Content-Length: ' . filesize($this->_downloadFile[0]));
+ CRM_Utils_System::setHttpHeader('Content-Type', 'text/plain');
+ CRM_Utils_System::setHttpHeader('Content-Disposition', 'attachment; filename=' . CRM_Utils_File::cleanFileName(basename($this->_downloadFile[0])));
+ CRM_Utils_System::setHttpHeader('Content-Length', '' . filesize($this->_downloadFile[0]));
ob_clean();
flush();
readfile($config->customFileUploadDir . CRM_Utils_File::cleanFileName(basename($this->_downloadFile[0])));
$paymentInstrument = array_flip(CRM_Contribute_PseudoConstant::paymentInstrument('label'));
$values['payment_instrument_id'] = array_search($values['payment_instrument_id'], $paymentInstrument);
}
- $details = '<p>' . ts('Record:') . ' ' . $values['title'] . '</p><p>' . ts('Description:') . '</p><p>' . ts('Created By:') . " $createdBy" . '</p><p>' . ts('Created Date:') . ' ' . $values['created_date'] . '</p><p>' . ts('Last Modified By:') . ' ' . $modifiedBy . '</p><p>' . ts('Payment Instrument:') . ' ' . $values['payment_instrument_id'] . '</p>';
+ $details = '<p>' . ts('Record:') . ' ' . $values['title'] . '</p><p>' . ts('Description:') . '</p><p>' . ts('Created By:') . " $createdBy" . '</p><p>' . ts('Created Date:') . ' ' . $values['created_date'] . '</p><p>' . ts('Last Modified By:') . ' ' . $modifiedBy . '</p><p>' . ts('Payment Method:') . ' ' . $values['payment_instrument_id'] . '</p>';
$subject = '';
if (!empty($values['total'])) {
$subject .= ts('Total') . '[' . CRM_Utils_Money::format($values['total']) . '],';
/**
* Retrieve payment processor id / info/ object based on component-id.
*
+ * @todo function needs revisiting. The whole 'info / obj' thing is an overload. Recommend creating new functions
+ * that are entity specific as there is little shared code specific to obj or info
+ *
+ * Also, it does not accurately derive the processor - for a completed contribution the best place to look is in the
+ * relevant financial_trxn record. For a recurring contribution it is in the contribution_recur table.
+ *
+ * For a membership the relevant contribution_recur should be derived & then resolved as above. The contribution page
+ * is never a reliable place to look as there can be more than one configured. For a pending contribution there is
+ * no way to derive the processor - but hey - what processor? it didn't go through!
+ *
+ * Query for membership might look something like:
+ * SELECT fte.payment_processor_id
+ * FROM civicrm_membership mem
+ * INNER JOIN civicrm_line_item li ON ( mem.id = li.entity_id AND li.entity_table = 'civicrm_membership')
+ * INNER JOIN civicrm_contribution con ON ( li.contribution_id = con.id )
+ * LEFT JOIN civicrm_entity_financial_trxn ft ON ft.entity_id = con.id AND ft.entity_table =
+ * 'civicrm_contribution'
+ * LEFT JOIN civicrm_financial_trxn fte ON fte.id = ft.financial_trxn_id
+ *
* @param int $entityID
* @param string $component
* Component.
elseif ($type == 'info') {
$result = self::getPayment($ppID, $mode);
}
- elseif ($type == 'obj') {
- $payment = self::getPayment($ppID, $mode);
- $result = Civi\Payment\System::singleton()->getByProcessor($payment);
+ elseif ($type == 'obj' && is_numeric($ppID)) {
+ try {
+ $paymentProcessor = civicrm_api3('PaymentProcessor', 'getsingle', array('id' => $ppID));
+ }
+ catch (API_Exception $e) {
+ // Unable to load the processor because this function uses an unreliable method to derive it.
+ // The function looks to load the payment processor ID from the contribution page, which
+ // can support multiple processors.
+ }
+ $result = Civi\Payment\System::singleton()->getByProcessor($paymentProcessor);
}
-
return $result;
}
'created_by' => ts('Created By'),
'status' => ts('Status'),
'description' => ts('Description'),
- 'payment_instrument' => ts('Payment Instrument'),
+ 'payment_instrument' => ts('Payment Method'),
'item_count' => ts('Entered Transactions'),
'assigned_item_count' => ts('Assigned Transactions'),
'total' => ts('Entered Total'),
$this->add('textarea', 'description', ts('Description'), $attributes['description']);
- $this->add('select', 'payment_instrument_id', ts('Payment Instrument'),
+ $this->add('select', 'payment_instrument_id', ts('Payment Method'),
array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::paymentInstrument(),
FALSE
);
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
class CRM_Financial_Form_Payment extends CRM_Core_Form {
/**
CRM_Core_Payment_ProcessorForm::buildQuickForm($this);
}
+ /**
+ * Set default values for the form.
+ */
+ public function setDefaultValues() {
+ $contactID = $this->getContactID();
+ CRM_Core_Payment_Form::setDefaultValues($this, $contactID);
+ return $this->_defaults;
+ }
+
/**
* Add JS to show icons for the accepted credit cards
*/
$this->add(
'select',
'payment_instrument_id',
- ts('Payment Instrument'),
+ ts('Payment Method'),
array('' => ts('- any -')) + CRM_Contribute_PseudoConstant::paymentInstrument(),
FALSE
);
'action',
);
- header('Content-Type: application/json');
+ CRM_Utils_System::setHttpHeader('Content-Type', 'application/json');
echo CRM_Utils_JSON::encodeDataTableSelector($financialitems, $sEcho, $iTotal, $iFilteredTotal, $selectorElements);
CRM_Utils_System::civiExit();
}
*/
protected $_prefix = "grant_";
- protected $_defaults;
-
/**
* Processing needed for buildForm and later.
*
$this->_formValues = CRM_Contact_BAO_SavedSearch::getFormValues($this->_ssID);
}
+ CRM_Core_BAO_CustomValue::fixCustomFieldValue($this->_formValues);
+
$this->_queryParams = CRM_Contact_BAO_Query::convertFormValues($this->_formValues);
$this->set('formValues', $this->_formValues);
if (!empty($params['is_unit_test'])) {
return array($groups, $iFilteredTotal);
}
- header('Content-Type: application/json');
+ CRM_Utils_System::setHttpHeader('Content-Type', 'application/json');
echo CRM_Utils_JSON::encodeDataTableSelector($groups, $sEcho, $iTotal, $iFilteredTotal, $selectorElements);
CRM_Utils_System::civiExit();
}
}
/**
+ * @deprecated
+ *
* @param int $job_id
* @param int $mailing_id
- * @param null $mode
*
* @return int
*/
- public static function &getRecipientsCount($job_id, $mailing_id = NULL, $mode = NULL) {
+ public static function getRecipientsCount($job_id, $mailing_id = NULL) {
// need this for backward compatibility, so we can get count for old mailings
// please do not use this function if possible
$eq = self::getRecipients($job_id, $mailing_id);
* @param int $job_id
* (misnomer) a nonce value used to name temporary tables.
* @param int $mailing_id
- * @param null $offset
- * @param null $limit
* @param bool $storeRecipients
* @param bool $dedupeEmail
* @param null $mode
*
* @return CRM_Mailing_Event_BAO_Queue|string
*/
- public static function &getRecipients(
+ public static function getRecipients(
$job_id,
$mailing_id = NULL,
- $offset = NULL,
- $limit = NULL,
$storeRecipients = FALSE,
$dedupeEmail = FALSE,
$mode = NULL) {
$job = CRM_Mailing_BAO_MailingJob::getTableName();
$mg = CRM_Mailing_DAO_MailingGroup::getTableName();
$eq = CRM_Mailing_Event_DAO_Queue::getTableName();
- $ed = CRM_Mailing_Event_DAO_Delivered::getTableName();
- $eb = CRM_Mailing_Event_DAO_Bounce::getTableName();
$email = CRM_Core_DAO_Email::getTableName();
if ($mode == 'sms') {
}
$mailingGroup->query($query);
- $results = array();
-
$eq = new CRM_Mailing_Event_BAO_Queue();
list($aclFrom, $aclWhere) = CRM_Contact_BAO_Contact_Permission::cacheClause();
$aclWhere = $aclWhere ? "WHERE {$aclWhere}" : '';
- $limitString = NULL;
- if ($limit && $offset !== NULL) {
- $offset = CRM_Utils_Type::escape($offset, 'Int');
- $limit = CRM_Utils_Type::escape($limit, 'Int');
-
- $limitString = "LIMIT $offset, $limit";
- }
if ($storeRecipients && $mailing_id) {
$sql = "
/**
* Returns the regex patterns that are used for preparing the text and html templates.
*/
- private function &getPatterns($onlyHrefs = FALSE) {
+ private function getPatterns($onlyHrefs = FALSE) {
$patterns = array();
*
* @return Mail_mime The mail object
*/
- public function &compose(
+ public function compose(
$job_id, $event_queue_id, $hash, $contactId,
$email, &$recipient, $test,
$contactDetails, &$attachments, $isForward = FALSE,
$fromEmail = NULL, $replyToEmail = NULL
) {
$config = CRM_Core_Config::singleton();
- $knownTokens = $this->getTokens();
+ $this->getTokens();
if ($this->_domain == NULL) {
$this->_domain = CRM_Core_BAO_Domain::getDomain();
}
else {
$params = array(array('contact_id', '=', $contactId, 0, 0));
- list($contact, $_) = CRM_Contact_BAO_Query::apiQuery($params);
+ list($contact) = CRM_Contact_BAO_Query::apiQuery($params);
//CRM-4524
$contact = reset($contact);
// Populate the recipients.
if (empty($params['_skip_evil_bao_auto_recipients_'])) {
- self::getRecipients($job->id, $mailing->id, NULL, NULL, TRUE, $mailing->dedupe_email);
+ self::getRecipients($job->id, $mailing->id, TRUE, $mailing->dedupe_email);
}
}
* @throws Exception
*/
public static function processQueue($mode = NULL) {
- $config = &CRM_Core_Config::singleton();
+ $config = CRM_Core_Config::singleton();
if ($mode == NULL && CRM_Core_BAO_MailSettings::defaultDomain() == "EXAMPLE.ORG") {
throw new CRM_Core_Exception(ts('The <a href="%1">default mailbox</a> has not been configured. You will find <a href="%2">more info in the online user and administrator guide</a>', array(
* @param CRM_Mailing_DAO_MailingAB $dao
*/
public static function distributeRecipients(CRM_Mailing_DAO_MailingAB $dao) {
- CRM_Mailing_BAO_Mailing::getRecipients($dao->mailing_id_a, $dao->mailing_id_a, NULL, NULL, TRUE);
+ CRM_Mailing_BAO_Mailing::getRecipients($dao->mailing_id_a, $dao->mailing_id_a, TRUE);
//calculate total number of random recipients for mail C from group_percentage selected
$totalCount = CRM_Mailing_BAO_Recipients::mailingSize($dao->mailing_id_a);
$mailing = new CRM_Mailing_BAO_Mailing();
$mailing->id = $params['mailing_id'];
if ($mailing->id && $mailing->find(TRUE)) {
- $mailing->getRecipients($job->id, $params['mailing_id'], NULL, NULL, TRUE, $mailing->dedupe_email);
+ $mailing->getRecipients($job->id, $params['mailing_id'], TRUE, $mailing->dedupe_email);
return $job;
}
else {
CRM_Mailing_BAO_Mailing::getRecipients(
$mailing->id,
$mailing->id,
- NULL,
- NULL,
TRUE,
$dedupeEmail
);
$groupNames = civicrm_api3('Group', 'get', $params + array(
'is_active' => 1,
+ 'check_permissions' => TRUE,
'return' => array('title', 'visibility', 'group_type', 'is_hidden'),
));
$headerfooterList = civicrm_api3('MailingComponent', 'get', $params + array(
));
$fromAddress = civicrm_api3('OptionValue', 'get', $params + array(
'option_group_id' => "from_email_address",
+ 'domain_id' => CRM_Core_Config::domainID(),
));
CRM_Core_Resources::singleton()
->addSetting(array(
);
if ($type == 'html') {
- header('Content-Type: text/html; charset=utf-8');
+ CRM_Utils_System::setHttpHeader('Content-Type', 'text/html; charset=utf-8');
print $mime->getHTMLBody();
}
else {
- header('Content-Type: text/plain; charset=utf-8');
+ CRM_Utils_System::setHttpHeader('Content-Type', 'text/plain; charset=utf-8');
print $mime->getTXTBody();
}
CRM_Utils_System::civiExit();
$this->addDate('receive_date', ts('Received'), FALSE, array('formatType' => 'activityDateTime'));
$this->add('select', 'payment_instrument_id',
- ts('Paid By'),
+ ts('Payment Method'),
array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::paymentInstrument(),
FALSE, array('onChange' => "return showHideByValue('payment_instrument_id','4','checkNumber','table-row','select',false);")
);
}
if (!empty($params['record_contribution']) && empty($params['payment_instrument_id'])) {
- $errors['payment_instrument_id'] = ts('Paid By is a required field.');
+ $errors['payment_instrument_id'] = ts('Payment Method is a required field.');
}
if (!empty($params['is_different_contribution_contact'])) {
CRM_Core_Session::setStatus($statusMsg, ts('Complete'), 'success');
//CRM-15187
// dusplay message when membership type is changed
- if ($this->_id && !in_array($this->_memType, $this->_memTypeSelected)) {
+ if (($this->_action & CRM_Core_Action::UPDATE) && $this->_id && !in_array($this->_memType, $this->_memTypeSelected)) {
CRM_Core_Session::setStatus(
ts('The financial types associated with the old and new membership types are different. You may want to edit the contribution associated with this membership to adjust its financial type.'),
ts('Warning')
$this->add('text', 'num_terms', ts('Extend Membership by'), array('onchange' => "setPaymentBlock();"), TRUE);
$this->addRule('num_terms', ts('Please enter a whole number for how many periods to renew.'), 'integer');
- $this->add('select', 'payment_instrument_id', ts('Paid By'),
+ $this->add('select', 'payment_instrument_id', ts('Payment Method'),
array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::paymentInstrument(),
FALSE, array('onChange' => "return showHideByValue('payment_instrument_id','4','checkNumber','table-row','select',false);")
);
$errors['total_amount'] = ts('Please enter a Contribution Amount.');
}
if (empty($params['payment_instrument_id'])) {
- $errors['payment_instrument_id'] = ts('Paid By is a required field.');
+ $errors['payment_instrument_id'] = ts('Payment Method is a required field.');
}
}
return empty($errors) ? TRUE : $errors;
*/
protected $_limit = NULL;
- protected $_defaults;
-
/**
* Prefix for the controller.
*/
}
}
- CRM_Core_BAO_CustomValue::fixFieldValueOfTypeMemo($this->_formValues);
+ CRM_Core_BAO_CustomValue::fixCustomFieldValue($this->_formValues);
$this->_queryParams = CRM_Contact_BAO_Query::convertFormValues($this->_formValues);
$checkCid->external_identifier = $formatValues['external_identifier'];
$checkCid->find(TRUE);
if ($checkCid->id != $formatted['contact_id']) {
- array_unshift($values, 'Mismatch of External identifier :' . $formatValues['external_identifier'] . ' and Contact Id:' . $formatted['contact_id']);
+ array_unshift($values, 'Mismatch of External ID:' . $formatValues['external_identifier'] . ' and Contact Id:' . $formatted['contact_id']);
return CRM_Import_Parser::ERROR;
}
}
}
$isUpdateBilling = FALSE;
+ // It would be better to determine if there is a recurring contribution &
+ // is so get the entity for the recurring contribution (& skip if not).
$paymentObject = CRM_Financial_BAO_PaymentProcessor::getProcessorForEntity(
$membership[$dao->id]['membership_id'], 'membership', 'obj');
if (!empty($paymentObject)) {
+ // @todo - get this working with syntax style $paymentObject->supports(array
+ //('updateSubscriptionBillingInfo'));
$isUpdateBilling = $paymentObject->isSupported('updateSubscriptionBillingInfo');
}
+ // @todo - get this working with syntax style $paymentObject->supports(array
+ //('CancelSubscriptionSupported'));
$isCancelSupported = CRM_Member_BAO_Membership::isCancelSubscriptionSupported(
$membership[$dao->id]['membership_id']);
*/
public $_single;
- /**
- * The default values for the form.
- *
- * @var array
- */
- protected $_defaults;
-
-
public function preProcess() {
$session = CRM_Core_Session::singleton();
$config = CRM_Core_Config::singleton();
*/
protected $_prefix = "pledge_";
- protected $_defaults;
-
/**
* Processing needed for buildForm and later.
- *
- * @return void
*/
public function preProcess() {
$this->_formValues = CRM_Contact_BAO_SavedSearch::getFormValues($this->_ssID);
}
- CRM_Core_BAO_CustomValue::fixFieldValueOfTypeMemo($this->_formValues);
+ CRM_Core_BAO_CustomValue::fixCustomFieldValue($this->_formValues);
$this->_queryParams = CRM_Contact_BAO_Query::convertFormValues($this->_formValues);
*/
protected $_ctype = NULL;
- protected $_defaults = NULL;
-
/**
* Store profile ids if multiple profile ids are passed using comma separated.
* Currently lets implement this functionality only for dialog mode
*/
protected $_options = array();
- protected $_defaults = array();
-
/**
* By default most reports hide contact id.
* Setting this to true makes it available
//Load the image
$chart = imagecreatefrompng($uploadUrl);
//convert it into formatted png
- header('Content-type: image/png');
+ CRM_Utils_System::setHttpHeader('Content-type', 'image/png');
//overwrite with same image
imagepng($chart, $uploadImg);
//delete the object
'default' => TRUE,
),
'payment_instrument_id' => array(
- 'title' => ts('Payment Instrument'),
+ 'title' => ts('Payment Method'),
'default' => TRUE,
),
'currency' => array(
),
'filters' => array(
'payment_instrument_id' => array(
- 'title' => ts('Payment Instrument'),
+ 'title' => ts('Payment Method'),
'operatorType' => CRM_Report_Form::OP_MULTISELECT,
'options' => CRM_Contribute_PseudoConstant::paymentInstrument(),
),
),
),
'order_bys' => array(
- 'payment_instrument_id' => array('title' => ts('Payment Instrument')),
+ 'payment_instrument_id' => array('title' => ts('Payment Method')),
),
),
'civicrm_entity_financial_trxn' => array(
'order_bys' => array(
'financial_type_id' => array('title' => ts('Financial Type')),
'contribution_status_id' => array('title' => ts('Contribution Status')),
- 'payment_instrument_id' => array('title' => ts('Payment Instrument')),
- 'receive_date' => array('title' => ts('Receive Date')),
+ 'payment_instrument_id' => array('title' => ts('Payment Method')),
+ 'receive_date' => array('title' => ts('Date Received')),
),
'grouping' => 'contri-fields',
),
'alter_display' => 'alterContributionType',
),
'payment_instrument_id' => array(
- 'title' => ts('Payment Instrument'),
+ 'title' => ts('Payment Method'),
'alter_display' => 'alterPaymentType',
),
'source' => array('title' => 'Contribution Source'),
),
'order_bys' => array(
'payment_instrument_id' => array(
- 'title' => ts('Payment Instrument'),
+ 'title' => ts('Payment Method'),
),
'financial_type_id' => array(
'title' => ts('Financial Type'),
),
'group_bys' => array(
'financial_type_id' => array('title' => ts('Financial Type')),
- 'payment_instrument_id' => array('title' => ts('Payment Instrument')),
+ 'payment_instrument_id' => array('title' => ts('Payment Method')),
'contribution_id' => array(
'title' => ts('Individual Contribution'),
'name' => 'id',
'dao' => 'CRM_Mailing_DAO_Mailing',
'fields' => array(
'delivered_count' => array(
- 'name' => 'id',
+ 'name' => 'event_queue_id',
'title' => ts('Delivered'),
),
'accepted_rate' => array(
'dao' => 'CRM_Mailing_DAO_Mailing',
'fields' => array(
'bounce_count' => array(
- 'name' => 'id',
+ 'name' => 'event_queue_id',
'title' => ts('Bounce'),
),
'bounce_rate' => array(
'dao' => 'CRM_Mailing_DAO_Mailing',
'fields' => array(
'open_count' => array(
- 'name' => 'id',
+ 'name' => 'event_queue_id',
'title' => ts('Opened'),
),
'open_rate' => array(
'dao' => 'CRM_Mailing_DAO_Mailing',
'fields' => array(
'click_count' => array(
- 'name' => 'id',
+ 'name' => 'event_queue_id',
'title' => ts('Clicks'),
),
'CTR' => array(
),
'order_bys' => array(
'receive_date' => array(
- 'title' => ts('Receive Date'),
+ 'title' => ts('Date Received'),
'default_weight' => '2',
'default_order' => 'DESC',
),
*/
public static function export2csv(&$form, &$rows) {
//Mark as a CSV file.
- header('Content-Type: text/csv');
+ CRM_Utils_System::setHttpHeader('Content-Type', 'text/csv');
//Force a download and name the file using the current timestamp.
$datetime = date('Ymd-Gi', $_SERVER['REQUEST_TIME']);
- header('Content-Disposition: attachment; filename=Report_' . $datetime . '.csv');
+ CRM_Utils_System::setHttpHeader('Content-Disposition', 'attachment; filename=Report_' . $datetime . '.csv');
echo self::makeCsv($form, $rows);
CRM_Utils_System::civiExit();
}
// also compute the recipients and store them in the mailing recipients table
CRM_Mailing_BAO_Mailing::getRecipients($mailing->id,
$mailing->id,
- NULL,
- NULL,
TRUE,
FALSE,
'sms'
{/if}
</p>
<table width="620" border="0" cellpadding="0" cellspacing="0" id="crm-event_receipt" style="font-family: Arial, Verdana, sans-serif; text-align: left;">
- <tr><td>{ts}Receive Date{/ts}:</td><td> {$receive_date|crmDate}</td></tr>
+ <tr><td>{ts}Received{/ts}:</td><td> {$receive_date|crmDate}</td></tr>
<tr><td>{ts}Amount{/ts}:</td><td> {$total_amount|crmMoney:$currency}</td></tr>
<tr><td>{ts}Name{/ts}:</td><td> {$donors_display_name}</td></tr>
<tr><td>{ts}Email{/ts}:</td><td> {$donors_email}</td></tr>
{ts}The donor's name has been added to your honor roll unless they asked not to be included.{/ts}
{/if}
-{ts}Receive Date{/ts}: {$receive_date|crmDate}
+{ts}Received{/ts}: {$receive_date|crmDate}
{ts}Amount{/ts}: {$total_amount|crmMoney:$currency}
return TRUE;
}
+ /**
+ * Queue Task Callback for CRM-16846
+ *
+ * Run a sql file without resetting locale to that version
+ */
+ public static function task_4_6_x_runOnlySql(CRM_Queue_TaskContext $ctx, $rev) {
+ $upgrade = new CRM_Upgrade_Form();
+ $smarty = CRM_Core_Smarty::singleton();
+ $smarty->assign('domainID', CRM_Core_Config::domainID());
+
+ $fileName = "CRM/Upgrade/Incremental/sql/$rev.mysql.tpl";
+
+ $upgrade->source($smarty->fetch($fileName), TRUE);
+
+ return TRUE;
+ }
+
}
+
{* file to handle db changes in 4.6.6 during upgrade *}
-- CRM-16846 - This upgrade may have been previously skipped so moving it to 4.6.6
SET `permission` = 'edit message templates'
WHERE `parent_id` = @messages_menu_id
AND name = 'Message Templates';
+
+-- CRM-16907
+SELECT @adminHelplastID := id FROM civicrm_navigation WHERE name = 'Help';
+UPDATE civicrm_navigation
+SET name = 'Support', label = 'Support'
+WHERE id = @adminHelplastID;
+
+DELETE FROM civicrm_navigation where parent_id = @adminHelplastID;
+
+INSERT INTO civicrm_navigation
+ ( domain_id, url, label, name, permission, permission_operator, parent_id, is_active, has_separator, weight )
+ VALUES
+ ( {$domainID}, 'http://civicrm.org/get-started?src=iam', '{ts escape="sql" skip="true"}Get started{/ts}', 'Get started', NULL, 'AND', @adminHelplastID, '1', NULL, 1 ),
+ ( {$domainID}, 'http://civicrm.org/documentation?src=iam', '{ts escape="sql" skip="true"}Documentation{/ts}', 'Documentation', NULL, 'AND', @adminHelplastID, '1', NULL, 2 ),
+ ( {$domainID}, 'http://civicrm.org/ask-a-question?src=iam', '{ts escape="sql" skip="true"}Ask a question{/ts}', 'Ask a question', NULL, 'AND', @adminHelplastID, '1', NULL, 3 ),
+ ( {$domainID}, 'http://civicrm.org/experts?src=iam', '{ts escape="sql" skip="true"}Get expert help{/ts}', 'Get expert help', NULL, 'AND', @adminHelplastID, '1', NULL, 4 ),
+ ( {$domainID}, 'http://civicrm.org/about?src=iam', '{ts escape="sql" skip="true"}About CiviCRM{/ts}', 'About CiviCRM', NULL, 'AND', @adminHelplastID, '1', 1, 5 ),
+ ( {$domainID}, 'http://civicrm.org/register-your-site?src=iam', '{ts escape="sql" skip="true"}Register your site{/ts}', 'Register your site', NULL, 'AND', @adminHelplastID, '1', NULL, 6 ),
+ ( {$domainID}, 'http://civicrm.org/become-member?src=iam', '{ts escape="sql" skip="true"}Join CiviCRM{/ts}', 'Join CiviCRM', NULL, 'AND', @adminHelplastID, '1', NULL, 7 );
+
+INSERT INTO civicrm_navigation
+ ( domain_id, url, label, name, permission, permission_operator, parent_id, is_active, has_separator, weight )
+ VALUES
+ ( {$domainID}, NULL, '{ts escape="sql" skip="true"}Developer{/ts}', 'Developer', 'administer CiviCRM', '', @adminHelplastID, '1', 1, 8 );
+
+SET @devellastID:=LAST_INSERT_ID();
+INSERT INTO civicrm_navigation
+ ( domain_id, url, label, name, permission, permission_operator, parent_id, is_active, has_separator, weight )
+ VALUES
+ ( {$domainID}, 'civicrm/api', '{ts escape="sql" skip="true"}API Explorer{/ts}','API Explorer', 'administer CiviCRM', '', @devellastID, '1', NULL, 1 ),
+ ( {$domainID}, 'http://civicrm.org/developer-documentation?src=iam', '{ts escape="sql" skip="true"}Developer Docs{/ts}', 'Developer Docs', 'administer CiviCRM', '', @devellastID, '1', NULL, 3 );
+
\ No newline at end of file
--- /dev/null
+{* file to handle db changes in 4.6.7 during upgrade *}
-- CRM-16447
UPDATE civicrm_state_province SET name = 'Northern Ostrobothnia' WHERE name = 'Nothern Ostrobothnia';
+
+-- CRM-14078
+UPDATE civicrm_option_group SET {localize field="title"}title = '{ts escape="sql"}Payment Methods{/ts}'{/localize} WHERE name = 'payment_instrument';
+UPDATE civicrm_navigation SET label = '{ts escape="sql"}Payment Methods{/ts}' WHERE name = 'Payment Instruments';
+
+-- CRM-16176
+{if $multilingual}
+ {foreach from=$locales item=locale}
+ ALTER TABLE civicrm_relationship_type ADD label_a_b_{$locale} varchar(64);
+ ALTER TABLE civicrm_relationship_type ADD label_b_a_{$locale} varchar(64);
+ ALTER TABLE civicrm_relationship_type ADD description_{$locale} varchar(255);
+
+ UPDATE civicrm_relationship_type SET label_a_b_{$locale} = label_a_b;
+ UPDATE civicrm_relationship_type SET label_b_a_{$locale} = label_b_a;
+ UPDATE civicrm_relationship_type SET description_{$locale} = description;
+ {/foreach}
+
+ ALTER TABLE civicrm_relationship_type DROP label_a_b;
+ ALTER TABLE civicrm_relationship_type DROP label_b_a;
+ ALTER TABLE civicrm_relationship_type DROP description;
+{/if}
if (!CRM_Utils_Array::value('is_error', $result, FALSE)) {
$reloadMode = $apiRequest['params']['options']['reload'];
}
+ $id = (!empty($apiRequest['params']['sequential'])) ? 0 : $result['id'];
}
switch ($reloadMode) {
if ($reloadResult['is_error']) {
throw new API_Exception($reloadResult['error_message']);
}
- $result['values'][$result['id']] = array_merge($result['values'][$result['id']], $reloadResult['values'][$result['id']]);
+ $result['values'][$id] = array_merge($result['values'][$id], $reloadResult['values'][$result['id']]);
return $result;
case 'selected':
$params = array(
- 'id' => $result['id'],
+ 'id' => $id,
'return' => $this->pickReturnFields($apiRequest),
);
$reloadResult = civicrm_api3($apiRequest['entity'], 'get', $params);
- $result['values'][$result['id']] = array_merge($result['values'][$result['id']], $reloadResult['values'][$result['id']]);
+ $result['values'][$id] = array_merge($result['values'][$id], $reloadResult['values'][$id]);
return $result;
default:
);
}
+ /**
+ * This hook is called when core resources are being loaded
+ *
+ * @see CRM_Core_Resources::coreResourceList
+ *
+ * @param array $list
+ * @param string $region
+ */
+ public static function coreResourceList(&$list, $region) {
+ // First allow the cms integration to add to the list
+ CRM_Core_Config::singleton()->userSystem->appendCoreResources($list);
+
+ self::singleton()->invoke(2, $list, $region,
+ self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
+ 'civicrm_coreResourceList'
+ );
+ }
+
}
public static function send($calendar, $content_type = 'text/calendar', $charset = 'us-ascii', $fileName = NULL, $disposition = NULL) {
$config = CRM_Core_Config::singleton();
$lang = $config->lcMessages;
- header("Content-Language: $lang");
- // header( "Content-Type: $content_type; charset=$charset; profile=\"ICalendar\"" );
- header("Content-Type: $content_type; charset=$charset");
+ CRM_Utils_System::setHttpHeader("Content-Language", $lang);
+ CRM_Utils_System::setHttpHeader("Content-Type", "$content_type; charset=$charset");
if ($content_type == 'text/calendar') {
- header('Content-Length: ' . strlen($calendar));
- header("Content-Disposition: $disposition; filename=\"$fileName\"");
- header("Pragma: no-cache");
- header("Expires: 0");
- header("Cache-Control: no-cache, must-revalidate");
+ CRM_Utils_System::setHttpHeader('Content-Length', strlen($calendar));
+ CRM_Utils_System::setHttpHeader("Content-Disposition", "$disposition; filename=\"$fileName\"");
+ CRM_Utils_System::setHttpHeader("Pragma", "no-cache");
+ CRM_Utils_System::setHttpHeader("Expires", "0");
+ CRM_Utils_System::setHttpHeader("Cache-Control", "no-cache, must-revalidate");
}
echo $calendar;
* @param mixed $input
*/
public static function output($input) {
- header('Content-Type: application/json');
+ CRM_Utils_System::setHttpHeader('Content-Type', 'application/json');
echo json_encode($input);
CRM_Utils_System::civiExit();
}
return $pdf;
}
else {
- header('Content-Type: application/pdf');
- header('Content-Disposition: attachment; filename="' . $fileName . '"');
+ CRM_Utils_System::setHttpHeader('Content-Type', 'application/pdf');
+ CRM_Utils_System::setHttpHeader('Content-Disposition', 'attachment; filename="' . $fileName . '"');
echo $pdf;
}
}
$len = strlen($buf);
if ($echo) {
- header('Content-type: application/pdf');
- header("Content-Length: $len");
- header("Content-Disposition: inline; filename={$output}.pdf");
+ CRM_Utils_System::setHttpHeader('Content-type', 'application/pdf');
+ CRM_Utils_System::setHttpHeader("Content-Length", $len);
+ CRM_Utils_System::setHttpHeader("Content-Disposition", "inline; filename={$output}.pdf");
echo $buf;
CRM_Utils_System::civiExit();
}
}
if (!empty($requestParams['json'])) {
- header('Content-Type: application/json');
if (!empty($requestParams['prettyprint'])) {
- // Used by the api explorer
+ // Don't set content-type header for api explorer output
return self::jsonFormated(array_merge($result));
}
+ CRM_Utils_System::setHttpHeader('Content-Type', 'application/json');
return json_encode(array_merge($result));
}
* @param $pearError
*/
public static function fatal($pearError) {
- header('Content-Type: text/xml');
+ CRM_Utils_System::setHttpHeader('Content-Type', 'text/xml');
$error = array();
$error['code'] = $pearError->getCode();
$error['error_message'] = $pearError->getMessage();
$smarty = CRM_Core_Smarty::singleton();
CRM_Utils_System::setTitle("$entity::$tplfile inline $tpl");
if (!$smarty->template_exists($tpl)) {
- header("Status: 404 Not Found");
+ CRM_Utils_System::setHttpHeader("Status", "404 Not Found");
die ("Can't find the requested template file templates/$tpl");
}
if (array_key_exists('id', $_GET)) {// special treatmenent, because it's often used
));
}
- header('Location: ' . $url);
+ self::setHttpHeader('Location', $url);
self::civiExit();
}
) {
$now = gmdate('D, d M Y H:i:s') . ' GMT';
- header('Content-Type: ' . $mimeType);
- header('Expires: ' . $now);
+ self::setHttpHeader('Content-Type', $mimeType);
+ self::setHttpHeader('Expires', $now);
// lem9 & loic1: IE need specific headers
$isIE = strstr($_SERVER['HTTP_USER_AGENT'], 'MSIE');
$fileString = "filename=\"{$name}\"";
}
if ($isIE) {
- header("Content-Disposition: inline; $fileString");
- header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
- header('Pragma: public');
+ self::setHttpHeader("Content-Disposition", "inline; $fileString");
+ self::setHttpHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0');
+ self::setHttpHeader('Pragma', 'public');
}
else {
- header("Content-Disposition: $disposition; $fileString");
- header('Pragma: no-cache');
+ self::setHttpHeader("Content-Disposition", "$disposition; $fileString");
+ self::setHttpHeader('Pragma', 'no-cache');
}
if ($output) {
return NULL;
}
+ /**
+ * @param string $name
+ * @param string $value
+ */
+ public static function setHttpHeader($name, $value) {
+ CRM_Core_Config::singleton()->userSystem->setHttpHeader($name, $value);
+ }
+
}
public function appendCoreResources(&$list) {
}
+ /**
+ * @param string $name
+ * @param string $value
+ */
+ public function setHttpHeader($name, $value) {
+ header("$name: $value");
+ }
+
}
return $timezone;
}
+ /**
+ * @inheritDoc
+ */
+ public function setHttpHeader($name, $value) {
+ drupal_add_http_header($name, $value);
+ }
+
}
return $timezone;
}
+ /**
+ * @inheritDoc
+ */
+ public function setHttpHeader($name, $value) {
+ drupal_set_header("$name: $value");
+ }
+
}
return 'sidebar_first';
}
+ /**
+ * @inheritDoc
+ */
+ public function flush() {
+ // CiviCRM and Drupal both provide (different versions of) Symfony (and possibly share other classes too).
+ // If we call drupal_flush_all_caches(), Drupal will attempt to rediscover all of its classes, use Civicrm's
+ // alternatives instead and then die. Instead, we only clear cache bins and no more.
+ foreach (Drupal\Core\Cache\Cache::getBins() as $service_id => $cache_backend) {
+ $cache_backend->deleteAll();
+ }
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function setHttpHeader($name, $value) {
+ \Symfony\Component\HttpFoundation\Response->headers->set($name, $value);
+ }
}
*/
public function logout() {
session_destroy();
- header("Location:index.php");
+ CRM_Utils_System::setHttpHeader("Location", "index.php");
}
/**
*/
public function logout() {
session_destroy();
- header("Location:index.php");
+ CRM_Utils_System::setHttpHeader("Location", "index.php");
}
/**
foreach ($newparams as $entityparams) {
$subParams = array_merge($genericParams, $entityparams);
_civicrm_api_replace_variables($subParams, $result['values'][$idIndex], $separator);
- $result['values'][$result['id']][$field][] = $apiKernel->run($subEntity, $subaction, $subParams);
+ $result['values'][$idIndex][$field][] = $apiKernel->run($subEntity, $subaction, $subParams);
if ($result['is_error'] === 1) {
throw new \Exception($subEntity . ' ' . $subaction . 'call failed with' . $result['error_message']);
}
$count = count($stringParts);
}
}
+ // CRM-16168 If we have failed to swap it out we should unset it rather than leave the placeholder.
+ if (substr($params[$field], 0, 6) == '$value') {
+ $params[$field] = NULL;
+ }
}
}
}
* @param array $params
*
* @return array
+ * API result array
*/
function civicrm_api3_acl_create($params) {
return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params);
* @param array $params
*
* @return array
- * Array of retrieved Acl property values.
+ * API result array
*/
function civicrm_api3_acl_get($params) {
return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params);
* @param array $params
*
* @return array
- * Array of deleted values.
+ * API result array
*/
function civicrm_api3_acl_delete($params) {
return _civicrm_api3_basic_delete(_civicrm_api3_get_BAO(__FUNCTION__), $params);
* @param array $params
*
* @return array
+ * API result array
*/
function civicrm_api3_acl_role_create($params) {
return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params);
* @param array $params
*
* @return array
- * Array of retrieved AclRole property values.
+ * API result array
*/
function civicrm_api3_acl_role_get($params) {
return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params);
* @param array $params
*
* @return array
- * Array of deleted values.
+ * API result array
*/
function civicrm_api3_acl_role_delete($params) {
return _civicrm_api3_basic_delete(_civicrm_api3_get_BAO(__FUNCTION__), $params);
* @param array $params
*
* @return array
+ * API result array
*/
function civicrm_api3_action_schedule_get($params) {
return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params, 'ActionSchedule');
*
* @throws API_Exception
* @return array
- * Array containing 'is_error' to denote success or failure and details of the created activity.
+ * API result array
*/
function civicrm_api3_activity_create($params) {
* Array per getfields documentation.
*
* @return array
+ * API result array
*/
function civicrm_api3_activity_get($params) {
if (!empty($params['contact_id'])) {
* @throws API_Exception
*
* @return array
+ * API result array
*/
function civicrm_api3_activity_delete($params) {
* @param array $params
*
* @return array
- * Api Result
+ * API result array
*/
function civicrm_api3_activity_contact_delete($params) {
return _civicrm_api3_basic_delete(_civicrm_api3_get_BAO(__FUNCTION__), $params);
* An associative array of name/value pairs.
*
* @return array
- * details of found tags else error
+ * API result array
*/
function civicrm_api3_activity_contact_get($params) {
return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params);
* Array per getfields metadata.
*
* @return array
+ * API result array
*/
function civicrm_api3_address_create(&$params) {
/**
* Array per getfields metadata.
*
* @return array
- * api result array
+ * API result array
*/
function civicrm_api3_address_delete($params) {
return _civicrm_api3_basic_delete(_civicrm_api3_get_BAO(__FUNCTION__), $params);
* Array per getfields metadata.
*
* @return array
- * details of found addresses else error
+ * API result array
*/
function civicrm_api3_address_get(&$params) {
return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params, TRUE, 'Address');
);
$params['prefix_id']['api.aliases'] = array('individual_prefix', 'individual_prefix_id');
$params['suffix_id']['api.aliases'] = array('individual_suffix', 'individual_suffix_id');
+ $params['gender_id']['api.aliases'] = array('gender');
}
/**
$params['skipLineItem'] = array(
'name' => 'skipLineItem',
'title' => 'Skip adding line items',
- 'type' => 1,
+ 'type' => CRM_Utils_Type::T_BOOLEAN,
'api.default' => 0,
'description' => 'Do not add line items by default (if you wish to add your own)',
);
throw new Exception('Contribution does not exist');
}
$input = $ids = $cvalues = array('receipt_from_email' => $params['receipt_from_email']);
- $contribution->loadRelatedObjects($input, $ids, FALSE, TRUE);
+ $contribution->loadRelatedObjects($input, $ids, TRUE);
$contribution->composeMessageArray($input, $ids, $cvalues, FALSE, FALSE);
}
throw new API_Exception('A valid contribution ID is required', 'invalid_data');
}
- if (!$contribution->loadRelatedObjects($input, $ids, FALSE, TRUE)) {
+ if (!$contribution->loadRelatedObjects($input, $ids, TRUE)) {
throw new API_Exception('failed to load related objects');
}
elseif ($contribution->contribution_status_id == CRM_Core_OptionGroup::getValue('contribution_status', 'Completed', 'name')) {
}
$original_contribution = clone $contribution;
try {
- if (!$contribution->loadRelatedObjects($input, $ids, FALSE, TRUE)) {
+ if (!$contribution->loadRelatedObjects($input, $ids, TRUE)) {
throw new API_Exception('failed to load related objects');
}
$input['receipt_from_name'] = CRM_Utils_Array::value('receipt_from_name', $params, $domainFromName);
$input['receipt_from_email'] = CRM_Utils_Array::value('receipt_from_email', $params, $domainFromEmail);
}
- // @todo required for base ipn but problematic as api layer handles this
$transaction = new CRM_Core_Transaction();
- $ipn = new CRM_Core_Payment_BaseIPN();
- $ipn->completeTransaction($input, $ids, $objects, $transaction, !empty($contribution->contribution_recur_id));
+ CRM_Contribute_BAO_Contribution::completeOrder($input, $ids, $objects, $transaction, !empty($contribution->contribution_recur_id), $contribution,
+ FALSE, FALSE);
return $params;
}
/**
* Retrieve custom searches.
*
- * FIXME This is a bare-minimum placeholder
- *
* @param array $params
*
* @return array
- * details of found Option Values
+ * API result array
*/
function civicrm_api3_custom_search_get($params) {
require_once 'api/v3/OptionValue.php';
* @param array $params
*
* @return array
+ * API result array
*/
function civicrm_api3_custom_search_create($params) {
require_once 'api/v3/OptionValue.php';
}
/**
- * Deletes an existing ReportTemplate.
+ * Deletes an existing CustomSearch.
*
* @param array $params
*
* @return array
- * Api result
+ * API result array
*/
function civicrm_api3_custom_search_delete($params) {
require_once 'api/v3/OptionValue.php';
*/
function civicrm_api3_group_get($params) {
$options = _civicrm_api3_get_options_from_params($params, TRUE, 'Group', 'get');
- if (empty($options['return']) || !in_array('member_count', $options['return'])) {
+ if ((empty($options['return']) || !in_array('member_count', $options['return'])) && empty($params['check_permissions'])) {
return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params, TRUE, 'Group');
}
$groups = _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params, FALSE, 'Group');
foreach ($groups as $id => $group) {
- $groups[$id]['member_count'] = CRM_Contact_BAO_Group::memberCount($id);
+ if (!empty($params['check_permissions']) && !CRM_Contact_BAO_Group::checkPermission($group['id'])) {
+ unset($groups[$id]);
+ }
+ elseif (!empty($options['return']) && in_array('member_count', $options['return'])) {
+ $groups[$id]['member_count'] = CRM_Contact_BAO_Group::memberCount($id);
+ }
}
return civicrm_api3_create_success($groups, $params, 'Group', 'get');
}
$status = CRM_Utils_Array::value('status', $params, 'Added');
$groupId = CRM_Utils_Array::value('group_id', $params);
- $values = &CRM_Contact_BAO_GroupContact::getContactGroup($params['contact_id'], $status, NULL, FALSE, TRUE, FALSE, TRUE, $groupId);
+ $values = CRM_Contact_BAO_GroupContact::getContactGroup($params['contact_id'], $status, NULL, FALSE, TRUE, FALSE, TRUE, $groupId);
return civicrm_api3_create_success($values, $params, 'GroupContact');
}
+/**
+ * Adjust metadata for Create action.
+ *
+ * @param array $params
+ */
+function _civicrm_api3_group_contact_create_spec(&$params) {
+ $params['contact_id']['api.required'] = 1;
+ $params['group_id']['api.required'] = 1;
+}
+
/**
* Add contact(s) to group(s).
*
* @endcode
*
* @param array $params
- * Input parameters.
- * - "contact_id" (required) : first contact to add
- * - "group_id" (required): first group to add contact(s) to
- * - "contact_id.1" etc. (optional) : another contact to add
- * - "group_id.1" etc. (optional) : additional group to add contact(s) to
- * - "status" (optional) : one of "Added", "Pending" or "Removed" (default is "Added")
+ * Input parameters:
+ * - "contact_id" (required): First contact to add, or array of Contact IDs
+ * - "group_id" (required): First group to add contact(s) to, or array of Group IDs
+ * - "status" (optional): "Added" (default), "Pending" or "Removed"
+ * Legacy input parameters (will be deprecated):
+ * - "contact_id.1" etc. (optional): Additional contact_id to add to group(s)
+ * - "group_id.1" etc. (optional): Additional groups to add contact(s) to
*
* @return array
* Information about operation results
$params['contact_id'] = $info['values'][$params['id']]['contact_id'];
}
}
- civicrm_api3_verify_mandatory($params, NULL, array('group_id', 'contact_id'));
$action = CRM_Utils_Array::value('status', $params, 'Added');
return _civicrm_api3_group_contact_common($params, $action);
}
$contactIDs = array();
$groupIDs = array();
+
+ // CRM-16959: Handle multiple Contact IDs and Group IDs in legacy format
+ // (contact_id.1, contact_id.2) or as an array
foreach ($params as $n => $v) {
if (substr($n, 0, 10) == 'contact_id') {
- $contactIDs[] = $v;
+ if (is_array($v)) {
+ foreach ($v as $arr_v) {
+ $contactIDs[] = $arr_v;
+ }
+ }
+ else {
+ $contactIDs[] = $v;
+ }
}
elseif (substr($n, 0, 8) == 'group_id') {
- $groupIDs[] = $v;
+ if (is_array($v)) {
+ foreach ($v as $arr_v) {
+ $groupIDs[] = $arr_v;
+ }
+ }
+ else {
+ $groupIDs[] = $v;
+ }
}
}
- if (empty($contactIDs)) {
- return civicrm_api3_create_error('contact_id is a required field');
- }
-
- if (empty($groupIDs)) {
- return civicrm_api3_create_error('group_id is a required field');
- }
-
$method = CRM_Utils_Array::value('method', $params, 'API');
$status = CRM_Utils_Array::value('status', $params, $op);
$tracking = CRM_Utils_Array::value('tracking', $params);
* An associative array of name/value property values of MembershipBlock.
*
* @return array
- * newly created or updated membership block property values.
+ * API result array
*/
function civicrm_api3_membership_block_create($params) {
return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params);
* {getfields MembershipBlock_get}
*
* @return array
- * api result array of all found membership block property values.
+ * API result array
*/
function civicrm_api3_membership_block_get($params) {
return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params);
* @param array $params
*
* @return array
- * api result array
+ * API result array
*/
function civicrm_api3_membership_block_delete($params) {
return _civicrm_api3_basic_delete(_civicrm_api3_get_BAO(__FUNCTION__), $params);
--- /dev/null
+<?php
+/*
+ +--------------------------------------------------------------------+
+ | CiviCRM version 4.6 |
+ +--------------------------------------------------------------------+
+ | Copyright CiviCRM LLC (c) 2004-2015 |
+ +--------------------------------------------------------------------+
+ | This file is a part of CiviCRM. |
+ | |
+ | CiviCRM is free software; you can copy, modify, and distribute it |
+ | under the terms of the GNU Affero General Public License |
+ | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
+ | |
+ | CiviCRM is distributed in the hope that it will be useful, but |
+ | WITHOUT ANY WARRANTY; without even the implied warranty of |
+ | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
+ | See the GNU Affero General Public License for more details. |
+ | |
+ | You should have received a copy of the GNU Affero General Public |
+ | License and the CiviCRM Licensing Exception along |
+ | with this program; if not, contact CiviCRM LLC |
+ | at info[AT]civicrm[DOT]org. If you have questions about the |
+ | GNU Affero General Public License or the licensing of CiviCRM, |
+ | see the CiviCRM license FAQ at http://civicrm.org/licensing |
+ +--------------------------------------------------------------------+
+ */
+
+/**
+ * This api exposes CiviCRM MembershipLog records.
+ *
+ * @package CiviCRM_APIv3
+ */
+
+/**
+ * API to Create or update a MembershipLog.
+ *
+ * @param array $params
+ * Values of MembershipLog.
+ *
+ * @return array
+ * API result array.
+ */
+function civicrm_api3_membership_log_create($params) {
+ return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params);
+}
+
+/**
+ * Adjust Metadata for Create action.
+ *
+ * The metadata is used for setting defaults, documentation & validation.
+ *
+ * @param array $params
+ * Array of parameters determined by getfields.
+ */
+function _civicrm_api3_membership_log_create_spec(&$params) {
+ $params['membership_id']['api.required'] = TRUE;
+}
+
+/**
+ * Get a Membership Log.
+ *
+ * This api is used for finding an existing membership log.
+ *
+ * @param array $params
+ * An associative array of name/value property values of civicrm_membership_log.
+ * {getfields MembershipLog_get}
+ *
+ * @return array
+ * API result array
+ */
+function civicrm_api3_membership_log_get($params) {
+ return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params);
+}
+
+/**
+ * Deletes an existing membership log.
+ *
+ * This API is used for deleting a membership log
+ * Required parameters : id of a membership log
+ *
+ * @param array $params
+ *
+ * @return array
+ * API result array
+ */
+function civicrm_api3_membership_log_delete($params) {
+ return _civicrm_api3_basic_delete(_civicrm_api3_get_BAO(__FUNCTION__), $params);
+}
* @param array $params
*
* @return array
+ * API result array
*/
function civicrm_api3_open_i_d_create($params) {
return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params);
* @param array $params
*
* @return array
- * API result Array
+ * API result array
*/
function civicrm_api3_open_i_d_delete($params) {
return _civicrm_api3_basic_delete(_civicrm_api3_get_BAO(__FUNCTION__), $params);
* An associative array of name/value pairs.
*
* @return array
- * details of found OpenID
+ * API result array
*/
function civicrm_api3_open_i_d_get($params) {
return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params);
* @param array $params
*
* @return array
- * Details of found Option Values
+ * API result array
*/
function civicrm_api3_option_value_get($params) {
*
* @throws API_Exception
* @return array
+ * API result array
*/
function civicrm_api3_option_value_create($params) {
$result = _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params);
* @param array $params
*
* @return array
- * Api result
+ * API result array
*/
function civicrm_api3_option_value_delete($params) {
// We will get the option group id before deleting so we can flush pseudoconstants.
* @param array $params
*
* @return array
+ * API result array
*/
function civicrm_api3_payment_processor_create($params) {
if (empty($params['id']) && empty($params['payment_instrument_id'])) {
* @param array $params
*
* @return array
- * API result Array
+ * API result array
*/
function civicrm_api3_payment_processor_delete($params) {
return _civicrm_api3_basic_delete(_civicrm_api3_get_BAO(__FUNCTION__), $params);
* Array of name/value pairs.
*
* @return array
- * details of found PaymentProcessor
+ * API result array
*/
function civicrm_api3_payment_processor_get($params) {
return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params);
* Array per getfields metadata.
*
* @return array
- * details of found phones else error
+ * API result array
*/
function civicrm_api3_phone_get($params) {
return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params);
* Input parameters.
*
* @return array
- * Details of found instances
+ * API result array
*/
function civicrm_api3_report_instance_get($params) {
return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params);
* @param array $params
*
* @return array
+ * API result array
*/
function civicrm_api3_report_instance_create($params) {
return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params);
* @param array $params
*
* @return array
- * Api result
+ * API result array
*/
function civicrm_api3_report_instance_delete($params) {
return _civicrm_api3_basic_delete(_civicrm_api3_get_BAO(__FUNCTION__), $params);
/**
* Retrieve a report template.
*
- * FIXME This is a bare-minimum placeholder
- *
* @param array $params
*
* @return array
- * details of found Option Values
+ * API result array
*/
function civicrm_api3_report_template_get($params) {
require_once 'api/v3/OptionValue.php';
* @param array $params
*
* @return array
+ * API result array
*/
function civicrm_api3_report_template_create($params) {
require_once 'api/v3/OptionValue.php';
* @param array $params
*
* @return array
- * Api result
+ * API result array
*/
function civicrm_api3_report_template_delete($params) {
require_once 'api/v3/OptionValue.php';
* Input parameters.
*
* @return array
- * details of found instances
+ * API result array
*/
function civicrm_api3_report_template_getrows($params) {
civicrm_api3_verify_one_mandatory($params, NULL, array('report_id', 'instance_id'));
* @param array $params
*
* @return array
+ * API result array
*/
function civicrm_api3_report_template_getstatistics($params) {
list($rows, $reportInstance, $metadata) = _civicrm_api3_report_template_getrows($params);
* Array per getfields metadata.
*
* @return array
+ * API result array
*/
function civicrm_api3_tag_create($params) {
return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params);
* Array per getfields metadata.
*
* @return array
- * details of found tags else error
+ * API result array
*/
function civicrm_api3_tag_get($params) {
* @param array $params
*
* @return array
- * API result array.
+ * API result array
* @todo convert to using basic create - BAO function non-std
*/
function civicrm_api3_website_create($params) {
* @param array $params
*
* @return array
- * API result
+ * API result array
* @throws \API_Exception
*/
function civicrm_api3_website_delete($params) {
* @param array $params
*
* @return array
- * details of found websites
+ * API result array
*/
function civicrm_api3_website_get($params) {
return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params, TRUE, 'Website');
'is_deceased' => array(
'name' => 'is_deceased',
'type' => 16,
- 'title' => 'Is Deceased',
+ 'title' => 'Deceased',
'import' => TRUE,
'where' => 'civicrm_contact.is_deceased',
'headerPattern' => '/i(s\\s)?d(eceased)$/i',
'source' => array(
'name' => 'source',
'type' => 2,
- 'title' => 'Source of Contact Data',
+ 'title' => 'Contact Source',
'maxlength' => 255,
'size' => 30,
'import' => TRUE,
'{contact.preferred_language}' => 'Preferred Language',
'{contact.preferred_mail_format}' => 'Preferred Mail Format',
'{contact.hash}' => 'Contact Hash',
- '{contact.contact_source}' => 'Source of Contact Data',
+ '{contact.contact_source}' => 'Contact Source',
'{contact.first_name}' => 'First Name',
'{contact.middle_name}' => 'Middle Name',
'{contact.last_name}' => 'Last Name',
* @param options object
*/
$.fn.crmSelect2 = function(options) {
+ if (options === 'destroy') {
+ return $(this).each(function() {
+ $(this)
+ .removeClass('crm-ajax-select')
+ .select2('destroy');
+ });
+ }
return $(this).each(function () {
var
$el = $(this),
* @param options object
*/
$.fn.crmEntityRef = function(options) {
+ if (options === 'destroy') {
+ return $(this).each(function() {
+ var entity = $(this).data('api-entity') || '';
+ $(this)
+ .off('.crmEntity')
+ .removeClass('crm-form-entityref crm-' + entity.toLowerCase() + '-ref')
+ .crmSelect2('destroy');
+ });
+ }
options = options || {};
options.select = options.select || {};
return $(this).each(function() {
CKEDITOR.document.getById( 'toolbarModifierWrapper' ).append( toolbarModifier.mainContainer );
- $('.toolbar button:last', '#toolbarModifierWrapper').hide();
-
$(function() {
var selectorOpen = false,
changedWhileOpen = false;
$('#toolbarModifierForm')
- // The buttons in the configurator are not submit buttons!
- .on('click', 'button', function(e) {
- e.preventDefault();
- })
.on('submit', function(e) {
$('.toolbar button:last', '#toolbarModifierWrapper')[0].click();
$('.configContainer textarea', '#toolbarModifierWrapper').attr('name', 'config');
{else}
<table class="form-layout-compressed">
<tr class="crm-relationship-type-form-block-label_a_b">
- <td class="label">{$form.label_a_b.label}</td>
+ <td class="label">{$form.label_a_b.label} {if $action == 2}{include file='CRM/Core/I18n/Dialog.tpl' table='civicrm_relationship_type' field='label_a_b' id=$relationship_type_id}{/if}</td>
<td>{$form.label_a_b.html}<br />
<span class="description">{ts}Label for the relationship from Contact A to Contact B. EXAMPLE: Contact A is 'Parent of' Contact B.{/ts}</span></td>
</tr>
<tr class="crm-relationship-type-form-block-label_b_a">
- <td class="label">{$form.label_b_a.label}</td>
+ <td class="label">{$form.label_b_a.label} {if $action == 2}{include file='CRM/Core/I18n/Dialog.tpl' table='civicrm_relationship_type' field='label_b_a' id=$relationship_type_id}{/if}</td>
<td>{$form.label_b_a.html}<br />
<span class="description">{ts}Label for the relationship from Contact B to Contact A. EXAMPLE: Contact B is 'Child of' Contact A. You may leave this blank for relationships where the name is the same in both directions (e.g. Spouse).{/ts}</span></td>
</tr>
<td>{$form.contact_types_b.html}</td>
</tr>
<tr class="crm-relationship-type-form-block-description">
- <td class="label">{$form.description.label}</td>
+ <td class="label">{$form.description.label} {if $action == 2}{include file='CRM/Core/I18n/Dialog.tpl' table='civicrm_relationship_type' field='description' id=$relationship_type_id}{/if}</td>
<td>{$form.description.html}</td>
</tr>
<tr class="crm-relationship-type-form-block-is_active">
fields = [],
getFieldData = {},
params = {},
- smartyStub,
+ smartyPhp,
entityDoc,
fieldTpl = _.template($('#api-param-tpl').html()),
optionsTpl = _.template($('#api-options-tpl').html()),
operator = $('.api-param-op', $row).val(),
$valField = $('input.api-param-value', $row),
multiSelect = isMultiSelect(name, operator),
- currentVal = $valField.val();
+ currentVal = $valField.val(),
+ wasSelect = $valField.data('select2');
+ if (wasSelect) {
+ $valField.crmEntityRef('destroy');
+ }
+ $valField.attr('placeholder', ts('Value'));
// Boolean fields only have 1 possible value
if (_.includes(BOOL, operator)) {
- if ($valField.data('select2')) {
- $valField.select2('destroy');
- }
$valField.css('visibility', 'hidden').val('1');
return;
}
$valField.css('visibility', '');
// Option list or entityRef input
if (isSelect(name, operator)) {
+ $valField.attr('placeholder', ts('- select -'));
// Reset value before switching to a select from something else
- if ($(this).is('.api-param-name') || !$valField.data('select2')) {
+ if ($(this).is('.api-param-name') || !wasSelect) {
$valField.val('');
}
// When switching from multi-select to single select
}
// EntityRef
else {
+ var entity = getFieldData[name].FKApiName;
+ $valField.attr('placeholder', entity == 'Contact' ? '[' + ts('Auto-Select Current User') + ']' : ts('- select -'));
$valField.crmEntityRef({
- entity: getFieldData[name].FKApiName,
+ entity: entity,
select: {
multiple: multiSelect,
- minimumInputLength: _.includes(OPEN_IMMEDIATELY, getFieldData[name].FKApiName) ? 0 : 1
+ minimumInputLength: _.includes(OPEN_IMMEDIATELY, entity) ? 0 : 1
}
});
}
- return;
- }
- // Plain text input
- if ($valField.data('select2')) {
- $valField.select2('destroy');
}
}
/**
* Format value to look like php code
+ * TODO: Use short array syntax when we drop support for php 5.3
* @param val
*/
function phpFormat(val) {
}
/**
- * Smarty doesn't support array literals so we provide a stub
+ * @param value string
* @param js string
* @param key string
*/
- function smartyFormat(js, key) {
+ function smartyFormat(value, js, key) {
+ var varName = 'param_' + key.replace(/[. -]/g, '_').toLowerCase();
+ // Can't pass array literals directly into smarty so we add a php snippet
if (_.includes(js, '[') || _.includes(js, '{')) {
- smartyStub = true;
- return '$' + key.replace(/[. -]/g, '_');
+ smartyPhp.push('$this->assign("'+ varName + '", '+ phpFormat(value) +');');
+ return '$' + varName;
}
return js;
}
name = 'options';
}
}
+ // Default for contact ref fields
+ if ($(this).is('.crm-contact-ref') && input === '') {
+ val = evaluate('user_contact_id', makeArray);
+ }
if (name && val !== undefined) {
params[name] = op === '=' ? val : (params[name] || {});
if (op !== '=') {
*/
function formatQuery() {
var i = 0, q = {
- smarty: "{crmAPI var='result' entity='" + entity + "' action='" + action + "'",
+ smarty: "{crmAPI var='result' entity='" + entity + "' action='" + action + "'" + (params.sequential ? '' : ' sequential=0'),
php: "$result = civicrm_api3('" + entity + "', '" + action + "'",
json: "CRM.api3('" + entity + "', '" + action + "'",
drush: "drush cvapi " + entity + '.' + action + ' ',
wpcli: "wp cv api " + entity + '.' + action + ' ',
- rest: CRM.config.resourceBase + "extern/rest.php?entity=" + entity + "&action=" + action + "&json=" + JSON.stringify(params) + "&api_key=yourkey&key=sitekey"
+ rest: CRM.config.resourceBase + "extern/rest.php?entity=" + entity + "&action=" + action + "&api_key=yourkey&key=sitekey&json=" + JSON.stringify(params)
};
- smartyStub = false;
+ smartyPhp = [];
$.each(params, function(key, value) {
var js = JSON.stringify(value);
if (!(i++)) {
}
q.php += " '" + key + "' => " + phpFormat(value) + ",\n";
q.json += " \"" + key + '": ' + js;
- q.smarty += ' ' + key + '=' + smartyFormat(js, key);
+ // smarty already defaults to sequential
+ if (key !== 'sequential') {
+ q.smarty += ' ' + key + '=' + smartyFormat(value, js, key);
+ }
// FIXME: This is not totally correct cli syntax
q.drush += key + '=' + js + ' ';
q.wpcli += key + '=' + js + ' ';
q.smarty += "}\n{foreach from=$result.values item=" + entity.toLowerCase() + "}\n {$" + entity.toLowerCase() + ".some_field}\n{/foreach}";
if (!_.includes(action, 'get')) {
q.smarty = '{* Smarty API only works with get actions *}';
- } else if (smartyStub) {
- q.smarty = "{* Smarty does not have a syntax for array literals; assign complex variables from php *}\n" + q.smarty;
+ } else if (smartyPhp.length) {
+ q.smarty = "{php}\n " + smartyPhp.join("\n ") + "\n{/php}\n" + q.smarty;
}
$.each(q, function(type, val) {
$('#api-' + type).text(val);
* Note: We have to manually execute the ajax in order to add the secret extra "prettyprint" param
*/
function execute() {
+ var footer;
$('#api-result').html('<div class="crm-loading-element"></div>');
$.ajax({
url: CRM.url('civicrm/ajax/rest'),
type: _.includes(action, 'get') ? 'GET' : 'POST',
dataType: 'text'
}).done(function(text) {
+ // There may be debug information appended to the end of the json string
+ var footerPos = text.indexOf("\n}<");
+ if (footerPos) {
+ footer = text.substr(footerPos + 2);
+ text = text.substr(0, footerPos + 2);
+ }
$('#api-result').text(text);
prettyPrint('#api-result');
+ if (footer) {
+ $('#api-result').append(footer);
+ }
});
}
.on('change', 'input.api-param-name, select.api-param-op', renderValueField)
.on('change', 'input.api-param-name, .api-option-name', function() {
if ($(this).val() === '-' && $(this).data('select2')) {
- $(this).select2('destroy');
- $(this).val('').focus();
+ $(this)
+ .crmSelect2('destroy')
+ .val('')
+ .focus();
}
})
.on('click', '.api-param-remove', function(e) {
#api-params-table th:first-child,
#api-params-table td:first-child {
width: 35%;
+ min-width: 190px;
+ }
+ #api-params-table td[colspan] {
+ width: 100%;
}
#api-params-table td:first-child + td,
- #api-params-table th:first-child + th,
+ #api-params-table th:first-child + th {
+ width: 140px;
+ }
+ #api-params-table td:first-child + td select {
+ width: 132px;
+ }
+ #api-params-table td:first-child + td + td,
+ #api-params-table th:first-child + th + th {
+ width: 65%
+ }
#api-generated td:first-child {
- width: 9em;
+ width: 60px;
}
#api-params {
min-height: 1em;
#api-params .red-icon {
margin-top: .5em;
}
+ .api-param-remove {
+ float: right;
+ }
#mainTabContainer label {
display: inline;
font-weight: bold;
{/htxt}
{htxt id="id-internal-id-title"}
- {ts}CiviCRM ID{/ts}
+ {ts}Contact ID{/ts}
{/htxt}
{htxt id="id-internal-id"}
<p>{ts}Every contact in CiviCRM has a unique ID number. This number will never change and is the most accurate way of identifying a contact.{/ts}</p>
</td>
{if $contactId}
<td>
- <label for="internal_identifier_display">{ts}CiviCRM ID{/ts} {help id="id-internal-id"}</label><br />
+ <label for="internal_identifier_display">{ts}Contact ID{/ts} {help id="id-internal-id"}</label><br />
<input id="internal_identifier_display" type="text" class="crm-form-text six" size="6" readonly="readonly" value="{$contactId}">
</td>
{/if}
{if !empty($form.address.$blockId.postal_code)}
<td>
{$form.address.$blockId.postal_code.label}<br />
- {$form.address.$blockId.postal_code.html}
- {if !empty($form.address.$blockId.postal_code_suffix)}
+ {$form.address.$blockId.postal_code.html}
+ </td>
+ {if !empty($form.address.$blockId.postal_code_suffix)}
<td>
- {$form.address.$blockId.postal_code_suffix.label}<br/>
- {$form.address.$blockId.postal_code_suffix.html} {help id="id-postal-code-suffix" file="CRM/Contact/Form/Contact.hlp"}
+ {$form.address.$blockId.postal_code_suffix.label} {help id="id-postal-code-suffix" file="CRM/Contact/Form/Contact.hlp"}<br/>
+ {$form.address.$blockId.postal_code_suffix.html}
<td>
- {/if}
- </td>
+ {/if}
{/if}
<td colspan="2"> </td>
</tr>
<tr id="id_existing_group">
<td>
<table class="form-layout">
- <tr><td class="label">{$form.group_id.label}<span class="marker">*</span></td><td>{$form.group_id.html}</td></tr>
+ <tr><td class="label">{$form.group_id.label}<span class="crm-marker">*</span></td><td>{$form.group_id.html}</td></tr>
</table>
</td>
</tr>
<td>
<table class="form-layout">
<tr class="crm-contact-task-addtogroup-form-block-title">
- <td class="label">{$form.title.label}<span class="marker">*</span></td>
+ <td class="label">{$form.title.label}<span class="crm-marker">*</span></td>
<td>{$form.title.html}</td>
<tr>
<tr class="crm-contact-task-addtogroup-form-block-description">
*}
{* template for custom data *}
{assign var="customDataGroupName" value=$customDataGroup.name}
+{strip}
+ {if $displayStyle neq 'tableOriented' and ($action eq 16 or $action eq 4)} {* Browse or View actions *}
+ <div class="form-item">
+ {include file="CRM/Custom/Page/CustomDataView.tpl"}
+ </div>
+ {/if}
+{/strip}
{foreach from=$viewCustomData item=customGroupWrapper}
{foreach from=$customGroupWrapper item=customGroup key=customGroupId}
{assign var="customRegion" value='contact-custom-data-'|cat:$customGroup.name}
</script>
{/literal}
{else}
- {strip}
- {if $action eq 16 or $action eq 4} {* Browse or View actions *}
- <div class="form-item">
- {include file="CRM/Custom/Page/CustomDataView.tpl"}
- </div>
- {/if}
- {/strip}
-
{if $mainEditForm}
<script type="text/javascript">
var showBlocks1 = new Array({$showBlocks1});
</div>
<div class="crm-summary-row">
<div class="crm-label">
- {ts}CiviCRM ID{/ts}{if !empty($userRecordUrl)} / {ts}User ID{/ts}{/if}
+ {ts}Contact ID{/ts}{if !empty($userRecordUrl)} / {ts}User ID{/ts}{/if}
</div>
<div class="crm-content">
<span class="crm-contact-contact_id">{$contactId}</span>
<tr class="columnheader">
<th>{ts}Amount{/ts}</th>
<th>{ts}Type{/ts}</th>
- <th>{ts}Paid By{/ts}</th>
+ <th>{ts}Payment Method{/ts}</th>
<th>{ts}Received{/ts}</th>
<th>{ts}Transaction ID{/ts}</th>
<th>{ts}Status{/ts}</th>
<td class="font-size12pt label"><strong>{ts}Participant{/ts}</strong></td><td class="font-size12pt"><strong>{$displayName}</strong></td>
</tr>
{if $contributionMode}
- <tr class="crm-payment-form-block-payment_processor_id"><td class="label nowrap">{$form.payment_processor_id.label}<span class="marker"> * </span></td><td>{$form.payment_processor_id.html}</td></tr>
+ <tr class="crm-payment-form-block-payment_processor_id"><td class="label nowrap">{$form.payment_processor_id.label}<span class="crm-marker"> * </span></td><td>{$form.payment_processor_id.html}</td></tr>
{/if}
<tr>
<td class='label'>{ts}Event{/ts}</td><td>{$eventName}</td>
{elseif $showAdditionalInfo and $formType }
{include file="CRM/Contribute/Form/AdditionalInfo/$formType.tpl"}
{else}
-
+ {include file="CRM/Contribute/Form/AdditionalInfo/Payment.tpl"}
<div class="crm-block crm-form-block crm-contribution-form-block">
{if !$email and $action neq 8 and $context neq 'standalone'}
<td>{$form.contact_id.html}</td>
{/if}
{if $contributionMode}
- <tr class="crm-contribution-form-block-payment_processor_id"><td class="label nowrap">{$form.payment_processor_id.label}<span class="marker"> * </span></td><td>{$form.payment_processor_id.html}</td></tr>
+ <tr class="crm-contribution-form-block-payment_processor_id"><td class="label nowrap">{$form.payment_processor_id.label}<span class="crm-marker"> * </span></td><td>{$form.payment_processor_id.html}</td></tr>
{/if}
<tr class="crm-contribution-form-block-contribution_type_id crm-contribution-form-block-financial_type_id">
<td class="label">{$form.financial_type_id.label}</td><td{$valueStyle}>{$form.financial_type_id.html}
{if $pledgeBlock}
{if $is_pledge_payment}
<div class="crm-section {$form.pledge_amount.name}-section">
- <div class="label">{$form.pledge_amount.label} <span class="marker">*</span></div>
+ <div class="label">{$form.pledge_amount.label} <span class="crm-marker">*</span></div>
<div class="content">{$form.pledge_amount.html}</div>
<div class="clear"></div>
</div>
<tr id="payLaterFields" class="crm-contribution-form-block-payLaterFields"><td> </td>
<td>
<table class="form-layout">
- <tr class="crm-contribution-contributionpage-amount-form-block-pay_later_text"><th scope="row" class="label">{$form.pay_later_text.label} <span class="marker" title="This field is required.">*</span> {if $action == 2}{include file='CRM/Core/I18n/Dialog.tpl' table='civicrm_contribution_page' field='pay_later_text' id=$contributionPageID}{/if}</th>
+ <tr class="crm-contribution-contributionpage-amount-form-block-pay_later_text"><th scope="row" class="label">{$form.pay_later_text.label} <span class="crm-marker" title="This field is required.">*</span> {if $action == 2}{include file='CRM/Core/I18n/Dialog.tpl' table='civicrm_contribution_page' field='pay_later_text' id=$contributionPageID}{/if}</th>
<td>{$form.pay_later_text.html|crmAddClass:big}<br />
<span class="description">{ts}Text displayed next to the checkbox for the 'pay later' option on the contribution form. You may include HTML formatting tags.{/ts}</span></td></tr>
- <tr class="crm-contribution-contributionpage-amount-form-block-pay_later_receipt"><th scope="row" class="label">{$form.pay_later_receipt.label} <span class="marker" title="This field is required.">*</span> {if $action == 2}{include file='CRM/Core/I18n/Dialog.tpl' table='civicrm_contribution_page' field='pay_later_receipt' id=$contributionPageID}{/if}</th>
+ <tr class="crm-contribution-contributionpage-amount-form-block-pay_later_receipt"><th scope="row" class="label">{$form.pay_later_receipt.label} <span class="crm-marker" title="This field is required.">*</span> {if $action == 2}{include file='CRM/Core/I18n/Dialog.tpl' table='civicrm_contribution_page' field='pay_later_receipt' id=$contributionPageID}{/if}</th>
<td>{$form.pay_later_receipt.html|crmAddClass:big}<br />
<span class="description">{ts}Instructions added to Confirmation and Thank-you pages, as well as the confirmation email, when the user selects the 'pay later' option (e.g. 'Mail your check to ... within 3 business days.').{/ts}</span></td></tr>
<tr id="recurFields" class="crm-contribution-form-block-recurFields"><td> </td>
<td>
<table class="form-layout-compressed">
- <tr class="crm-contribution-form-block-recur_frequency_unit"><th scope="row" class="label">{$form.recur_frequency_unit.label}<span class="marker" title="This field is required.">*</span></th>
+ <tr class="crm-contribution-form-block-recur_frequency_unit"><th scope="row" class="label">{$form.recur_frequency_unit.label}<span class="crm-marker" title="This field is required.">*</span></th>
<td>{$form.recur_frequency_unit.html}<br />
<span class="description">{ts}Select recurring units supported for recurring payments.{/ts}</span></td>
</tr>
</tr>
<tr id="pledgeFields" class="crm-contribution-form-block-pledgeFields"><td></td><td>
<table class="form-layout-compressed">
- <tr class="crm-contribution-form-block-pledge_frequency_unit"><th scope="row" class="label">{$form.pledge_frequency_unit.label}<span class="marker"> *</span></th>
+ <tr class="crm-contribution-form-block-pledge_frequency_unit"><th scope="row" class="label">{$form.pledge_frequency_unit.label}<span class="crm-marker"> *</span></th>
<td>{$form.pledge_frequency_unit.html}<br />
<span class="description">{ts}Which frequencies can the user pick from (e.g. every 'week', every 'month', every 'year')?{/ts}</span></td>
</tr>
{/if}
<tr class="crm-contribution-form-block-amount_label">
- <th scope="row" class="label" width="20%">{$form.amount_label.label}<span class="marker"> *</span></th>
+ <th scope="row" class="label" width="20%">{$form.amount_label.label}<span class="crm-marker"> *</span></th>
<td>{$form.amount_label.html}</td>
</tr>
<tr class="crm-contribution-form-block-is_allow_other_amount"><th scope="row" class="label" width="20%">{$form.is_allow_other_amount.label}</th>
</tr>
<tr class="crm-contribution-contributionpage-premium-form-block-premiums_nothankyou_label">
<td class="label">
- {$form.premiums_nothankyou_label.label}<span class="marker"> *</span>
+ {$form.premiums_nothankyou_label.label}<span class="crm-marker"> *</span>
</td>
<td class="html-adjust">{$form.premiums_nothankyou_label.html}<br/>
<span class="description">{ts}You can change the text for the 'No thank-you' radio button.{/ts}</span>
<div id="widgetFields">
<table class="form-layout-compressed">
- <tr class="crm-contribution-contributionpage-widget-form-block-title"><td class="label">{$form.title.label}<span class="marker"> *</span></td><td>{$form.title.html}</td></tr>
+ <tr class="crm-contribution-contributionpage-widget-form-block-title"><td class="label">{$form.title.label}<span class="crm-marker"> *</span></td><td>{$form.title.html}</td></tr>
<tr class="crm-contribution-form-block-url_logo"><td class="label">{$form.url_logo.label}</span></td><td>{$form.url_logo.html}</td></tr>
<tr class="crm-contribution-contributionpage-widget-form-block-button_title"><td class="label">{$form.button_title.label}</td><td>{$form.button_title.html}</td></tr>
- <tr class="crm-contribution-contributionpage-widget-form-block-about"><td class="label">{$form.about.label}<span class="marker"> *</span></td><td>{$form.about.html}
+ <tr class="crm-contribution-contributionpage-widget-form-block-about"><td class="label">{$form.about.label}<span class="crm-marker"> *</span></td><td>{$form.about.html}
<br /><span class="description">{ts}Enter content for the about message. You may include HTML formatting tags. You can also include images, as long as they are already uploaded to a server - reference them using complete URLs.{/ts}</span>
</td></tr>
</div>
<table class="form-layout-compressed">
{foreach from=$colorFields item=field key=fieldName}
- <tr><td class="label">{$form.$fieldName.label}<span class="marker"> *</span></td><td>{$form.$fieldName.html}</td></tr>
+ <tr><td class="label">{$form.$fieldName.label}<span class="crm-marker"> *</span></td><td>{$form.$fieldName.html}</td></tr>
{/foreach}
</table>
</div><!-- /.crm-accordion-body -->
{/if}
{/if}
<tr>
- <td class="label">{ts}Paid By{/ts}</td>
+ <td class="label">{ts}Payment Method{/ts}</td>
<td>{$payment_instrument}{if $payment_processor_name} ({$payment_processor_name}){/if}</td>
</tr>
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
*}
-{* this template is used for adding/editing/deleting Payment-Instrument *}
+{* this template is used for adding/editing/deleting Payment-Method *}
<div class="crm-block crm-form-block crm-contribution-payment_instrument-form-block">
-<fieldset><legend>{if $action eq 1}{ts}New Payment Instrument{/ts}{elseif $action eq 2}{ts}Edit Payment Instrument{/ts}{else}{ts}Delete Payment Instrument{/ts}{/if}</legend>
+<fieldset><legend>{if $action eq 1}{ts}New Payment Method{/ts}{elseif $action eq 2}{ts}Edit Payment Method{/ts}{else}{ts}Delete Payment Method{/ts}{/if}</legend>
<div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="top"}</div>
{if $action eq 8}
<div class="messages status no-popup">
+--------------------------------------------------------------------+
*}
-<tr><td><label>{ts}Contribution Dates{/ts}</label></td></tr>
+<tr><td><label>{ts}Date Received{/ts}</label></td></tr>
<tr>
{include file="CRM/Core/DateRange.tpl" fieldName="contribution_date" from='_low' to='_high'}
</tr>
<th class="right">{ts}Amount{/ts} </th>
<th>{ts}Source{/ts}</th>
<th>{ts}Fee Amount{/ts}</th>
- <th>{ts}Paid By{/ts}</th>
+ <th>{ts}Payment Method{/ts}</th>
<th>{ts}Check{/ts} #</th>
<th>{ts}Transaction ID{/ts}</th>
<th>{ts}Transaction Date{/ts}</th>
{/htxt}
{htxt id="payment_instrument_id-title"}
- {ts}Payment Instrument{/ts}
+ {ts}Payment Method{/ts}
{/htxt}
{htxt id="payment_instrument_id"}
<p>
{ts}Choose the method by which this transaction was paid.{/ts}
</p><p>
- {ts}Note: if the correct payment instrument is not listed here (e.g. for in-kind donations) ask your administrator to add a new option to this list.{/ts}
+ {ts}Note: if the correct payment method is not listed here (e.g. for in-kind donations) ask your administrator to add a new option to this list.{/ts}
</p>
{/htxt}
*}
{crmRegion name="billing-block"}
<div id="payment_information">
- {if $paymentFields|@count && (!$form.$expressButtonName || $paymentProcessor.payment_processor_type EQ 'PayPal')}
+ {if $paymentFields|@count}
<fieldset class="billing_mode-group {$paymentTypeName}_info-group">
<legend>
{$paymentTypeLabel}
{ts}Importing Multi-value Custom Data{/ts}
{/htxt}
{htxt id="upload"}
- {ts}The import file should contain a row for each set of custom data fields. For example, if you are importing employment history for a group of contacts, each row might contain columns for Employer, Start Date, End Date, and Position. You will also need a column containing the CiviCRM Internal Contact ID which is used to match each row to the corresponding (existing) CiviCRM contact record. NOTE: Contact IDs are included by default when exporting contacts from CiviCRM.{/ts}
+ {ts}The import file should contain a row for each set of custom data fields. For example, if you are importing employment history for a group of contacts, each row might contain columns for Employer, Start Date, End Date, and Position. You will also need a column containing the CiviCRM Contact ID which is used to match each row to the corresponding (existing) CiviCRM contact record. NOTE: Contact IDs are included by default when exporting contacts from CiviCRM.{/ts}
{/htxt}
<td class="label">{ts}Selections{/ts}</td>
<td>{include file="CRM/Price/Page/LineItem.tpl" context="Event"}</td>
</tr>
- <tr>
- <td></td>
- <td>
- <a class="action-item crm-hover-button" href='{crmURL p="civicrm/event/participant/feeselection" q="reset=1&id=`$participantId`&cid=`$contactId`&action=update"}'><span class="icon ui-icon-pencil"></span> {ts}Change Selections{/ts}</a>
- </td>
- </tr>
{else}
<tr class="crm-event-eventfees-form-block-event_level">
<td class="label">{ts}Event Level{/ts}</td>
<td>{$fee_level} {if $fee_amount}- {$fee_amount|crmMoney:$fee_currency}{/if}</td>
</tr>
{/if}
+ <tr>
+ <td></td>
+ <td>
+ <a class="action-item crm-hover-button" href='{crmURL p="civicrm/event/participant/feeselection" q="reset=1&id=`$participantId`&cid=`$contactId`&action=update"}'><span class="icon ui-icon-pencil"></span> {ts}Change Selections{/ts}</a>
+ </td>
+ </tr>
{else} {* New participant *}
{if $priceSet.fields}
<fieldset id="priceset" class="crm-group priceset-group">
<fieldset><legend>{ts}Payment Information{/ts}</legend>
<table id="recordContribution" class="form-layout" style="width:auto;">
<tr class="crm-event-eventfees-form-block-financial_type_id">
- <td class="label">{$form.financial_type_id.label}<span class="marker"> *</span></td>
+ <td class="label">{$form.financial_type_id.label}<span class="crm-marker"> *</span></td>
<td>{$form.financial_type_id.html}<br /><span class="description">{ts}Select the appropriate financial type for this payment.{/ts}</span></td>
</tr>
<tr class="crm-event-eventfees-form-block-total_amount"><td class="label">{$form.total_amount.label}</td><td>{$form.total_amount.html|crmMoney:$currency}</td></tr>
<td class="label" >{$form.receive_date.label}</td>
<td>{include file="CRM/common/jcalendar.tpl" elementName=receive_date}</td>
</tr>
- <tr class="crm-event-eventfees-form-block-payment_instrument_id"><td class="label">{$form.payment_instrument_id.label}<span class="marker"> *</span></td><td>{$form.payment_instrument_id.html} {help id="payment_instrument_id" file="CRM/Contribute/Page/Tab.hlp"}</td></tr>
+ <tr class="crm-event-eventfees-form-block-payment_instrument_id"><td class="label">{$form.payment_instrument_id.label}<span class="crm-marker"> *</span></td><td>{$form.payment_instrument_id.html} {help id="payment_instrument_id" file="CRM/Contribute/Page/Tab.hlp"}</td></tr>
<tr id="checkNumber" class="crm-event-eventfees-form-block-check_number"><td class="label">{$form.check_number.label}</td><td>{$form.check_number.html|crmAddClass:six}</td></tr>
{if $showTransactionId }
<tr class="crm-event-eventfees-form-block-trxn_id"><td class="label">{$form.trxn_id.label}</td><td>{$form.trxn_id.html}</td></tr>
<table id="payLaterOptions" class="form-layout">
<tr class="crm-event-manage-fee-form-block-pay_later_text">
- <td class="label">{$form.pay_later_text.label}<span class="marker"> *</span> </td>
+ <td class="label">{$form.pay_later_text.label}<span class="crm-marker"> *</span> </td>
<td>{if $action == 2}{include file='CRM/Core/I18n/Dialog.tpl' table='civicrm_event' field='pay_later_text' id=$id}{/if}{$form.pay_later_text.html|crmAddClass:big}
</td>
</tr>
<td class="description">{ts}Text displayed next to the checkbox for the 'pay later' option on the contribution form. You may include HTML formatting tags.{/ts}</td>
</tr>
<tr class="crm-event-manage-fee-form-block-pay_later_receipt">
- <td class="label">{$form.pay_later_receipt.label}<span class="marker"> *</span> </td>
+ <td class="label">{$form.pay_later_receipt.label}<span class="crm-marker"> *</span> </td>
<td>{if $action == 2}{include file='CRM/Core/I18n/Dialog.tpl' table='civicrm_event' field='pay_later_receipt' id=$id}{/if}{$form.pay_later_receipt.html|crmAddClass:big}
</td>
</tr>
<table id="contributionType" class="form-layout">
<tr class="crm-event-manage-fee-form-block-fee_label">
- <td class="label">{$form.fee_label.label}<span class="marker"> *</span>
+ <td class="label">{$form.fee_label.label}<span class="crm-marker"> *</span>
</td>
<td>{if $action == 2}{include file='CRM/Core/I18n/Dialog.tpl' table='civicrm_event' field='fee_label' id=$id}{/if}{$form.fee_label.html}
</td>
</td>
</tr>
<tr class="crm-event-manage-fee-form-block-financial_type_id">
- <td class="label">{$form.financial_type_id.label}<span class="marker"> *</span></td>
+ <td class="label">{$form.financial_type_id.label}<span class="crm-marker"> *</span></td>
<td>{$form.financial_type_id.html}</td>
</tr>
<tr>
<table class="form-layout-compressed">
<tr class="crm-event-manage-registration-form-block-confirm_title">
<td scope="row" class="label" width="20%">{$form.confirm_title.label} <span
- class="marker">*</span> {if $action == 2}{include file='CRM/Core/I18n/Dialog.tpl' table='civicrm_event' field='confirm_title' id=$eventID}{/if}
+ class="crm-marker">*</span> {if $action == 2}{include file='CRM/Core/I18n/Dialog.tpl' table='civicrm_event' field='confirm_title' id=$eventID}{/if}
</td>
<td>{$form.confirm_title.html}<br/>
<span
<table class="form-layout-compressed">
<tr class="crm-event-manage-registration-form-block-confirm_thankyou_title">
<td scope="row" class="label" width="20%">{$form.thankyou_title.label} <span
- class="marker">*</span> {if $action == 2}{include file='CRM/Core/I18n/Dialog.tpl' table='civicrm_event' field='thankyou_title' id=$eventID}{/if}
+ class="crm-marker">*</span> {if $action == 2}{include file='CRM/Core/I18n/Dialog.tpl' table='civicrm_event' field='thankyou_title' id=$eventID}{/if}
</td>
<td>{$form.thankyou_title.html}
<div class="description">{ts}Page title for registration Thank-you screen.{/ts}</div>
</tr>
<tr class="crm-event-manage-registration-form-block-confirm_from_name">
<td scope="row" class="label" width="20%">{$form.confirm_from_name.label} <span
- class="marker">*</span> {if $action == 2}{include file='CRM/Core/I18n/Dialog.tpl' table='civicrm_event' field='confirm_from_name' id=$eventID}{/if}
+ class="crm-marker">*</span> {if $action == 2}{include file='CRM/Core/I18n/Dialog.tpl' table='civicrm_event' field='confirm_from_name' id=$eventID}{/if}
</td>
<td>{$form.confirm_from_name.html}<br/>
<span class="description">{ts}FROM name for email.{/ts}</span>
</td>
</tr>
<tr class="crm-event-manage-registration-form-block-confirm_from_email">
- <td scope="row" class="label" width="20%">{$form.confirm_from_email.label} <span class="marker">*</span></td>
+ <td scope="row" class="label" width="20%">{$form.confirm_from_email.label} <span class="crm-marker">*</span></td>
<td>{$form.confirm_from_email.html}<br/>
<span
class="description">{ts}FROM email address (this must be a valid email account with your SMTP email service provider).{/ts}</span>
{if $paidEvent}
<table class="form-layout-compressed">
<tr class="crm-event-additionalparticipant-form-block-amount">
- <td class="label nowrap">{$event.fee_label} <span class="marker">*</span></td>
+ <td class="label nowrap">{$event.fee_label} <span class="crm-marker">*</span></td>
<td> </td>
<td>{$form.amount.html}</td>
</tr>
<tr id="id_existing_group">
<td>
<table class="form-layout">
- <tr><td class="label">{$form.group_id.label}<span class="marker">*</span></td><td>{$form.group_id.html}</td></tr>
+ <tr><td class="label">{$form.group_id.label}<span class="crm-marker">*</span></td><td>{$form.group_id.html}</td></tr>
</table>
</td>
</tr>
<td>
<table class="form-layout">
<tr class="crm-contact-task-addtogroup-form-block-title">
- <td class="label">{$form.title.label}<span class="marker">*</span></td>
+ <td class="label">{$form.title.label}<span class="crm-marker">*</span></td>
<td>{$form.title.html}</td>
<tr>
<tr class="crm-contact-task-addtogroup-form-block-description">
<tr>
<th class="crm-batch-checkbox">{$form.toggleSelect.html}</th>
<th class="crm-batch-name">{ts}Batch Name{/ts}</th>
- <th class="crm-batch-payment_instrument">{ts}Payment Instrument{/ts}</th>
+ <th class="crm-batch-payment_instrument">{ts}Payment Method{/ts}</th>
<th class="crm-batch-item_count">{ts}Item Count{/ts}</th>
<th class="crm-batch-total">{ts}Total Amount{/ts}</th>
<th class="crm-batch-status">{ts}Status{/ts}</th>
{capture assign="typeLink"}{crmURL p="civicrm/admin/financial/financialType" q="reset=1"}{/capture}
{capture assign="paymentLink"}{crmURL p="civicrm/admin/options/payment_instrument" q="reset=1"}{/capture}
{capture assign="premiumLink"}{crmURL p="civicrm/admin/contribute/managePremiums" q="reset=1"}{/capture}
- <p>{ts 1=$typeLink 2=$paymentLink 3=$premiumLink}Financial accounts correspond to those in your accounting system. <a href="%1">Financial types</a>, <a href="%2">payment instruments</a>, and <a href="%3">premiums</a> are associated with financial accounts so that they can result in the proper double-entry transactions to export to your accounting system.{/ts}</p>
+ <p>{ts 1=$typeLink 2=$paymentLink 3=$premiumLink}Financial accounts correspond to those in your accounting system. <a href="%1">Financial types</a>, <a href="%2">payment methods</a>, and <a href="%3">premiums</a> are associated with financial accounts so that they can result in the proper double-entry transactions to export to your accounting system.{/ts}</p>
</div>
{if $action ne 1 and $action ne 2}
<div class="action-link">
+--------------------------------------------------------------------+
*}
{htxt id="payment_instrument-title"}
- {ts}Payment Instrument{/ts}
+ {ts}Payment Method{/ts}
{/htxt}
{htxt id="payment_instrument"}
<p>
- {ts}If you specify a payment instrument then this batch will be limited to exporting only transactions paid with that method.{/ts}
+ {ts}If you specify a payment method then this batch will be limited to exporting only transactions paid with that method.{/ts}
</p>
<p>
- {ts}Note that not all transactions are necessarily associated with a payment instrument.{/ts}
+ {ts}Note that not all transactions are necessarily associated with a payment method.{/ts}
</p>
{/htxt}
</tr>
<tr class="crm-membership-form-block-record_contribution"><td colspan="2">
<fieldset id="recordContribution"><legend>{ts}Membership Payment and Receipt{/ts}</legend>
- {/if}
- {include file="CRM/Member/Form/MembershipCommon.tpl"}
+
+ {include file="CRM/Member/Form/MembershipCommon.tpl"}
+ {/if}
{if $emailExists and $outBound_option != 2}
<tr id="send-receipt" class="crm-membership-form-block-send_receipt">
{if $form.target_entity_type}
<table class="form-layout">
<tr class="crm-contribution-contributionpage-pcp-form-block-target_entity_type">
- <td class="label">{$form.target_entity_type.label} <span class="marker"> *</span></td>
+ <td class="label">{$form.target_entity_type.label} <span class="crm-marker"> *</span></td>
<td>{$form.target_entity_type.html} {help id="id-target_entity_type"}</td>
</tr>
</table>
<div id="pcpDetailFields" {if $form.target_entity_type.value[0] == 'event'} style="display:none;"{/if}>
<table class="form-layout">
<tr class="crm-contribution-contributionpage-pcp-form-block-target_entity_id" id="pcpDetailFields">
- <td class="label">{$form.target_entity_id.label} <span class="marker"> *</span></td>
+ <td class="label">{$form.target_entity_id.label} <span class="crm-marker"> *</span></td>
<td>{$form.target_entity_id.html} {help id="id-target_entity_id"}</td>
</tr>
</table>
<div class="crm-footer" id="crm-record-log">
<span class="col1">
{if !empty($external_identifier)}{ts}External ID{/ts}: {$external_identifier}{/if}
- {if $action NEQ 2} {ts}CiviCRM ID{/ts}: {$contactId}{/if}
+ {if $action NEQ 2} {ts}Contact ID{/ts}: {$contactId}{/if}
</span>
{if !empty($lastModified)}
{ts}Last Change by{/ts}: <a href="{crmURL p='civicrm/contact/view' q="action=view&reset=1&cid=`$lastModified.id`"}">{$lastModified.name}</a> ({$lastModified.date|crmDate})
</form>
<ul>
<li><label class="crm-quickSearchField"><input type="radio" data-tablename="cc" checked="checked" value="" name="quickSearchField">{ts}Name/Email{/ts}</label></li>
- <li><label class="crm-quickSearchField"><input type="radio" data-tablename="cc" value="contact_id" name="quickSearchField">{ts}CiviCRM ID{/ts}</label></li>
+ <li><label class="crm-quickSearchField"><input type="radio" data-tablename="cc" value="contact_id" name="quickSearchField">{ts}Contact ID{/ts}</label></li>
<li><label class="crm-quickSearchField"><input type="radio" data-tablename="cc" value="external_identifier" name="quickSearchField">{ts}External ID{/ts}</label></li>
<li><label class="crm-quickSearchField"><input type="radio" data-tablename="cc" value="first_name" name="quickSearchField">{ts}First Name{/ts}</label></li>
<li><label class="crm-quickSearchField"><input type="radio" data-tablename="cc" value="last_name" name="quickSearchField">{ts}Last Name{/ts}</label></li>
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
require_once 'CiviTest/CiviUnitTestCase.php';
class CRM_Core_BAO_CustomValueTest extends CiviUnitTestCase {
public function testTypeCheckWithValidInput() {
- $values = array();
$values = array(
'Memo' => 'Test1',
'String' => 'Test',
}
public function testTypeCheckWithInvalidInput() {
- $values = array();
$values = array('check1' => 'chk');
foreach ($values as $type => $value) {
$valid = CRM_Core_BAO_CustomValue::typecheck($type, $value);
}
public function testTypeCheckWithWrongInput() {
- $values = array();
$values = array(
'String' => 1,
'Boolean' => 'US',
}
public function testTypeToFieldWithValidInput() {
- $values = array();
$values = array(
'String' => 'char_data',
'File' => 'char_data',
}
public function testTypeToFieldWithWrongInput() {
- $values = array();
$values = array(
'String' => 'memo_data',
'File' => 'date_data',
}
}
- public function testFixFieldValueOfTypeMemo() {
+ public function fixCustomFieldValue() {
$customGroup = Custom::createGroup(array(), 'Individual');
$fields = array(
$customField = Custom::createField(array(), $fields);
$custom = 'custom_' . $customField->id;
- $params = array();
$params = array(
'email' => 'abc@webaccess.co.in',
$custom => 'note',
);
- CRM_Core_BAO_CustomValue::fixFieldValueOfTypeMemo($params);
+ CRM_Core_BAO_CustomValue::fixCustomFieldValue($params);
$this->assertEquals($params[$custom], '%note%', 'Checking the returned value of type Memo.');
Custom::deleteField($customField);
Custom::deleteGroup($customGroup);
}
- public function testFixFieldValueOfTypeMemoWithEmptyParams() {
+ public function testFixCustomFieldValueWithEmptyParams() {
$params = array();
- $result = CRM_Core_BAO_CustomValue::fixFieldValueOfTypeMemo($params);
+ $result = CRM_Core_BAO_CustomValue::fixCustomFieldValue($params);
$this->assertEquals($result, NULL, 'Checking the returned value of type Memo.');
}
$contribution = new CRM_Contribute_BAO_Contribution();
$contribution->id = $this->_contributionId;
$contribution->find(TRUE);
- $contribution->loadRelatedObjects($this->input, $this->ids, FALSE, TRUE);
+ $contribution->loadRelatedObjects($this->input, $this->ids, TRUE);
$this->assertFalse(empty($contribution->_relatedObjects['membership']));
$this->assertArrayHasKey($this->_membershipTypeID, $contribution->_relatedObjects['membership']);
$this->assertTrue(is_a($contribution->_relatedObjects['membership'][$this->_membershipTypeID], 'CRM_Member_BAO_Membership'));
*/
public function testRequiredWithoutProcessorID() {
$this->_setUpPledgeObjects();
- $values = array();
$result = $this->IPN->loadObjects($this->input, $this->ids, $this->objects, TRUE, NULL, array('return_error' => 1));
$this->assertArrayHasKey('error_message', $result);
$this->assertEquals('Could not find payment processor for contribution record: 1', $result['error_message']);
}
/**
- *
* Test that an error is not if required set & no processor ID
*/
public function testRequiredWithContributionPage() {
$this->_setUpContributionObjects(TRUE);
$result = $this->IPN->loadObjects($this->input, $this->ids, $this->objects, TRUE, NULL, array('return_error' => 1));
- $this->assertFalse(is_array($result), $result['error_message']);
+ $this->assertEquals(1, $result['is_error']);
+ ;
+ }
+
+ /**
+ * Test that if part of $input the payment processor loads OK.
+ *
+ * It's preferable to pass it in as it cannot be correctly calculated.
+ */
+ public function testPaymentProcessorLoadsAsParam() {
+ $this->_setUpContributionObjects();
+ $this->input = array_merge($this->input, array('payment_processor_id' => $this->_processorId));
+ $this->assertTrue($this->IPN->loadObjects($this->input, $this->ids, $this->objects, TRUE, NULL, array('return_error' => 1)));
}
/**
$this->_setUpContributionObjects();
$result = $this->IPN->loadObjects($this->input, $this->ids, $this->objects, TRUE, NULL, array('return_error' => 1));
$this->assertArrayHasKey('error_message', $result);
- $this->assertEquals('Could not find contribution page for contribution record: 1', $result['error_message']);
+ $this->assertEquals('Could not find payment processor for contribution record: 1', $result['error_message']);
// error is only returned if $required set to True
$result = $this->IPN->loadObjects($this->input, $this->ids, $this->objects, FALSE, NULL, array('return_error' => 1));
$this->assertFalse(is_array($result));
$this->assertAPISuccess($result['values'][$result['id']]['api.Email.create']);
}
+ /**
+ * When the reload option is combined with chaining, the reload should munge
+ * the chain results, even if sequential=1.
+ */
+ public function testReloadNoChainInterferenceSequential() {
+ $result = $this->callAPISuccess('contact', 'create', array(
+ 'sequential' => 1,
+ 'contact_type' => 'Individual',
+ 'first_name' => 'First',
+ 'last_name' => 'Last',
+ 'nick_name' => 'Firstie',
+ 'api.Email.create' => array(
+ 'email' => 'test@example.com',
+ ),
+ 'options' => array(
+ 'reload' => 1,
+ ),
+ ));
+ $this->assertEquals('First', $result['values'][0]['first_name']);
+ $this->assertEquals('munged', $result['values'][0]['nick_name']);
+ $this->assertAPISuccess($result['values'][0]['api.Email.create']);
+ }
+
/**
* An implementation of hook_civicrm_post used with all our test cases.
*
$this->click("_qf_Contact_upload_view-bottom");
$this->waitForPageToLoad($this->getTimeoutMsec());
$this->waitForText('crm-notification-container', "Contact Saved");
- $mainId = explode("CiviCRM ID:", trim($this->getText("xpath=//div[@id='crm-record-log']/span[@class='col1']")));
+ $mainId = explode("Contact ID:", trim($this->getText("xpath=//div[@id='crm-record-log']/span[@class='col1']")));
$mainId = trim($mainId[1]);
//Duplicate of above contact.
$this->click("_qf_Contact_upload_duplicate");
$this->waitForPageToLoad($this->getTimeoutMsec());
$this->waitForText('crm-notification-container', "Contact Saved");
- $duplicateId = explode("CiviCRM ID:", trim($this->getText("xpath=//div[@id='crm-record-log']/span[@class='col1']")));
+ $duplicateId = explode("Contact ID:", trim($this->getText("xpath=//div[@id='crm-record-log']/span[@class='col1']")));
$duplicateId = trim($duplicateId[1]);
return array(
$sortName = "adv$firstName, $firstName";
$displayName = "$firstName adv$firstName";
- $this->_searchBuilder("Zip / Postal Code", "100[0-9]", $sortName, "RLIKE");
+ $this->_searchBuilder("Postal Code", "100[0-9]", $sortName, "RLIKE");
}
/**
$this->_createContact('Household', $firstName7, "$firstName7@advsearch.co.in", NULL, $postalCode);
// check if the resultset of search builder and advanced search match for the postal code
- $this->_searchBuilder('Zip / Postal Code', $postalCode, NULL, 'LIKE', '4');
+ $this->_searchBuilder('Postal Code', $postalCode, NULL, 'LIKE', '4');
$this->_advancedSearch($postalCode, NULL, NULL, '4', 'postal_code');
$firstName8 = "abcc" . substr(sha1(rand()), 0, 7);
'bodyLocator' => 'select#financial_type_id',
'title' => 'Contributions',
'fields' => array(
- 'Contribution Dates' => array(
+ 'Date Received' => array(
'type' => 'select',
'locator' => 'contribution_date_relative',
'values' => array('Today'),
'bodyLocator' => 'select#pledge_payment_date_relative',
'title' => 'Pledges',
'fields' => array(
- 'Contribution Dates' => array(
+ 'Date Received' => array(
'type' => 'select',
'locator' => 'pledge_payment_date_relative',
'values' => array('Prior to Previous Month'),
'From' => $contact['display_name'],
'Financial Type' => $financialType,
'Contribution Amount' => 'Contribution Total: $ 590.00',
- 'Paid By' => 'Check',
+ 'Payment Method' => 'Check',
'Check Number' => '1041',
'Contribution Status' => 'Completed',
);
'Financial Type' => $fields['values'][$fields['id']]['financial_type'],
'Contribution Amount' => $fields['values'][$fields['id']]['total_amount'],
'Contribution Status' => $fields['values'][$fields['id']]['contribution_status'],
- 'Paid By' => $fields['values'][$fields['id']]['payment_instrument'],
+ 'Payment Method' => $fields['values'][$fields['id']]['payment_instrument'],
'Check Number' => $fields['values'][$fields['id']]['contribution_check_number'],
);
'From' => $firstName . " Anderson",
'Financial Type' => 'Donation',
'Contribution Status' => 'Completed',
- 'Paid By' => 'Check',
+ 'Payment Method' => 'Check',
'Total Amount' => '$ 100.00',
'Non-deductible Amount' => '$ 12.50',
'Check Number' => 'check #1041',
'Financial Type' => 'Donation',
'Total Amount' => '100.00',
'Contribution Status' => 'Completed',
- 'Paid By' => 'Check',
+ 'Payment Method' => 'Check',
'Check Number' => 'check #1041',
'Non-deductible Amount' => '10.00',
'Received Into' => $financialAccount,
'Financial Type' => 'Donation',
'Total Amount' => '0.00',
'Contribution Status' => 'Completed',
- 'Paid By' => 'Credit Card',
+ 'Payment Method' => 'Credit Card',
);
$this->webtestVerifyTabularData($expected);
}
'Financial Type' => 'Donation (test)',
'Total Amount' => 'Installments: 12, Interval: 1 month(s)',
'Contribution Status' => 'Pending : Incomplete Transaction',
- 'Paid By' => 'Credit Card',
+ 'Payment Method' => 'Credit Card',
);
foreach ($verifyData as $label => $value) {
'Financial Type' => 'Donation (test)',
'Total Amount' => 'Installments: 12, Interval: 1 month(s)',
'Contribution Status' => 'Pending : Incomplete Transaction',
- 'Paid By' => 'Credit Card',
+ 'Payment Method' => 'Credit Card',
'Online Contribution Page' => $pageTitle,
);
foreach ($verifyData as $label => $value) {
'Financial Type' => 'Donation',
'Total Amount' => '$ 100.00',
'Contribution Status' => 'Completed',
- 'Paid By' => 'Check',
+ 'Payment Method' => 'Check',
'Check Number' => 'check #1041',
);
'Financial Type' => $financialType['name'],
'Total Amount' => '$ 100.00',
'Contribution Status' => 'Completed',
- 'Paid By' => 'Check',
+ 'Payment Method' => 'Check',
'Check Number' => 'check #1041',
);
'Financial Type' => 'Donation',
'Total Amount' => '100.00',
'Contribution Status' => 'Pending',
- 'Paid By' => 'Check',
+ 'Payment Method' => 'Check',
'Check Number' => 'check #1041',
);
$this->webtestVerifyTabularData($expected);
'Financial Type' => 'Event Fee',
'Total Amount' => '$ 800.00',
'Contribution Status' => 'Completed',
- 'Paid By' => 'Check',
+ 'Payment Method' => 'Check',
'Check Number' => '1044',
)
);
'From' => $displayName,
'Financial Type' => 'Event Fee',
'Contribution Status' => 'Completed',
- 'Paid By' => 'Check',
+ 'Payment Method' => 'Check',
'Check Number' => '1044',
)
);
'From' => $displayName,
'Financial Type' => 'Event Fee',
'Contribution Status' => 'Completed',
- 'Paid By' => 'Check',
+ 'Payment Method' => 'Check',
'Check Number' => '1044',
'Received Into' => 'Deposit Bank Account',
)
'Financial Type' => 'Event Fee',
'Total Amount' => '$ 800.00',
'Contribution Status' => 'Partially paid',
- 'Paid By' => 'Check',
+ 'Payment Method' => 'Check',
'Check Number' => '1044',
)
);
'Financial Type' => 'Event Fee',
'Total Amount' => '$ 800.00',
'Contribution Status' => 'Completed',
- 'Paid By' => 'Check',
+ 'Payment Method' => 'Check',
'Check Number' => '1044',
)
);
$this->waitForElementPresent("xpath=//td[@id='payment-info']/table[@id='info']/tbody/tr[2]/td[2]/a");
$this->clickAjaxLink("xpath=//td[@id='payment-info']/table[@id='info']/tbody/tr[2]/td[2]/a");
$this->waitForElementPresent("xpath=//table[@id='info']/tbody/tr/th[contains(text(), 'Amount')]/../../tr[2]/td[contains(text(), '$ 400.00')]/../../tr[3]/td[contains(text(), '$ 400.00')]");
- $this->waitForElementPresent("xpath=//table[@id='info']/tbody/tr/th[3][contains(text(), 'Paid By')]/../../tr[2]/td[3][contains(text(), 'Check')]/../../tr[3]/td[3][contains(text(), 'Cash')]");
+ $this->waitForElementPresent("xpath=//table[@id='info']/tbody/tr/th[3][contains(text(), 'Payment Method')]/../../tr[2]/td[3][contains(text(), 'Check')]/../../tr[3]/td[3][contains(text(), 'Cash')]");
$this->waitForElementPresent("xpath=//table[@id='info']/tbody/tr/th[6][contains(text(), 'Status')]/../../tr[2]/td[6][contains(text(), 'Completed')]/../../tr[3]/td[6][contains(text(), 'Completed')]");
}
--- /dev/null
+<?php
+/*
+ +--------------------------------------------------------------------+
+ | CiviCRM version 4.6 |
+ +--------------------------------------------------------------------+
+ | Copyright CiviCRM LLC (c) 2004-2015 |
+ +--------------------------------------------------------------------+
+ | This file is a part of CiviCRM. |
+ | |
+ | CiviCRM is free software; you can copy, modify, and distribute it |
+ | under the terms of the GNU Affero General Public License |
+ | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
+ | |
+ | CiviCRM is distributed in the hope that it will be useful, but |
+ | WITHOUT ANY WARRANTY; without even the implied warranty of |
+ | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
+ | See the GNU Affero General Public License for more details. |
+ | |
+ | You should have received a copy of the GNU Affero General Public |
+ | License along with this program; if not, contact CiviCRM LLC |
+ | at info[AT]civicrm[DOT]org. If you have questions about the |
+ | GNU Affero General Public License or the licensing of CiviCRM, |
+ | see the CiviCRM license FAQ at http://civicrm.org/licensing |
+ +--------------------------------------------------------------------+
+ */
+
+require_once 'CiviTest/CiviUnitTestCase.php';
+require_once 'CiviTest/CiviSeleniumSettings.php';
+
+/**
+ * Include configuration
+ */
+define('CIVICRM_SETTINGS_PATH', __DIR__ . '/civicrm.settings.dist.php');
+define('CIVICRM_SETTINGS_LOCAL_PATH', __DIR__ . '/civicrm.settings.local.php');
+define('CIVICRM_WEBTEST', 1);
+
+if (file_exists(CIVICRM_SETTINGS_LOCAL_PATH)) {
+ require_once CIVICRM_SETTINGS_LOCAL_PATH;
+}
+require_once CIVICRM_SETTINGS_PATH;
+
+
+/**
+ * Check that we handle redirects appropriately.
+ */
+class WebTest_Utils_RedirectTest extends CiviUnitTestCase {
+ protected $url;
+ protected $ch;
+
+ /**
+ * @param string|null $name
+ */
+ public function __construct($name = NULL) {
+ parent::__construct($name);
+
+ $this->settings = new CiviSeleniumSettings();
+ if (property_exists($this->settings, 'serverStartupTimeOut') && $this->settings->serverStartupTimeOut) {
+ global $CiviSeleniumTestCase_polled;
+ if (!$CiviSeleniumTestCase_polled) {
+ $CiviSeleniumTestCase_polled = TRUE;
+ CRM_Utils_Network::waitForServiceStartup(
+ $this->drivers[0]->getHost(),
+ $this->drivers[0]->getPort(),
+ $this->settings->serverStartupTimeOut
+ );
+ }
+ }
+ }
+
+ protected function setUp() {
+ parent::setUp();
+ //URL should eventually be adapted for multisite
+ $this->url = $this->settings->sandboxURL;
+
+ $this->ch = curl_init();
+ curl_setopt($this->ch, CURLOPT_HEADER, FALSE);
+ curl_setopt($this->ch, CURLOPT_FOLLOWLOCATION, FALSE);
+ // curl_setopt($this->ch, CURLOPT_ENCODING, 'gzip');
+ // curl_setopt($this->ch, CURLOPT_VERBOSE, 0);
+ }
+
+ /**
+ *
+ */
+ private function tryRedirect($input_url, $expected_url) {
+ // file_put_contents('php://stderr', $input_url . "\n", FILE_APPEND);
+ $url = $this->url . '/' . $input_url;
+ $expected_url = $this->url . '/' . $expected_url;
+ curl_setopt($this->ch, CURLOPT_URL, $url);
+ $req = curl_exec($this->ch);
+ $this->assertEquals(0, curl_errno($this->ch), 'cURL error: ' . curl_error($this->ch));
+ if (!curl_errno($this->ch)) {
+ $info = curl_getinfo($this->ch);
+ // file_put_contents('php://stderr', print_r($info,1), FILE_APPEND);
+ $this->assertEquals($expected_url, $info['redirect_url']);
+ $this->assertEquals('302', $info['http_code']);
+ }
+ }
+
+ /**
+ * Handle onsite redirects with absolute URL.
+ */
+ public function testAbsoluteOnsiteRedirect() {
+ $this->tryRedirect("civicrm/contribute/transact?qfKey=xxx&entryURL={$this->url}/civicrm/contribute/transact%3Fid%3D1", 'civicrm/contribute/transact?id=1');
+ }
+
+ /**
+ * Handle onsite redirects with slash prefix and query params.
+ */
+ public function testOnsiteRedirectWithSlashPrefixAndQueryParams() {
+ $this->tryRedirect('civicrm/contribute/transact?qfKey=xxx&entryURL=/civicrm/contribute/transact%3Fid%3D1', 'civicrm/contribute/transact?id=1');
+ }
+
+ /**
+ * Handle onsite redirects with non-CiviCRM paths.
+ */
+ public function testOtherpathRedirect() {
+ $this->tryRedirect('civicrm/contribute/transact?qfKey=xxx&entryURL=asdf', 'asdf');
+ }
+
+ /**
+ * Handle offsite redirects without path as onsite redirects.
+ */
+ public function testOffsiteRedirectNoPath() {
+ $this->tryRedirect('civicrm/contribute/transact?qfKey=xxx&entryURL=http://evil.example.com/', '');
+ }
+
+ /**
+ * Handle offsite redirects with paths as onsite redirects.
+ */
+ public function testOffsiteRedirectWithPath() {
+ $this->tryRedirect('civicrm/contribute/transact?qfKey=xxx&entryURL=http://evil.example.com/civicrm', 'civicrm');
+ }
+
+}
-Contact ID,External ID,Contribution Type,Amount,Date,Paid By,Source,Transaction ID,Fee Amount,Non-deductible,Check #\r2,22,Campaign Contribution,125,20081011,Check,Oct 2005 Mailer 1,,,125,109\r4,44,Donation,50,20080921,Credit Card,Online: Save the Penguins,P20901X9,1.75,,\r6,66,Campaign Contribution,25,20081029,Check,Oct 2005 Mailer 1,,,25,2309\r55,55abc,Campaign Contribution,2175,20081011,Check,Oct 2005 Mailer 1,,,175,1902\r32,3232abc,Donation,50,20080927,Credit Card,Online: Save the Penguins,P20193L235,1.75,,\r92,9292,Donation,10,20080908,Credit Card,Online: Save the Penguins,P40232Y256,0.27,,\r34,3434,Donation,250,20081022,Credit Card,Online: Save the Penguins,P20193SSS092,3.55,,\r199,199199,Donation,250,20081022,Credit Card,Online: Save the Penguins,XJA090322,3.55,,
\ No newline at end of file
+Contact ID,External ID,Contribution Type,Amount,Date,Payment Method,Source,Transaction ID,Fee Amount,Non-deductible,Check #\r2,22,Campaign Contribution,125,20081011,Check,Oct 2005 Mailer 1,,,125,109\r4,44,Donation,50,20080921,Credit Card,Online: Save the Penguins,P20901X9,1.75,,\r6,66,Campaign Contribution,25,20081029,Check,Oct 2005 Mailer 1,,,25,2309\r55,55abc,Campaign Contribution,2175,20081011,Check,Oct 2005 Mailer 1,,,175,1902\r32,3232abc,Donation,50,20080927,Credit Card,Online: Save the Penguins,P20193L235,1.75,,\r92,9292,Donation,10,20080908,Credit Card,Online: Save the Penguins,P40232Y256,0.27,,\r34,3434,Donation,250,20081022,Credit Card,Online: Save the Penguins,P20193SSS092,3.55,,\r199,199199,Donation,250,20081022,Credit Card,Online: Save the Penguins,XJA090322,3.55,,
\ No newline at end of file
-Email,Contribution Type,Amount,Receive Date,Paid By,Source,Transaction ID,Invoice ID,Status,Comments\rjake@foo.org,Donation,125,,,Oct 2005 Mailer 1,,,Completed,Coming in by mail.\rdggreenberg@gmail.com,Donation,50,20060111,Check,Dec 2005 Mailer,,,Pending,\radamspeter@hotmail.com,Member Dues,25,20051029,Check,Oct 2005 Mailer 1,check #2095,10924,Completed,\r,Member Dues,50,20051011,Check,Oct 2005 Mailer 1,check #10552,10925,Completed,
\ No newline at end of file
+Email,Contribution Type,Amount,Receive Date,Payment Method,Source,Transaction ID,Invoice ID,Status,Comments\rjake@foo.org,Donation,125,,,Oct 2005 Mailer 1,,,Completed,Coming in by mail.\rdggreenberg@gmail.com,Donation,50,20060111,Check,Dec 2005 Mailer,,,Pending,\radamspeter@hotmail.com,Member Dues,25,20051029,Check,Oct 2005 Mailer 1,check #2095,10924,Completed,\r,Member Dues,50,20051011,Check,Oct 2005 Mailer 1,check #10552,10925,Completed,
\ No newline at end of file
-External ID,Contribution Type,Amount,Date,Paid By,Source,Transaction ID,Fee Amount,Non-deductible\rN101,Campaign Contribution,125,20051011,Check,Oct 2005 Mailer 1,check #1066,,125\rN102,Donation,50,20050921,Credit Card,Online: Save the Penguins,P20901X9,1.75,\rN103,Campaign Contribution,25,20051029,Check,Oct 2005 Mailer 1,Acct 2099002 check #2098,,25\rN105,Campaign Contribution,50,20051011,Cash,Oct 2005 Mailer 1,,,50\rN110,Campaign Contribution,500,20051015,Check,Oct 2005 Mailer 1,10909131 #09022,,500
\ No newline at end of file
+External ID,Contribution Type,Amount,Date,Payment Method,Source,Transaction ID,Fee Amount,Non-deductible\rN101,Campaign Contribution,125,20051011,Check,Oct 2005 Mailer 1,check #1066,,125\rN102,Donation,50,20050921,Credit Card,Online: Save the Penguins,P20901X9,1.75,\rN103,Campaign Contribution,25,20051029,Check,Oct 2005 Mailer 1,Acct 2099002 check #2098,,25\rN105,Campaign Contribution,50,20051011,Cash,Oct 2005 Mailer 1,,,50\rN110,Campaign Contribution,500,20051015,Check,Oct 2005 Mailer 1,10909131 #09022,,500
\ No newline at end of file
-Contact ID,Contribution Type,Amount,Date,Paid By,Source,Transaction ID,Fee Amount,Non-deductible,Region-Alpha,Region-Int,External ID\r103,Campaign Contribution,33,20070111,Check,Mar 2007 Mailer 1,check #1066,,125,East,1,N101\r104,Donation,33,20070521,Credit Card,Online: Save the Penguins,P20901X9,1.75,,East Region,East Region,N110\r105,Campaign Contribution,33,20070129,Check,Mar 2007 Mailer 1,Acct 2099002 check #2098,,25,West,2,N102\r105,Campaign Contribution,33,20070411,Cash,Mar 2007 Mailer 1,,,50,West Region,West Region,N105\r107,Donation,33,20070315,Check,Mar 2007 Mailer 1,10909131 #09022,,500,Foo,3,N105
\ No newline at end of file
+Contact ID,Contribution Type,Amount,Date,Payment Method,Source,Transaction ID,Fee Amount,Non-deductible,Region-Alpha,Region-Int,External ID\r103,Campaign Contribution,33,20070111,Check,Mar 2007 Mailer 1,check #1066,,125,East,1,N101\r104,Donation,33,20070521,Credit Card,Online: Save the Penguins,P20901X9,1.75,,East Region,East Region,N110\r105,Campaign Contribution,33,20070129,Check,Mar 2007 Mailer 1,Acct 2099002 check #2098,,25,West,2,N102\r105,Campaign Contribution,33,20070411,Cash,Mar 2007 Mailer 1,,,50,West Region,West Region,N105\r107,Donation,33,20070315,Check,Mar 2007 Mailer 1,10909131 #09022,,500,Foo,3,N105
\ No newline at end of file
$this->assertEquals(1, $contact['id']);
}
+ /**
+ * Test creating individual by display_name.
+ *
+ * Display name & sort name should be set.
+ */
+ public function testCreateDisplayNameIndividual() {
+ $params = array(
+ 'display_name' => 'abc1',
+ 'contact_type' => 'Individual',
+ );
+
+ $contact = $this->callAPISuccess('contact', 'create', $params);
+ $params['sort_name'] = 'abc1';
+ $this->getAndCheck($params, $contact['id'], 'contact');
+ }
+
/**
* Test old keys still work.
*
}
/**
- * Verify attempt to create individual with chained arrays.
+ * Verify attempt to create individual with chained arrays and sequential
+ */
+ public function testGetIndividualWithChainedArraysAndSequential() {
+ $ids = $this->entityCustomGroupWithSingleFieldCreate(__FUNCTION__, __FILE__);
+ $params['custom_' . $ids['custom_field_id']] = "custom string";
+
+ $moreids = $this->CustomGroupMultipleCreateWithFields();
+ $description = "/*this demonstrates the usage of chained api functions. In this case no notes or custom fields have been created ";
+ $subfile = "APIChainedArray";
+ $params = array(
+ 'sequential' => 1,
+ 'first_name' => 'abc3',
+ 'last_name' => 'xyz3',
+ 'contact_type' => 'Individual',
+ 'email' => 'man3@yahoo.com',
+ 'api.website.create' => array(
+ array(
+ 'url' => "http://civicrm.org",
+ ),
+ array(
+ 'url' => "https://civicrm.org",
+ ),
+ ),
+ );
+
+ $result = $this->callAPISuccess('Contact', 'create', $params);
+
+ // delete the contact and custom groups
+ $this->callAPISuccess('contact', 'delete', array('id' => $result['id']));
+ $this->customGroupDelete($ids['custom_group_id']);
+ $this->customGroupDelete($moreids['custom_group_id']);
+
+ $this->assertEquals($result['id'], $result['values'][0]['id']);
+ $this->assertArrayKeyExists('api.website.create', $result['values'][0]);
+ }
+
+ /**
+ * Verify attempt to create individual with chained arrays
*/
public function testGetIndividualWithChainedArrays() {
$ids = $this->entityCustomGroupWithSingleFieldCreate(__FUNCTION__, __FILE__);
$this->assertEquals("http://civicrm.org", $result['values'][$result['id']]['api.website.get']['values'][0]['url']);
}
+ /**
+ * Verify attempt to create individual with chained arrays and sequential.
+ *
+ * See https://issues.civicrm.org/jira/browse/CRM-15815
+ */
+ public function testCreateIndividualWithChainedArrayAndSequential() {
+ $params = array(
+ 'sequential' => 1,
+ 'first_name' => 'abc5',
+ 'last_name' => 'xyz5',
+ 'contact_type' => 'Individual',
+ 'email' => 'woman5@yahoo.com',
+ 'api.phone.create' => array(
+ array('phone' => '03-231 07 95'),
+ array('phone' => '03-232 51 62'),
+ ),
+ 'api.website.create' => array(
+ 'url' => 'http://civicrm.org',
+ ),
+ );
+ $result = $this->callAPISuccess('Contact', 'create', $params);
+
+ // I could try to parse the result to see whether the two phone numbers
+ // and the website are there, but I am not sure about the correct format.
+ // So I will just fetch it again before checking.
+ // See also http://forum.civicrm.org/index.php/topic,35393.0.html
+ $params = array(
+ 'sequential' => 1,
+ 'id' => $result['id'],
+ 'api.website.get' => array(),
+ 'api.phone.get' => array(),
+ );
+ $result = $this->callAPISuccess('Contact', 'get', $params);
+
+ // delete the contact
+ $this->callAPISuccess('contact', 'delete', $result);
+
+ $this->assertEquals(2, $result['values'][0]['api.phone.get']['count']);
+ $this->assertEquals(1, $result['values'][0]['api.website.get']['count']);
+ }
+
public function testGetIndividualWithChainedArraysFormats() {
$description = "This demonstrates the usage of chained api functions.\nIn this case no notes or custom fields have been created.";
$subfile = "APIChainedArrayFormats";
'contribution_page_id' => $this->_ids['contribution_page'],
'contribution_status_id' => 1,
));
+
+ $this->assertEquals('create_first_success', $contribution['trxn_id']);
$membershipPayment = $this->callAPISuccess('membership_payment', 'getsingle', array());
$this->assertEquals($membershipPayment['contribution_id'], $contribution['id']);
$membership = $this->callAPISuccessGetSingle('membership', array('id' => $membershipPayment['membership_id']));
*/
public function testCompleteTransactionMembershipPriceSet() {
$this->createPriceSetWithPage('membership');
+ $stateOfGrace = $this->callAPISuccess('MembershipStatus', 'getvalue', array(
+ 'name' => 'Grace',
+ 'return' => 'id')
+ );
$this->setUpPendingContribution($this->_ids['price_field_value'][0]);
+ $membership = $this->callAPISuccess('membership', 'getsingle', array('id' => $this->_ids['membership']));
+ $logs = $this->callAPISuccess('MembershipLog', 'get', array(
+ 'membership_id' => $this->_ids['membership'],
+ ));
+ $this->assertEquals(1, $logs['count']);
+ $this->assertEquals($stateOfGrace, $membership['status_id']);
$this->callAPISuccess('contribution', 'completetransaction', array('id' => $this->_ids['contribution']));
$membership = $this->callAPISuccess('membership', 'getsingle', array('id' => $this->_ids['membership']));
$this->assertEquals(date('Y-m-d', strtotime('yesterday + 1 year')), $membership['end_date']);
+ $this->callAPISuccessGetSingle('LineItem', array(
+ 'entity_id' => $this->_ids['membership'],
+ 'entity_table' => 'civicrm_membership',
+ ));
+ $logs = $this->callAPISuccess('MembershipLog', 'get', array(
+ 'membership_id' => $this->_ids['membership'],
+ ));
+ $this->assertEquals(2, $logs['count']);
+ $this->assertNotEquals($stateOfGrace, $logs['values'][2]['status_id']);
$this->cleanUpAfterPriceSets();
}
'membership_type_id' => $this->_ids['membership_type'],
'start_date' => 'yesterday - 1 year',
'end_date' => 'yesterday',
+ 'join_date' => 'yesterday - 1 year',
));
$contribution = $this->callAPISuccess('contribution', 'create', array(
'domain_id' => 1,
}
/**
- * @param $contribution
- * @param $context
+ * @param array $contribution
+ * @param string $context
* @param int $instrumentId
*/
public function _checkFinancialTrxn($contribution, $context, $instrumentId = NULL) {
$this->callAPISuccess('event', 'delete', array('id' => $result['id']));
}
+ /**
+ * Chaining get event and loc block.
+ */
+ public function testChainingGetLocBlock() {
+ // create a loc block and an event for that loc block.
+ $eventParams = $this->_params[0];
+ $eventParams['loc_bloc_id'] = '$value.id';
+ $locBlockParams = array(
+ 'address' => array(
+ 'street_address' => 'Kipdorp 24',
+ 'postal_code' => '2000',
+ 'city' => 'Antwerpen',
+ 'country_id' => '1020',
+ 'location_type_id' => '1',
+ ),
+ 'api.Event.create' => $eventParams,
+ 'sequential' => 1,
+ );
+ $createResult = $this->callAPIAndDocument('LocBlock', 'create', $locBlockParams, __FUNCTION__, __FILE__);
+ $locBlockId = $createResult['id'];
+ $addressId = $createResult['values'][0]['address_id'];
+ $eventId = $createResult['values'][0]['api.Event.create']['id'];
+
+ // request the event with its loc block:
+ $check = $this->callAPISuccess($this->_entity, 'getsingle', array(
+ 'id' => $eventId,
+ 'api.LocBlock.get' => array('id' => '$value.loc_block_id'),
+ 'sequential' => 1,
+ ));
+
+ // assert
+ $this->assertEquals($eventId, $check['id'], ' in line ' . __LINE__);
+ $this->assertEquals(1, $check['api.LocBlock.get']['count'], ' in line ' . __LINE__);
+ $this->assertEquals($locBlockId, $check['api.LocBlock.get']['id'], ' in line ' . __LINE__);
+
+ // cleanup
+ $this->callAPISuccess($this->_entity, 'delete', array('id' => $eventId));
+ }
+
+ /**
+ * Chaining get event and non existing loc block.
+ *
+ * Even if there is no loc block, at least the event should be returned.
+ * http://forum.civicrm.org/index.php/topic,36113.0.html
+ */
+ public function testChainingGetNonExistingLocBlock() {
+ $params = $this->_params[0];
+ $result = $this->callAPISuccess($this->_entity, 'create', $params);
+
+ $check = $this->callAPISuccess($this->_entity, 'get', array(
+ 'id' => $result['id'],
+ // this chaining request should not break things:
+ 'api.LocBlock.get' => array('id' => '$value.loc_block_id'),
+ ));
+ $this->assertEquals($result['id'], $check['id']);
+
+ $this->callAPISuccess($this->_entity, 'Delete', array('id' => $result['id']));
+ }
+
/**
* Check with complete array + custom field.
*
protected $_contactId;
protected $_contactId1;
protected $_apiversion = 3;
+
+ /**
+ * @var int
+ */
protected $_groupId1;
+ /**
+ * @var int
+ */
+ protected $_groupId2;
+
/**
* Set up for group contact tests.
*
$this->_contactId = $this->individualCreate();
$this->_groupId1 = $this->groupCreate();
- $params = array(
+
+ $this->callAPISuccess('group_contact', 'create', array(
'contact_id' => $this->_contactId,
'group_id' => $this->_groupId1,
- );
+ ));
- $result = $this->callAPISuccess('group_contact', 'create', $params);
-
- $group = array(
+ $this->_groupId2 = $this->groupCreate(array(
'name' => 'Test Group 2',
'domain_id' => 1,
'title' => 'New Test Group2 Created',
'description' => 'New Test Group2 Created',
'is_active' => 1,
'visibility' => 'User and User Admin Only',
- );
-
- $this->_groupId2 = $this->groupCreate($group);
+ ));
$this->_group = array(
$this->_groupId1 => array(
);
$result = $this->callAPIAndDocument('group_contact', 'create', $params, __FUNCTION__, __FILE__);
- $this->assertEquals($result['not_added'], 1, "in line " . __LINE__);
- $this->assertEquals($result['added'], 1, "in line " . __LINE__);
- $this->assertEquals($result['total_count'], 2, "in line " . __LINE__);
+ $this->assertEquals($result['not_added'], 1);
+ $this->assertEquals($result['added'], 1);
+ $this->assertEquals($result['total_count'], 2);
}
///////////////// civicrm_group_contact_remove methods
);
$result = $this->callAPIAndDocument('group_contact', 'delete', $params, __FUNCTION__, __FILE__);
- $this->assertEquals($result['removed'], 1, "in line " . __LINE__);
- $this->assertEquals($result['total_count'], 1, "in line " . __LINE__);
+ $this->assertEquals($result['removed'], 1);
+ $this->assertEquals($result['total_count'], 1);
}
public function testDeletePermanent() {
);
$this->callAPIAndDocument('group_contact', 'delete', $params, __FUNCTION__, __FILE__);
$result = $this->callAPISuccess('group_contact', 'get', $params);
- $this->assertEquals(0, $result['count'], "in line " . __LINE__);
- $this->assertArrayNotHasKey('id', $result, "in line " . __LINE__);
+ $this->assertEquals(0, $result['count']);
+ $this->assertArrayNotHasKey('id', $result);
+ }
+
+ /**
+ * CRM-16945 duplicate groups are showing up when contacts are hard-added to child groups or smart groups.
+ *
+ * Fix documented in
+ *
+ * Test illustrates this (& ensures once fixed it will stay fixed).
+ */
+ public function testAccurateCountWithSmartGroups() {
+ $childGroupID = $this->groupCreate(array(
+ 'name' => 'Child group',
+ 'domain_id' => 1,
+ 'title' => 'Child group',
+ 'description' => 'Child group',
+ 'is_active' => 1,
+ 'parents' => $this->_groupId1,
+ 'visibility' => 'User and User Admin Only',
+ ));
+
+ $params = array(
+ 'name' => 'Individuals',
+ 'title' => 'Individuals',
+ 'is_active' => 1,
+ 'parents' => $this->_groupId1,
+ 'formValues' => array('contact_type' => 'Goat'),
+ );
+ $smartGroup2 = CRM_Contact_BAO_Group::createSmartGroup($params);
+
+ $this->callAPISuccess('GroupContact', 'create', array('contact_id' => $this->_contactId, 'status' => 'Added', 'group_id' => $this->_groupId2));
+ $this->callAPISuccess('GroupContact', 'create', array('contact_id' => $this->_contactId, 'status' => 'Added', 'group_id' => $smartGroup2->id));
+ $this->callAPISuccess('GroupContact', 'create', array('contact_id' => $this->_contactId, 'status' => 'Added', 'group_id' => $childGroupID));
+ $groups = $this->callAPISuccess('GroupContact', 'get', array('contact_id' => $this->_contactId));
+
+ // Although the contact is actually hard-added to 4 groups the smart groups are conventionally not returned by the api or displayed
+ // on the main part of the groups tab on the contact (which calls the same function. So, 3 groups is an OK number to return.
+ // However, as of writing this test 4 groups are returned (indexed by group_contact_id, but more seriously 3/4 of those have the group id 1
+ // so 2 on them have group ids that do not match the group contact id they have been keyed by.
+ foreach ($groups['values'] as $groupContactID => $groupContactRecord) {
+ $this->assertEquals($groupContactRecord['group_id'], CRM_Core_DAO::singleValueQuery("SELECT group_id FROM civicrm_group_contact WHERE id = $groupContactID"), 'Group contact record mis-returned for id ' . $groupContactID);
+ }
+ $this->assertEquals(3, $groups['count']);
+
}
}
'sequential' => 1,
));
$optionValue = $optionValue['values'];
- $options[$optionValue[0]['value']] = 'new option value';
+ $keyColumn = CRM_Utils_Array::value('keyColumn', $specs['pseudoconstant'], 'value');
+ $options[$optionValue[0][$keyColumn]] = 'new option value';
}
}
$entity[$field] = array_rand($options);
</div>
<table class="form-layout-compressed">
- <tr><td class="label nowrap">{$event.fee_label} <span class="marker">*</span></td>
+ <tr><td class="label nowrap">{$event.fee_label} <span class="crm-marker">*</span></td>
<td> </td>
<td>{$form.amount.html}</td>
</tr>
</div>
<table class="form-layout-compressed">
- <tr><td class="label nowrap">{$event.fee_label} <span class="marker">*</span></td>
+ <tr><td class="label nowrap">{$event.fee_label} <span class="crm-marker">*</span></td>
<td> </td>
<td>{$form.amount.html}</td>
</tr>
</field>
<field>
<name>payment_instrument_id</name>
- <title>Batch Payment Instrument</title>
+ <title>Batch Payment Method</title>
<type>int unsigned</type>
<comment>fk to Payment Instrument options in civicrm_option_values</comment>
<pseudoconstant>
<field>
<name>id</name>
<type>int unsigned</type>
- <title>Internal Contact ID</title>
+ <title>Contact ID</title>
<import>true</import>
<headerPattern>/internal|contact?|id$/i</headerPattern>
<required>true</required>
</index>
<field>
<name>source</name>
- <title>Source of Contact Data</title>
+ <title>Contact Source</title>
<uniqueName>contact_source</uniqueName>
<type>varchar</type>
<length>255</length>
</html>
<import>true</import>
- <headerPattern>/(S(ource\s)?o(f\s)?C(ontact\s)?Data)$/i</headerPattern>
+ <headerPattern>/(C(ontact\s)?Source)$/i</headerPattern>
<comment>where contact come from, e.g. import, donate module insert...</comment>
<add>1.1</add>
</field>
</field>
<field>
<name>is_deceased</name>
- <title>Is Deceased</title>
+ <title>Deceased</title>
<import>true</import>
<export>true</export>
<headerPattern>/i(s\s)?d(eceased)$/i</headerPattern>
</field>
<field>
<name>is_deceased</name>
- <title>Is Deceased</title>
+ <title>Deceased</title>
<import>true</import>
<export>true</export>
<headerPattern>/i(s\s)?d(eceased)$/i</headerPattern>
<length>64</length>
<comment>label for relationship of contact_a to contact_b.</comment>
<add>3.0</add>
+ <localizable>true</localizable>
</field>
<field>
<name>name_b_a</name>
<length>64</length>
<comment>Optional label for relationship of contact_b to contact_a.</comment>
<add>3.0</add>
+ <localizable>true</localizable>
</field>
<field>
<name>description</name>
<length>255</length>
<comment>Optional verbose description of the relationship type.</comment>
<add>1.1</add>
+ <localizable>true</localizable>
</field>
<field>
<name>contact_type_a</name>
<field>
<name>payment_instrument_id</name>
<uniqueName>payment_instrument_id</uniqueName>
- <title>Payment Instrument ID</title>
+ <title>Payment Method</title>
<type>int unsigned</type>
<comment>FK to Payment Instrument</comment>
<pseudoconstant>
</index>
<field>
<name>receive_date</name>
+ <title>Date Received</title>
<type>datetime</type>
<import>true</import>
<headerPattern>/receive(.?date)?/i</headerPattern>
<dataPattern>/^\d{4}-?\d{2}-?\d{2} ?(\d{2}:?\d{2}:?(\d{2})?)?$/</dataPattern>
- <comment>when was gift received</comment>
+ <comment>Date contribution was received - not necessarily the creation date of the record</comment>
<add>1.3</add>
<html>
<type>Select Date</type>
</foreignKey>
<field>
<name>payment_instrument_id</name>
- <title>Payment Instrument</title>
+ <title>Payment Method</title>
<type>int unsigned</type>
<comment>FK to Payment Instrument</comment>
<pseudoconstant>
</foreignKey>
<field>
<name>postal_code_suffix</name>
- <title>Zip / Postal Code Suffix</title>
+ <title>Postal Code Suffix</title>
<type>varchar</type>
<length>12</length>
<import>true</import>
<add>1.1</add>
<html>
<type>Text</type>
+ <size>3</size>
</html>
</field>
<field>
<name>postal_code</name>
- <title>Zip / Postal Code</title>
+ <title>Postal Code</title>
<type>varchar</type>
<length>12</length>
<import>true</import>
<headerPattern>/postal|zip/i</headerPattern>
<dataPattern>/\d?\d{4}(-\d{4})?/</dataPattern>
- <comment>Store both US (zip5) AND international postal codes. App is responsible for country/region appropriate
- validation.
- </comment>
+ <comment>Store both US (zip5) AND international postal codes. App is responsible for country/region appropriate validation.</comment>
<add>1.1</add>
<html>
<type>Text</type>
+ <size>6</size>
</html>
</field>
<field>
<comment>a pseudo-FK to civicrm_option_value containing PDF Page Format.</comment>
<pseudoconstant>
<optionGroupName>pdf_format</optionGroupName>
+ <keyColumn>id</keyColumn>
</pseudoconstant>
<add>3.4</add>
</field>
<field>
<name>payment_instrument_id</name>
<uniqueName>financial_trxn_payment_instrument_id</uniqueName>
- <title>Payment Instrument</title>
+ <title>Payment Method</title>
<type>int unsigned</type>
<comment>FK to payment_instrument option group values</comment>
<pseudoconstant>
</field>
<field>
<name>payment_instrument_id</name>
- <title>Payment Instrument</title>
+ <title>Payment Method</title>
<type>int unsigned</type>
<default>1</default>
<comment>Payment Instrument ID</comment>
</field>
<field>
<name>payment_instrument_id</name>
- <title>Payment Instrument</title>
+ <title>Payment Method</title>
<type>int unsigned</type>
<default>1</default>
<comment>Payment Instrument ID</comment>
<add>1.5</add>
<field>
<name>id</name>
+ <title>Membership Log ID</title>
<type>int unsigned</type>
<required>true</required>
<add>1.5</add>
</primaryKey>
<field>
<name>membership_id</name>
+ <title>Membership ID</title>
<type>int unsigned</type>
<required>true</required>
<comment>FK to Membership table</comment>
</foreignKey>
<field>
<name>start_date</name>
+ <title>Membership Log Start Date</title>
<type>date</type>
<dataPattern>/\d{4}-?\d{2}-?\d{2}/</dataPattern>
<comment>New membership period start date</comment>
</field>
<field>
<name>end_date</name>
+ <title>Membership Log End Date</title>
<type>date</type>
<dataPattern>/\d{4}-?\d{2}-?\d{2}/</dataPattern>
<comment>New membership period expiration date.</comment>
</field>
<field>
<name>modified_id</name>
+ <title>Membership Log modified By</title>
<type>int unsigned</type>
<comment>FK to Contact ID of person under whose credentials this data modification was made.</comment>
<add>1.5</add>
</field>
<field>
<name>membership_type_id</name>
+ <title>Membership Type ID</title>
<type>int unsigned</type>
<comment>FK to Membership Type.</comment>
<add>3.4</add>
</foreignKey>
<field>
<name>max_related</name>
+ <title>Maximum Related Memberships</title>
<type>int</type>
<comment>Maximum number of related memberships.</comment>
<add>4.3</add>
('individual_suffix' , '{ts escape="sql"}Individual contact suffixes{/ts}' , 1, 1, 0),
('acl_role' , '{ts escape="sql"}ACL Role{/ts}' , 1, 1, 0),
('accept_creditcard' , '{ts escape="sql"}Accepted Credit Cards{/ts}' , 1, 1, 0),
- ('payment_instrument' , '{ts escape="sql"}Payment Instruments{/ts}' , 1, 1, 0),
+ ('payment_instrument' , '{ts escape="sql"}Payment Methods{/ts}' , 1, 1, 0),
('contribution_status' , '{ts escape="sql"}Contribution Status{/ts}' , 1, 1, 1),
('pcp_status' , '{ts escape="sql"}PCP Status{/ts}' , 1, 1, 1),
('pcp_owner_notify' , '{ts escape="sql"}PCP owner notifications{/ts}' , 1, 1, 1),
(@option_group_id_adOpt, '{ts escape="sql"}Supplemental Address 1{/ts}' , 2, 'supplemental_address_1', NULL, 0, NULL, 2, NULL, 0, 0, 1, NULL, NULL),
(@option_group_id_adOpt, '{ts escape="sql"}Supplemental Address 2{/ts}' , 3, 'supplemental_address_2', NULL, 0, NULL, 3, NULL, 0, 0, 1, NULL, NULL),
(@option_group_id_adOpt, '{ts escape="sql"}City{/ts}' , 4, 'city' , NULL, 0, NULL, 4, NULL, 0, 0, 1, NULL, NULL),
- (@option_group_id_adOpt, '{ts escape="sql"}Zip / Postal Code{/ts}' , 5, 'postal_code' , NULL, 0, NULL, 5, NULL, 0, 0, 1, NULL, NULL),
+ (@option_group_id_adOpt, '{ts escape="sql"}Postal Code{/ts}' , 5, 'postal_code' , NULL, 0, NULL, 5, NULL, 0, 0, 1, NULL, NULL),
(@option_group_id_adOpt, '{ts escape="sql"}Postal Code Suffix{/ts}', 6, 'postal_code_suffix', NULL, 0, NULL, 6, NULL, 0, 0, 1, NULL, NULL),
(@option_group_id_adOpt, '{ts escape="sql"}County{/ts}' , 7, 'county' , NULL, 0, NULL, 7, NULL, 0, 0, 1, NULL, NULL),
(@option_group_id_adOpt, '{ts escape="sql"}State/Province{/ts}' , 8, 'state_province', NULL, 0, NULL, 8, NULL, 0, 0, 1, NULL, NULL),
( 10, 'contribution_status_id', 1, 1, 3, 'User and User Admin Only', 0, 0, NULL, '{ts escape="sql"}Status{/ts}', 'Contribution', NULL, NULL ),
( 10, 'receive_date', 1, 1, 4, 'User and User Admin Only', 0, 0, NULL, '{ts escape="sql"}Received{/ts}', 'Contribution', NULL, NULL ),
( 10, 'contribution_source', 0, 0, 5, 'User and User Admin Only', 0, 0, NULL, '{ts escape="sql"}Source{/ts}', 'Contribution', NULL, NULL ),
- ( 10, 'payment_instrument', 0, 0, 6, 'User and User Admin Only', 0, 0, NULL, '{ts escape="sql"}Paid By{/ts}', 'Contribution', NULL, NULL ),
+ ( 10, 'payment_instrument', 0, 0, 6, 'User and User Admin Only', 0, 0, NULL, '{ts escape="sql"}Payment Method{/ts}', 'Contribution', NULL, NULL ),
( 10, 'check_number', 0, 0, 7, 'User and User Admin Only', 0, 0, NULL, '{ts escape="sql"}Check Number{/ts}', 'Contribution', NULL, NULL ),
( 10, 'send_receipt', 0, 0, 8, 'User and User Admin Only', 0, 0, NULL, '{ts escape="sql"}Send Receipt{/ts}', 'Contribution', NULL, NULL ),
( 10, 'invoice_id', 0, 0, 9, 'User and User Admin Only', 0, 0, NULL, '{ts escape="sql"}Invoice ID{/ts}', 'Contribution', NULL, NULL ),
( 11, 'financial_type', 0, 1, 7, 'User and User Admin Only', 0, 0, NULL, '{ts escape="sql"}Financial Type{/ts}', 'Membership', NULL, NULL ),
( 11, 'total_amount', 0, 1, 8, 'User and User Admin Only', 0, 0, NULL, '{ts escape="sql"}Amount{/ts}', 'Membership', NULL, NULL ),
( 11, 'receive_date', 1, 1, 9, 'User and User Admin Only', 0, 0, NULL, '{ts escape="sql"}Received{/ts}', 'Membership', NULL, NULL ),
- ( 11, 'payment_instrument', 0, 0, 10, 'User and User Admin Only', 0, 0, NULL, '{ts escape="sql"}Paid By{/ts}', 'Membership', NULL, NULL ),
+ ( 11, 'payment_instrument', 0, 0, 10, 'User and User Admin Only', 0, 0, NULL, '{ts escape="sql"}Payment Method{/ts}', 'Membership', NULL, NULL ),
( 11, 'check_number', 0, 0, 11, 'User and User Admin Only', 0, 0, NULL, '{ts escape="sql"}Check Number{/ts}', 'Membership', NULL, NULL ),
( 11, 'contribution_status_id', 1, 1, 12, 'User and User Admin Only', 0, 0, NULL, '{ts escape="sql"}Payment Status{/ts}', 'Membership', NULL, NULL ),
( 11, 'soft_credit', 0, 0, 13, 'User and User Admin Only', 0, 0, NULL, '{ts escape="sql"}Soft Credit{/ts}', 'Membership', NULL, NULL ),
( @domainID, 'civicrm/admin/contribute/managePremiums?reset=1', '{ts escape="sql" skip="true"}Premiums (Thank-you Gifts){/ts}', 'Premiums', 'access CiviContribute,administer CiviCRM', 'AND', @adminContributelastID, '1', 1, 9 ),
( @domainID, 'civicrm/admin/financial/financialType?reset=1', '{ts escape="sql" skip="true"}Financial Types{/ts}', 'Financial Types', 'access CiviContribute,administer CiviCRM', 'AND', @adminContributelastID, '1', NULL, 10),
( @domainID, 'civicrm/admin/financial/financialAccount?reset=1', '{ts escape="sql" skip="true"}Financial Accounts{/ts}', 'Financial Accounts', 'access CiviContribute,administer CiviCRM', 'AND', @adminContributelastID, '1', NULL, 11),
- ( @domainID, 'civicrm/admin/options/payment_instrument?reset=1', '{ts escape="sql" skip="true"}Payment Instruments{/ts}', 'Payment Instruments', 'access CiviContribute,administer CiviCRM', 'AND', @adminContributelastID, '1', NULL, 12 ),
+ ( @domainID, 'civicrm/admin/options/payment_instrument?reset=1', '{ts escape="sql" skip="true"}Payment Methods{/ts}', 'Payment Instruments', 'access CiviContribute,administer CiviCRM', 'AND', @adminContributelastID, '1', NULL, 12 ),
( @domainID, 'civicrm/admin/options/accept_creditcard?reset=1', '{ts escape="sql" skip="true"}Accepted Credit Cards{/ts}', 'Accepted Credit Cards', 'access CiviContribute,administer CiviCRM', 'AND', @adminContributelastID, '1', NULL, 13 ),
( @domainID, 'civicrm/admin/options/soft_credit_type?reset=1', '{ts escape="sql" skip="true"}Soft Credit Types{/ts}', 'Soft Credit Types', 'access CiviContribute,administer CiviCRM', 'AND', @adminContributelastID, '1', 1, 14 ),
( @domainID, 'civicrm/admin/price?reset=1&action=add', '{ts escape="sql" skip="true"}New Price Set{/ts}', 'New Price Set', 'access CiviContribute,administer CiviCRM', 'AND', @adminContributelastID, '1', NULL, 15 ),
INSERT INTO civicrm_navigation
( domain_id, url, label, name, permission, permission_operator, parent_id, is_active, has_separator, weight )
VALUES
- ( @domainID, NULL, '{ts escape="sql" skip="true"}Help{/ts}', 'Help', NULL, '', NULL, '1', NULL, 110);
+ ( @domainID, NULL, '{ts escape="sql" skip="true"}Support{/ts}', 'Support', NULL, '', NULL, '1', NULL, 110);
SET @adminHelplastID:=LAST_INSERT_ID();
INSERT INTO civicrm_navigation
( domain_id, url, label, name, permission, permission_operator, parent_id, is_active, has_separator, weight )
VALUES
- ( @domainID, 'http://documentation.civicrm.org', '{ts escape="sql" skip="true"}Documentation{/ts}', 'Documentation', NULL, 'AND', @adminHelplastID, '1', NULL, 1 ),
- ( @domainID, 'http://forum.civicrm.org', '{ts escape="sql" skip="true"}Community Forums{/ts}', 'Community Forums', NULL, 'AND', @adminHelplastID, '1', NULL, 2 ),
- ( @domainID, 'http://civicrm.org/participate', '{ts escape="sql" skip="true"}Participate{/ts}', 'Participate', NULL, 'AND', @adminHelplastID, '1', NULL, 3 ),
- ( @domainID, 'http://civicrm.org/what/whatiscivicrm', '{ts escape="sql" skip="true"}About{/ts}', 'About', NULL, 'AND', @adminHelplastID, '1', NULL, 4 );
+ ( @domainID, 'http://civicrm.org/get-started?src=iam', '{ts escape="sql" skip="true"}Get started{/ts}', 'Get started', NULL, 'AND', @adminHelplastID, '1', NULL, 1 ),
+ ( @domainID, 'http://civicrm.org/documentation?src=iam', '{ts escape="sql" skip="true"}Documentation{/ts}', 'Documentation', NULL, 'AND', @adminHelplastID, '1', NULL, 2 ),
+ ( @domainID, 'http://civicrm.org/ask-a-question?src=iam', '{ts escape="sql" skip="true"}Ask a question{/ts}', 'Ask a question', NULL, 'AND', @adminHelplastID, '1', NULL, 3 ),
+ ( @domainID, 'http://civicrm.org/experts?src=iam', '{ts escape="sql" skip="true"}Get expert help{/ts}', 'Get expert help', NULL, 'AND', @adminHelplastID, '1', NULL, 4 ),
+ ( @domainID, 'http://civicrm.org/about?src=iam', '{ts escape="sql" skip="true"}About CiviCRM{/ts}', 'About CiviCRM', NULL, 'AND', @adminHelplastID, '1', 1, 5 ),
+ ( @domainID, 'http://civicrm.org/register-your-site?src=iam', '{ts escape="sql" skip="true"}Register your site{/ts}', 'Register your site', NULL, 'AND', @adminHelplastID, '1', NULL, 6 ),
+ ( @domainID, 'http://civicrm.org/become-member?src=iam', '{ts escape="sql" skip="true"}Join CiviCRM{/ts}', 'Join CiviCRM', NULL, 'AND', @adminHelplastID, '1', NULL, 7 );
INSERT INTO civicrm_navigation
( domain_id, url, label, name, permission, permission_operator, parent_id, is_active, has_separator, weight )
VALUES
- ( @domainID, NULL, '{ts escape="sql" skip="true"}Developer{/ts}', 'Developer', 'administer CiviCRM', '', @adminHelplastID, '1', NULL, 5 );
+ ( @domainID, NULL, '{ts escape="sql" skip="true"}Developer{/ts}', 'Developer', 'administer CiviCRM', '', @adminHelplastID, '1', 1, 8 );
SET @devellastID:=LAST_INSERT_ID();
INSERT INTO civicrm_navigation
( domain_id, url, label, name, permission, permission_operator, parent_id, is_active, has_separator, weight )
VALUES
( @domainID, 'civicrm/api', '{ts escape="sql" skip="true"}API Explorer{/ts}','API Explorer', 'administer CiviCRM', '', @devellastID, '1', NULL, 1 ),
-( @domainID, 'http://wiki.civicrm.org/confluence/display/CRMDOC/Develop', '{ts escape="sql" skip="true"}Developer Docs{/ts}', 'Developer Docs', 'administer CiviCRM', '', @devellastID, '1', NULL, 3 );
+( @domainID, 'http://civicrm.org/developer-documentation?src=iam', '{ts escape="sql" skip="true"}Developer Docs{/ts}', 'Developer Docs', 'administer CiviCRM', '', @devellastID, '1', NULL, 3 );
INSERT INTO civicrm_navigation
( domain_id, url, label, name, permission, permission_operator, parent_id, is_active, has_separator, weight )
{if $receive_date}
<tr>
<td {$labelStyle}>
- {ts}Received Date{/ts}
+ {ts}Date Received{/ts}
</td>
<td {$valueStyle}>
{$receive_date|truncate:10:''|crmDate}
{/if}
{ts}Total Amount{/ts} : {$formValues.total_amount|crmMoney:$currency}
{if $receive_date}
-{ts}Received Date{/ts}: {$receive_date|truncate:10:''|crmDate}
+{ts}Date Received{/ts}: {$receive_date|truncate:10:''|crmDate}
{/if}
{if $receipt_date}
{ts}Receipt Date{/ts}: {$receipt_date|truncate:10:''|crmDate}
{if $receive_date}
<tr>
<td {$labelStyle}>
- {ts}Received Date{/ts}
+ {ts}Date Received{/ts}
</td>
<td {$valueStyle}>
{$receive_date|truncate:10:''|crmDate}
{ts}Amount{/ts}: {$formValues.total_amount|crmMoney}
{if $receive_date}
-{ts}Received Date{/ts}: {$receive_date|truncate:10:''|crmDate}
+{ts}Date Received{/ts}: {$receive_date|truncate:10:''|crmDate}
{/if}
{if $formValues.paidBy}
{ts}Paid By{/ts}: {$formValues.paidBy}
{/if}
</p>
<table width="620" border="0" cellpadding="0" cellspacing="0" id="crm-event_receipt" style="font-family: Arial, Verdana, sans-serif; text-align: left;">
- <tr><td>{ts}Receive Date{/ts}:</td><td> {$receive_date|crmDate}</td></tr>
+ <tr><td>{ts}Received{/ts}:</td><td> {$receive_date|crmDate}</td></tr>
<tr><td>{ts}Amount{/ts}:</td><td> {$total_amount|crmMoney:$currency}</td></tr>
<tr><td>{ts}Name{/ts}:</td><td> {$donors_display_name}</td></tr>
<tr><td>{ts}Email{/ts}:</td><td> {$donors_email}</td></tr>
{ts}The donor's name has been added to your honor roll unless they asked not to be included.{/ts}
{/if}
-{ts}Receive Date{/ts}: {$receive_date|crmDate}
+{ts}Received{/ts}: {$receive_date|crmDate}
{ts}Amount{/ts}: {$total_amount|crmMoney:$currency}