Moved installation to UMIL install file

This commit is contained in:
Marc Alexander
2010-11-17 19:44:54 +00:00
parent ed8f256ffb
commit 670bd11fa6
3 changed files with 90 additions and 70 deletions

View File

@@ -20,6 +20,10 @@ if (!file_exists($phpbb_root_path . 'umil/umil_auto.' . $phpEx))
{ {
trigger_error('Please download the latest UMIL (Unified MOD Install Library) from: <a href="http://www.phpbb.com/mods/umil/">phpBB.com/mods/umil</a>', E_USER_ERROR); trigger_error('Please download the latest UMIL (Unified MOD Install Library) from: <a href="http://www.phpbb.com/mods/umil/">phpBB.com/mods/umil</a>', E_USER_ERROR);
} }
if(!function_exists('board3_basic_install'))
{
include($phpbb_root_path . 'portal/includes/functions.' . $phpEx);
}
// The name of the mod to be displayed during installation. // The name of the mod to be displayed during installation.
$mod_name = 'Board3 Portal'; $mod_name = 'Board3 Portal';
@@ -83,7 +87,7 @@ $versions = array(
), ),
'PRIMARY_KEY' => 'config_name', 'PRIMARY_KEY' => 'config_name',
)); )),
), ),
@@ -95,7 +99,6 @@ $versions = array(
array('board3_forum_index', 1, 0), array('board3_forum_index', 1, 0),
array('board3_left_column_width', 180, 0), array('board3_left_column_width', 180, 0),
array('board3_right_column_width', 180, 0), array('board3_right_column_width', 180, 0),
array('board3_first_install', 1, 0), // this will tell board3 portal to install the basic modules
), ),
'module_add' => array( 'module_add' => array(
@@ -118,6 +121,7 @@ $versions = array(
), ),
), ),
), ),
'custom' => array('board3_basic_install'),
), ),
); );

View File

