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


PHP CRM_Activity_BAO_Activity::create方法代码示例

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


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

示例1: createActivities

 function createActivities($form, $html_message, $contactIds)
 {
     $session = CRM_Core_Session::singleton();
     $userID = $session->get('userID');
     $activityTypeID = CRM_Core_OptionGroup::getValue('activity_type', 'Print PDF Letter', 'name');
     $activityParams = array('source_contact_id' => $userID, 'activity_type_id' => $activityTypeID, 'activity_date_time' => date('YmdHis'), 'details' => $html_message);
     if ($form->_activityId) {
         $activityParams += array('id' => $form->_activityId);
     }
     if ($form->_cid) {
         $activity = CRM_Activity_BAO_Activity::create($activityParams);
     } 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;
         }
     }
     foreach ($form->_contactIds as $contactId) {
         $activityTargetParams = array('activity_id' => empty($activity->id) ? $activityIds[$contactId] : $activity->id, 'target_contact_id' => $contactId);
         CRM_Activity_BAO_Activity::createActivityTarget($activityTargetParams);
     }
 }
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:24,代码来源:PDFLetterCommon.php

示例2: addActivityForSelection

 /**
  * @param int $participantId
  * @param $activityType
  *
  * @throws CRM_Core_Exception
  */
 public static function addActivityForSelection($participantId, $activityType)
 {
     $eventId = CRM_Core_DAO::getFieldValue('CRM_Event_BAO_Participant', $participantId, 'event_id');
     $contactId = CRM_Core_DAO::getFieldValue('CRM_Event_BAO_Participant', $participantId, 'contact_id');
     $date = CRM_Utils_Date::currentDBDate();
     $event = CRM_Event_BAO_Event::getEvents(0, $eventId);
     $eventTitle = $event[$eventId];
     $subject = "Registration selections changed for {$eventTitle}";
     $targetCid = $contactId;
     $srcRecId = $participantId;
     // activity params
     $activityParams = array('source_contact_id' => $targetCid, 'source_record_id' => $srcRecId, 'activity_type_id' => CRM_Core_OptionGroup::getValue('activity_type', $activityType, 'name'), 'subject' => $subject, 'activity_date_time' => $date, 'status_id' => CRM_Core_OptionGroup::getValue('activity_status', 'Completed', 'name'), 'skipRecentView' => TRUE);
     // create activity with target contacts
     $session = CRM_Core_Session::singleton();
     $id = $session->get('userID');
     if ($id) {
         $activityParams['source_contact_id'] = $id;
         $activityParams['target_contact_id'][] = $targetCid;
     }
     CRM_Activity_BAO_Activity::create($activityParams);
 }
开发者ID:kcristiano,项目名称:civicrm-core,代码行数:27,代码来源:Participant.php

示例3: mergeCases


//.........这里部分代码省略.........
                $otherAssigneeActivity->free();
                // copy custom fields and attachments
                $aparams = array('activityID' => $otherActivityId, 'mainActivityId' => $mainActivityId);
                CRM_Activity_BAO_Activity::copyExtendedActivityData($aparams);
            }
            //copy case relationship.
            if ($duplicateContacts) {
                //migrate relationship records.
                $otherRelationship = new CRM_Contact_DAO_Relationship();
                $otherRelationship->case_id = $otherCaseId;
                $otherRelationship->find();
                $otherRelationshipIds = array();
                while ($otherRelationship->fetch()) {
                    $otherRelVals = array();
                    $updateOtherRel = FALSE;
                    CRM_Core_DAO::storeValues($otherRelationship, $otherRelVals);
                    $mainRelationship = new CRM_Contact_DAO_Relationship();
                    $mainRelationship->copyValues($otherRelVals);
                    $mainRelationship->id = NULL;
                    $mainRelationship->case_id = $mainCaseId;
                    if ($mainRelationship->contact_id_a == $otherContactId) {
                        $updateOtherRel = TRUE;
                        $mainRelationship->contact_id_a = $mainContactId;
                    }
                    //case creator change only when we merge user contact.
                    if ($mainRelationship->contact_id_b == $otherContactId) {
                        //do not change creator for change client.
                        if (!$changeClient) {
                            $updateOtherRel = TRUE;
                            $mainRelationship->contact_id_b = $currentUserId ? $currentUserId : $mainContactId;
                        }
                    }
                    $mainRelationship->end_date = CRM_Utils_Date::isoToMysql($otherRelationship->end_date);
                    $mainRelationship->start_date = CRM_Utils_Date::isoToMysql($otherRelationship->start_date);
                    //avoid duplicate object.
                    if (!$mainRelationship->find(TRUE)) {
                        $mainRelationship->save();
                    }
                    $mainRelationship->free();
                    //get the other relationship ids to update end date.
                    if ($updateOtherRel) {
                        $otherRelationshipIds[$otherRelationship->id] = $otherRelationship->id;
                    }
                }
                $otherRelationship->free();
                //update other relationships end dates
                if (!empty($otherRelationshipIds)) {
                    $sql = 'UPDATE  civicrm_relationship
                               SET  end_date = CURDATE()
                             WHERE  id IN ( ' . implode(',', $otherRelationshipIds) . ')';
                    CRM_Core_DAO::executeQuery($sql);
                }
            }
            //move other case to trash.
            $mergeCase = self::deleteCase($otherCaseId, $moveToTrash);
            if (!$mergeCase) {
                continue;
            }
            $mergeActSubject = $mergeActSubjectDetails = $mergeActType = '';
            if ($changeClient) {
                $mainContactDisplayName = CRM_Contact_BAO_Contact::displayName($mainContactId);
                $otherContactDisplayName = CRM_Contact_BAO_Contact::displayName($otherContactId);
                $mergeActType = array_search('Reassigned Case', $activityTypes);
                $mergeActSubject = ts("Case %1 reassigned client from %2 to %3. New Case ID is %4.", array(1 => $otherCaseId, 2 => $otherContactDisplayName, 3 => $mainContactDisplayName, 4 => $mainCaseId));
            } elseif ($duplicateContacts) {
                $mergeActType = array_search('Merge Case', $activityTypes);
                $mergeActSubject = ts("Case %1 copied from contact id %2 to contact id %3 via merge. New Case ID is %4.", array(1 => $otherCaseId, 2 => $otherContactId, 3 => $mainContactId, 4 => $mainCaseId));
            } else {
                $mergeActType = array_search('Merge Case', $activityTypes);
                $mergeActSubject = ts("Case %1 merged into case %2", array(1 => $otherCaseId, 2 => $mainCaseId));
                if (!empty($copiedActivityIds)) {
                    $sql = '
SELECT id, subject, activity_date_time, activity_type_id
FROM civicrm_activity
WHERE id IN (' . implode(',', $copiedActivityIds) . ')';
                    $dao = CRM_Core_DAO::executeQuery($sql);
                    while ($dao->fetch()) {
                        $mergeActSubjectDetails .= "{$dao->activity_date_time} :: {$activityTypes[$dao->activity_type_id]}";
                        if ($dao->subject) {
                            $mergeActSubjectDetails .= " :: {$dao->subject}";
                        }
                        $mergeActSubjectDetails .= "<br />";
                    }
                }
            }
            //create merge activity record.
            $activityParams = array('subject' => $mergeActSubject, 'details' => $mergeActSubjectDetails, 'status_id' => array_search('Completed', $activityStatuses), 'activity_type_id' => $mergeActType, 'source_contact_id' => $mainContactId, 'activity_date_time' => date('YmdHis'));
            $mergeActivity = CRM_Activity_BAO_Activity::create($activityParams);
            $mergeActivityId = $mergeActivity->id;
            if (!$mergeActivityId) {
                continue;
            }
            $mergeActivity->free();
            //connect merge activity to case.
            $mergeCaseAct = array('case_id' => $mainCaseId, 'activity_id' => $mergeActivityId);
            self::processCaseActivity($mergeCaseAct);
        }
        CRM_Utils_Hook::post_case_merge($mainContactId, $mainCaseId, $otherContactId, $otherCaseId, $changeClient);
        return $mainCaseIds;
    }
