summaryrefslogtreecommitdiff
path: root/includes/quota_inc.php
blob: 4ae644205260920d3d42e1e648cfea2afaa555df (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
<?php
/**
 * @version  $Revision$
 * @package  quota
 * 
 * settings that are useful to know about at upload time
 */

/**
 * quota setup
 */

use Bitweaver\Quota\LibertyQuota;

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 );

$quotaPercent = $diskQuota != 0 ? round( ( $diskUsage / $diskQuota ) * 100, 0 ) : 0;

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

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