Merge pull request #209 from marc1706/ticket/208

[ticket/208] Move includes files out of portal folder
This commit is contained in:
Marc Alexander
2014-02-03 15:52:46 -08:00
12 changed files with 36 additions and 147 deletions

View File

@@ -22,7 +22,7 @@ class portal_module
public $u_action;
public $new_config = array();
protected $c_class;
protected $db, $user, $cache, $template, $display_vars, $config, $phpbb_root_path, $portal_root_path, $phpbb_admin_path, $phpEx, $phpbb_container;
protected $db, $user, $cache, $template, $display_vars, $config, $phpbb_root_path, $phpbb_admin_path, $phpEx, $phpbb_container;
protected $root_path, $mod_version_check, $request;
/** @var \phpbb\di\service_collection Portal modules */
@@ -31,14 +31,13 @@ class portal_module
public function __construct()
{
global $db, $user, $cache, $request, $template;
global $config, $phpbb_root_path, $portal_root_path, $phpbb_admin_path, $phpbb_container, $phpEx;
global $config, $phpbb_root_path, $phpbb_admin_path, $phpbb_container, $phpEx;
$user->add_lang_ext('board3/portal', 'portal');
$this->root_path = $phpbb_root_path . 'ext/board3/portal/';
include($this->root_path . 'portal/includes/constants.' . $phpEx);
$portal_root_path = PORTAL_ROOT_PATH;
include($this->root_path . 'includes/constants.' . $phpEx);
$this->db = $db;
$this->user = $user;
@@ -48,7 +47,6 @@ class portal_module
$this->request = $request;
$this->phpbb_root_path = $phpbb_root_path;
$this->phpbb_admin_path = $phpbb_admin_path;
$this->portal_root_path = $this->root_path . 'portal/';
$this->php_ex = $phpEx;
$this->phpbb_container = $phpbb_container;
$this->mod_version_check = $this->phpbb_container->get('board3.version.check');
@@ -56,12 +54,12 @@ class portal_module
if (!function_exists('column_string_const'))
{
include($this->portal_root_path . 'includes/functions_modules.' . $this->php_ex);
include($this->root_path . 'includes/functions_modules.' . $this->php_ex);
}
if(!function_exists('obtain_portal_config'))
{
include($this->portal_root_path . 'includes/functions.' . $this->php_ex);
include($this->root_path . 'includes/functions.' . $this->php_ex);
}
}
@@ -722,7 +720,7 @@ class portal_module
{
trigger_error($this->user->lang['FORM_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING);
}
include($this->root_path . 'portal/includes/functions_upload.' . $this->php_ex);
include($this->root_path . 'includes/functions_upload.' . $this->php_ex);
// Default upload path is portal/upload/
$upload_path = $this->root_path . 'portal/upload/';

View File

@@ -98,15 +98,15 @@ class main
$this->php_ext = $php_ext;
$this->register_modules($modules);
$this->includes_path = $phpbb_root_path . 'ext/board3/portal/portal/';
$this->includes_path = $phpbb_root_path . 'ext/board3/portal/includes/';
$this->root_path = $phpbb_root_path . 'ext/board3/portal/';
$portal_root_path = $this->root_path;
if (!function_exists('obtain_portal_config'))
{
include($this->includes_path . 'includes/constants' . $this->php_ext);
include($this->includes_path . 'includes/functions_modules' . $this->php_ext);
include($this->includes_path . 'includes/functions' . $this->php_ext);
include($this->includes_path . 'constants' . $this->php_ext);
include($this->includes_path . 'functions_modules' . $this->php_ext);
include($this->includes_path . 'functions' . $this->php_ext);
}
}

View File

@@ -694,129 +694,6 @@ function get_portal_tracking_info($fetch_news)
return $last_read;
}
/**
* This function will install the basic set of portal modules
*
* 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
* note 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($mode = 'install', $purge_modules = true, $u_action = '')
{
global $db, $phpbb_root_path, $phpEx, $cache, $user, $table_prefix, $config;
// Shouldn't happen but we should check this nonetheless
if (!defined('PORTAL_MODULES_TABLE'))
{
include($phpbb_root_path . 'portal/includes/constants.' . $phpEx);
}
if ($mode == 'install')
{
$directory = $phpbb_root_path . 'portal/modules/';
if ($purge_modules)
{
$sql = 'DELETE FROM ' . PORTAL_MODULES_TABLE;
$result = $db->sql_query($sql);
$db->sql_freeresult($result);
}
/*
* 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_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),
// 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';
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' => '',
'module_image_width' => 16,
'module_image_height' => 16,
'module_status' => B3_MODULE_ENABLED,
);
$sql = 'INSERT INTO ' . PORTAL_MODULES_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary);
$db->sql_query($sql);
$c_class->install($db->sql_nextid());
}
// Make sure we get rid of old data
$cache->destroy('portal_modules');
return $user->lang['PORTAL_BASIC_INSTALL'];
}
else
{
$skip_entries = array(
'board3_right_column_width',
'board3_left_column_width',
'board3_forum_index',
'board3_version_check',
'board3_right_column',
'board3_left_column',
'board3_enable',
'board3_portal_version',
'board3_phpbb_menu',
'board3_display_jumpbox',
);
$sql = 'DELETE FROM ' . CONFIG_TABLE . ' WHERE config_name ' . $db->sql_like_expression(utf8_clean_string('board3_') . $db->any_char) . '
AND ' . $db->sql_in_set('config_name', $skip_entries, true);
$db->sql_query($sql);
return $user->lang['PORTAL_BASIC_UNINSTALL'];
}
}
/**
* check if the entered source file actually exists
*/

