本文整理汇总了PHP中CRM_Contact_BAO_Contact::getContactDetails方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Contact_BAO_Contact::getContactDetails方法的具体用法?PHP CRM_Contact_BAO_Contact::getContactDetails怎么用?PHP CRM_Contact_BAO_Contact::getContactDetails使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Contact_BAO_Contact
的用法示例。
在下文中一共展示了CRM_Contact_BAO_Contact::getContactDetails方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: postProcess
static function postProcess(&$form)
{
$values = $form->exportValues();
$teamId = $values['pcp_team_contact'];
$teampcpId = CRM_Pcpteams_Utils::getPcpIdByContactAndEvent($form->get('component_page_id'), $teamId);
$userId = CRM_Pcpteams_Utils::getloggedInUserId();
// Create Team Member of relation to this Team
$cfpcpab = CRM_Pcpteams_Utils::getPcpABCustomFieldId();
$cfpcpba = CRM_Pcpteams_Utils::getPcpBACustomFieldId();
$customParams = array("custom_{$cfpcpab}" => $form->get('page_id'), "custom_{$cfpcpba}" => $teampcpId);
CRM_Pcpteams_Utils::createTeamRelationship($userId, $teamId, $customParams);
$form->_teamName = CRM_Contact_BAO_Contact::displayName($teamId);
$form->set('teamName', $form->_teamName);
$form->set('teamContactID', $teamId);
$form->set('teamPcpId', $teampcpId);
$teamAdminId = CRM_Pcpteams_Utils::getTeamAdmin($teampcpId);
// Team Join: create activity
$actParams = array('target_contact_id' => $teamId, 'assignee_contact_id' => $teamAdminId);
CRM_Pcpteams_Utils::createPcpActivity($actParams, CRM_Pcpteams_Constant::C_AT_REQ_MADE);
CRM_Core_Session::setStatus(ts('A notification has been sent to the team. Once approved, team should be visible on your page.'), ts('Team Request Sent'));
//send email once the team request has done.
list($teamAdminName, $teamAdminEmail) = CRM_Contact_BAO_Contact::getContactDetails($teamAdminId);
$contactDetails = civicrm_api('Contact', 'get', array('version' => 3, 'sequential' => 1, 'id' => $userId));
$emailParams = array('tplParams' => array('teamAdminName' => $teamAdminName, 'userFirstName' => $contactDetails['values'][0]['first_name'], 'userlastName' => $contactDetails['values'][0]['last_name'], 'teamName' => $form->_teamName, 'pageURL' => CRM_Utils_System::url('civicrm/pcp/manage', "reset=1&id={$teampcpId}", TRUE, NULL, FALSE, TRUE)), 'email' => array($teamAdminName => array('first_name' => $teamAdminName, 'last_name' => $teamAdminName, 'email-Primary' => $teamAdminEmail, 'display_name' => $teamAdminName)), 'valueName' => CRM_Pcpteams_Constant::C_MSG_TPL_JOIN_REQUEST);
$sendEmail = CRM_Pcpteams_Utils::sendMail($userId, $emailParams);
}
示例2: run
/**
* Run the page.
*
* This method is called after the page is created.
*
* @return void
* @access public
*
*/
function run()
{
// get the callback, module and activity id
$action = CRM_Utils_Request::retrieve('action', $this, false, 'browse');
$id = CRM_Utils_Request::retrieve('id', $this);
$dao =& new CRM_Core_DAO_ActivityHistory();
$dao->activity_id = $id;
$dao->activity_type = ts('Email Sent');
if ($dao->find(true)) {
$cid = $dao->entity_id;
}
$dao =& new CRM_Core_DAO_EmailHistory();
$dao->id = $id;
if ($dao->find(true)) {
// get the display name and email for the contact
list($toContactName, $toContactEmail, $toDoNotEmail) = CRM_Contact_BAO_Contact::getContactDetails($cid);
if (!trim($toContactName)) {
$toContactName = $toContactEmail;
}
if (trim($toContactEmail)) {
$toContactName = "\"{$toContactName}\" <{$toContactEmail}>";
}
$this->assign('toName', $toContactName);
// get the display name and email for the contact
list($fromContactName, $fromContactEmail, $toDoNotEmail) = CRM_Contact_BAO_Contact::getContactDetails($dao->contact_id);
if (!trim($fromContactEmail)) {
CRM_Utils_System::statusBounce(ts('Your user record does not have a valid email address'));
}
if (!trim($fromContactName)) {
$fromContactName = $fromContactEmail;
}
$this->assign('fromName', "\"{$fromContactName}\" <{$fromContactEmail}>");
$this->assign('sentDate', $dao->sent_date);
$this->assign('subject', $dao->subject);
$this->assign('message', $dao->message);
// get the display name and images for the contact
list($displayName, $contactImage) = CRM_Contact_BAO_Contact::getDisplayAndImage($dao->contact_id);
CRM_Utils_System::setTitle($contactImage . ' ' . $displayName);
require_once 'CRM/Utils/Menu.php';
// also add the cid params to the Menu array
CRM_Utils_Menu::addParam('cid', $cid);
// create menus ..
$startWeight = CRM_Utils_Menu::getMaxWeight('civicrm/contact/view');
$startWeight++;
require_once 'CRM/Core/BAO/CustomGroup.php';
CRM_Core_BAO_CustomGroup::addMenuTabs(CRM_Contact_BAO_Contact::getContactType($cid), 'civicrm/contact/view/cd', $startWeight);
}
parent::run();
}
示例3: commonBuildQuickForm
/**
* @param $self
*/
public static function commonBuildQuickForm($self)
{
$contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $self);
if (!$contactId) {
$contactId = CRM_Utils_Request::retrieve('cid', 'Positive', CRM_Core_DAO::$_nullObject, FALSE, NULL, $_REQUEST);
}
$urlParams = "action=add&reset=1&cid={$contactId}&selectedChild=activity&atype=";
$activityTypes = $urls = array();
$emailTypeId = CRM_Core_OptionGroup::getValue('activity_type', 'Email', 'name');
$letterTypeId = CRM_Core_OptionGroup::getValue('activity_type', 'Print PDF Letter', 'name');
$SMSId = CRM_Core_OptionGroup::getValue('activity_type', 'Text Message (SMS)', 'label');
if (CRM_Utils_Mail::validOutBoundMail() && $contactId) {
list($name, $email, $doNotEmail, $onHold, $isDeseased) = CRM_Contact_BAO_Contact::getContactDetails($contactId);
if (!$doNotEmail && $email && !$isDeseased) {
$activityTypes = array($emailTypeId => ts('Send an Email'));
}
}
if ($contactId && CRM_SMS_BAO_Provider::activeProviderCount()) {
// Check for existence of a mobile phone and ! do not SMS privacy setting
$mobileTypeID = CRM_Core_OptionGroup::getValue('phone_type', 'Mobile', 'name');
list($name, $phone, $doNotSMS) = CRM_Contact_BAO_Contact_Location::getPhoneDetails($contactId, $mobileTypeID);
if (!$doNotSMS && $phone) {
$sendSMS = array($SMSId => ts('Send SMS'));
$activityTypes += $sendSMS;
}
}
// this returns activity types sorted by weight
$otherTypes = CRM_Core_PseudoConstant::activityType(FALSE);
$activityTypes += $otherTypes;
foreach (array_keys($activityTypes) as $typeId) {
if ($typeId == $emailTypeId) {
$urls[$typeId] = CRM_Utils_System::url('civicrm/activity/email/add', "{$urlParams}{$typeId}", FALSE, NULL, FALSE);
} elseif ($typeId == $SMSId) {
$urls[$typeId] = CRM_Utils_System::url('civicrm/activity/sms/add', "{$urlParams}{$typeId}", FALSE, NULL, FALSE);
} elseif ($typeId == $letterTypeId) {
$urls[$typeId] = CRM_Utils_System::url('civicrm/activity/pdf/add', "{$urlParams}{$typeId}", FALSE, NULL, FALSE);
} else {
$urls[$typeId] = CRM_Utils_System::url('civicrm/activity/add', "{$urlParams}{$typeId}", FALSE, NULL, FALSE);
}
}
$self->assign('activityTypes', $activityTypes);
$self->assign('urls', $urls);
$self->assign('suppressForm', TRUE);
}
示例4: run
/**
* Run the page.
*
* This method is called after the page is created.
*
* @return void
* @access public
*
*/
function run()
{
// get the callback, module and activity id
$action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'browse');
$id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
$dao = new CRM_Core_DAO_ActivityHistory();
$dao->activity_id = $id;
$dao->activity_type = ts('Email Sent');
if ($dao->find(TRUE)) {
$cid = $dao->entity_id;
}
$dao = new CRM_Core_DAO_EmailHistory();
$dao->id = $id;
if ($dao->find(TRUE)) {
// get the display name and email for the contact
list($toContactName, $toContactEmail, $toDoNotEmail) = CRM_Contact_BAO_Contact::getContactDetails($cid);
if (!trim($toContactName)) {
$toContactName = $toContactEmail;
}
if (trim($toContactEmail)) {
$toContactName = "\"{$toContactName}\" <{$toContactEmail}>";
}
$this->assign('toName', $toContactName);
// get the display name and email for the contact
list($fromContactName, $fromContactEmail, $toDoNotEmail) = CRM_Contact_BAO_Contact::getContactDetails($dao->contact_id);
if (!trim($fromContactEmail)) {
CRM_Core_Error::statusBounce(ts('Your user record does not have a valid email address'));
}
if (!trim($fromContactName)) {
$fromContactName = $fromContactEmail;
}
$this->assign('fromName', "\"{$fromContactName}\" <{$fromContactEmail}>");
$this->assign('sentDate', $dao->sent_date);
$this->assign('subject', $dao->subject);
$this->assign('message', $dao->message);
// get the display name and images for the contact
list($displayName, $contactImage) = CRM_Contact_BAO_Contact::getDisplayAndImage($dao->contact_id);
CRM_Utils_System::setTitle($contactImage . ' ' . $displayName);
// also add the cid params to the Menu array
CRM_Core_Menu::addParam('cid', $cid);
}
return parent::run();
}
示例5: buildQuickForm
public function buildQuickForm()
{
$contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
$urlParams = "action=add&reset=1&cid={$contactId}&selectedChild=activity&atype=";
$url = CRM_Utils_System::url('civicrm/contact/view/activity', $urlParams, false, null, false);
$activityTypes = array();
require_once 'CRM/Utils/Mail.php';
if (CRM_Utils_Mail::validOutBoundMail() && $contactId) {
require_once 'CRM/Contact/BAO/Contact.php';
list($name, $email, $doNotEmail, $onHold, $isDeseased) = CRM_Contact_BAO_Contact::getContactDetails($contactId);
if (!$doNotEmail && $email && !$isDeseased) {
$activityTypes = array('3' => ts('Send an Email'));
}
}
// this returns activity types sorted by weight
$otherTypes = CRM_Core_PseudoConstant::activityType(false);
$activityTypes += $otherTypes;
$this->assign('activityTypes', $activityTypes);
$this->assign('url', $url);
$this->assign('suppressForm', true);
}
示例6: buildQuickForm
public function buildQuickForm()
{
$this->applyFilter('__ALL__', 'trim');
$contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
$urlParams = "action=add&reset=1&cid={$contactId}&selectedChild=activity&atype=";
$url = CRM_Utils_System::url('civicrm/contact/view/activity', $urlParams, false, null, false);
$activityType = CRM_Core_PseudoConstant::activityType(false);
$this->assign('emailSetting', false);
require_once 'CRM/Utils/Mail.php';
if (CRM_Utils_Mail::validOutBoundMail() && $contactId) {
$this->assign('emailSetting', true);
require_once 'CRM/Contact/BAO/Contact.php';
list($name, $email, $doNotEmail, $onHold, $isDeseased) = CRM_Contact_BAO_Contact::getContactDetails($contactId);
if (!$doNotEmail && $email && !$isDeseased) {
$activityType += array('3' => ts('Send an Email'));
}
}
$this->applyFilter('__ALL__', 'trim');
$this->add('select', 'other_activity', ts('Other Activities'), array('' => ts('- new activity -')) + $activityType, false, array('onchange' => "if (this.value) window.location='{$url}'+ this.value; else return false"));
$this->assign('suppressForm', true);
}
示例7: 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(' ', $status));
}
}
示例8: postProcess
/**
* Process the form submission.
*/
function postProcess()
{
$formValues = $this->exportValues();
$buttonName = $this->controller->getButtonName();
if ($buttonName == $this->_testButtonName) {
$session = CRM_Core_Session::singleton();
$userID = $session->get('userID');
list($toDisplayName, $toEmail, $toDoNotEmail) = CRM_Contact_BAO_Contact::getContactDetails($userID);
//get the default domain email address.CRM-4250
list($domainEmailName, $domainEmailAddress) = CRM_Core_BAO_Domain::getNameAndEmail();
if (!$domainEmailAddress || $domainEmailAddress == 'info@EXAMPLE.ORG') {
$fixUrl = CRM_Utils_System::url("civicrm/admin/domain", 'action=update&reset=1');
CRM_Core_Error::fatal(ts('The site administrator needs to enter a valid \'FROM Email Address\' in <a href="%1">Administer CiviCRM » Communications » FROM Email Addresses</a>. The email address used may need to be a valid mail account with your email service provider.', array(1 => $fixUrl)));
}
if (!$toEmail) {
CRM_Core_Error::statusBounce(ts('Cannot send a test email because your user record does not have a valid email address.'));
}
if (!trim($toDisplayName)) {
$toDisplayName = $toEmail;
}
$testMailStatusMsg = ts('Sending test email. FROM: %1 TO: %2.<br />', array(1 => $domainEmailAddress, 2 => $toEmail));
$params = array();
$message = "SMTP settings are correct.";
$params['host'] = $formValues['smtpServer'];
$params['port'] = $formValues['smtpPort'];
if ($formValues['smtpAuth']) {
$params['username'] = $formValues['smtpUsername'];
$params['password'] = $formValues['smtpPassword'];
$params['auth'] = TRUE;
} else {
$params['auth'] = FALSE;
}
// set the localhost value, CRM-3153, CRM-9332
$params['localhost'] = $_SERVER['SERVER_NAME'];
// also set the timeout value, lets set it to 30 seconds
// CRM-7510, CRM-9332
$params['timeout'] = 30;
$mailerName = 'smtp';
$headers = array('From' => '"' . $domainEmailName . '" <' . $domainEmailAddress . '>', 'To' => '"' . $toDisplayName . '"' . "<{$toEmail}>", 'Subject' => "Test for SMTP settings");
$mailer = Mail::factory($mailerName, $params);
$config = CRM_Core_Config::singleton();
if (property_exists($config, 'civiVersion')) {
$civiVersion = $config->civiVersion;
} else {
$civiVersion = CRM_Core_BAO_Domain::version();
}
if (version_compare('4.5alpha1', $civiVersion) > 0) {
CRM_Core_Error::ignoreException();
} else {
$errorScope = CRM_Core_TemporaryErrorScope::ignoreException();
}
$result = $mailer->send($toEmail, $headers, $message);
if (version_compare('4.5alpha1', $civiVersion) > 0) {
CRM_Core_Error::setCallback();
} else {
unset($errorScope);
}
if (!is_a($result, 'PEAR_Error')) {
CRM_Core_Session::setStatus($testMailStatusMsg . ts('Your %1 settings are correct. A test email has been sent to your email address.', array(1 => strtoupper($mailerName))), ts("Mail Sent"), "success");
} else {
$message = CRM_Utils_Mail::errorMessage($mailer, $result);
CRM_Core_Session::setStatus($testMailStatusMsg . ts('Oops. Your %1 settings are incorrect. No test mail has been sent.', array(1 => strtoupper($mailerName))) . $message, ts("Mail Not Sent"), "error");
}
}
// if password is present, encrypt it
if (!empty($formValues['smtpPassword'])) {
$formValues['smtpPassword'] = CRM_Utils_Crypt::encrypt($formValues['smtpPassword']);
}
CRM_Core_BAO_Setting::setItem($formValues, CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME, 'mandrill_smtp_settings');
}
示例9: postProcess
/**
* Process the form submission.
*/
public function postProcess()
{
// flush caches so we reload details for future requests
// CRM-11967
CRM_Utils_System::flushCache();
$formValues = $this->controller->exportValues($this->_name);
$buttonName = $this->controller->getButtonName();
// check if test button
if ($buttonName == $this->_testButtonName) {
if ($formValues['outBound_option'] == CRM_Mailing_Config::OUTBOUND_OPTION_DISABLED) {
CRM_Core_Session::setStatus(ts('You have selected "Disable Outbound Email". A test email can not be sent.'), ts("Email Disabled"), "error");
} elseif ($formValues['outBound_option'] == CRM_Mailing_Config::OUTBOUND_OPTION_REDIRECT_TO_DB) {
CRM_Core_Session::setStatus(ts('You have selected "Redirect to Database". A test email can not be sent.'), ts("Email Disabled"), "error");
} else {
$session = CRM_Core_Session::singleton();
$userID = $session->get('userID');
list($toDisplayName, $toEmail, $toDoNotEmail) = CRM_Contact_BAO_Contact::getContactDetails($userID);
//get the default domain email address.CRM-4250
list($domainEmailName, $domainEmailAddress) = CRM_Core_BAO_Domain::getNameAndEmail();
if (!$domainEmailAddress || $domainEmailAddress == 'info@EXAMPLE.ORG') {
$fixUrl = CRM_Utils_System::url("civicrm/admin/domain", 'action=update&reset=1');
CRM_Core_Error::fatal(ts('The site administrator needs to enter a valid \'FROM Email Address\' in <a href="%1">Administer CiviCRM » Communications » FROM Email Addresses</a>. The email address used may need to be a valid mail account with your email service provider.', array(1 => $fixUrl)));
}
if (!$toEmail) {
CRM_Core_Error::statusBounce(ts('Cannot send a test email because your user record does not have a valid email address.'));
}
if (!trim($toDisplayName)) {
$toDisplayName = $toEmail;
}
$to = '"' . $toDisplayName . '"' . "<{$toEmail}>";
$from = '"' . $domainEmailName . '" <' . $domainEmailAddress . '>';
$testMailStatusMsg = ts('Sending test email. FROM: %1 TO: %2.<br />', array(1 => $domainEmailAddress, 2 => $toEmail));
$params = array();
if ($formValues['outBound_option'] == CRM_Mailing_Config::OUTBOUND_OPTION_SMTP) {
$subject = "Test for SMTP settings";
$message = "SMTP settings are correct.";
$params['host'] = $formValues['smtpServer'];
$params['port'] = $formValues['smtpPort'];
if ($formValues['smtpAuth']) {
$params['username'] = $formValues['smtpUsername'];
$params['password'] = $formValues['smtpPassword'];
$params['auth'] = TRUE;
} else {
$params['auth'] = FALSE;
}
// set the localhost value, CRM-3153, CRM-9332
$params['localhost'] = $_SERVER['SERVER_NAME'];
// also set the timeout value, lets set it to 30 seconds
// CRM-7510, CRM-9332
$params['timeout'] = 30;
$mailerName = 'smtp';
} elseif ($formValues['outBound_option'] == CRM_Mailing_Config::OUTBOUND_OPTION_SENDMAIL) {
$subject = "Test for Sendmail settings";
$message = "Sendmail settings are correct.";
$params['sendmail_path'] = $formValues['sendmail_path'];
$params['sendmail_args'] = $formValues['sendmail_args'];
$mailerName = 'sendmail';
} elseif ($formValues['outBound_option'] == CRM_Mailing_Config::OUTBOUND_OPTION_MAIL) {
$subject = "Test for PHP mail settings";
$message = "mail settings are correct.";
$mailerName = 'mail';
}
$headers = array('From' => $from, 'To' => $to, 'Subject' => $subject);
$mailer = Mail::factory($mailerName, $params);
$errorScope = CRM_Core_TemporaryErrorScope::ignoreException();
$result = $mailer->send($toEmail, $headers, $message);
unset($errorScope);
if (!is_a($result, 'PEAR_Error')) {
CRM_Core_Session::setStatus($testMailStatusMsg . ts('Your %1 settings are correct. A test email has been sent to your email address.', array(1 => strtoupper($mailerName))), ts("Mail Sent"), "success");
} else {
$message = CRM_Utils_Mail::errorMessage($mailer, $result);
CRM_Core_Session::setStatus($testMailStatusMsg . ts('Oops. Your %1 settings are incorrect. No test mail has been sent.', array(1 => strtoupper($mailerName))) . $message, ts("Mail Not Sent"), "error");
}
}
}
$mailingBackend = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME, 'mailing_backend');
if (!empty($mailingBackend)) {
CRM_Core_BAO_ConfigSetting::formatParams($formValues, $mailingBackend);
}
// if password is present, encrypt it
if (!empty($formValues['smtpPassword'])) {
$formValues['smtpPassword'] = CRM_Utils_Crypt::encrypt($formValues['smtpPassword']);
}
CRM_Core_BAO_Setting::setItem($formValues, CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME, 'mailing_backend');
}
示例10: postProcess
//.........这里部分代码省略.........
$participantCount = array();
foreach ($lineItem as $k) {
foreach ($k as $v) {
if (CRM_Utils_Array::value('participant_count', $v) > 0) {
$participantCount[] = $v['participant_count'];
}
}
}
}
if (isset($participantCount)) {
$this->assign('pricesetFieldsCount', $participantCount);
}
$this->assign('lineItem', empty($lineItem[0]) || $this->_quickConfig ? FALSE : $lineItem);
} else {
$this->assign('amount_level', $params['amount_level']);
}
}
$this->_params = $params;
$amountOwed = NULL;
if (isset($params['amount'])) {
$amountOwed = $params['amount'];
unset($params['amount']);
}
$params['register_date'] = CRM_Utils_Date::processDate($params['register_date'], $params['register_date_time']);
$params['receive_date'] = CRM_Utils_Date::processDate(CRM_Utils_Array::value('receive_date', $params), CRM_Utils_Array::value('receive_date_time', $params));
$params['contact_id'] = $this->_contactId;
// overwrite actual payment amount if entered
if (!empty($params['total_amount'])) {
$contributionParams['total_amount'] = CRM_Utils_Array::value('total_amount', $params);
}
// Retrieve the name and email of the current user - this will be the FROM for the receipt email
$userName = CRM_Core_Session::singleton()->getLoggedInContactDisplayName();
if ($this->_contactId) {
list($this->_contributorDisplayName, $this->_contributorEmail, $this->_toDoNotEmail) = CRM_Contact_BAO_Contact::getContactDetails($this->_contactId);
}
//modify params according to parameter used in create
//participant method (addParticipant)
$this->_params['participant_status_id'] = $params['status_id'];
$this->_params['participant_role_id'] = is_array($params['role_id']) ? $params['role_id'] : explode(',', $params['role_id']);
$this->_params['participant_register_date'] = $params['register_date'];
$roleIdWithSeparator = implode(CRM_Core_DAO::VALUE_SEPARATOR, $this->_params['participant_role_id']);
if ($this->_mode) {
if (!$this->_isPaidEvent) {
CRM_Core_Error::fatal(ts('Selected Event is not Paid Event '));
}
$eventTitle = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $params['event_id'], 'title');
// set source if not set
if (empty($params['source'])) {
$this->_params['participant_source'] = ts('Offline Registration for Event: %2 by: %1', array(1 => $userName, 2 => $eventTitle));
} else {
$this->_params['participant_source'] = $params['source'];
}
$this->_params['description'] = $this->_params['participant_source'];
$this->_paymentProcessor = CRM_Financial_BAO_PaymentProcessor::getPayment($this->_params['payment_processor_id'], $this->_mode);
$now = date('YmdHis');
$fields = array();
// set email for primary location.
$fields['email-Primary'] = 1;
$params['email-Primary'] = $params["email-{$this->_bltID}"] = $this->_contributorEmail;
$params['register_date'] = $now;
// now set the values for the billing location.
foreach ($this->_fields as $name => $dontCare) {
$fields[$name] = 1;
}
// also add location name to the array
$params["address_name-{$this->_bltID}"] = CRM_Utils_Array::value('billing_first_name', $params) . ' ' . CRM_Utils_Array::value('billing_middle_name', $params) . ' ' . CRM_Utils_Array::value('billing_last_name', $params);
示例11: 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;
}
示例12: postProcess
//.........这里部分代码省略.........
$this->assign('address', CRM_Utils_Address::format($addressFields));
$date = CRM_Utils_Date::format($params['credit_card_exp_date']);
$date = CRM_Utils_Date::mysqlToIso($date);
$this->assign('credit_card_exp_date', $date);
$this->assign('credit_card_number', CRM_Utils_System::mungeCreditCard($params['credit_card_number']));
$this->assign('credit_card_type', $params['credit_card_type']);
$this->assign('contributeMode', 'direct');
$this->assign('isAmountzero', 0);
$this->assign('is_pay_later', 0);
$this->assign('isPrimary', 1);
}
$this->assign('register_date', $params['register_date']);
if ($params['receive_date']) {
$this->assign('receive_date', $params['receive_date']);
}
$participant = array(array('participant_id', '=', $participants[0]->id, 0, 0));
// check whether its a test drive ref CRM-3075
if (CRM_Utils_Array::value('is_test', $this->_defaultValues)) {
$participant[] = array('participant_test', '=', 1, 0, 0);
}
$template =& CRM_Core_Smarty::singleton();
$customGroup = array();
//format submitted data
foreach ($params['custom'] as $fieldID => $values) {
foreach ($values as $fieldValue) {
$customValue = array('data' => $fieldValue['value']);
$customFields[$fieldID]['id'] = $fieldID;
$formattedValue = CRM_Core_BAO_CustomGroup::formatCustomValues($customValue, $customFields[$fieldID]);
$customGroup[$customFields[$fieldID]['groupTitle']][$customFields[$fieldID]['label']] = str_replace(' ', '', $formattedValue);
}
}
foreach ($this->_contactIds as $num => $contactID) {
// Retrieve the name and email of the contact - this will be the TO for receipt email
list($this->_contributorDisplayName, $this->_contributorEmail, $this->_toDoNotEmail) = CRM_Contact_BAO_Contact::getContactDetails($contactID);
$this->_contributorDisplayName = $this->_contributorDisplayName == ' ' ? $this->_contributorEmail : $this->_contributorDisplayName;
$this->assign('customGroup', $customGroup);
$this->assign('contactID', $contactID);
$this->assign('participantID', $participants[$num]->id);
if ($this->_isPaidEvent) {
// fix amount for each of participants ( for bulk mode )
$eventAmount = array();
$eventAmount[$num] = array('label' => $params['amount_level'], 'amount' => $params['fee_amount']);
//as we are using same template for online & offline registration.
//So we have to build amount as array.
$this->assign('amount', $eventAmount);
}
$sendTemplateParams = array('groupName' => 'msg_tpl_workflow_event', 'valueName' => 'event_offline_receipt', 'contactId' => $contactID, 'isTest' => (bool) CRM_Utils_Array::value('is_test', $this->_defaultValues));
// try to send emails only if email id is present
// and the do-not-email option is not checked for that contact
if ($this->_contributorEmail and !$this->_toDoNotEmail) {
$sendTemplateParams['from'] = $receiptFrom;
$sendTemplateParams['toName'] = $this->_contributorDisplayName;
$sendTemplateParams['toEmail'] = $this->_contributorEmail;
}
require_once 'CRM/Core/BAO/MessageTemplates.php';
list($mailSent, $subject, $message, $html) = CRM_Core_BAO_MessageTemplates::sendTemplate($sendTemplateParams);
if ($mailSent) {
$sent[] = $contactID;
} else {
$notSent[] = $contactID;
}
}
}
if ($this->_action & CRM_Core_Action::UPDATE) {
$statusMsg = ts('Event registration information for %1 has been updated.', array(1 => $this->_contributorDisplayName));
if ($params['send_receipt'] && count($sent)) {
示例13: postProcess
/**
* Function to process the form
*
* @access public
* @return None
*/
public function postProcess()
{
$formValues = $this->controller->exportValues($this->_name);
$buttonName = $this->controller->getButtonName();
// check if test button
if ($buttonName == $this->_testButtonName) {
if ($formValues['outBound_option'] == 2) {
CRM_Core_Session::setStatus(ts('You have selected "Disable Outbound Email". A test email can not be sent.'));
} else {
$session =& CRM_Core_Session::singleton();
$userID = $session->get('userID');
require_once 'CRM/Contact/BAO/Contact.php';
list($toDisplayName, $toEmail, $toDoNotEmail) = CRM_Contact_BAO_Contact::getContactDetails($userID);
//get the default domain email address.CRM-4250
require_once 'CRM/Core/BAO/Domain.php';
list($domainEmailName, $domainEmailAddress) = CRM_Core_BAO_Domain::getNameAndEmail();
if (!$domainEmailAddress || $domainEmailAddress == 'info@FIXME.ORG') {
require_once 'CRM/Utils/System.php';
$fixUrl = CRM_Utils_System::url("civicrm/admin/domain", 'action=update&reset=1');
CRM_Core_Error::fatal(ts('The site administrator needs to enter a valid \'FROM Email Address\' in <a href="%1">Administer CiviCRM » Configure » Domain Information</a>. The email address used may need to be a valid mail account with your email service provider.', array(1 => $fixUrl)));
}
if (!$toEmail) {
CRM_Core_Error::statusBounce(ts('Cannot send a test email because your user record does not have a valid email address.'));
}
if (!trim($toDisplayName)) {
$toDisplayName = $toEmail;
}
$to = '"' . $toDisplayName . '"' . "<{$toEmail}>";
$from = '"' . $domainEmailName . '" <' . $domainEmailAddress . '>';
$testMailStatusMsg = ts('Sending test email. FROM: %1 TO: %2.<br />', array(1 => $domainEmailAddress, 2 => $toEmail));
if ($formValues['outBound_option'] == 0) {
$subject = "Test for SMTP settings";
$message = "SMTP settings are correct.";
$params['host'] = $formValues['smtpServer'];
$params['port'] = $formValues['smtpPort'];
if ($formValues['smtpAuth']) {
$params['username'] = $formValues['smtpUsername'];
$params['password'] = $formValues['smtpPassword'];
$params['auth'] = true;
} else {
$params['auth'] = false;
}
$mailerName = 'smtp';
} elseif ($formValues['outBound_option'] == 1) {
$subject = "Test for Sendmail settings";
$message = "Sendmail settings are correct.";
$params['sendmail_path'] = $formValues['sendmail_path'];
$params['sendmail_args'] = $formValues['sendmail_args'];
$mailerName = 'sendmail';
}
$headers = array('From' => $from, 'To' => $to, 'Subject' => $subject);
$mailer =& Mail::factory($mailerName, $params);
CRM_Core_Error::ignoreException();
$result = $mailer->send($toEmail, $headers, $message);
if (!is_a($result, 'PEAR_Error')) {
CRM_Core_Session::setStatus($testMailStatusMsg . ts('Your %1 settings are correct. A test email has been sent to your email address.', array(1 => strtoupper($mailerName))));
} else {
$message = CRM_Utils_Mail::errorMessage($mailer, $result);
CRM_Core_Session::setStatus($testMailStatusMsg . ts('Oops. Your %1 settings are incorrect. No test mail has been sent.', array(1 => strtoupper($mailerName))) . $message);
}
}
}
$mailingDomain =& new CRM_Core_DAO_Preferences();
$mailingDomain->domain_id = CRM_Core_Config::domainID();
$mailingDomain->is_domain = true;
$mailingDomain->find(true);
if ($mailingDomain->mailing_backend) {
$values = unserialize($mailingDomain->mailing_backend);
CRM_Core_BAO_Setting::formatParams($formValues, $values);
}
// if password is present, encrypt it
if (!empty($formValues['smtpPassword'])) {
require_once 'CRM/Utils/Crypt.php';
$formValues['smtpPassword'] = CRM_Utils_Crypt::encrypt($formValues['smtpPassword']);
}
$mailingDomain->mailing_backend = serialize($formValues);
$mailingDomain->save();
}
示例14: sendMessage
/**
* send the message to a specific contact
*
* @param string $from the name and email of the sender
* @param int $toID the contact id of the recipient
* @param string $subject the subject of the message
* @param string $message the message contents
* @param string $emailAddress use this 'to' email address instead of the default Primary address
* @param int $activityID the activity ID that tracks the message
*
* @return boolean true if successfull else false.
* @access public
* @static
*/
function sendMessage($from, $toID, &$subject, &$message, $emailAddress, $activityID)
{
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;
}
if (!CRM_Utils_Mail::send($from, $toDisplayName, $toEmail, $subject, $message)) {
return false;
}
// we need to insert an activity history record here
$params = array('entity_table' => 'civicrm_contact', 'entity_id' => $toID, 'activity_type' => ts('Email Sent'), 'module' => 'CiviCRM', 'callback' => 'CRM_Core_BAO_EmailHistory::showEmailDetails', 'activity_id' => $activityID, 'activity_summary' => ts('To: %1; Subject: %2', array(1 => "{$toDisplayName} <{$toEmail}>", 2 => $subject)), 'activity_date' => date('YmdHis'));
if (is_a(crm_create_activity_history($params), CRM_Core_Error)) {
return false;
}
return true;
}
示例15: sendMail
static function sendMail($contactID, &$values)
{
list($fromName, $email) = CRM_Contact_BAO_Contact::getContactDetails($contactID);
// if no $fromName (only email collected from originating contact) - list returns single space
if (trim($fromName) == '') {
$fromName = $email;
}
// use contact email, CRM-4963
if (empty($values['email_from'])) {
$values['email_from'] = $email;
}
$tplParams = array();
if (isset($values['tplParams'])) {
$tplParams = $values['tplParams'];
}
$sent = FALSE;
foreach ($values['email'] as $key => $emailDetails) {
if ($emailDetails['email-Primary']) {
// FIXME: factor the below out of the foreach loop
$tplParams['inviteeFirstName'] = $emailDetails['first_name'];
$tplParams['inviteeEmail'] = $emailDetails['email-Primary'];
list($sent, $subject, $text, $html) = CRM_Core_BAO_MessageTemplate::sendTemplate(array('groupName' => CRM_Pcpteams_Constant::C_OG_MSG_TPL_WORKFLOW, 'valueName' => $values['valueName'], 'contactId' => $contactID, 'tplParams' => $tplParams, 'from' => "{$fromName} <{$values['email_from']}>", 'toName' => $emailDetails['display_name'], 'toEmail' => $emailDetails['email-Primary'], 'replyTo' => $email));
}
}
return $sent ? TRUE : FALSE;
}