/** * 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'); }
/** * 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'); }
/** * Admin_Action_Delete * This function handles what happens when you delete a split test. * It checks you are doing a form post. * Then it grabs the api and passes the id(s) across to the api to delete. * * It checks what the api returns and creates a flash message based on the result. * Eg you can't delete a split test campaign while it's sending. * * After that, it returns you to the 'Manage' page. * * @uses SplitTest_API::Delete * @see Admin_Action_Default * @uses GetApi */ public function Admin_Action_Delete() { $user = GetUser(); $api = $this->GetApi(); $split_ids = $this->_getPOSTRequest('splitids', null); if (is_null($split_ids)) { $split_ids = $this->_getPOSTRequest('splitid', null); } if (is_null($split_ids)) { FlashMessage(GetLang('Addon_splittest_ChooseSplittestsToDelete'), SS_FLASH_MSG_ERROR, $this->admin_url); return; } $split_ids = SplitTest_API::FilterIntSet($split_ids); if (!SplitTest_API::OwnsSplitTests($user->Get('userid'), $split_ids) && !$user->Admin()) { FlashMessage(GetLang('NoAccess'), SS_FLASH_MSG_ERROR, $this->admin_url); return; } $deleted = 0; $not_deleted = 0; foreach ($split_ids as $split_id) { $delete_success = $api->Delete($split_id); if ($delete_success) { $deleted++; continue; } $not_deleted++; } /** * If there are only "delete ok" messages, then just work out the number to show * and then create a flash message. */ $url = $this->admin_url; if ($not_deleted > 0) { $url = null; } if ($deleted == 1) { FlashMessage(GetLang('Addon_splittest_SplittestDeleted_One'), SS_FLASH_MSG_SUCCESS, $url); if ($not_deleted == 0) { return; } } if ($deleted > 1) { FlashMessage(sprintf(GetLang('Addon_splittest_SplittestDeleted_Many'), self::PrintNumber($deleted)), SS_FLASH_MSG_SUCCESS, $url); if ($not_deleted == 0) { return; } } if ($not_deleted == 1) { $msg = GetLang('Addon_splittest_SplittestNotDeleted_One'); } else { $msg = sprintf(GetLang('Addon_splittest_SplittestNotDeleted_Many'), self::PrintNumber($not_deleted)); } FlashMessage($msg, SS_FLASH_MSG_ERROR, $this->admin_url); }
/** * ShowStats * Displays statistics for a split test. * * @param Int $split_id The ID of a split test. * * @return String The HTML to output. */ private function ShowStats($split_id) { $user = GetUser(); $template_name = 'splittest_campaign_stats'; $split_api = $this->GetApi('Splittest'); $stats_api = $this->GetApi('Splittest_Stats'); $date_format = self::getDateFormat(); $jobid = $this->_getGETRequest('jobid', null); if (!SplitTest_API::OwnsSplitTests($user->Get('userid'), $split_id) && !$user->Admin()) { FlashMessage(GetLang('NoAccess'), SS_FLASH_MSG_ERROR, $this->base_url); return; } $stats = $stats_api->GetStats(array($split_id), array(), false, 0, 1, false, $jobid); $stats = $stats[$jobid]; $stats['splitname'] = htmlspecialchars($stats['splitname'], ENT_QUOTES, SENDSTUDIO_CHARSET); $stats['campaign_names'] = htmlspecialchars($stats['campaign_names'], ENT_QUOTES, SENDSTUDIO_CHARSET); $stats['list_names'] = htmlspecialchars($stats['list_names'], ENT_QUOTES, SENDSTUDIO_CHARSET); $charts = $this->generateCharts($stats['splitname'], $stats['campaigns']); foreach ($charts as $type => $data) { $stats[$type] = $data; } $this->template_system->Assign('AdminUrl', $this->admin_url, false); $this->template_system->Assign('ApplicationUrl', $this->application_url, false); $this->template_system->Assign('DateFormat', $date_format); $this->template_system->Assign('statsDetails', $stats); $this->template_system->Assign('FlashMessages', GetFlashMessages()); $this->template_system->ParseTemplate($template_name); }