开发者ID:prashantgajare,项目名称:civicrm-core,代码行数:101,代码来源:Case.php

示例4: cancelRecurContribution

    /**
     * Cancel Recurring contribution.
     *
     * @param int $recurId
     *   Recur contribution id.
     * @param array $objects
     *   An array of objects that is to be cancelled like.
     *                          contribution, membership, event. At least contribution object is a must.
     *
     * @param array $activityParams
     *
     * @return bool
     */
    public static function cancelRecurContribution($recurId, $objects, $activityParams = array())
    {
        if (!$recurId) {
            return FALSE;
        }
        $contributionStatus = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
        $canceledId = array_search('Cancelled', $contributionStatus);
        $recur = new CRM_Contribute_DAO_ContributionRecur();
        $recur->id = $recurId;
        $recur->whereAdd("contribution_status_id != {$canceledId}");
        if ($recur->find(TRUE)) {
            $transaction = new CRM_Core_Transaction();
            $recur->contribution_status_id = $canceledId;
            $recur->start_date = CRM_Utils_Date::isoToMysql($recur->start_date);
            $recur->create_date = CRM_Utils_Date::isoToMysql($recur->create_date);
            $recur->modified_date = CRM_Utils_Date::isoToMysql($recur->modified_date);
            $recur->cancel_date = date('YmdHis');
            $recur->save();
            $dao = CRM_Contribute_BAO_ContributionRecur::getSubscriptionDetails($recurId);
            if ($dao && $dao->recur_id) {
                $details = CRM_Utils_Array::value('details', $activityParams);
                if ($dao->auto_renew && $dao->membership_id) {
                    // its auto-renewal membership mode
                    $membershipTypes = CRM_Member_PseudoConstant::membershipType();
                    $membershipType = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_Membership', $dao->membership_id, 'membership_type_id');
                    $membershipType = CRM_Utils_Array::value($membershipType, $membershipTypes);
                    $details .= '
<br/>' . ts('Automatic renewal of %1 membership cancelled.', array(1 => $membershipType));
                } else {
                    $details .= '
<br/>' . ts('The recurring contribution of %1, every %2 %3 has been cancelled.', array(1 => $dao->amount, 2 => $dao->frequency_interval, 3 => $dao->frequency_unit));
                }
                $activityParams = array('source_contact_id' => $dao->contact_id, 'source_record_id' => CRM_Utils_Array::value('source_record_id', $activityParams), 'activity_type_id' => CRM_Core_OptionGroup::getValue('activity_type', 'Cancel Recurring Contribution', 'name'), 'subject' => CRM_Utils_Array::value('subject', $activityParams, ts('Recurring contribution cancelled')), 'details' => $details, 'activity_date_time' => date('YmdHis'), 'status_id' => CRM_Core_OptionGroup::getValue('activity_status', 'Completed', 'name'));
                $session = CRM_Core_Session::singleton();
                $cid = $session->get('userID');
                if ($cid) {
                    $activityParams['target_contact_id'][] = $activityParams['source_contact_id'];
                    $activityParams['source_contact_id'] = $cid;
                }
                CRM_Activity_BAO_Activity::create($activityParams);
            }
            // if there are associated objects, cancel them as well
            if ($objects == CRM_Core_DAO::$_nullObject) {
                $transaction->commit();
                return TRUE;
            } else {
                $baseIPN = new CRM_Core_Payment_BaseIPN();
                return $baseIPN->cancelled($objects, $transaction);
            }
        } else {
            // if already cancelled, return true
            $recur->whereAdd();
            $recur->whereAdd("contribution_status_id = {$canceledId}");
            if ($recur->find(TRUE)) {
                return TRUE;
            }
        }
        return FALSE;
    }
开发者ID:kcristiano,项目名称:civicrm-core,代码行数:72,代码来源:ContributionRecur.php

示例5: 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

