summaryrefslogtreecommitdiff
path: root/quota_inc.php
blob: b78f08b6c3ac42a7417c2ed65f480de74ceb69fb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
/**
 * @version  $Revision$
 * @package  quota
 * 
 * settings that are useful to know about at upload time
 */

/**
 * quota setup
 */
require_once( QUOTA_PKG_PATH.'LibertyQuota.php' );
global $gBitSmarty, $assignUser, $gBitUser;

if( empty( $pQuotaUserId ) ) {
	if( !empty( $assignUser->mUserId ) ) {
		$pQuotaUserId = $assignUser->mUserId;
	} else {
		$pQuotaUserId = $gBitUser->mUserId;
	}
}

$quota = new LibertyQuota();
$diskUsage = $quota->getUserUsage( $pQuotaUserId );
$diskQuota = $quota->getUserQuota( $pQuotaUserId );

if( $diskQuota != 0 ) {
        $quotaPercent = round( (($diskUsage / $diskQuota) * 100), 0 );
} else {
        $quotaPercent = 0;
}

if( $quotaPercent > 100 ) {
        $errors['disk_quota'] = "You are over your disk quota.";
        $gBitSmarty->assign_by_ref( 'errors', $errors );
        $quotaPercent = 100;
}

$gBitSmarty->assign( 'usage', round( ($diskUsage / 1000000), 2 ) );
$gBitSmarty->assign( 'quota', round( ($diskQuota / 1000000), 2 ) );
$gBitSmarty->assign_by_ref( 'quotaPercent', $quotaPercent );
?>