/**
  * Example: Run an external SQL script when the module is installed
  **/
 public function install()
 {
     //Install Mailjet bounce types
     $bounceType = array(1 => array('name' => self::HARD_BOUNCE, 'description' => 'Emails "Hard Bounces" by Mailjet’s system', 'hold_threshold' => 1), 2 => array('name' => self::SOFT_BOUNCE, 'description' => 'Emails "Soft Bounces" by Mailjet’s system', 'hold_threshold' => 3), 3 => array('name' => self::BLOCKED, 'description' => 'Emails ”Blocked” by Mailjet’s system', 'hold_threshold' => 1), 4 => array('name' => self::SPAM, 'description' => 'Emails reported as "Spam"', 'hold_threshold' => 1));
     foreach ($bounceType as $type) {
         $bounceTypeDAO = new CRM_Mailing_DAO_BounceType();
         $bounceTypeDAO->copyValues($type);
         if (!$bounceTypeDAO->find(true)) {
             $bounceTypeDAO->save();
         }
     }
     //$this->executeSqlFile('sql/myinstall.sql');
 }
Example #2
0
/**
 * Implementation of hook_civicrm_install
 */
function mte_civicrm_install()
{
    $mailingParams = array('subject' => '***All Transactional Emails***', 'name' => ts('Transaction Emails'), 'url_tracking' => TRUE, 'forward_replies' => FALSE, 'auto_responder' => FALSE, 'open_tracking' => TRUE, 'is_completed' => FALSE);
    //create entry in civicrm_mailing
    $mailing = CRM_Mailing_BAO_Mailing::add($mailingParams, CRM_Core_DAO::$_nullArray);
    //add entry in civicrm_mailing_job
    //MTE-17
    $config = CRM_Core_Config::singleton();
    if (property_exists($config, 'civiVersion')) {
        $civiVersion = $config->civiVersion;
    } else {
        $civiVersion = CRM_Core_BAO_Domain::version();
    }
    $jobCLassName = 'CRM_Mailing_DAO_MailingJob';
    if (version_compare('4.4alpha1', $civiVersion) > 0) {
        $jobCLassName = 'CRM_Mailing_DAO_Job';
    }
    $changeENUM = FALSE;
    if (version_compare('4.5alpha1', $civiVersion) > 0) {
        $changeENUM = TRUE;
    }
    CRM_Core_Smarty::singleton()->assign('changeENUM', $changeENUM);
    _mte_civix_civicrm_install();
    $saveJob = new $jobCLassName();
    $saveJob->start_date = $saveJob->end_date = date('YmdHis');
    $saveJob->status = 'Complete';
    $saveJob->job_type = "Special: All transactional emails being sent through Mandrill";
    $saveJob->mailing_id = $mailing->id;
    $saveJob->save();
    // create mailing bounce type
    $mailingBounceType = array('1' => array('name' => 'Mandrill Hard', 'description' => 'Mandrill hard bounce', 'hold_threshold' => 1), '2' => array('name' => 'Mandrill Soft', 'description' => 'Mandrill soft bounce', 'hold_threshold' => 3), '3' => array('name' => 'Mandrill Spam', 'description' => 'User marked a transactional email sent via Mandrill as spam', 'hold_threshold' => 1), '4' => array('name' => 'Mandrill Reject', 'description' => 'Mandrill rejected delivery to this email address', 'hold_threshold' => 1));
    foreach ($mailingBounceType as $value) {
        $bounceType = new CRM_Mailing_DAO_BounceType();
        $bounceType->copyValues($value);
        if (!$bounceType->find(true)) {
            $bounceType->save();
        }
    }
    return TRUE;
}