当前位置: 首页>>代码示例>>PHP>>正文


PHP CRM_Activity_BAO_ActivityContact::create方法代码示例

本文整理汇总了PHP中CRM_Activity_BAO_ActivityContact::create方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Activity_BAO_ActivityContact::create方法的具体用法?PHP CRM_Activity_BAO_ActivityContact::create怎么用?PHP CRM_Activity_BAO_ActivityContact::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CRM_Activity_BAO_ActivityContact的用法示例。


在下文中一共展示了CRM_Activity_BAO_ActivityContact::create方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: sendMessage

 /**
  * Send the message to a specific contact.
  *
  * @param string $from
  *   The name and email of the sender.
  * @param int $fromID
  * @param int $toID
  *   The contact id of the recipient.
  * @param string $subject
  *   The subject of the message.
  * @param $text_message
  * @param $html_message
  * @param string $emailAddress
  *   Use this 'to' email address instead of the default Primary address.
  * @param int $activityID
  *   The activity ID that tracks the message.
  * @param null $attachments
  * @param null $cc
  * @param null $bcc
  *
  * @return bool
  *   TRUE if successful else FALSE.
  */
 public static function sendMessage($from, $fromID, $toID, &$subject, &$text_message, &$html_message, $emailAddress, $activityID, $attachments = NULL, $cc = NULL, $bcc = NULL)
 {
     list($toDisplayName, $toEmail, $toDoNotEmail) = CRM_Contact_BAO_Contact::getContactDetails($toID);
     if ($emailAddress) {
         $toEmail = trim($emailAddress);
     }
     // make sure both email addresses are valid
     // and that the recipient wants to receive email
     if (empty($toEmail) or $toDoNotEmail) {
         return FALSE;
     }
     if (!trim($toDisplayName)) {
         $toDisplayName = $toEmail;
     }
     $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name');
     $targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts);
     // create the params array
     $mailParams = array('groupName' => 'Activity Email Sender', 'from' => $from, 'toName' => $toDisplayName, 'toEmail' => $toEmail, 'subject' => $subject, 'cc' => $cc, 'bcc' => $bcc, 'text' => $text_message, 'html' => $html_message, 'attachments' => $attachments);
     if (!CRM_Utils_Mail::send($mailParams)) {
         return FALSE;
     }
     // add activity target record for every mail that is send
     $activityTargetParams = array('activity_id' => $activityID, 'contact_id' => $toID, 'record_type_id' => $targetID);
     CRM_Activity_BAO_ActivityContact::create($activityTargetParams);
     return TRUE;
 }
开发者ID:saurabhbatra96,项目名称:civicrm-core,代码行数:49,代码来源:Activity.php

示例2: 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);
 }
开发者ID:kcristiano,项目名称:civicrm-core,代码行数:91,代码来源:Friend.php

示例3: _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);
 }
开发者ID:nielosz,项目名称:civicrm-core,代码行数:86,代码来源:AJAX.php

示例4: 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);
     }
 }
开发者ID:BorislavZlatanov,项目名称:civicrm-core,代码行数:40,代码来源:PDFLetterCommon.php

示例5: executeCancellation

 /**
  * Handle the different actions, should probably be handles at base class level ...
  * 
  * @param type $match
  * @param type $btx
  */
 public function executeCancellation($match, $btx)
 {
     $config = $this->_plugin_config;
     $contribution_id = $match->getParameter('contribution_id');
     $mandate_id = $match->getParameter('mandate_id');
     $status_cancelled = banking_helper_optionvalue_by_groupname_and_name('contribution_status', 'Cancelled');
     // set the status to 'Cancelled'
     $query = array('version' => 3, 'id' => $contribution_id);
     $query['contribution_status_id'] = $status_cancelled;
     $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)) {
//.........这里部分代码省略.........
开发者ID:VangelisP,项目名称:org.project60.banking,代码行数:101,代码来源:SepaMandate.php

示例6: sendInviteEmail

 static function sendInviteEmail($message_template, $contact_id, $emailParams = array(), $teampcpId, $activityId)
 {
     $mailParams = array();
     $contactParams = array();
     if (isset($emailParams['tplParams'])) {
         $mailParams['tplParams'] = $emailParams['tplParams'];
     }
     //create contact corresponding to each friend
     foreach ($emailParams['friend'] as $key => $details) {
         if ($details["first_name"]) {
             $displayName = $details["first_name"] . " " . $details["last_name"];
             $contactParams[$key] = array('first_name' => $details["first_name"], 'last_name' => $details["last_name"], 'contact_source' => ts('PCP Team Invite'), 'email-Primary' => $details["email"], 'display_name' => $displayName);
             $mailParams['email'][$displayName] = $contactParams[$key];
         }
     }
     if (empty($mailParams)) {
         return NULL;
     }
     $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 = CRM_Contact_BAO_Contact::createProfileContact($value, CRM_Core_DAO::$_nullArray);
         }
         // attempt to save activity targets
         $targetParams = array('activity_id' => $activityId, 'contact_id' => $contact, 'record_type_id' => $targetID);
         // See if it already exists
         $activityContact = new CRM_Activity_DAO_ActivityContact();
         $activityContact->activity_id = $activityId;
         $activityContact->contact_id = $contact;
         $activityContact->find(TRUE);
         if (empty($activityContact->id)) {
             CRM_Activity_BAO_ActivityContact::create($targetParams);
         }
     }
     $mailParams['valueName'] = $message_template;
     return self::sendMail($contact_id, $mailParams);
 }
开发者ID:eruraindil,项目名称:uk.co.vedaconsulting.pcpteams,代码行数:43,代码来源:Utils.php


注:本文中的CRM_Activity_BAO_ActivityContact::create方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。