/**
  * the main function that is called when the page loads,
  * it decides the which action has to be taken for the page.
  *
  * @return null
  */
 function run()
 {
     $secretCode = CRM_Utils_Type::escape($_GET['mandrillSecret'], 'String');
     $mandrillSecret = CRM_Core_OptionGroup::values('mandrill_secret', TRUE);
     if ($secretCode !== $mandrillSecret['Secret Code']) {
         return FALSE;
     }
     if (CRM_Utils_Array::value('mandrill_events', $_POST)) {
         $reponse = json_decode($_POST['mandrill_events'], TRUE);
         if (is_array($reponse) && !empty($reponse)) {
             CRM_Mte_BAO_Mandrill::processMandrillCalls($reponse);
         }
     }
     CRM_Utils_System::civiExit();
 }
Example #2
0
function mte_createQueue(&$mandrillHeader, $toEmail)
{
    $mail = new CRM_Mailing_DAO_Mailing();
    $mail->subject = "***All Transactional Emails***";
    $mail->url_tracking = TRUE;
    $mail->forward_replies = FALSE;
    $mail->auto_responder = FALSE;
    $mail->open_tracking = TRUE;
    if ($mail->find(TRUE)) {
        $emails = CRM_Mte_BAO_Mandrill::retrieveEmailContactId($toEmail);
        $jobCLassName = 'CRM_Mailing_DAO_MailingJob';
        if (version_compare('4.4alpha1', CRM_Core_Config::singleton()->civiVersion) > 0) {
            $jobCLassName = 'CRM_Mailing_DAO_Job';
        }
        $params = array('job_id' => CRM_Core_DAO::getFieldValue($jobCLassName, $mail->id, 'id', 'mailing_id'), 'contact_id' => $emails['email']['contact_id'], 'email_id' => $emails['email']['id']);
        $eventQueue = CRM_Mailing_Event_BAO_Queue::create($params);
        $mandrillHeader = implode(CRM_Core_Config::singleton()->verpSeparator, array($mandrillHeader, 'm', $params['job_id'], $eventQueue->id, $eventQueue->hash));
    }
}