public function testretrieve()
 {
     error_reporting(E_ERROR | E_PARSE);
     $emailMarketing = new EmailMarketing();
     $result = $emailMarketing->retrieve();
     $this->assertInstanceOf('EmailMarketing', $result);
 }
Esempio n. 2
0
 //fetch user that scheduled the campaign.
 if (empty($current_user) or $row['user_id'] != $current_user->id) {
     $current_user->retrieve($row['user_id']);
 }
 if (!$emailman->verify_campaign($row['marketing_id'])) {
     $GLOBALS['log']->fatal('Error verifying templates for the campaign, exiting');
     continue;
 }
 //verify the email template too..
 //find the template associated with marketing message. make sure that template has a subject and
 //a non-empty body
 if (!isset($template_status[$row['marketing_id']])) {
     if (!class_exists('EmailMarketing')) {
     }
     $current_emailmarketing = new EmailMarketing();
     $current_emailmarketing->retrieve($row['marketing_id']);
     if (!class_exists('EmailTemplate')) {
     }
     $current_emailtemplate = new EmailTemplate();
     $current_emailtemplate->retrieve($current_emailmarketing->template_id);
 }
 //acquire a lock.
 //if the database does not support repeatable read isolation by default, we might get data that does not meet
 //the criteria in the original query, and we care most about the in_queue_date and process_date_time,
 //if they are null or in past(older than 24 horus) then we are okay.
 $lock_query = "UPDATE emailman SET in_queue=1, in_queue_date=" . $db->now() . " WHERE id = " . intval($row['id']);
 $lock_query .= " AND (in_queue ='0' OR in_queue IS NULL OR ( in_queue ='1' AND in_queue_date <= " . $db->convert($db->quoted($timedate->fromString("-1 day")->asDb()), "datetime") . "))";
 //if the query fails to execute.. terminate campaign email process.
 $lock_result = $db->query($lock_query, true, 'Error acquiring a lock for emailman entry.');
 $lock_count = $db->getAffectedRowCount($lock_result);
 //do not process the message if unable to acquire lock.
