Merge pull request #115 from marc1706/feature/controller

[feature/controller] Make portal work with new controller interface
This commit is contained in:
Marc Alexander
2013-02-25 02:49:17 -08:00
12 changed files with 442 additions and 209 deletions

142
README.md
View File

@@ -1,12 +1,146 @@
#Board3 Portal 2.0.0
#Board3 Portal 2.1.0
Board Portal 2.0.0 is a second generation portal for phpBB 3.0.x. It adds a portal with several blocks to your forum.
Board Portal 2.1.0 is a second generation portal for phpBB 3.1.x. It adds a portal with several blocks to your forum.
You can change the settings, move the blocks, add new blocks and more in the ACP.
##How to use
You can download the current development version of Board3 Portal 2.0.0 here or download the current release at [www.board3.de](http://www.board3.de/ "Board3 • Portal").
Board3 Portal can be installed via AutoMOD or manually by following the instructions in install.xml (open it with your browser).
You can download the current development version of Board3 Portal 2.1.x here or download the current release at [www.board3.de](http://www.board3.de/ "Board3 • Portal").
Board3 Portal 2.1.x can currently not be installed.
Once the portal has been merged into the new extension system, you can manually install it by executing the following SQL queries (tested on MySQL):
```sql
CREATE TABLE IF NOT EXISTS `phpbb_portal_config` (
`config_name` varchar(255) COLLATE utf8_bin NOT NULL DEFAULT '',
`config_value` mediumtext COLLATE utf8_bin NOT NULL,
PRIMARY KEY (`config_name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
INSERT INTO `phpbb_portal_config` (`config_name`, `config_value`) VALUES
('board3_calendar_events_18', ''),
('board3_links_array_21', 0x613a323a7b693a303b613a343a7b733a353a227469746c65223b733a393a22426f617264332e6465223b733a333a2275726c223b733a32313a22687474703a2f2f7777772e626f617264332e64652f223b733a343a2274797065223b693a323b733a31303a227065726d697373696f6e223b733a303a22223b7d693a313b613a343a7b733a353a227469746c65223b733a393a2270687042422e636f6d223b733a333a2275726c223b733a32313a22687474703a2f2f7777772e70687062622e636f6d2f223b733a343a2274797065223b693a323b733a31303a227065726d697373696f6e223b733a303a22223b7d7d),
('board3_menu_array_1', 0x613a31313a7b693a303b613a343a7b733a353a227469746c65223b733a393a224d5f434f4e54454e54223b733a333a2275726c223b733a303a22223b733a343a2274797065223b693a303b733a31303a227065726d697373696f6e223b733a303a22223b7d693a313b613a343a7b733a353a227469746c65223b733a353a22494e444558223b733a333a2275726c223b733a393a22696e6465782e706870223b733a343a2274797065223b693a313b733a31303a227065726d697373696f6e223b733a303a22223b7d693a323b613a343a7b733a353a227469746c65223b733a363a22534541524348223b733a333a2275726c223b733a31303a227365617263682e706870223b733a343a2274797065223b693a313b733a31303a227065726d697373696f6e223b733a303a22223b7d693a333b613a343a7b733a353a227469746c65223b733a383a225245474953544552223b733a333a2275726c223b733a32313a227563702e7068703f6d6f64653d7265676973746572223b733a343a2274797065223b693a313b733a31303a227065726d697373696f6e223b733a313a2231223b7d693a343b613a343a7b733a353a227469746c65223b733a31303a224d454d4245524c495354223b733a333a2275726c223b733a31343a226d656d6265726c6973742e706870223b733a343a2274797065223b693a313b733a31303a227065726d697373696f6e223b733a333a22322c33223b7d693a353b613a343a7b733a353a227469746c65223b733a383a225448455f5445414d223b733a333a2275726c223b733a32373a226d656d6265726c6973742e7068703f6d6f64653d6c656164657273223b733a343a2274797065223b693a313b733a31303a227065726d697373696f6e223b733a333a22322c33223b7d693a363b613a343a7b733a353a227469746c65223b733a363a224d5f48454c50223b733a333a2275726c223b733a303a22223b733a343a2274797065223b693a303b733a31303a227065726d697373696f6e223b733a303a22223b7d693a373b613a343a7b733a353a227469746c65223b733a333a22464151223b733a333a2275726c223b733a373a226661712e706870223b733a343a2274797065223b693a313b733a31303a227065726d697373696f6e223b733a303a22223b7d693a383b613a343a7b733a353a227469746c65223b733a383a224d5f4242434f4445223b733a333a2275726c223b733a31393a226661712e7068703f6d6f64653d6262636f6465223b733a343a2274797065223b693a313b733a31303a227065726d697373696f6e223b733a303a22223b7d693a393b613a343a7b733a353a227469746c65223b733a373a224d5f5445524d53223b733a333a2275726c223b733a31383a227563702e7068703f6d6f64653d7465726d73223b733a343a2274797065223b693a313b733a31303a227065726d697373696f6e223b733a303a22223b7d693a31303b613a343a7b733a353a227469746c65223b733a353a224d5f505256223b733a333a2275726c223b733a32303a227563702e7068703f6d6f64653d70726976616379223b733a343a2274797065223b693a313b733a31303a227065726d697373696f6e223b733a303a22223b7d7d),
('board3_welcome_message_10', 0x57656c636f6d6520746f206d7920436f6d6d756e69747921);
CREATE TABLE IF NOT EXISTS `phpbb_portal_modules` (
`module_id` int(3) unsigned NOT NULL AUTO_INCREMENT,
`module_classname` varchar(64) COLLATE utf8_bin NOT NULL DEFAULT '',
`module_column` tinyint(3) NOT NULL DEFAULT '0',
`module_order` tinyint(3) NOT NULL DEFAULT '0',
`module_name` varchar(255) COLLATE utf8_bin NOT NULL DEFAULT '',
`module_image_src` varchar(255) COLLATE utf8_bin NOT NULL DEFAULT '',
`module_image_width` int(3) NOT NULL DEFAULT '0',
`module_image_height` int(3) NOT NULL DEFAULT '0',
`module_group_ids` varchar(255) COLLATE utf8_bin NOT NULL DEFAULT '',
`module_status` tinyint(1) NOT NULL DEFAULT '1',
PRIMARY KEY (`module_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCREMENT=22 ;
INSERT INTO `phpbb_portal_modules` (`module_id`, `module_classname`, `module_column`, `module_order`, `module_name`, `module_image_src`, `module_image_width`, `module_image_height`, `module_group_ids`, `module_status`) VALUES
(1, 'main_menu', 1, 1, 'M_MENU', 'portal_menu.png', 16, 16, '', 1),
(2, 'stylechanger', 1, 2, 'BOARD_STYLE', 'portal_style.png', 16, 16, '', 1),
(3, 'birthday_list', 1, 3, 'BIRTHDAYS', 'portal_birthday.png', 16, 16, '', 1),
(4, 'clock', 1, 5, 'CLOCK', 'portal_clock.png', 16, 16, '', 1),
(5, 'search', 1, 4, 'PORTAL_SEARCH', 'portal_search.png', 16, 16, '', 1),
(6, 'attachments', 1, 7, 'PORTAL_ATTACHMENTS', 'portal_attach.png', 16, 16, '', 1),
(7, 'topposters', 1, 8, 'TOPPOSTERS', 'portal_top_poster.png', 16, 16, '', 1),
(8, 'latest_members', 1, 9, 'LATEST_MEMBERS', 'portal_members.png', 16, 16, '', 1),
(10, 'welcome', 2, 1, 'PORTAL_WELCOME', '', 16, 16, '', 1),
(11, 'recent', 2, 2, 'PORTAL_RECENT', '', 16, 16, '', 1),
(12, 'announcements', 2, 3, 'GLOBAL_ANNOUNCEMENTS', '', 16, 16, '', 1),
(13, 'news', 2, 4, 'LATEST_NEWS', '', 0, 0, '', 1),
(14, 'poll', 2, 5, 'PORTAL_POLL', 'portal_poll.png', 16, 16, '', 1),
(15, 'whois_online', 2, 6, 'PORTAL_WHOIS_ONLINE', 'portal_friends.png', 16, 16, '', 1),
(16, 'user_menu', 3, 1, 'USER_MENU', 'portal_user.png', 16, 16, '', 1),
(17, 'statistics', 3, 2, 'STATISTICS', 'portal_statistics.png', 16, 16, '', 1),
(18, 'calendar', 3, 3, 'PORTAL_CALENDAR', 'portal_calendar.png', 16, 16, '', 1),
(19, 'leaders', 3, 4, 'THE_TEAM', 'portal_team.png', 16, 16, '', 1),
(20, 'latest_bots', 3, 5, 'LATEST_BOTS', 'portal_bots.png', 16, 16, '', 1),
(21, 'links', 3, 6, 'PORTAL_LINKS', 'portal_links.png', 16, 16, '', 1);
```
and:
```sql
CREATE TABLE IF NOT EXISTS `phpbb_config` (
`config_name` varchar(255) COLLATE utf8_bin NOT NULL DEFAULT '',
`config_value` varchar(255) COLLATE utf8_bin NOT NULL DEFAULT '',
`is_dynamic` tinyint(1) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`config_name`),
KEY `is_dynamic` (`is_dynamic`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
INSERT INTO `phpbb_config` (`config_name`, `config_value`, `is_dynamic`) VALUES
('board3_announcements_archive_12', '1', 0),
('board3_announcements_day_12', '0', 0),
('board3_announcements_forum_exclude_12', '0', 0),
('board3_announcements_length_12', '200', 0),
('board3_announcements_permissions_12', '1', 0),
('board3_announcements_style_12', '0', 0),
('board3_attach_max_length_6', '15', 0),
('board3_attachments_exclude_6', '0', 0),
('board3_attachments_filetype_6', '', 0),
('board3_attachments_forum_exclude_6', '0', 0),
('board3_attachments_forum_ids_6', '', 0),
('board3_attachments_number_6', '8', 0),
('board3_birthdays_ahead_3', '30', 0),
('board3_calendar_sunday_color_18', '#FF0000', 0),
('board3_calendar_today_color_18', '#000000', 0),
('board3_clock_src_4', 'board3clock.swf', 0),
('board3_display_events_18', '0', 0),
('board3_display_jumpbox', '1', 0),
('board3_enable', '1', 0),
('board3_events_18', '', 0),
('board3_events_url_new_window_18', '0', 0),
('board3_forum_index', '1', 0),
('board3_global_announcements_forum_12', '', 0),
('board3_last_visited_bots_number_20', '1', 0),
('board3_leaders_ext_19', '0', 0),
('board3_left_column', '1', 0),
('board3_left_column_width', '180', 0),
('board3_links_21', '', 0),
('board3_links_url_new_window_21', '0', 0),
('board3_long_month_18', '0', 0),
('board3_max_last_member_8', '8', 0),
('board3_max_topics_11', '10', 0),
('board3_menu_1', '', 0),
('board3_menu_url_new_window_1', '0', 0),
('board3_news_archive_13', '1', 0),
('board3_news_exclude_13', '0', 0),
('board3_news_forum_13', '', 0),
('board3_news_length_13', '250', 0),
('board3_news_permissions_13', '1', 0),
('board3_news_show_last_13', '0', 0),
('board3_news_style_13', '0', 0),
('board3_number_of_announcements_12', '1', 0),
('board3_number_of_news_13', '5', 0),
('board3_phpbb_menu', '0', 0),
('board3_poll_allow_vote_14', '1', 0),
('board3_poll_exclude_id_14', '0', 0),
('board3_poll_hide_14', '0', 0),
('board3_poll_limit_14', '3', 0),
('board3_poll_topic_id_14', '', 0),
('board3_portal_version', '2.0.1', 0),
('board3_recent_exclude_forums_11', '1', 0),
('board3_recent_forum_11', '', 0),
('board3_recent_title_limit_11', '100', 0),
('board3_right_column', '1', 0),
('board3_right_column_width', '180', 0),
('board3_show_all_news_13', '1', 0),
('board3_show_announcements_replies_views_12', '1', 0),
('board3_show_news_replies_views_13', '1', 0),
('board3_sunday_first_18', '1', 0),
('board3_topposters_7', '5', 0),
('board3_user_menu_register_16', '1', 0),
('board3_version_check', '1', 0),
('board3_welcome_message_10', '', 0),
('board3_welcome_message_bitfield_10', '', 0),
('board3_welcome_message_uid_10', '', 0);
```
and finally:
```sql
INSERT INTO `phpbb_acl_options` (`auth_option`, `is_global`, `is_local`, `founder_only`) VALUES
('u_view_portal', 1, 0, 0),
('a_manage_portal', 1, 0, 0);
```
##Support

8
root/config/routing.yml Normal file
View File

@@ -0,0 +1,8 @@
board3_controller:
pattern: /portal
defaults: { _controller: board3.portal.main:handle }
# This is currently not supported yet
board3_pages_controller:
pattern: /portal/{page}
defaults: { _controller: board3.portal.main:handle_page, page: "portal" }

11
root/config/services.yml Normal file
View File

@@ -0,0 +1,11 @@
services:
board3.portal.main:
class: phpbb_ext_board3_portal_controller_main
arguments:
- @auth
- @config
- @template
- @user
- %core.root_path%
- .%core.php_ext%

View File

@@ -1,182 +0,0 @@
<?php
class phpbb_ext_board3_portal_controller extends phpbb_extension_controller
{
// extension root path
private $root_path = '';
/**
* Extension front handler method. This is called automatically when your extension is accessed
* through index.php?ext=example/foobar
* @return null
*/
public function handle()
{
global $phpbb_root_path, $phpEx;
$this->root_path = $phpbb_root_path . '/ext/board3/portal/portal/';
$this->check_permission();
// We defined the phpBB objects in __construct() and can use them in the rest of our class like this
//echo 'Welcome, ' . $this->user->data['username'];
// The following takes two arguments:
// 1) which extension language folder we're using (it's not smart enough to use its own automatically)
// 2) what language file to use
$this->user->add_lang_ext('board3/portal', 'mods/portal');
//$this->template->set_ext_dir_prefix($phpbb_root_path . 'ext/board3/portal/');
$this->display_modules();
// foobar_body.html is in ./ext/foobar/example/styles/prosilver/template/foobar_body.html
$this->template->set_filenames(array(
'body' => 'portal/portal_body.html'
));
// And we assign template variables the same as before as well
$this->template->assign_var('MESSAGE', 'Yes, this is hard-coded language, which should still be avoided in virtually all cases.');
// And now to output the page.
page_header($this->user->lang('PORTAL'));
page_footer();
}
// check if user should be able to access this page
private function check_permission()
{
global $config, $auth, $phpbb_root_path, $phpEx;
if (!isset($config['board3_enable']) || !$config['board3_enable'] || !$auth->acl_get('u_view_portal'))
{
redirect(append_sid($phpbb_root_path . 'index.' . $phpEx));
}
}
/**
* Display the portal modules
*
* @return: true if page can be display, false if there are no modules to display
*/
private function display_modules()
{
global $template, $phpbb_root_path;
/**
* get initial data
*/
$portal_config = obtain_portal_config();
$portal_modules = obtain_portal_modules();
/**
* set up column_count array
* with this we can hide unneeded parts of the portal
*/
$module_count = array(
'total' => 0,
'top' => 0,
'left' => 0,
'center' => 0,
'right' => 0,
'bottom' => 0,
);
/**
* start assigning block vars
*/
foreach ($portal_modules as $row)
{
if($row['module_status'] == B3_MODULE_DISABLED)
{
continue;
}
$class_name = 'portal_' . $row['module_classname'] . '_module';
if (!class_exists($class_name))
{
include("{$this->root_path}modules/portal_{$row['module_classname']}.$phpEx");
}
if (!class_exists($class_name))
{
trigger_error(sprintf($user->lang['CLASS_NOT_FOUND'], $class_name, 'portal_' . $row['module_classname']), E_USER_ERROR);
}
$module = new $class_name();
/**
* Check for permissions before loading anything
* the default group of a user always defines his/her permission (KISS)
*/
$group_ary = (!empty($row['module_group_ids'])) ? explode(',', $row['module_group_ids']) : '';
if ((is_array($group_ary) && !in_array($user->data['group_id'], $group_ary)))
{
continue;
}
if ($module->language)
{
$user->add_lang_ext('board3/portal', 'mods/portal/' . $module->language);
}
if ($row['module_column'] == column_string_num('left') && $config['board3_left_column'])
{
$template_module = $module->get_template_side($row['module_id']);
$template_column = 'left';
++$module_count['left'];
}
if ($row['module_column'] == column_string_num('center'))
{
$template_module = $module->get_template_center($row['module_id']);
$template_column = 'center';
++$module_count['center'];
}
if ($row['module_column'] == column_string_num('right') && $config['board3_right_column'])
{
$template_module = $module->get_template_side($row['module_id']);
$template_column = 'right';
++$module_count['right'];
}
if ($row['module_column'] == column_string_num('top'))
{
$template_module = $module->get_template_center($row['module_id']);
++$module_count['top'];
}
if ($row['module_column'] == column_string_num('bottom'))
{
$template_module = $module->get_template_center($row['module_id']);
++$module_count['bottom'];
}
if (!isset($template_module))
{
continue;
}
// Custom Blocks that have been defined in the ACP will return an array instead of just the name of the template file
if (is_array($template_module))
{
$template->assign_block_vars('modules_' . column_num_string($row['module_column']), array(
'TEMPLATE_FILE' => 'portal/modules/' . $template_module['template'],
'IMAGE_SRC' => $this->root_path . 'styles/' . $user->theme['theme_path'] . '/theme/images/portal/' . $template_module['image_src'],
'TITLE' => $template_module['title'],
'CODE' => $template_module['code'],
'MODULE_ID' => $row['module_id'],
'IMAGE_WIDTH' => $row['module_image_width'],
'IMAGE_HEIGHT' => $row['module_image_height'],
));
}
else
{
$template->assign_block_vars('modules_' . column_num_string($row['module_column']), array(
'TEMPLATE_FILE' => 'portal/modules/' . $template_module,
'IMAGE_SRC' => $this->root_path . 'styles/' . $user->theme['theme_path'] . '/theme/images/portal/' . $row['module_image_src'],
'IMAGE_WIDTH' => $row['module_image_width'],
'IMAGE_HEIGHT' => $row['module_image_height'],
'MODULE_ID' => $row['module_id'],
'TITLE' => (isset($user->lang[$row['module_name']])) ? $user->lang[$row['module_name']] : utf8_normalize_nfc($row['module_name']),
));
}
unset($template_module);
}
return sizeof($portal_modules);
}
}

257
root/controller/main.php Normal file
View File

@@ -0,0 +1,257 @@
<?php
/**
*
* @package Board3 Portal 2.1
* @copyright (c) Board3 Group ( www.board3.de )
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
class phpbb_ext_board3_portal_controller_main
{
/**
* Auth object
* @var phpbb_auth
*/
private $auth;
/**
* phpBB Config object
* @var phpbb_config_db
*/
private $config;
/**
* Template object
* @var phpbb_template
*/
private $template;
/**
* User object
* @var phpbb_user
*/
private $user;
/**
* phpBB root path
* @var string
*/
private $phpbb_root_path;
/**
* PHP file extension
* @var string
*/
private $php_ext;
/**
* Portal root path
* @var string
*/
private $root_path;
/**
* Constructor
* NOTE: The parameters of this method must match in order and type with
* the dependencies defined in the services.yml file for this service.
* @param phpbb_auth $auth Auth object
* @param phpbb_config_db $config phpBB Config object
* @param phpbb_template $template Template object
* @param phpbb_user $user User object
* @param string $phpbb_root_path phpBB root path
* @param string $php_ext PHP file extension
*/
public function __construct($auth, $config, $template, $user, $phpbb_root_path, $php_ext)
{
global $portal_root_path;
$this->auth = $auth;
$this->config = $config;
$this->template = $template;
$this->user = $user;
$this->phpbb_root_path = $phpbb_root_path;
$this->php_ext = $php_ext;
$this->root_path = $phpbb_root_path . 'ext/board3/portal/portal/';
$portal_root_path = $this->root_path;
if (!function_exists('obtain_portal_config'))
{
include($this->root_path . 'includes/constants' . $this->php_ext);
include($this->root_path . 'includes/functions_modules' . $this->php_ext);
include($this->root_path . 'includes/functions' . $this->php_ext);
}
}
/**
* Extension front handler method. This is called automatically when your extension is accessed
* through index.php?ext=example/foobar
* @return null
*/
public function handle()
{
$this->check_permission();
// We defined the phpBB objects in __construct() and can use them in the rest of our class like this
//echo 'Welcome, ' . $this->user->data['username'];
// The following takes two arguments:
// 1) which extension language folder we're using (it's not smart enough to use its own automatically)
// 2) what language file to use
$this->user->add_lang_ext('board3/portal', 'mods/portal');
/**
* get initial data
*/
$portal_config = obtain_portal_config();
$portal_modules = obtain_portal_modules();
/**
* set up column_count array
* with this we can hide unneeded parts of the portal
*/
$module_count = array(
'total' => 0,
'top' => 0,
'left' => 0,
'center' => 0,
'right' => 0,
'bottom' => 0,
);
/**
* start assigning block vars
*/
foreach ($portal_modules as $row)
{
if($row['module_status'] == B3_MODULE_DISABLED)
{
continue;
}
$class_name = 'portal_' . $row['module_classname'] . '_module';
if (!class_exists($class_name))
{
include("{$this->root_path}modules/portal_{$row['module_classname']}{$this->php_ext}");
}
if (!class_exists($class_name))
{
trigger_error(sprintf($this->user->lang['CLASS_NOT_FOUND'], $class_name, 'portal_' . $row['module_classname']), E_USER_ERROR);
}
$module = new $class_name();
/**
* Check for permissions before loading anything
* the default group of a user always defines his/her permission (KISS)
*/
$group_ary = (!empty($row['module_group_ids'])) ? explode(',', $row['module_group_ids']) : '';
if ((is_array($group_ary) && !in_array($this->user->data['group_id'], $group_ary)))
{
continue;
}
if ($module->language)
{
$this->user->add_lang_ext('board3/portal', 'mods/portal/' . $module->language);
}
if ($row['module_column'] == column_string_num('left') && $this->config['board3_left_column'])
{
$template_module = $module->get_template_side($row['module_id']);
$template_column = 'left';
++$module_count['left'];
}
if ($row['module_column'] == column_string_num('center'))
{
$template_module = $module->get_template_center($row['module_id']);
$template_column = 'center';
++$module_count['center'];
}
if ($row['module_column'] == column_string_num('right') && $this->config['board3_right_column'])
{
$template_module = $module->get_template_side($row['module_id']);
$template_column = 'right';
++$module_count['right'];
}
if ($row['module_column'] == column_string_num('top'))
{
$template_module = $module->get_template_center($row['module_id']);
++$module_count['top'];
}
if ($row['module_column'] == column_string_num('bottom'))
{
$template_module = $module->get_template_center($row['module_id']);
++$module_count['bottom'];
}
if (!isset($template_module))
{
continue;
}
// Custom Blocks that have been defined in the ACP will return an array instead of just the name of the template file
if (is_array($template_module))
{
$this->template->assign_block_vars('modules_' . column_num_string($row['module_column']), array(
'TEMPLATE_FILE' => 'portal/modules/' . $template_module['template'],
'IMAGE_SRC' => $this->root_path . '../styles/' . $this->user->style['style_path'] . '/theme/images/portal/' . $template_module['image_src'],
'TITLE' => $template_module['title'],
'CODE' => $template_module['code'],
'MODULE_ID' => $row['module_id'],
'IMAGE_WIDTH' => $row['module_image_width'],
'IMAGE_HEIGHT' => $row['module_image_height'],
));
}
else
{
$this->template->assign_block_vars('modules_' . column_num_string($row['module_column']), array(
'TEMPLATE_FILE' => 'portal/modules/' . $template_module,
'IMAGE_SRC' => $this->root_path . '../styles/' . $this->user->style['style_path'] . '/theme/images/portal/' . $row['module_image_src'],
'IMAGE_WIDTH' => $row['module_image_width'],
'IMAGE_HEIGHT' => $row['module_image_height'],
'MODULE_ID' => $row['module_id'],
'TITLE' => (isset($this->user->lang[$row['module_name']])) ? $this->user->lang[$row['module_name']] : utf8_normalize_nfc($row['module_name']),
));
}
unset($template_module);
}
$module_count['total'] = sizeof($portal_modules);
// Redirect to index if there are currently no active modules
if($module_count['total'] < 1)
{
redirect(append_sid($this->phpbb_root_path . 'index.' . $phpEx));
}
// Assign specific vars
$this->template->assign_vars(array(
// 'S_SMALL_BLOCK' => true,
'S_PORTAL_LEFT_COLUMN' => $this->config['board3_left_column_width'],
'S_PORTAL_RIGHT_COLUMN' => $this->config['board3_right_column_width'],
'S_LEFT_COLUMN' => ($module_count['left'] > 0 && $this->config['board3_left_column']) ? true : false,
'S_CENTER_COLUMN' => ($module_count['center'] > 0) ? true : false,
'S_RIGHT_COLUMN' => ($module_count['right'] > 0 && $this->config['board3_right_column']) ? true : false,
'S_TOP_COLUMN' => ($module_count['top'] > 0) ? true : false,
'S_BOTTOM_COLUMN' => ($module_count['bottom'] > 0) ? true : false,
'S_DISPLAY_PHPBB_MENU' => $this->config['board3_phpbb_menu'],
'B3P_DISPLAY_JUMPBOX' => $this->config['board3_display_jumpbox'],
));
// And now to output the page.
page_header($this->user->lang('PORTAL'));
// foobar_body.html is in ./ext/foobar/example/styles/prosilver/template/foobar_body.html
$this->template->set_filenames(array(
'body' => 'portal/portal_body.html'
));
page_footer();
}
// check if user should be able to access this page
private function check_permission()
{
if (!isset($this->config['board3_enable']) || !$this->config['board3_enable'] || !$this->auth->acl_get('u_view_portal'))
{
redirect(append_sid($this->phpbb_root_path . 'index' . $this->php_ext));
}
}
}

View File

@@ -404,16 +404,16 @@ function character_limit(&$title, $limit = 0)
*/
function get_sub_taged_string($message, $bbcode_uid, $length)
{
global $phpbb_root_path, $phpEx;
global $portal_root_path, $phpEx;
if(!class_exists('phpbb_trim_message'))
{
include($phpbb_root_path . 'includes/trim_message/trim_message.' . $phpEx);
include($portal_root_path . '../includes/trim_message/trim_message.' . $phpEx);
}
if(!class_exists('phpbb_trim_message_bbcodes'))
{
include($phpbb_root_path . 'includes/trim_message/bbcodes.' . $phpEx);
include($portal_root_path . '../includes/trim_message/bbcodes.' . $phpEx);
}
$object = new phpbb_trim_message($message, $bbcode_uid, $length);

View File

@@ -53,14 +53,16 @@ class portal_birthday_list_module
// Generate birthday list if required ... / borrowed from index.php 3.0.6
$birthday_list = $birthday_ahead_list = '';
if ($config['load_birthdays'] && $config['allow_birthdays'])
{
$now = getdate(time() + $user->timezone + $user->dst - date('Z'));
$time = $user->create_datetime();
$now = phpbb_gmgetdate($time->getTimestamp() + $time->getOffset());
$cache_days = $config['board3_birthdays_ahead_' . $module_id];
$sql_days = '';
while ($cache_days > 0)
{
$day = getdate(time() + 86400 * $cache_days + $user->timezone + $user->dst - date('Z'));
$day = phpbb_gmgetdate($time->getTimestamp() + 86400 * $cache_days + $time->getOffset());
$sql_days .= " OR u.user_birthday LIKE '" . $db->sql_escape(sprintf('%2d-%2d-', $day['mday'], $day['mon'])) . "%'";
$cache_days--;
}
@@ -76,7 +78,7 @@ class portal_birthday_list_module
$order_by = 'SUBSTRING(u.user_birthday FROM 4 FOR 2) ASC, SUBSTRING(u.user_birthday FROM 1 FOR 2) ASC, u.username_clean ASC';
break;
}
$now = getdate(time() + $user->timezone + $user->dst - date('Z'));
$sql = 'SELECT u.user_id, u.username, u.user_colour, u.user_birthday
FROM ' . USERS_TABLE . ' u
LEFT JOIN ' . BANLIST_TABLE . " b ON (u.user_id = b.ban_userid)

View File

@@ -89,8 +89,11 @@ class portal_calendar_module
}
// initialise some variables
$today_timestamp = time() + $user->timezone + $user->dst;
$mini_cal_today = date('Ymd', time() + $user->timezone + $user->dst - date('Z'));
$time = $user->create_datetime();
$now = phpbb_gmgetdate($time->getTimestamp() + $time->getOffset());
$today_timestamp = $now[0];
$mini_cal_today = date('Ymd', $today_timestamp - date('Z'));
$this->stamp = $today_timestamp;
$s_cal_month = ($this->mini_cal_month != 0) ? $this->mini_cal_month . ' month' : $mini_cal_today;
$this->getMonth($s_cal_month);
$mini_cal_count = $this->mini_cal_fdow;
@@ -102,8 +105,8 @@ class portal_calendar_module
// output our general calendar bits
$down = $this->mini_cal_month - 1;
$up = $this->mini_cal_month + 1;
$prev_month = '<a href="' . append_sid("{$phpbb_root_path}portal.$phpEx", "m$module_id=$down#minical$module_id") . '"><img src="' . $phpbb_root_path . 'styles/' . $user->theme['theme_path'] . '/theme/images/portal/cal_icon_left_arrow.png' . '" title="' . $user->lang['VIEW_PREVIOUS_MONTH'] . '" height="16" width="16" alt="&lt;&lt;" /></a>';
$next_month = '<a href="' . append_sid("{$phpbb_root_path}portal.$phpEx", "m$module_id=$up#minical$module_id") . '"><img src="' . $phpbb_root_path . 'styles/' . $user->theme['theme_path'] . '/theme/images/portal/cal_icon_right_arrow.png' . '" title="' . $user->lang['VIEW_NEXT_MONTH'] . '" height="16" width="16" alt="&gt;&gt;" /></a>';
$prev_month = '<a href="' . append_sid("{$phpbb_root_path}portal.$phpEx", "m$module_id=$down#minical$module_id") . '"><img src="' . $phpbb_root_path . 'styles/' . $user->style['style_path'] . '/theme/images/portal/cal_icon_left_arrow.png' . '" title="' . $user->lang['VIEW_PREVIOUS_MONTH'] . '" height="16" width="16" alt="&lt;&lt;" /></a>';
$next_month = '<a href="' . append_sid("{$phpbb_root_path}portal.$phpEx", "m$module_id=$up#minical$module_id") . '"><img src="' . $phpbb_root_path . 'styles/' . $user->style['style_path'] . '/theme/images/portal/cal_icon_right_arrow.png' . '" title="' . $user->lang['VIEW_NEXT_MONTH'] . '" height="16" width="16" alt="&gt;&gt;" /></a>';
$template->assign_block_vars('minical', array(
'S_SUNDAY_FIRST' => ($config['board3_sunday_first_' . $module_id]) ? true : false,
@@ -576,7 +579,7 @@ class portal_calendar_module
{
global $user;
$this->stamp = strtotime($date) + $user->timezone + $user->dst;
$this->stamp = (empty($this->stamp)) ? strtotime($date) + $user->timezone + $user->dst : $this->stamp;
return ($this->stamp);
}

View File

@@ -207,6 +207,8 @@ class portal_news_module
// Grab icons
$icons = $cache->obtain_icons();
phpbb_generate_template_pagination($template, $view_topic_url, 'pagination', 'np', $fetch_news[$i]['topic_replies'], $config['board3_number_of_news_' . $module_id], $start);
$template->assign_block_vars('news_row', array(
'ATTACH_ICON_IMG' => ($fetch_news[$i]['attachment'] && $config['allow_attachments']) ? $user->img('icon_topic_attach', $user->lang['TOTAL_ATTACHMENTS']) : '',
'FORUM_NAME' => ($forum_id) ? $fetch_news[$i]['forum_name'] : '',
@@ -240,7 +242,6 @@ class portal_news_module
'S_NOT_LAST' => ($i < sizeof($fetch_news) - 1) ? true : false,
'S_POLL' => $fetch_news[$i]['poll'],
'S_UNREAD_INFO' => $unread_topic,
'PAGINATION' => topic_generate_pagination($fetch_news[$i]['topic_replies'], $view_topic_url),
'S_HAS_ATTACHMENTS' => (!empty($fetch_news[$i]['attachments'])) ? true : false,
));
@@ -258,8 +259,8 @@ class portal_news_module
{
$template->assign_vars(array(
'NP_PAGINATION' => $pagination,
'TOTAL_NEWS' => ($total_news == 1) ? $user->lang['VIEW_FORUM_TOPIC'] : sprintf($user->lang['VIEW_FORUM_TOPICS'], $total_news),
'NP_PAGE_NUMBER' => on_page($total_news, $config['board3_number_of_news_' . $module_id], $start))
'TOTAL_NEWS' => ($total_news == 1) ? sprintf($user->lang['VIEW_FORUM_TOPICS'][1], $total_news) : sprintf($user->lang['VIEW_FORUM_TOPICS'][2], $total_news),
'NP_PAGE_NUMBER' => phpbb_on_page($template, $user, $view_topic_url, $total_news, $config['board3_number_of_news_' . $module_id], $start))
);
}
}

View File

@@ -63,9 +63,9 @@ class portal_statistics_module
$total_users = $config['num_users'];
$total_files = $config['num_files'];
$l_total_user_s = ($total_users == 0) ? 'TOTAL_USERS_ZERO' : 'TOTAL_USERS_OTHER';
$l_total_post_s = ($total_posts == 0) ? 'TOTAL_POSTS_ZERO' : 'TOTAL_POSTS_OTHER';
$l_total_topic_s = ($total_topics == 0) ? 'TOTAL_TOPICS_ZERO' : 'TOTAL_TOPICS_OTHER';
$l_total_user_s = ($total_users == 0) ? sprintf($user->lang['TOTAL_USERS_ZERO'], $total_users) : sprintf($user->lang['TOTAL_USERS'][2], $total_users);
$l_total_post_s = ($total_posts == 0) ? sprintf($user->lang['TOTAL_POSTS_ZERO'], $total_posts) : sprintf($user->lang['TOTAL_POSTS_COUNT'][2], $total_posts);
$l_total_topic_s = ($total_topics == 0) ? sprintf($user->lang['TOTAL_TOPICS_ZERO'], $total_topics) : sprintf($user->lang['TOTAL_TOPICS'][2], $total_topics);
// avarage stat
$board_days = (time() - $config['board_startdate']) / 86400;
@@ -116,12 +116,11 @@ class portal_statistics_module
$topics_count = $this->get_topics_count();
// Assign specific vars
$template->assign_vars(array(
'B3_TOTAL_POSTS' => sprintf($user->lang[$l_total_post_s], $total_posts),
'B3_TOTAL_TOPICS' => sprintf($user->lang[$l_total_topic_s], $total_topics),
'B3_TOTAL_USERS' => sprintf($user->lang[$l_total_user_s], $total_users),
'B3_TOTAL_POSTS' => $l_total_post_s,
'B3_TOTAL_TOPICS' => $l_total_topic_s,
'B3_TOTAL_USERS' => $l_total_user_s,
'B3_NEWEST_USER' => sprintf($user->lang['NEWEST_USER'], get_username_string('full', $config['newest_user_id'], $config['newest_username'], $config['newest_user_colour'])),
'B3_ANNOUNCE_COUNT' => $topics_count[POST_ANNOUNCE],
'B3_STICKY_COUNT' => $topics_count[POST_STICKY],

View File

@@ -70,7 +70,7 @@ class portal_stylechanger_module
$url = append_sid("{$phpbb_root_path}portal.$phpEx", 'style=' . $row['style_id']);
}
++$style_count;
$style_select .= '<option value="' . $url . '"' . ($row['style_id'] == $user->theme['style_id'] ? ' selected="selected"' : '') . '>' . htmlspecialchars($row['style_name']) . '</option>';
$style_select .= '<option value="' . $url . '"' . ($row['style_id'] == $user->style['style_id'] ? ' selected="selected"' : '') . '>' . htmlspecialchars($row['style_name']) . '</option>';
}
$db->sql_freeresult($result);
if(strlen($style_select))

View File

@@ -51,7 +51,7 @@ class portal_user_menu_module
{
global $config, $template, $user, $auth, $db, $phpEx, $phpbb_root_path;
if (!function_exists('display_forums'))
if (!function_exists('get_user_avatar'))
{
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
}