summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlsces <lester@lsces.co.uk>2025-08-29 09:50:44 +0100
committerlsces <lester@lsces.co.uk>2025-08-29 09:50:44 +0100
commit24ac90ba2d2e8911b8b51d251541565f202dd9ce (patch)
tree998a5e4a84dc2008d7fe68123a8fc164e7ce5204
parentef37929a5577234fc2a350b6207260c52d5835cd (diff)
downloadquota-24ac90ba2d2e8911b8b51d251541565f202dd9ce.tar.gz
quota-24ac90ba2d2e8911b8b51d251541565f202dd9ce.tar.bz2
quota-24ac90ba2d2e8911b8b51d251541565f202dd9ce.zip
Refactor for PHP8.4, namespace and Smarty5
-rw-r--r--admin/admin_quota_inc.php14
-rw-r--r--admin/pump_quota_inc.php3
-rw-r--r--admin/schema_inc.php63
-rw-r--r--admin/upgrade_inc.php30
-rw-r--r--includes/bit_setup_inc.php20
-rw-r--r--includes/calculate_quota_inc.php (renamed from calculate_quota_inc.php)9
-rw-r--r--includes/classes/LibertyQuota.php (renamed from LibertyQuota.php)71
-rw-r--r--includes/quota_inc.php (renamed from quota_inc.php)19
-rw-r--r--index.php7
9 files changed, 105 insertions, 131 deletions
diff --git a/admin/admin_quota_inc.php b/admin/admin_quota_inc.php
index f4c1733..22a3d87 100644
--- a/admin/admin_quota_inc.php
+++ b/admin/admin_quota_inc.php
@@ -10,7 +10,7 @@
// $gBitSmarty->assign( 'home_quota', $_REQUEST["homeSample"] );
//}
-require_once( QUOTA_PKG_CLASS_PATH.'LibertyQuota.php' );
+use Bitweaver\Quota\LibertyQuota;
if( !empty( $_REQUEST['cancelquota'] ) ) {
unset( $_REQUEST['quota_id'] );
@@ -24,7 +24,7 @@ if( !empty( $_REQUEST['savequota'] ) ) {
die;
} else {
$saveError = TRUE;
- $gBitSmarty->assignByRef( 'errors', $gQuota->mErrors );
+ $gBitSmarty->assign( 'errors', $gQuota->mErrors );
}
} elseif( !empty( $_REQUEST['assignquota'] ) ) {
foreach( array_keys( $_REQUEST ) as $key ) {
@@ -37,16 +37,14 @@ if( !empty( $_REQUEST['savequota'] ) ) {
}
$gQuota->load();
if( $gQuota->isValid() || isset( $_REQUEST['newquota'] ) || !empty( $saveError ) ) {
- $gBitSmarty->assignByRef('gQuota', $gQuota);
+ $gBitSmarty->assign('gQuota', $gQuota);
} else {
$quotas = $gQuota->getList();
$systemGroups = $gQuota->getQuotaGroups();
- $gBitSmarty->assignByRef('systemGroups', $systemGroups );
+ $gBitSmarty->assign('systemGroups', $systemGroups );
foreach( array_keys( $systemGroups ) as $groupId ) {
$groupQuota[$groupId] = $gQuota->getQuotaMenu( 'quota_group_'.$groupId, $systemGroups[$groupId]['quota_id'] );
}
- $gBitSmarty->assignByRef('groupQuota', $groupQuota );
- $gBitSmarty->assignByRef('quotaList', $quotas);
+ $gBitSmarty->assign('groupQuota', $groupQuota );
+ $gBitSmarty->assign('quotaList', $quotas);
}
-
-?>
diff --git a/admin/pump_quota_inc.php b/admin/pump_quota_inc.php
index 893a4dc..d76e1d3 100644
--- a/admin/pump_quota_inc.php
+++ b/admin/pump_quota_inc.php
@@ -8,7 +8,8 @@
/**
* required setup
*/
-require_once( QUOTA_PKG_CLASS_PATH.'LibertyQuota.php' );
+use Bitweaver\Quota\LibertyQuota;
+
$quota = new LibertyQuota();
$quota->mDb->Execute("INSERT INTO `".BIT_DB_PREFIX."quotas` ( `quota_id`, `disk_usage`, `monthly_transfer`, `title`, `description` ) VALUES ('1', 2000000, 20000000, 'Free Trial', 'A little space to try out site features' )");
diff --git a/admin/schema_inc.php b/admin/schema_inc.php
index 25ca7f1..9051837 100644
--- a/admin/schema_inc.php
+++ b/admin/schema_inc.php
@@ -1,13 +1,13 @@
<?php
-$tables = array(
+$tables = [
-'users_quota_units' => "
+ 'users_quota_units' => "
user_id I4 PRIMARY,
units I4 NOTNULL
",
-'quotas' => "
+ 'quotas' => "
quota_id I4 PRIMARY,
disk_usage I8,
monthly_transfer I8,
@@ -15,14 +15,14 @@ $tables = array(
description X
",
-'quotas_group_map' => "
+ 'quotas_group_map' => "
quota_id I4 PRIMARY,
group_id I4 PRIMARY
- CONSTRAINT ', CONSTRAINT `quotas_group_ref` FOREIGN KEY (`group_id`) REFERENCES `".BIT_DB_PREFIX."users_groups`( `group_id` )
- , CONSTRAINT `quotas_map_ref` FOREIGN KEY (`quota_id`) REFERENCES `".BIT_DB_PREFIX."quotas`( `quota_id` )'
+ CONSTRAINT ', CONSTRAINT `quotas_group_ref` FOREIGN KEY (`group_id`) REFERENCES `" . BIT_DB_PREFIX . "users_groups`( `group_id` )
+ , CONSTRAINT `quotas_map_ref` FOREIGN KEY (`quota_id`) REFERENCES `" . BIT_DB_PREFIX . "quotas`( `quota_id` )'
",
-);
+];
global $gBitInstaller;
@@ -30,38 +30,37 @@ foreach( array_keys( $tables ) AS $tableName ) {
$gBitInstaller->registerSchemaTable( QUOTA_PKG_NAME, $tableName, $tables[$tableName] );
}
-$gBitInstaller->registerPackageInfo( QUOTA_PKG_NAME, array(
+$gBitInstaller->registerPackageInfo( QUOTA_PKG_NAME, [
'description' => "Quota system limits user disk and bandwidth usage for Liberty content",
- 'license' => '<a href="http://www.gnu.org/licenses/licenses.html#LGPL">LGPL</a>',
-) );
+ 'license' => '<a href="http://www.gnu.org/licenses/licenses.html#LGPL">LGPL</a>',
+] );
// ### Indexes
-$indices = array (
- 'quotas_group_idx' => array( 'table' => 'quotas_group_map', 'cols' => 'group_id', 'opts' => array( 'UNIQUE' ) ),
-);
+$indices = [
+ 'quotas_group_idx' => [ 'table' => 'quotas_group_map', 'cols' => 'group_id', 'opts' => [ 'UNIQUE' ] ],
+];
$gBitInstaller->registerSchemaIndexes( QUOTA_PKG_NAME, $indices );
// ### Sequences
-$sequences = array (
- 'quota_id_seq' => array( 'start' => 3 )
-);
+$sequences = [
+ 'quota_id_seq' => [ 'start' => 3 ],
+];
$gBitInstaller->registerSchemaSequences( QUOTA_PKG_NAME, $sequences );
-$gBitInstaller->registerUserPermissions( QUOTA_PKG_NAME, array(
- array('p_quota_create', 'Can create a quota', 'registered', QUOTA_PKG_NAME),
- array('p_quota_edit', 'Can edit any quota', 'editors', QUOTA_PKG_NAME),
- array('p_quota_admin', 'Can admin quota', 'editors', QUOTA_PKG_NAME),
- array('p_quota_read', 'Can read quota', 'basic', QUOTA_PKG_NAME),
- array('p_quota_unlimited', 'Can upload unlimited amount of data', 'editors', QUOTA_PKG_NAME),
-) );
+$gBitInstaller->registerUserPermissions( QUOTA_PKG_NAME, [
+ [ 'p_quota_create', 'Can create a quota', 'registered', QUOTA_PKG_NAME ],
+ [ 'p_quota_edit', 'Can edit any quota', 'editors', QUOTA_PKG_NAME ],
+ [ 'p_quota_admin', 'Can admin quota', 'editors', QUOTA_PKG_NAME ],
+ [ 'p_quota_read', 'Can read quota', 'basic', QUOTA_PKG_NAME ],
+ [ 'p_quota_unlimited', 'Can upload unlimited amount of data', 'editors', QUOTA_PKG_NAME ],
+] );
-$gBitInstaller->registerPreferences( QUOTA_PKG_NAME, array(
- array(QUOTA_PKG_NAME, 'quota_default_ordering','title_desc'),
- array(QUOTA_PKG_NAME, 'quota_list_content_id','y'),
- array(QUOTA_PKG_NAME, 'quota_list_title','y'),
- array(QUOTA_PKG_NAME, 'quota_list_description','y'),
-) );
+$gBitInstaller->registerPreferences( QUOTA_PKG_NAME, [
+ [ QUOTA_PKG_NAME, 'quota_default_ordering', 'title_desc' ],
+ [ QUOTA_PKG_NAME, 'quota_list_content_id', 'y' ],
+ [ QUOTA_PKG_NAME, 'quota_list_title', 'y' ],
+ [ QUOTA_PKG_NAME, 'quota_list_description', 'y' ],
+] );
-//$gBitInstaller->registerSchemaDefault( QUOTA_PKG_NAME, array(
-//) );
-?>
+//$gBitInstaller->registerSchemaDefault( QUOTA_PKG_NAME, [
+//] );
diff --git a/admin/upgrade_inc.php b/admin/upgrade_inc.php
deleted file mode 100644
index 87a6ba2..0000000
--- a/admin/upgrade_inc.php
+++ /dev/null
@@ -1,30 +0,0 @@
-<?php
-
-global $gBitSystem, $gUpgradeFrom, $gUpgradeTo;
-
-$upgrades = array(
-
- 'BWR1' => array(
- 'BWR2' => array(
-// de-tikify tables
-array( 'DATADICT' => array(
- array( 'RENAMETABLE' => array(
- 'tiki_quotas' => 'quotas',
- 'tiki_quotas_group_map' => 'quotas_group_map',
- )),
-)),
-
-// query: create a quota_id_seq and bring the table up to date with the current max quota_id used in the quotas table - this basically for mysql
-array( 'PHP' => '
- $query = $gBitDb->getOne("SELECT MAX(quota_id) FROM `'.BIT_DB_PREFIX.'quotas`");
- $tempId = $gBitDb->mDb->GenID("`'.BIT_DB_PREFIX.'quota_id_seq`", $query);
-' ),
- )
- ),
-
-);
-
-if( isset( $upgrades[$gUpgradeFrom][$gUpgradeTo] ) ) {
- $gBitSystem->registerUpgrade( QUOTA_PKG_NAME, $upgrades[$gUpgradeFrom][$gUpgradeTo] );
-}
-?>
diff --git a/includes/bit_setup_inc.php b/includes/bit_setup_inc.php
index 1ec36f8..5cf8fbb 100644
--- a/includes/bit_setup_inc.php
+++ b/includes/bit_setup_inc.php
@@ -1,10 +1,18 @@
<?php
global $gBitSystem, $gBitSmarty;
-$registerHash = array(
+$pRegisterHash = [
'package_name' => 'quota',
- 'package_path' => dirname( dirname( __FILE__ ) ).'/',
- 'homeable' => TRUE,
-);
-$gBitSystem->registerPackage( $registerHash );
-?>
+ 'package_path' => dirname( dirname( __FILE__ ) ) . '/',
+ 'homeable' => true,
+];
+
+// fix to quieten down VS Code which can't see the dynamic creation of these ...
+define( 'QUOTA_PKG_NAME', $pRegisterHash['package_name'] );
+define( 'QUOTA_PKG_URL', BIT_ROOT_URL . basename( $pRegisterHash['package_path'] ) . '/' );
+define( 'QUOTA_PKG_PATH', BIT_ROOT_PATH . basename( $pRegisterHash['package_path'] ) . '/' );
+define( 'QUOTA_PKG_INCLUDE_PATH', BIT_ROOT_PATH . basename( $pRegisterHash['package_path'] ) . '/includes/');
+define( 'QUOTA_PKG_CLASS_PATH', BIT_ROOT_PATH . basename( $pRegisterHash['package_path'] ) . '/includes/classes/');
+define( 'QUOTA_PKG_ADMIN_PATH', BIT_ROOT_PATH . basename( $pRegisterHash['package_path'] ) . '/admin/');
+
+$gBitSystem->registerPackage( $pRegisterHash );
diff --git a/calculate_quota_inc.php b/includes/calculate_quota_inc.php
index 65db3ec..de4940e 100644
--- a/calculate_quota_inc.php
+++ b/includes/calculate_quota_inc.php
@@ -9,11 +9,13 @@
/**
* quota setup
*/
-require_once( QUOTA_PKG_CLASS_PATH.'LibertyQuota.php' );
+
+use Bitweaver\KernelTools;
+use Bitweaver\Quota\LibertyQuota;
$quota = new LibertyQuota();
if( !$gBitUser->isAdmin() && !$quota->isUserUnderQuota( $gBitUser->mUserId ) ) {
- $gBitSystem->display( 'bitpackage:quota/over_quota.tpl', tra( 'You are over your quota.' ) , array( 'display_mode' => 'display' ));
+ $gBitSystem->display( 'bitpackage:quota/over_quota.tpl', KernelTools::tra( 'You are over your quota.' ) , [ 'display_mode' => 'display' ]);
die;
}
@@ -21,10 +23,9 @@ if( !$gBitUser->isAdmin() ) {
// Prevent people from uploading more than their quota
$q = $quota->getUserQuota( $gBitUser->mUserId );
$u = $quota->getUserUsage( $gBitUser->mUserId );
- $gBitSmarty->assign( 'quotaMessage', tra( 'Your remaining disk quota is' ).' '.round( ( $q - $u ) / 1000000, 2 ).' '.tra( 'Megabytes' ) );
+ $gBitSmarty->assign( 'quotaMessage', KernelTools::tra( 'Your remaining disk quota is' ).' '.round( ( $q - $u ) / 1000000, 2 ).' '.KernelTools::tra( 'Megabytes' ) );
$qMegs = round( $q / 1000000 );
if( $qMegs < $uploadMax ) {
$uploadMax = $qMegs;
}
}
-?>
diff --git a/LibertyQuota.php b/includes/classes/LibertyQuota.php
index 549e62f..4feb6a4 100644
--- a/LibertyQuota.php
+++ b/includes/classes/LibertyQuota.php
@@ -15,7 +15,10 @@
/**
* required setup
*/
-require_once( LIBERTY_PKG_CLASS_PATH.'LibertyAttachable.php' );
+
+namespace Bitweaver\Quota;
+use Bitweaver\BitBase;
+use Bitweaver\Liberty\LibertyBase;
/**
* Quota class to illustrate best practices when creating a new bitweaver package that
@@ -35,12 +38,12 @@ class LibertyQuota extends LibertyBase {
* Primary key for our mythical Quota class object & table
* @public
*/
- var $mQuotaId;
+ public $mQuotaId;
/**
* During initialisation, be sure to call our base constructors
**/
- function __construct( $pQuotaId=NULL, $pContentId=NULL ) {
+ public function __construct( $pQuotaId=NULL, $pContentId=NULL ) {
$this->mQuotaId = $pQuotaId;
parent::__construct();
}
@@ -48,14 +51,14 @@ class LibertyQuota extends LibertyBase {
/**
* Any method named Store inherently implies data will be written to the database
- * @param pParamHash be sure to pass by reference in case we need to make modifcations to the hash
+ * @param array pParamHash be sure to pass by reference in case we need to make modifcations to the hash
**/
- function store( &$pParamHash ) {
+ public function store( &$pParamHash ) {
if( $this->verify( $pParamHash ) ) {
$this->mDb->StartTrans();
$table = BIT_DB_PREFIX."quotas";
if( $this->mQuotaId ) {
- $result = $this->mDb->associateUpdate( $table, $pParamHash['quota_store'], array( "quota_id" => $pParamHash['quota_id'] ) );
+ $result = $this->mDb->associateUpdate( $table, $pParamHash['quota_store'], [ "quota_id" => $pParamHash['quota_id'] ] );
} else {
$this->mQuotaId = $this->mDb->GenID( 'quota_id_seq' );
$pParamHash['quota_store']['quota_id'] = $this->mQuotaId;
@@ -69,9 +72,9 @@ class LibertyQuota extends LibertyBase {
/**
* Make sure the data is safe to store
- * @param pParamHash be sure to pass by reference in case we need to make modifcations to the hash
+ * @param array pParamHash be sure to pass by reference in case we need to make modifcations to the hash
**/
- function verify( &$pParamHash ) {
+ public function verify( &$pParamHash ) {
if( isset( $pParamHash['description'] ) ) {
// insure we don't have column overflow, etc.
$pParamHash['quota_store']['description'] = trim( $pParamHash['description'], 0, 160 );
@@ -100,32 +103,32 @@ class LibertyQuota extends LibertyBase {
/**
* Load the data from the database
- * @param pParamHash be sure to pass by reference in case we need to make modifcations to the hash
+ * @param array pParamHash be sure to pass by reference in case we need to make modifcations to the hash
**/
- function load() {
+ public function load() {
if( $this->mQuotaId ) {
// LibertyContent::load() assumes you have joined already, and will not execute any sql!
// This is a significant performance optimization
$query = "SELECT qo.* FROM `".BIT_DB_PREFIX."quotas` qo WHERE qo.`quota_id`=?";
- $result = $this->mDb->query( $query, array( $this->mQuotaId ) );
+ $result = $this->mDb->query( $query, [ $this->mQuotaId ] );
if ( $result && $result->numRows() ) {
$this->mInfo = $result->fields;
$query = "SELECT ug.`group_id`, ug.* FROM `".BIT_DB_PREFIX."users_groups` ug INNER JOIN `".BIT_DB_PREFIX."quotas_group_map` qgm ON( ug.`group_id`=qgm.`group_id` ) WHERE qgm.`quota_id`=?";
- if( $rs = $this->mDb->query( $query, array( $this->mQuotaId ) ) ) {
+ if( $rs = $this->mDb->query( $query, [ $this->mQuotaId ] ) ) {
$this->mInfo['quota_groups'] = $rs->fields;
}
}
}
- return( count( $this->mInfo ) == 0 );
+ return count( $this->mInfo ) == 0;
}
/**
*
**/
- function getList() {
+ public function getList() {
$query = "SELECT qo.`quota_id`, qo.* FROM `".BIT_DB_PREFIX."quotas` qo";
$ret = $this->mDb->getAssoc($query);
- return ( $ret );
+ return $ret;
}
/**
@@ -154,17 +157,17 @@ class LibertyQuota extends LibertyBase {
**/
function assignQuotaToGroup( $pQuotaId, $pGroupId ) {
if( is_numeric( $pQuotaId ) && is_numeric( $pGroupId ) ) {
- $hasRow = $this->mDb->getOne( 'SELECT `quota_id` FROM `'.BIT_DB_PREFIX.'quotas_group_map` WHERE `group_id`=?',array( $pGroupId ) );
+ $hasRow = $this->mDb->getOne( 'SELECT `quota_id` FROM `'.BIT_DB_PREFIX.'quotas_group_map` WHERE `group_id`=?', [ $pGroupId ] );
if( $hasRow ) {
$query = 'UPDATE `'.BIT_DB_PREFIX.'quotas_group_map` SET `quota_id`=? WHERE `group_id`=?';
- $rs = $this->mDb->query( $query, array( $pQuotaId, $pGroupId ) );
+ $rs = $this->mDb->query( $query, [ $pQuotaId, $pGroupId ] );
} else {
$query = 'INSERT INTO `'.BIT_DB_PREFIX.'quotas_group_map` (`quota_id`, `group_id`) VALUES (?,?)';
- $rs = $this->mDb->query( $query, array( $pQuotaId, $pGroupId ) );
+ $rs = $this->mDb->query( $query, [ $pQuotaId, $pGroupId ] );
}
} elseif( is_numeric( $pGroupId ) && empty( $pQuotaId ) ) {
$query = 'DELETE FROM `'.BIT_DB_PREFIX.'quotas_group_map` WHERE `group_id`=?';
- $rs = $this->mDb->query( $query, array( $pGroupId ) );
+ $rs = $this->mDb->query( $query, [ $pGroupId ] );
}
}
@@ -181,11 +184,11 @@ class LibertyQuota extends LibertyBase {
INNER JOIN `'.BIT_DB_PREFIX.'quotas_group_map` qgm ON( qgm.`group_id`=ugm.`group_id` )
INNER JOIN `'.BIT_DB_PREFIX.'quotas` qo ON( qo.`quota_id`=qgm.`quota_id` )
WHERE uu.`user_id`=?';
- if( $rs = $this->mDb->query( $query, array( $pUserId ) ) ) {
+ if( $rs = $this->mDb->query( $query, [ $pUserId ] ) ) {
$diskQuota = $rs->fields['disk_usage'];
$diskConsumed = $this->getUserUsage( $pUserId );
if( $diskQuota == NULL || $diskQuota > $diskConsumed ) {
- $ret = array($diskQuota, $diskConsumed);
+ $ret = [ $diskQuota, $diskConsumed ];
}
}
}
@@ -195,10 +198,10 @@ class LibertyQuota extends LibertyBase {
/**
* Given a user_id, this will return the max quota for the given user. If the user belongs to more than one group, it will chose the max values
- * @param pUserId user_id of the user for usage to be calculated for
- * @returns an integer of the total bytes used
+ * @param integer pUserId user_id of the user for usage to be calculated for
+ * @return integer an integer of the total bytes used
*/
- function getUserQuota( $pUserId ) {
+ public function getUserQuota( $pUserId ) {
$ret = 0;
if( is_numeric( $pUserId ) ) {
$query = 'SELECT MAX(qo.`disk_usage`) AS `disk_usage`
@@ -207,17 +210,17 @@ class LibertyQuota extends LibertyBase {
INNER JOIN `'.BIT_DB_PREFIX.'quotas_group_map` qgm ON( qgm.`group_id`=ugm.`group_id` )
INNER JOIN `'.BIT_DB_PREFIX.'quotas` qo ON( qo.`quota_id`=qgm.`quota_id` )
WHERE uu.`user_id`=?';
- $ret = $this->mDb->getOne( $query, array( $pUserId ) );
+ $ret = $this->mDb->getOne( $query, [ $pUserId ] );
}
return $ret;
}
/**
* Given a user_id, this will return this disk space used for the given user
- * @param pUserId user_id of the user for usage to be calculated for
- * @returns an integer of the total bytes used
+ * @param integer pUserId user_id of the user for usage to be calculated for
+ * @return integer an integer of the total bytes used
*/
- function getUserUsage( $pUserId ) {
+ public function getUserUsage( $pUserId ) {
$ret = 0;
if( is_numeric( $pUserId ) ) {
// INNER JOIN on attachments so orphans are not counted
@@ -228,20 +231,18 @@ class LibertyQuota extends LibertyBase {
/**
* Generates the URL to the quota page
- * @return the link to display the page.
+ * @return string the link to display the page.
*/
- function getDisplayUrl() {
+ public function getDisplayUrl() {
$ret = NULL;
- if( @BitBase::verifyId( $this->mQuotaId ) ) {
+ if( BitBase::verifyId( $this->mQuotaId ) ) {
$ret = QUOTA_PKG_URL."index.php?quota_id=".$this->mQuotaId;
}
return $ret;
}
- function isValid() {
- return( @BitBase::verifyId( $this->mQuotaId ) );
+ public function isValid() {
+ return @BitBase::verifyId( $this->mQuotaId );
}
}
-
-?>
diff --git a/quota_inc.php b/includes/quota_inc.php
index b4e3225..23125d1 100644
--- a/quota_inc.php
+++ b/includes/quota_inc.php
@@ -9,7 +9,9 @@
/**
* quota setup
*/
-require_once( QUOTA_PKG_CLASS_PATH.'LibertyQuota.php' );
+
+use Bitweaver\Quota\LibertyQuota;
+
global $gBitSmarty, $assignUser, $gBitUser;
if( empty( $pQuotaUserId ) ) {
@@ -24,19 +26,14 @@ $quota = new LibertyQuota();
$diskUsage = $quota->getUserUsage( $pQuotaUserId );
$diskQuota = $quota->getUserQuota( $pQuotaUserId );
-if( $diskQuota != 0 ) {
- $quotaPercent = round( (($diskUsage / $diskQuota) * 100), 0 );
-} else {
- $quotaPercent = 0;
-}
+$quotaPercent = $diskQuota != 0 ? round( ( $diskUsage / $diskQuota ) * 100, 0 ) : 0;
if( $quotaPercent > 100 ) {
$errors['disk_quota'] = "You are over your disk quota.";
- $gBitSmarty->assignByRef( 'errors', $errors );
+ $gBitSmarty->assign( 'errors', $errors );
$quotaPercent = 100;
}
-$gBitSmarty->assign( 'usage', round( ($diskUsage / 1000000), 2 ) );
-$gBitSmarty->assign( 'quota', round( ($diskQuota / 1000000), 2 ) );
-$gBitSmarty->assignByRef( 'quotaPercent', $quotaPercent );
-?>
+$gBitSmarty->assign( 'usage', round( $diskUsage / 1000000, 2 ) );
+$gBitSmarty->assign( 'quota', round( $diskQuota / 1000000, 2 ) );
+$gBitSmarty->assign( 'quotaPercent', $quotaPercent );
diff --git a/index.php b/index.php
index f0400de..d6f1156 100644
--- a/index.php
+++ b/index.php
@@ -15,11 +15,10 @@
/**
* required setup
*/
-require_once( '../kernel/includes/setup_inc.php' );
+require_once '../kernel/includes/setup_inc.php';
$gBitSystem->verifyPackage( 'quota' );
-require_once( QUOTA_PKG_INCLUDE_PATH.'quota_inc.php' );
+require_once QUOTA_PKG_INCLUDE_PATH . 'quota_inc.php';
-$gBitSystem->display( 'bitpackage:quota/quota.tpl', 'View Quota' , array( 'display_mode' => 'display' ));
-?>
+$gBitSystem->display( 'bitpackage:quota/quota.tpl', 'View Quota' , [ 'display_mode' => 'display' ]);