[feature/controller] Fix missing issues that prevented portal from working

The portal still requires the fix to PHPBB3-11323 in order to work.

B3P-114
This commit is contained in:
Marc Alexander
2013-02-25 11:41:57 +01:00
parent edf7541001
commit b755201897
8 changed files with 75 additions and 62 deletions

View File

@@ -64,13 +64,16 @@ class phpbb_ext_board3_portal_controller_main
*/
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/';
$this->root_path = $phpbb_root_path . 'ext/board3/portal/portal/';
$portal_root_path = $this->root_path;
if (!function_exists('obtain_portal_config'))
{
@@ -86,7 +89,7 @@ class phpbb_ext_board3_portal_controller_main
* @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'];
@@ -96,39 +99,6 @@ class phpbb_ext_board3_portal_controller_main
// 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()
{
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));
}
}
/**
* Display the portal modules
*
* @return: true if page can be display, false if there are no modules to display
*/
private function display_modules()
{
/**
* get initial data
*/
@@ -222,7 +192,7 @@ class phpbb_ext_board3_portal_controller_main
{
$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->theme['theme_path'] . '/theme/images/portal/' . $template_module['image_src'],
'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'],
@@ -234,7 +204,7 @@ class phpbb_ext_board3_portal_controller_main
{
$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->theme['theme_path'] . '/theme/images/portal/' . $row['module_image_src'],
'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'],
@@ -243,7 +213,45 @@ class phpbb_ext_board3_portal_controller_main
}
unset($template_module);
}
return sizeof($portal_modules);
$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);
}