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


PHP CRM_Core_BAO_Domain::getCurrentDomain方法代码示例

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


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

示例1: dataRule

 /**
  * Function for validation
  *
  * @param array $params (ref.) an assoc array of name/value pairs
  *
  * @return mixed true or array of errors
  * @access public
  * @static
  */
 function dataRule(&$params, &$files, &$options)
 {
     if (CRM_Utils_Array::value('_qf_Import_refresh', $_POST)) {
         return true;
     }
     $errors = array();
     require_once 'CRM/Core/BAO/Domain.php';
     $domain =& CRM_Core_BAO_Domain::getCurrentDomain();
     $mailing = null;
     $session =& CRM_Core_Session::singleton();
     $values = array('contact_id' => $session->get('userID'));
     $contact = array();
     $ids = array();
     CRM_Contact_BAO_Contact::retrieve($values, $contact, $id);
     $verp = array_flip(array('optOut', 'reply', 'unsubscribe', 'owner'));
     foreach ($verp as $key => $value) {
         $verp[$key]++;
     }
     $urls = array_flip(array('forward'));
     foreach ($urls as $key => $value) {
         $urls[$key]++;
     }
     require_once 'CRM/Mailing/BAO/Component.php';
     $header =& new CRM_Mailing_BAO_Component();
     $header->id = $params['header_id'];
     $header->find(true);
     $footer =& new CRM_Mailing_BAO_Component();
     $footer->id = $params['footer_id'];
     $footer->find(true);
     list($headerBody['htmlFile'], $headerBody['textFile']) = array($header->body_html, $header->body_text);
     list($footerBody['htmlFile'], $footerBody['textFile']) = array($footer->body_html, $footer->body_text);
     require_once 'CRM/Utils/Token.php';
     if (!file_exists($files['textFile']['tmp_name'])) {
         $errors['textFile'] = ts('Please provide at least the text message.');
     }
     foreach (array('textFile', 'htmlFile') as $file) {
         if (!file_exists($files[$file]['tmp_name'])) {
             continue;
         }
         $str = file_get_contents($files[$file]['tmp_name']);
         $name = $files[$file]['name'];
         /* append header/footer */
         $str = $headerBody[$file] . $str . $footerBody[$file];
         $dataErrors = array();
         /* First look for missing tokens */
         $err = CRM_Utils_Token::requiredTokens($str);
         if ($err !== true) {
             foreach ($err as $token => $desc) {
                 $dataErrors[] = '<li>' . ts('Missing required token') . ' {' . $token . "}: {$desc}</li>";
             }
         }
         /* Do a full token replacement on a dummy verp, the current contact
          * and domain. */
         $str = CRM_Utils_Token::replaceDomainTokens($str, $domain);
         $str = CRM_Utils_Token::replaceMailingTokens($str, $mailing);
         $str = CRM_Utils_Token::replaceActionTokens($str, $verp, $urls);
         $str = CRM_Utils_Token::replaceContactTokens($str, $contact);
         $unmatched = CRM_Utils_Token::unmatchedTokens($str);
         if (!empty($unmatched)) {
             foreach ($unmatched as $token) {
                 $dataErrors[] = '<li>' . ts('Invalid token code') . ' {' . $token . '}</li>';
             }
         }
         if (!empty($dataErrors)) {
             $errors[$file] = ts('The following errors were detected in %1:', array(1 => $name)) . ': <ul>' . implode('', $dataErrors) . '</ul>';
         }
     }
     return empty($errors) ? true : $errors;
 }
开发者ID:bhirsch,项目名称:voipdrupal-4.7-1.0,代码行数:78,代码来源:Upload.php

示例2: send_confirm_request

 /**
  * Ask a contact for subscription confirmation (opt-in)
  *
  * @param string $email         The email address
  * @return void
  * @access public
  */
 function send_confirm_request($email)
 {
     $config =& CRM_Core_Config::singleton();
     require_once 'CRM/Core/BAO/Domain.php';
     $domain =& CRM_Core_BAO_Domain::getCurrentDomain();
     require_once 'CRM/Utils/Verp.php';
     $confirm = CRM_Utils_Verp::encode(implode($config->verpSeparator, array('confirm', $this->contact_id, $this->id, $this->hash)) . "@{$domain->email_domain}", $email);
     require_once 'CRM/Contact/BAO/Group.php';
     $group =& new CRM_Contact_BAO_Group();
     $group->id = $this->group_id;
     $group->find(true);
     require_once 'CRM/Mailing/BAO/Component.php';
     $component =& new CRM_Mailing_BAO_Component();
     $component->domain_id = $domain->id;
     $component->is_default = 1;
     $component->is_active = 1;
     $component->component_type = 'Subscribe';
     $component->find(true);
     $headers = array('Subject' => $component->subject, 'From' => ts('"%1 Administrator" <do-not-reply@%2>', array(1 => $domain->name, 2 => $domain->email_domain)), 'To' => $email, 'Reply-To' => $confirm, 'Return-Path' => "do-not-reply@{$domain->email_domain}");
     $html = $component->body_html;
     require_once 'CRM/Utils/Token.php';
     $html = CRM_Utils_Token::replaceDomainTokens($html, $domain, true);
     $html = CRM_Utils_Token::replaceSubscribeTokens($html, $group->name, true);
     $text = $component->body_text;
     $text = CRM_Utils_Token::replaceDomainTokens($text, $domain, false);
     $text = CRM_Utils_Token::replaceSubscribeTokens($text, $group->name, false);
     $message =& new Mail_Mime("\n");
     $message->setHTMLBody($html);
     $message->setTxtBody($text);
     $b = $message->get();
     $h = $message->headers($headers);
     $mailer =& $config->getMailer();
     PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, array('CRM_Mailing_BAO_Mailing', 'catchSMTP'));
     $mailer->send($email, $h, $b);
     CRM_Core_Error::setCallback();
 }
开发者ID:bhirsch,项目名称:voipdrupal-4.7-1.0,代码行数:43,代码来源:Subscribe.php


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