|
From: <ree...@us...> - 2007-08-30 19:44:29
|
Revision: 29
http://thevr.svn.sourceforge.net/thevr/?rev=29&view=rev
Author: reekingofrandom
Date: 2007-08-30 12:44:31 -0700 (Thu, 30 Aug 2007)
Log Message:
-----------
ReekingofRandomness - Improved the install script to include ACP Module Setup and fix error tracking
Modified Paths:
--------------
mods/pms/trunk/thevr_pms_install.php
Modified: mods/pms/trunk/thevr_pms_install.php
===================================================================
--- mods/pms/trunk/thevr_pms_install.php 2007-08-30 16:22:37 UTC (rev 28)
+++ mods/pms/trunk/thevr_pms_install.php 2007-08-30 19:44:31 UTC (rev 29)
@@ -25,7 +25,9 @@
switch ($mode)
{
case 'install':
- //Install
+ /***
+ * Create New Tables
+ **/
/* _site_config */
$sql = "CREATE TABLE `" . $table_prefix . "site_config` (
`config_name` varchar(255) character set latin1 collate latin1_general_ci NOT NULL,
@@ -94,60 +96,298 @@
trigger_error('TheVR Mod :: Failed to create tables');
}
- //Create Permissions
- $sql = "INSERT INTO `phpbb_acl_options` ( `auth_option_id` , `auth_option` , `is_global` , `is_local` , `founder_only` ) VALUES ( NULL , 'a_sites_a', '1', '0', '0' ),
- ( NULL , 'a_sites_e', '1', '0', '0' ),
- ( NULL , 'a_sites_d', '1', '0', '0' ),
- ( NULL , 'a_sites_ug', '1', '0', '0' ),
- ( NULL , 'a_sites_f', '1', '0', '0' )";
+ /***
+ * Insert Permissions
+ **/
+ $sql = "INSERT INTO " . ACL_OPTIONS_TABLE . " ( `auth_option_id` , `auth_option` , `is_global` , `is_local` , `founder_only` )
+ VALUES ( NULL , 'a_sites_a', '1', '0', '0' ),
+ ( NULL , 'a_sites_e', '1', '0', '0' ),
+ ( NULL , 'a_sites_d', '1', '0', '0' ),
+ ( NULL , 'a_sites_ug', '1', '0', '0' ),
+ ( NULL , 'a_sites_f', '1', '0', '0' )";
if(!$db->sql_query($sql))
{
- define('ERROR',true);
- }
+ foreach($success as $i => $table)
+ {
+ $sql = "DROP TABLE " . $table_prefix . $table . " ";
+ @$db->sql_query($sql);
+ }
- if(defined('ERROR'))
- {
trigger_error('TheVR Mod :: Failed to create permissions');
+ }
+ /***
+ * Update forums table
+ **/
+ $sql = "ALTER TABLE `phpbb_forums` ADD `site_id` MEDIUMINT( 4 ) NOT NULL DEFAULT '0';";
+
+ if(!$db->sql_query($sql))
+ {
foreach($success as $i => $table)
{
$sql = "DROP TABLE " . $table_prefix . $table . " ";
@$db->sql_query($sql);
}
+ $sql = "DELETE
+ FROM " . ACL_OPTIONS_TABLE . "
+ WHERE auth_option_id LIKE 'a_sites_%'";
+ @$db->sql_query($sql);
+
+ trigger_error('TheVR Mod :: Failed to alter forums table');
}
- //Update forums table
- $sql = "ALTER TABLE `phpbb_forums` ADD `site_id` MEDIUMINT( 4 ) NOT NULL DEFAULT '0';";
+ /***
+ * Set Up admin Panel Module
+ **/
+ $sql = 'SELECT right_id
+ FROM ' . MODULES_TABLE . '
+ WHERE module_class = \'acp\'
+ ORDER BY right_id DESC';
+ $result = $db->sql_query($sql);
+ $posnum = $db->sql_fetchfield('right_id',0,$result) + 1;
+ $topmodule = array( 'module_enabled' => 1,
+ 'module_display' => 1,
+ 'module_basename' => '',
+ 'module_class' => 'acp',
+ 'parent_id' => 0,
+ 'left_id' => $posnum,
+ 'right_id' => $posnum+11,
+ 'module_langname' => 'Sites',
+ 'module_mode' => '',
+ 'module_auth' => ''
+ );
+
+ $sql = 'INSERT INTO ' . MODULES_TABLE . ' ' . $db->sql_build_array('INSERT',$topmodule);
if(!$db->sql_query($sql))
{
- define('ERROR',true);
+ foreach($success as $i => $table)
+ {
+ $sql = "DROP TABLE " . $table_prefix . $table . " ";
+ @$db->sql_query($sql);
+ }
+
+ $sql = "DELETE
+ FROM " . ACL_OPTIONS_TABLE . "
+ WHERE auth_option_id LIKE 'a_sites_%'";
+ @$db->sql_query($sql);
+
+ $sql = 'ALTER TABLE ' . FORUMS_TABLE . ' DROP COLUMN `site_id`';
+ @$db->sql_query($sql);
+
+ trigger_error('TheVR Mod :: Failed to add sites category');
}
+ $topid = $db->sql_nextid;
- if(defined('ERROR'))
- {
- trigger_error('TheVR Mod :: Failed to alter forums table');
+ $modules = array( 1 => array( 'module_enabled' => 1,
+ 'module_display' => 1,
+ 'module_basename' => '',
+ 'module_class' => 'acp',
+ 'parent_id' => $topid,
+ 'left_id' => $posnum+1,
+ 'right_id' => $posnum+6,
+ 'module_langname' => 'Global Management',
+ 'module_mode' => '',
+ 'module_auth' => ''
+ ),
+ 2 => array( 'module_enabled' => 1,
+ 'module_display' => 1,
+ 'module_basename' => '',
+ 'module_class' => 'acp',
+ 'parent_id' => $topid,
+ 'left_id' => $posnum+7,
+ 'right_id' => $posnum+10,
+ 'module_langname' => 'Site Config',
+ 'module_mode' => '',
+ 'module_auth' => ''
+ ),
+ 3 => array( 'module_enabled' => 1,
+ 'module_display' => 1,
+ 'module_basename' => 'sites',
+ 'module_class' => 'acp',
+ 'parent_id' => $topid+1,
+ 'left_id' => $posnum+2,
+ 'right_id' => $posnum+3,
+ 'module_langname' => 'ACP_MANAGE_SITES',
+ 'module_mode' => 'manage',
+ 'module_auth' => 'acl_a_server'
+ ),
+ 4 => array( 'module_enabled' => 1,
+ 'module_display' => 1,
+ 'module_basename' => 'sites',
+ 'module_class' => 'acp',
+ 'parent_id' => $top_id+1,
+ 'left_id' => $posnum+4,
+ 'right_id' => $posnum+5,
+ 'module_langname' => 'ACP_MANAGE_SITE_URLS',
+ 'module_mode' => 'manage_url',
+ 'module_auth' => 'acl_a_server'
+ ),
+ 5 => array( 'module_enabled' => 1,
+ 'module_display' => 1,
+ 'module_basename' => 'sites',
+ 'module_class' => 'acp',
+ 'parent_id' => $topid+2,
+ 'left_id' => $posnum+8,
+ 'right_id' => $posnum+9,
+ 'module_langname' => 'ACP_SITE_SETTINGS',
+ 'module_mode' => 'settings',
+ 'module_auth' => 'acl_a_server'
+ )
+ );
+ if(!$db->sql_multi_insert(MODULES_TABLE,$modules))
+ {
foreach($success as $i => $table)
{
$sql = "DROP TABLE " . $table_prefix . $table . " ";
@$db->sql_query($sql);
}
- }
- //Put initial data into table.
+ $sql = 'DELETE
+ FROM ' . ACL_OPTIONS_TABLE . '
+ WHERE auth_option_id LIKE \'a_sites_%\'';
+ @$db->sql_query($sql);
+
+ $sql = 'ALTER TABLE ' . FORUMS_TABLE . ' DROP COLUMN `site_id`';
+ @$db->sql_query($sql);
+
+ $sql = 'DELETE
+ FROM ' . MODULES_TABLE . '
+ WHERE module_id = ' . $topid;
+ @$db->sql_query($sql);
+
+ trigger_error('TheVR Mod :: Failed to add modules');
+ }
+
+ /***
+ * Create Initial Site
+ **/
+ $errors = array();
+ $success2 = array();
+
+ //Put initial data into table.
$data = array( 'name' => $config['sitename'],
'domain' => $config['server_name'],
'desc' => $config['site_desc'],
'group_id' => '',
- 'home' => '',
+ 'home' => 'index.php',
'style' => $config['default_style']);
- add_site($data);
+ include($phpbb_root_path . 'includes/functions_user.php');
- trigger_error('TheVR Mod :: Successful Installation');
+ //Vars for group creation:
+ $g_type = 'GROUP_CLOSED';
+ $g_name = 'registered_'.preg_replace('/\s\s+/','_',$data['name']);
+ $g_desc = 'The members of '.$data['name'];
+ $g_att = array('group_legend' => 0);
+
+ if (group_create($group_id,$g_type,$g_name,$g_desc,$g_att))
+ {
+ define('ERROR',true);
+ $errors[] = $user->lang['GRP_ADD_FAIL']
+ }
+ else
+ {
+ $success2[] = 'groups';
+ $data['group_id'] = $group_id;
+
+ $site_ins = array ( 'name' => $data['name'],
+ 'description' => $data['desc'],
+ 'group_id' => $data['group_id'],
+ 'home' => $data['home'],
+ 'default_style' => $data['style'] );
+
+ //Insert into sites table.
+ if( !$db->sql_query('INSERT INTO '. $table_prefix .'sites '.$db->sql_build_array('INSERT',$site_ins)))
+ {
+ define('ERROR',true);
+ $errors[] = $user->lang['SITE_ADD_FAIL'];
+ }
+ else
+ {
+ $success2[] = 'sites';
+ }
+ $data['site_id'] = $db->sql_nextid
+ }
+
+ $siteurl_ins = array ( 'site_id' => $data['site_id'],
+ 'domain' => $data['domain'] );
+
+ if( !$db->sql_query('INSERT INTO '. $table_prefix . 'site_urls '.$db->sql_build_array('INSERT',$siteurl_ins)))
+ {
+ define('ERROR',true);
+ $errors[] = $user->lang['SITE_URL_ADD_FAIL'];
+ }
+ else
+ {
+ $success2[] = 'url';
+ }
+
+ if (defined('ERROR'))
+ {
+ foreach($success as $i => $table)
+ {
+ $sql = "DROP TABLE " . $table_prefix . $table . " ";
+ @$db->sql_query($sql);
+ }
+
+ $sql = 'DELETE
+ FROM ' . ACL_OPTIONS_TABLE . '
+ WHERE auth_option_id LIKE \'a_sites_%\'';
+ @$db->sql_query($sql);
+
+ $sql = 'ALTER TABLE ' . FORUMS_TABLE . ' DROP COLUMN `site_id`';
+ @$db->sql_query($sql);
+
+ $sql = 'DELETE
+ FROM ' . MODULES_TABLE . '
+ WHERE module_id = ' . $topid;
+ @$db->sql_query($sql);
+
+ foreach($modules as $array)
+ {
+ $sql = 'DELETE
+ FROM ' . MODULES_TABLE . '
+ WHERE left_id = ' . $array['left_id'];
+ @$db->sql_query($sql);
+ }
+
+ foreach($success2 as $ob)
+ {
+ switch ($ob)
+ {
+ case 'groups':
+ group_delete($group_id);
+ break;
+ case 'sites':
+ $sql = 'DELETE
+ FROM ' . $table_prefix . 'sites
+ WHERE site_id = ' . $data['site_id'];
+ @$db->sql_query($sql);
+ break;
+ case 'url':
+ $sql = 'DELETE
+ FROM ' . $table_prefix . 'sites
+ WHERE site_id = ' . $data['site_id'];
+ @$db->sql_query($sql);
+ break;
+ }
+ }
+
+ $error = '';
+ foreach($errors as $message)
+ {
+ $error .= $message;
+ }
+
+ trigger_error('TheVR Mod :: ' . $message);
+
+ }
+ trigger_error('TheVR Mod :: Successful Installation');
+
break;
case 'update':
$vers = request_var('v','');
@@ -207,99 +447,5 @@
}
-//Functions
-function add_url($data)
-{
- global $db, $user, $table_prefix;
-
- if (!is_array($data))
- {
- trigger_error($user->lang['VAR_NOT_ARRAY'], E_USER_WARNING);
- }
-
- //Check if domain already exists.
- $sql = 'SELECT * FROM '. $table_prefix . 'site_urls WHERE domain=\''.$data['domain'].'\'';
- $result = $db->sql_query($sql);
- if (sizeof($db->sql_fetchrowset($result)) > 0)
- {
- trigger_error($user->lang['DUPLI_DOMAIN']);
- }
-
- $siteurl_ins = array ( 'site_id' => $data['site_id'],
- 'domain' => $data['domain'] );
-
- if( !$db->sql_query('INSERT INTO '. $table_prefix . 'site_urls '.$db->sql_build_array('INSERT',$siteurl_ins)))
- {
- trigger_error($user->lang['SITE_URL_ADD_FAIL']);
- }
- else
- {
- return true;
- }
-}
-
-
-function add_site($data)
-{
- global $db, $user, $table_prefix, $phpbb_root_path;
-
- include($phpbb_root_path . 'includes/functions_user.php');
-
- if (!is_array($data))
- {
- trigger_error($user->lang['VAR_NOT_ARRAY'], E_USER_WARNING);
- }
-
- if ( $data['domain'] == '' )
- {
- trigger_error($user->lang['NO_DOMAIN_SUPPLIED']);
- }
-
- //Check if the name or domain name already exist.
- $sql = 'SELECT * FROM '. $table_prefix . 'sites WHERE name=\''.$data['name'].'\'';
- $result = $db->sql_query($sql);
- if (sizeof($db->sql_fetchrowset($result)) > 0)
- {
- trigger_error($user->lang['DUPLI_NAME']);
- }
-
- //Vars for group creation:
- $g_type = 'GROUP_CLOSED';
- $g_name = 'registered_'.preg_replace('/\s\s+/','_',$data['name']);
- $g_desc = 'The members of '.$data['name'];
- $g_att = array('group_legend' => 0);
-
-
- if (group_create($group_id,$g_type,$g_name,$g_desc,$g_att))
- {
- trigger_error($user->lang['GRP_ADD_FAIL']);
- }
- else
- {
- $sql = 'SELECT * FROM '.GROUPS_TABLE.' WHERE group_name=\'registered_'.$data['name'].'\'';
- $data['group_id'] = $db->sql_fetchfield('group_id',0,$db->sql_query($sql));
-
- $site_ins = array ( 'name' => $data['name'],
- 'description' => $data['desc'],
- 'group_id' => $data['group_id'],
- 'home' => $data['home'],
- 'default_style' => $data['style'] );
-
- //Insert into sites table.
- if( !$db->sql_query('INSERT INTO '. $table_prefix .'sites '.$db->sql_build_array('INSERT',$site_ins)))
- {
- trigger_error($user->lang['SITE_ADD_FAIL']);
- }
-
- $sql = 'SELECT * FROM '. $table_prefix .'sites WHERE name=\''.$data['name'].'\'';
- $data['site_id'] = $db->sql_fetchfield('site_id',0,$db->sql_query($sql));
-
- if(add_url($data))
- {
- return $data['site_id'];
- }
-
- }
-}
?>
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|