Added the basic way of installing the modules after portal has been installed for the first time
This commit is contained in:
@@ -43,6 +43,13 @@ class acp_portal
|
|||||||
|
|
||||||
$user->add_lang('mods/portal');
|
$user->add_lang('mods/portal');
|
||||||
$submit = (isset($_POST['submit'])) ? true : false;
|
$submit = (isset($_POST['submit'])) ? true : false;
|
||||||
|
|
||||||
|
// install modules first if this is the first visit
|
||||||
|
if($config['board3_first_install'])
|
||||||
|
{
|
||||||
|
set_config('board3_first_install', 0);
|
||||||
|
board3_basic_install(true, $this->u_action);
|
||||||
|
}
|
||||||
|
|
||||||
$form_key = 'acp_portal';
|
$form_key = 'acp_portal';
|
||||||
add_form_key($form_key);
|
add_form_key($form_key);
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ $language_file = 'mods/info_acp_portal';
|
|||||||
* The version numbering must otherwise be compatible with the version_compare function - http://php.net/manual/en/function.version-compare.php
|
* The version numbering must otherwise be compatible with the version_compare function - http://php.net/manual/en/function.version-compare.php
|
||||||
*/
|
*/
|
||||||
$versions = array(
|
$versions = array(
|
||||||
'2.0.0-dev1' => array(
|
'2.0.0-dev2' => array(
|
||||||
|
|
||||||
'permission_add' => array(
|
'permission_add' => array(
|
||||||
array('a_portal'),
|
array('a_portal'),
|
||||||
@@ -88,13 +88,14 @@ $versions = array(
|
|||||||
),
|
),
|
||||||
|
|
||||||
'config_add' => array(
|
'config_add' => array(
|
||||||
array('board3_enable', '1', 0),
|
array('board3_enable', 1, 0),
|
||||||
array('board3_left_column', '1', 0),
|
array('board3_left_column', 1, 0),
|
||||||
array('board3_right_column', '1', 0),
|
array('board3_right_column', 1, 0),
|
||||||
array('board3_version_check', '1', 0),
|
array('board3_version_check', 1, 0),
|
||||||
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(
|
||||||
|
|||||||
@@ -806,50 +806,94 @@ function get_portal_tracking_info($fetch_news)
|
|||||||
return $last_read;
|
return $last_read;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mini Cal.
|
/*
|
||||||
class calendar
|
* this function will install the basic set of blocks
|
||||||
|
* only set $purge_modules to false if you already know that the table is empty
|
||||||
|
* set $u_action to where the user should be redirected after this
|
||||||
|
* not that already existing data won't be deleted from the config and portal_config
|
||||||
|
* just to make sure we don't overwrite anything, the IDs won't be reset
|
||||||
|
* !! 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)
|
||||||
|
*/
|
||||||
|
function board3_basic_install($purge_modules = true, $u_action)
|
||||||
{
|
{
|
||||||
var $dateYYY; // year in numeric format (YYYY)
|
global $db, $phpbb_root_path, $phpEx, $cache, $user;
|
||||||
var $dateMM; // month in numeric format (MM)
|
|
||||||
var $dateDD; // day in numeric format (DD)
|
$directory = $phpbb_root_path . 'portal/modules/';
|
||||||
var $ext_dateMM; // extended month (e.g. February)
|
|
||||||
var $daysMonth; // count of days in month
|
if($purge_modules)
|
||||||
var $stamp; // timestamp
|
|
||||||
var $day; // return array s.a.
|
|
||||||
|
|
||||||
/**
|
|
||||||
* convert date->timestamp
|
|
||||||
**/
|
|
||||||
function makeTimestamp($date)
|
|
||||||
{
|
{
|
||||||
$this->stamp = strtotime($date);
|
$sql = 'DELETE FROM ' . PORTAL_MODULES_TABLE;
|
||||||
return ($this->stamp);
|
$result = $db->sql_query($sql);
|
||||||
|
$db->sql_freeresult($result);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* get date listed in array
|
* this is a list of the basic modules that will be installed
|
||||||
**/
|
* module_name => array(module_column, module_order)
|
||||||
function getMonth($callDate)
|
*/
|
||||||
|
$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';
|
||||||
$this->makeTimestamp($callDate);
|
if (!class_exists($class_name))
|
||||||
$this->dateYYYY = date("Y", $this->stamp);
|
|
||||||
$this->dateMM = date("n", $this->stamp);
|
|
||||||
$this->ext_dateMM = date("F", $this->stamp);
|
|
||||||
$this->dateDD = date("d", $this->stamp);
|
|
||||||
$this->daysMonth = date("t", $this->stamp);
|
|
||||||
|
|
||||||
for($i=1; $i < $this->daysMonth+1; $i++)
|
|
||||||
{
|
{
|
||||||
$this->makeTimestamp("$i $this->ext_dateMM $this->dateYYYY");
|
include($directory . $module_name . '.' . $phpEx);
|
||||||
$this->day[] = array(
|
|
||||||
"0" => "$i",
|
|
||||||
"1" => $this->dateMM,
|
|
||||||
"2" => $this->dateYYYY,
|
|
||||||
"3" => (date('w', $this->stamp))
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
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());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$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));
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
Reference in New Issue
Block a user