From 274db344ba6e638fdf8c488c2c3c1beb88ae437d Mon Sep 17 00:00:00 2001 From: Max Kremmel Date: Thu, 18 May 2006 18:37:49 +0000 Subject: modularise quota for other packages to include --- index.php | 27 +++------------------------ quota_inc.php | 23 +++++++++++++++++++++++ templates/quota.tpl | 28 +--------------------------- templates/quota_inc.tpl | 29 +++++++++++++++++++++++++++++ 4 files changed, 56 insertions(+), 51 deletions(-) create mode 100644 quota_inc.php create mode 100644 templates/quota_inc.tpl diff --git a/index.php b/index.php index 8cfcb08..3832d6a 100644 --- a/index.php +++ b/index.php @@ -1,6 +1,6 @@ verifyPackage( 'quota' ); -require_once( QUOTA_PKG_PATH.'LibertyQuota.php' ); - -$quota = new LibertyQuota(); -$diskUsage = $quota->getUserUsage( $gBitUser->mUserId ); -$diskQuota = $quota->getUserQuota( $gBitUser->mUserId ); - -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 ); +require_once( QUOTA_PKG_PATH.'quota_inc.php' ); $gBitSystem->display( 'bitpackage:quota/quota.tpl', 'View Quota' ); - ?> diff --git a/quota_inc.php b/quota_inc.php new file mode 100644 index 0000000..d05679b --- /dev/null +++ b/quota_inc.php @@ -0,0 +1,23 @@ +getUserUsage( $gBitUser->mUserId ); +$diskQuota = $quota->getUserQuota( $gBitUser->mUserId ); + +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 ); +?> diff --git a/templates/quota.tpl b/templates/quota.tpl index af1df16..f6f181c 100644 --- a/templates/quota.tpl +++ b/templates/quota.tpl @@ -6,32 +6,6 @@ {include file="bitpackage:users/my_bitweaver_bar.tpl"}
- {legend legend="Your Personal Usage Quota"} - {if $gBitUser->isAdmin()} - Administrators have no enforced quota limit - {else} - {formfeedback error=$errors.disk_quota} - -
- {formlabel label="Your disk quota"} - {forminput} - {formfeedback note="$quota MB"} - {/forminput} -
- -
- {formlabel label="Your current usage"} - {forminput} - {formfeedback note="$usage MB ( `$quotaPercent`% )"} - {/forminput} -
- -
-
-
{$quotaPercent}%
-
-
- {/if} - {/legend} + {include file="bitpackage:quota/quota_inc.tpl"}
diff --git a/templates/quota_inc.tpl b/templates/quota_inc.tpl new file mode 100644 index 0000000..19ff33d --- /dev/null +++ b/templates/quota_inc.tpl @@ -0,0 +1,29 @@ +{strip} +{legend legend="Your Personal Usage Quota"} + {if $gBitUser->isAdmin()} + Administrators have no enforced quota limit + {else} + {formfeedback error=$errors.disk_quota} + +
+ {formlabel label="Your disk quota"} + {forminput} + {formfeedback note="$quota MB"} + {/forminput} +
+ +
+ {formlabel label="Your current usage"} + {forminput} + {formfeedback note="$usage MB ( `$quotaPercent`% )"} + {/forminput} +
+ +
+
+
{$quotaPercent}%
+
+
+ {/if} +{/legend} +{/strip} -- cgit v1.3