Esempio n. 3
0
if (isset($_REQUEST['from_wiz'])) {
    $from_wiz = true;
}
//if campaign status is 'sending' disallow this step.
if (!empty($campaign->status) && $campaign->status == 'sending') {
    $err_messages[] = $mod_strings['ERR_SENDING_NOW'];
}
$current_date = $campaign->db->now();
//start scheduling now.....
foreach ($_POST['mass'] as $message_id) {
    //fetch email marketing definition.
    if (!class_exists('EmailMarketing')) {
        require_once 'modules/EmailMarketing/EmailMarketing.php';
    }
    $marketing = new EmailMarketing();
    $marketing->retrieve($message_id);
    //make sure that the marketing message has a mailbox.
    //
    if (empty($marketing->inbound_email_id)) {
        echo "<p>";
        echo "<h4>{$mod_strings['ERR_NO_MAILBOX']}</h4>";
        echo "<BR><a href='index.php?module=EmailMarketing&action=EditView&record={$marketing->id}'>{$marketing->name}</a>";
        echo "</p>";
        sugar_die('');
    }
    global $timedate;
    $mergedvalue = $timedate->merge_date_time($marketing->date_start, $marketing->time_start);
    if ($test) {
        $send_date_time = $timedate->getNow()->get("-60 seconds")->asDb();
    } else {
        $send_date_time = $timedate->to_db($mergedvalue);
Esempio n. 4
0
function create_marketing_summary($focus)
{
    global $mod_strings, $app_strings;
    $colorclass = '';
    //create new marketing button input
    $new_mrkt_input = "<input id='wiz_new_mrkt_button' name='SUBMIT' ";
    $new_mrkt_input .= "onclick=\"this.form.return_module.value='Campaigns';";
    $new_mrkt_input .= "this.form.module.value='Campaigns';";
    $new_mrkt_input .= "this.form.record.value='';";
    $new_mrkt_input .= "this.form.return_module.value='Campaigns';";
    $new_mrkt_input .= "this.form.action.value='WizardMarketing';";
    $new_mrkt_input .= "this.form.return_action.value='WizardHome';";
    $new_mrkt_input .= "this.form.direct_step.value='1';";
    $new_mrkt_input .= "this.form.campaign_id.value='" . $focus->id . "';";
    $new_mrkt_input .= "this.form.return_id.value='" . $focus->id . "';\" ";
    $new_mrkt_input .= "class='button' value='" . $mod_strings['LBL_CREATE_NEW_MARKETING_EMAIL'] . "' type='submit'>";
    //create marketing email table
    $mrkt_tbl = '';
    $focus->load_relationship('emailmarketing');
    $mrkt_lists = $focus->emailmarketing->get();
    $mrkt_tbl = "<p><table  class='list view' width='100%' border='0' cellspacing='1' cellpadding='1'>";
    $mrkt_tbl .= "<tr class='detail view'><td colspan='3'><h4> " . $mod_strings['LBL_WIZ_MARKETING_TITLE'] . " </h4></td>" . "<td colspan=2 align='right'>{$new_mrkt_input}</td></tr>";
    $mrkt_tbl .= "<tr  class='listViewHRS1'><td scope='col' width='15%'><b>" . $mod_strings['LBL_MRKT_NAME'] . "</b></td><td width='15%' scope='col'><b>" . $mod_strings['LBL_FROM_MAILBOX_NAME'] . "</b></td><td width='15%' scope='col'><b>" . $mod_strings['LBL_STATUS_TEXT'] . "</b></td><td scope='col' colspan=2>&nbsp;</td></tr>";
    if (count($mrkt_lists) > 0) {
        $mrkt_focus = new EmailMarketing();
        foreach ($mrkt_lists as $mrkt_id) {
            $mrkt_focus->retrieve($mrkt_id);
            //create send test marketing button input
            $test_mrkt_input = "<input id='wiz_new_mrkt_button' name='SUBMIT'  ";
            $test_mrkt_input .= "onclick=\"this.form.return_module.value='Campaigns'; ";
            $test_mrkt_input .= "this.form.module.value='Campaigns'; ";
            $test_mrkt_input .= "this.form.record.value='';";
            $test_mrkt_input .= "this.form.return_module.value='Campaigns'; ";
            $test_mrkt_input .= "this.form.action.value='QueueCampaign'; ";
            $test_mrkt_input .= "this.form.return_action.value='WizardHome'; ";
            $test_mrkt_input .= "this.form.wiz_mass.value='" . $mrkt_focus->id . "'; ";
            $test_mrkt_input .= "this.form.mode.value='test'; ";
            $test_mrkt_input .= "this.form.direct_step.value='1'; ";
            $test_mrkt_input .= "this.form.record.value='" . $focus->id . "'; ";
            $test_mrkt_input .= "this.form.return_id.value='" . $focus->id . "';\" ";
            $test_mrkt_input .= "class='button' value='" . $mod_strings['LBL_TEST_BUTTON_LABEL'] . "' type='submit'>";
            //create send marketing button input
            $send_mrkt_input = "<input id='wiz_new_mrkt_button' name='SUBMIT'  ";
            $send_mrkt_input .= "onclick=\"this.form.return_module.value='Campaigns'; ";
            $send_mrkt_input .= "this.form.module.value='Campaigns'; ";
            $send_mrkt_input .= "this.form.record.value='';";
            $send_mrkt_input .= "this.form.return_module.value='Campaigns'; ";
            $send_mrkt_input .= "this.form.action.value='QueueCampaign'; ";
            $send_mrkt_input .= "this.form.return_action.value='WizardHome'; ";
            $send_mrkt_input .= "this.form.wiz_mass.value='" . $mrkt_focus->id . "'; ";
            $send_mrkt_input .= "this.form.mode.value='send'; ";
            $send_mrkt_input .= "this.form.direct_step.value='1'; ";
            $send_mrkt_input .= "this.form.record.value='" . $focus->id . "'; ";
            $send_mrkt_input .= "this.form.return_id.value='" . $focus->id . "';\" ";
            $send_mrkt_input .= "class='button' value='" . $mod_strings['LBL_SEND_EMAIL'] . "' type='submit'>";
            if ($colorclass == "class='evenListRowS1'") {
                $colorclass = "class='oddListRowS1'";
            } else {
                $colorclass = "class='evenListRowS1'";
            }
            if (isset($mrkt_focus->name) && !empty($mrkt_focus->name)) {
                $mrkt_tbl .= "<tr {$colorclass}>";
                $mrkt_tbl .= "<td scope='row' width='40%'><a href='index.php?action=WizardMarketing&module=Campaigns&return_module=Campaigns&return_action=WizardHome";
                $mrkt_tbl .= "&return_id=" . $focus->id . "&campaign_id=" . $focus->id . "&record=" . $mrkt_focus->id . "'>" . $mrkt_focus->name . "</a></td>";
                $mrkt_tbl .= "<td scope='row' width='25%'>" . $mrkt_focus->from_name . "</td>";
                $mrkt_tbl .= "<td scope='row' width='15%'>" . $mrkt_focus->status . "</td>";
                $mrkt_tbl .= "<td scope='row' width='10%'>{$test_mrkt_input}</td>";
                $mrkt_tbl .= "<td scope='row' width='10%'>{$send_mrkt_input}</td>";
                $mrkt_tbl .= "</tr>";
            }
        }
    } else {
        $mrkt_tbl .= "<tr><td colspan='3'>" . $mod_strings['LBL_NONE'] . "</td></tr>";
    }
    $mrkt_tbl .= "</table></p>";
    return $mrkt_tbl;
}
Esempio n. 5
0
}
if (isset($_REQUEST['return_id'])) {
    $ss->assign("RETURN_ID", $_REQUEST['return_id']);
}
// handle Create $module then Cancel
$ss->assign('CAMPAIGN_ID', $campaign_focus->id);
$seps = get_number_seperators();
$ss->assign("NUM_GRP_SEP", $seps[0]);
$ss->assign("DEC_SEP", $seps[1]);
/**************************** MARKETING UI DIV Stuff *******************/
//$campaign_focus->load_relationship('emailmarketing');
//$mrkt_ids = $campaign_focus->emailmarketing->get();
$mrkt_focus = new EmailMarketing();
//if record param exists and it is not empty, then retrieve this bean
if (isset($_REQUEST['record']) and !empty($_REQUEST['record'])) {
    $mrkt_focus->retrieve($_REQUEST['record']);
} else {
    //check to see if this campaign has an email marketing already attached, and if so, create duplicate
    $campaign_focus->load_relationship('emailmarketing');
    $mrkt_lists = $campaign_focus->emailmarketing->get();
    if (!empty($mrkt_lists)) {
        //reverse array so we always use the most recent one:
        $mrkt_lists = array_reverse($mrkt_lists);
        $mrkt_focus->retrieve($mrkt_lists[0]);
        $mrkt_focus->id = '';
        $mrkt_focus->name = $mod_strings['LBL_COPY_OF'] . ' ' . $mrkt_focus->name;
    }
}
$ss->assign("CALENDAR_LANG", "en");
$ss->assign("USER_DATEFORMAT", '(' . $timedate->get_user_date_format() . ')');
$ss->assign("CALENDAR_DATEFORMAT", $timedate->get_cal_date_format());
Esempio n. 6
0
 function verify_campaign($marketing_id)
 {
     if (!isset($this->verified_email_marketing_ids[$marketing_id])) {
         if (!class_exists('EmailMarketing')) {
         }
         $email_marketing = new EmailMarketing();
         $ret = $email_marketing->retrieve($marketing_id);
         if (empty($ret)) {
             $GLOBALS['log']->fatal('Error retrieving marketing message for the email campaign. marketing_id = ' . $marketing_id);
             return false;
         }
         //verify the email template.
         if (empty($email_marketing->template_id)) {
             $GLOBALS['log']->fatal('Error retrieving template for the email campaign. marketing_id = ' . $marketing_id);
             return false;
         }
         if (!class_exists('EmailTemplate')) {
         }
         $emailtemplate = new EmailTemplate();
         $ret = $emailtemplate->retrieve($email_marketing->template_id);
         if (empty($ret)) {
             $GLOBALS['log']->fatal('Error retrieving template for the email campaign. template_id = ' . $email_marketing->template_id);
             return false;
         }
         if (empty($emailtemplate->subject) and empty($emailtemplate->body) and empty($emailtemplate->body_html)) {
             $GLOBALS['log']->fatal('Email template is empty. email_template_id=' . $email_marketing->template_id);
             return false;
         }
     }
     $this->verified_email_marketing_ids[$marketing_id] = 1;
     return true;
 }
Esempio n. 7
0
        $master = 'send';
    } elseif ($_REQUEST['wiz_home_next_step'] == 2) {
        //user has chosen to save and send this campaign in test mode
        $master = 'test';
    } else {
        //user has chosen to simply save
        $master = 'save';
    }
} else {
    //default to just saving and exiting wizard
    $master = 'save';
}
$prefix = 'wiz_step3_';
$marketing = new EmailMarketing();
if (isset($_REQUEST['record']) && !empty($_REQUEST['record'])) {
    $marketing->retrieve($_REQUEST['record']);
}
if (!$marketing->ACLAccess('Save')) {
    ACLController::displayNoAccess(true);
    sugar_cleanup(true);
}
if (!empty($_REQUEST['assigned_user_id']) && $marketing->assigned_user_id != $_REQUEST['assigned_user_id'] && $_POST['assigned_user_id'] != $current_user->id) {
    $check_notify = TRUE;
} else {
    $check_notify = FALSE;
}
foreach ($_REQUEST as $key => $val) {
    if (strstr($key, $prefix) && strpos($key, $prefix) == 0) {
        $newkey = substr($key, strlen($prefix));
        $_REQUEST[$newkey] = $val;
    }
Esempio n. 8
0
 * The interactive user interfaces in modified source and object code versions
 * of this program must display Appropriate Legal Notices, as required under
 * Section 5 of the GNU Affero General Public License version 3.
 * 
 * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
 * these Appropriate Legal Notices must retain the display of the "Powered by
 * SugarCRM" logo. If the display of the logo is not reasonably feasible for
 * technical reasons, the Appropriate Legal Notices must display the words
 * "Powered by SugarCRM".
 ********************************************************************************/
/*********************************************************************************
 * Description:  TODO: To be written.
 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
 * All Rights Reserved.
 * Contributor(s): ______________________________________..
 ********************************************************************************/
$focus = new EmailMarketing();
if (!isset($_REQUEST['record'])) {
    sugar_die("A record number must be specified to delete the marketing campaign.");
}
$focus->retrieve($_REQUEST['record']);
if (!$focus->ACLAccess('Delete')) {
    ACLController::displayNoAccess(true);
    sugar_cleanup(true);
}
$focus->mark_deleted($_REQUEST['record']);
if (isset($_REQUEST['record'])) {
    $query = "DELETE FROM emailman WHERE marketing_id ='" . $_REQUEST['record'] . "'";
    $focus->db->query($query);
}
header("Location: index.php?module=" . $_REQUEST['return_module'] . "&action=" . $_REQUEST['return_action'] . "&record=" . $_REQUEST['return_id']);
Esempio n. 9
0
        $query .= " and prospect_lists.deleted=0 ";
        $query .= " and prospect_lists.list_type='test' ";
        $query .= " and plc.deleted=0 ";
        $query .= " and plc.campaign_id='{$campaign_id}'";
        $query .= " and email_marketing.campaign_id='{$campaign_id}'";
        $query .= " and email_marketing.deleted=0 ";
        $query .= " and email_marketing.all_prospect_lists=0 ";
        $seed = array();
        $result = $focus->db->query($query);
        while (($row = $focus->db->fetchByAssoc($result)) != null) {
            $bean = new EmailMarketing();
            $bean->retrieve($row['email_marketing_id']);
            $bean->mode = 'test';
            $seed[] = $bean;
        }
        $query = " select email_marketing.id email_marketing_id from email_marketing ";
        $query .= " WHERE email_marketing.campaign_id='{$campaign_id}'";
        $query .= " and email_marketing.deleted=0 ";
        $query .= " and email_marketing.all_prospect_lists=1 ";
        $result = $focus->db->query($query);
        while (($row = $focus->db->fetchByAssoc($result)) != null) {
            $bean = new EmailMarketing();
            $bean->retrieve($row['email_marketing_id']);
            $bean->mode = 'test';
            $seed[] = $bean;
        }
        $ListView->processListView($seed, "main", "EMAILMARKETING");
    } else {
        $ListView->processListView($focus, "main", "EMAILMARKETING");
    }
}
Esempio n. 10
0
 ********************************************************************************/
