本文整理汇总了PHP中CRM_Activity_BAO_ActivityContact类的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Activity_BAO_ActivityContact类的具体用法?PHP CRM_Activity_BAO_ActivityContact怎么用?PHP CRM_Activity_BAO_ActivityContact使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CRM_Activity_BAO_ActivityContact类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: create
/**
* Add activity assignment.
*
* @param array $params (reference ) an assoc array of name/value pairs
* @param array $ids (reference ) the array that holds all the db ids
*
* @return object activity type of object that is added
* @access public
*
*/
public static function create(&$params)
{
$assignment = new CRM_Activity_BAO_ActivityContact();
$activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name');
$assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts);
$assignment->copyValues($params);
$assignment->record_type_id = $assigneeID;
return $assignment->save();
}
示例2: triggerEvent
/**
* Trigger a rule for this event
*
* @param $op
* @param $objectName
* @param $objectId
* @param $objectRef
*/
public function triggerEvent($op, $objectName, $objectId, $objectRef)
{
$eventData = $this->getEventDataFromPost($op, $objectName, $objectId, $objectRef);
//trigger for activity event for every source_contact_id, target_contact_id and assignee_contact_id
$activityContact = new CRM_Activity_BAO_ActivityContact();
$activityContact->activity_id = $objectId;
$activityContact->find();
while ($activityContact->fetch()) {
$data = array();
CRM_Core_DAO::storeValues($activityContact, $data);
$eventData->setEntityData('ActivityContact', $data);
CRM_Civirules_Engine::triggerRule($this, clone $eventData);
}
}
示例3: init
/**
* the initializer code, called before the processing
*
* @return void
* @access public
*/
function init()
{
$activityContact = CRM_Activity_BAO_ActivityContact::import();
$activityTarget['target_contact_id'] = $activityContact['contact_id'];
$fields = array_merge(CRM_Activity_BAO_Activity::importableFields(), $activityTarget);
$fields = array_merge($fields, array('source_contact_id' => array('title' => ts('Source Contact'), 'headerPattern' => '/Source.Contact?/i'), 'activity_label' => array('title' => ts('Activity Type Label'), 'headerPattern' => '/(activity.)?type label?/i')));
foreach ($fields as $name => $field) {
$field['type'] = CRM_Utils_Array::value('type', $field, CRM_Utils_Type::T_INT);
$field['dataPattern'] = CRM_Utils_Array::value('dataPattern', $field, '//');
$field['headerPattern'] = CRM_Utils_Array::value('headerPattern', $field, '//');
$this->addField($name, $field['title'], $field['type'], $field['headerPattern'], $field['dataPattern']);
}
$this->_newActivity = array();
$this->setActiveFields($this->_mapperKeys);
// FIXME: we should do this in one place together with Form/MapField.php
$this->_contactIdIndex = -1;
$this->_activityTypeIndex = -1;
$this->_activityLabelIndex = -1;
$this->_activityDateIndex = -1;
$index = 0;
foreach ($this->_mapperKeys as $key) {
switch ($key) {
case 'target_contact_id':
case 'external_identifier':
$this->_contactIdIndex = $index;
break;
case 'activity_label':
$this->_activityLabelIndex = $index;
break;
case 'activity_type_id':
$this->_activityTypeIndex = $index;
break;
case 'activity_date_time':
$this->_activityDateIndex = $index;
break;
}
$index++;
}
}
示例4: buildQuickForm
/**
* Build the form object.
*
*
* @param CRM_Core_Form $form
*
* @return void
*/
public static function buildQuickForm(&$form)
{
$toArray = array();
$providers = CRM_SMS_BAO_Provider::getProviders(NULL, NULL, TRUE, 'is_default desc');
$providerSelect = array();
foreach ($providers as $provider) {
$providerSelect[$provider['id']] = $provider['title'];
}
$suppressedSms = 0;
//here we are getting logged in user id as array but we need target contact id. CRM-5988
$cid = $form->get('cid');
if ($cid) {
$form->_contactIds = array($cid);
}
$to = $form->add('text', 'to', ts('To'), array('class' => 'huge'), TRUE);
$form->add('text', 'activity_subject', ts('Name The SMS'), array('class' => 'huge'), TRUE);
$toSetDefault = TRUE;
if (property_exists($form, '_context') && $form->_context == 'standalone') {
$toSetDefault = FALSE;
}
// when form is submitted recompute contactIds
$allToSMS = array();
if ($to->getValue()) {
$allToPhone = explode(',', $to->getValue());
$form->_contactIds = array();
foreach ($allToPhone as $value) {
list($contactId, $phone) = explode('::', $value);
if ($contactId) {
$form->_contactIds[] = $contactId;
$form->_toContactPhone[] = $phone;
}
}
$toSetDefault = TRUE;
}
//get the group of contacts as per selected by user in case of Find Activities
if (!empty($form->_activityHolderIds)) {
$extendTargetContacts = 0;
$invalidActivity = 0;
$validActivities = 0;
foreach ($form->_activityHolderIds as $key => $id) {
//valid activity check
if (CRM_Core_DAO::getFieldValue('CRM_Activity_DAO_Activity', $id, 'subject', 'id') != self::RECIEVED_SMS_ACTIVITY_SUBJECT) {
$invalidActivity++;
continue;
}
$activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name');
$targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts);
//target contacts limit check
$ids = array_keys(CRM_Activity_BAO_ActivityContact::getNames($id, $targetID));
if (count($ids) > 1) {
$extendTargetContacts++;
continue;
}
$validActivities++;
$form->_contactIds = empty($form->_contactIds) ? $ids : array_unique(array_merge($form->_contactIds, $ids));
}
if (!$validActivities) {
$errorMess = "";
if ($extendTargetContacts) {
$errorMess = ts('One selected activity consists of more than one target contact.', array('count' => $extendTargetContacts, 'plural' => '%count selected activities consist of more than one target contact.'));
}
if ($invalidActivity) {
$errorMess = $errorMess ? ' ' : '';
$errorMess .= ts('The selected activity is invalid.', array('count' => $invalidActivity, 'plural' => '%count selected activities are invalid.'));
}
CRM_Core_Error::statusBounce(ts("%1: SMS Reply will not be sent.", array(1 => $errorMess)));
}
}
if (is_array($form->_contactIds) && !empty($form->_contactIds) && $toSetDefault) {
$returnProperties = array('sort_name' => 1, 'phone' => 1, 'do_not_sms' => 1, 'is_deceased' => 1, 'display_name' => 1);
list($form->_contactDetails) = CRM_Utils_Token::getTokenDetails($form->_contactIds, $returnProperties, FALSE, FALSE);
// make a copy of all contact details
$form->_allContactDetails = $form->_contactDetails;
foreach ($form->_contactIds as $key => $contactId) {
$value = $form->_contactDetails[$contactId];
//to check if the phone type is "Mobile"
$phoneTypes = CRM_Core_OptionGroup::values('phone_type', TRUE, FALSE, FALSE, NULL, 'name');
if (CRM_Utils_System::getClassName($form) == 'CRM_Activity_Form_Task_SMS') {
//to check for "if the contact id belongs to a specified activity type"
$actDetails = CRM_Activity_BAO_Activity::getContactActivity($contactId);
if (self::RECIEVED_SMS_ACTIVITY_SUBJECT != CRM_Utils_Array::retrieveValueRecursive($actDetails, 'subject')) {
$suppressedSms++;
unset($form->_contactDetails[$contactId]);
continue;
}
}
if (isset($value['phone_type_id']) && $value['phone_type_id'] != CRM_Utils_Array::value('Mobile', $phoneTypes) || $value['do_not_sms'] || empty($value['phone']) || !empty($value['is_deceased'])) {
//if phone is not primary check if non-primary phone is "Mobile"
if (!empty($value['phone']) && $value['phone_type_id'] != CRM_Utils_Array::value('Mobile', $phoneTypes) && empty($value['is_deceased'])) {
$filter = array('do_not_sms' => 0);
$contactPhones = CRM_Core_BAO_Phone::allPhones($contactId, FALSE, 'Mobile', $filter);
if (count($contactPhones) > 0) {
//.........这里部分代码省略.........
示例5: getCaseActivity
//.........这里部分代码省略.........
$statusTitle = ts('Edit status');
$emailActivityTypeIDs = array('Email' => CRM_Core_OptionGroup::getValue('activity_type', 'Email', 'name'), 'Inbound Email' => CRM_Core_OptionGroup::getValue('activity_type', 'Inbound Email', 'name'));
$emailActivityTypeIDs = array('Email' => CRM_Core_OptionGroup::getValue('activity_type', 'Email', 'name'), 'Inbound Email' => CRM_Core_OptionGroup::getValue('activity_type', 'Inbound Email', 'name'));
$caseDeleted = CRM_Core_DAO::getFieldValue('CRM_Case_DAO_Case', $caseID, 'is_deleted');
// define statuses which are handled like Completed status (others are assumed to be handled like Scheduled status)
$compStatusValues = array();
$compStatusNames = array('Completed', 'Left Message', 'Cancelled', 'Unreachable', 'Not Required');
foreach ($compStatusNames as $name) {
$compStatusValues[] = CRM_Core_OptionGroup::getValue('activity_status', $name, 'name');
}
$contactViewUrl = CRM_Utils_System::url("civicrm/contact/view", "reset=1&cid=", FALSE, NULL, FALSE);
$hasViewContact = CRM_Core_Permission::giveMeAllACLs();
$clientIds = self::retrieveContactIdsByCaseId($caseID);
if (!$userID) {
$session = CRM_Core_Session::singleton();
$userID = $session->get('userID');
}
while ($dao->fetch()) {
$allowView = self::checkPermission($dao->id, 'view', $dao->activity_type_id, $userID);
$allowEdit = self::checkPermission($dao->id, 'edit', $dao->activity_type_id, $userID);
$allowDelete = self::checkPermission($dao->id, 'delete', $dao->activity_type_id, $userID);
//do not have sufficient permission
//to access given case activity record.
if (!$allowView && !$allowEdit && !$allowDelete) {
continue;
}
$values[$dao->id]['id'] = $dao->id;
$values[$dao->id]['type'] = $activityTypes[$dao->type]['label'];
$reporterName = $dao->reporter;
if ($hasViewContact) {
$reporterName = '<a href="' . $contactViewUrl . $dao->reporter_id . '">' . $dao->reporter . '</a>';
}
$values[$dao->id]['reporter'] = $reporterName;
$targetNames = CRM_Activity_BAO_ActivityContact::getNames($dao->id, $targetID);
$targetContactUrls = $withContacts = array();
foreach ($targetNames as $targetId => $targetName) {
if (!in_array($targetId, $clientIds)) {
$withContacts[$targetId] = $targetName;
}
}
foreach ($withContacts as $cid => $name) {
if ($hasViewContact) {
$name = '<a href="' . $contactViewUrl . $cid . '">' . $name . '</a>';
}
$targetContactUrls[] = $name;
}
$values[$dao->id]['with_contacts'] = implode('; ', $targetContactUrls);
$values[$dao->id]['display_date'] = CRM_Utils_Date::customFormat($dao->display_date);
$values[$dao->id]['status'] = $activityStatus[$dao->status];
//check for view activity.
$subject = empty($dao->subject) ? '(' . ts('no subject') . ')' : $dao->subject;
if ($allowView) {
$url = CRM_Utils_System::url('civicrm/case/activity/view', array('cid' => $contactID, 'aid' => $dao->id));
$subject = '<a class="crm-popup medium-popup" href="' . $url . '" title="' . $viewTitle . '">' . $subject . '</a>';
}
$values[$dao->id]['subject'] = $subject;
// add activity assignee to activity selector. CRM-4485.
if (isset($dao->assignee)) {
if ($dao->ismultiple == 1) {
if ($dao->reporter_id != $dao->assignee_id) {
$values[$dao->id]['reporter'] .= $hasViewContact ? ' / ' . "<a href='{$contactViewUrl}{$dao->assignee_id}'>{$dao->assignee}</a>" : ' / ' . $dao->assignee;
}
$values[$dao->id]['assignee'] = $dao->assignee;
} else {
$values[$dao->id]['reporter'] .= ' / ' . ts('(multiple)');
}
示例6: getActivityContact
/**
* Get activity contact.
*
* @param int $activityId
* @param int $recordTypeID
* @param string $column
*
* @return null
*/
public static function getActivityContact($activityId, $recordTypeID = NULL, $column = 'contact_id')
{
$activityContact = new CRM_Activity_BAO_ActivityContact();
$activityContact->activity_id = $activityId;
if ($recordTypeID) {
$activityContact->record_type_id = $recordTypeID;
}
if ($activityContact->find(TRUE)) {
return $activityContact->{$column};
}
return NULL;
}
示例7: create
/**
* Takes an associative array and creates a friend object.
*
* @param array $params
* (reference ) an assoc array of name/value pairs.
*
* @return void
*/
public static function create(&$params)
{
$transaction = new CRM_Core_Transaction();
$mailParams = array();
//create contact corresponding to each friend
foreach ($params['friend'] as $key => $details) {
if ($details["first_name"]) {
$contactParams[$key] = array('first_name' => $details["first_name"], 'last_name' => $details["last_name"], 'contact_source' => ts('Tell a Friend') . ": {$params['title']}", 'email-Primary' => $details["email"]);
$displayName = $details["first_name"] . " " . $details["last_name"];
$mailParams['email'][$displayName] = $details["email"];
}
}
$frndParams = array();
$frndParams['entity_id'] = $params['entity_id'];
$frndParams['entity_table'] = $params['entity_table'];
self::getValues($frndParams);
$activityTypeId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionValue', 'Tell a Friend', 'value', 'name');
//create activity
$activityParams = array('source_contact_id' => $params['source_contact_id'], 'source_record_id' => NULL, 'activity_type_id' => $activityTypeId, 'title' => $params['title'], 'activity_date_time' => date("YmdHis"), 'subject' => ts('Tell a Friend') . ": {$params['title']}", 'details' => $params['suggested_message'], 'status_id' => 2, 'is_test' => $params['is_test'], 'campaign_id' => CRM_Utils_Array::value('campaign_id', $params));
//activity creation
$activity = CRM_Activity_BAO_Activity::create($activityParams);
$activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name');
$targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts);
//friend contacts creation
foreach ($contactParams as $key => $value) {
//create contact only if it does not exits in db
$value['email'] = $value['email-Primary'];
$value['check_permission'] = FALSE;
$contact = CRM_Core_BAO_UFGroup::findContact($value, NULL, 'Individual');
if (!$contact) {
$contact = self::add($value);
}
// attempt to save activity targets
$targetParams = array('activity_id' => $activity->id, 'contact_id' => $contact, 'record_type_id' => $targetID);
// See if it already exists
$activityContact = new CRM_Activity_DAO_ActivityContact();
$activityContact->activity_id = $activity->id;
$activityContact->contact_id = $contact;
$activityContact->find(TRUE);
if (empty($activityContact->id)) {
$resultTarget = CRM_Activity_BAO_ActivityContact::create($targetParams);
}
}
$transaction->commit();
//process sending of mails
$mailParams['title'] = CRM_Utils_Array::value('title', $params);
$mailParams['general_link'] = CRM_Utils_Array::value('general_link', $frndParams);
$mailParams['message'] = CRM_Utils_Array::value('suggested_message', $params);
// get domain
$domainDetails = CRM_Core_BAO_Domain::getNameAndEmail();
list($username, $mailParams['domain']) = explode('@', $domainDetails[1]);
$default = array();
$findProperties = array('id' => $params['entity_id']);
if ($params['entity_table'] == 'civicrm_contribution_page') {
$returnProperties = array('receipt_from_email', 'is_email_receipt');
CRM_Core_DAO::commonRetrieve('CRM_Contribute_DAO_ContributionPage', $findProperties, $default, $returnProperties);
//if is_email_receipt is set then take receipt_from_email
//as from_email
if (!empty($default['is_email_receipt']) && !empty($default['receipt_from_email'])) {
$mailParams['email_from'] = $default['receipt_from_email'];
}
$urlPath = 'civicrm/contribute/transact';
$mailParams['module'] = 'contribute';
} elseif ($params['entity_table'] == 'civicrm_event') {
$returnProperties = array('confirm_from_email', 'is_email_confirm');
CRM_Core_DAO::commonRetrieve('CRM_Event_DAO_Event', $findProperties, $default, $returnProperties);
$mailParams['email_from'] = $domainDetails['1'];
//if is_email_confirm is set then take confirm_from_email
//as from_email
if (!empty($default['is_email_confirm']) && !empty($default['confirm_from_email'])) {
$mailParams['email_from'] = $default['confirm_from_email'];
}
$urlPath = 'civicrm/event/info';
$mailParams['module'] = 'event';
} elseif ($params['entity_table'] == 'civicrm_pcp') {
$mailParams['email_from'] = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Email', $params['source_contact_id'], 'email', 'contact_id');
$urlPath = 'civicrm/pcp/info';
$mailParams['module'] = 'contribute';
}
$mailParams['page_url'] = CRM_Utils_System::url($urlPath, "reset=1&id={$params['entity_id']}", TRUE, NULL, FALSE, TRUE);
//send mail
self::sendMail($params['source_contact_id'], $mailParams);
}
示例8: processActivity
/**
* Process activity creation.
*
* @param array $params
* Associated array of submitted values.
*
* @return self|null|object
*/
protected function processActivity(&$params)
{
$activityAssigned = array();
$activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name');
$assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts);
// format assignee params
if (!CRM_Utils_Array::crmIsEmptyArray($params['assignee_contact_id'])) {
//skip those assignee contacts which are already assigned
//while sending a copy.CRM-4509.
$activityAssigned = array_flip($params['assignee_contact_id']);
if ($this->_activityId) {
$assigneeContacts = CRM_Activity_BAO_ActivityContact::getNames($this->_activityId, $assigneeID);
$activityAssigned = array_diff_key($activityAssigned, $assigneeContacts);
}
}
// call begin post process. Idea is to let injecting file do
// any processing before the activity is added/updated.
$this->beginPostProcess($params);
$activity = CRM_Activity_BAO_Activity::create($params);
// add tags if exists
$tagParams = array();
if (!empty($params['tag'])) {
foreach ($params['tag'] as $tag) {
$tagParams[$tag] = 1;
}
}
// Save static tags.
CRM_Core_BAO_EntityTag::create($tagParams, 'civicrm_activity', $activity->id);
// Save free tags.
if (isset($params['activity_taglist']) && !empty($params['activity_taglist'])) {
CRM_Core_Form_Tag::postProcess($params['activity_taglist'], $activity->id, 'civicrm_activity', $this);
}
// call end post process. Idea is to let injecting file do any
// processing needed, after the activity has been added/updated.
$this->endPostProcess($params, $activity);
// CRM-9590
if (!empty($params['is_multi_activity'])) {
$this->_activityIds[] = $activity->id;
} else {
$this->_activityId = $activity->id;
}
// create follow up activity if needed
$followupStatus = '';
$followupActivity = NULL;
if (!empty($params['followup_activity_type_id'])) {
$followupActivity = CRM_Activity_BAO_Activity::createFollowupActivity($activity->id, $params);
$followupStatus = ts('A followup activity has been scheduled.');
}
// send copy to assignee contacts.CRM-4509
$mailStatus = '';
if (Civi::settings()->get('activity_assignee_notification')) {
$activityIDs = array($activity->id);
if ($followupActivity) {
$activityIDs = array_merge($activityIDs, array($followupActivity->id));
}
$assigneeContacts = CRM_Activity_BAO_ActivityAssignment::getAssigneeNames($activityIDs, TRUE, FALSE);
if (!CRM_Utils_Array::crmIsEmptyArray($params['assignee_contact_id'])) {
$mailToContacts = array();
// Build an associative array with unique email addresses.
foreach ($activityAssigned as $id => $dnc) {
if (isset($id) && array_key_exists($id, $assigneeContacts)) {
$mailToContacts[$assigneeContacts[$id]['email']] = $assigneeContacts[$id];
}
}
$sent = CRM_Activity_BAO_Activity::sendToAssignee($activity, $mailToContacts);
if ($sent) {
$mailStatus .= ts("A copy of the activity has also been sent to assignee contacts(s).");
}
}
// Also send email to follow-up activity assignees if set
if ($followupActivity) {
$mailToFollowupContacts = array();
foreach ($assigneeContacts as $values) {
if ($values['activity_id'] == $followupActivity->id) {
$mailToFollowupContacts[$values['email']] = $values;
}
}
$sentFollowup = CRM_Activity_BAO_Activity::sendToAssignee($followupActivity, $mailToFollowupContacts);
if ($sentFollowup) {
$mailStatus .= '<br />' . ts("A copy of the follow-up activity has also been sent to follow-up assignee contacts(s).");
}
}
}
// set status message
$subject = '';
if (!empty($params['subject'])) {
$subject = "'" . $params['subject'] . "'";
}
CRM_Core_Session::setStatus(ts('Activity %1 has been saved. %2 %3', array(1 => $subject, 2 => $followupStatus, 3 => $mailStatus)), ts('Saved'), 'success');
return $activity;
}
示例9: executeCancellation
//.........这里部分代码省略.........
$query['cancel_date'] = date('Ymdhis', strtotime($btx->value_date));
$query = array_merge($query, $this->getPropagationSet($btx, $match, 'contribution', $config->cancellation_value_propagation));
// add propagated values
if (empty($query['cancel_reason'])) {
// add default values
$query['cancel_reason'] = $config->cancellation_default_reason;
}
if ($config->cancellation_cancel_reason) {
$query['cancel_reason'] = $match->getParameter('cancel_reason');
}
$result = civicrm_api('Contribution', 'create', $query);
if (isset($result['is_error']) && $result['is_error']) {
error_log("org.project60.sepa: matcher_sepa: Couldn't modify contribution, error was: " . $result['error_message']);
CRM_Core_Session::setStatus(ts("Couldn't modify contribution."), ts('Error'), 'error');
} else {
// now for the mandate...
$contribution = civicrm_api('Contribution', 'getsingle', array('version' => 3, 'id' => $contribution_id));
if (!empty($contribution['is_error'])) {
error_log("org.project60.sepa: matcher_sepa: Couldn't load contribution, error was: " . $result['error_message']);
CRM_Core_Session::setStatus(ts("Couldn't modify contribution."), ts('Error'), 'error');
} else {
if ('OOFF' == $contribution['contribution_payment_instrument'] && !empty($config->cancellation_update_mandate_status_OOFF)) {
// everything seems fine, adjust the mandate's status
$query = array('version' => 3, 'id' => $mandate_id);
$query['status'] = $config->cancellation_update_mandate_status_OOFF;
$query = array_merge($query, $this->getPropagationSet($btx, $match, 'mandate'));
// add propagated values
$result = civicrm_api('SepaMandate', 'create', $query);
if (!empty($result['is_error'])) {
error_log("org.project60.sepa: matcher_sepa: Couldn't modify mandate, error was: " . $result['error_message']);
CRM_Core_Session::setStatus(ts("Couldn't modify mandate."), ts('Error'), 'error');
}
} elseif ('RCUR' == $contribution['contribution_payment_instrument'] && !empty($config->cancellation_update_mandate_status_RCUR)) {
// everything seems fine, adjust the mandate's status
$query = array('version' => 3, 'id' => $mandate_id);
$query['status'] = $config->cancellation_update_mandate_status_RCUR;
$query = array_merge($query, $this->getPropagationSet($btx, $match, 'mandate'));
// add propagated values
$result = civicrm_api('SepaMandate', 'create', $query);
if (!empty($result['is_error'])) {
error_log("org.project60.sepa: matcher_sepa: Couldn't modify mandate, error was: " . $result['error_message']);
CRM_Core_Session::setStatus(ts("Couldn't modify mandate."), ts('Error'), 'error');
}
}
}
}
// create activity if wanted
if ($config->cancellation_create_activity) {
// gather some information to put in the text
$smarty_vars = array();
$smarty_vars['contribution'] = $contribution;
$smarty_vars['cancel_fee'] = $match->getParameter('cancel_fee');
$smarty_vars['cancel_reason'] = $match->getParameter('cancel_reason');
// load the mandate
$mandate = civicrm_api('SepaMandate', 'getsingle', array('id' => $mandate_id, 'version' => 3));
$smarty_vars['mandate'] = $mandate;
// load the contact
$contact = civicrm_api('Contact', 'getsingle', array('id' => $contribution['contact_id'], 'version' => 3));
$smarty_vars['contact'] = $contact;
// count the cancelled contributions connected to this mandate
$cancelled_contribution_count = 0;
$current_contribution_date = date('Ymdhis', strtotime($contribution['receive_date']));
if ($mandate['type'] == 'RCUR') {
$query = "SELECT contribution_status_id\n FROM civicrm_contribution\n WHERE contribution_recur_id = {$mandate['entity_id']}\n AND receive_date <= '{$current_contribution_date}'\n ORDER BY receive_date DESC;";
$status_list = CRM_Core_DAO::executeQuery($query);
while ($status_list->fetch()) {
if ($status_list->contribution_status_id == $status_cancelled) {
$cancelled_contribution_count += 1;
} else {
break;
}
}
}
$smarty_vars['cancelled_contribution_count'] = $cancelled_contribution_count;
// look up contact if not set
$user_id = CRM_Core_Session::singleton()->get('userID');
if (empty($config->cancellation_create_activity_assignee_id)) {
$assignedTo = $user_id;
} else {
$assignedTo = (int) $config->cancellation_create_activity_assignee_id;
}
// compile the text
$smarty = CRM_Banking_Helpers_Smarty::singleton();
$smarty->pushScope($smarty_vars);
if (empty($config->cancellation_create_activity_text)) {
$details = $smarty->fetch('CRM/Banking/PluginImpl/Matcher/SepaMandate.activity.tpl');
} else {
$details = $smarty->fetch("string:" . $config->cancellation_create_activity_text);
}
$smarty->popScope();
$activity_parameters = array('version' => 3, 'activity_type_id' => $config->cancellation_create_activity_type_id, 'subject' => $config->cancellation_create_activity_subject, 'status_id' => 1, 'activity_date_time' => date('YmdHis'), 'source_contact_id' => $user_id, 'target_contact_id' => $contact['id'], 'details' => $details);
$activity = CRM_Activity_BAO_Activity::create($activity_parameters);
$assignment_parameters = array('activity_id' => $activity->id, 'contact_id' => $assignedTo, 'record_type_id' => 1);
$assignment = CRM_Activity_BAO_ActivityContact::create($assignment_parameters);
}
$newStatus = banking_helper_optionvalueid_by_groupname_and_name('civicrm_banking.bank_tx_status', 'Processed');
$btx->setStatus($newStatus);
parent::execute($match, $btx);
return true;
}
示例10: _convertToCaseActivity
/**
* @param array $params
*
* @return array
*/
public static function _convertToCaseActivity($params)
{
if (!$params['activityID'] || !$params['caseID']) {
return array('error_msg' => 'required params missing.');
}
$otherActivity = new CRM_Activity_DAO_Activity();
$otherActivity->id = $params['activityID'];
if (!$otherActivity->find(TRUE)) {
return array('error_msg' => 'activity record is missing.');
}
$actDateTime = CRM_Utils_Date::isoToMysql($otherActivity->activity_date_time);
// Create new activity record.
$mainActivity = new CRM_Activity_DAO_Activity();
$mainActVals = array();
CRM_Core_DAO::storeValues($otherActivity, $mainActVals);
// Get new activity subject.
if (!empty($params['newSubject'])) {
$mainActVals['subject'] = $params['newSubject'];
}
$mainActivity->copyValues($mainActVals);
$mainActivity->id = NULL;
$mainActivity->activity_date_time = $actDateTime;
// Make sure this is current revision.
$mainActivity->is_current_revision = TRUE;
// Drop all relations.
$mainActivity->parent_id = $mainActivity->original_id = NULL;
$mainActivity->save();
$mainActivityId = $mainActivity->id;
CRM_Activity_BAO_Activity::logActivityAction($mainActivity);
$mainActivity->free();
// Mark previous activity as deleted. If it was a non-case activity
// then just change the subject.
if (in_array($params['mode'], array('move', 'file'))) {
$caseActivity = new CRM_Case_DAO_CaseActivity();
$caseActivity->case_id = $params['caseID'];
$caseActivity->activity_id = $otherActivity->id;
if ($params['mode'] == 'move' || $caseActivity->find(TRUE)) {
$otherActivity->is_deleted = 1;
} else {
$otherActivity->subject = ts('(Filed on case %1)', array(1 => $params['caseID'])) . ' ' . $otherActivity->subject;
}
$otherActivity->activity_date_time = $actDateTime;
$otherActivity->save();
$caseActivity->free();
}
$otherActivity->free();
$targetContacts = array();
if (!empty($params['targetContactIds'])) {
$targetContacts = array_unique(explode(',', $params['targetContactIds']));
}
$activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name');
$sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts);
$assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts);
$targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts);
$sourceContactID = CRM_Activity_BAO_Activity::getSourceContactID($params['activityID']);
$src_params = array('activity_id' => $mainActivityId, 'contact_id' => $sourceContactID, 'record_type_id' => $sourceID);
CRM_Activity_BAO_ActivityContact::create($src_params);
foreach ($targetContacts as $key => $value) {
$targ_params = array('activity_id' => $mainActivityId, 'contact_id' => $value, 'record_type_id' => $targetID);
CRM_Activity_BAO_ActivityContact::create($targ_params);
}
// typically this will be empty, since assignees on another case may be completely different
$assigneeContacts = array();
if (!empty($params['assigneeContactIds'])) {
$assigneeContacts = array_unique(explode(',', $params['assigneeContactIds']));
}
foreach ($assigneeContacts as $key => $value) {
$assigneeParams = array('activity_id' => $mainActivityId, 'contact_id' => $value, 'record_type_id' => $assigneeID);
CRM_Activity_BAO_ActivityContact::create($assigneeParams);
}
// Attach newly created activity to case.
$caseActivity = new CRM_Case_DAO_CaseActivity();
$caseActivity->case_id = $params['caseID'];
$caseActivity->activity_id = $mainActivityId;
$caseActivity->save();
$error_msg = $caseActivity->_lastError;
$caseActivity->free();
$params['mainActivityId'] = $mainActivityId;
CRM_Activity_BAO_Activity::copyExtendedActivityData($params);
return array('error_msg' => $error_msg, 'newId' => $mainActivity->id);
}
示例11: postProcess
/**
* Process the form after the input has been submitted and validated.
*/
public function postProcess()
{
// Clear any formRule errors from Email form in case they came back here via Cancel button
$this->controller->resetPage('Email');
$params = $this->exportValues();
$this->_contacts = array();
$activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name');
$assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts);
$targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts);
// Get assignee contacts.
if (!empty($params['assigned_to'])) {
foreach ($this->_activityHolderIds as $key => $id) {
$ids = array_keys(CRM_Activity_BAO_ActivityContact::getNames($id, $assigneeID));
$this->_contacts = array_merge($this->_contacts, $ids);
}
}
// Get target contacts.
if (!empty($params['with_contact'])) {
foreach ($this->_activityHolderIds as $key => $id) {
$ids = array_keys(CRM_Activity_BAO_ActivityContact::getNames($id, $targetID));
$this->_contacts = array_merge($this->_contacts, $ids);
}
}
// Get 'Added by' contacts.
if (!empty($params['created_by'])) {
parent::setContactIDs();
if (!empty($this->_contactIds)) {
$this->_contacts = array_merge($this->_contacts, $this->_contactIds);
}
}
$this->_contacts = array_unique($this->_contacts);
// Bounce to pick option if no contacts to send to.
if (empty($this->_contacts)) {
$urlParams = "_qf_PickOption_display=true&qfKey={$params['qfKey']}";
$urlRedirect = CRM_Utils_System::url('civicrm/activity/search', $urlParams);
CRM_Core_Error::statusBounce(ts('It appears you have no contacts with email addresses from the selected recipients.'), $urlRedirect);
}
$this->set('contacts', $this->_contacts);
}
示例12: createActivities
/**
* @param CRM_Core_Form $form
* @param $html_message
* @param $contactIds
*
* @throws CRM_Core_Exception
*/
public static function createActivities($form, $html_message, $contactIds)
{
//Added for CRM-12682: Add activity subject and campaign fields
$formValues = $form->controller->exportValues($form->getName());
$session = CRM_Core_Session::singleton();
$userID = $session->get('userID');
$activityTypeID = CRM_Core_OptionGroup::getValue('activity_type', 'Print PDF Letter', 'name');
$activityParams = array('subject' => $formValues['subject'], 'campaign_id' => CRM_Utils_Array::value('campaign_id', $formValues), 'source_contact_id' => $userID, 'activity_type_id' => $activityTypeID, 'activity_date_time' => date('YmdHis'), 'details' => $html_message);
if (!empty($form->_activityId)) {
$activityParams += array('id' => $form->_activityId);
}
if ($form->_cid) {
$activity = CRM_Activity_BAO_Activity::create($activityParams);
if (!empty($form->_caseId)) {
$caseActivityParams = array('activity_id' => $activity->id, 'case_id' => $form->_caseId);
CRM_Case_BAO_Case::processCaseActivity($caseActivityParams);
}
} else {
// create Print PDF activity for each selected contact. CRM-6886
$activityIds = array();
foreach ($contactIds as $contactId) {
$activityID = CRM_Activity_BAO_Activity::create($activityParams);
$activityIds[$contactId] = $activityID->id;
}
}
$activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name');
$targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts);
//@todo why are we using $form->_contactIds here & contactIds above - need comment
foreach ($form->_contactIds as $contactId) {
$activityTargetParams = array('activity_id' => empty($activity->id) ? $activityIds[$contactId] : $activity->id, 'contact_id' => $contactId, 'record_type_id' => $targetID);
CRM_Activity_BAO_ActivityContact::create($activityTargetParams);
}
}
示例13: recentApplicationActivities
static function recentApplicationActivities($limit = 10)
{
$recentActivities = array();
$customTableName = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup', 'application_case', 'table_name', 'name');
//Retrieve top $limit(as total activity count) recent activities
$query = CRM_Case_BAO_Case::getCaseActivityQuery($type = 'any', NULL, $condition = "AND c_type.name = 'Application' AND t_act.desired_date <= CURRENT_TIMESTAMP ");
$query .= "LIMIT 0, {$limit}";
$query = str_replace('ORDER BY case_activity_date ASC', 'ORDER BY case_activity_date DESC', $query);
$dao = CRM_Core_DAO::executeQuery($query);
while ($dao->fetch()) {
$query = "SELECT vacancy_id FROM {$customTableName} WHERE entity_id = {$dao->case_id}";
$ctDAO = CRM_Core_DAO::executeQuery($query);
$ctDAO->fetch();
$vacancyDAO = new self();
$vacancyDAO->id = $ctDAO->vacancy_id;
$vacancyDAO->find(TRUE);
//Applicant contact link
$applicant = "<a href='" . CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$dao->contact_id}") . "'>{$dao->sort_name}</a>";
//Position link
$position = "<a href='" . CRM_Utils_System::url('civicrm/case/pipeline', "reset=1&vid={$vacancyDAO->id}") . "'>{$vacancyDAO->position}</a>";
//Case Activity Source link
$sourceID = civicrm_api3('OptionValue', 'getvalue', array('option_group_id' => 'activity_contacts', 'name' => 'Activity Source', 'return' => 'value'));
$sourceContact = CRM_Activity_BAO_ActivityContact::getNames($dao->case_activity_id, $sourceID);
$sourceContactID = key($sourceContact);
$source = "<a href='" . CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$sourceContactID}") . "'>{$sourceContact[$sourceContactID]}</a>";
switch ($dao->case_activity_type_name) {
case 'Open Case':
$recentActivities[] = array('activity' => "{$applicant} applied for {$position}", 'time' => $dao->case_activity_date);
break;
case 'Comment':
$recentActivities[] = array('activity' => "{$source} commented on {$position}", 'time' => $dao->case_activity_date);
break;
case 'Phone Call':
case 'Meeting':
case 'Follow up':
$recentActivities[] = array('activity' => "{$source} had a {$dao->case_activity_type_name} with {$applicant} (vis-a-vis {$position})", 'time' => $dao->case_activity_date);
break;
case 'Email':
$recentActivities[] = array('activity' => "{$source} sent email to {$applicant}", 'time' => $dao->case_activity_date);
break;
case 'Change Case Status':
$subject = CRM_Core_DAO::getFieldValue('CRM_Activity_DAO_Activity', $dao->case_activity_id, 'subject');
$subject = str_replace('Assignment status changed', '', $subject);
$recentActivities[] = array('activity' => "{$source} changed the status of {$position} {$subject}", 'time' => $dao->case_activity_date);
break;
case 'Evaluation':
$subject = CRM_Core_DAO::getFieldValue('CRM_Activity_DAO_Activity', $dao->case_activity_id, 'subject');
$recentActivities[] = array('activity' => "{$source} evaluated {$applicant} for {$position}", 'time' => $dao->case_activity_date);
break;
default:
$subject = CRM_Core_DAO::getFieldValue('CRM_Activity_DAO_Activity', $dao->case_activity_id, 'subject');
$recentActivities[] = array('activity' => "{$position}: {$dao->case_activity_type_name} for {$applicant}", 'time' => $dao->case_activity_date);
break;
}
}
return $recentActivities;
}
示例14: processActivity
/**
* Process activity creation
*
* @param array $params associated array of submitted values
* @access protected
*/
protected function processActivity(&$params)
{
$activityAssigned = array();
$activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name');
$assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts);
// format assignee params
if (!CRM_Utils_Array::crmIsEmptyArray($params['assignee_contact_id'])) {
//skip those assignee contacts which are already assigned
//while sending a copy.CRM-4509.
$activityAssigned = array_flip($params['assignee_contact_id']);
if ($this->_activityId) {
$assigneeContacts = CRM_Activity_BAO_ActivityContact::getNames($this->_activityId, $assigneeID);
$activityAssigned = array_diff_key($activityAssigned, $assigneeContacts);
}
}
// call begin post process. Idea is to let injecting file do
// any processing before the activity is added/updated.
$this->beginPostProcess($params);
$activity = CRM_Activity_BAO_Activity::create($params);
// add tags if exists
$tagParams = array();
if (!empty($params['tag'])) {
foreach ($params['tag'] as $tag) {
$tagParams[$tag] = 1;
}
}
//save static tags
CRM_Core_BAO_EntityTag::create($tagParams, 'civicrm_activity', $activity->id);
//save free tags
if (isset($params['activity_taglist']) && !empty($params['activity_taglist'])) {
CRM_Core_Form_Tag::postProcess($params['activity_taglist'], $activity->id, 'civicrm_activity', $this);
}
// call end post process. Idea is to let injecting file do any
// processing needed, after the activity has been added/updated.
$this->endPostProcess($params, $activity);
// CRM-9590
if (CRM_Utils_Array::value('is_multi_activity', $params)) {
$this->_activityIds[] = $activity->id;
} else {
$this->_activityId = $activity->id;
}
// create follow up activity if needed
$followupStatus = '';
if (CRM_Utils_Array::value('followup_activity_type_id', $params)) {
CRM_Activity_BAO_Activity::createFollowupActivity($activity->id, $params);
$followupStatus = ts('A followup activity has been scheduled.');
}
// send copy to assignee contacts.CRM-4509
$mailStatus = '';
if (!CRM_Utils_Array::crmIsEmptyArray($params['assignee_contact_id']) && CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'activity_assignee_notification')) {
$mailToContacts = array();
$assigneeContacts = CRM_Activity_BAO_ActivityAssignment::getAssigneeNames($activity->id, TRUE, FALSE);
//build an associative array with unique email addresses.
foreach ($activityAssigned as $id => $dnc) {
if (isset($id) && array_key_exists($id, $assigneeContacts)) {
$mailToContacts[$assigneeContacts[$id]['email']] = $assigneeContacts[$id];
}
}
if (!CRM_Utils_array::crmIsEmptyArray($mailToContacts)) {
//include attachments while sending a copy of activity.
$attachments = CRM_Core_BAO_File::getEntityFile('civicrm_activity', $activity->id);
$ics = new CRM_Activity_BAO_ICalendar($activity);
$ics->addAttachment($attachments, $mailToContacts);
// CRM-8400 add param with _currentlyViewedContactId for URL link in mail
CRM_Case_BAO_Case::sendActivityCopy(NULL, $activity->id, $mailToContacts, $attachments, NULL);
$ics->cleanup();
$mailStatus .= ts("A copy of the activity has also been sent to assignee contacts(s).");
}
}
// set status message
$subject = '';
if (CRM_Utils_Array::value('subject', $params)) {
$subject = "'" . $params['subject'] . "'";
}
CRM_Core_Session::setStatus(ts('Activity %1 has been saved. %2 %3', array(1 => $subject, 2 => $followupStatus, 3 => $mailStatus)), ts('Saved'), 'success');
return $activity;
}
示例15: array
/**
* Returns all the rows in the given offset and rowCount.
*
* @param string $action
* The action being performed.
* @param int $offset
* The row number to start from.
* @param int $rowCount
* The number of rows to return.
* @param string $sort
* The sql string that describes the sort order.
* @param string $output
* What should the result set include (web/email/csv).
*
* @return array
* rows in the given offset and rowCount
*/
public function &getRows($action, $offset, $rowCount, $sort, $output = NULL)
{
$result = $this->_query->searchQuery($offset, $rowCount, $sort, FALSE, FALSE, FALSE, FALSE, FALSE, $this->_activityClause);
$rows = array();
$mailingIDs = CRM_Mailing_BAO_Mailing::mailingACLIDs();
$accessCiviMail = CRM_Core_Permission::check('access CiviMail');
//get all campaigns.
$allCampaigns = CRM_Campaign_BAO_Campaign::getCampaigns(NULL, NULL, FALSE, FALSE, FALSE, TRUE);
$engagementLevels = CRM_Campaign_PseudoConstant::engagementLevel();
$activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name');
$sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts);
$assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts);
$targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts);
//get all activity types
$activityTypes = CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'name', TRUE);
while ($result->fetch()) {
$row = array();
// ignore rows where we dont have an activity id
if (empty($result->activity_id)) {
continue;
}
// the columns we are interested in
foreach (self::$_properties as $property) {
if (isset($result->{$property})) {
$row[$property] = $result->{$property};
}
}
$contactId = CRM_Utils_Array::value('contact_id', $row);
if (!$contactId) {
$contactId = CRM_Utils_Array::value('source_contact_id', $row);
}
$row['target_contact_name'] = CRM_Activity_BAO_ActivityContact::getNames($row['activity_id'], $targetID);
$row['assignee_contact_name'] = CRM_Activity_BAO_ActivityContact::getNames($row['activity_id'], $assigneeID);
list($row['source_contact_name'], $row['source_contact_id']) = CRM_Activity_BAO_ActivityContact::getNames($row['activity_id'], $sourceID, TRUE);
$row['source_contact_name'] = implode(',', array_values($row['source_contact_name']));
$row['source_contact_id'] = implode(',', $row['source_contact_id']);
if ($this->_context == 'search') {
$row['checkbox'] = CRM_Core_Form::CB_PREFIX . $result->activity_id;
}
$row['contact_type'] = CRM_Contact_BAO_Contact_Utils::getImage($result->contact_sub_type ? $result->contact_sub_type : $result->contact_type, FALSE, $result->contact_id);
$accessMailingReport = FALSE;
$activityTypeId = $row['activity_type_id'];
if ($row['activity_is_test']) {
$row['activity_type'] = $row['activity_type'] . " (test)";
}
$bulkActivityTypeID = CRM_Utils_Array::key('Bulk Email', $activityTypes);
$row['mailingId'] = '';
if ($accessCiviMail && ($mailingIDs === TRUE || in_array($result->source_record_id, $mailingIDs)) && $bulkActivityTypeID == $activityTypeId) {
$row['mailingId'] = CRM_Utils_System::url('civicrm/mailing/report', "mid={$result->source_record_id}&reset=1&cid={$contactId}&context=activitySelector");
$row['recipients'] = ts('(recipients)');
$row['target_contact_name'] = '';
$row['assignee_contact_name'] = '';
$accessMailingReport = TRUE;
}
$activityActions = new CRM_Activity_Selector_Activity($result->contact_id, NULL);
$actionLinks = $activityActions->actionLinks($activityTypeId, CRM_Utils_Array::value('source_record_id', $row), $accessMailingReport, CRM_Utils_Array::value('activity_id', $row), $this->_key, $this->_compContext);
$row['action'] = CRM_Core_Action::formLink($actionLinks, NULL, array('id' => $result->activity_id, 'cid' => $contactId, 'cxt' => $this->_context), ts('more'), FALSE, 'activity.selector.row', 'Activity', $result->activity_id);
//carry campaign to selector.
$row['campaign'] = CRM_Utils_Array::value($result->activity_campaign_id, $allCampaigns);
$row['campaign_id'] = $result->activity_campaign_id;
if ($engagementLevel = CRM_Utils_Array::value('activity_engagement_level', $row)) {
$row['activity_engagement_level'] = CRM_Utils_Array::value($engagementLevel, $engagementLevels, $engagementLevel);
}
//Check if recurring activity
$repeat = CRM_Core_BAO_RecurringEntity::getPositionAndCount($row['activity_id'], 'civicrm_activity');
$row['repeat'] = '';
if ($repeat) {
$row['repeat'] = ts('Repeating (%1 of %2)', array(1 => $repeat[0], 2 => $repeat[1]));
}
$rows[] = $row;
}
return $rows;
}