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 testfill_in_additional_detail_fields() { $campaignTracker = new CampaignTracker(); //test without is_optout set $campaignTracker->fill_in_additional_detail_fields(); $this->assertStringEndsWith('/index.php?entryPoint=campaign_trackerv2&track=', $campaignTracker->message_url); //test with is_optout set $campaignTracker->is_optout = 1; $campaignTracker->fill_in_additional_detail_fields(); $this->assertStringEndsWith('/index.php?entryPoint=removeme&identifier={MESSAGE_ID}', $campaignTracker->message_url); }
public static function preserveReferer() { if (array_key_exists('HTTP_REFERER', $_SERVER)) { $referer = $_SERVER['HTTP_REFERER']; // only set if referrer is not on this site if (strpos($referer, UserConfig::$SITEROOTFULLURL) === 0) { return; } $storage = new MrClay_CookieStorage(array('secret' => UserConfig::$SESSION_SECRET, 'mode' => MrClay_CookieStorage::MODE_ENCRYPT, 'path' => UserConfig::$SITEROOTURL, 'expire' => 0, 'httponly' => true)); if (!$storage->store(UserConfig::$entry_referer_key, $referer)) { throw new Exception(implode("\n", $storage->errors)); } self::$referer = $referer; } }
//Assign NewsLetter as type of campaign being created an disable the select widget $ss->assign("CAMPAIGN_TYPE_OPTIONS", $mod_strings['LBL_NEWSLETTER']); $ss->assign("SHOULD_TYPE_BE_DISABLED", "input type='hidden' value='NewsLetter'"); } /*************** TRACKER UI DIV Stuff ***************/ //retrieve the trackers $focus->load_relationship('tracked_urls'); $trkr_lists = $focus->tracked_urls->get(); $trkr_html = ''; $ss->assign('TRACKER_COUNT', count($trkr_lists)); if (count($trkr_lists) > 0) { global $odd_bg, $even_bg, $hilite_bg; $trkr_count = 0; //create the html to create tracker table foreach ($trkr_lists as $trkr_id) { $ct_focus = new CampaignTracker(); $ct_focus->retrieve($trkr_id); if (isset($ct_focus->tracker_name) && !empty($ct_focus->tracker_name)) { if ($ct_focus->is_optout) { $opt = 'checked'; } else { $opt = ''; } $trkr_html .= "<div id='existing_trkr" . $trkr_count . "'> <table width='100%' border='0' cellspacing='0' cellpadding='0'>"; $trkr_html .= "<tr class='evenListRowS1'><td width='15%'><input name='wiz_step3_is_optout" . $trkr_count . "' title='" . $mod_strings['LBL_EDIT_OPT_OUT'] . $trkr_count . "' id='existing_is_optout" . $trkr_count . "' class='checkbox' type='checkbox' {$opt} /><input name='wiz_step3_id" . $trkr_count . "' value='" . $ct_focus->id . "' id='existing_tracker_id" . $trkr_count . "'type='hidden''/></td>"; $trkr_html .= "<td width='40%'> <input id='existing_tracker_name" . $trkr_count . "' type='text' size='20' maxlength='255' name='wiz_step3_tracker_name" . $trkr_count . "' title='" . $mod_strings['LBL_EDIT_TRACKER_NAME'] . $trkr_count . "' value='" . $ct_focus->tracker_name . "' ></td>"; $trkr_html .= "<td width='40%'><input type='text' size='60' maxlength='255' name='wiz_step3_tracker_url" . $trkr_count . "' title='" . $mod_strings['LBL_EDIT_TRACKER_URL'] . $trkr_count . "' id='existing_tracker_url" . $trkr_count . "' value='" . $ct_focus->tracker_url . "' ></td>"; $trkr_html .= "<td><a href='#' onclick=\"javascript:remove_existing_tracker('existing_trkr" . $trkr_count . "','" . $ct_focus->id . "'); \" > "; $trkr_html .= "<img src='" . SugarThemeRegistry::current()->getImageURL("delete_inline.gif") . "' border='0' alt='rem' align='absmiddle' border='0' height='12' width='12'>" . $mod_strings['LBL_REMOVE'] . "</a></td></tr></table></div>"; } $trkr_count = $trkr_count + 1;
function create_tracker_summary($focus) { global $mod_strings, $app_strings; $colorclass = ''; $trkr_tbl = ''; //create tracker table $focus->load_relationship('tracked_urls'); $trkr_lists = $focus->tracked_urls->get(); $trkr_tbl = "<p><table align='center' class='list view' width='100%' border='0' cellspacing='1' cellpadding='1'>"; $trkr_tbl .= "<tr class='detail view'><td colspan='6'><h4> " . $mod_strings['LBL_NAVIGATION_MENU_TRACKERS'] . " </h4></td></tr>"; $trkr_tbl .= "<tr class='listViewHRS1'><td width='15%' scope='col'><b>" . $mod_strings['LBL_EDIT_TRACKER_NAME'] . "</b></td><td width='15%' scope='col'><b>" . $mod_strings['LBL_EDIT_TRACKER_URL'] . "</b></td><td width='15%' scope='col'><b>" . $mod_strings['LBL_EDIT_OPT_OUT'] . "</b></td></tr>"; if (count($trkr_lists) > 0) { foreach ($trkr_lists as $trkr_id) { if ($colorclass == "class='evenListRowS1'") { $colorclass = "class='oddListRowS1'"; } else { $colorclass = "class='evenListRowS1'"; } $ct_focus = new CampaignTracker(); $ct_focus->retrieve($trkr_id); if (isset($ct_focus->tracker_name) && !empty($ct_focus->tracker_name)) { if ($ct_focus->is_optout) { $opt = 'checked'; } else { $opt = ''; } $trkr_tbl .= "<tr {$colorclass}>"; $trkr_tbl .= "<td scope='row' ><a href='index.php?action=DetailView&module=CampaignTrackers&return_module=Campaigns&return_action=WizardHome&return_id=" . $focus->id . "&record=" . $ct_focus->id . "'>"; $trkr_tbl .= $ct_focus->tracker_name . "</a></td>"; $trkr_tbl .= "<td scope='row' width='15%'>" . $ct_focus->tracker_url . "</td>"; $trkr_tbl .= "<td scope='row' width='15%'> <input type='checkbox' class='checkbox' {$opt} disabled></td>"; $trkr_tbl .= "</tr>"; } } } else { $trkr_tbl .= "<tr ><td colspan='3'>" . $mod_strings['LBL_NONE'] . "</td>"; } $trkr_tbl .= "</table></p>"; return $trkr_tbl; }
* 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): ______________________________________.. ********************************************************************************/ 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];
$ct_focus->is_optout = $tracker_values[2]; $ct_focus->tracker_url = $tracker_values[3]; $ct_focus->save(); //load relationship and add to the list $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";
* * 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): ______________________________________.. ********************************************************************************/ global $app_strings; global $mod_strings; $focus = new CampaignTracker(); $focus->retrieve($_REQUEST['record']); if (isset($_REQUEST['isDuplicate']) && $_REQUEST['isDuplicate'] == 'true') { $focus->id = ""; } echo getClassicModuleTitle($mod_strings['LBL_MODULE_NAME'], array($mod_strings['LBL_MODULE_NAME'], $focus->tracker_name), true); $GLOBALS['log']->info("campaign tracker detail view"); $xtpl = new XTemplate('modules/CampaignTrackers/DetailView.html'); $xtpl->assign("MOD", $mod_strings); $xtpl->assign("APP", $app_strings); if (isset($_REQUEST['return_module'])) { $xtpl->assign("RETURN_MODULE", $_REQUEST['return_module']); } else { $xtpl->assign("RETURN_MODULE", 'Campaigns'); } if (isset($_REQUEST['return_action'])) {
* Contributor(s): ______________________________________. ********************************************************************************/ /********************************************************************************* * Description: TODO: To be written. * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. * All Rights Reserved. * Contributor(s): ______________________________________.. ********************************************************************************/ require_once 'XTemplate/xtpl.php'; require_once 'data/Tracker.php'; require_once 'modules/CampaignTrackers/CampaignTracker.php'; global $app_strings; global $app_list_strings; global $mod_strings; global $sugar_version, $sugar_config; $focus = new CampaignTracker(); if (isset($_REQUEST['record'])) { $focus->retrieve($_REQUEST['record']); } $old_id = ''; if (isset($_REQUEST['isDuplicate']) && $_REQUEST['isDuplicate'] == 'true') { $focus->id = ""; } echo "\n<p>\n"; echo get_module_title($mod_strings['LBL_MODULE_NAME'], $mod_strings['LBL_MODULE_NAME'] . ": " . $focus->tracker_name, true); echo "\n</p>\n"; global $theme; $theme_path = "themes/" . $theme . "/"; $image_path = $theme_path . "images/"; require_once $theme_path . 'layout_utils.php'; $GLOBALS['log']->info("Campaign Tracker Edit View");
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; }
} //create the type dropdown domain and set the selected value if $opp value already exists foreach ($key_list as $option_key => $option_value) { $select_options .= '<OPTION value="'.$option_key.'" data-id="'.$label_list[$option_key]['id'].'" data-url="'.$label_list[$option_key]['url'].'">'.$label_list[$option_key]['text'].'</OPTION>'; } $select_options = preg_replace($pattern, $replacement, $select_options); return $select_options; }; $ss->assign("TRACKER_KEY_OPTIONS", $get_tracker_options($campaign_urls, $campaign_urls, null)); //$ss->parse("main.NoInbound.tracker_url"); // create tracker URL fields $campaignTracker = new CampaignTracker(); if(isset($_REQUEST['campaign_tracker_id']) && $_REQUEST['campaign_tracker_id']) { $campaignTracker->retrieve((int) $_REQUEST['campaign_tracker_id']); } // todo: hide tracker select if it has no trackers $ss->assign("TRACKER_NAME", isset($focus) ? $focus->tracker_name : null); $ss->assign("TRACKER_URL", isset($focus) ? $focus->tracker_url : null); if (!empty($focus->is_optout) && $focus->is_optout == 1) { $ss->assign("IS_OPTOUT_CHECKED","checked"); $ss->assign("TRACKER_URL_DISABLED","disabled"); } } } // create option of "Contact/Lead/Task" from corresponding module // translations
<?php /* * Users.php * * This is a main file to be included into pap pages */ require_once dirname(__FILE__) . '/config.php'; require_once dirname(__FILE__) . '/User.php'; require_once dirname(__FILE__) . '/Plan.php'; require_once dirname(__FILE__) . '/Account.php'; require_once dirname(__FILE__) . '/Cohort.php'; require_once dirname(__FILE__) . '/Feature.php'; require_once dirname(__FILE__) . '/CampaignTracker.php'; // do this on each page view (where user.php is included) CampaignTracker::preserveReferer(); CampaignTracker::recordCampaignVariables(); User::updateReturnActivity(); // only if user is logged in
private function setRegCampaign() { $campaign = CampaignTracker::getCampaign(); if (is_null($campaign) || !$campaign) { return; } $db = UserConfig::getDB(); $cmp_source_id = null; if (array_key_exists('cmp_source', $campaign)) { $cmp_source_id = CampaignTracker::getCampaignSourceID($campaign['cmp_source']); } $cmp_medium_id = null; if (array_key_exists('cmp_medium', $campaign)) { $cmp_medium_id = CampaignTracker::getCampaignMediumID($campaign['cmp_medium']); } $cmp_keywords_id = null; if (array_key_exists('cmp_keywords', $campaign)) { $cmp_keywords_id = CampaignTracker::getCampaignKeywordsID($campaign['cmp_keywords']); } $cmp_content_id = null; if (array_key_exists('cmp_content', $campaign)) { $cmp_content_id = CampaignTracker::getCampaignContentID($campaign['cmp_content']); } $cmp_name_id = null; if (array_key_exists('cmp_name', $campaign)) { $cmp_name_id = CampaignTracker::getCampaignNameID($campaign['cmp_name']); } // update user record with compaign IDs if ($stmt = $db->prepare('UPDATE ' . UserConfig::$mysql_prefix . 'users SET reg_cmp_source_id = ?, reg_cmp_medium_id = ?, reg_cmp_keywords_id = ?, reg_cmp_content_id = ?, reg_cmp_name_id = ? WHERE id = ?')) { if (!$stmt->bind_param('sssssi', $cmp_source_id, $cmp_medium_id, $cmp_keywords_id, $cmp_content_id, $cmp_name_id, $this->userid)) { throw new Exception("Can't bind parameter" . $stmt->error); } if (!$stmt->execute()) { throw new Exception("Can't execute statement: " . $stmt->error); } $stmt->close(); } else { throw new Exception("Can't prepare statement: " . $db->error); } }