View File

@@ -109,7 +109,7 @@ class announcements extends module_base
$start = $this->request->variable('ap', 0);
$start = ($start < 0) ? 0 : $start;
// Fetch announcements from portal/includes/functions.php with check if "read full" is requested.
// Fetch announcements from porta functions.php with check if "read full" is requested.
$portal_announcement_length = ($announcement < 0) ? $this->config['board3_announcements_length_' . $module_id] : 0;
$fetch_news = phpbb_fetch_posts($module_id, $this->config['board3_global_announcements_forum_' . $module_id], $this->config['board3_announcements_permissions_' . $module_id], $this->config['board3_number_of_announcements_' . $module_id], $portal_announcement_length, $this->config['board3_announcements_day_' . $module_id], 'announcements', $start, $this->config['board3_announcements_forum_exclude_' . $module_id]);

View File

@@ -110,7 +110,7 @@ class news extends module_base
$start = $this->request->variable('np', 0);
$start = ($start < 0) ? 0 : $start;
// Fetch news from portal/includes/functions.php with check if "read full" is requested.
// Fetch news from portal functions.php with check if "read full" is requested.
$portal_news_length = ($news < 0) ? $this->config['board3_news_length_' . $module_id] : 0;
$fetch_news = phpbb_fetch_posts($module_id, $this->config['board3_news_forum_' . $module_id], $this->config['board3_news_permissions_' . $module_id], $this->config['board3_number_of_news_' . $module_id], $portal_news_length, 0, ($this->config['board3_show_all_news_' . $module_id]) ? 'news_all' : 'news', $start, $this->config['board3_news_exclude_' . $module_id]);

View File

@@ -1,7 +0,0 @@
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
</head>
<body bgcolor="#FFFFFF" text="#000000">
</body>
</html>

View File

@@ -7,7 +7,7 @@
*
*/
require_once(dirname(__FILE__) . '/../../portal/includes/functions.php');
require_once(dirname(__FILE__) . '/../../includes/functions.php');
require_once(dirname(__FILE__) . '/../../../../../includes/functions_acp.php');
class phpbb_functions_check_file_src_test extends \board3\portal\tests\testframework\database_test_case

View File

@@ -7,7 +7,7 @@
*
*/
require_once(dirname(__FILE__) . '/../../portal/includes/functions.php');
require_once(dirname(__FILE__) . '/../../includes/functions.php');
class phpbb_functions_simple_test extends PHPUnit_Framework_TestCase
{

View File

@@ -17,7 +17,7 @@ abstract class functional_test_case extends \phpbb_functional_test_case
{
$enable_portal = false;
if ($this->portal_enabled === true)
if ($this->portal_enabled === true || $this->check_if_enabled())
{
return;
}
@@ -39,6 +39,27 @@ abstract class functional_test_case extends \phpbb_functional_test_case
$crawler = self::submit($form);
$this->assertContains('The extension was enabled successfully', $crawler->text());
$this->portal_enabled = true;
$this->set_enabled();
}
}
protected function check_if_enabled()
{
$this->db = $this->get_db();
$sql = "SELECT config_value FROM phpbb_config WHERE config_name = 'b3p_ext_enabled'";
$result = $this->db->sql_query($sql);
$enabled = $this->db->sql_fetchfield('config_value');
$this->db->sql_freeresult($result);
return $enabled;
}
protected function set_enabled()
{
$this->db = $this->get_db();
$sql = "INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('b3p_ext_enabled', 1, 1)";
$this->db->sql_query($sql);
}
}