/** * showOptionsPage * Displays the print option page. * * @return Void Does not return anything. */ function showOptionsPage() { $statstype = $this->_getGETRequest('statstype', null); if ($statstype == null) { return false; exit; } $path = $this->_getGETRequest('path', ''); SendStudio_Functions::LoadLanguageFile('stats'); $stats_api = $this->GetApi('Splittest_Stats'); $bg_color = 'white'; $print_options = '<input type="hidden" name="statstype" value="' . htmlentities($statstype, ENT_QUOTES, SENDSTUDIO_CHARSET) . '" />'; switch ($statstype) { case 'splittest': $splitStatIds = $this->_getGETRequest('statids', null); $jobIds = $this->_getGETRequest('jobids', null); $splitStatIds = SplitTest_API::FilterIntSet($splitStatIds); $jobIds = SplitTest_API::FilterIntSet($jobIds); $print_options .= '<input type="hidden" name="split_statids" value="' . implode(',', $splitStatIds) . '" />'; $print_options .= '<input type="hidden" name="jobids" value="' . implode(',', $jobIds) . '" />'; $options = array('snapshot' => GetLang('Addon_splittest_Menu_ViewStats'), 'open' => GetLang('Addon_splittest_open_summary'), 'click' => GetLang('Addon_splittest_linkclick_summary'), 'bounce' => GetLang('Addon_splittest_bounce_summary'), 'unsubscribe' => GetLang('Addon_splittest_unsubscribe_summary')); foreach ($options as $key => $val) { $bg_color = $bg_color == 'white' ? '#EDECEC' : 'white'; $print_options .= '<div style="background-color: ' . $bg_color . '; padding: 5px; margin-bottom: 5px;">'; $print_options .= '<input id="print_' . $key . '" type="checkbox" name="options[]" value="' . $key . '" checked="checked" style="margin:0;"/> <label for="print_' . $key . '">' . $val . '</label>' . "\n"; $print_options .= '</div>' . "\n"; } break; } $this->template_system->assign('path', $path); $this->template_system->Assign('title', GetLang('Addon_splittest_PrintSplitTestStatistics')); $this->template_system->Assign('print_options', $print_options); $this->template_system->ParseTemplate('print_stats_options'); }
/** * The control flow entry point from the stats add-on. * * @return String The HTML to output. */ public function Route() { SendStudio_Functions::LoadLanguageFile('stats'); $split_id = $this->_getGetRequest('splitid', null); if (!is_null($split_id)) { return $this->ShowStats($split_id); } return $this->ManageStats(); }
/** * printPage * * @return Void Doesn't return anything. */ public function printPage() { $user = GetUser(); $split_api = $this->GetApi('Splittest'); // for permission checks $subaction = $this->_getGetRequest('subaction', 'print'); $perpage = $this->_getGetRequest('PerPageDisplay', null); $jobids = $this->_getGETRequest('jobids', null); $listids = $this->_getGETRequest('split_statids', null); $jobids = explode(",", $jobids); $listids = explode(",", $listids); SendStudio_Functions::LoadLanguageFile('Stats'); if (!SplitTest_API::OwnsJobs($user->Get('userid'), $jobids) && !$user->Admin()) { FlashMessage(GetLang('NoAccess'), SS_FLASH_MSG_ERROR, $this->base_url); return; } // Get some setup parameters for the API $sortdetails = array('sort' => 'splitname', 'direction' => 'asc'); $page_number = 0; $perpage = 20; $displayAll = false; // just show a single splitest campaign send. If you want every campaign send for a split test set to true $dateFromat = self::getDateFormat(); $statitics = array(); $jobid = 0; for ($i = 0; $i < count($jobids); $i++) { $stats = array(); $stats_api = new Splittest_Stats_API(); $jobid = $jobids[$i]; $splitid = $listids[$i]; // get the array of stats data $stats = $stats_api->GetStats(array($splitid), $sortdetails, false, $page_number, $perpage, $displayAll, $jobid); foreach ($stats as $stats_id => $stats_details) { $stats[$stats_id]['splitname'] = htmlspecialchars($stats_details['splitname'], ENT_QUOTES, SENDSTUDIO_CHARSET); $stats[$stats_id]['campaign_names'] = htmlspecialchars($stats_details['campaign_names'], ENT_QUOTES, SENDSTUDIO_CHARSET); $stats[$stats_id]['list_names'] = htmlspecialchars($stats_details['list_names'], ENT_QUOTES, SENDSTUDIO_CHARSET); } // A Splittest can be sent multiple times hence we might have multiple campaign record sets here while (list($id, $data) = each($stats)) { $charts = $this->generateCharts($data['splitname'], $data['campaigns'], $subaction); foreach ($charts as $type => $data) { $stats[$id][$type] = $data; } } $statistics[] = $stats; } $template = GetTemplateSystem(dirname(__FILE__) . '/templates'); $template->Assign('DateFormat', $dateFromat); $template->Assign('statsData', $statistics); $template->Assign('subaction', $subaction); $options = $this->_getGETRequest('options', null); for ($i = 0; $i < count($options); $i++) { $template->Assign($options[$i], $options[$i]); } $template->ParseTemplate('Stats_Summary_Splittest'); }
/** * Show_Send_Step_2 * This handles the second step of the send process where * * 1) the first step is verified in php * - checks you are choosing a list or segment * - checks the list/segment id's are valid (ie they are proper id's and not non-numeric values) * - checks the list or segment has contacts in it * * If that checks out ok, the second step shows the form where you set: * - from details * - bounce details * - whether to send the campaigns as multipart (where possible) * - whether to embed images or not (where possible) * - choose the first/last name custom fields * - when to send the split test (if cron is enabled) * * @uses FlashMessage * @uses GetFlashMessages * @uses List_API::Load * @uses List_API::GetCustomFields * @uses Segment_API::Load * @uses GetUser * @uses User_API::HasAccess * @uses CheckCronEnabled */ public function Show_Send_Step_2() { $send_details = IEM::sessionGet('SplitTestSend'); /** * Check the user has been through step 1 successfully. */ if (!$send_details || !isset($send_details['splitid']) || (int) $send_details['splitid'] <= 0) { FlashMessage(GetLang('Addon_splittest_Send_InvalidSplitTest'), SS_FLASH_MSG_ERROR, $this->admin_url); return; } $step1_url = $this->admin_url . '&Action=Send&id=' . $send_details['splitid']; $flash_messages = GetFlashMessages(); /** * If we are not posting a form, maybe we're being redirected back to this step from step 3. * If we are, we'll have flash messages. * * If there are no post variables and we are not showing any messages, then go back to step 1. */ if (empty($_POST) && empty($flash_messages)) { FlashMessage(GetLang('Addon_splittest_Send_ChooseListOrSegment'), SS_FLASH_MSG_ERROR, $step1_url); return; } /** * If we are posting a form, check we are posting a proper form (we should have lists or segments chosen) */ if (!empty($_POST)) { /** * Work out which option the user chose */ $sending_to = array(); $send_type = ''; switch ((int) $_POST['ShowFilteringOptions']) { case 1: $send_type = 'list'; if (isset($_POST['lists'])) { $sending_to = $_POST['lists']; } break; case 2: $send_type = 'segment'; if (isset($_POST['segments'])) { $sending_to = $_POST['segments']; } break; default: FlashMessage(GetLang('Addon_splittest_Send_ChooseListOrSegment'), SS_FLASH_MSG_ERROR, $step1_url); return; break; } /** * Make sure the user actually chose some options. */ if (empty($sending_to)) { FlashMessage(GetLang('Addon_splittest_Send_ChooseListOrSegment'), SS_FLASH_MSG_ERROR, $step1_url); return; } /** * Make sure the id's the user chose are valid * If any area invalid (not int's), the user is thrown back to the first step. */ foreach ($sending_to as $id) { $id = (int) $id; if ($id <= 0) { FlashMessage(GetLang('Addon_splittest_Send_ChooseListOrSegment'), SS_FLASH_MSG_ERROR, $step1_url); return; } } /** * After everything has been validated, store the settings and display the next form. */ $send_details['sendingto'] = array('sendtype' => $send_type, 'sendids' => $sending_to); IEM::sessionSet('SplitTestSend', $send_details); } $user = GetUser(); /** * Re-set these variables. * They may be coming from the session if we are being redirected back to step 2 from another step. */ $send_type = $send_details['sendingto']['sendtype']; $sending_to = $send_details['sendingto']['sendids']; /** * Get the first list or segment we're sending to. * We need this to set the defaults for the from name, email, reply-to email and bounce details. * It doesn't really matter what the id is, the user can override the options anyway through the form. */ $id = $sending_to[0]; $send_size = 0; /** * We always need the list api * so we can load the right details regardless of whether the user is sending to a segment or list. */ require_once SENDSTUDIO_API_DIRECTORY . '/lists.php'; $list_api = new Lists_API(); switch ($send_type) { case 'list': $list_id = $id; $listids = $sending_to; $user_lists = $user->GetLists(); foreach ($user_lists as $user_list_id => $user_list_details) { if (!in_array($user_list_id, $sending_to)) { continue; } $send_size += $user_list_details['subscribecount']; } // this is used at a later step to check duplicates etc. $send_details['sendingto']['Lists'] = $sending_to; break; case 'segment': require_once SENDSTUDIO_API_DIRECTORY . '/subscribers.php'; $api = new Subscribers_API(); $segment_info = $api->GetSubscribersFromSegment($sending_to, true); $send_size = $segment_info['count']; /** * Since a segment can go across lists, * we only need one list - so just get the first one we come across. * The user can change the details on the fly anyway. */ $listids = $segment_info['lists']; $list_id = $listids[0]; // this is used at a later step to check duplicates etc. $send_details['sendingto']['Lists'] = $listids; break; } if ($send_size <= 0) { $var = 'Addon_splittest_Send_NoContacts_'; if (sizeof($sending_to) == 1) { $var .= 'One_'; } else { $var .= 'Many_'; } $var .= $send_type; FlashMessage(GetLang($var), SS_FLASH_MSG_ERROR, $step1_url); return; } $send_details['sendsize'] = $send_size; IEM::sessionSet('SplitTestSend', $send_details); /** * Get the flashmessage to draw the box. * then add to the existing messages (eg we're back here from step 3). */ if ($send_size == 1) { FlashMessage(GetLang('Addon_splittest_Send_Step2_Size_One'), SS_FLASH_MSG_SUCCESS); } else { FlashMessage(sprintf(GetLang('Addon_splittest_Send_Step2_Size_Many'), $this->PrintNumber($send_size)), SS_FLASH_MSG_SUCCESS); } $flash_messages .= GetFlashMessages(); $this->template_system->Assign('FlashMessages', $flash_messages, false); if (self::CheckCronEnabled()) { $this->template_system->Assign('CronEnabled', true); /** * Get the sendstudio functions file to create the date/time box. */ require_once SENDSTUDIO_FUNCTION_DIRECTORY . '/sendstudio_functions.php'; /** * also need to load the 'send' language file so it can put in the names/descriptions. */ $ssf = new SendStudio_Functions(); $ssf->LoadLanguageFile('send'); $timebox = $ssf->CreateDateTimeBox(0, false, 'datetime', true); $this->template_system->Assign('ScheduleTimeBox', $timebox, false); } $this->template_system->Assign('ShowBounceInfo', $user->HasAccess('Lists', 'BounceSettings')); $this->template_system->Assign('DisplayEmbedImages', SENDSTUDIO_ALLOW_EMBEDIMAGES); $this->template_system->Assign('EmbedImagesByDefault', SENDSTUDIO_DEFAULT_EMBEDIMAGES); $list_api->Load($list_id); $details = array('fromname' => $list_api->Get('ownername'), 'fromemail' => $list_api->Get('owneremail'), 'replytoemail' => $list_api->Get('replytoemail'), 'bounceemail' => $list_api->Get('bounceemail')); $customfield_settings = array(); $list_customfields = $list_api->GetCustomFields($listids); foreach ($list_customfields as $fieldid => $fielddetails) { if (strtolower($fielddetails['fieldtype']) != 'text') { continue; } $customfield_settings[$fieldid] = htmlspecialchars($fielddetails['name'], ENT_QUOTES, SENDSTUDIO_CHARSET); } $show_customfields = false; if (!empty($customfield_settings)) { $show_customfields = true; } $this->template_system->Assign('CustomFields', $customfield_settings); $this->template_system->Assign('ShowCustomFields', $show_customfields); foreach ($details as $name => $value) { $this->template_system->Assign($name, $value); } $this->template_system->Assign('AdminUrl', $this->admin_url, false); $this->template_system->ParseTemplate('send_step2'); }
/** * Constructor * Calls the parent object to set up the database. * Sets up references to the email api, list api and subscriber api. * * @see Email_API * @see Lists_API * @see Subscriber_API * @see newsletter_api * * @see Jobs_API::Jobs_API */ function Jobs_Autoresponders_API() { $this->LogFile = TEMP_DIRECTORY . '/autoresponder_debug.'.getmypid().'.log'; if ($this->Debug) { error_log(time() . "\t" . __FILE__ . "\t" . __LINE__ . "\t" . "---------------------\n", 3, $this->LogFile); } $this->currenttime = $this->GetServerTime(); Jobs_API::Jobs_API(false); SendStudio_Functions::LoadLanguageFile('jobs_autoresponders'); if ($this->Debug) { $this->Db->QueryLog = TEMP_DIRECTORY . '/autoresponder_queries.'.getmypid().'.log'; $this->Db->LogQuery('-----------'); $this->Db->TimeLog = TEMP_DIRECTORY . '/autoresponder_queries_timed.'.getmypid().'.log'; $this->Db->TimeQuery('-----------', 0, 0); } if (is_null($this->Email_API)) { if (!class_exists('ss_email_api', false)) { require_once(dirname(__FILE__) . '/ss_email.php'); } $email = new SS_Email_API(); $this->Email_API = &$email; } if ($this->Debug) { $this->Email_API->Debug = true; } if (is_null($this->Subscriber_API)) { if (!class_exists('subscribers_api', false)) { require_once(dirname(__FILE__) . '/subscribers.php'); } $subscribers = new Subscribers_API(); $this->Subscriber_API = &$subscribers; } if (is_null($this->Lists_API)) { if (!class_exists('lists_api', false)) { require_once(dirname(__FILE__) . '/lists.php'); } $lists = new Lists_API(); $this->Lists_API = &$lists; } if (is_null($this->autoresponder_api)) { require_once(dirname(__FILE__) . '/autoresponders.php'); $newsl = new Autoresponders_API(); $this->autoresponder_api = &$newsl; } if (is_null($this->Stats_API)) { if (!class_exists('stats_api', false)) { require_once(dirname(__FILE__) . '/stats.php'); } $statsapi = new Stats_API(); $this->Stats_API = &$statsapi; } $this->_queues_done = array(); }
/** * Constructor * Calls the parent object to set up the database. * Sets up references to the email api, list api and subscriber api. * * @see Email_API * @see Lists_API * @see Subscriber_API * @see Newsletter_API * @see Jobs_API::Jobs_API */ function Jobs_Send_API() { SendStudio_Functions::LoadLanguageFile('jobs_send'); $this->Send_API(); }
/** * Bounce * The constructor sets up the required objects, checks for imap support and loads the language files which also load up the bounce rules. * * @return Mixed Returns false if there is no imap support. Otherwise returns true once all the sub-objects are set up for easy access. */ function Bounce_API() { if (is_null($this->LogFile)) { if (defined('TEMP_DIRECTORY')) { $this->LogFile = TEMP_DIRECTORY . '/bounce.debug.log'; } } require_once dirname(dirname(__FILE__)) . '/sendstudio_functions.php'; $temp = new SendStudio_Functions(); $temp->LoadLanguageFile('jobs_bounce'); $temp->LoadLanguageFile('jobs_send'); unset($temp); if (is_null($this->Email_API)) { if (!class_exists('email_api', false)) { require_once(IEM_PATH . '/ext/interspire_email/email.php'); } $email = new Email_API(); $this->Email_API = &$email; } if (is_null($this->Subscriber_API)) { if (!class_exists('subscribers_api', false)) { require_once(dirname(__FILE__) . '/subscribers.php'); } $subscribers = new Subscribers_API(); $this->Subscriber_API = &$subscribers; } if (is_null($this->Lists_API)) { if (!class_exists('lists_api', false)) { require_once(dirname(__FILE__) . '/lists.php'); } $list = new Lists_API(); $this->Lists_API = &$list; } if (is_null($this->Stats_API)) { if (!class_exists('stats_api', false)) { require_once(dirname(__FILE__) . '/stats.php'); } $stats = new Stats_API(); $this->Stats_API = &$stats; } $this->GetDb(); return true; }