summaryrefslogtreecommitdiff
path: root/includes/quota_inc.php
diff options
context:
space:
mode:
Diffstat (limited to 'includes/quota_inc.php')
-rw-r--r--includes/quota_inc.php39
1 files changed, 39 insertions, 0 deletions
diff --git a/includes/quota_inc.php b/includes/quota_inc.php
new file mode 100644
index 0000000..23125d1
--- /dev/null
+++ b/includes/quota_inc.php
@@ -0,0 +1,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 );