示例6: writeToDB

 /**
  * @param array $deliveredParams
  * @param array $targetParams
  * @param $mailing
  * @param $job_date
  *
  * @return bool
  * @throws CRM_Core_Exception
  * @throws Exception
  */
 public function writeToDB(&$deliveredParams, &$targetParams, &$mailing, $job_date)
 {
     static $activityTypeID = NULL;
     static $writeActivity = NULL;
     if (!empty($deliveredParams)) {
         CRM_Mailing_Event_BAO_Delivered::bulkCreate($deliveredParams);
         $deliveredParams = array();
     }
     if ($writeActivity === NULL) {
         $writeActivity = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME, 'write_activity_record', NULL, TRUE);
     }
     if (!$writeActivity) {
         return TRUE;
     }
     $result = TRUE;
     if (!empty($targetParams) && !empty($mailing->scheduled_id)) {
         if (!$activityTypeID) {
             if ($mailing->sms_provider_id) {
                 $mailing->subject = $mailing->name;
                 $activityTypeID = CRM_Core_OptionGroup::getValue('activity_type', 'Mass SMS', 'name');
             } else {
                 $activityTypeID = CRM_Core_OptionGroup::getValue('activity_type', 'Bulk Email', 'name');
             }
             if (!$activityTypeID) {
                 CRM_Core_Error::fatal();
             }
         }
         $activity = array('source_contact_id' => $mailing->scheduled_id, 'target_contact_id' => array_unique($targetParams), 'activity_type_id' => $activityTypeID, 'source_record_id' => $this->mailing_id, 'activity_date_time' => $job_date, 'subject' => $mailing->subject, 'status_id' => 2, 'deleteActivityTarget' => FALSE, 'campaign_id' => $mailing->campaign_id);
         //check whether activity is already created for this mailing.
         //if yes then create only target contact record.
         $query = "\nSELECT id\nFROM   civicrm_activity\nWHERE  civicrm_activity.activity_type_id = %1\nAND    civicrm_activity.source_record_id = %2\n";
         $queryParams = array(1 => array($activityTypeID, 'Integer'), 2 => array($this->mailing_id, 'Integer'));
         $activityID = CRM_Core_DAO::singleValueQuery($query, $queryParams);
         if ($activityID) {
             $activity['id'] = $activityID;
             // CRM-9519
             if (CRM_Core_BAO_Email::isMultipleBulkMail()) {
                 static $targetRecordID = NULL;
                 if (!$targetRecordID) {
                     $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name');
                     $targetRecordID = CRM_Utils_Array::key('Activity Targets', $activityContacts);
                 }
                 // make sure we don't attempt to duplicate the target activity
                 foreach ($activity['target_contact_id'] as $key => $targetID) {
                     $sql = "\nSELECT id\nFROM   civicrm_activity_contact\nWHERE  activity_id = {$activityID}\nAND    contact_id = {$targetID}\nAND    record_type_id = {$targetRecordID}\n";
                     if (CRM_Core_DAO::singleValueQuery($sql)) {
                         unset($activity['target_contact_id'][$key]);
                     }
                 }
             }
         }
         if (is_a(CRM_Activity_BAO_Activity::create($activity), 'CRM_Core_Error')) {
             $result = FALSE;
         }
         $targetParams = array();
     }
     return $result;
 }
开发者ID:vakeesan26,项目名称:civicrm-core,代码行数:68,代码来源:MailingJob.php

示例7: addActivityForPayment

 /**
  * @param $entityObj
  * @param $trxnObj
  * @param $activityType
  * @param $component
  * @param int $contributionId
  *
  * @throws CRM_Core_Exception
  */
 public static function addActivityForPayment($entityObj, $trxnObj, $activityType, $component, $contributionId)
 {
     if ($component == 'event') {
         $date = CRM_Utils_Date::isoToMysql($trxnObj->trxn_date);
         $paymentAmount = CRM_Utils_Money::format($trxnObj->total_amount, $trxnObj->currency);
         $eventTitle = CRM_Core_DAO::getFieldValue('CRM_Event_BAO_Event', $entityObj->event_id, 'title');
         $subject = "{$paymentAmount} - Offline {$activityType} for {$eventTitle}";
         $targetCid = $entityObj->contact_id;
         // source record id would be the contribution id
         $srcRecId = $contributionId;
     }
     // activity params
     $activityParams = array('source_contact_id' => $targetCid, 'source_record_id' => $srcRecId, 'activity_type_id' => CRM_Core_OptionGroup::getValue('activity_type', $activityType, 'name'), 'subject' => $subject, 'activity_date_time' => $date, 'status_id' => CRM_Core_OptionGroup::getValue('activity_status', 'Completed', 'name'), 'skipRecentView' => TRUE);
     // create activity with target contacts
     $session = CRM_Core_Session::singleton();
     $id = $session->get('userID');
     if ($id) {
         $activityParams['source_contact_id'] = $id;
         $activityParams['target_contact_id'][] = $targetCid;
     }
     CRM_Activity_BAO_Activity::create($activityParams);
 }
开发者ID:nganivet,项目名称:civicrm-core,代码行数:31,代码来源:Contribution.php

示例8: postProcess

 /**
  * called after the user submits the form.
  *
  *
  * @return void
  */
 public function postProcess()
 {
     // store the submitted values in an array
     $params = $this->exportValues();
     if ($this->_selfService && $this->_donorEmail) {
         // for self service force notify
         $params['is_notify'] = 1;
     }
     // if this is an update of an existing recurring contribution, pass the ID
     $params['id'] = $this->_subscriptionDetails->recur_id;
     $message = '';
     $params['subscriptionId'] = $this->_subscriptionDetails->subscription_id;
     $updateSubscription = TRUE;
     if ($this->_paymentProcessorObj->isSupported('changeSubscriptionAmount')) {
         $updateSubscription = $this->_paymentProcessorObj->changeSubscriptionAmount($message, $params);
     }
     if (is_a($updateSubscription, 'CRM_Core_Error')) {
         CRM_Core_Error::displaySessionError($updateSubscription);
         $status = ts('Could not update the Recurring contribution details');
         $msgTitle = ts('Update Error');
         $msgType = 'error';
     } elseif ($updateSubscription) {
         // save the changes
         $result = CRM_Contribute_BAO_ContributionRecur::add($params);
         $status = ts('Recurring contribution has been updated to: %1, every %2 %3(s) for %4 installments.', array(1 => CRM_Utils_Money::format($params['amount'], $this->_subscriptionDetails->currency), 2 => $this->_subscriptionDetails->frequency_interval, 3 => $this->_subscriptionDetails->frequency_unit, 4 => $params['installments']));
         $msgTitle = ts('Update Success');
         $msgType = 'success';
         $contactID = $this->_subscriptionDetails->contact_id;
         if ($this->_subscriptionDetails->amount != $params['amount']) {
             $message .= "<br /> " . ts("Recurring contribution amount has been updated from %1 to %2 for this subscription.", array(1 => CRM_Utils_Money::format($this->_subscriptionDetails->amount, $this->_subscriptionDetails->currency), 2 => CRM_Utils_Money::format($params['amount'], $this->_subscriptionDetails->currency))) . ' ';
         }
         if ($this->_subscriptionDetails->installments != $params['installments']) {
             $message .= "<br /> " . ts("Recurring contribution installments have been updated from %1 to %2 for this subscription.", array(1 => $this->_subscriptionDetails->installments, 2 => $params['installments'])) . ' ';
         }
         $activityParams = array('source_contact_id' => $contactID, 'activity_type_id' => CRM_Core_OptionGroup::getValue('activity_type', 'Update Recurring Contribution', 'name'), 'subject' => ts('Recurring Contribution Updated'), 'details' => $message, 'activity_date_time' => date('YmdHis'), 'status_id' => CRM_Core_OptionGroup::getValue('activity_status', 'Completed', 'name'));
         $session = CRM_Core_Session::singleton();
         $cid = $session->get('userID');
         if ($cid) {
             $activityParams['target_contact_id'][] = $activityParams['source_contact_id'];
             $activityParams['source_contact_id'] = $cid;
         }
         CRM_Activity_BAO_Activity::create($activityParams);
         if (!empty($params['is_notify'])) {
             // send notification
             if ($this->_subscriptionDetails->contribution_page_id) {
                 CRM_Core_DAO::commonRetrieveAll('CRM_Contribute_DAO_ContributionPage', 'id', $this->_subscriptionDetails->contribution_page_id, $value, array('title', 'receipt_from_name', 'receipt_from_email'));
                 $receiptFrom = '"' . CRM_Utils_Array::value('receipt_from_name', $value[$this->_subscriptionDetails->contribution_page_id]) . '" <' . $value[$this->_subscriptionDetails->contribution_page_id]['receipt_from_email'] . '>';
             } else {
                 $domainValues = CRM_Core_BAO_Domain::getNameAndEmail();
                 $receiptFrom = "{$domainValues['0']} <{$domainValues['1']}>";
             }
             list($donorDisplayName, $donorEmail) = CRM_Contact_BAO_Contact::getContactDetails($contactID);
             $tplParams = array('recur_frequency_interval' => $this->_subscriptionDetails->frequency_interval, 'recur_frequency_unit' => $this->_subscriptionDetails->frequency_unit, 'amount' => CRM_Utils_Money::format($params['amount']), 'installments' => $params['installments']);
             $tplParams['contact'] = array('display_name' => $donorDisplayName);
             $tplParams['receipt_from_email'] = $receiptFrom;
             $sendTemplateParams = array('groupName' => 'msg_tpl_workflow_contribution', 'valueName' => 'contribution_recurring_edit', 'contactId' => $contactID, 'tplParams' => $tplParams, 'isTest' => $this->_subscriptionDetails->is_test, 'PDFFilename' => 'receipt.pdf', 'from' => $receiptFrom, 'toName' => $donorDisplayName, 'toEmail' => $donorEmail);
             list($sent) = CRM_Core_BAO_MessageTemplate::sendTemplate($sendTemplateParams);
         }
     }
     $session = CRM_Core_Session::singleton();
     $userID = $session->get('userID');
     if ($userID && $status) {
         CRM_Core_Session::setStatus($status, $msgTitle, $msgType);
     } elseif (!$userID) {
         if ($status) {
             CRM_Utils_System::setUFMessage($status);
         }
         // keep result as 1, since we not displaying anything on the redirected page anyway
         return CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/contribute/subscriptionstatus', "reset=1&task=update&result=1"));
     }
 }
