summaryrefslogtreecommitdiff
path: root/admin/admin_quota_inc.php
blob: bc8e441fc480f381e5bab493c185c78643c24800 (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
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
// $Header: /cvsroot/bitweaver/_bit_quota/admin/admin_quota_inc.php,v 1.3 2006/02/08 21:51:14 squareing Exp $
// Copyright (c) 2002-2003, Luis Argerich, Garland Foster, Eduardo Polidor, et. al.
// 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.

// is this used?
//if( isset( $_REQUEST["quotaset"] ) && isset( $_REQUEST["homeSample"] ) ) {
//	$gBitSystem->storePreference( "home_quota", $_REQUEST["homeSample"], QUOTA_PKG_NAME );
//	$gBitSmarty->assign( 'home_quota', $_REQUEST["homeSample"] );
//}

require_once( QUOTA_PKG_PATH.'LibertyQuota.php' );

if( !empty( $_REQUEST['cancelquota'] ) ) {
	unset( $_REQUEST['quota_id'] );
}

$gQuota = new LibertyQuota( !empty( $_REQUEST['quota_id'] ) ? $_REQUEST['quota_id'] : NULL );

if( !empty( $_REQUEST['savequota'] ) ) {
	if( $gQuota->store( $_REQUEST ) ) {
		header( 'Location: '.KERNEL_PKG_URL.'admin/index.php?page=quota' );
		die;
	} else {
		$saveError = TRUE;
		$gBitSmarty->assign_by_ref( 'errors', $gQuota->mErrors );
	}
} elseif( !empty( $_REQUEST['assignquota'] ) ) {
	foreach( array_keys( $_REQUEST ) as $key ) {
		if( preg_match( '/^quota_group_([-0-9]*)/', $key, $match ) ) {
			$groupId = $match[1];
			$gQuota->assignQuotaToGroup( $_REQUEST[$key], $groupId );
//vd( $match );
		}
	}
}
$gQuota->load();
if( $gQuota->isValid() || isset( $_REQUEST['newquota'] ) || !empty( $saveError ) ) {
	$gBitSmarty->assign_by_ref('gQuota', $gQuota);
} else {
	$quotas = $gQuota->getList();
	$systemGroups = $gQuota->getQuotaGroups();
	$gBitSmarty->assign_by_ref('systemGroups', $systemGroups );
foreach( array_keys( $systemGroups ) as $groupId ) {
	$groupQuota[$groupId] = $gQuota->getQuotaMenu( 'quota_group_'.$groupId, $systemGroups[$groupId]['quota_id'] );
}
	$gBitSmarty->assign_by_ref('groupQuota', $groupQuota );
	$gBitSmarty->assign_by_ref('quotaList', $quotas);
}

?>