예제 #1
0
function statistics($listId, $listType, $mailingId, $message, $task, $action)
{
    global $database;
    $erro = new xerr(__FILE__, __FUNCTION__);
    switch ($task) {
        case 'edit':
        case 'view':
            $mailing = xmailing::getOneMailing(0, $mailingId, '', $new);
            $list = lists::getOneList($mailing->list_id);
            $listId = $list->id;
            $listType = $list->list_type;
            if ($mailingId != 0) {
                $query = 'SELECT * FROM `#__acajoom_stats_global` WHERE `mailing_id` = \'' . $mailingId . '\'';
                $database->setQuery($query);
                $database->loadObject($globalStats);
                $erro->err = $database->getErrorMsg();
                if (empty($globalStats)) {
                    $globalStats->html_sent = '';
                    $globalStats->html_read = 0;
                    $globalStats->text_sent = '';
                }
                $query = 'SELECT U.name, U.email, D.html, D.read FROM `#__acajoom_stats_details` as D ' . 'LEFT JOIN `#__acajoom_subscribers` as U ON D.subscriber_id=U.id WHERE  D.mailing_id = \'' . $mailingId . '\'';
                $database->setQuery($query);
                $detailedStats = $database->loadObjectList();
                $erro->err .= $database->getErrorMsg();
                $erro->show();
                if (!$erro->E(__LINE__, '8009')) {
                    return false;
                } else {
                    $html_read = array();
                    $html_unread = array();
                    $text = array();
                    foreach ($detailedStats as $detailedStat) {
                        if ($detailedStat->html == 1) {
                            if ($detailedStat->read == 1) {
                                $html_read[] = $detailedStat;
                            } else {
                                $html_unread[] = $detailedStat;
                            }
                        } else {
                            $text[] = $detailedStat;
                        }
                    }
                    backHTML::_header(_ACA_MENU_STATS, 'query.png', $message, $task, $action);
                    backHTML::showStatistics($list, $mailing, $globalStats, $html_read, $html_unread, $text, $listId);
                }
            } else {
                echo '<p> Please select a mailings id.</p>';
                return false;
            }
            break;
        case 'cancel':
            compa::redirect('index2.php?option=com_acajoom&act=statistics&listid=' . $listId);
            break;
        case 'cpanel':
            backHTML::controlPanel();
            break;
        default:
            backHTML::_header(_ACA_MENU_STATS, 'query.png', $message, $task, $action);
            xmailing::showMailings($task, $action, $listId, $listType, '', false, _ACA_MENU_STATS_FOR);
    }
}