<commit_before><?php
require_once dirname(__FILE__).'/../accesscheck.php';
if (!defined('PHPLISTINIT')) {
    exit;
}

if (!$_GET['id']) {
    Fatal_Error(s('no such User'));

    return;
} else {
    $id = sprintf('%d', $_GET['id']);
}
$status = "";

$result = Sql_query("SELECT * FROM {$GLOBALS['tables']['user']} where id = $id");
if (!Sql_Affected_Rows()) {
    Fatal_Error(s('no such User'));

    return;
}
$user = sql_fetch_array($result);

$ls = new WebblerListing(s('Campaigns'));
if (Sql_Table_Exists($GLOBALS['tables']['usermessage'])) {
    $msgs = Sql_Query(sprintf('select messageid,entered,viewed,(viewed = 0 or viewed is null) as notviewed,
abs(unix_timestamp(entered) - unix_timestamp(viewed)) as responsetime from %s where userid = %d and status = "sent" order by entered desc',
        $GLOBALS['tables']['usermessage'], $user['id']));
    $num = Sql_Affected_Rows();
} else {
    $num = 0;
}
printf('%d '.s('messages sent to this user').'<br/>', $num);
if ($num) {
    $resptime = 0;
    $totalresp = 0;
    $ls->setElementHeading(s('Campaign'));

    while ($msg = Sql_Fetch_Array($msgs)) {
        $element = sprintf('<!--%d--> %s', $msg['messageid'],  campaignTitle($msg['messageid']));
        $ls->addElement($element, PageURL2('message', s('view'), 'id='.$msg['messageid']));

        if (defined('CLICKTRACK') && CLICKTRACK) {
            $clicksreq = Sql_Fetch_Row_Query(sprintf('select sum(clicked) as numclicks from %s where userid = %s and messageid = %s',
                $GLOBALS['tables']['linktrack_uml_click'], $user['id'], $msg['messageid']));
            $clicks = sprintf('%d', $clicksreq[0]);
            if ($clicks) {
                $ls->addColumn($element, s('clicks'),
                    PageLink2('userclicks&amp;userid='.$user['id'].'&amp;msgid='.$msg['messageid'], $clicks));
            } else {
                $ls->addColumn($element, s('clicks'), 0);
            }
        }

        $ls->addColumn($element, s('sent'), formatDateTime($msg['entered'], 1));
        if (!$msg['notviewed']) {
            $ls->addColumn($element, s('viewed'), formatDateTime($msg['viewed'], 1));
            $ls->addColumn($element, s('Response time'), secs2time($msg['responsetime']));
            $resptime += $msg['responsetime'];
            $totalresp += 1;
        }
        if (!empty($bounces[$msg['messageid']])) {
            $ls->addColumn($element, s('bounce'), $bounces[$msg['messageid']]);
        }
    }<commit_msg>Display the bounce time on the Campaigns tab.<commit_after><?php
require_once dirname(__FILE__).'/../accesscheck.php';
if (!defined('PHPLISTINIT')) {
    exit;
}

if (!$_GET['id']) {
    Fatal_Error(s('no such User'));

    return;
} else {
    $id = sprintf('%d', $_GET['id']);
}
$status = "";

$result = Sql_query("SELECT * FROM {$GLOBALS['tables']['user']} where id = $id");
if (!Sql_Affected_Rows()) {
    Fatal_Error(s('no such User'));

    return;
}
$user = sql_fetch_array($result);

$ls = new WebblerListing(s('Campaigns'));
if (Sql_Table_Exists($GLOBALS['tables']['usermessage'])) {
    $msgs = Sql_Query(sprintf(
        'select messageid,
            entered,
            viewed,
            (viewed = 0 or viewed is null) as notviewed,
            abs(unix_timestamp(entered) - unix_timestamp(viewed)) as responsetime,
            (select max(time)
                from %s umb
                where umb.message = messageid and umb.user = userid
            ) as bouncetime
            from %s
            where userid = %d and status = "sent"
            order by entered desc',
        $GLOBALS['tables']['user_message_bounce'],
        $GLOBALS['tables']['usermessage'],
        $user['id']
    ));
    $num = Sql_Affected_Rows();
} else {
    $num = 0;
}
printf('%d '.s('messages sent to this user').'<br/>', $num);
if ($num) {
    $resptime = 0;
    $totalresp = 0;
    $ls->setElementHeading(s('Campaign'));

    while ($msg = Sql_Fetch_Array($msgs)) {
        $element = sprintf('<!--%d--> %s', $msg['messageid'],  campaignTitle($msg['messageid']));
        $ls->addElement($element, PageURL2('message', s('view'), 'id='.$msg['messageid']));

        if (defined('CLICKTRACK') && CLICKTRACK) {
            $clicksreq = Sql_Fetch_Row_Query(sprintf('select sum(clicked) as numclicks from %s where userid = %s and messageid = %s',
                $GLOBALS['tables']['linktrack_uml_click'], $user['id'], $msg['messageid']));
            $clicks = sprintf('%d', $clicksreq[0]);
            if ($clicks) {
                $ls->addColumn($element, s('clicks'),
                    PageLink2('userclicks&amp;userid='.$user['id'].'&amp;msgid='.$msg['messageid'], $clicks));
            } else {
                $ls->addColumn($element, s('clicks'), 0);
            }
        }

        $ls->addColumn($element, s('sent'), formatDateTime($msg['entered'], 1));
        if (!$msg['notviewed']) {
            $ls->addColumn($element, s('viewed'), formatDateTime($msg['viewed'], 1));
            $ls->addColumn($element, s('Response time'), secs2time($msg['responsetime']));
            $resptime += $msg['responsetime'];
            $totalresp += 1;
        }

        if ($msg['bouncetime']) {
            $ls->addColumn($element, s('bounce'), formatDateTime($msg['bouncetime'], 1));
        }
    }
{'fraction_non_alphanumeric': 0.20470498956554734, 'fraction_numerical': 0.00474293302978562, 'mean_word_length': 2.984882842025699, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3216787', 'n_tokens_mistral': 1758, 'n_tokens_neox': 1704, 'n_words': 328}