@@ -65,6 +65,10 @@ $lang = array_merge($lang, array(
'PORTAL_RIGHT_COLUMN_WIDTH' => 'Width of the right column', 'PORTAL_RIGHT_COLUMN_WIDTH' => 'Width of the right column',
'PORTAL_RIGHT_COLUMN_WIDTH_EXP' => 'Change the width of the right column in pixels; recommended value is 180', 'PORTAL_RIGHT_COLUMN_WIDTH_EXP' => 'Change the width of the right column in pixels; recommended value is 180',
// Install
'PORTAL_BASIC_INSTALL' => 'Adding basic set of modules',
'PORTAL_BASIC_UNINSTALL' => 'Removing modules from database',
// Portal Modules // Portal Modules
'ACP_PORTAL_MODULES' => 'Portal Modules', 'ACP_PORTAL_MODULES' => 'Portal Modules',

View File

@@ -9,7 +9,7 @@
* *
*/ */
if (!defined('IN_PHPBB')) if (!defined('IN_PHPBB') && !defined('UMIL_AUTO') && !defined('IN_INSTALL'))
{ {
exit; exit;
} }
@@ -815,85 +815,97 @@ function get_portal_tracking_info($fetch_news)
* !! this function should usually only be executed once upon installing the portal !! * !! this function should usually only be executed once upon installing the portal !!
* DO NOT set $purge_modules to false unless you want to auto-add all modules again after deleting them (i.e. if your database was corrupted) * DO NOT set $purge_modules to false unless you want to auto-add all modules again after deleting them (i.e. if your database was corrupted)
*/ */
function board3_basic_install($purge_modules = true, $u_action) function board3_basic_install($mode = 'install', $purge_modules = true, $u_action = '')
{ {
global $db, $phpbb_root_path, $phpEx, $cache, $user; global $db, $phpbb_root_path, $phpEx, $cache, $user, $table_prefix;
$directory = $phpbb_root_path . 'portal/modules/'; if(!defined('PORTAL_MODULES_TABLE'))
if($purge_modules)
{ {
$sql = 'DELETE FROM ' . PORTAL_MODULES_TABLE; include($phpbb_root_path . 'portal/includes/constants.' . $phpEx);
$result = $db->sql_query($sql);
$db->sql_freeresult($result);
} }
/* if($mode == 'install')
* this is a list of the basic modules that will be installed
* module_name => array(module_column, module_order)
*/
$modules_ary = array(
// left column
'portal_main_menu' => array(1, 1),
'portal_stylechanger' => array(1, 2),
'portal_birthday_list' => array(1, 3),
'portal_clock' => array(1, 4),
'portal_search' => array(1, 5),
'portal_random_member' => array(1, 6),
'portal_attachments' => array(1, 7),
'portal_topposters' => array(1, 8),
'portal_latest_members' => array(1, 9),
'portal_link_us' => array(1, 10),
// center column
'portal_welcome' => array(2, 1),
'portal_recent' => array(2, 2),
'portal_announcements' => array(2, 3),
'portal_news' => array(2, 4),
'portal_poll' => array(2, 5),
'portal_whois_online' => array(2, 6),
// 'portal_jumpbox' => array(2, 7),
// right column
'portal_user_menu' => array(3, 1),
'portal_statistics' => array(3, 2),
'portal_calendar' => array(3, 3),
'portal_leaders' => array(3, 4),
'portal_latest_bots' => array(3, 5),
'portal_links' => array(3, 6),
);
foreach($modules_ary as $module_name => $module_data)
{ {
$class_name = $module_name . '_module'; $directory = $phpbb_root_path . 'portal/modules/';
if (!class_exists($class_name))
if($purge_modules)
{ {
include($directory . $module_name . '.' . $phpEx); $sql = 'DELETE FROM ' . PORTAL_MODULES_TABLE;
} $result = $db->sql_query($sql);
if (!class_exists($class_name)) $db->sql_freeresult($result);
{
trigger_error('CLASS_NOT_FOUND', E_USER_ERROR);
} }
$c_class = new $class_name(); /*
* this is a list of the basic modules that will be installed
* module_name => array(module_column, module_order)
*/
$modules_ary = array(
// left column
'portal_main_menu' => array(1, 1),
'portal_stylechanger' => array(1, 2),
'portal_birthday_list' => array(1, 3),
'portal_clock' => array(1, 4),
'portal_search' => array(1, 5),
'portal_random_member' => array(1, 6),
'portal_attachments' => array(1, 7),
'portal_topposters' => array(1, 8),
'portal_latest_members' => array(1, 9),
'portal_link_us' => array(1, 10),
$sql_ary = array( // center column
'module_classname' => substr($module_name, 7), 'portal_welcome' => array(2, 1),
'module_column' => $module_data[0], 'portal_recent' => array(2, 2),
'module_order' => $module_data[1], 'portal_announcements' => array(2, 3),
'module_name' => $c_class->name, 'portal_news' => array(2, 4),
'module_image_src' => $c_class->image_src, 'portal_poll' => array(2, 5),
'module_group_ids' => '', 'portal_whois_online' => array(2, 6),
// 'portal_jumpbox' => array(2, 7),
// right column
'portal_user_menu' => array(3, 1),
'portal_statistics' => array(3, 2),
'portal_calendar' => array(3, 3),
'portal_leaders' => array(3, 4),
'portal_latest_bots' => array(3, 5),
'portal_links' => array(3, 6),
); );
$sql = 'INSERT INTO ' . PORTAL_MODULES_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary);
$db->sql_query($sql);
$c_class->install($db->sql_nextid()); foreach($modules_ary as $module_name => $module_data)
{
$class_name = $module_name . '_module';
if (!class_exists($class_name))
{
include($directory . $module_name . '.' . $phpEx);
}
if (!class_exists($class_name))
{
trigger_error('CLASS_NOT_FOUND', E_USER_ERROR);
}
$c_class = new $class_name();
$sql_ary = array(
'module_classname' => substr($module_name, 7),
'module_column' => $module_data[0],
'module_order' => $module_data[1],
'module_name' => $c_class->name,
'module_image_src' => $c_class->image_src,
'module_group_ids' => '',
);
$sql = 'INSERT INTO ' . PORTAL_MODULES_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary);
$db->sql_query($sql);
$c_class->install($db->sql_nextid());
}
return $user->lang['PORTAL_BASIC_INSTALL'];
}
else
{
return $user->lang['PORTAL_BASIC_UNINSTALL'];
} }
$cache->purge(); // make sure we don't get errors after re-adding a module
trigger_error($user->lang['SUCCESS_ADD'] . adm_back_link($u_action));
} }
?> ?>