public function setup()
 {
     global $current_user;
     $current_user = SugarTestUserUtilities::createAnonymousUser();
     //for the purpose of this test, we need to create a campaign and relate it to a campaign tracker object
     //create campaign
     $c = new Campaign();
     $c->name = 'CT test ' . time();
     $c->campaign_type = 'Email';
     $c->status = 'Active';
     $timeDate = new TimeDate();
     $c->end_date = $timeDate->to_display_date(date('Y') + 1 . '-01-01');
     $c->assigned_id = $current_user->id;
     $c->team_id = '1';
     $c->team_set_id = '1';
     $c->save();
     $this->campaign = $c;
     //create campaign tracker
     $ct = new CampaignTracker();
     $ct->tracker_name = 'CampaignTrackerTest' . time();
     $ct->tracker_url = 'sugarcrm.com';
     $ct->campaign_id = $this->campaign->id;
     $ct->save();
     $this->campaign_tracker = $ct;
 }
 public function testsave()
 {
     $campaignTracker = new CampaignTracker();
     $campaignTracker->tracker_name = 'test';
     $campaignTracker->is_optout = 1;
     $campaignTracker->save();
     //test for record ID to verify that record is saved
     $this->assertTrue(isset($campaignTracker->id));
     $this->assertEquals(36, strlen($campaignTracker->id));
     //mark the record as deleted and verify that this record cannot be retrieved anymore.
     $campaignTracker->mark_deleted($campaignTracker->id);
     $result = $campaignTracker->retrieve($campaignTracker->id);
     $this->assertEquals(null, $result);
 }
示例#3
0
require_once 'include/formbase.php';
$focus = new CampaignTracker();
$focus->retrieve($_POST['record']);
if (!$focus->ACLAccess('Save')) {
    ACLController::displayNoAccess(true);
    sugar_cleanup(true);
}
$check_notify = FALSE;
foreach ($focus->column_fields as $field) {
    if (isset($_POST[$field])) {
        $value = $_POST[$field];
        $focus->{$field} = $value;
    }
}
foreach ($focus->additional_column_fields as $field) {
    if (isset($_POST[$field])) {
        $value = $_POST[$field];
        $focus->{$field} = $value;
    }
}
//set check box states.
if (isset($_POST['is_optout']) && $_POST['is_optout'] == 'on') {
    $focus->is_optout = 1;
    $focus->tracker_url = 'index.php?entryPoint=removeme';
} else {
    $focus->is_optout = 0;
}
$focus->save($check_notify);
$return_id = $focus->id;
$GLOBALS['log']->debug("Saved record with id of " . $return_id);
handleRedirect('', '');
            $campaign_focus->load_relationship('tracked_urls');
            $campaign_focus->tracked_urls->add($ct_focus->id);
        }
    }
}
//create new campaign tracker and save if defined
if (isset($_REQUEST['wiz_list_of_trackers'])) {
    $tracker_strings = explode(",", $_REQUEST['wiz_list_of_trackers']);
    foreach ($tracker_strings as $trkr_string) {
        $tracker_values = explode("@@", $trkr_string);
        if (count($tracker_values) == 3) {
            $ct_focus = new CampaignTracker();
            $ct_focus->tracker_name = $tracker_values[0];
            $ct_focus->is_optout = $tracker_values[1];
            $ct_focus->tracker_url = $tracker_values[2];
            $ct_focus->save();
            //load relationship and add to the list
            $campaign_focus->load_relationship('tracked_urls');
            $campaign_focus->tracked_urls->add($ct_focus->id);
        }
    }
}
//set navigation details
$_REQUEST['return_id'] = $campaign_focus->id;
$_REQUEST['return_module'] = $campaign_focus->module_dir;
$_REQUEST['return_action'] = "WizardNewsLetter";
$_REQUEST['action'] = "WizardMarketing";
$_REQUEST['record'] = $campaign_focus->id;
$action = '';
if (isset($_REQUEST['wiz_direction']) && $_REQUEST['wiz_direction'] == 'continue') {
    $action = 'WizardMarketing';
示例#5
0
 public function setup()
 {
     global $current_user;
     $current_user = SugarTestUserUtilities::createAnonymousUser();
     //for the purpose of this test, we need to create some records with fake campaign and prospect list data,
     //however we do need to create some targets for the prospect list
     //create campaign tracker
     $ct = new CampaignTracker();
     $ct->tracker_name = 'Campaign Log Unit Test Tracker';
     $ct->tracker_url = 'sugarcrm.com';
     $ct->campaign_id = $this->campaign_id;
     $ct->save();
     $this->campaign_tracker = $ct;
     //for each type, create an object and populate the campaignLog list
     foreach ($this->targetObjectArray as $type) {
         //skip campaign tracker
         if ($type == 'CampaignTracker') {
             continue;
         }
         //create the new bean
         $bean = new $type();
         if ($type == 'Account') {
             $bean->name = 'CampLog Unit Test Account';
         } else {
             $bean->first_name = 'CampaignLog';
             $bean->last_name = 'Test ' . $type;
         }
         $type_obj = 'target_' . $type;
         $bean->save();
         $this->{$type_obj} = $bean;
         //save email
         $sea = new SugarEmailAddress();
         $id = $this->{$type_obj}->id;
         $module = $this->{$type_obj}->module_dir;
         $new_addrs = array();
         $primary = '';
         $replyTo = '';
         $invalid = '';
         $optOut = '';
         $in_workflow = false;
         $_REQUEST[$module . '_email_widget_id'] = 0;
         $_REQUEST[$module . '0emailAddress0'] = $type . '*****@*****.**';
         $_REQUEST[$module . 'emailAddressPrimaryFlag'] = '0emailAddress0';
         $_REQUEST[$module . 'emailAddressVerifiedFlag0'] = 'true';
         $_REQUEST[$module . 'emailAddressVerifiedValue0'] = '*****@*****.**';
         $requestVariablesSet = array('0emailAddress0', 'emailAddressPrimaryFlag', 'emailAddressVerifiedFlag0', 'emailAddressVerifiedValue0');
         $sea->save($id, $module, $new_addrs, $primary, $replyTo, $invalid, $optOut, $in_workflow);
         //unset email request values for next run
         foreach ($requestVariablesSet as $k) {
             unset($_REQUEST[$k]);
         }
         //now create the campaign log
         $cl = new CampaignLog();
         $cl->campaign_id = $this->campaign_id;
         $cl->tracker_key = $ct->tracker_key;
         $cl->target_id = $bean->id;
         $cl->target_type = $bean->module_dir;
         $cl->activity_type = 'targeted';
         //options are targeted (user was sent an email), link (user clicked on link), removed (user opted out) and viewed (viewed)
         $cl->activity_date = date('Y-m-d H:i:s');
         $cl->related_id = 'somebogusemailid' . date('His');
         // this means link will not really work, but we are not testing email
         $cl->related_type = 'Emails';
         $cl->list_id = $this->prospect_list_id;
         $cl->marketing_id = $this->email_marketing_id;
         $cl->save();
     }
     //keep last created campaign log bean to be used to call functions
     $this->campaign_log = $cl;
 }