本文整理汇总了PHP中CRM_Utils_Time::getTime方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Utils_Time::getTime方法的具体用法?PHP CRM_Utils_Time::getTime怎么用?PHP CRM_Utils_Time::getTime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Utils_Time
的用法示例。
在下文中一共展示了CRM_Utils_Time::getTime方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: civicrm_api3_mailing_a_b_graph_stats
/**
* Send graph detail for A/B tests mail.
*
* @param array $params
*
* @return array
* @throws API_Exception
*/
function civicrm_api3_mailing_a_b_graph_stats($params)
{
civicrm_api3_verify_mandatory($params, 'CRM_Mailing_DAO_MailingAB', array('id'), FALSE);
$defaults = array('criteria' => 'Open', 'target_date' => CRM_Utils_Time::getTime('YmdHis'), 'split_count' => 6, 'split_count_select' => 1);
$params = array_merge($defaults, $params);
$mailingAB = civicrm_api3('MailingAB', 'getsingle', array('id' => $params['id']));
$graphStats = array();
$ABFormat = array('A' => 'mailing_id_a', 'B' => 'mailing_id_b');
foreach ($ABFormat as $name => $column) {
switch (strtolower($params['criteria'])) {
case 'open':
$result = CRM_Mailing_Event_BAO_Opened::getRows($mailingAB['mailing_id_a'], NULL, TRUE, 0, 1, "civicrm_mailing_event_opened.time_stamp ASC");
$startDate = CRM_Utils_Date::processDate($result[0]['date']);
$targetDate = CRM_Utils_Date::processDate($params['target_date']);
$dateDuration = round(round(strtotime($targetDate) - strtotime($startDate)) / $params['split_count']);
$toDate = strtotime($startDate) + $dateDuration * $params['split_count_select'];
$toDate = date('YmdHis', $toDate);
$graphStats[$name] = array($params['split_count_select'] => array('count' => CRM_Mailing_Event_BAO_Opened::getTotalCount($mailingAB[$column], NULL, TRUE, $toDate), 'time' => CRM_Utils_Date::customFormat($toDate)));
break;
case 'total unique clicks':
$result = CRM_Mailing_Event_BAO_TrackableURLOpen::getRows($mailingAB['mailing_id_a'], NULL, TRUE, 0, 1, "civicrm_mailing_event_trackable_url_open.time_stamp ASC");
$startDate = CRM_Utils_Date::processDate($result[0]['date']);
$targetDate = CRM_Utils_Date::processDate($params['target_date']);
$dateDuration = round(abs(strtotime($targetDate) - strtotime($startDate)) / $params['split_count']);
$toDate = strtotime($startDate) + $dateDuration * $params['split_count_select'];
$toDate = date('YmdHis', $toDate);
$graphStats[$name] = array($params['split_count_select'] => array('count' => CRM_Mailing_Event_BAO_TrackableURLOpen::getTotalCount($params['mailing_id'], NULL, FALSE, NULL, $toDate), 'time' => CRM_Utils_Date::customFormat($toDate)));
break;
case 'total clicks on a particular link':
if (empty($params['target_url'])) {
throw new API_Exception("Provide url to get stats result for total clicks on a particular link");
}
// FIXME: doesn't make sense to get url_id mailing_id_(a|b) while getting start date in mailing_id_a
$url_id = CRM_Mailing_BAO_TrackableURL::getTrackerURLId($mailingAB[$column], $params['target_url']);
$result = CRM_Mailing_Event_BAO_TrackableURLOpen::getRows($mailingAB['mailing_id_a'], NULL, FALSE, $url_id, 0, 1, "civicrm_mailing_event_trackable_url_open.time_stamp ASC");
$startDate = CRM_Utils_Date::processDate($result[0]['date']);
$targetDate = CRM_Utils_Date::processDate($params['target_date']);
$dateDuration = round(abs(strtotime($targetDate) - strtotime($startDate)) / $params['split_count']);
$toDate = strtotime($startDate) + $dateDuration * $params['split_count_select'];
$toDate = CRM_Utils_Date::processDate($toDate);
$graphStats[$name] = array($params['split_count_select'] => array('count' => CRM_Mailing_Event_BAO_TrackableURLOpen::getTotalCount($params['mailing_id'], NULL, FALSE, $url_id, $toDate), 'time' => CRM_Utils_Date::customFormat($toDate)));
break;
}
}
return civicrm_api3_create_success($graphStats);
}
示例2: setDb
/**
* Update the DB record for this setting.
*
* @param string $name
* The simple name of the setting.
* @param mixed $value
* The new value of the setting.
*/
protected function setDb($name, $value)
{
if (\CRM_Core_BAO_Setting::isUpgradeFromPreFourOneAlpha1()) {
// civicrm_setting table is not going to be present.
return;
}
$fields = array();
$fieldsToSet = \CRM_Core_BAO_Setting::validateSettingsInput(array($name => $value), $fields);
//We haven't traditionally validated inputs to setItem, so this breaks things.
//foreach ($fieldsToSet as $settingField => &$settingValue) {
// self::validateSetting($settingValue, $fields['values'][$settingField]);
//}
$metadata = $fields['values'][$name];
$dao = new \CRM_Core_DAO_Setting();
$dao->name = $name;
$dao->domain_id = $this->domainId;
if ($this->contactId) {
$dao->contact_id = $this->contactId;
$dao->is_domain = 0;
} else {
$dao->is_domain = 1;
}
$dao->find(TRUE);
if (isset($metadata['on_change'])) {
foreach ($metadata['on_change'] as $callback) {
call_user_func(\Civi\Core\Resolver::singleton()->get($callback), unserialize($dao->value), $value, $metadata, $this->domainId);
}
}
if (\CRM_Utils_System::isNull($value)) {
$dao->value = 'null';
} else {
$dao->value = serialize($value);
}
$dao->created_date = \CRM_Utils_Time::getTime('Ymdhis');
$session = \CRM_Core_Session::singleton();
if (\CRM_Contact_BAO_Contact_Utils::isContactId($session->get('userID'))) {
$dao->created_id = $session->get('userID');
}
$dao->save();
$dao->free();
}
示例3: setDb
/**
* Update the DB record for this setting.
*
* @param string $name
* The simple name of the setting.
* @param mixed $value
* The new value of the setting.
*/
protected function setDb($name, $value)
{
if (\CRM_Core_BAO_Setting::isUpgradeFromPreFourOneAlpha1()) {
// civicrm_setting table is not going to be present.
return;
}
$fields = array();
$fieldsToSet = \CRM_Core_BAO_Setting::validateSettingsInput(array($name => $value), $fields);
//We haven't traditionally validated inputs to setItem, so this breaks things.
//foreach ($fieldsToSet as $settingField => &$settingValue) {
// self::validateSetting($settingValue, $fields['values'][$settingField]);
//}
$metadata = $fields['values'][$name];
$dao = new \CRM_Core_DAO_Setting();
$dao->name = $name;
$dao->domain_id = $this->domainId;
if ($this->contactId) {
$dao->contact_id = $this->contactId;
$dao->is_domain = 0;
} else {
$dao->is_domain = 1;
}
$dao->find(TRUE);
if (isset($metadata['on_change'])) {
foreach ($metadata['on_change'] as $callback) {
call_user_func(\Civi\Core\Resolver::singleton()->get($callback), unserialize($dao->value), $value, $metadata, $this->domainId);
}
}
if (!is_array($value) && \CRM_Utils_System::isNull($value)) {
$dao->value = 'null';
} else {
$dao->value = serialize($value);
}
if (!isset(\Civi::$statics[__CLASS__]['upgradeMode'])) {
\Civi::$statics[__CLASS__]['upgradeMode'] = \CRM_Core_Config::isUpgradeMode();
}
if (\Civi::$statics[__CLASS__]['upgradeMode'] && \CRM_Core_DAO::checkFieldExists('civicrm_setting', 'group_name')) {
$dao->group_name = 'placeholder';
}
$dao->created_date = \CRM_Utils_Time::getTime('YmdHis');
$session = \CRM_Core_Session::singleton();
if (\CRM_Contact_BAO_Contact_Utils::isContactId($session->get('userID'))) {
$dao->created_id = $session->get('userID');
}
if ($dao->id) {
$dao->save();
} else {
// Cannot use $dao->save(); in upgrade mode (eg WP + Civi 4.4=>4.7), the DAO will refuse
// to save the field `group_name`, which is required in older schema.
\CRM_Core_DAO::executeQuery(\CRM_Utils_SQL_Insert::dao($dao)->toSQL());
}
$dao->free();
}
示例4: processQueue
/**
* @param null $now
* @param array $params
*
* @return array
*/
static function processQueue($now = NULL, $params = array())
{
$now = $now ? CRM_Utils_Time::setTime($now) : CRM_Utils_Time::getTime();
$mappings = self::getMapping();
foreach ($mappings as $mappingID => $mapping) {
self::buildRecipientContacts($mappingID, $now, $params);
self::sendMailings($mappingID, $now);
}
$result = array('is_error' => 0, 'messages' => ts('Sent all scheduled reminders successfully'));
return $result;
}
示例5: createMailingActivity
/**
* Save a record about the delivery of a reminder email.
*
* WISHLIST: Instead of saving $actionSchedule->body_html, call this immediately after
* sending the message and pass in the fully rendered text of the message.
*
* @param CRM_Core_DAO_ActionSchedule $actionSchedule
* @param Civi\ActionSchedule\Mapping $mapping
* @param int $contactID
* @param int $entityID
* @param int|NULL $caseID
* @throws CRM_Core_Exception
*/
protected static function createMailingActivity($actionSchedule, $mapping, $contactID, $entityID, $caseID)
{
$session = CRM_Core_Session::singleton();
if ($mapping->getEntity() == 'civicrm_membership') {
$activityTypeID = CRM_Core_OptionGroup::getValue('activity_type', 'Membership Renewal Reminder', 'name');
} else {
$activityTypeID = CRM_Core_OptionGroup::getValue('activity_type', 'Reminder Sent', 'name');
}
$activityParams = array('subject' => $actionSchedule->title, 'details' => $actionSchedule->body_html, 'source_contact_id' => $session->get('userID') ? $session->get('userID') : $contactID, 'target_contact_id' => $contactID, 'activity_date_time' => CRM_Utils_Time::getTime('YmdHis'), 'status_id' => CRM_Core_OptionGroup::getValue('activity_status', 'Completed', 'name'), 'activity_type_id' => $activityTypeID, 'source_record_id' => $entityID);
$activity = CRM_Activity_BAO_Activity::create($activityParams);
//file reminder on case if source activity is a case activity
if (!empty($caseID)) {
$caseActivityParams = array();
$caseActivityParams['case_id'] = $caseID;
$caseActivityParams['activity_id'] = $activity->id;
CRM_Case_BAO_Case::processCaseActivity($caseActivityParams);
}
}
示例6: createItem
/**
* Add a new item to the queue.
*
* @param mixed $data
* Serializable PHP object or array.
* @param array $options
* Queue-dependent options; for example, if this is a
* priority-queue, then $options might specify the item's priority.
*/
public function createItem($data, $options = array())
{
$dao = new CRM_Queue_DAO_QueueItem();
$dao->queue_name = $this->getName();
$dao->submit_time = CRM_Utils_Time::getTime('YmdHis');
$dao->data = serialize($data);
$dao->weight = CRM_Utils_Array::value('weight', $options, 0);
$dao->save();
}
示例7: createActivity
/**
* @param Analyzer $analyzer
* The case being analyzed -- to which we want to add an activity.
* @param \SimpleXMLElement $actXML the <ActivityType> tag which describes the new activity
*/
public function createActivity(Analyzer $analyzer, \SimpleXMLElement $actXML)
{
$params = array('activity_type_id' => (string) $actXML->name, 'status_id' => 'Scheduled', 'activity_date_time' => \CRM_Utils_Time::getTime('YmdHis'), 'case_id' => $analyzer->getCaseId());
$r = civicrm_api3('Activity', 'create', $params);
$analyzer->flush();
}
示例8: testSequence
public function testSequence()
{
$actStatuses = array_flip(\CRM_Core_PseudoConstant::activityStatus('name'));
$caseStatuses = array_flip(\CRM_Case_PseudoConstant::caseStatus('name'));
$actTypes = array_flip(\CRM_Activity_BAO_Activity::buildOptions('activity_type_id', 'create'));
// Create case; schedule first activity
\CRM_Utils_Time::setTime('2013-11-30 01:00:00');
$case = $this->callAPISuccess('case', 'create', $this->_params);
$analyzer = new \Civi\CCase\Analyzer($case['id']);
$this->assertEquals($caseStatuses['Open'], self::ag($analyzer->getCase(), 'status_id'));
$this->assertApproxTime('2013-11-30 01:00:00', self::ag($analyzer->getSingleActivity('Medical evaluation'), 'activity_date_time'));
$this->assertEquals($actStatuses['Scheduled'], self::ag($analyzer->getSingleActivity('Medical evaluation'), 'status_id'));
$this->assertFalse($analyzer->hasActivity('Mental health evaluation'));
$this->assertFalse($analyzer->hasActivity('Secure temporary housing'));
// Edit details of first activity -- but don't finish it yet!
\CRM_Utils_Time::setTime('2013-11-30 01:30:00');
$this->callApiSuccess('Activity', 'create', array('id' => self::ag($analyzer->getSingleActivity('Medical evaluation'), 'id'), 'subject' => 'This is the new subject'));
$analyzer = new \Civi\CCase\Analyzer($case['id']);
$this->assertEquals($caseStatuses['Open'], self::ag($analyzer->getCase(), 'status_id'));
$this->assertApproxTime('2013-11-30 01:00:00', self::ag($analyzer->getSingleActivity('Medical evaluation'), 'activity_date_time'));
$this->assertEquals($actStatuses['Scheduled'], self::ag($analyzer->getSingleActivity('Medical evaluation'), 'status_id'));
$this->assertFalse($analyzer->hasActivity('Mental health evaluation'));
$this->assertFalse($analyzer->hasActivity('Secure temporary housing'));
// Complete first activity; schedule second
\CRM_Utils_Time::setTime('2013-11-30 02:00:00');
$this->callApiSuccess('Activity', 'create', array('id' => self::ag($analyzer->getSingleActivity('Medical evaluation'), 'id'), 'status_id' => $actStatuses['Completed']));
$analyzer->flush();
$this->assertEquals($caseStatuses['Open'], self::ag($analyzer->getCase(), 'status_id'));
$this->assertApproxTime('2013-11-30 01:00:00', self::ag($analyzer->getSingleActivity('Medical evaluation'), 'activity_date_time'));
$this->assertEquals($actStatuses['Completed'], self::ag($analyzer->getSingleActivity('Medical evaluation'), 'status_id'));
$this->assertApproxTime('2013-11-30 02:00:00', self::ag($analyzer->getSingleActivity('Mental health evaluation'), 'activity_date_time'));
$this->assertEquals($actStatuses['Scheduled'], self::ag($analyzer->getSingleActivity('Mental health evaluation'), 'status_id'));
$this->assertFalse($analyzer->hasActivity('Secure temporary housing'));
// Complete second activity; schedule third
\CRM_Utils_Time::setTime('2013-11-30 03:00:00');
$this->callApiSuccess('Activity', 'create', array('id' => self::ag($analyzer->getSingleActivity('Mental health evaluation'), 'id'), 'status_id' => $actStatuses['Completed']));
$analyzer->flush();
$this->assertEquals($caseStatuses['Open'], self::ag($analyzer->getCase(), 'status_id'));
$this->assertApproxTime('2013-11-30 01:00:00', self::ag($analyzer->getSingleActivity('Medical evaluation'), 'activity_date_time'));
$this->assertEquals($actStatuses['Completed'], self::ag($analyzer->getSingleActivity('Medical evaluation'), 'status_id'));
$this->assertApproxTime('2013-11-30 02:00:00', self::ag($analyzer->getSingleActivity('Mental health evaluation'), 'activity_date_time'));
$this->assertEquals($actStatuses['Completed'], self::ag($analyzer->getSingleActivity('Mental health evaluation'), 'status_id'));
$this->assertApproxTime('2013-11-30 03:00:00', self::ag($analyzer->getSingleActivity('Secure temporary housing'), 'activity_date_time'));
$this->assertEquals($actStatuses['Scheduled'], self::ag($analyzer->getSingleActivity('Secure temporary housing'), 'status_id'));
//Add an Activity before the case is closed
\CRM_Utils_Time::setTime('2013-11-30 04:00:00');
$this->callApiSuccess('Activity', 'create', array('activity_name' => 'Follow up', 'activity_type_id' => $actTypes['Follow up'], 'status_id' => $actStatuses['Scheduled'], 'case_id' => $case['id'], 'activity_date_time' => \CRM_Utils_Time::getTime()));
$analyzer->flush();
$this->assertApproxTime('2013-11-30 01:00:00', self::ag($analyzer->getSingleActivity('Medical evaluation'), 'activity_date_time'));
$this->assertEquals($actStatuses['Completed'], self::ag($analyzer->getSingleActivity('Medical evaluation'), 'status_id'));
$this->assertApproxTime('2013-11-30 02:00:00', self::ag($analyzer->getSingleActivity('Mental health evaluation'), 'activity_date_time'));
$this->assertEquals($actStatuses['Completed'], self::ag($analyzer->getSingleActivity('Mental health evaluation'), 'status_id'));
$this->assertApproxTime('2013-11-30 03:00:00', self::ag($analyzer->getSingleActivity('Secure temporary housing'), 'activity_date_time'));
$this->assertEquals($actStatuses['Scheduled'], self::ag($analyzer->getSingleActivity('Secure temporary housing'), 'status_id'));
$this->assertApproxTime('2013-11-30 04:00:00', self::ag($analyzer->getSingleActivity('Follow up'), 'activity_date_time'));
$this->assertEquals($actStatuses['Scheduled'], self::ag($analyzer->getSingleActivity('Follow up'), 'status_id'));
// Complete third activity; Case should remain open because of the Follow up activity
\CRM_Utils_Time::setTime('2013-11-30 04:00:00');
$this->callApiSuccess('Activity', 'create', array('id' => self::ag($analyzer->getSingleActivity('Secure temporary housing'), 'id'), 'status_id' => $actStatuses['Completed']));
$analyzer->flush();
$this->assertApproxTime('2013-11-30 01:00:00', self::ag($analyzer->getSingleActivity('Medical evaluation'), 'activity_date_time'));
$this->assertEquals($actStatuses['Completed'], self::ag($analyzer->getSingleActivity('Medical evaluation'), 'status_id'));
$this->assertApproxTime('2013-11-30 02:00:00', self::ag($analyzer->getSingleActivity('Mental health evaluation'), 'activity_date_time'));
$this->assertEquals($actStatuses['Completed'], self::ag($analyzer->getSingleActivity('Mental health evaluation'), 'status_id'));
$this->assertApproxTime('2013-11-30 03:00:00', self::ag($analyzer->getSingleActivity('Secure temporary housing'), 'activity_date_time'));
$this->assertEquals($actStatuses['Completed'], self::ag($analyzer->getSingleActivity('Secure temporary housing'), 'status_id'));
$this->assertApproxTime('2013-11-30 04:00:00', self::ag($analyzer->getSingleActivity('Follow up'), 'activity_date_time'));
$this->assertEquals($actStatuses['Scheduled'], self::ag($analyzer->getSingleActivity('Follow up'), 'status_id'));
$this->assertEquals($caseStatuses['Open'], self::ag($analyzer->getCase(), 'status_id'));
// Complete the additional Activity; Case closed
\CRM_Utils_Time::setTime('2013-11-30 04:00:00');
$this->callApiSuccess('Activity', 'create', array('id' => self::ag($analyzer->getSingleActivity('Follow up'), 'id'), 'status_id' => $actStatuses['Completed']));
$analyzer->flush();
$this->assertApproxTime('2013-11-30 01:00:00', self::ag($analyzer->getSingleActivity('Medical evaluation'), 'activity_date_time'));
$this->assertEquals($actStatuses['Completed'], self::ag($analyzer->getSingleActivity('Medical evaluation'), 'status_id'));
$this->assertApproxTime('2013-11-30 02:00:00', self::ag($analyzer->getSingleActivity('Mental health evaluation'), 'activity_date_time'));
$this->assertEquals($actStatuses['Completed'], self::ag($analyzer->getSingleActivity('Mental health evaluation'), 'status_id'));
$this->assertApproxTime('2013-11-30 03:00:00', self::ag($analyzer->getSingleActivity('Secure temporary housing'), 'activity_date_time'));
$this->assertEquals($actStatuses['Completed'], self::ag($analyzer->getSingleActivity('Secure temporary housing'), 'status_id'));
$this->assertApproxTime('2013-11-30 04:00:00', self::ag($analyzer->getSingleActivity('Follow up'), 'activity_date_time'));
$this->assertEquals($actStatuses['Completed'], self::ag($analyzer->getSingleActivity('Follow up'), 'status_id'));
$this->assertEquals($caseStatuses['Closed'], self::ag($analyzer->getCase(), 'status_id'));
}
示例9: delayAction
/**
* Save an action into a queue for delayed processing
*
* @param \DateTime $delayTo
* @param \CRM_Civirules_Action $action
* @param \CRM_Civirules_TriggerData_TriggerData $triggerData
*/
protected static function delayAction(DateTime $delayTo, CRM_Civirules_Action $action, CRM_Civirules_TriggerData_TriggerData $triggerData)
{
$queue = CRM_Queue_Service::singleton()->create(array('type' => 'Civirules', 'name' => self::QUEUE_NAME, 'reset' => false));
//create a task with the action and eventData as parameters
$task = new CRM_Queue_Task(array('CRM_Civirules_Engine', 'executeDelayedAction'), array($action, $triggerData));
//save the task with a delay
$dao = new CRM_Queue_DAO_QueueItem();
$dao->queue_name = $queue->getName();
$dao->submit_time = CRM_Utils_Time::getTime('YmdHis');
$dao->data = serialize($task);
$dao->weight = 0;
//weight, normal priority
$dao->release_time = $delayTo->format('YmdHis');
$dao->save();
}
示例10: cividiscount_civicrm_postProcess
/**
* Implementation of hook_civicrm_postProcess()
*
* Record information about a discount use.
*/
function cividiscount_civicrm_postProcess($class, &$form)
{
if (!in_array($class, array('CRM_Contribute_Form_Contribution_Confirm', 'CRM_Event_Form_Participant', 'CRM_Event_Form_Registration_Confirm', 'CRM_Member_Form_Membership', 'CRM_Member_Form_MembershipRenewal', 'CRM_Event_Form_ParticipantFeeSelection'))) {
return;
}
$discountInfo = $form->get('_discountInfo');
if (!$discountInfo) {
return;
}
$ts = CRM_Utils_Time::getTime();
$discount = $discountInfo['discount'];
$params = $form->getVar('_params');
$description = CRM_Utils_Array::value('amount_level', $params);
// Online event registration.
// Note that CRM_Event_Form_Registration_Register is an intermediate form.
// CRM_Event_Form_Registration_Confirm completes the transaction.
if ($class == 'CRM_Event_Form_Registration_Confirm') {
$pids = $form->getVar('_participantIDS');
// if multiple participant discount is not enabled then only use primary participant info for discount
// and ignore additional participants
if (!_cividiscount_allow_multiple()) {
$pids = array($pids[0]);
}
foreach ($pids as $pid) {
$participant = _cividiscount_get_participant($pid);
$contact_id = $participant['contact_id'];
$participant_payment = _cividiscount_get_participant_payment($pid);
$contribution_id = $participant_payment['contribution_id'];
CRM_CiviDiscount_BAO_Item::incrementUsage($discount['id']);
$track = new CRM_CiviDiscount_DAO_Track();
$track->item_id = $discount['id'];
$track->contact_id = $contact_id;
$track->contribution_id = $contribution_id;
$track->entity_table = 'civicrm_participant';
$track->entity_id = $pid;
$track->used_date = $ts;
$track->description = $description;
$track->save();
}
// Online membership.
// Note that CRM_Contribute_Form_Contribution_Main is an intermediate
// form - CRM_Contribute_Form_Contribution_Confirm completes the
// transaction.
} else {
if ($class == 'CRM_Contribute_Form_Contribution_Confirm') {
$membership_type = $params['selectMembership'];
$membershipId = $params['membershipID'];
if (!is_array($membership_type)) {
$membership_type = array($membership_type);
}
$discount_membership_matches = array_intersect($membership_type, $discount['memberships']);
// check to make sure the discount actually applied to this membership.
if (empty($discount_membership_matches) || !$membershipId) {
return;
}
$description = CRM_Utils_Array::value('description', $params);
$membership = _cividiscount_get_membership($membershipId);
$contact_id = $membership['contact_id'];
$membership_payment = _cividiscount_get_membership_payment($membershipId);
$contribution_id = $membership_payment['contribution_id'];
CRM_CiviDiscount_BAO_Item::incrementUsage($discount['id']);
$track = new CRM_CiviDiscount_DAO_Track();
$track->item_id = $discount['id'];
$track->contact_id = $contact_id;
$track->contribution_id = $contribution_id;
$track->entity_table = 'civicrm_membership';
$track->entity_id = $membershipId;
$track->used_date = $ts;
$track->description = $description;
$track->save();
} else {
$contribution_id = NULL;
// Offline event registration.
if (in_array($class, array('CRM_Event_Form_Participant', 'CRM_Event_Form_ParticipantFeeSelection'))) {
if ($class == 'CRM_Event_Form_ParticipantFeeSelection') {
$entity_id = $form->getVar('_participantId');
} else {
$entity_id = $form->getVar('_id');
}
$participant_payment = _cividiscount_get_participant_payment($entity_id);
$contribution_id = $participant_payment['contribution_id'];
$entity_table = 'civicrm_participant';
$participant = _cividiscount_get_participant($entity_id);
$contact_id = $participant['contact_id'];
} elseif (in_array($class, array('CRM_Member_Form_Membership', 'CRM_Member_Form_MembershipRenewal'))) {
$membership_types = $form->getVar('_memTypeSelected');
$membership_type = isset($membership_types[0]) ? $membership_types[0] : NULL;
if (!$membership_type) {
$membership_type = $form->getVar('_memType');
}
// Check to make sure the discount actually applied to this membership.
if (!CRM_Utils_Array::value($membership_type, $discount['memberships'])) {
return;
}
$entity_table = 'civicrm_membership';
//.........这里部分代码省略.........
示例11: migrateSettings
/**
* Migrate any last remaining options from `civicrm_domain.config_backend` to `civicrm_setting`.
* Cleanup setting schema.
*
* @param CRM_Queue_TaskContext $ctx
* @return bool
*/
public static function migrateSettings(CRM_Queue_TaskContext $ctx)
{
// Tip: If there are problems with adding the new uniqueness index, try inspecting:
// SELECT name, domain_id, contact_id, count(*) AS dupes FROM civicrm_setting cs GROUP BY name, domain_id, contact_id HAVING dupes > 1;
// Nav records are expendable. https://forum.civicrm.org/index.php?topic=36933.0
CRM_Core_DAO::executeQuery('DELETE FROM civicrm_setting WHERE contact_id IS NOT NULL AND name = "navigation"');
CRM_Core_DAO::executeQuery('ALTER TABLE civicrm_setting DROP INDEX index_group_name');
CRM_Core_DAO::executeQuery('ALTER TABLE civicrm_setting DROP COLUMN group_name');
// Handle Strange activity_tab_filter settings.
CRM_Core_DAO::executeQuery('CREATE TABLE civicrm_activity_setting LIKE civicrm_setting');
CRM_Core_DAO::executeQuery('ALTER TABLE civicrm_activity_setting ADD UNIQUE INDEX index_domain_contact_name (domain_id, contact_id, name)');
CRM_Core_DAO::executeQuery('INSERT INTO civicrm_activity_setting (name, contact_id, domain_id, value)
SELECT DISTINCT name, contact_id, domain_id, value
FROM civicrm_setting
WHERE name = "activity_tab_filter"
AND value is not NULL');
CRM_Core_DAO::executeQuery('DELETE FROM civicrm_setting WHERE name = "activity_tab_filter"');
$date = CRM_Utils_Time::getTime('Y-m-d H:i:s');
CRM_Core_DAO::executeQuery('ALTER TABLE civicrm_setting ADD UNIQUE INDEX index_domain_contact_name (domain_id, contact_id, name)');
CRM_Core_DAO::executeQuery("INSERT INTO civicrm_setting (name, contact_id, domain_id, value, is_domain, created_id, created_date)\n SELECT name, contact_id, domain_id, value, 0, contact_id,'{$date}'\n FROM civicrm_activity_setting\n WHERE name = 'activity_tab_filter'\n AND value is not NULL");
CRM_Core_DAO::executeQuery('DROP TABLE civicrm_activity_setting');
$domainDao = CRM_Core_DAO::executeQuery('SELECT id, config_backend FROM civicrm_domain');
while ($domainDao->fetch()) {
$settings = CRM_Upgrade_Incremental_php_FourSeven::convertBackendToSettings($domainDao->id, $domainDao->config_backend);
CRM_Core_Error::debug_var('convertBackendToSettings', array('domainId' => $domainDao->id, 'backend' => $domainDao->config_backend, 'settings' => $settings));
foreach ($settings as $name => $value) {
$rowParams = array(1 => array($domainDao->id, 'Positive'), 2 => array($name, 'String'), 3 => array(serialize($value), 'String'));
$settingId = CRM_Core_DAO::singleValueQuery('SELECT id FROM civicrm_setting WHERE domain_id = %1 AND name = %2', $rowParams);
if (!$settingId) {
CRM_Core_DAO::executeQuery('INSERT INTO civicrm_setting (domain_id, name, value, is_domain) VALUES (%1,%2,%3,1)', $rowParams);
}
}
}
CRM_Core_DAO::executeQuery('ALTER TABLE civicrm_domain DROP COLUMN config_backend');
return TRUE;
}