'details' => ts('Activity Details'),
'activity_date_time' => ts('Activity Date-Time'),
),
- $this->getCustomTokens('Activity')
+ CRM_Utils_Token::getCustomFieldTokens('Activity')
));
}
// we do this only to initialize monetary decimal point and thousand separator
$config = CRM_Core_Config::singleton();
- // save enabled currencies and defaul currency in option group 'currencies_enabled'
+ // save enabled currencies and default currency in option group 'currencies_enabled'
// CRM-1496
if (empty($values['currencyLimit'])) {
$values['currencyLimit'] = array($values['defaultCurrency']);
}
- elseif (!in_array($values['defaultCurrency'],
- $values['currencyLimit']
- )
- ) {
+ elseif (!in_array($values['defaultCurrency'], $values['currencyLimit'])) {
$values['currencyLimit'][] = $values['defaultCurrency'];
}
- // sort so that when we display drop down, weights have right value
- sort($values['currencyLimit']);
-
- // get labels for all the currencies
- $options = array();
-
- $currencySymbols = self::getCurrencySymbols();
- for ($i = 0; $i < count($values['currencyLimit']); $i++) {
- $options[] = array(
- 'label' => $currencySymbols[$values['currencyLimit'][$i]],
- 'value' => $values['currencyLimit'][$i],
- 'weight' => $i + 1,
- 'is_active' => 1,
- 'is_default' => $values['currencyLimit'][$i] == $values['defaultCurrency'],
- );
- }
-
- $dontCare = NULL;
- CRM_Core_OptionGroup::createAssoc('currencies_enabled',
- $options,
- $dontCare
- );
+ self::updateEnabledCurrencies($values['currencyLimit'], $values['defaultCurrency']);
// unset currencyLimit so we dont store there
unset($values['currencyLimit']);
}
}
+
+ /**
+ * Replace available currencies by the ones provided
+ *
+ * @param $currencies array of currencies ['USD', 'CAD']
+ * @param $default default currency
+ */
+ public static function updateEnabledCurrencies($currencies, $default) {
+
+ // sort so that when we display drop down, weights have right value
+ sort($currencies);
+
+ // get labels for all the currencies
+ $options = array();
+
+ $currencySymbols = CRM_Admin_Form_Setting_Localization::getCurrencySymbols();
+ for ($i = 0; $i < count($currencies); $i++) {
+ $options[] = array(
+ 'label' => $currencySymbols[$currencies[$i]],
+ 'value' => $currencies[$i],
+ 'weight' => $i + 1,
+ 'is_active' => 1,
+ 'is_default' => $currencies[$i] == $default,
+ );
+ }
+
+ $dontCare = NULL;
+ CRM_Core_OptionGroup::createAssoc('currencies_enabled', $options, $dontCare);
+
+ }
+
+
/**
* @return array
*/
}
}
+ public static function onChangeDefaultCurrency($oldCurrency, $newCurrency, $metadata) {
+ if ($oldCurrency == $newCurrency) {
+ return;
+ }
+
+ // ensure that default currency is always in the list of enabled currencies
+ $currencies = array_keys(CRM_Core_OptionGroup::values('currencies_enabled'));
+ if (!in_array($newCurrency, $currencies)) {
+ if (empty($currencies)) {
+ $currencies = array($values['defaultCurrency']);
+ }
+ else {
+ $currencies[] = $newCurrency;
+ }
+
+ CRM_Admin_Form_Setting_Localization::updateEnabledCurrencies($currencies, $newCurrency);
+ }
+
+ }
+
/**
* @return array
*/
$parent = CRM_Utils_Type::escape(CRM_Utils_Array::value('parent_id', $_GET, 0), 'Integer');
$result = array();
- $parentClause = $parent ? "AND tag.parent_id = $parent" : 'AND tag.parent_id IS NULL';
- $sql = "SELECT tag.*, child.id AS child, COUNT(et.id) as usages
- FROM civicrm_tag tag
- LEFT JOIN civicrm_entity_tag et ON et.tag_id = tag.id
- LEFT JOIN civicrm_tag child ON child.parent_id = tag.id
- WHERE tag.is_tagset <> 1 $parentClause
- GROUP BY tag.id
- ORDER BY tag.name";
+ $parentClause = $parent ? "AND parent_id = $parent" : 'AND parent_id IS NULL';
+ $sql = "SELECT *
+ FROM civicrm_tag
+ WHERE is_tagset <> 1 $parentClause
+ GROUP BY id
+ ORDER BY name";
+
+ // fetch all child tags in Array('parent_tag' => array('child_tag_1', 'child_tag_2', ...)) format
+ $childTagIDs = CRM_Core_BAO_Tag::getChildTags();
+
$dao = CRM_Core_DAO::executeQuery($sql);
while ($dao->fetch()) {
$style = '';
if ($dao->color) {
$style = "background-color: {$dao->color}; color: " . CRM_Utils_Color::getContrast($dao->color);
}
+ $hasChildTags = empty($childTagIDs[$dao->id]) ? FALSE : TRUE;
+ $usedFor = (array) explode(',', $dao->used_for);
$result[] = array(
'id' => $dao->id,
'text' => $dao->name,
'style' => $style,
'class' => 'crm-tag-item',
),
- 'children' => (bool) $dao->child,
+ 'children' => $hasChildTags,
'data' => array(
'description' => (string) $dao->description,
'is_selectable' => (bool) $dao->is_selectable,
'is_reserved' => (bool) $dao->is_reserved,
- 'used_for' => $dao->used_for ? explode(',', $dao->used_for) : array(),
+ 'used_for' => $usedFor,
'color' => $dao->color ? $dao->color : '#ffffff',
- 'usages' => (int) $dao->usages,
+ 'usages' => civicrm_api3('EntityTag', 'getcount', array(
+ 'entity_table' => array('IN' => $usedFor),
+ 'tag_id' => $dao->id,
+ )),
),
);
}
+ if (!empty($_REQUEST['is_unit_test'])) {
+ return $result;
+ }
+
CRM_Utils_JSON::output($result);
}
if (array_key_exists('TagsAndGroups', $this->_editOptions)) {
//add contact to tags
- CRM_Core_BAO_EntityTag::create($params['tag'], 'civicrm_contact', $params['contact_id']);
+ if (isset($params['tag']) && !empty($params['tag'])) {
+ $params['tag'] = array_flip(explode(',', $params['tag']));
+ CRM_Core_BAO_EntityTag::create($params['tag'], 'civicrm_contact', $params['contact_id']);
+ }
//save free tags
if (isset($params['contact_taglist']) && !empty($params['contact_taglist'])) {
if ($groupElementType == 'select' && !empty($groupsOptions)) {
$form->add('select', $fName, $groupName, $groupsOptions, FALSE,
- array('id' => $fName, 'multiple' => 'multiple', 'class' => 'crm-select2')
+ array('id' => $fName, 'multiple' => 'multiple', 'class' => 'crm-select2 twenty')
);
$form->assign('groupCount', count($groupsOptions));
}
}
if ($type & self::TAG) {
- $fName = 'tag';
- if ($fieldName) {
- $fName = $fieldName;
- }
- $form->_tagGroup[$fName] = 1;
-
- // get the list of all the categories
- $tags = new CRM_Core_BAO_Tag();
- $tree = $tags->getTree('civicrm_contact', TRUE);
- // let's not load jstree if there are not children. This also fixes blank
- // display at the beginning of checkboxes
- $loadJsTree = CRM_Utils_Array::retrieveValueRecursive($tree, 'children');
- $form->assign('loadjsTree', FALSE);
- if (!empty($loadJsTree)) {
- // CODE FROM CRM/Tag/Form/Tag.php //
- CRM_Core_Resources::singleton()
- ->addScriptFile('civicrm', 'packages/jquery/plugins/jstree/jquery.jstree.js', 0, 'html-header', FALSE)
- ->addStyleFile('civicrm', 'packages/jquery/plugins/jstree/themes/default/style.css', 0, 'html-header');
- $form->assign('loadjsTree', TRUE);
- }
-
- $elements = array();
- self::climbtree($form, $tree, $elements);
+ $tags = CRM_Core_BAO_Tag::getColorTags('civicrm_contact');
- $form->addGroup($elements, $fName, $tagName, '<br />');
- $form->assign('tagCount', count($elements));
- $form->assign('tree', $tree);
- $form->assign('tag', $tree);
- $form->assign('entityID', $contactId);
- $form->assign('entityTable', 'civicrm_contact');
- $form->assign('allTags', CRM_Core_BAO_Tag::getTagsUsedFor('civicrm_contact', FALSE));
-
- if ($isRequired) {
- $form->addRule($fName, ts('%1 is a required field.', array(1 => $tagName)), 'required');
+ if (!empty($tags)) {
+ $form->add('select2', 'tag', ts('Tag(s)'), $tags, FALSE, array('class' => 'huge', 'placeholder' => ts('- select -'), 'multiple' => TRUE));
}
// build tag widget
$form->assign('tagGroup', $form->_tagGroup);
}
- /**
- * Climb tree.
- *
- * @param $form
- * @param $tree
- * @param $elements
- *
- * @return mixed
- */
- public static function climbtree($form, $tree, &$elements) {
- foreach ($tree as $tagID => $varValue) {
- $tagAttribute = array(
- 'onclick' => "return changeRowColor(\"rowidtag_$tagID\")",
- 'id' => "tag_{$tagID}",
- );
-
- $elements[$tagID] = $form->createElement('checkbox', $tagID, '', $varValue['name'], $tagAttribute);
-
- if (array_key_exists('children', $varValue)) {
- self::climbtree($form, $varValue['children'], $elements);
- }
- }
- return $elements;
- }
-
/**
* Set defaults for relevant form elements.
*
}
if ($type & self::TAG) {
- $fName = 'tag';
- if ($fieldName) {
- $fName = $fieldName;
- }
-
- $contactTag = CRM_Core_BAO_EntityTag::getTag($id);
- if ($contactTag) {
- foreach ($contactTag as $tag) {
- $defaults[$fName . '[' . $tag . ']'] = 1;
- }
- }
+ $defaults['tag'] = implode(',', CRM_Core_BAO_EntityTag::getTag($id, 'civicrm_contact'));
}
}
$ids['paymentProcessor'] = $paymentProcessorID;
$this->_relatedObjects['paymentProcessor'] = $paymentProcessor;
}
+
+ // Add contribution id to $ids. CRM-20401
+ $ids['contribution'] = $this->id;
return TRUE;
}
'contact_id' => $membership->contact_id,
'is_test' => $membership->is_test,
'membership_type_id' => $membership->membership_type_id,
+ 'membership_activity_status' => 'Completed',
);
$currentMembership = CRM_Member_BAO_Membership::getContactMembership($membershipParams['contact_id'],
protected $_formType;
- public $_honoreeProfileType;
-
/**
* Array of the payment fields to be displayed in the payment fieldset (pane) in billingBlock.tpl
* this contains all the information to describe these fields from quickform. See CRM_Core_Form_Payment getPaymentFormFieldsMetadata
else {
$this->setPageTitle($this->_ppID ? ts('Pledge Payment') : ts('Contribution'));
}
-
- if ($this->_id) {
- CRM_Contribute_Form_SoftCredit::preprocess($this);
- }
}
/**
if (!empty($this->_params['receive_date'])) {
$this->_params['receive_date'] = CRM_Utils_Date::processDate($this->_params['receive_date'], $this->_params['receive_date_time']);
}
+ else {
+ $this->_params['receive_date'] = $now;
+ }
$this->_params['pcp_display_in_roll'] = CRM_Utils_Array::value('pcp_display_in_roll', $params);
$this->_params['pcp_roll_nickname'] = CRM_Utils_Array::value('pcp_roll_nickname', $params);
$paymentParams['receive_date'] = $this->_params['receive_date'];
}
- $this->_params['receive_date'] = $now;
-
if (!empty($this->_params['is_email_receipt'])) {
$this->_params['receipt_date'] = $now;
}
*/
class CRM_Contribute_Form_SoftCredit {
- /**
- * Set variables up before form is built.
- *
- * @param CRM_Core_Form $form
- */
- public static function preProcess(&$form) {
- $contriDAO = new CRM_Contribute_DAO_Contribution();
- $contriDAO->id = $form->_id;
- $contriDAO->find(TRUE);
- if ($contriDAO->contribution_page_id) {
- $ufJoinParams = array(
- 'module' => 'soft_credit',
- 'entity_table' => 'civicrm_contribution_page',
- 'entity_id' => $contriDAO->contribution_page_id,
- );
- $profileId = CRM_Core_BAO_UFJoin::getUFGroupIds($ufJoinParams);
-
- //check if any honree profile is enabled if yes then assign its profile type to $_honoreeProfileType
- // which will be used to constraint soft-credit contact type in formRule, CRM-13981
- if (!empty($profileId[0]) && !empty($profileId[2])) {
- $form->_honoreeProfileType = CRM_Core_BAO_UFGroup::getContactType($profileId[0]);
- }
- }
- }
-
/**
* Function used to build form element for soft credit block.
*
if (empty($fields['soft_credit_amount'][$key])) {
$errors["soft_credit_amount[$key]"] = ts('Please enter the soft credit amount.');
}
- $contactType = CRM_Contact_BAO_Contact::getContactType($fields['soft_credit_contact_id'][$key]);
- if ($self->_honoreeProfileType && $self->_honoreeProfileType != $contactType) {
- $errors["soft_credit_contact_id[$key]"] = ts('Please choose a contact of type %1', array(1 => $self->_honoreeProfileType));
- }
}
}
}
$tokens['source'] = ts('Contribution Source');
$tokens['status'] = ts('Contribution Status');
$tokens['type'] = ts('Financial Type');
- $tokens = array_merge($tokens, $this->getCustomTokens('Contribution'));
+ $tokens = array_merge($tokens, CRM_Utils_Token::getCustomFieldTokens('Contribution'));
parent::__construct('contribution', $tokens);
}
// add attachments
for ($i = 1; $i <= $numAttachments; $i++) {
- $form->addElement('file', "attachFile_$i", ts('Attach File'), 'size=30 maxlength=60');
+ $form->addElement('file', "attachFile_$i", ts('Attach File'), 'size=30 maxlength=221');
$form->addUploadElement("attachFile_$i");
$form->setMaxFileSize($maxFileSize * 1024 * 1024);
$form->addRule("attachFile_$i",
return \Civi::$statics[__CLASS__]['titles_by_name'];
}
+ /**
+ * Set the given values to active, and set all other values to inactive.
+ *
+ * @param string $optionGroupName
+ * e.g "languages"
+ * @param array<string> $activeValues
+ * e.g. array("en_CA","fr_CA")
+ */
+ public static function setActiveValues($optionGroupName, $activeValues) {
+ $params = array(
+ 1 => array($optionGroupName, 'String'),
+ );
+
+ // convert activeValues into placeholders / params in the query
+ $placeholders = array();
+ $i = count($params) + 1;
+ foreach ($activeValues as $value) {
+ $placeholders[] = "%{$i}";
+ $params[$i] = array($value, 'String');
+ $i++;
+ }
+ $placeholders = implode(', ', $placeholders);
+
+ CRM_Core_DAO::executeQuery("
+UPDATE civicrm_option_value cov
+ LEFT JOIN civicrm_option_group cog ON cov.option_group_id = cog.id
+SET cov.is_active = CASE WHEN cov.name IN ({$placeholders}) THEN 1 ELSE 0 END
+WHERE cog.name = %1",
+ $params
+ );
+ }
+
}
return NULL;
}
+ // Check permission to create or modify reserved tag
+ if (!empty($params['check_permissions']) && !CRM_Core_Permission::check('administer reserved tags')) {
+ if (!empty($params['is_reserved']) || ($id && CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Tag', $id, 'is_reserved'))) {
+ throw new CRM_Core_Exception('Insufficient permission to administer reserved tag.');
+ }
+ }
+
+ // Check permission to create or modify tagset
+ if (!empty($params['check_permissions']) && !CRM_Core_Permission::check('administer Tagsets')) {
+ if (!empty($params['is_tagset']) || ($id && CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Tag', $id, 'is_tagset'))) {
+ throw new CRM_Core_Exception('Insufficient permission to administer tagset.');
+ }
+ }
+
$tag = new CRM_Core_DAO_Tag();
// if parent id is set then inherit used for and is hidden properties
return $tags;
}
+ /**
+ * Get child tags IDs
+ *
+ * @return array $childTagIDs
+ * associated array of child tags in Array('Parent Tag ID' => Array('Child Tag 1', ...)) format
+ */
+ public static function getChildTags() {
+ $childTagIDs = array();
+
+ // only fetch those tags which has child tags
+ $getChildGroupSQL = "SELECT parent.id as parent_id, GROUP_CONCAT(child.id) as child_id
+ FROM civicrm_tag parent,
+ civicrm_tag child
+ WHERE parent.is_tagset <> 1 AND child.parent_id = parent.id
+ GROUP BY parent.id
+ ";
+ $dao = CRM_Core_DAO::executeQuery($getChildGroupSQL);
+ while ($dao->fetch()) {
+ $childTagIDs[$dao->parent_id] = (array) explode(',', $dao->child_id);
+ }
+
+ // check if child tag has any childs, if found then include those child tags inside parent tag
+ // i.e. format Array('parent_tag' => array('child_tag_1', ...), 'child_tag_1' => array(child_tag_1_1, ..), ..)
+ // to Array('parent_tag' => array('child_tag_1', 'child_tag_1_1'...), ..)
+ foreach ($childTagIDs as $parentTagID => $childTags) {
+ foreach ($childTags as $childTag) {
+ // if $childTag has any child tag of its own
+ if (array_key_exists($childTag, $childTagIDs)) {
+ $childTagIDs[$parentTagID] = array_merge($childTagIDs[$parentTagID], $childTagIDs[$childTag]);
+ }
+ }
+ }
+
+ return $childTagIDs;
+ }
+
}
if (!$all) {
$all = CRM_Contact_BAO_Contact::buildOptions('preferred_language');
+ // get labels
+ $rows = array();
+ $labels = array();
+ CRM_Core_OptionValue::getValues(array('name' => 'languages'), $rows);
+ foreach ($rows as $id => $row) {
+ $labels[$row['name']] = $row['label'];
+ }
+
// check which ones are available; add them to $all if not there already
$codes = array();
if (is_dir(CRM_Core_I18n::getResourceDir()) && $dir = opendir(CRM_Core_I18n::getResourceDir())) {
if (preg_match('/^[a-z][a-z]_[A-Z][A-Z]$/', $filename)) {
$codes[] = $filename;
if (!isset($all[$filename])) {
- $all[$filename] = $filename;
+ $all[$filename] = $labels[$filename];
}
}
}
unset($all[$code]);
}
}
+
+ ksort($all);
}
if ($enabled === NULL) {
$objects['contact'] = &$contact;
$objects['contribution'] = &$contribution;
+
+ // CRM-19478: handle oddity when p=null is set in place of contribution page ID,
+ if (!empty($ids['contributionPage']) && !is_numeric($ids['contributionPage'])) {
+ // We don't need to worry if about removing contribution page id as it will be set later in
+ // CRM_Contribute_BAO_Contribution::loadRelatedObjects(..) using $objects['contribution']->contribution_page_id
+ unset($ids['contributionPage']);
+ }
+
if (!$this->loadObjects($input, $ids, $objects, $required, $paymentProcessorID)) {
return FALSE;
}
foreach ($permission as $orPerm) {
if (self::check($orPerm)) {
//one of our 'or' permissions has succeeded - stop checking this permission
- return TRUE;;
+ return TRUE;
}
}
//none of our our conditions was met
* @return array
*/
public static function contributionTokens() {
- return array(
+ return array_merge(array(
'{contribution.contribution_id}' => ts('Contribution ID'),
'{contribution.total_amount}' => ts('Total Amount'),
'{contribution.fee_amount}' => ts('Fee Amount'),
//'{contribution.address_id}' => ts('Address ID'),
'{contribution.check_number}' => ts('Check Number'),
'{contribution.campaign}' => ts('Contribution Campaign'),
- );
+ ), CRM_Utils_Token::getCustomFieldTokens('contribution', TRUE));
}
/**
}
$this->postProcessHook();
-
- CRM_Core_Error::statusBounce($statusMessage,
- CRM_Utils_System::url('civicrm/event/info',
+ CRM_Core_Session::setStatus($statusMessage);
+ CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/event/info',
"reset=1&id={$this->_eventId}&noFullMsg=1",
FALSE, NULL, FALSE, TRUE
)
'contact_phone' => ts('Event Contact (Phone)'),
'balance' => ts('Event Balance'),
),
- $this->getCustomTokens('Event')
+ CRM_Utils_Token::getCustomFieldTokens('Event')
));
}
}
\Civi::$statics[__CLASS__]['columnsOf'][$table] = array();
while ($dao->fetch()) {
- \Civi::$statics[__CLASS__]['columnsOf'][$table][] = $dao->Field;
+ \Civi::$statics[__CLASS__]['columnsOf'][$table][] = CRM_Utils_type::escape($dao->Field, 'MysqlColumnNameOrAlias');
}
}
return \Civi::$statics[__CLASS__]['columnsOf'][$table];
// Populate the recipients.
if (empty($params['_skip_evil_bao_auto_recipients_'])) {
// check if it's sms
- $mode = $mailing->sms_provider_id ? 'sms' : NULL;
+ $mode = $mailing->sms_provider_id && $mailing->sms_provider_id != 'null' ? 'sms' : NULL;
self::getRecipients($job->id, $mailing->id, TRUE, $mailing->dedupe_email, $mode);
}
// Schedule the job now that it has recipients.
$message->setHTMLBody($html);
}
if (!$html || $eq->format == 'Text' || $eq->format == 'Both') {
- $text = CRM_Utils_Token::replaceDomainTokens($html, $domain, TRUE, $tokens['text']);
+ $text = CRM_Utils_Token::replaceDomainTokens($text, $domain, TRUE, $tokens['text']);
$text = CRM_Utils_Token::replaceResubscribeTokens($text, $domain, $groups, FALSE, $eq->contact_id, $eq->hash);
$text = CRM_Utils_Token::replaceActionTokens($text, $addresses, $urls, FALSE, $tokens['text']);
$text = CRM_Utils_Token::replaceMailingTokens($text, $dao, NULL, $tokens['text']);
);
// 1. Update Schedule Membership Signup/Renwal activity to completed on successful payment of pending membership
// 2. OR Create renewal activity scheduled if its membership renewal will be paid later
- if (!empty($activityParams['id']) || $activityType == 'Membership Renewal') {
+ if (!empty($params['membership_activity_status']) && (!empty($activityParams['id']) || $activityType == 'Membership Renewal')) {
CRM_Activity_BAO_Activity::addActivity($membership, $activityType, $targetContactID, $activityParams);
break;
}
$currentMembership['today_date'] = $today;
if ($status['id'] !== $currentMembership['status_id']) {
+ $oldStatus = $currentMembership['status_id'];
$memberDAO = new CRM_Member_DAO_Membership();
$memberDAO->id = $currentMembership['id'];
$memberDAO->find(TRUE);
else {
$logParams['modified_id'] = $currentMembership['contact_id'];
}
+
+ //Create activity for status change.
+ $allStatus = CRM_Member_BAO_Membership::buildOptions('status_id', 'get');
+ CRM_Activity_BAO_Activity::addActivity($memberDAO,
+ 'Change Membership Status',
+ NULL,
+ array(
+ 'subject' => "Status changed from {$allStatus[$oldStatus]} to {$allStatus[$status['id']]}",
+ 'source_contact_id' => $logParams['modified_id'],
+ 'priority_id' => 'Normal',
+ )
+ );
+
CRM_Member_BAO_MembershipLog::add($logParams, CRM_Core_DAO::$_nullArray);
}
}
if (!empty($currentMembership['id'])) {
$ids['membership'] = $currentMembership['id'];
}
+ $memParams['membership_activity_status'] = ($pending || $isPayLater) ? 'Scheduled' : 'Completed';
}
//CRM-4555
if ($pending) {
$membershipRecords = FALSE;
if ($this->_action & CRM_Core_Action::UPDATE) {
- $membershipType = new CRM_Member_BAO_Membership();
- $membershipType->membership_type_id = $this->_id;
- if ($membershipType->find(TRUE)) {
- $membershipRecords = TRUE;
+ $result = civicrm_api3("Membership", "get", array("membership_type_id" => $this->_id, "options" => array("limit" => 1)));
+ $membershipRecords = ($result["count"] > 0);
+ if ($membershipRecords) {
$memberRel->freeze();
}
}
$this->assign('membershipSummary', $membershipSummary);
$this->assign('totalCount', $totalCount);
- $this->assign('month', date('F', $monthStartTs));
+ $this->assign('month', CRM_Utils_Date::customFormat($monthStartTs, '%B'));
$this->assign('year', date('Y', $monthStartTs));
- $this->assign('premonth', date('F', strtotime($preMonth)));
+ $this->assign('premonth', CRM_Utils_Date::customFormat($preMonth, '%B'));
$this->assign('currentMonth', date('F'));
$this->assign('currentYear', date('Y'));
$this->assign('isCurrent', $isCurrentMonth);
'status' => ts('Membership Status'),
'type' => ts('Membership Type'),
),
- $this->getCustomTokens('Membership')
+ CRM_Utils_Token::getCustomFieldTokens('Membership')
));
}
* Build the form object.
*/
public function buildQuickForm() {
+ $bounceUrl = CRM_Utils_System::url('civicrm/tag');
if ($this->_action == CRM_Core_Action::DELETE) {
- $url = CRM_Utils_System::url('civicrm/tag');
if (!$this->_id) {
$this->_id = explode(',', CRM_Utils_Request::retrieve('id', 'String'));
}
$this->_id = (array) $this->_id;
if (!$this->_id) {
- CRM_Core_Error::statusBounce(ts("Unknown tag."), $url);
+ CRM_Core_Error::statusBounce(ts("Unknown tag."), $bounceUrl);
}
foreach ($this->_id as $id) {
if (!CRM_Utils_Rule::positiveInteger($id)) {
- CRM_Core_Error::statusBounce(ts("Unknown tag."), $url);
+ CRM_Core_Error::statusBounce(ts("Unknown tag."), $bounceUrl);
}
if ($tag = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Tag', $id, 'name', 'parent_id')) {
- CRM_Core_Error::statusBounce(ts("This tag cannot be deleted. You must delete all its child tags ('%1', etc) prior to deleting this tag.", array(1 => $tag)), $url);
+ CRM_Core_Error::statusBounce(ts("This tag cannot be deleted. You must delete all its child tags ('%1', etc) prior to deleting this tag.", array(1 => $tag)), $bounceUrl);
}
if (!CRM_Core_Permission::check('administer reserved tags') && CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Tag', $id, 'is_reserved')) {
- CRM_Core_Error::statusBounce(ts("You do not have sufficient permission to delete this reserved tag."), $url);
+ CRM_Core_Error::statusBounce(ts("You do not have sufficient permission to delete this reserved tag."), $bounceUrl);
}
}
if (count($this->_id) > 1) {
}
}
else {
+ $adminTagset = CRM_Core_Permission::check('administer Tagsets');
+ $adminReservedTags = CRM_Core_Permission::check('administer reserved tags');
+
$this->_isTagSet = CRM_Utils_Request::retrieve('tagset', 'Positive', $this);
if (!$this->_isTagSet && $this->_id &&
) {
$this->_isTagSet = TRUE;
}
+ if ($this->_isTagSet && !$adminTagset) {
+ CRM_Core_Error::statusBounce(ts("You do not have sufficient permission to edit this tagset."), $bounceUrl);
+ }
+ if ($this->_id && !$adminReservedTags && CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Tag', $this->_id, 'is_reserved')) {
+ CRM_Core_Error::statusBounce(ts("You do not have sufficient permission to edit this reserved tag."), $bounceUrl);
+ }
if ($this->_id) {
$parentId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Tag', $this->_id, 'parent_id');
$this->addSelect('used_for', array('multiple' => TRUE, 'option_url' => NULL));
}
- $adminTagset = TRUE;
- if (!CRM_Core_Permission::check('administer Tagsets')) {
- $adminTagset = FALSE;
- }
$this->assign('adminTagset', $adminTagset);
- $adminReservedTags = TRUE;
- if (!CRM_Core_Permission::check('administer reserved tags')) {
+ if (!$adminReservedTags) {
$isReserved->freeze();
- $adminReservedTags = FALSE;
}
$this->assign('adminReservedTags', $adminReservedTags);
}
$params = array('id' => $cloneFrom);
CRM_Core_BAO_Tag::retrieve($params, $this->_values);
$this->_values['name'] .= ' (' . ts('copy') . ')';
+ if (!empty($this->_values['is_reserved']) && !CRM_Core_Permission::check('administer reserved tags')) {
+ $this->_values['is_reserved'] = 0;
+ }
$defaults = $this->_values;
}
if (empty($defaults['color'])) {
--- /dev/null
+{* file to handle db changes in 4.7.22 during upgrade *}
$key = 'contribution';
if (self::$_tokens[$key] == NULL) {
self::$_tokens[$key] = array_keys(array_merge(CRM_Contribute_BAO_Contribution::exportableFields('All'),
- array('campaign', 'financial_type')
+ array('campaign', 'financial_type'),
+ self::getCustomFieldTokens('Contribution')
));
}
}
);
}
+ /**
+ * Get all custom field tokens of $entity
+ *
+ * @param string $entity
+ * @param bool $usedForTokenWidget
+ *
+ * @return array $customTokens
+ * return custom field tokens in array('custom_N' => 'label') format
+ */
+ public static function getCustomFieldTokens($entity, $usedForTokenWidget = FALSE) {
+ $customTokens = array();
+ $tokenName = $usedForTokenWidget ? "{contribution.custom_%d}" : "custom_%d";
+ foreach (CRM_Core_BAO_CustomField::getFields($entity) as $id => $info) {
+ $customTokens[sprintf($tokenName, $id)] = $info['label'];
+ }
+
+ return $customTokens;
+ }
+
/**
* Formats a token list for the select2 widget
*
$dispatcher = new CiviEventDispatcher($container);
$dispatcher->addListener(SystemInstallEvent::EVENT_NAME, array('\Civi\Core\InstallationCanary', 'check'));
$dispatcher->addListener(SystemInstallEvent::EVENT_NAME, array('\Civi\Core\DatabaseInitializer', 'initialize'));
+ $dispatcher->addListener(SystemInstallEvent::EVENT_NAME, array('\Civi\Core\LocalizationInitializer', 'initialize'));
$dispatcher->addListener('hook_civicrm_pre', array('\Civi\Core\Event\PreEvent', 'dispatchSubevent'), 100);
$dispatcher->addListener('hook_civicrm_post', array('\Civi\Core\Event\PostEvent', 'dispatchSubevent'), 100);
$dispatcher->addListener('hook_civicrm_post::Activity', array('\Civi\CCase\Events', 'fireCaseChange'));
--- /dev/null
+<?php
+/*
+ +--------------------------------------------------------------------+
+ | CiviCRM version 4.7 |
+ +--------------------------------------------------------------------+
+ | 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 |
+ +--------------------------------------------------------------------+
+ */
+
+namespace Civi\Core;
+
+use Civi;
+use Civi\Core\Event\SystemInstallEvent;
+
+/**
+ * Class LocalizationInitializer
+ * @package Civi\Core
+ */
+class LocalizationInitializer {
+
+ /**
+ * Load the locale settings based on the installation language
+ *
+ * @param \Civi\Core\Event\SystemInstallEvent $event
+ * @throws \CRM_Core_Exception
+ */
+ public static function initialize(SystemInstallEvent $event) {
+
+ // get the current installation language
+ global $tsLocale;
+ $seedLanguage = $tsLocale;
+ if (!$seedLanguage) {
+ return;
+ }
+
+ // get the corresponding settings file if any
+ $localeDir = \CRM_Core_I18n::getResourceDir();
+ $fileName = $localeDir . $seedLanguage . DIRECTORY_SEPARATOR . 'settings.default.json';
+
+ // initalization
+ $settingsParams = array();
+
+ if (file_exists($fileName)) {
+
+ // load the file and parse it
+ $json = file_get_contents($fileName);
+ $settings = json_decode($json, TRUE);
+
+ if (!empty($settings)) {
+ // get all valid settings
+ $results = civicrm_api3('Setting', 'getfields', array());
+ $validSettings = array_keys($results['values']);
+ // add valid settings to params to send to api
+ foreach ($settings as $setting => $value) {
+ if (in_array($setting, $validSettings)) {
+ $settingsParams[$setting] = $value;
+ }
+
+ }
+
+ // ensure we don't mess with multilingual
+ unset($settingsParams['languageLimit']);
+
+ // support for enabled languages (option group)
+ if (isset($settings['languagesOption']) && count($settings['languagesOption']) > 0) {
+ \CRM_Core_BAO_OptionGroup::setActiveValues('languages', $settings['languagesOption']);
+ }
+
+ // set default currency in currencies_enabled (option group)
+ if (isset($settings['defaultCurrency'])) {
+ \CRM_Admin_Form_Setting_Localization::updateEnabledCurrencies(array($settings['defaultCurrency']), $settings['defaultCurrency']);
+ }
+
+ }
+
+ }
+
+ // in any case, enforce the seedLanguage as the default language
+ $settingsParams['lcMessages'] = $seedLanguage;
+
+ // apply the config
+ civicrm_api3('Setting', 'create', $settingsParams);
+
+ }
+
+}
}
}
- /**
- * Get all custom field tokens of $entity
- *
- * @param string $entity
- * @return array $customTokens
- * return custom field tokens in array('custom_N' => 'label') format
- */
- public function getCustomTokens($entity) {
- $customTokens = array();
- foreach (\CRM_Core_BAO_CustomField::getFields($entity) as $id => $info) {
- $customTokens["custom_$id"] = $info['label'];
- }
-
- return $customTokens;
- }
-
/**
* Alter the query which prepopulates mailing data
* for scheduled reminders.
}
}
-// Set the locale (required by CRM_Core_Config)
+// Set the CMS
// This is mostly sympbolic, since nothing we do during the install
// really requires CIVICRM_UF to be defined.
$installTypeToUF = array(
$uf = (isset($installTypeToUF[$installType]) ? $installTypeToUF[$installType] : 'Drupal');
define('CIVICRM_UF', $uf);
+// Set the Locale (required by CRM_Core_Config)
global $tsLocale;
$tsLocale = 'en_US';
// now enable civicrm module.
module_enable(array('civicrm', 'civicrmtheme'));
+ // SystemInstallEvent will be called from here with the first call of CRM_Core_Config,
+ // which calls Core_BAO_ConfigSetting::applyLocale(), who will default to calling
+ // Civi::settings()->get('lcMessages');
+ // Therefore, we need to pass the seedLanguage before that.
+ global $civicrm_setting;
+ $civicrm_setting['domain']['lcMessages'] = $config['seedLanguage'];
+
// clear block, page, theme, and hook caches
drupal_flush_all_caches();
$GLOBALS['user'] = $original_user;
drupal_save_session(TRUE);
- //change the default language to one chosen
- if (isset($config['seedLanguage']) && $config['seedLanguage'] != 'en_US') {
- civicrm_api3('Setting', 'create', array(
- 'domain_id' => 'current_domain',
- 'lcMessages' => $config['seedLanguage'],
- )
- );
- }
-
$output .= '</ul>';
$output .= '</div>';
$output .= '</body>';
'pseudoconstant' => array(
'callback' => 'CRM_Admin_Form_Setting_Localization::getCurrencySymbols',
),
+ 'on_change' => array(
+ 'CRM_Admin_Form_Setting_Localization::onChangeDefaultCurrency',
+ ),
),
'defaultContactCountry' => array(
'group_name' => 'Localization Preferences',
LOCK TABLES `civicrm_domain` WRITE;
/*!40000 ALTER TABLE `civicrm_domain` DISABLE KEYS */;
-INSERT INTO `civicrm_domain` (`id`, `name`, `description`, `config_backend`, `version`, `contact_id`, `locales`, `locale_custom_strings`) VALUES (1,'Default Domain Name',NULL,NULL,'4.7.21',1,NULL,'a:1:{s:5:\"en_US\";a:0:{}}');
+INSERT INTO `civicrm_domain` (`id`, `name`, `description`, `config_backend`, `version`, `contact_id`, `locales`, `locale_custom_strings`) VALUES (1,'Default Domain Name',NULL,NULL,'4.7.22',1,NULL,'a:1:{s:5:\"en_US\";a:0:{}}');
/*!40000 ALTER TABLE `civicrm_domain` ENABLE KEYS */;
UNLOCK TABLES;
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
*}
-{literal}
-<style>
- #tagtree .highlighted > span {
- background-color: #fefca6;
- }
- #tagtree .helpicon ins {
- display: none;
- }
- #tagtree ins.jstree-icon {
- cursor: pointer;
- }
-</style>
-<script type="text/javascript">
- (function($, _){{/literal}
- var entityID='{$entityID}',
- entityTable='{$entityTable}',
- $form = $('form.{$form.formClass}');
- {literal}
-
- $(function() {
- function highlightSelected() {
- $("ul input:not(:checked)", '#tagtree').each(function () {
- $(this).closest("li").removeClass('highlighted');
- });
- $("ul input:checked", '#tagtree').each(function () {
- $(this).parents("li[id^=tag]").addClass('highlighted');
- });
- }
- highlightSelected();
-
- $("#tagtree input").change(function(){
- highlightSelected();
- });
-
- var childTag = "{/literal}{$loadjsTree}{literal}";
- if (childTag) {
- //load js tree.
- $("#tagtree").jstree({
- plugins : ["themes", "html_data"],
- themes: {
- "theme": 'classic',
- "dots": false,
- "icons": false,
- "url": CRM.config.resourceBase + 'packages/jquery/plugins/jstree/themes/classic/style.css'
- }
- });
- }
- {/literal}
- {if !empty($permission) && $permission neq 'edit'}
- {literal}
- $("#tagtree input").prop('disabled', true);
- {/literal}
- {/if}
- {literal}
- });
- })(CRM.$, CRM._);
- {/literal}
-</script>
-
{if $title}
<div class="crm-accordion-wrapper crm-tagGroup-accordion collapsed">
<div class="crm-accordion-header">{$title}</div>
{/if}
<table class="form-layout-compressed{if $context EQ 'profile'} crm-profile-tagsandgroups{/if}">
<tr>
+ {if !$type || $type eq 'tag'}
+ <td>
+ <div class="crm-section tag-section">
+ {if $title}{$form.tag.label}{/if}
+ {$form.tag.html}
+ </div>
+ {if $context NEQ 'profile'}
+ {include file="CRM/common/Tagset.tpl"}
+ {/if}
+ </td>
+ {/if}
{if !$type || $type eq 'group'}
<td>
{if $groupElementType eq 'select'}
- <span class="label">{if $title}{$form.group.label}{/if}</span>
+ <div class="crm-section group-section">
+ {if $title}{$form.group.label}{/if}
{$form.group.html}
+ </div>
{else}
{foreach key=key item=item from=$tagGroup.group}
<div class="group-wrapper">
{/if}
</td>
{/if}
- {if (!$type || $type eq 'tag') && $tree}
- <td width="70%">{if $title}<span class="label">{$form.tag.label}</span>{/if}
- <div id="tagtree">
- {include file="CRM/Contact/Form/Edit/Tagtree.tpl" level=1}
- </div>
- </td>
- <tr><td>{include file="CRM/common/Tagset.tpl"}</td></tr>
- {/if}
</tr>
</table>
{if $title}
}
}
- function showHideAmountBlock( element, elementName )
- {
- // show / hide when amount section is active check/uncheck.
-
- var priceSetID = {/literal}'{$priceSetID}'{literal};
-
- switch ( elementName ) {
+ function showHideAmountBlock(element, elementName) {
+ // show / hide when amount section is active check/uncheck.
+ var priceSetID = {/literal}'{$priceSetID}'{literal};
+ switch (elementName) {
case 'price_set_id':
- if ( element ) {
- cj('#amountFields').hide();
- } else {
- cj('#amountFields').show();
- }
- cj("#amount_block_is_active").prop('checked', true );
- break;
-
- case 'is_pledge_active' :
- case 'is_allow_other_amount' :
- if ( element.checked ) {
- if ( priceSetID ) cj( "#price_set_id" ).val( '' );
- cj('#amountFields').show();
- }
- cj("#amount_block_is_active").prop('checked', true );
- break;
-
- case 'amount_block_is_active' :
- if ( element.checked ) {
- if ( priceSetID ) {
- cj('#amountFields').hide();
- cj( "#price_set_id" ).val( priceSetID );
- } else {
- cj('#amountFields').show();
- cj( "#price_set_id" ).val( '' );
+ if (element) {
+ cj('#amountFields').hide();
}
- cj('#priceSet, #recurringFields').show();
- } else {
- cj( "#price_set_id" ).val( '' );
- cj('#amountFields, #priceSet, #recurringFields').hide();
- }
- break;
- }
- }
+ break;
+
+ case 'is_pledge_active':
+ case 'is_allow_other_amount':
+ if (element.checked) {
+ if (priceSetID) cj( "#price_set_id" ).val('');
+ cj('#amountFields').show();
+ }
+ cj("#amount_block_is_active").prop('checked', true );
+ break;
+
+ case 'amount_block_is_active':
+ if (element.checked) {
+ if (priceSetID) {
+ cj('#amountFields').hide();
+ cj( "#price_set_id" ).val(priceSetID);
+ }
+ else {
+ cj('#amountFields').show();
+ cj( "#price_set_id" ).val('');
+ }
+ cj('#priceSet, #recurringFields').show();
+ }
+ else {
+ cj( "#price_set_id" ).val('');
+ cj('#amountFields, #priceSet, #recurringFields').hide();
+ }
+ break;
+ }
+ }
function showRecurring( paymentProcessorIds ) {
var display = true;
{if $relatedContributions}
{ts 1=$title}You cannot delete this Contribution Page because it has already been used to submit a contribution or membership payment. It is recommended that your disable the page instead of deleting it, to preserve the integrity of your contribution records. If you do want to completely delete this contribution page, you first need to search for and delete all of the contribution transactions associated with this page in CiviContribute.{/ts}
{else}
- WARNING: Are you sure you want to Delete the selected Contribution Page? A Delete operation cannot be undone. Do you want to continue?
+ {ts}WARNING: Are you sure you want to Delete the selected Contribution Page? A Delete operation cannot be undone. Do you want to continue?{/ts}
{/if}
</div>
<div class="form-item">
{if $n eq 'email_greeting' or $n eq 'postal_greeting' or $n eq 'addressee'}
{include file="CRM/Profile/Form/GreetingType.tpl"}
{elseif ( $n eq 'group' && $form.group ) || ( $n eq 'tag' && $form.tag )}
- {include file="CRM/Contact/Form/Edit/TagsAndGroups.tpl" type=$n context="profile"}
+ {include file="CRM/Contact/Form/Edit/TagsAndGroups.tpl" type=$n context="profile" tableLayout=1}
{elseif ( $form.$n.name eq 'image_URL' )}
{$form.$n.html}
{if !empty($imageURL)}
div.tag-info input[type=color] {
cursor: pointer;
}
+ div.tag-info input[disabled] {
+ cursor: default;
+ }
div.tag-info .tdl {
font-weight: bold;
color: #999;
<script type="text/template" id="oneSelectedTpl">
<div class="crm-entity" data-entity="Tag" data-id="<%= id %>">
<h4>
- <input type="color" value="<%= data.color %>" title="{ts}Select color{/ts}"/>
- <span class="crm-editable" data-field="name"><%- text %></span>
+ <input type="color" value="<%= data.color %>" <% if (!data.is_reserved || adminReserved) {ldelim} %>title="{ts}Select color{/ts}" <% {rdelim} else {ldelim} %>disabled<% {rdelim} %> />
+ <span class="<% if (!data.is_reserved || adminReserved) {ldelim} %>crm-editable<% {rdelim} %>" data-field="name"><%- text %></span>
</h4>
<hr />
<div><span class="tdl">{ts}Description:{/ts}</span>
- <span class="crm-editable" data-field="description"><%- data.description %></span>
+ <span class="<% if (!data.is_reserved || adminReserved) {ldelim} %>crm-editable<% {rdelim} %>" data-field="description"><%- data.description %></span>
</div>
<div><span class="tdl">{ts}Selectable:{/ts}</span>
- <span class="crm-editable" data-field="is_selectable" data-type="select"><% if (data.is_selectable) {ldelim} %> {ts}Yes{/ts} <% {rdelim} else {ldelim} %> {ts}No{/ts} <% {rdelim} %></span>
+ <span class="<% if (!data.is_reserved || adminReserved) {ldelim} %>crm-editable<% {rdelim} %>" data-field="is_selectable" data-type="select"><% if (data.is_selectable) {ldelim} %> {ts}Yes{/ts} <% {rdelim} else {ldelim} %> {ts}No{/ts} <% {rdelim} %></span>
</div>
<div><span class="tdl">{ts}Reserved:{/ts}</span>
<span class="<% if (adminReserved) {ldelim} %>crm-editable<% {rdelim} %>" data-field="is_reserved" data-type="select"><% if (data.is_reserved) {ldelim} %> {ts}Yes{/ts} <% {rdelim} else {ldelim} %> {ts}No{/ts} <% {rdelim} %></span>
<div>
<span class="tdl">{ts}Used For:{/ts}</span>
{literal}
- <span class="crm-editable-enabled used-for-toggle">
+ <span class="<% if (!data.is_reserved || adminReserved) { %>crm-editable-enabled used-for-toggle<% } %>">
<% if (!data.used_for.length) { %><i class="crm-i fa-pencil crm-editable-placeholder"></i><% } %>
<% _.forEach(data.used_for, function(key, i) { %><%- (i ? ', ' : '') + usedFor[key] %><% }) %>
</span>
$this->assertEquals(array('data' => array(), 'recordsTotal' => 0, 'recordsFiltered' => 0), $result);
}
+ /**
+ * CRM-20621 : Test to check usage count of Tag tree
+ */
+ public function testGetTagTree() {
+ $contacts = array();
+ // create three contacts
+ for ($i = 0; $i < 3; $i++) {
+ $contacts[] = $this->individualCreate();
+ }
+
+ // Create Tag called as 'Parent Tag'
+ $parentTag = $this->tagCreate(array(
+ 'name' => 'Parent Tag',
+ 'used_for' => 'civicrm_contact',
+ ));
+ //assign first contact to parent tag
+ $params = array(
+ 'entity_id' => $contacts[0],
+ 'entity_table' => 'civicrm_contact',
+ 'tag_id' => $parentTag['id'],
+ );
+ // TODO: EntityTag.create API is not working
+ CRM_Core_BAO_EntityTag::add($params);
+
+ // Create child Tag of $parentTag
+ $childTag1 = $this->tagCreate(array(
+ 'name' => 'Child Tag Level 1',
+ 'parent_id' => $parentTag['id'],
+ 'used_for' => 'civicrm_contact',
+ ));
+ //assign contact to this level 1 child tag
+ $params = array(
+ 'entity_id' => $contacts[1],
+ 'entity_table' => 'civicrm_contact',
+ 'tag_id' => $childTag1['id'],
+ );
+ CRM_Core_BAO_EntityTag::add($params);
+
+ // Create child Tag of $childTag1
+ $childTag2 = $this->tagCreate(array(
+ 'name' => 'Child Tag Level 2',
+ 'parent_id' => $childTag1['id'],
+ 'used_for' => 'civicrm_contact',
+ ));
+ //assign contact to this level 2 child tag
+ $params = array(
+ 'entity_id' => $contacts[2],
+ 'entity_table' => 'civicrm_contact',
+ 'tag_id' => $childTag2['id'],
+ );
+ CRM_Core_BAO_EntityTag::add($params);
+
+ // CASE I : check the usage count of parent tag which need to be 1
+ // as the one contact added
+ $_REQUEST['is_unit_test'] = TRUE;
+ $parentTagTreeResult = CRM_Admin_Page_AJAX::getTagTree();
+ foreach ($parentTagTreeResult as $result) {
+ if ($result['id'] == $parentTag['id']) {
+ $this->assertEquals(1, $result['data']['usages']);
+ }
+ }
+
+ // CASE 2 : check the usage count of level 1 child tag, which needs to be 1
+ // as it should include the count of added one contact
+ $_GET['parent_id'] = $parentTag['id'];
+ $childTagTree = CRM_Admin_Page_AJAX::getTagTree();
+ $this->assertEquals(1, $childTagTree[0]['data']['usages']);
+
+ // CASE 2 : check the usage count of child tag at level 2
+ //which needs to be 1 as it has no child tag
+ $_GET['parent_id'] = $childTag1['id'];
+ $childTagTree = CRM_Admin_Page_AJAX::getTagTree();
+ $this->assertEquals(1, $childTagTree[0]['data']['usages']);
+
+ //cleanup
+ foreach ($contacts as $id) {
+ $this->callAPISuccess('Contact', 'delete', array('id' => $id));
+ }
+ $this->callAPISuccess('Tag', 'delete', array('id' => $childTag2['id']));
+ $this->callAPISuccess('Tag', 'delete', array('id' => $childTag1['id']));
+ $this->callAPISuccess('Tag', 'delete', array('id' => $parentTag['id']));
+ }
+
/**
* Test to check contact reference field
*/
$this->callAPISuccessGetSingle('Address', array(
'id' => $contribution['address_id'],
));
+ }
+ /**
+ * CRM-20745: Test the submit function correctly sets the
+ * receive date for recurring contribution.
+ */
+ public function testSubmitCreditCardWithRecur() {
+ $form = new CRM_Contribute_Form_Contribution();
+ $receiveDate = date('m/d/Y', strtotime('+1 month'));
+ $form->testSubmit(array(
+ 'total_amount' => 50,
+ 'financial_type_id' => 1,
+ 'is_recur' => 1,
+ 'frequency_interval' => 2,
+ 'frequency_unit' => 'month',
+ 'installments' => 2,
+ 'receive_date' => $receiveDate,
+ 'receive_date_time' => '11:27PM',
+ 'contact_id' => $this->_individualId,
+ 'payment_instrument_id' => array_search('Credit Card', $this->paymentInstruments),
+ 'payment_processor_id' => $this->paymentProcessorID,
+ 'credit_card_exp_date' => array('M' => 5, 'Y' => 2025),
+ 'credit_card_number' => '411111111111111',
+ 'billing_city-5' => 'Vancouver',
+ ), CRM_Core_Action::ADD,
+ 'live'
+ );
+ $contribution = $this->callAPISuccessGetSingle('Contribution', array('return' => 'receive_date'));
+ $this->assertEquals(date("m/d/Y", strtotime($contribution['receive_date'])), $receiveDate);
}
/**
*/
public function testIPNPaymentRecurSuccess() {
$this->setupRecurringPaymentProcessorTransaction();
+ global $_GET;
+ $_GET = $this->getPaypalProRecurTransaction();
$paypalIPN = new CRM_Core_Payment_PayPalProIPN($this->getPaypalProRecurTransaction());
$paypalIPN->main();
$contribution = $this->callAPISuccess('contribution', 'getsingle', array('id' => $this->_contributionID));
'amount_per_cycle' => '15.00',
'mc_gross' => '15.00',
'payment_date' => '03:59:05 Jul 14, 2013 PDT',
- 'rp_invoice_id' => 'i=' . $this->_invoiceID . '&m=contribute&c=' . $this->_contactID . '&r=' . $this->_contributionRecurID . '&b=' . $this->_contributionID . '&p=' . $this->_contributionPageID,
+ 'rp_invoice_id' => 'i=' . $this->_invoiceID . '&m=contribute&c=' . $this->_contactID . '&r=' . $this->_contributionRecurID . '&b=' . $this->_contributionID . '&p=null',
'payment_status' => 'Completed',
'business' => 'nowhere@civicrm.org',
'last_name' => 'Roberty',
$this->mut->checkMailLog(array(
'is_recur:::1',
- 'cancelSubscriptionUrl:::http://dummy.com',
+ 'cancelSubscriptionUrl:::' . CIVICRM_UF_BASEURL,
));
$this->mut->stop();
$this->revertTemplateToReservedTemplate();
);
$result = $this->callAPISuccess('membership', 'create', $params);
+
+ //Update Status and check activities created.
+ $updateStatus = array(
+ 'id' => $result['id'],
+ 'status_id' => CRM_Core_PseudoConstant::getKey('CRM_Member_BAO_Membership', 'status_id', 'Cancelled'),
+ );
+ $this->callAPISuccess('Membership', 'create', $updateStatus);
+ $activities = CRM_Activity_BAO_Activity::getContactActivity($this->_contactID);
+ $this->assertEquals(2, count($activities));
+ $activityNames = array_flip(CRM_Utils_Array::collect('activity_name', $activities));
+ $this->assertArrayHasKey('Membership Signup', $activityNames);
+ $this->assertArrayHasKey('Change Membership Status', $activityNames);
+
$this->callAPISuccess('Membership', 'Delete', array(
'id' => $result['id'],
));
<?xml version="1.0" encoding="iso-8859-1" ?>
<version>
- <version_no>4.7.21</version_no>
+ <version_no>4.7.22</version_no>
</version>