diff options
| author | Max Kremmel <xing@synapse.plus.com> | 2006-05-18 18:37:49 +0000 |
|---|---|---|
| committer | Max Kremmel <xing@synapse.plus.com> | 2006-05-18 18:37:49 +0000 |
| commit | 274db344ba6e638fdf8c488c2c3c1beb88ae437d (patch) | |
| tree | 28f5e437836f35cb9f9030e950aeff3ead34dd91 | |
| parent | b2315628563fad5e923e25eb2e18f4b584e6182d (diff) | |
| download | quota-274db344ba6e638fdf8c488c2c3c1beb88ae437d.tar.gz quota-274db344ba6e638fdf8c488c2c3c1beb88ae437d.tar.bz2 quota-274db344ba6e638fdf8c488c2c3c1beb88ae437d.zip | |
modularise quota for other packages to include
| -rw-r--r-- | index.php | 27 | ||||
| -rw-r--r-- | quota_inc.php | 23 | ||||
| -rw-r--r-- | templates/quota.tpl | 28 | ||||
| -rw-r--r-- | templates/quota_inc.tpl | 29 |
4 files changed, 56 insertions, 51 deletions
@@ -1,6 +1,6 @@ <?php /** - * $Header: /cvsroot/bitweaver/_bit_quota/index.php,v 1.3 2005/08/01 18:41:18 squareing Exp $ + * $Header: /cvsroot/bitweaver/_bit_quota/index.php,v 1.4 2006/05/18 18:37:49 squareing Exp $ * * Copyright (c) 2004 bitweaver.org * Copyright (c) 2003 tikwiki.org @@ -8,7 +8,7 @@ * All Rights Reserved. See copyright.txt for details and a complete list of authors. * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details * - * $Id: index.php,v 1.3 2005/08/01 18:41:18 squareing Exp $ + * $Id: index.php,v 1.4 2006/05/18 18:37:49 squareing Exp $ * @package quota */ @@ -19,28 +19,7 @@ require_once( '../bit_setup_inc.php' ); $gBitSystem->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 @@ +<?php +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 ); +?> 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"} <div class="body"> - {legend legend="Your Personal Usage Quota"} - {if $gBitUser->isAdmin()} - Administrators have no enforced quota limit - {else} - {formfeedback error=$errors.disk_quota} - - <div class="row"> - {formlabel label="Your disk quota"} - {forminput} - {formfeedback note="$quota MB"} - {/forminput} - </div> - - <div class="row"> - {formlabel label="Your current usage"} - {forminput} - {formfeedback note="$usage MB <small>( `$quotaPercent`% )</small>"} - {/forminput} - </div> - - <div class="row"> - <div style="border:1px solid #ccc;background:#eee;"> - <div style="width:{$quotaPercent}%;background:#f80;text-align:left;color:#000;line-height:30px;"><small>{$quotaPercent}%</small></div> - </div> - </div> - {/if} - {/legend} + {include file="bitpackage:quota/quota_inc.tpl"} </div> <!-- end .body --> </div> <!-- end .fisheye --> 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} + + <div class="row"> + {formlabel label="Your disk quota"} + {forminput} + {formfeedback note="$quota MB"} + {/forminput} + </div> + + <div class="row"> + {formlabel label="Your current usage"} + {forminput} + {formfeedback note="$usage MB <small>( `$quotaPercent`% )</small>"} + {/forminput} + </div> + + <div class="row"> + <div style="border:1px solid #ccc;background:#eee;"> + <div style="width:{$quotaPercent}%;background:#f80;text-align:left;color:#000;line-height:30px;"><small>{$quotaPercent}%</small></div> + </div> + </div> + {/if} +{/legend} +{/strip} |
