private function getAllowedQuotaInBytes($group_id)
 {
     $allowed_quota_in_GB = $this->project_quota_manager->getProjectCustomQuota($group_id);
     if (!$allowed_quota_in_GB) {
         $allowed_quota_in_GB = $this->disk_usage_manager->getProperty('allowed_quota');
     }
     return $this->gigabytesToBytes($allowed_quota_in_GB);
 }
Exemplo n.º 2
0
 /**
  * Delete custom quota for a project
  *
  * @param Array $projects List of projects for which custom quota will be deleted
  *
  * @return Void
  */
 public function deleteCustomQuota($projects)
 {
     if (empty($projects)) {
         $GLOBALS['Response']->addFeedback('error', $GLOBALS['Language']->getText('plugin_statistics', 'nothing_to_delete'));
     } else {
         $list = array();
         $names = array();
         $dum = new Statistics_DiskUsageManager();
         $defaultQuota = $dum->getProperty('allowed_quota');
         $historyDao = new ProjectHistoryDao(CodendiDataAccess::instance());
         foreach ($projects as $projectId => $name) {
             $list[] = $projectId;
             $names[] = $name;
             $historyDao->groupAddHistory("restore_default_quota", intval($defaultQuota), $projectId);
         }
         if ($this->dao->deleteCustomQuota($list)) {
             $GLOBALS['Response']->addFeedback('info', $GLOBALS['Language']->getText('plugin_statistics', 'quota_deleted', array(join(', ', $names))));
         } else {
             $GLOBALS['Response']->addFeedback('error', $GLOBALS['Language']->getText('plugin_statistics', 'delete_error'));
         }
     }
 }
Exemplo n.º 3
0
 }
 if ($period == 'year') {
     $statDuration = 12;
     $link = '?' . $serviceParam . '&group_id=' . $groupId . '&period=months';
 } else {
     $statDuration = $statPeriod;
     $link = '?' . $serviceParam . '&group_id=' . $groupId . '&period=year';
 }
 $endDate = date('Y-m-d');
 $startDate = date('Y-m-d', mktime(0, 0, 0, date('m') - $statDuration, date('d'), date('y')));
 $params['group'] = $groupId;
 $params['title'] = $GLOBALS['Language']->getText('admin_groupedit', 'proj_admin') . ': ' . $project->getPublicName();
 project_admin_header($params);
 echo '<h2>' . $GLOBALS['Language']->getText('plugin_statistics_admin_page', 'show_statistics') . '</h2>';
 $usedProportion = $duMgr->returnTotalProjectSize($groupId);
 $allowedQuota = $duMgr->getProperty('allowed_quota');
 $pqm = new ProjectQuotaManager();
 $customQuota = $pqm->getProjectCustomQuota($groupId);
 if ($customQuota) {
     $allowedQuota = $customQuota;
 }
 if ($allowedQuota) {
     echo '<div id="help_init" class="stat_help">' . $GLOBALS['Language']->getText('plugin_statistics_admin_page', 'disk_usage_proportion', array($duHtml->sizeReadable($usedProportion), $allowedQuota . 'GiB')) . '</div>';
     echo '<p><img src="/plugins/statistics/project_cumulativeDiskUsage_graph.php?func=usage&size=' . $usedProportion . '&group_id=' . $groupId . '" title="Disk usage percentage" /></p>';
 } else {
     echo '<LABEL><b>';
     echo $GLOBALS['Language']->getText('plugin_statistics', 'widget_total_project_size');
     echo '</b></LABEL>';
     echo $duHtml->sizeReadable($usedProportion);
 }
 $title = $GLOBALS['Language']->getText('plugin_statistics_admin_page', 'disk_usage_period_' . $period, array($statDuration));
$p = $pluginManager->getPluginByName('statistics');
if (!$p || !$pluginManager->isPluginAvailable($p)) {
    header('Location: ' . get_server_url());
}
$vGroupId = new Valid_GroupId();
$vGroupId->required();
if ($request->valid($vGroupId)) {
    $groupId = $request->get('group_id');
    $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;