开发者ID:JSProffitt,项目名称:civicrm-website-org,代码行数:77,代码来源:UpdateSubscription.php

示例9: createCaseRoleActivity

 /**
  * Function to create activities when Case or Other roles assigned/modified/deleted. 
  *
  * @param int      $caseID case id
  * @param int      $relationshipId relationship id
  * @param int      $relContactId case role assigne contactId.
  *
  * @return void on success creates activity and case activity 
  *
  * @static
  */
 static function createCaseRoleActivity($caseId, $relationshipId, $relContactId = null, $contactId = null)
 {
     if (!$caseId || !$relationshipId || empty($relationshipId)) {
         return;
     }
     $queryParam = array();
     if (is_array($relationshipId)) {
         $relationshipId = implode(',', $relationshipId);
         $relationshipClause = " civicrm_relationship.id IN ({$relationshipId})";
     } else {
         $relationshipClause = " civicrm_relationship.id = %1";
         $queryParam[1] = array($relationshipId, 'Integer');
     }
     $query = "\n                  SELECT civicrm_relationship.contact_id_b as rel_contact_id, civicrm_relationship.contact_id_a as assign_contact_id, \n                  civicrm_relationship_type.label_b_a as relation, civicrm_relationship.case_id as caseId,\n                  cc.display_name as clientName, cca.display_name as  assigneeContactName  \n                  FROM civicrm_relationship_type,  civicrm_relationship \n                  LEFT JOIN civicrm_contact cc  ON cc.id  = civicrm_relationship.contact_id_b  \n                  LEFT JOIN civicrm_contact cca ON cca.id = civicrm_relationship.contact_id_a\n                  WHERE civicrm_relationship.relationship_type_id = civicrm_relationship_type.id AND {$relationshipClause}";
     $dao = CRM_Core_DAO::executeQuery($query, $queryParam);
     while ($dao->fetch()) {
         $caseRelationship = $dao->relation;
         //to get valid assignee contact(s).
         if (isset($dao->caseId) || $dao->rel_contact_id != $contactId) {
             $assigneContactIds[$dao->rel_contact_id] = $dao->rel_contact_id;
             $assigneContactName = $dao->clientName;
         } else {
             $assigneContactIds[$dao->assign_contact_id] = $dao->assign_contact_id;
             $assigneContactName = $dao->assigneeContactName;
         }
     }
     require_once 'CRM/Core/OptionGroup.php';
     $session =& CRM_Core_Session::singleton();
     $activityParams = array('source_contact_id' => $session->get('userID'), 'subject' => $caseRelationship . ' : ' . $assigneContactName, 'activity_date_time' => date('YmdHis'), 'status_id' => CRM_Core_OptionGroup::getValue('activity_status', 'Completed', 'name'));
     //if $relContactId is passed, role is added or modified.
     if (!empty($relContactId)) {
         $activityParams['assignee_contact_id'] = $assigneContactIds;
         $activityTypeID = CRM_Core_OptionGroup::getValue('activity_type', 'Assign Case Role', 'name');
     } else {
         $activityTypeID = CRM_Core_OptionGroup::getValue('activity_type', 'Remove Case Role', 'name');
     }
     $activityParams['activity_type_id'] = $activityTypeID;
     require_once "CRM/Activity/BAO/Activity.php";
     $activity = CRM_Activity_BAO_Activity::create($activityParams);
     //create case_activity record.
     $caseParams = array('activity_id' => $activity->id, 'case_id' => $caseId);
     require_once "CRM/Activity/BAO/Activity.php";
     CRM_Case_BAO_Case::processCaseActivity($caseParams);
 }
开发者ID:bhirsch,项目名称:voipdev,代码行数:55,代码来源:Case.php

