예제 #1
0
}
$vRelative = new Valid_WhiteList('relative', array('true'));
$vRelative->required();
if ($request->valid($vRelative)) {
    $relative = true;
} else {
    $relative = false;
}
if (strtotime($startDate) >= strtotime($endDate)) {
    $feedback[] = $GLOBALS['Language']->getText('plugin_statistics', 'period_error');
    $error = true;
}
//
// Display graph
//
$graph = new Statistics_DiskUsageGraph($duMgr);
if (!$error) {
    switch ($graphType) {
        case 'graph_service':
            $graph->displayServiceGraph($services, $selectedGroupByDate, $startDate, $endDate, !$relative);
            break;
        case 'graph_user':
            $graph->displayUserGraph($userId, $selectedGroupByDate, $startDate, $endDate, !$relative);
            break;
        case 'graph_project':
            $graph->displayProjectGraph($groupId, $services, $selectedGroupByDate, $startDate, $endDate, !$relative);
            break;
        default:
    }
} else {
    $msg = '';
예제 #2
0
$vStartDate->required();
if ($request->valid($vStartDate)) {
    $startDate = $request->get('start_date');
} else {
    $startDate = '';
}
$vEndDate = new Valid('end_date');
$vEndDate->addRule(new Rule_Date());
$vEndDate->required();
if ($request->valid($vEndDate)) {
    $endDate = $request->get('end_date');
} else {
    $endDate = date('Y-m-d');
}
$duration = strtotime($endDate) - strtotime($startDate);
$error = false;
if ($duration <= 0) {
    $feedback[] = 'You made a mistake in selecting period. Please try again!';
    $error = true;
} elseif ($duration < 31536000) {
    $groupBy = 'Week';
} else {
    $groupBy = 'Month';
}
//
// Display graph
//
if (!$error) {
    $graph = new Statistics_DiskUsageGraph($duMgr);
    $graph->displayProjectGraph($groupId, $services, $groupBy, $startDate, $endDate, true, true, false);
}
    $project = ProjectManager::instance()->getProject($groupId);
} else {
    header('Location: ' . get_server_url());
}
$func = $request->getValidated('func', new Valid_WhiteList('usage', 'progress'), '');
//Get dates for start and end period to watch statistics
$duMgr = new Statistics_DiskUsageManager();
$statPeriod = $duMgr->getProperty('statistics_period');
if (!$statPeriod) {
    $statPeriod = 3;
}
$endDate = date('Y-m-d');
$startDate = date('Y-m-d', mktime(0, 0, 0, date('m') - $statPeriod, date('d'), date('y')));
$services = $duMgr->getProjectServices();
// Display graph
$graph = new Statistics_DiskUsageGraph($duMgr);
if ($func == 'usage') {
    //Retreive the config param & convert it to bytes
    $quota = $duMgr->getProperty('allowed_quota');
    $pqm = new ProjectQuotaManager();
    $customQuota = $pqm->getProjectCustomQuota($groupId);
    if ($customQuota) {
        $quota = $customQuota;
    }
    $allowed = $quota * (1024 * 1024 * 1024);
    $used = $request->get('size');
    //In case of over usage
    if ($used > $allowed) {
        $used = $allowed;
        //May be should display warning
    }