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


PHP CRM_Mailing_BAO_Mailing::find方法代码示例

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


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

示例1: preProcess

 /**
  * Heart of the viewing process. The runner gets all the meta data for
  * the contact and calls the appropriate type of page to view.
  *
  * @return void
  * @access public
  *
  */
 function preProcess()
 {
     $this->_mailingId = CRM_Utils_Request::retrieve('mid', 'Positive', $this);
     $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this);
     // check for action permissions.
     if (!CRM_Core_Permission::checkActionPermission('CiviMail', $this->_action)) {
         CRM_Core_Error::fatal(ts('You do not have permission to access this page'));
     }
     require_once 'CRM/Mailing/BAO/Mailing.php';
     $mailing = new CRM_Mailing_BAO_Mailing();
     $mailing->id = $this->_mailingId;
     if ($mailing->find(true)) {
         $this->assign('subject', $mailing->subject);
     }
 }
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:23,代码来源:Browse.php

示例2: preProcess

 /**
  * Heart of the viewing process. The runner gets all the meta data for
  * the contact and calls the appropriate type of page to view.
  *
  * @return void
  */
 public function preProcess()
 {
     $this->_mailingId = CRM_Utils_Request::retrieve('mid', 'Positive', $this);
     $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this);
     // check for action permissions.
     if (!CRM_Core_Permission::checkActionPermission('CiviMail', $this->_action)) {
         CRM_Core_Error::fatal(ts('You do not have permission to access this page.'));
     }
     $mailing = new CRM_Mailing_BAO_Mailing();
     $mailing->id = $this->_mailingId;
     $subject = '';
     if ($mailing->find(TRUE)) {
         $subject = $mailing->subject;
     }
     $this->assign('subject', $subject);
 }
开发者ID:nganivet,项目名称:civicrm-core,代码行数:22,代码来源:Browse.php

示例3: run

 /** 
  * run this page (figure out the action needed and perform it).
  * 
  * @return void
  */
 function run()
 {
     require_once 'CRM/Mailing/BAO/Mailing.php';
     $session = CRM_Core_Session::singleton();
     $qfKey = CRM_Utils_Request::retrieve('qfKey', 'String', CRM_Core_DAO::$_nullObject, false, 'text');
     $type = CRM_Utils_Request::retrieve('type', 'String', CRM_Core_DAO::$_nullObject, false, 'text');
     $options = array();
     $session->getVars($options, "CRM_Mailing_Controller_Send_{$qfKey}");
     //get the options if control come from search context, CRM-3711
     if (empty($options)) {
         $session->getVars($options, "CRM_Contact_Controller_Search_{$qfKey}");
     }
     // FIXME: the below and CRM_Mailing_Form_Test::testMail()
     // should be refactored
     $fromEmail = null;
     $mailing = new CRM_Mailing_BAO_Mailing();
     if (!empty($options)) {
         $mailing->id = $options['mailing_id'];
         $fromEmail = CRM_Utils_Array::value('from_email', $options);
     }
     $mailing->find(true);
     CRM_Mailing_BAO_Mailing::tokenReplace($mailing);
     if (defined('CIVICRM_MAIL_SMARTY')) {
         require_once 'CRM/Core/Smarty/resources/String.php';
         civicrm_smarty_register_string_resource();
     }
     // get and format attachments
     require_once 'CRM/Core/BAO/File.php';
     $attachments =& CRM_Core_BAO_File::getEntityFile('civicrm_mailing', $mailing->id);
     //get details of contact with token value including Custom Field Token Values.CRM-3734
     $returnProperties = $mailing->getReturnProperties();
     $params = array('contact_id' => $session->get('userID'));
     $details = $mailing->getDetails($params, $returnProperties);
     $mime =& $mailing->compose(null, null, null, $session->get('userID'), $fromEmail, $fromEmail, true, $details[0][$session->get('userID')], $attachments);
     if ($type == 'html') {
         header('Content-Type: text/html; charset=utf-8');
         print $mime->getHTMLBody();
     } else {
         header('Content-Type: text/plain; charset=utf-8');
         print $mime->getTXTBody();
     }
     CRM_Utils_System::civiExit();
 }
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:48,代码来源:Preview.php

示例4: run

 /**
  * Run this page (figure out the action needed and perform it).
  *
  * @return void
  */
 public function run()
 {
     $session = CRM_Core_Session::singleton();
     $qfKey = CRM_Utils_Request::retrieve('qfKey', 'String', CRM_Core_DAO::$_nullObject, FALSE, 'text');
     $type = CRM_Utils_Request::retrieve('type', 'String', CRM_Core_DAO::$_nullObject, FALSE, 'text');
     $options = array();
     $session->getVars($options, "CRM_Mailing_Controller_Send_{$qfKey}");
     //get the options if control come from search context, CRM-3711
     if (empty($options)) {
         $session->getVars($options, "CRM_Contact_Controller_Search_{$qfKey}");
     }
     // FIXME: the below and CRM_Mailing_Form_Test::testMail()
     // should be refactored
     $fromEmail = NULL;
     $mailing = new CRM_Mailing_BAO_Mailing();
     if (!empty($options)) {
         $mailing->id = $options['mailing_id'];
         $fromEmail = CRM_Utils_Array::value('from_email', $options);
     }
     $mailing->find(TRUE);
     CRM_Mailing_BAO_Mailing::tokenReplace($mailing);
     // get and format attachments
     $attachments = CRM_Core_BAO_File::getEntityFile('civicrm_mailing', $mailing->id);
     //get details of contact with token value including Custom Field Token Values.CRM-3734
     $returnProperties = $mailing->getReturnProperties();
     $params = array('contact_id' => $session->get('userID'));
     $details = CRM_Utils_Token::getTokenDetails($params, $returnProperties, TRUE, TRUE, NULL, $mailing->getFlattenedTokens(), get_class($this));
     $mime =& $mailing->compose(NULL, NULL, NULL, $session->get('userID'), $fromEmail, $fromEmail, TRUE, $details[0][$session->get('userID')], $attachments);
     if ($type == 'html') {
         CRM_Utils_System::setHttpHeader('Content-Type', 'text/html; charset=utf-8');
         print $mime->getHTMLBody();
     } else {
         CRM_Utils_System::setHttpHeader('Content-Type', 'text/plain; charset=utf-8');
         print $mime->getTXTBody();
     }
     CRM_Utils_System::civiExit();
 }