示例10: postProcess

 /**
  * process the form after the input has been submitted and validated
  *
  * @access public
  * @return None
  */
 public function postProcess()
 {
     //get the submitted values in an array
     $params = $this->controller->exportValues($this->_name);
     require_once 'CRM/Activity/BAO/Activity.php';
     require_once 'CRM/Contact/BAO/Contact.php';
     require_once 'CRM/Core/BAO/CustomField.php';
     require_once 'CRM/Core/BAO/CustomGroup.php';
     require_once 'CRM/Core/BAO/CustomValueTable.php';
     $this->_groupId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup', 'civicrm_value_survey_activity_details', 'id', 'table_name');
     $groupTree = CRM_Core_BAO_CustomGroup::getTree('Activity', $this, null, $this->_groupId);
     $this->_surveyId = CRM_Utils_Array::value('survey_id', $params);
     $activityGroupTree = CRM_Core_BAO_CustomGroup::formatGroupTree($groupTree, 1, $this);
     $fieldMapper = array();
     foreach ($activityGroupTree[$this->_groupId]['fields'] as $fieldId => $field) {
         $fieldMapper[$field['column_name']] = $field['element_name'];
     }
     $duplicateContacts = array();
     $query = "SELECT DISTINCT(target.target_contact_id) as contact_id FROM " . self::ACTIVITY_SURVEY_DETAIL_TABLE . " survey INNER JOIN civicrm_activity_target target ON ( target.activity_id = survey.entity_id ) WHERE survey.status_id = 'H' AND survey.survey_id = %1  AND target.target_contact_id IN (" . implode(',', $this->_contactIds) . ") ";
     $findDuplicate = CRM_Core_DAO::executeQuery($query, array(1 => array($this->_surveyId, 'Integer')));
     while ($findDuplicate->fetch()) {
         $duplicateContacts[$findDuplicate->contact_id] = $findDuplicate->contact_id;
     }
     $customFields = CRM_Core_BAO_CustomField::getFields('Activity');
     $surveyDetails = $this->_surveyDetails;
     $maxVoters = $surveyDetails->max_number_of_contacts;
     list($cName, $cEmail, $doNotEmail, $onHold, $isDeceased) = CRM_Contact_BAO_Contact::getContactDetails($this->_interviewerId);
     $fieldParams[$fieldMapper['survey_id']] = $this->_surveyId;
     $fieldParams[$fieldMapper['status_id']] = 'H';
     $fieldParams[$fieldMapper['interviewer_id']] = $this->_interviewerId;
     $fieldParams[$fieldMapper['interviewer_display_name']] = CRM_Utils_Type::escape($cName, 'String');
     $fieldParams[$fieldMapper['interviewer_email']] = CRM_Utils_Type::escape($cEmail, 'String');
     $fieldParams[$fieldMapper['interviewer_ip']] = CRM_Utils_Type::escape($_SERVER['REMOTE_ADDR'], 'String');
     $countVoters = 0;
     foreach ($this->_contactIds as $cid) {
         if ($maxVoters && $maxVoters <= $this->_numVoters + $countVoters) {
             break;
         }
         if (in_array($cid, $duplicateContacts)) {
             continue;
         }
         $countVoters++;
         $activityParams = array();
         $activityParams['source_contact_id'] = $this->_interviewerId;
         $activityParams['assignee_contact_id'] = array($this->_interviewerId);
         $activityParams['target_contact_id'] = array($cid);
         $activityParams['activity_type_id'] = $surveyDetails->survey_type_id;
         $activityParams['subject'] = ts('Voter Reservation');
         $activityParams['status_id'] = 1;
         $activityParams['campaign_id'] = $surveyDetails->campaign_id;
         $result = CRM_Activity_BAO_Activity::create($activityParams);
         $fieldParams[$fieldMapper['subject_display_name']] = CRM_Contact_BAO_Contact::displayName($cid);
         if ($result) {
             CRM_Core_BAO_CustomValueTable::postProcess($fieldParams, $customFields, 'civicrm_activity', $result->id, 'Activity');
         }
     }
     $status = array();
     if ($countVoters > 0) {
         $status[] = ts('Voter Reservation has been added for %1 Contact(s).', array(1 => $countVoters));
     }
     if (count($this->_contactIds) > $countVoters) {
         $status[] = ts('Voter Reservation did not add for %1 Contact(s).', array(1 => count($this->_contactIds) - $countVoters));
     }
     if (!empty($status)) {
         CRM_Core_Session::setStatus(implode('&nbsp;', $status));
     }
 }
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:73,代码来源:VoterReservation.php

示例11: array

/**
 * Update a specified activity.
 *
 * Updates activity with the values passed in the 'params' array. An
 * error is returned if an invalid id or activity Name is passed 
 * @param CRM_Activity $activity A valid Activity object
 * @param array       $params  Associative array of property
 *                             name/value pairs to be updated. 
 *  
 * @return CRM_Activity|CRM_Core_Error  Return the updated ActivtyType Object else
 *                                Error Object (if integrity violation)
 *
 * @access public
 *
 */
function &civicrm_activity_update(&$params)
{
    $errors = array();
    //check for various error and required conditions
    $errors = _civicrm_activity_check_params($params);
    if (!empty($errors)) {
        return $errors;
    }
    // processing for custom data
    $values = array();
    _civicrm_custom_format_params($params, $values, 'Activity');
    if (!empty($values['custom'])) {
        $params['custom'] = $values['custom'];
    }
    $activity = CRM_Activity_BAO_Activity::create($params);
    $activityArray = array();
    _civicrm_object_to_array($activity, $activityArray);
    return $activityArray;
}
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:34,代码来源:Activity.php

