summaryrefslogtreecommitdiff
path: root/admin
diff options
context:
space:
mode:
authorbitweaver.org <bitweaver@users.sourceforge.net>2005-06-19 05:02:20 +0000
committerbitweaver.org <bitweaver@users.sourceforge.net>2005-06-19 05:02:20 +0000
commit9896c8e5b5aa9b110bea5c4dbc438525489e15c0 (patch)
treecb1237f32a289854859c5ca4930074f60d639d45 /admin
downloadquota-9896c8e5b5aa9b110bea5c4dbc438525489e15c0.tar.gz
quota-9896c8e5b5aa9b110bea5c4dbc438525489e15c0.tar.bz2
quota-9896c8e5b5aa9b110bea5c4dbc438525489e15c0.zip
IMPORT TikiPro CLYDE FINAL
Diffstat (limited to 'admin')
-rw-r--r--admin/admin_quota_inc.php50
-rw-r--r--admin/schema_inc.php76
2 files changed, 126 insertions, 0 deletions
diff --git a/admin/admin_quota_inc.php b/admin/admin_quota_inc.php
new file mode 100644
index 0000000..af2e6c7
--- /dev/null
+++ b/admin/admin_quota_inc.php
@@ -0,0 +1,50 @@
+<?php
+// $Header: /cvsroot/bitweaver/_bit_quota/admin/admin_quota_inc.php,v 1.1 2005/06/19 05:02:20 bitweaver 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.
+if (isset($_REQUEST["quotaset"]) && isset($_REQUEST["homeSample"])) {
+ $gBitSystem->storePreference("home_quota", $_REQUEST["homeSample"]);
+ $smarty->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;
+ $smarty->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 ) ) {
+ $smarty->assign_by_ref('gQuota', $gQuota);
+} else {
+ $quotas = $gQuota->getList();
+ $systemGroups = $gQuota->getQuotaGroups();
+ $smarty->assign_by_ref('systemGroups', $systemGroups );
+foreach( array_keys( $systemGroups ) as $groupId ) {
+ $groupQuota[$groupId] = $gQuota->getQuotaMenu( 'quota_group_'.$groupId, $systemGroups[$groupId]['quota_id'] );
+}
+ $smarty->assign_by_ref('groupQuota', $groupQuota );
+ $smarty->assign_by_ref('quotaList', $quotas);
+}
+
+?>
diff --git a/admin/schema_inc.php b/admin/schema_inc.php
new file mode 100644
index 0000000..64a0a53
--- /dev/null
+++ b/admin/schema_inc.php
@@ -0,0 +1,76 @@
+<?php
+
+$tables = array(
+
+'users_quota_units' => "
+ user_id I4 PRIMARY,
+ units I4 NOTNULL
+",
+
+'tiki_quotas' => "
+ quota_id I4 PRIMARY,
+ disk_usage I8,
+ monthly_transfer I8,
+ title C(160) NOTNULL,
+ description X
+",
+
+'tiki_quotas_group_map' => "
+ quota_id I4 PRIMARY,
+ group_id I4 PRIMARY
+ CONSTRAINTS ', CONSTRAINT `tiki_quotas_group_ref` FOREIGN KEY (`group_id`) REFERENCES `".BIT_DB_PREFIX."users_groups`( `group_id` )
+ , CONSTRAINT `tiki_quotas_map_ref` FOREIGN KEY (`quota_id`) REFERENCES `".BIT_DB_PREFIX."tiki_quotas`( `quota_id` )'
+",
+
+);
+
+global $gBitInstaller;
+
+$gBitInstaller->makePackageHomeable('quota');
+
+foreach( array_keys( $tables ) AS $tableName ) {
+ $gBitInstaller->registerSchemaTable( QUOTA_PKG_DIR, $tableName, $tables[$tableName] );
+}
+
+$gBitInstaller->registerPackageInfo( QUOTA_PKG_DIR, array(
+ '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>',
+ 'version' => '0.1',
+ 'state' => 'beta',
+ 'dependencies' => 'liberty',
+) );
+
+// ### Indexes
+$indices = array (
+ 'tiki_quotas_group_idx' => array( 'table' => 'tiki_quotas_group_map', 'cols' => 'group_id', 'opts' => array( 'UNIQUE' ) ),
+);
+$gBitInstaller->registerSchemaIndexes( QUOTA_PKG_DIR, $indices );
+
+// ### Sequences
+$sequences = array (
+ 'tiki_quota_id_seq' => array( 'start' => 3 )
+);
+$gBitInstaller->registerSchemaSequences( QUOTA_PKG_DIR, $sequences );
+
+$gBitInstaller->registerSchemaDefault( QUOTA_PKG_DIR, array(
+
+ "INSERT INTO `".BIT_DB_PREFIX."tiki_quotas` ( `quota_id`, `disk_usage`, `monthly_transfer`, `title`, `description` ) VALUES ('1', 2000000, 20000000, 'Free Trial', 'A little space to try out site features' )",
+ "INSERT INTO `".BIT_DB_PREFIX."tiki_quotas` ( `quota_id`, `disk_usage`, `monthly_transfer`, `title`, `description` ) VALUES ('2', 10000000, 100000000, 'Site Supporters', 'Extra space for site supporters.' )",
+
+ "INSERT INTO `".BIT_DB_PREFIX."tiki_quotas_group_map` ( `quota_id`, `group_id` ) VALUES ( 1, 3 )",
+ "INSERT INTO `".BIT_DB_PREFIX."tiki_quotas_group_map` ( `quota_id`, `group_id` ) VALUES ( 2, 2 )",
+
+
+ "INSERT INTO `".BIT_DB_PREFIX."users_permissions` (`perm_name`, `perm_desc`, `level`, `package`) VALUES ('bit_p_create_quota', 'Can create a quota', 'registered', 'quota')",
+ "INSERT INTO `".BIT_DB_PREFIX."users_permissions` (`perm_name`, `perm_desc`, `level`, `package`) VALUES ('bit_p_quota_edit', 'Can edit any quota', 'editors', 'quota')",
+ "INSERT INTO `".BIT_DB_PREFIX."users_permissions` (`perm_name`, `perm_desc`, `level`, `package`) VALUES ('bit_p_quota_admin', 'Can admin quota', 'editors', 'quota')",
+ "INSERT INTO `".BIT_DB_PREFIX."users_permissions` (`perm_name`, `perm_desc`, `level`, `package`) VALUES ('bit_p_read_quota', 'Can read quota', 'basic', 'quota')",
+
+ "INSERT INTO `".BIT_DB_PREFIX."tiki_preferences`(`package`,`name`,`value`) VALUES ('quota', 'quota_default_ordering','title_desc')",
+ "INSERT INTO `".BIT_DB_PREFIX."tiki_preferences`(`package`,`name`,`value`) VALUES ('quota', 'quota_list_content_id','y')",
+ "INSERT INTO `".BIT_DB_PREFIX."tiki_preferences`(`package`,`name`,`value`) VALUES ('quota', 'quota_list_title','y')",
+ "INSERT INTO `".BIT_DB_PREFIX."tiki_preferences`(`package`,`name`,`value`) VALUES ('quota', 'quota_list_description','y')",
+
+
+) );
+?>