global $timedate;
global $current_user;
if (!empty($_POST['meridiem'])) {
    $_POST['time_start'] = $timedate->merge_time_meridiem($_POST['time_start'], $timedate->get_time_format(), $_POST['meridiem']);
}
if (empty($_REQUEST['time_start'])) {
    $_REQUEST['date_start'] = $_REQUEST['date_start'] . ' 00:00';
    $_POST['date_start'] = $_POST['date_start'] . ' 00:00';
} else {
    $_REQUEST['date_start'] = $_REQUEST['date_start'] . ' ' . $_REQUEST['time_start'];
    $_POST['date_start'] = $_POST['date_start'] . ' ' . $_POST['time_start'];
}
$marketing = new EmailMarketing();
if (isset($_POST['record']) && !empty($_POST['record'])) {
    $marketing->retrieve($_POST['record']);
}
if (!$marketing->ACLAccess('Save')) {
    ACLController::displayNoAccess(true);
    sugar_cleanup(true);
}
if (!empty($_POST['assigned_user_id']) && $marketing->assigned_user_id != $_POST['assigned_user_id'] && $_POST['assigned_user_id'] != $current_user->id) {
    $check_notify = TRUE;
} else {
    $check_notify = FALSE;
}
foreach ($marketing->column_fields as $field) {
    if ($field == 'all_prospect_lists') {
        if (isset($_POST[$field]) && ($_POST[$field] = 'on')) {
            $marketing->{$field} = 1;
        } else {
        $master = 'send';
    } elseif ($_REQUEST['wiz_home_next_step'] == 2) {
        //user has chosen to save and send this campaign in test mode
        $master = 'test';
    } else {
        //user has chosen to simply save
        $master = 'save';
    }
} else {
    //default to just saving and exiting wizard
    $master = 'save';
}
$prefix = 'wiz_step3_';
$marketing = new EmailMarketing();
if (isset($_REQUEST['record']) && !empty($_REQUEST['record'])) {
    $marketing->retrieve($_REQUEST['record']);
} else {
    if (!empty($_SESSION['campaignWizard'][$_REQUEST['campaign_id']]['defaultSelectedMarketingId'])) {
        $marketing->retrieve($_SESSION['campaignWizard'][$_REQUEST['campaign_id']]['defaultSelectedMarketingId']);
    }
}
if (!$marketing->ACLAccess('Save')) {
    ACLController::displayNoAccess(true);
    sugar_cleanup(true);
}
if (!empty($_REQUEST['assigned_user_id']) && $marketing->assigned_user_id != $_REQUEST['assigned_user_id'] && $_POST['assigned_user_id'] != $current_user->id) {
    $check_notify = TRUE;
} else {
    $check_notify = FALSE;
}
foreach ($_REQUEST as $key => $val) {
Esempio n. 12
0
if(!empty($_SESSION['campaignWizardSelectedMarketingId']) && !in_array($_SESSION['campaignWizardSelectedMarketingId'], $mrkt_lists)) {
    unset($_SESSION['campaignWizardSelectedMarketingId']);
}

if(!empty($_SESSION['campaignWizardSelectedMarketingId'])) {
    if(!empty($_REQUEST['record']) && in_array($_SESSION['campaignWizardSelectedMarketingId'], $mrkt_lists)) {
        $_REQUEST['record'] = $_SESSION['campaignWizardSelectedMarketingId'];
    }
    if(!empty($_REQUEST['marketing_id']) && in_array($_SESSION['campaignWizardSelectedMarketingId'], $mrkt_lists)) {
        $_REQUEST['marketing_id'] = $_SESSION['campaignWizardSelectedMarketingId'];
    }
}

//if record param exists and it is not empty, then retrieve this bean
if(isset($_REQUEST['record']) and !empty($_REQUEST['record'])){
    $mrkt_focus->retrieve($_REQUEST['record']);
    $_SESSION['campaignWizardSelectedMarketingId'] = $mrkt_focus->id;
}
else if(isset($_REQUEST['marketing_id']) and !empty($_REQUEST['marketing_id'])) {
    $mrkt_focus->retrieve($_REQUEST['marketing_id']);
    $_SESSION['campaignWizardSelectedMarketingId'] = $mrkt_focus->id;
}else{



    if(!isset($mrkt_lists) || !$mrkt_lists) {
        unset($_SESSION['campaignWizardSelectedMarketingId']);
    }
    else if(count($mrkt_lists) == 1){
        $mrkt_focus->retrieve($mrkt_lists[0]);
        $_SESSION['campaignWizardSelectedMarketingId'] = $mrkt_lists[0];
Esempio n. 13
0
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
 * these Appropriate Legal Notices must retain the display of the "Powered by
 * SugarCRM" logo and "Supercharged by SuiteCRM" logo. If the display of the logos is not
 * reasonably feasible for  technical reasons, the Appropriate Legal Notices must
 * display the words  "Powered by SugarCRM" and "Supercharged by SuiteCRM".
 ********************************************************************************/

global $db;

$campaignId = $db->quote($_POST['campaignId']);
$marketingId = $db->quote($_POST['marketingId']);
if(!empty($_POST['templateId'])) {
    $templateId = $db->quote($_POST['templateId']);
}

//$campaign = new Campaign();
//$campaign->retrieve($campaignId);

$marketing = new EmailMarketing();
$marketing->retrieve($marketingId);
$marketing->campaign_id = $campaignId;
if(!empty($_POST['templateId'])) {
    $marketing->template_id = $templateId;
}
$marketing->save();

$_SESSION['campaignWizardSelectedMarketingId'] = $marketing->id;

echo json_encode($_POST);