示例#1
0
function export_cvs_logs($project, $span, $who)
{
    $eol = "\n";
    $sql_cvs = cvsaccess_logs_extract($project, $span, $who);
    $col_list_cvs = array('day', 'user', 'email', 'cvs_checkouts', 'cvs_browse');
    $cvs_title = array('day' => $GLOBALS['Language']->getText('project_stats_source_code_access_utils', 'cvs_access'), 'user' => '', 'email' => '', 'cvs_checkouts' => '', 'cvs_browse' => '');
    $lbl_list_cvs = array('day' => $GLOBALS['Language']->getText('project_export_access_logs_export', 'time'), 'user' => $GLOBALS['Language']->getText('project_export_access_logs_export', 'user'), 'email' => $GLOBALS['Language']->getText('project_export_access_logs_export', 'email'), 'cvs_checkouts' => $GLOBALS['Language']->getText('project_export_access_logs_export', 'chk_upd'), 'cvs_browse' => $GLOBALS['Language']->getText('project_export_access_logs_export', 'file_brows'));
    $result_cvs = db_query($sql_cvs);
    $rows_cvs = db_numrows($result_cvs);
    if ($result_cvs && $rows_cvs > 0) {
        // Build csv for cvs access logs
        echo build_csv_header($col_list_cvs, $cvs_title) . $eol;
        echo build_csv_header($col_list_cvs, $lbl_list_cvs) . $eol;
        while ($arr_cvs = db_fetch_array($result_cvs)) {
            prepare_access_logs_record($project->getGroupId(), $arr_cvs);
            echo build_csv_record($col_list_cvs, $arr_cvs) . $eol;
        }
        echo build_csv_header($col_list_cvs, array()) . $eol;
    }
}
function cvsaccess_logs_daily($project, $span = 7, $who = "allusers")
{
    $hp = Codendi_HTMLPurifier::instance();
    // check first if service is used by this project
    // if service not used return immediately
    if (!$project->usesCVS()) {
        print '<P><B><U>' . $GLOBALS['Language']->getText('project_stats_source_code_access_utils', 'service_disabled', $GLOBALS['Language']->getText('project_stats_index', 'cvs')) . '</U></B>';
        return;
    }
    $month_name = array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'June', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec');
    $sql = cvsaccess_logs_extract($project, $span, $who);
    // Executions will continue until morale improves.
    $res = db_query($sql);
    print '<P><B><U>' . $GLOBALS['Language']->getText('project_stats_source_code_access_utils', 'access_for_past_x_days', array($GLOBALS['Language']->getText('project_stats_source_code_access_utils', 'cvs_co_upd'), $hp->purify($span))) . '</U></B></P>';
    // if there are any days, we have valid data.
    if (($nb_downloads = db_numrows($res)) >= 1) {
        print '<P><TABLE width="100%" cellpadding=2 cellspacing=0 border=0>' . '<TR valign="top">' . '<TD><B>' . $GLOBALS['Language']->getText('project_admin_utils', 'date') . '</B></TD>' . '<TD><B>' . $GLOBALS['Language']->getText('project_export_utils', 'user') . '</B></TD>' . '<TD><B>' . $GLOBALS['Language']->getText('project_export_artifact_history_export', 'email') . '</B></TD>' . '<TD align><B>' . $GLOBALS['Language']->getText('project_stats_source_code_access_utils', 'co_upd') . '</B></TD>' . '<TD align><B>' . $GLOBALS['Language']->getText('project_stats_source_code_access_utils', 'browsing') . '</B></TD>' . '</TR>' . "\n";
        while ($row = db_fetch_array($res)) {
            $i++;
            print '<TR class="' . util_get_alt_row_color($i) . '">' . '<TD>' . substr($row["day"], 6, 2) . ' ' . $month_name[substr($row["day"], 4, 2) - 1] . ' ' . substr($row["day"], 0, 4) . '</TD>' . '<TD> <a href="/users/' . $hp->purify($row["user_name"]) . '/">' . $hp->purify($row["user_name"]) . '</a> (' . $hp->purify($row["realname"]) . ')</TD>' . '<TD>' . $hp->purify($row["email"]) . '</TD>' . '<TD>' . $hp->purify($row["cvs_checkouts"]) . '</TD>' . '<TD>' . $hp->purify($row["cvs_browse"]) . '</TD>' . '</TR>' . "\n";
        }
        print '</TABLE>';
    } else {
        echo '<P>' . $GLOBALS['Language']->getText('project_stats_source_code_access_utils', 'no_access', $GLOBALS['Language']->getText('project_stats_source_code_access_utils', 'cvs_access'));
    }
}