开发者ID:utkarshsharma,项目名称:civicrm-core,代码行数:42,代码来源:Preview.php

示例5: formRule

 /**
  * Validation.
  *
  * @param array $params
  *   (ref.) an assoc array of name/value pairs.
  *
  * @param $files
  * @param $self
  *
  * @return bool|array
  *   mixed true or array of errors
  */
 public static function formRule($params, $files, $self)
 {
     if (!empty($_POST['_qf_Import_refresh'])) {
         return TRUE;
     }
     $errors = array();
     $template = CRM_Core_Smarty::singleton();
     if (isset($params['html_message'])) {
         $htmlMessage = str_replace(array("\n", "\r"), ' ', $params['html_message']);
         $htmlMessage = str_replace("'", "\\'", $htmlMessage);
         $template->assign('htmlContent', $htmlMessage);
     }
     $domain = CRM_Core_BAO_Domain::getDomain();
     $mailing = new CRM_Mailing_BAO_Mailing();
     $mailing->id = $self->_mailingID;
     $mailing->find(TRUE);
     $session = CRM_Core_Session::singleton();
     $values = array('contact_id' => $session->get('userID'), 'version' => 3);
     require_once 'api/api.php';
     $contact = civicrm_api('contact', 'get', $values);
     //CRM-4524
     $contact = reset($contact['values']);
     $verp = array_flip(array('optOut', 'reply', 'unsubscribe', 'resubscribe', 'owner'));
     foreach ($verp as $key => $value) {
         $verp[$key]++;
     }
     $urls = array_flip(array('forward', 'optOutUrl', 'unsubscribeUrl', 'resubscribeUrl'));
     foreach ($urls as $key => $value) {
         $urls[$key]++;
     }
     // set $header and $footer
     foreach (array('header', 'footer') as $part) {
         ${$part} = array();
         if ($params["{$part}_id"]) {
             //echo "found<p>";
             $component = new CRM_Mailing_BAO_Component();
             $component->id = $params["{$part}_id"];
             $component->find(TRUE);
             ${$part}['textFile'] = $component->body_text;
             ${$part}['htmlFile'] = $component->body_html;
             $component->free();
         } else {
             ${$part}['htmlFile'] = ${$part}['textFile'] = '';
         }
     }
     $skipTextFile = $self->get('skipTextFile');
     $skipHtmlFile = $self->get('skipHtmlFile');
     if (!$params['upload_type']) {
         if ((!isset($files['textFile']) || !file_exists($files['textFile']['tmp_name'])) && (!isset($files['htmlFile']) || !file_exists($files['htmlFile']['tmp_name']))) {
             if (!($skipTextFile || $skipHtmlFile)) {
                 $errors['textFile'] = ts('Please provide either a Text or HTML formatted message - or both.');
             }
         }
     } else {
         if (empty($params['text_message']) && empty($params['html_message'])) {
             $errors['html_message'] = ts('Please provide either a Text or HTML formatted message - or both.');
         }
         if (!empty($params['saveTemplate']) && empty($params['saveTemplateName'])) {
             $errors['saveTemplateName'] = ts('Please provide a Template Name.');
         }
     }
     foreach (array('text', 'html') as $file) {
         if (!$params['upload_type'] && !file_exists(CRM_Utils_Array::value('tmp_name', $files[$file . 'File']))) {
             continue;
         }
         if ($params['upload_type'] && !$params[$file . '_message']) {
             continue;
         }
         if (!$params['upload_type']) {
             $str = file_get_contents($files[$file . 'File']['tmp_name']);
             $name = $files[$file . 'File']['name'];
         } else {
             $str = $params[$file . '_message'];
             $str = $file == 'html' ? str_replace('%7B', '{', str_replace('%7D', '}', $str)) : $str;
             $name = $file . ' message';
         }
         /* append header/footer */
         $str = $header[$file . 'File'] . $str . $footer[$file . 'File'];
         $dataErrors = array();
         /* First look for missing tokens */
         if (!CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME, 'disable_mandatory_tokens_check')) {
             $err = CRM_Utils_Token::requiredTokens($str);
             if ($err !== TRUE) {
                 foreach ($err as $token => $desc) {
                     $dataErrors[] = '<li>' . ts('This message is missing a required token - {%1}: %2', array(1 => $token, 2 => $desc)) . '</li>';
                 }
             }
         }
//.........这里部分代码省略.........
开发者ID:BorislavZlatanov,项目名称:civicrm-core,代码行数:101,代码来源:Upload.php

示例6: civicrm_api3_mailing_preview

/**
 * Preview mailing.
 *
 * @param array $params
 *   Array per getfields metadata.
 *
 * @return array
 * @throws \API_Exception
 */
function civicrm_api3_mailing_preview($params)
{
    civicrm_api3_verify_mandatory($params, 'CRM_Mailing_DAO_Mailing', array('id'), FALSE);
    $fromEmail = NULL;
    if (!empty($params['from_email'])) {
        $fromEmail = $params['from_email'];
    }
    $session = CRM_Core_Session::singleton();
    $mailing = new CRM_Mailing_BAO_Mailing();
    $mailing->id = $params['id'];
    $mailing->find(TRUE);
    CRM_Mailing_BAO_Mailing::tokenReplace($mailing);
    // get and format attachments
    $attachments = CRM_Core_BAO_File::getEntityFile('civicrm_mailing', $mailing->id);
    $returnProperties = $mailing->getReturnProperties();
    $contactID = CRM_Utils_Array::value('contact_id', $params);
    if (!$contactID) {
        $contactID = $session->get('userID');
    }
    $mailingParams = array('contact_id' => $contactID);
    $details = CRM_Utils_Token::getTokenDetails($mailingParams, $returnProperties, TRUE, TRUE, NULL, $mailing->getFlattenedTokens());
    $mime =& $mailing->compose(NULL, NULL, NULL, $session->get('userID'), $fromEmail, $fromEmail, TRUE, $details[0][$contactID], $attachments);
    return civicrm_api3_create_success(array('id' => $params['id'], 'contact_id' => $contactID, 'subject' => $mime->_headers['Subject'], 'body_html' => $mime->getHTMLBody(), 'body_text' => $mime->getTXTBody()));
}
开发者ID:rameshrr99,项目名称:civicrm-core,代码行数:33,代码来源:Mailing.php

示例7: formRule

 /**
  * Function for validation
  *
  * @param array $params (ref.) an assoc array of name/value pairs
  *
  * @param $files
  * @param $self
  *
  * @return mixed true or array of errors
  * @access public
  * @static
  */
 static function formRule($params, $files, $self)
 {
     if (!empty($_POST['_qf_Import_refresh'])) {
         return TRUE;
     }
     $errors = array();
     $template = CRM_Core_Smarty::singleton();
     $domain = CRM_Core_BAO_Domain::getDomain();
     $mailing = new CRM_Mailing_BAO_Mailing();
     $mailing->id = $self->_mailingID;
     $mailing->find(TRUE);
     $session = CRM_Core_Session::singleton();
     $values = array('contact_id' => $session->get('userID'), 'version' => 3);
     require_once 'api/api.php';
     $contact = civicrm_api('contact', 'get', $values);
     //CRM-4524
     $contact = reset($contact['values']);
     $verp = array_flip(array('optOut', 'reply', 'unsubscribe', 'resubscribe', 'owner'));
     foreach ($verp as $key => $value) {
         $verp[$key]++;
     }
     $urls = array_flip(array('forward', 'optOutUrl', 'unsubscribeUrl', 'resubscribeUrl'));
     foreach ($urls as $key => $value) {
         $urls[$key]++;
     }
     $skipTextFile = $self->get('skipTextFile');
     if (!$params['upload_type']) {
         if (!isset($files['textFile']) || !file_exists($files['textFile']['tmp_name'])) {
             if (!$skipTextFile) {
                 $errors['textFile'] = ts('Please provide a Text');
             }
         }
     } else {
         if (empty($params['text_message'])) {
             $errors['text_message'] = ts('Please provide a Text');
         } else {
             if (!empty($params['text_message'])) {
                 $messageCheck = CRM_Utils_Array::value('text_message', $params);
                 if ($messageCheck && strlen($messageCheck) > CRM_SMS_Provider::MAX_SMS_CHAR) {
                     $errors['text_message'] = ts("You can configure the SMS message body up to %1 characters", array(1 => CRM_SMS_Provider::MAX_SMS_CHAR));
                 }
             }
         }
         if (!empty($params['saveTemplate']) && empty($params['saveTemplateName'])) {
             $errors['saveTemplateName'] = ts('Please provide a Template Name.');
         }
     }
     if ($params['upload_type'] || file_exists(CRM_Utils_Array::value('tmp_name', $files['textFile'])) || !$params['upload_type'] && $params['text_message']) {
         if (!$params['upload_type']) {
             $str = file_get_contents($files['textFile']['tmp_name']);
             $name = $files['textFile']['name'];
         } else {
             $str = $params['text_message'];
             $name = 'text message';
         }
         $dataErrors = array();
         /* Do a full token replacement on a dummy verp, the current
          * contact and domain, and the first organization. */
         // here we make a dummy mailing object so that we
         // can retrieve the tokens that we need to replace
         // so that we do get an invalid token error
         // this is qute hacky and I hope that there might
         // be a suggestion from someone on how to
         // make it a bit more elegant
         $dummy_mail = new CRM_Mailing_BAO_Mailing();
         $mess = "body_text";
         $dummy_mail->{$mess} = $str;
         $tokens = $dummy_mail->getTokens();
         $str = CRM_Utils_Token::replaceSubscribeInviteTokens($str);
         $str = CRM_Utils_Token::replaceDomainTokens($str, $domain, NULL, $tokens['text']);
         $str = CRM_Utils_Token::replaceMailingTokens($str, $mailing, NULL, $tokens['text']);
         $str = CRM_Utils_Token::replaceOrgTokens($str, $org);
         $str = CRM_Utils_Token::replaceActionTokens($str, $verp, $urls, NULL, $tokens['text']);
         $str = CRM_Utils_Token::replaceContactTokens($str, $contact, NULL, $tokens['text']);
         $unmatched = CRM_Utils_Token::unmatchedTokens($str);
         $contentCheck = CRM_Utils_String::htmlToText($str);
         if (!empty($unmatched) && 0) {
             foreach ($unmatched as $token) {
                 $dataErrors[] = '<li>' . ts('Invalid token code') . ' {' . $token . '}</li>';
             }
         }
         if (strlen($contentCheck) > CRM_SMS_Provider::MAX_SMS_CHAR) {
             $dataErrors[] = '<li>' . ts('The body of the SMS cannot exceed %1 characters.', array(1 => CRM_SMS_Provider::MAX_SMS_CHAR)) . '</li>';
         }
         if (!empty($dataErrors)) {
             $errors['textFile'] = ts('The following errors were detected in %1:', array(1 => $name)) . ' <ul>' . implode('', $dataErrors) . '</ul>';
         }
     }
//.........这里部分代码省略.........
开发者ID:prashantgajare,项目名称:civicrm-core,代码行数:101,代码来源:Upload.php

示例8: postProcess

 /**
  * Process the posted form values.  Create and schedule a mailing.
  *
  * @param
  *
  * @return void
  * @access public
  */
 public function postProcess()
 {
     $params = array();
     $params['mailing_id'] = $ids['mailing_id'] = $this->_mailingID;
     if (empty($params['mailing_id'])) {
         CRM_Core_Error::fatal(ts('Could not find a mailing id'));
     }
     foreach (array('now', 'start_date', 'start_date_time') as $parameter) {
         $params[$parameter] = $this->controller->exportValue($this->_name, $parameter);
     }
     $mailing = new CRM_Mailing_BAO_Mailing();
     $mailing->id = $ids['mailing_id'];
     if ($mailing->find(TRUE)) {
         $job = new CRM_Mailing_BAO_Job();
         $job->mailing_id = $mailing->id;
         $job->is_test = 0;
         if ($job->find(TRUE)) {
             CRM_Core_Error::fatal(ts('A job for this mailing already exists'));
         }
         if (empty($mailing->is_template)) {
             $job->status = 'Scheduled';
             if ($params['now']) {
                 $job->scheduled_date = date('YmdHis');
             } else {
                 $job->scheduled_date = CRM_Utils_Date::processDate($params['start_date'] . ' ' . $params['start_date_time']);
             }
             $job->save();
         }
         // set approval details if workflow is not enabled
         if (!CRM_Mailing_Info::workflowEnabled()) {
             $session = CRM_Core_Session::singleton();
             $mailing->approver_id = $session->get('userID');
             $mailing->approval_date = date('YmdHis');
             $mailing->approval_status_id = 1;
         } else {
             // reset them in case this mailing was rejected
             $mailing->approver_id = 'null';
             $mailing->approval_date = 'null';
             $mailing->approval_status_id = 'null';
         }
         if ($mailing->approval_date) {
             $mailing->approval_date = CRM_Utils_Date::isoToMysql($mailing->approval_date);
         }
         // also set the scheduled_id
         $session = CRM_Core_Session::singleton();
         $mailing->scheduled_id = $session->get('userID');
         $mailing->scheduled_date = date('YmdHis');
         $mailing->created_date = CRM_Utils_Date::isoToMysql($mailing->created_date);
         $mailing->save();
     }
     //when user perform mailing from search context
     //redirect it to search result CRM-3711.
     $ssID = $this->get('ssID');
     if ($ssID && $this->_searchBasedMailing && !CRM_Mailing_Info::workflowEnabled()) {
         if ($this->_action == CRM_Core_Action::BASIC) {
             $fragment = 'search';
         } elseif ($this->_action == CRM_Core_Action::PROFILE) {
             $fragment = 'search/builder';
         } elseif ($this->_action == CRM_Core_Action::ADVANCED) {
             $fragment = 'search/advanced';
         } else {
             $fragment = 'search/custom';
         }
         $context = $this->get('context');
         if (!CRM_Contact_Form_Search::isSearchContext($context)) {
             $context = 'search';
         }
         $urlParams = "force=1&reset=1&ssID={$ssID}&context={$context}";
         $qfKey = CRM_Utils_Request::retrieve('qfKey', 'String', $this);
         if (CRM_Utils_Rule::qfKey($qfKey)) {
             $urlParams .= "&qfKey={$qfKey}";
         }
         $url = CRM_Utils_System::url('civicrm/contact/' . $fragment, $urlParams);
         return $this->controller->setDestination($url);
     }
     $session = CRM_Core_Session::singleton();
     $session->pushUserContext(CRM_Utils_System::url('civicrm/mailing/browse/scheduled', 'reset=1&scheduled=true'));
 }
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:86,代码来源:Schedule.php

示例9: postProcess

 /**
  * Process the posted form values.  Approve /reject a mailing.
  */
 public function postProcess()
 {
     // get the submitted form values.
     $params = $this->controller->exportValues($this->_name);
     $ids = array();
     if (isset($this->_mailingID)) {
         $ids['mailing_id'] = $this->_mailingID;
     } else {
         $ids['mailing_id'] = $this->get('mailing_id');
     }
     if (!$ids['mailing_id']) {
         CRM_Core_Error::fatal();
     }
     $params['approver_id'] = $this->_contactID;
     $params['approval_date'] = date('YmdHis');
     // if rejected, then we need to reset the scheduled date and scheduled id
     $rejectOptionID = CRM_Core_OptionGroup::getValue('mail_approval_status', 'Rejected', 'name');
     if ($rejectOptionID && $params['approval_status_id'] == $rejectOptionID) {
         $params['scheduled_id'] = 'null';
         $params['scheduled_date'] = 'null';
         // also delete any jobs associated with this mailing
         $job = new CRM_Mailing_BAO_MailingJob();
         $job->mailing_id = $ids['mailing_id'];
         $job->delete();
     } else {
         $mailing = new CRM_Mailing_BAO_Mailing();
         $mailing->id = $ids['mailing_id'];
         $mailing->find(TRUE);
         $params['scheduled_date'] = CRM_Utils_Date::processDate($mailing->scheduled_date);
     }
     CRM_Mailing_BAO_Mailing::create($params, $ids);
     //when user perform mailing from search context
     //redirect it to search result CRM-3711
     $ssID = $this->get('ssID');
     if ($ssID && $this->_searchBasedMailing) {
         if ($this->_action == CRM_Core_Action::BASIC) {
             $fragment = 'search';
         } elseif ($this->_action == CRM_Core_Action::PROFILE) {
             $fragment = 'search/builder';
         } elseif ($this->_action == CRM_Core_Action::ADVANCED) {
             $fragment = 'search/advanced';
         } else {
             $fragment = 'search/custom';
         }
         $context = $this->get('context');
         if (!CRM_Contact_Form_Search::isSearchContext($context)) {
             $context = 'search';
         }
         $urlParams = "force=1&reset=1&ssID={$ssID}&context={$context}";
         $qfKey = CRM_Utils_Request::retrieve('qfKey', 'String', $this);
         if (CRM_Utils_Rule::qfKey($qfKey)) {
             $urlParams .= "&qfKey={$qfKey}";
         }
         $url = CRM_Utils_System::url('civicrm/contact/' . $fragment, $urlParams);
         return $this->controller->setDestination($url);
     }
     $session = CRM_Core_Session::singleton();
     $session->pushUserContext(CRM_Utils_System::url('civicrm/mailing/browse/scheduled', 'reset=1&scheduled=true'));
 }
开发者ID:kcristiano,项目名称:civicrm-core,代码行数:62,代码来源:Approve.php

示例10: buildQuickForm

 public function buildQuickForm()
 {
     $session = CRM_Core_Session::singleton();
     $this->add('text', 'test_email', ts('Send to This Address'));
     $defaults['test_email'] = $session->get('ufUniqID');
     $qfKey = $this->get('qfKey');
     $this->add('select', 'test_group', ts('Send to This Group'), array('' => ts('- none -')) + CRM_Core_PseudoConstant::group('Mailing'));
     $this->setDefaults($defaults);
     $this->add('submit', 'sendtest', ts('Send a Test Mailing'));
     $name = ts('Next >>');
     require_once 'CRM/Mailing/Info.php';
     if (CRM_Mailing_Info::workflowEnabled()) {
         if (!CRM_Core_Permission::check('schedule mailings') && CRM_Core_Permission::check('create mailings')) {
             $name = ts('Inform Scheduler');
         }
     }
     //FIXME : currently we are hiding save an continue later when
     //search base mailing, we should handle it when we fix CRM-3876
     $buttons = array(array('type' => 'back', 'name' => ts('<< Previous')), array('type' => 'next', 'name' => $name, 'spacing' => '&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;', 'isDefault' => true), array('type' => 'submit', 'name' => ts('Save & Continue Later')), array('type' => 'cancel', 'name' => ts('Cancel')));
     if ($this->_searchBasedMailing && $this->get('ssID')) {
         $buttons = array(array('type' => 'back', 'name' => ts('<< Previous')), array('type' => 'next', 'name' => $name, 'spacing' => '&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;', 'isDefault' => true), array('type' => 'cancel', 'name' => ts('Cancel')));
     }
     $this->addButtons($buttons);
     $mailingID = $this->get('mailing_id');
     $textFile = $this->get('textFile');
     $htmlFile = $this->get('htmlFile');
     $this->addFormRule(array('CRM_Mailing_Form_Test', 'testMail'), $this);
     $preview = array();
     if ($textFile) {
         $preview['text_link'] = CRM_Utils_System::url('civicrm/mailing/preview', "type=text&qfKey={$qfKey}");
     }
     if ($htmlFile) {
         $preview['html_link'] = CRM_Utils_System::url('civicrm/mailing/preview', "type=html&qfKey={$qfKey}");
     }
     require_once 'CRM/Core/BAO/File.php';
     $preview['attachment'] = CRM_Core_BAO_File::attachmentInfo('civicrm_mailing', $mailingID);
     $this->assign('preview', $preview);
     //Token Replacement of Subject in preview mailing
     $options = array();
     $prefix = "CRM_Mailing_Controller_Send_{$qfKey}";
     if ($this->_searchBasedMailing) {
         $prefix = "CRM_Contact_Controller_Search_{$qfKey}";
     }
     $session->getVars($options, $prefix);
     require_once 'CRM/Mailing/BAO/Mailing.php';
     $mailing = new CRM_Mailing_BAO_Mailing();
     $mailing->id = $options['mailing_id'];
     $mailing->find(true);
     $fromEmail = $mailing->from_email;
     require_once 'CRM/Core/BAO/File.php';
     $attachments =& CRM_Core_BAO_File::getEntityFile('civicrm_mailing', $mailing->id);
     $returnProperties = $mailing->getReturnProperties();
     $userID = $session->get('userID');
     $params = array('contact_id' => $userID);
     $details = $mailing->getDetails($params, $returnProperties);
     $allDetails =& $mailing->compose(null, null, null, $userID, $fromEmail, $fromEmail, true, $details[0][$userID], $attachments);
     $this->assign('subject', $allDetails->_headers['Subject']);
 }
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:58,代码来源:Test.php

示例11: delete

 /**
  * Delete the CiviCRM mailing corresponding to the SimpleMail mailing currently being deleted, as it would indirectly
  * cause deletion of SimpleMail mailing and any associated scheduled mailing jobs
  *
  * @param bool $useWhere
  *
  * @return mixed|void
  * @throws \CRM_Extension_Exception
  */
 public function delete($useWhere = FALSE)
 {
     if (!static::authorised(SM_PERMISSION_DELETE)) {
         throw new CRM_Extension_Exception('Sorry! You do not have permission to delete mailings', 500);
     }
     if (!static::isActionAllowed(static::ACTION_ALLOWED_DELETE, $this->toArray())) {
         throw new CRM_Extension_Exception('Cannot delete a scheduled/running mailing', 405);
     }
     if (!$this->crm_mailing_id) {
         throw new CRM_Extension_Exception('Failed to delete mailing it does not have a corresponding CiviCRM mailing associated', 500);
     }
     // Delete the inline attachments first, because they are tied to a cascade delete on the simple mailing table
     $attachments = CRM_Simplemail_BAO_SimpleMailInlineAttachment::removeAll((int) $this->id);
     $civiMailing = new CRM_Mailing_BAO_Mailing();
     $civiMailing->id = (int) $this->crm_mailing_id;
     $civiMailing->find(TRUE);
     $civiMailing->delete();
     // This will cascade and delete the corresponding SimpleMail mailing and mailing jobs
 }
开发者ID:jaapjansma,项目名称:uk.co.compucorp.civicrm.simplemail,代码行数:28,代码来源:SimpleMail.php

示例12: array

 /**
  * Create a new forward event, create a new contact if necessary
  *
  * @param $job_id
  * @param $queue_id
  * @param $hash
  * @param $forward_email
  * @param null $fromEmail
  * @param null $comment
  *
  * @return bool
  */
 public static function &forward($job_id, $queue_id, $hash, $forward_email, $fromEmail = NULL, $comment = NULL)
 {
     $q = CRM_Mailing_Event_BAO_Queue::verify($job_id, $queue_id, $hash);
     $successfulForward = FALSE;
     $contact_id = NULL;
     if (!$q) {
         return $successfulForward;
     }
     /* Find the email address/contact, if it exists */
     $contact = CRM_Contact_BAO_Contact::getTableName();
     $location = CRM_Core_BAO_Location::getTableName();
     $email = CRM_Core_BAO_Email::getTableName();
     $queueTable = CRM_Mailing_Event_BAO_Queue::getTableName();
     $job = CRM_Mailing_BAO_MailingJob::getTableName();
     $mailing = CRM_Mailing_BAO_Mailing::getTableName();
     $forward = self::getTableName();
     $domain = CRM_Core_BAO_Domain::getDomain();
     $dao = new CRM_Core_Dao();
     $dao->query("\n                SELECT      {$contact}.id as contact_id,\n                            {$email}.id as email_id,\n                            {$contact}.do_not_email as do_not_email,\n                            {$queueTable}.id as queue_id\n                FROM        ({$email}, {$job} as temp_job)\n                INNER JOIN  {$contact}\n                        ON  {$email}.contact_id = {$contact}.id\n                LEFT JOIN   {$queueTable}\n                        ON  {$email}.id = {$queueTable}.email_id\n                LEFT JOIN   {$job}\n                        ON  {$queueTable}.job_id = {$job}.id\n                        AND temp_job.mailing_id = {$job}.mailing_id\n                WHERE       {$queueTable}.job_id = {$job_id}\n                    AND     {$email}.email = '" . CRM_Utils_Type::escape($forward_email, 'String') . "'");
     $dao->fetch();
     $transaction = new CRM_Core_Transaction();
     if (isset($dao->queue_id) || isset($dao->do_not_email) && $dao->do_not_email == 1) {
         /* We already sent this mailing to $forward_email, or we should
          * never email this contact.  Give up. */
         return $successfulForward;
     }
     require_once 'api/api.php';
     $contactParams = array('email' => $forward_email, 'version' => 3);
     $contactValues = civicrm_api('contact', 'get', $contactParams);
     $count = $contactValues['count'];
     if ($count == 0) {
         /* If the contact does not exist, create one. */
         $formatted = array('contact_type' => 'Individual', 'version' => 3);
         $locationType = CRM_Core_BAO_LocationType::getDefault();
         $value = array('email' => $forward_email, 'location_type_id' => $locationType->id);
         require_once 'CRM/Utils/DeprecatedUtils.php';
         _civicrm_api3_deprecated_add_formatted_param($value, $formatted);
         $formatted['onDuplicate'] = CRM_Import_Parser::DUPLICATE_SKIP;
         $formatted['fixAddress'] = TRUE;
         $contact = civicrm_api('contact', 'create', $formatted);
         if (civicrm_error($contact)) {
             return $successfulForward;
         }
         $contact_id = $contact['id'];
     }
     $email = new CRM_Core_DAO_Email();
     $email->email = $forward_email;
     $email->find(TRUE);
     $email_id = $email->id;
     if (!$contact_id) {
         $contact_id = $email->contact_id;
     }
     /* Create a new queue event */
     $queue_params = array('email_id' => $email_id, 'contact_id' => $contact_id, 'job_id' => $job_id);
     $queue = CRM_Mailing_Event_BAO_Queue::create($queue_params);
     $forward = new CRM_Mailing_Event_BAO_Forward();
     $forward->time_stamp = date('YmdHis');
     $forward->event_queue_id = $queue_id;
     $forward->dest_queue_id = $queue->id;
     $forward->save();
     $dao->reset();
     $dao->query("   SELECT  {$job}.mailing_id as mailing_id\n                        FROM    {$job}\n                        WHERE   {$job}.id = " . CRM_Utils_Type::escape($job_id, 'Integer'));
     $dao->fetch();
     $mailing_obj = new CRM_Mailing_BAO_Mailing();
     $mailing_obj->id = $dao->mailing_id;
     $mailing_obj->find(TRUE);
     $config = CRM_Core_Config::singleton();
     $mailer = $config->getMailer();
     $recipient = NULL;
     $attachments = NULL;
     $message = $mailing_obj->compose($job_id, $queue->id, $queue->hash, $queue->contact_id, $forward_email, $recipient, FALSE, NULL, $attachments, TRUE, $fromEmail);
     //append comment if added while forwarding.
     if (count($comment)) {
         $message->_txtbody = CRM_Utils_Array::value('body_text', $comment) . $message->_txtbody;
         if (!empty($comment['body_html'])) {
             $message->_htmlbody = $comment['body_html'] . '<br />---------------Original message---------------------<br />' . $message->_htmlbody;
         }
     }
     $body = $message->get();
     $headers = $message->headers();
     $result = NULL;
     if (is_object($mailer)) {
         $errorScope = CRM_Core_TemporaryErrorScope::ignoreException();
         $result = $mailer->send($recipient, $headers, $body);
         unset($errorScope);
     }
     $params = array('event_queue_id' => $queue->id, 'job_id' => $job_id, 'hash' => $queue->hash);
     if (is_a($result, 'PEAR_Error')) {
//.........这里部分代码省略.........
开发者ID:kidaa30,项目名称:yes,代码行数:101,代码来源:Forward.php

示例13: getTokenData

 /**
  *
  *  getTokenData receives a token from an email
  *  and returns the appropriate data for the token
  *
  */
 private function getTokenData(&$token_a, $html = false, &$contact, &$verp, &$urls, $event_queue_id)
 {
     $type = $token_a['type'];
     $token = $token_a['token'];
     $data = $token;
     $escapeSmarty = defined('CIVICRM_MAIL_SMARTY') ? true : false;
     if ($type == 'embedded_url') {
         $embed_data = array();
         foreach ($token as $t) {
             $embed_data[] = $this->getTokenData($t, $html = false, $contact, $verp, $urls, $event_queue_id);
         }
         $numSlices = count($embed_data);
         $url = '';
         for ($i = 0; $i < $numSlices; $i++) {
             $url .= "{$token_a['embed_parts'][$i]}{$embed_data[$i]}";
         }
         if (isset($token_a['embed_parts'][$numSlices])) {
             $url .= $token_a['embed_parts'][$numSlices];
         }
         // add trailing quote since we've gobbled it up in a previous regex
         // function getPatterns, line 431
         if (preg_match('/^href[ ]*=[ ]*\'/', $url)) {
             $url .= "'";
         } else {
             if (preg_match('/^href[ ]*=[ ]*\\"/', $url)) {
                 $url .= '"';
             }
         }
         $data = $url;
     } else {
         if ($type == 'url') {
             if ($this->url_tracking) {
                 $data = CRM_Mailing_BAO_TrackableURL::getTrackerURL($token, $this->id, $event_queue_id);
             } else {
                 $data = $token;
             }
         } else {
             if ($type == 'contact') {
                 $data = CRM_Utils_Token::getContactTokenReplacement($token, $contact, false, false, $escapeSmarty);
             } else {
                 if ($type == 'action') {
                     $data = CRM_Utils_Token::getActionTokenReplacement($token, $verp, $urls, $html);
                 } else {
                     if ($type == 'domain') {
                         require_once 'CRM/Core/BAO/Domain.php';
                         $domain =& CRM_Core_BAO_Domain::getDomain();
                         $data = CRM_Utils_Token::getDomainTokenReplacement($token, $domain, $html);
                     } else {
                         if ($type == 'mailing') {
                             require_once 'CRM/Mailing/BAO/Mailing.php';
                             $mailing = new CRM_Mailing_BAO_Mailing();
                             $mailing->find(true);
                             if ($token == 'name') {
                                 $data = $mailing->name;
                             } else {
                                 if ($token == 'group') {
                                     $groups = $mailing->getGroupNames();
                                     $data = implode(', ', $groups);
                                 }
                             }
                         } else {
                             $data = CRM_Utils_Array::value("{$type}.{$token}", $contact);
                         }
                     }
                 }
             }
         }
     }
     return $data;
 }
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:76,代码来源:Mailing.php

示例14: deliver

 /**
  * Send the mailing
  *
  * @param object $mailer        A Mail object to send the messages
  * @return void
  * @access public
  */
 public function deliver(&$mailer, $testParams = null)
 {
     require_once 'CRM/Mailing/BAO/Mailing.php';
     $mailing = new CRM_Mailing_BAO_Mailing();
     $mailing->id = $this->mailing_id;
     $mailing->find(true);
     $eq = new CRM_Mailing_Event_BAO_Queue();
     $eqTable = CRM_Mailing_Event_BAO_Queue::getTableName();
     $emailTable = CRM_Core_BAO_Email::getTableName();
     $contactTable = CRM_Contact_BAO_Contact::getTableName();
     $edTable = CRM_Mailing_Event_BAO_Delivered::getTableName();
     $ebTable = CRM_Mailing_Event_BAO_Bounce::getTableName();
     $query = "  SELECT      {$eqTable}.id,\n                                {$emailTable}.email as email,\n                                {$eqTable}.contact_id,\n                                {$eqTable}.hash\n                    FROM        {$eqTable}\n                    INNER JOIN  {$emailTable}\n                            ON  {$eqTable}.email_id = {$emailTable}.id\n                    LEFT JOIN   {$edTable}\n                            ON  {$eqTable}.id = {$edTable}.event_queue_id\n                    LEFT JOIN   {$ebTable}\n                            ON  {$eqTable}.id = {$ebTable}.event_queue_id\n                    WHERE       {$eqTable}.job_id = " . $this->id . "\n                        AND     {$edTable}.id IS null\n                        AND     {$ebTable}.id IS null";
     $eq->query($query);
     static $config = null;
     static $mailsProcessed = 0;
     if ($config == null) {
         $config = CRM_Core_Config::singleton();
     }
     $job_date = CRM_Utils_Date::isoToMysql($this->scheduled_date);
     $fields = array();
     if (!empty($testParams)) {
         $mailing->from_name = ts('CiviCRM Test Mailer (%1)', array(1 => $mailing->from_name));
         $mailing->subject = ts('Test Mailing:') . ' ' . $mailing->subject;
     }
     CRM_Mailing_BAO_Mailing::tokenReplace($mailing);
     // get and format attachments
     require_once 'CRM/Core/BAO/File.php';
     $attachments =& CRM_Core_BAO_File::getEntityFile('civicrm_mailing', $mailing->id);
     if (defined('CIVICRM_MAIL_SMARTY')) {
         require_once 'CRM/Core/Smarty/resources/String.php';
         civicrm_smarty_register_string_resource();
     }
     // make sure that there's no more than $config->mailerBatchLimit mails processed in a run
     while ($eq->fetch()) {
         // if ( ( $mailsProcessed % 100 ) == 0 ) {
         // CRM_Utils_System::xMemory( "$mailsProcessed: " );
         // }
         if ($config->mailerBatchLimit > 0 && $mailsProcessed >= $config->mailerBatchLimit) {
             $this->deliverGroup($fields, $mailing, $mailer, $job_date, $attachments);
             return false;
         }
         $mailsProcessed++;
         $fields[] = array('id' => $eq->id, 'hash' => $eq->hash, 'contact_id' => $eq->contact_id, 'email' => $eq->email);
         if (count($fields) == self::MAX_CONTACTS_TO_PROCESS) {
             $isDelivered = $this->deliverGroup($fields, $mailing, $mailer, $job_date, $attachments);
             if (!$isDelivered) {
                 return $isDelivered;
             }
             $fields = array();
         }
     }
     $isDelivered = $this->deliverGroup($fields, $mailing, $mailer, $job_date, $attachments);
     return $isDelivered;
 }
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:62,代码来源:Job.php

示例15: buildQuickForm

 public function buildQuickForm()
 {
     $session = CRM_Core_Session::singleton();
     $this->add('text', 'test_email', ts('Send to This Address'));
     $defaults['test_email'] = $session->get('ufUniqID');
     $qfKey = $this->get('qfKey');
     $this->add('select', 'test_group', ts('Send to This Group'), array('' => ts('- none -')) + CRM_Core_PseudoConstant::group('Mailing'));
     $this->setDefaults($defaults);
     $this->add('submit', 'sendtest', ts('Send a Test Mailing'));
     $name = ts('Next');
     if (CRM_Mailing_Info::workflowEnabled()) {
         if (!CRM_Core_Permission::check('schedule mailings') && CRM_Core_Permission::check('create mailings')) {
             $name = ts('Inform Scheduler');
         }
     }
     $buttons = array(array('type' => 'back', 'name' => ts('Previous')), array('type' => 'next', 'name' => $name, 'spacing' => '&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;', 'isDefault' => TRUE), array('type' => 'submit', 'name' => ts('Save & Continue Later')), array('type' => 'cancel', 'name' => ts('Cancel')));
     $this->addButtons($buttons);
     $mailingID = $this->get('mailing_id');
     $textFile = $this->get('textFile');
     $htmlFile = $this->get('htmlFile');
     $this->addFormRule(array('CRM_Mailing_Form_Test', 'testMail'), $this);
     $preview = array();
     if ($textFile) {
         $preview['text_link'] = CRM_Utils_System::url('civicrm/mailing/preview', "type=text&qfKey={$qfKey}");
     }
     if ($htmlFile) {
         $preview['html_link'] = CRM_Utils_System::url('civicrm/mailing/preview', "type=html&qfKey={$qfKey}");
     }
     $preview['attachment'] = CRM_Core_BAO_File::attachmentInfo('civicrm_mailing', $mailingID);
     $this->assign('preview', $preview);
     //Token Replacement of Subject in preview mailing
     $options = array();
     $prefix = "CRM_Mailing_Controller_Send_{$qfKey}";
     if ($this->_searchBasedMailing) {
         $prefix = "CRM_Contact_Controller_Search_{$qfKey}";
     }
     $session->getVars($options, $prefix);
     $mailing = new CRM_Mailing_BAO_Mailing();
     $mailing->id = $options['mailing_id'];
     $mailing->find(TRUE);
     $fromEmail = $mailing->from_email;
     $replyToEmail = $mailing->replyto_email;
     $attachments = CRM_Core_BAO_File::getEntityFile('civicrm_mailing', $mailing->id);
     $returnProperties = $mailing->getReturnProperties();
     $userID = $session->get('userID');
     $params = array('contact_id' => $userID);
     $details = CRM_Utils_Token::getTokenDetails($params, $returnProperties, TRUE, TRUE, NULL, $mailing->getFlattenedTokens(), get_class($this));
     $allDetails =& $mailing->compose(NULL, NULL, NULL, $userID, $fromEmail, $fromEmail, TRUE, $details[0][$userID], $attachments);
     $this->assign('subject', $allDetails->_headers['Subject']);
 }
开发者ID:BorislavZlatanov,项目名称:civicrm-core,代码行数:50,代码来源:Test.php


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