示例12: postProcess

 /**
  * Process the form submission.
  *
  * @return void
  */
 public function postProcess()
 {
     $session = CRM_Core_Session::singleton();
     $ids = array();
     $params = $this->exportValues();
     $batchStatus = CRM_Core_PseudoConstant::get('CRM_Batch_DAO_Batch', 'status_id');
     if ($this->_id) {
         $ids['batchID'] = $this->_id;
         $params['id'] = $this->_id;
     }
     // store the submitted values in an array
     $params['modified_date'] = date('YmdHis');
     $params['modified_id'] = $session->get('userID');
     if (!empty($params['created_date'])) {
         $params['created_date'] = CRM_Utils_Date::processDate($params['created_date']);
     }
     if ($this->_action & CRM_Core_Action::ADD) {
         $batchMode = CRM_Core_PseudoConstant::get('CRM_Batch_DAO_Batch', 'mode_id', array('labelColumn' => 'name'));
         $params['mode_id'] = CRM_Utils_Array::key('Manual Batch', $batchMode);
         $params['status_id'] = CRM_Utils_Array::key('Open', $batchStatus);
         $params['created_date'] = date('YmdHis');
         $params['created_id'] = $session->get('userID');
         $details = "{$params['title']} batch has been created by this contact.";
         $activityTypeName = 'Create Batch';
     } elseif ($this->_action & CRM_Core_Action::UPDATE && $this->_id) {
         $details = "{$params['title']} batch has been edited by this contact.";
         if (CRM_Utils_Array::value($params['status_id'], $batchStatus) == 'Closed') {
             $details = "{$params['title']} batch has been closed by this contact.";
         }
         $activityTypeName = 'Edit Batch';
     }
     $batch = CRM_Batch_BAO_Batch::create($params, $ids, 'financialBatch');
     $activityTypes = CRM_Core_PseudoConstant::activityType(TRUE, FALSE, FALSE, 'name');
     //create activity.
     $activityParams = array('activity_type_id' => array_search($activityTypeName, $activityTypes), 'subject' => $batch->title . "- Batch", 'status_id' => 2, 'priority_id' => 2, 'activity_date_time' => date('YmdHis'), 'source_contact_id' => $session->get('userID'), 'source_contact_qid' => $session->get('userID'), 'details' => $details);
     CRM_Activity_BAO_Activity::create($activityParams);
     $buttonName = $this->controller->getButtonName();
     $context = $this->get("context");
     if ($batch->title) {
         CRM_Core_Session::setStatus(ts("'%1' batch has been saved.", array(1 => $batch->title)), ts('Saved'), 'success');
     }
     if ($buttonName == $this->getButtonName('next', 'new') & $this->_action == CRM_Core_Action::UPDATE) {
         $session->replaceUserContext(CRM_Utils_System::url('civicrm/financial/batch', "reset=1&action=add&context=1"));
     } elseif ($buttonName == $this->getButtonName('next', 'new')) {
         $session->replaceUserContext(CRM_Utils_System::url('civicrm/financial/batch', "reset=1&action=add"));
     } elseif (CRM_Utils_Array::value($batch->status_id, $batchStatus) == 'Closed') {
         $session->replaceUserContext(CRM_Utils_System::url('civicrm', 'reset=1'));
     } elseif ($buttonName == $this->getButtonName('next') & $this->_action == CRM_Core_Action::UPDATE || $buttonName == $this->getButtonName('next') & $this->_action == CRM_Core_Action::ADD & $context == 1) {
         $session->replaceUserContext(CRM_Utils_System::url('civicrm/financial/financialbatches', "reset=1&batchStatus=1"));
     } else {
         $session->replaceUserContext(CRM_Utils_System::url('civicrm/batchtransaction', "reset=1&bid={$batch->id}"));
     }
 }
开发者ID:utkarshsharma,项目名称:civicrm-core,代码行数:58,代码来源:FinancialBatch.php

示例13: createActivity

 /**
  * @param $activityTypeXML
  * @param array $params
  *
  * @return bool
  * @throws CRM_Core_Exception
  * @throws Exception
  */
 public function createActivity($activityTypeXML, &$params)
 {
     $activityTypeName = (string) $activityTypeXML->name;
     $activityTypes =& $this->allActivityTypes(TRUE, TRUE);
     $activityTypeInfo = CRM_Utils_Array::value($activityTypeName, $activityTypes);
     if (!$activityTypeInfo) {
         $docLink = CRM_Utils_System::docURL2("user/case-management/setup");
         CRM_Core_Error::fatal(ts('Activity type %1, found in case configuration file, is not present in the database %2', array(1 => $activityTypeName, 2 => $docLink)));
         return FALSE;
     }
     $activityTypeID = $activityTypeInfo['id'];
     if (isset($activityTypeXML->status)) {
         $statusName = (string) $activityTypeXML->status;
     } else {
         $statusName = 'Scheduled';
     }
     if ($this->_isMultiClient) {
         $client = $params['clientID'];
     } else {
         $client = array(1 => $params['clientID']);
     }
     //set order
     $orderVal = '';
     if (isset($activityTypeXML->order)) {
         $orderVal = (string) $activityTypeXML->order;
     }
     if ($activityTypeName == 'Open Case') {
         $activityParams = array('activity_type_id' => $activityTypeID, 'source_contact_id' => $params['creatorID'], 'is_auto' => FALSE, 'is_current_revision' => 1, 'subject' => CRM_Utils_Array::value('subject', $params) ? $params['subject'] : $activityTypeName, 'status_id' => CRM_Core_OptionGroup::getValue('activity_status', $statusName, 'name'), 'target_contact_id' => $client, 'medium_id' => CRM_Utils_Array::value('medium_id', $params), 'location' => CRM_Utils_Array::value('location', $params), 'details' => CRM_Utils_Array::value('details', $params), 'duration' => CRM_Utils_Array::value('duration', $params), 'weight' => $orderVal);
     } else {
         $activityParams = array('activity_type_id' => $activityTypeID, 'source_contact_id' => $params['creatorID'], 'is_auto' => TRUE, 'is_current_revision' => 1, 'status_id' => CRM_Core_OptionGroup::getValue('activity_status', $statusName, 'name'), 'target_contact_id' => $client, 'weight' => $orderVal);
     }
     //parsing date to default preference format
     $params['activity_date_time'] = CRM_Utils_Date::processDate($params['activity_date_time']);
     if ($activityTypeName == 'Open Case') {
         // we don't set activity_date_time for auto generated
         // activities, but we want it to be set for open case.
         $activityParams['activity_date_time'] = $params['activity_date_time'];
         if (array_key_exists('custom', $params) && is_array($params['custom'])) {
             $activityParams['custom'] = $params['custom'];
         }
         // Add parameters for attachments
         $numAttachments = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'max_attachments');
         for ($i = 1; $i <= $numAttachments; $i++) {
             $attachName = "attachFile_{$i}";
             if (isset($params[$attachName]) && !empty($params[$attachName])) {
                 $activityParams[$attachName] = $params[$attachName];
             }
         }
     } else {
         $activityDate = NULL;
         //get date of reference activity if set.
         if ($referenceActivityName = (string) $activityTypeXML->reference_activity) {
             //we skip open case as reference activity.CRM-4374.
             if (!empty($params['resetTimeline']) && $referenceActivityName == 'Open Case') {
                 $activityDate = $params['activity_date_time'];
             } else {
                 $referenceActivityInfo = CRM_Utils_Array::value($referenceActivityName, $activityTypes);
                 if ($referenceActivityInfo['id']) {
                     $caseActivityParams = array('activity_type_id' => $referenceActivityInfo['id']);
                     //if reference_select is set take according activity.
                     if ($referenceSelect = (string) $activityTypeXML->reference_select) {
                         $caseActivityParams[$referenceSelect] = 1;
                     }
                     $referenceActivity = CRM_Case_BAO_Case::getCaseActivityDates($params['caseID'], $caseActivityParams, TRUE);
                     if (is_array($referenceActivity)) {
                         foreach ($referenceActivity as $aId => $details) {
                             $activityDate = CRM_Utils_Array::value('activity_date', $details);
                             break;
                         }
                     }
                 }
             }
         }
         if (!$activityDate) {
             $activityDate = $params['activity_date_time'];
         }
         list($activity_date, $activity_time) = CRM_Utils_Date::setDateDefaults($activityDate);
         $activityDateTime = CRM_Utils_Date::processDate($activity_date, $activity_time);
         //add reference offset to date.
         if ((int) $activityTypeXML->reference_offset) {
             $activityDateTime = CRM_Utils_Date::intervalAdd('day', (int) $activityTypeXML->reference_offset, $activityDateTime);
         }
         $activityParams['activity_date_time'] = CRM_Utils_Date::format($activityDateTime);
     }
     // if same activity is already there, skip and dont touch
     $params['activityTypeID'] = $activityTypeID;
     $params['activityTypeName'] = $activityTypeName;
     if ($this->isActivityPresent($params)) {
         return TRUE;
     }
     $activityParams['case_id'] = $params['caseID'];
     if (!empty($activityParams['is_auto'])) {
//.........这里部分代码省略.........
开发者ID:BorislavZlatanov,项目名称:civicrm-core,代码行数:101,代码来源:Process.php

示例14: sendTransitionParticipantMail

 /**
  * Function to send mail and create activity
  * when participant status changed.
  *
  * @param  int     $participantId      participant id.
  * @param  array   $participantValues  participant detail values. status id for participants
  * @param  array   $eventDetails       required event details
  * @param  array   $contactDetails     required contact details
  * @param  array   $domainValues       required domain values.
  * @param  string  $mailType           (eg 'approval', 'confirm', 'expired' )
  *
  * return  void
  * @access public
  * @static
  */
 function sendTransitionParticipantMail($participantId, $participantValues, $eventDetails, $contactDetails, &$domainValues, $mailType)
 {
     //send emails.
     $mailSent = FALSE;
     //don't send confirmation mail to additional
     //since only primary able to confirm registration.
     if (CRM_Utils_Array::value('registered_by_id', $participantValues) && $mailType == 'Confirm') {
         return $mailSent;
     }
     if ($toEmail = CRM_Utils_Array::value('email', $contactDetails)) {
         $contactId = $participantValues['contact_id'];
         $participantName = $contactDetails['display_name'];
         //calculate the checksum value.
         $checksumValue = NULL;
         if ($mailType == 'Confirm' && !$participantValues['registered_by_id']) {
             $checksumLife = 'inf';
             if ($endDate = CRM_Utils_Array::value('end_date', $eventDetails)) {
                 $checksumLife = (CRM_Utils_Date::unixTime($endDate) - time()) / (60 * 60);
             }
             $checksumValue = CRM_Contact_BAO_Contact_Utils::generateChecksum($contactId, NULL, $checksumLife);
         }
         //take a receipt from as event else domain.
         $receiptFrom = $domainValues['name'] . ' <' . $domainValues['email'] . '>';
         if (CRM_Utils_Array::value('confirm_from_name', $eventDetails) && CRM_Utils_Array::value('confirm_from_email', $eventDetails)) {
             $receiptFrom = $eventDetails['confirm_from_name'] . ' <' . $eventDetails['confirm_from_email'] . '>';
         }
         list($mailSent, $subject, $message, $html) = CRM_Core_BAO_MessageTemplates::sendTemplate(array('groupName' => 'msg_tpl_workflow_event', 'valueName' => 'participant_' . strtolower($mailType), 'contactId' => $contactId, 'tplParams' => array('contact' => $contactDetails, 'domain' => $domainValues, 'participant' => $participantValues, 'event' => $eventDetails, 'paidEvent' => CRM_Utils_Array::value('is_monetary', $eventDetails), 'isShowLocation' => CRM_Utils_Array::value('is_show_location', $eventDetails), 'isAdditional' => $participantValues['registered_by_id'], 'isExpired' => $mailType == 'Expired', 'isConfirm' => $mailType == 'Confirm', 'checksumValue' => $checksumValue), 'from' => $receiptFrom, 'toName' => $participantName, 'toEmail' => $toEmail, 'cc' => CRM_Utils_Array::value('cc_confirm', $eventDetails), 'bcc' => CRM_Utils_Array::value('bcc_confirm', $eventDetails)));
         // 3. create activity record.
         if ($mailSent) {
             $now = date('YmdHis');
             $activityType = 'Event Registration';
             $activityParams = array('subject' => $subject, 'source_contact_id' => $contactId, 'source_record_id' => $participantId, 'activity_type_id' => CRM_Core_OptionGroup::getValue('activity_type', $activityType, 'name'), 'activity_date_time' => CRM_Utils_Date::isoToMysql($now), 'due_date_time' => CRM_Utils_Date::isoToMysql($participantValues['register_date']), 'is_test' => $participantValues['is_test'], 'status_id' => 2);
             if (is_a(CRM_Activity_BAO_Activity::create($activityParams), 'CRM_Core_Error')) {
                 CRM_Core_Error::fatal('Failed creating Activity for expiration mail');
             }
         }
     }
     return $mailSent;
 }
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:54,代码来源:Participant.php

示例15: sendMailings


//.........这里部分代码省略.........
                $extraJoin = "\nINNER JOIN civicrm_event ev ON e.event_id = ev.id\nINNER JOIN civicrm_option_group og ON og.name = 'event_type'\nINNER JOIN civicrm_option_value ov ON ev.event_type_id = ov.value AND ov.option_group_id = og.id\nLEFT  JOIN civicrm_loc_block lb ON lb.id = ev.loc_block_id\nLEFT  JOIN civicrm_address address ON address.id = lb.address_id\nLEFT  JOIN civicrm_email email ON email.id = lb.email_id\nLEFT  JOIN civicrm_phone phone ON phone.id = lb.phone_id\n";
                if ($actionSchedule->limit_to == 0) {
                    $extraJoin = "\nLEFT JOIN civicrm_event ev ON e.event_id = ev.id\nLEFT JOIN civicrm_option_group og ON og.name = 'event_type'\nLEFT JOIN civicrm_option_value ov ON ev.event_type_id = ov.value AND ov.option_group_id = og.id\nLEFT JOIN civicrm_loc_block lb ON lb.id = ev.loc_block_id\nLEFT JOIN civicrm_address address ON address.id = lb.address_id\nLEFT JOIN civicrm_email email ON email.id = lb.email_id\nLEFT JOIN civicrm_phone phone ON phone.id = lb.phone_id\n";
                }
            }
            if ($mapping->entity == 'civicrm_membership') {
                $tokenEntity = 'membership';
                $tokenFields = array('fee', 'id', 'join_date', 'start_date', 'end_date', 'status', 'type');
                $extraSelect = ', mt.minimum_fee as fee, e.id as id , e.join_date, e.start_date, e.end_date, ms.name as status, mt.name as type';
                $extraJoin = '
 INNER JOIN civicrm_membership_type mt ON e.membership_type_id = mt.id
 INNER JOIN civicrm_membership_status ms ON e.status_id = ms.id';
                if ($actionSchedule->limit_to == 0) {
                    $extraJoin = '
 LEFT JOIN civicrm_membership_type mt ON e.membership_type_id = mt.id
 LEFT JOIN civicrm_membership_status ms ON e.status_id = ms.id';
                }
            }
            if ($mapping->entity == 'civicrm_contact') {
                $tokenEntity = 'contact';
                //TODO: get full list somewhere!
                $tokenFields = array('birth_date', 'last_name');
                //TODO: is there anything to add here?
            }
            $entityJoinClause = "INNER JOIN {$mapping->entity} e ON e.id = reminder.entity_id";
            if ($actionSchedule->limit_to == 0) {
                $entityJoinClause = "LEFT JOIN {$mapping->entity} e ON e.id = reminder.entity_id";
                $extraWhere .= " AND (e.id = reminder.entity_id OR reminder.entity_table = 'civicrm_contact')";
            }
            $entityJoinClause .= $extraOn;
            $query = "\nSELECT reminder.id as reminderID, reminder.contact_id as contactID, reminder.*, e.id as entityID, e.* {$extraSelect}\nFROM  civicrm_action_log reminder\n{$entityJoinClause}\n{$extraJoin}\nWHERE reminder.action_schedule_id = %1 AND reminder.action_date_time IS NULL\n{$extraWhere}";
            $dao = CRM_Core_DAO::executeQuery($query, array(1 => array($actionSchedule->id, 'Integer')));
            while ($dao->fetch()) {
                $entityTokenParams = array();
                foreach ($tokenFields as $field) {
                    if ($field == 'location') {
                        $loc = array();
                        $stateProvince = CRM_Core_PseudoConstant::stateProvince();
                        $loc['street_address'] = $dao->street_address;
                        $loc['city'] = $dao->city;
                        $loc['state_province'] = CRM_Utils_Array::value($dao->state_province_id, $stateProvince);
                        $loc['postal_code'] = $dao->postal_code;
                        $entityTokenParams["{$tokenEntity}." . $field] = CRM_Utils_Address::format($loc);
                    } elseif ($field == 'info_url') {
                        $entityTokenParams["{$tokenEntity}." . $field] = CRM_Utils_System::url('civicrm/event/info', 'reset=1&id=' . $dao->event_id, TRUE, NULL, FALSE);
                    } elseif ($field == 'registration_url') {
                        $entityTokenParams["{$tokenEntity}." . $field] = CRM_Utils_System::url('civicrm/event/register', 'reset=1&id=' . $dao->event_id, TRUE, NULL, FALSE);
                    } elseif (in_array($field, array('start_date', 'end_date', 'join_date', 'activity_date_time'))) {
                        $entityTokenParams["{$tokenEntity}." . $field] = CRM_Utils_Date::customFormat($dao->{$field});
                    } elseif ($field == 'balance') {
                        $info = CRM_Contribute_BAO_Contribution::getPaymentInfo($dao->entityID, 'event');
                        $balancePay = CRM_Utils_Array::value('balance', $info);
                        $balancePay = CRM_Utils_Money::format($balancePay);
                        $entityTokenParams["{$tokenEntity}." . $field] = $balancePay;
                    } elseif ($field == 'fee_amount') {
                        $entityTokenParams["{$tokenEntity}." . $field] = CRM_Utils_Money::format($dao->{$field});
                    } else {
                        $entityTokenParams["{$tokenEntity}." . $field] = $dao->{$field};
                    }
                }
                $isError = 0;
                $errorMsg = $toEmail = $toPhoneNumber = '';
                if ($actionSchedule->mode == 'SMS' or $actionSchedule->mode == 'User_Preference') {
                    $filters = array('is_deceased' => 0, 'is_deleted' => 0, 'do_not_sms' => 0);
                    $toPhoneNumbers = CRM_Core_BAO_Phone::allPhones($dao->contactID, FALSE, 'Mobile', $filters);
                    //to get primary mobile ph,if not get a first mobile phONE
                    if (!empty($toPhoneNumbers)) {
                        $toPhoneNumberDetails = reset($toPhoneNumbers);
                        $toPhoneNumber = CRM_Utils_Array::value('phone', $toPhoneNumberDetails);
                        //contact allows to send sms
                        $toDoNotSms = 0;
                    }
                }
                if ($actionSchedule->mode == 'Email' or $actionSchedule->mode == 'User_Preference') {
                    $toEmail = CRM_Contact_BAO_Contact::getPrimaryEmail($dao->contactID);
                }
                if ($toEmail || !(empty($toPhoneNumber) or $toDoNotSms)) {
                    $to['email'] = $toEmail;
                    $to['phone'] = $toPhoneNumber;
                    $result = CRM_Core_BAO_ActionSchedule::sendReminder($dao->contactID, $to, $actionSchedule->id, $fromEmailAddress, $entityTokenParams);
                    if (!$result || is_a($result, 'PEAR_Error')) {
                        // we could not send an email, for now we ignore, CRM-3406
                        $isError = 1;
                    }
                } else {
                    $isError = 1;
                    $errorMsg = "Couldn\\'t find recipient\\'s email address.";
                }
                // update action log record
                $logParams = array('id' => $dao->reminderID, 'is_error' => $isError, 'message' => $errorMsg ? $errorMsg : "null", 'action_date_time' => $now);
                CRM_Core_BAO_ActionLog::create($logParams);
                // insert activity log record if needed
                if ($actionSchedule->record_activity) {
                    $activityParams = array('subject' => $actionSchedule->title, 'details' => $actionSchedule->body_html, 'source_contact_id' => $session->get('userID') ? $session->get('userID') : $dao->contactID, 'target_contact_id' => $dao->contactID, 'activity_date_time' => date('YmdHis'), 'status_id' => $activityStatusID, 'activity_type_id' => $activityTypeID, 'source_record_id' => $dao->entityID);
                    $activity = CRM_Activity_BAO_Activity::create($activityParams);
                }
            }
            $dao->free();
        }
    }
开发者ID:ruchirapingale,项目名称:civicrm-core,代码行数:101,代码来源:ActionSchedule.php


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