mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 06:08:52 +00:00
- added users activity load setting
git-svn-id: file:///svn/phpbb/trunk@5624 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
parent
939b9c28ba
commit
d85c4e73ed
8 changed files with 191 additions and 210 deletions
|
@ -156,15 +156,16 @@ class acp_board
|
||||||
'active_sessions' => array('lang' => 'LIMIT_SESSIONS', 'type' => 'text:4:4', 'explain' => true),
|
'active_sessions' => array('lang' => 'LIMIT_SESSIONS', 'type' => 'text:4:4', 'explain' => true),
|
||||||
'load_online_time' => array('lang' => 'ONLINE_LENGTH', 'type' => 'text:4:3', 'explain' => true),
|
'load_online_time' => array('lang' => 'ONLINE_LENGTH', 'type' => 'text:4:3', 'explain' => true),
|
||||||
|
|
||||||
'legend2' => 'GENERAL_OPTIONS',
|
'legend2' => 'GENERAL_OPTIONS',
|
||||||
'load_db_track' => array('lang' => 'YES_POST_MARKING', 'type' => 'radio:yes_no', 'explain' => true),
|
'load_db_track' => array('lang' => 'YES_POST_MARKING', 'type' => 'radio:yes_no', 'explain' => true),
|
||||||
'load_db_lastread' => array('lang' => 'YES_READ_MARKING', 'type' => 'radio:yes_no', 'explain' => true),
|
'load_db_lastread' => array('lang' => 'YES_READ_MARKING', 'type' => 'radio:yes_no', 'explain' => true),
|
||||||
'load_online' => array('lang' => 'YES_ONLINE', 'type' => 'radio:yes_no', 'explain' => true),
|
'load_online' => array('lang' => 'YES_ONLINE', 'type' => 'radio:yes_no', 'explain' => true),
|
||||||
'load_onlinetrack' => array('lang' => 'YES_ONLINE_TRACK', 'type' => 'radio:yes_no', 'explain' => true),
|
'load_onlinetrack' => array('lang' => 'YES_ONLINE_TRACK', 'type' => 'radio:yes_no', 'explain' => true),
|
||||||
'load_birthdays' => array('lang' => 'YES_BIRTHDAYS', 'type' => 'radio:yes_no', 'explain' => false),
|
'load_birthdays' => array('lang' => 'YES_BIRTHDAYS', 'type' => 'radio:yes_no', 'explain' => false),
|
||||||
'load_moderators' => array('lang' => 'YES_MODERATORS', 'type' => 'radio:yes_no', 'explain' => false),
|
'load_moderators' => array('lang' => 'YES_MODERATORS', 'type' => 'radio:yes_no', 'explain' => false),
|
||||||
'load_jumpbox' => array('lang' => 'YES_JUMPBOX', 'type' => 'radio:yes_no', 'explain' => false),
|
'load_jumpbox' => array('lang' => 'YES_JUMPBOX', 'type' => 'radio:yes_no', 'explain' => false),
|
||||||
'load_tplcompile' => array('lang' => 'RECOMPILE_TEMPLATES', 'type' => 'radio:yes_no', 'explain' => true),
|
'load_user_activity' => array('lang' => 'LOAD_USER_ACTIVITY','type' => 'radio:yes_no', 'explain' => true),
|
||||||
|
'load_tplcompile' => array('lang' => 'RECOMPILE_TEMPLATES', 'type' => 'radio:yes_no', 'explain' => true),
|
||||||
|
|
||||||
'legend3' => 'SEARCH_SETTINGS',
|
'legend3' => 'SEARCH_SETTINGS',
|
||||||
'load_search' => array('lang' => 'YES_SEARCH', 'type' => 'radio:yes_no', 'explain' => true),
|
'load_search' => array('lang' => 'YES_SEARCH', 'type' => 'radio:yes_no', 'explain' => true),
|
||||||
|
|
|
@ -1153,9 +1153,11 @@ function redirect($url)
|
||||||
$url = generate_board_url() . '/' . $url;
|
$url = generate_board_url() . '/' . $url;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
// Make sure no linebreaks are there... to prevent http response splitting for PHP < 4.4.2
|
||||||
* Make sure no HTTP Response Splitting attacks are possible
|
if (strpos(urldecode($url), "\n") !== false || strpos(urldecode($url), "\r") !== false)
|
||||||
*/
|
{
|
||||||
|
trigger_error('Tried to redirect to potentially insecure url.', E_USER_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
// Redirect via an HTML form for PITA webservers
|
// Redirect via an HTML form for PITA webservers
|
||||||
if (@preg_match('#Microsoft|WebSTAR|Xitami#', getenv('SERVER_SOFTWARE')))
|
if (@preg_match('#Microsoft|WebSTAR|Xitami#', getenv('SERVER_SOFTWARE')))
|
||||||
|
|
|
@ -136,92 +136,15 @@ class ucp_main
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$post_count_ary = $auth->acl_getf('!f_postcount');
|
if ($config['load_user_activity'])
|
||||||
$forum_read_ary = $auth->acl_getf('!f_read');
|
|
||||||
|
|
||||||
$forum_ary = array();
|
|
||||||
foreach ($post_count_ary as $forum_id => $allowed)
|
|
||||||
{
|
{
|
||||||
if ($allowed['f_postcount'] || $forum_read_ary[$forum_id]['f_read'])
|
$this->show_user_activity();
|
||||||
{
|
|
||||||
$forum_ary[] = $forum_id;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$post_count_sql = (sizeof($forum_ary)) ? 'AND f.forum_id NOT IN (' . implode(', ', $forum_ary) . ')' : '';
|
|
||||||
unset($forum_ary, $post_count_ary, $forum_read_ary);
|
|
||||||
|
|
||||||
if ($post_count_sql)
|
|
||||||
{
|
|
||||||
// NOTE: The following three queries could be a problem for big boards
|
|
||||||
|
|
||||||
// Grab all the relevant data
|
|
||||||
$sql = 'SELECT COUNT(p.post_id) AS num_posts
|
|
||||||
FROM ' . POSTS_TABLE . ' p, ' . FORUMS_TABLE . ' f
|
|
||||||
WHERE p.poster_id = ' . $user->data['user_id'] . "
|
|
||||||
AND f.forum_id = p.forum_id
|
|
||||||
$post_count_sql";
|
|
||||||
$result = $db->sql_query($sql);
|
|
||||||
|
|
||||||
$num_real_posts = min($user->data['user_posts'], $db->sql_fetchfield('num_posts', 0, $result));
|
|
||||||
$db->sql_freeresult($result);
|
|
||||||
|
|
||||||
$sql = 'SELECT f.forum_id, f.forum_name, COUNT(post_id) AS num_posts
|
|
||||||
FROM ' . POSTS_TABLE . ' p, ' . FORUMS_TABLE . ' f
|
|
||||||
WHERE p.poster_id = ' . $user->data['user_id'] . "
|
|
||||||
AND f.forum_id = p.forum_id
|
|
||||||
$post_count_sql
|
|
||||||
GROUP BY f.forum_id, f.forum_name
|
|
||||||
ORDER BY num_posts DESC";
|
|
||||||
$result = $db->sql_query_limit($sql, 1);
|
|
||||||
|
|
||||||
$active_f_row = $db->sql_fetchrow($result);
|
|
||||||
$db->sql_freeresult($result);
|
|
||||||
|
|
||||||
$sql = 'SELECT t.topic_id, t.topic_title, COUNT(p.post_id) AS num_posts
|
|
||||||
FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t, ' . FORUMS_TABLE . ' f
|
|
||||||
WHERE p.poster_id = ' . $user->data['user_id'] . "
|
|
||||||
AND t.topic_id = p.topic_id
|
|
||||||
AND f.forum_id = t.forum_id
|
|
||||||
$post_count_sql
|
|
||||||
GROUP BY t.topic_id, t.topic_title
|
|
||||||
ORDER BY num_posts DESC";
|
|
||||||
$result = $db->sql_query_limit($sql, 1);
|
|
||||||
|
|
||||||
$active_t_row = $db->sql_fetchrow($result);
|
|
||||||
$db->sql_freeresult($result);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$num_real_posts = 0;
|
|
||||||
$active_f_row = $active_t_row = array();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Do the relevant calculations
|
// Do the relevant calculations
|
||||||
$memberdays = max(1, round((time() - $user->data['user_regdate']) / 86400));
|
$memberdays = max(1, round((time() - $user->data['user_regdate']) / 86400));
|
||||||
$posts_per_day = $user->data['user_posts'] / $memberdays;
|
$posts_per_day = $user->data['user_posts'] / $memberdays;
|
||||||
$percentage = ($config['num_posts']) ? min(100, ($num_real_posts / $config['num_posts']) * 100) : 0;
|
$percentage = ($config['num_posts']) ? min(100, ($user->data['user_posts'] / $config['num_posts']) * 100) : 0;
|
||||||
|
|
||||||
$active_f_name = $active_f_id = $active_f_count = $active_f_pct = '';
|
|
||||||
if (!empty($active_f_row['num_posts']))
|
|
||||||
{
|
|
||||||
$active_f_name = $active_f_row['forum_name'];
|
|
||||||
$active_f_id = $active_f_row['forum_id'];
|
|
||||||
$active_f_count = $active_f_row['num_posts'];
|
|
||||||
$active_f_pct = ($user->data['user_posts']) ? ($active_f_count / $user->data['user_posts']) * 100 : 0;
|
|
||||||
}
|
|
||||||
unset($active_f_row);
|
|
||||||
|
|
||||||
$active_t_name = $active_t_id = $active_t_count = $active_t_pct = '';
|
|
||||||
if (!empty($active_t_row['num_posts']))
|
|
||||||
{
|
|
||||||
$active_t_name = $active_t_row['topic_title'];
|
|
||||||
$active_t_id = $active_t_row['topic_id'];
|
|
||||||
$active_t_count = $active_t_row['num_posts'];
|
|
||||||
$active_t_pct = ($user->data['user_posts']) ? ($active_t_count / $user->data['user_posts']) * 100 : 0;
|
|
||||||
}
|
|
||||||
unset($active_t_row);
|
|
||||||
|
|
||||||
|
|
||||||
$template->assign_vars(array(
|
$template->assign_vars(array(
|
||||||
'USER_COLOR' => (!empty($user->data['user_colour'])) ? $user->data['user_colour'] : '',
|
'USER_COLOR' => (!empty($user->data['user_colour'])) ? $user->data['user_colour'] : '',
|
||||||
|
@ -231,21 +154,15 @@ class ucp_main
|
||||||
'POSTS' => ($user->data['user_posts']) ? $user->data['user_posts'] : 0,
|
'POSTS' => ($user->data['user_posts']) ? $user->data['user_posts'] : 0,
|
||||||
'POSTS_DAY' => sprintf($user->lang['POST_DAY'], $posts_per_day),
|
'POSTS_DAY' => sprintf($user->lang['POST_DAY'], $posts_per_day),
|
||||||
'POSTS_PCT' => sprintf($user->lang['POST_PCT'], $percentage),
|
'POSTS_PCT' => sprintf($user->lang['POST_PCT'], $percentage),
|
||||||
'ACTIVE_FORUM' => $active_f_name,
|
|
||||||
'ACTIVE_FORUM_POSTS'=> ($active_f_count == 1) ? sprintf($user->lang['USER_POST'], 1) : sprintf($user->lang['USER_POSTS'], $active_f_count),
|
|
||||||
'ACTIVE_FORUM_PCT' => sprintf($user->lang['POST_PCT'], $active_f_pct),
|
|
||||||
'ACTIVE_TOPIC' => $active_t_name,
|
|
||||||
'ACTIVE_TOPIC_POSTS'=> ($active_t_count == 1) ? sprintf($user->lang['USER_POST'], 1) : sprintf($user->lang['USER_POSTS'], $active_t_count),
|
|
||||||
'ACTIVE_TOPIC_PCT' => sprintf($user->lang['POST_PCT'], $active_t_pct),
|
|
||||||
|
|
||||||
'OCCUPATION' => (!empty($row['user_occ'])) ? $row['user_occ'] : '',
|
'OCCUPATION' => (!empty($row['user_occ'])) ? $row['user_occ'] : '',
|
||||||
'INTERESTS' => (!empty($row['user_interests'])) ? $row['user_interests'] : '',
|
'INTERESTS' => (!empty($row['user_interests'])) ? $row['user_interests'] : '',
|
||||||
|
|
||||||
// 'S_GROUP_OPTIONS' => $group_options,
|
// 'S_GROUP_OPTIONS' => $group_options,
|
||||||
|
'S_SHOW_ACTIVITY' => ($config['load_user_activity']) ? true : false,
|
||||||
|
|
||||||
'U_SEARCH_USER' => ($auth->acl_get('u_search')) ? "{$phpbb_root_path}search.$phpEx$SID&search_author=" . urlencode($user->data['username']) . "&show_results=posts" : '',
|
'U_SEARCH_USER' => ($auth->acl_get('u_search')) ? "{$phpbb_root_path}search.$phpEx$SID&search_author=" . urlencode($user->data['username']) . "&show_results=posts" : '',
|
||||||
'U_ACTIVE_FORUM' => "{$phpbb_root_path}viewforum.$phpEx$SID&f=$active_f_id",
|
)
|
||||||
'U_ACTIVE_TOPIC' => "{$phpbb_root_path}viewtopic.$phpEx$SID&t=$active_t_id",)
|
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -824,6 +741,82 @@ class ucp_main
|
||||||
// Set desired template
|
// Set desired template
|
||||||
$this->tpl_name = 'ucp_main_' . $mode;
|
$this->tpl_name = 'ucp_main_' . $mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function show_user_activity()
|
||||||
|
{
|
||||||
|
global $auth, $template, $db, $user;
|
||||||
|
global $phpbb_root_path, $SID, $phpEx;
|
||||||
|
|
||||||
|
$post_count_ary = $auth->acl_getf('!f_postcount');
|
||||||
|
$forum_read_ary = $auth->acl_getf('!f_read');
|
||||||
|
|
||||||
|
$forum_ary = array();
|
||||||
|
foreach ($post_count_ary as $forum_id => $allowed)
|
||||||
|
{
|
||||||
|
if ($allowed['f_postcount'] || $forum_read_ary[$forum_id]['f_read'])
|
||||||
|
{
|
||||||
|
$forum_ary[] = $forum_id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$post_count_sql = (sizeof($forum_ary)) ? 'AND f.forum_id NOT IN (' . implode(', ', $forum_ary) . ')' : '';
|
||||||
|
|
||||||
|
if ($post_count_sql)
|
||||||
|
{
|
||||||
|
$sql = 'SELECT f.forum_id, f.forum_name, COUNT(post_id) AS num_posts
|
||||||
|
FROM ' . POSTS_TABLE . ' p, ' . FORUMS_TABLE . ' f
|
||||||
|
WHERE p.poster_id = ' . $user->data['user_id'] . "
|
||||||
|
AND f.forum_id = p.forum_id
|
||||||
|
$post_count_sql
|
||||||
|
GROUP BY f.forum_id, f.forum_name
|
||||||
|
ORDER BY num_posts DESC";
|
||||||
|
$result = $db->sql_query_limit($sql, 1);
|
||||||
|
$active_f_row = $db->sql_fetchrow($result);
|
||||||
|
$db->sql_freeresult($result);
|
||||||
|
|
||||||
|
$sql = 'SELECT t.topic_id, t.topic_title, COUNT(p.post_id) AS num_posts
|
||||||
|
FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t, ' . FORUMS_TABLE . ' f
|
||||||
|
WHERE p.poster_id = ' . $user->data['user_id'] . "
|
||||||
|
AND t.topic_id = p.topic_id
|
||||||
|
AND f.forum_id = t.forum_id
|
||||||
|
$post_count_sql
|
||||||
|
GROUP BY t.topic_id, t.topic_title
|
||||||
|
ORDER BY num_posts DESC";
|
||||||
|
$result = $db->sql_query_limit($sql, 1);
|
||||||
|
$active_t_row = $db->sql_fetchrow($result);
|
||||||
|
$db->sql_freeresult($result);
|
||||||
|
}
|
||||||
|
|
||||||
|
$active_f_name = $active_f_id = $active_f_count = $active_f_pct = '';
|
||||||
|
if (!empty($active_f_row['num_posts']))
|
||||||
|
{
|
||||||
|
$active_f_name = $active_f_row['forum_name'];
|
||||||
|
$active_f_id = $active_f_row['forum_id'];
|
||||||
|
$active_f_count = $active_f_row['num_posts'];
|
||||||
|
$active_f_pct = ($user->data['user_posts']) ? ($active_f_count / $user->data['user_posts']) * 100 : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
$active_t_name = $active_t_id = $active_t_count = $active_t_pct = '';
|
||||||
|
if (!empty($active_t_row['num_posts']))
|
||||||
|
{
|
||||||
|
$active_t_name = $active_t_row['topic_title'];
|
||||||
|
$active_t_id = $active_t_row['topic_id'];
|
||||||
|
$active_t_count = $active_t_row['num_posts'];
|
||||||
|
$active_t_pct = ($user->data['user_posts']) ? ($active_t_count / $user->data['user_posts']) * 100 : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
$template->assign_vars(array(
|
||||||
|
'ACTIVE_FORUM' => $active_f_name,
|
||||||
|
'ACTIVE_FORUM_POSTS' => ($active_f_count == 1) ? sprintf($user->lang['USER_POST'], 1) : sprintf($user->lang['USER_POSTS'], $active_f_count),
|
||||||
|
'ACTIVE_FORUM_PCT' => sprintf($user->lang['POST_PCT'], $active_f_pct),
|
||||||
|
'ACTIVE_TOPIC' => censor_text($active_t_name),
|
||||||
|
'ACTIVE_TOPIC_POSTS' => ($active_t_count == 1) ? sprintf($user->lang['USER_POST'], 1) : sprintf($user->lang['USER_POSTS'], $active_t_count),
|
||||||
|
'ACTIVE_TOPIC_PCT' => sprintf($user->lang['POST_PCT'], $active_t_pct),
|
||||||
|
'U_ACTIVE_FORUM' => "{$phpbb_root_path}viewforum.$phpEx$SID&f=$active_f_id",
|
||||||
|
'U_ACTIVE_TOPIC' => "{$phpbb_root_path}viewtopic.$phpEx$SID&t=$active_t_id")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -122,6 +122,7 @@ INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_online_time',
|
||||||
INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_search', '1');
|
INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_search', '1');
|
||||||
INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_search_upd', '1');
|
INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_search_upd', '1');
|
||||||
INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_tplcompile', '0');
|
INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_tplcompile', '0');
|
||||||
|
INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_user_activity', '1');
|
||||||
INSERT INTO phpbb_config (config_name, config_value) VALUES ('max_attachments', '3');
|
INSERT INTO phpbb_config (config_name, config_value) VALUES ('max_attachments', '3');
|
||||||
INSERT INTO phpbb_config (config_name, config_value) VALUES ('max_attachments_pm', '1');
|
INSERT INTO phpbb_config (config_name, config_value) VALUES ('max_attachments_pm', '1');
|
||||||
INSERT INTO phpbb_config (config_name, config_value) VALUES ('max_autologin_time','0');
|
INSERT INTO phpbb_config (config_name, config_value) VALUES ('max_autologin_time','0');
|
||||||
|
|
|
@ -122,8 +122,6 @@ $lang = array_merge($lang, array(
|
||||||
'PATH_SETTINGS' => 'Path Settings',
|
'PATH_SETTINGS' => 'Path Settings',
|
||||||
'SERVER_NAME' => 'Domain Name',
|
'SERVER_NAME' => 'Domain Name',
|
||||||
'SERVER_NAME_EXPLAIN' => 'The domain name this board runs from (for example: www.foo.bar)',
|
'SERVER_NAME_EXPLAIN' => 'The domain name this board runs from (for example: www.foo.bar)',
|
||||||
// 'SCRIPT_PATH' => 'Script path',
|
|
||||||
// 'SCRIPT_PATH_EXPLAIN' => 'The path where phpBB2 is located relative to the domain name',
|
|
||||||
'SERVER_PORT' => 'Server Port',
|
'SERVER_PORT' => 'Server Port',
|
||||||
'SERVER_PORT_EXPLAIN' => 'The port your server is running on, usually 80, only change if different',
|
'SERVER_PORT_EXPLAIN' => 'The port your server is running on, usually 80, only change if different',
|
||||||
'SERVER_PROTOCOL' => 'Server Protocol',
|
'SERVER_PROTOCOL' => 'Server Protocol',
|
||||||
|
@ -187,7 +185,9 @@ $lang = array_merge($lang, array(
|
||||||
'MIN_SEARCH_CHARS' => 'Min characters indexed by search',
|
'MIN_SEARCH_CHARS' => 'Min characters indexed by search',
|
||||||
'MIN_SEARCH_CHARS_EXPLAIN' => 'Words with at least this many characters will be indexed for searching.',
|
'MIN_SEARCH_CHARS_EXPLAIN' => 'Words with at least this many characters will be indexed for searching.',
|
||||||
'MAX_SEARCH_CHARS' => 'Max characters indexed by search',
|
'MAX_SEARCH_CHARS' => 'Max characters indexed by search',
|
||||||
'MAX_SEARCH_CHARS_EXPLAIN' => 'Words with no more than this many characters will be indexed for searching.'
|
'MAX_SEARCH_CHARS_EXPLAIN' => 'Words with no more than this many characters will be indexed for searching.',
|
||||||
|
'LOAD_USER_ACTIVITY' => 'Show users activity',
|
||||||
|
'LOAD_USER_ACTIVITY_EXPLAIN' => 'Displays active topic/forum in user profiles and user control panel. It is recommended to disable this on boards with more than one million posts.',
|
||||||
));
|
));
|
||||||
|
|
||||||
// Email settings
|
// Email settings
|
||||||
|
|
|
@ -321,109 +321,15 @@ switch ($mode)
|
||||||
$member['session_viewonline'] = (isset($row['session_viewonline'])) ? $row['session_viewonline'] : 0;
|
$member['session_viewonline'] = (isset($row['session_viewonline'])) ? $row['session_viewonline'] : 0;
|
||||||
unset($row);
|
unset($row);
|
||||||
|
|
||||||
/**
|
if ($config['load_user_activity'])
|
||||||
* @todo check for f_read and check the reasoning why $auth2 is not used for determining the active topics
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Obtain list of forums where this users post count is incremented
|
|
||||||
$auth2 = new auth();
|
|
||||||
$auth2->acl($member);
|
|
||||||
$f_postcount_ary = $auth2->acl_getf('f_postcount');
|
|
||||||
|
|
||||||
$sql_forums = array();
|
|
||||||
foreach ($f_postcount_ary as $forum_id => $allow)
|
|
||||||
{
|
{
|
||||||
if ($allow['f_postcount'])
|
show_user_activity($member);
|
||||||
{
|
|
||||||
$sql_forums[] = $forum_id;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$post_count_sql = (sizeof($sql_forums)) ? 'AND f.forum_id IN (' . implode(', ', $sql_forums) . ')' : '';
|
|
||||||
unset($sql_forums, $f_postcount_ary, $auth2);
|
|
||||||
|
|
||||||
// Grab all the relevant data
|
|
||||||
$sql = 'SELECT COUNT(p.post_id) AS num_posts
|
|
||||||
FROM ' . POSTS_TABLE . ' p, ' . FORUMS_TABLE . " f
|
|
||||||
WHERE p.poster_id = $user_id
|
|
||||||
AND f.forum_id = p.forum_id
|
|
||||||
$post_count_sql";
|
|
||||||
$result = $db->sql_query($sql);
|
|
||||||
|
|
||||||
$num_real_posts = min($user->data['user_posts'], $db->sql_fetchfield('num_posts', 0, $result));
|
|
||||||
$db->sql_freeresult($result);
|
|
||||||
|
|
||||||
// Change post_count_sql to an forum_id array the user is able to see
|
|
||||||
$f_forum_ary = $auth->acl_getf('f_read');
|
|
||||||
|
|
||||||
$sql_forums = array();
|
|
||||||
foreach ($f_forum_ary as $forum_id => $allow)
|
|
||||||
{
|
|
||||||
if (isset($allow['f_read']) && $allow['f_read'])
|
|
||||||
{
|
|
||||||
$sql_forums[] = $forum_id;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$post_count_sql = (sizeof($sql_forums)) ? 'AND f.forum_id IN (' . implode(', ', $sql_forums) . ')' : '';
|
|
||||||
unset($sql_forums, $f_forum_ary);
|
|
||||||
|
|
||||||
if ($post_count_sql)
|
|
||||||
{
|
|
||||||
$sql = 'SELECT f.forum_id, f.forum_name, COUNT(post_id) AS num_posts
|
|
||||||
FROM ' . POSTS_TABLE . ' p, ' . FORUMS_TABLE . " f
|
|
||||||
WHERE p.poster_id = $user_id
|
|
||||||
AND f.forum_id = p.forum_id
|
|
||||||
$post_count_sql
|
|
||||||
GROUP BY f.forum_id, f.forum_name
|
|
||||||
ORDER BY num_posts DESC";
|
|
||||||
$result = $db->sql_query_limit($sql, 1);
|
|
||||||
|
|
||||||
$active_f_row = $db->sql_fetchrow($result);
|
|
||||||
$db->sql_freeresult($result);
|
|
||||||
|
|
||||||
$sql = 'SELECT t.topic_id, t.topic_title, COUNT(p.post_id) AS num_posts
|
|
||||||
FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t, ' . FORUMS_TABLE . " f
|
|
||||||
WHERE p.poster_id = $user_id
|
|
||||||
AND t.topic_id = p.topic_id
|
|
||||||
AND f.forum_id = t.forum_id
|
|
||||||
$post_count_sql
|
|
||||||
GROUP BY t.topic_id, t.topic_title
|
|
||||||
ORDER BY num_posts DESC";
|
|
||||||
$result = $db->sql_query_limit($sql, 1);
|
|
||||||
|
|
||||||
$active_t_row = $db->sql_fetchrow($result);
|
|
||||||
$db->sql_freeresult($result);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$active_f_row = $active_t_row = array();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Do the relevant calculations
|
// Do the relevant calculations
|
||||||
$memberdays = max(1, round((time() - $member['user_regdate']) / 86400));
|
$memberdays = max(1, round((time() - $member['user_regdate']) / 86400));
|
||||||
$posts_per_day = $member['user_posts'] / $memberdays;
|
$posts_per_day = $member['user_posts'] / $memberdays;
|
||||||
$percentage = ($config['num_posts']) ? min(100, ($num_real_posts / $config['num_posts']) * 100) : 0;
|
$percentage = ($config['num_posts']) ? min(100, ($member['user_posts'] / $config['num_posts']) * 100) : 0;
|
||||||
|
|
||||||
$active_f_name = $active_f_id = $active_f_count = $active_f_pct = '';
|
|
||||||
if (!empty($active_f_row['num_posts']))
|
|
||||||
{
|
|
||||||
$active_f_name = $active_f_row['forum_name'];
|
|
||||||
$active_f_id = $active_f_row['forum_id'];
|
|
||||||
$active_f_count = $active_f_row['num_posts'];
|
|
||||||
$active_f_pct = ($member['user_posts']) ? ($active_f_count / $member['user_posts']) * 100 : 0;
|
|
||||||
}
|
|
||||||
unset($active_f_row);
|
|
||||||
|
|
||||||
$active_t_name = $active_t_id = $active_t_count = $active_t_pct = '';
|
|
||||||
if (!empty($active_t_row['num_posts']))
|
|
||||||
{
|
|
||||||
$active_t_name = $active_t_row['topic_title'];
|
|
||||||
$active_t_id = $active_t_row['topic_id'];
|
|
||||||
$active_t_count = $active_t_row['num_posts'];
|
|
||||||
$active_t_pct = ($member['user_posts']) ? ($active_t_count / $member['user_posts']) * 100 : 0;
|
|
||||||
}
|
|
||||||
unset($active_t_row);
|
|
||||||
|
|
||||||
if ($member['user_sig_bbcode_bitfield'] && $member['user_sig'])
|
if ($member['user_sig_bbcode_bitfield'] && $member['user_sig'])
|
||||||
{
|
{
|
||||||
|
@ -469,12 +375,6 @@ switch ($mode)
|
||||||
$template->assign_vars(array(
|
$template->assign_vars(array(
|
||||||
'POSTS_DAY' => sprintf($user->lang['POST_DAY'], $posts_per_day),
|
'POSTS_DAY' => sprintf($user->lang['POST_DAY'], $posts_per_day),
|
||||||
'POSTS_PCT' => sprintf($user->lang['POST_PCT'], $percentage),
|
'POSTS_PCT' => sprintf($user->lang['POST_PCT'], $percentage),
|
||||||
'ACTIVE_FORUM' => $active_f_name,
|
|
||||||
'ACTIVE_FORUM_POSTS'=> ($active_f_count == 1) ? sprintf($user->lang['USER_POST'], 1) : sprintf($user->lang['USER_POSTS'], $active_f_count),
|
|
||||||
'ACTIVE_FORUM_PCT' => sprintf($user->lang['POST_PCT'], $active_f_pct),
|
|
||||||
'ACTIVE_TOPIC' => censor_text($active_t_name),
|
|
||||||
'ACTIVE_TOPIC_POSTS'=> ($active_t_count == 1) ? sprintf($user->lang['USER_POST'], 1) : sprintf($user->lang['USER_POSTS'], $active_t_count),
|
|
||||||
'ACTIVE_TOPIC_PCT' => sprintf($user->lang['POST_PCT'], $active_t_pct),
|
|
||||||
|
|
||||||
'OCCUPATION' => (!empty($member['user_occ'])) ? censor_text($member['user_occ']) : '',
|
'OCCUPATION' => (!empty($member['user_occ'])) ? censor_text($member['user_occ']) : '',
|
||||||
'INTERESTS' => (!empty($member['user_interests'])) ? censor_text($member['user_interests']) : '',
|
'INTERESTS' => (!empty($member['user_interests'])) ? censor_text($member['user_interests']) : '',
|
||||||
|
@ -494,11 +394,10 @@ switch ($mode)
|
||||||
'S_PROFILE_ACTION' => "{$phpbb_root_path}memberlist.$phpEx$SID&mode=group",
|
'S_PROFILE_ACTION' => "{$phpbb_root_path}memberlist.$phpEx$SID&mode=group",
|
||||||
'S_GROUP_OPTIONS' => $group_options,
|
'S_GROUP_OPTIONS' => $group_options,
|
||||||
'S_CUSTOM_FIELDS' => (isset($profile_fields['row']) && sizeof($profile_fields['row'])) ? true : false,
|
'S_CUSTOM_FIELDS' => (isset($profile_fields['row']) && sizeof($profile_fields['row'])) ? true : false,
|
||||||
|
'S_SHOW_ACTIVITY' => ($config['load_user_activity']) ? true : false,
|
||||||
|
|
||||||
'U_ADD_FRIEND' => "ucp.$phpEx$SID&i=zebra&add=" . urlencode($member['username']),
|
'U_ADD_FRIEND' => "ucp.$phpEx$SID&i=zebra&add=" . urlencode($member['username']),
|
||||||
'U_ADD_FOE' => "ucp.$phpEx$SID&i=zebra&mode=foes&add=" . urlencode($member['username']),
|
'U_ADD_FOE' => "ucp.$phpEx$SID&i=zebra&mode=foes&add=" . urlencode($member['username']))
|
||||||
'U_ACTIVE_FORUM' => "viewforum.$phpEx$SID&f=$active_f_id",
|
|
||||||
'U_ACTIVE_TOPIC' => "viewtopic.$phpEx$SID&t=$active_t_id",)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
if (isset($profile_fields['row']) && sizeof($profile_fields['row']))
|
if (isset($profile_fields['row']) && sizeof($profile_fields['row']))
|
||||||
|
@ -1257,4 +1156,85 @@ function show_profile($data)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function show_user_activity(&$member)
|
||||||
|
{
|
||||||
|
global $auth, $template, $db, $user;
|
||||||
|
global $phpbb_root_path, $SID, $phpEx;
|
||||||
|
|
||||||
|
$auth2 = new auth();
|
||||||
|
$auth2->acl($member);
|
||||||
|
|
||||||
|
$post_count_ary = $auth2->acl_getf('!f_postcount');
|
||||||
|
$forum_read_ary = $auth->acl_getf('!f_read');
|
||||||
|
|
||||||
|
$forum_ary = array();
|
||||||
|
foreach ($post_count_ary as $forum_id => $allowed)
|
||||||
|
{
|
||||||
|
if ($allowed['f_postcount'] || $forum_read_ary[$forum_id]['f_read'])
|
||||||
|
{
|
||||||
|
$forum_ary[] = $forum_id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$post_count_sql = (sizeof($forum_ary)) ? 'AND f.forum_id NOT IN (' . implode(', ', $forum_ary) . ')' : '';
|
||||||
|
|
||||||
|
if ($post_count_sql)
|
||||||
|
{
|
||||||
|
$sql = 'SELECT f.forum_id, f.forum_name, COUNT(post_id) AS num_posts
|
||||||
|
FROM ' . POSTS_TABLE . ' p, ' . FORUMS_TABLE . " f
|
||||||
|
WHERE p.poster_id = {$member['user_id']}
|
||||||
|
AND f.forum_id = p.forum_id
|
||||||
|
$post_count_sql
|
||||||
|
GROUP BY f.forum_id, f.forum_name
|
||||||
|
ORDER BY num_posts DESC";
|
||||||
|
$result = $db->sql_query_limit($sql, 1);
|
||||||
|
$active_f_row = $db->sql_fetchrow($result);
|
||||||
|
$db->sql_freeresult($result);
|
||||||
|
|
||||||
|
$sql = 'SELECT t.topic_id, t.topic_title, COUNT(p.post_id) AS num_posts
|
||||||
|
FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t, ' . FORUMS_TABLE . " f
|
||||||
|
WHERE p.poster_id = {$member['user_id']}
|
||||||
|
AND t.topic_id = p.topic_id
|
||||||
|
AND f.forum_id = t.forum_id
|
||||||
|
$post_count_sql
|
||||||
|
GROUP BY t.topic_id, t.topic_title
|
||||||
|
ORDER BY num_posts DESC";
|
||||||
|
$result = $db->sql_query_limit($sql, 1);
|
||||||
|
$active_t_row = $db->sql_fetchrow($result);
|
||||||
|
$db->sql_freeresult($result);
|
||||||
|
}
|
||||||
|
|
||||||
|
$member['active_t_row'] = $active_t_row;
|
||||||
|
$member['active_f_row'] = $active_f_row;
|
||||||
|
|
||||||
|
$active_f_name = $active_f_id = $active_f_count = $active_f_pct = '';
|
||||||
|
if (!empty($active_f_row['num_posts']))
|
||||||
|
{
|
||||||
|
$active_f_name = $active_f_row['forum_name'];
|
||||||
|
$active_f_id = $active_f_row['forum_id'];
|
||||||
|
$active_f_count = $active_f_row['num_posts'];
|
||||||
|
$active_f_pct = ($member['user_posts']) ? ($active_f_count / $member['user_posts']) * 100 : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
$active_t_name = $active_t_id = $active_t_count = $active_t_pct = '';
|
||||||
|
if (!empty($active_t_row['num_posts']))
|
||||||
|
{
|
||||||
|
$active_t_name = $active_t_row['topic_title'];
|
||||||
|
$active_t_id = $active_t_row['topic_id'];
|
||||||
|
$active_t_count = $active_t_row['num_posts'];
|
||||||
|
$active_t_pct = ($member['user_posts']) ? ($active_t_count / $member['user_posts']) * 100 : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
$template->assign_vars(array(
|
||||||
|
'ACTIVE_FORUM' => $active_f_name,
|
||||||
|
'ACTIVE_FORUM_POSTS' => ($active_f_count == 1) ? sprintf($user->lang['USER_POST'], 1) : sprintf($user->lang['USER_POSTS'], $active_f_count),
|
||||||
|
'ACTIVE_FORUM_PCT' => sprintf($user->lang['POST_PCT'], $active_f_pct),
|
||||||
|
'ACTIVE_TOPIC' => censor_text($active_t_name),
|
||||||
|
'ACTIVE_TOPIC_POSTS' => ($active_t_count == 1) ? sprintf($user->lang['USER_POST'], 1) : sprintf($user->lang['USER_POSTS'], $active_t_count),
|
||||||
|
'ACTIVE_TOPIC_PCT' => sprintf($user->lang['POST_PCT'], $active_t_pct),
|
||||||
|
'U_ACTIVE_FORUM' => "{$phpbb_root_path}viewforum.$phpEx$SID&f=$active_f_id",
|
||||||
|
'U_ACTIVE_TOPIC' => "{$phpbb_root_path}viewtopic.$phpEx$SID&t=$active_t_id")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
|
@ -60,6 +60,7 @@
|
||||||
<td class="gen" align="right" valign="top" nowrap="nowrap">{L_TOTAL_POSTS}: </td>
|
<td class="gen" align="right" valign="top" nowrap="nowrap">{L_TOTAL_POSTS}: </td>
|
||||||
<td><!-- IF POSTS_PCT neq 0 --><b class="gen">{POSTS}</b><br /><span class="genmed">[{POSTS_PCT} / {POSTS_DAY}]<br /><a href="{U_SEARCH_USER}">{L_SEARCH_USER_POSTS}</a></span><!-- ELSE --><b class="gen">{POSTS}</b><!-- ENDIF --></td>
|
<td><!-- IF POSTS_PCT neq 0 --><b class="gen">{POSTS}</b><br /><span class="genmed">[{POSTS_PCT} / {POSTS_DAY}]<br /><a href="{U_SEARCH_USER}">{L_SEARCH_USER_POSTS}</a></span><!-- ELSE --><b class="gen">{POSTS}</b><!-- ENDIF --></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<!-- IF S_SHOW_ACTIVITY -->
|
||||||
<tr>
|
<tr>
|
||||||
<td class="gen" align="right" valign="top" nowrap="nowrap">{L_ACTIVE_IN_FORUM}: </td>
|
<td class="gen" align="right" valign="top" nowrap="nowrap">{L_ACTIVE_IN_FORUM}: </td>
|
||||||
<td><!-- IF ACTIVE_FORUM_PCT neq 0 --><b><a class="gen" href="{U_ACTIVE_FORUM}">{ACTIVE_FORUM}</a></b><br /><span class="genmed">[ {ACTIVE_FORUM_POSTS} / {ACTIVE_FORUM_PCT} ]</span><!-- ELSE --><span class="gen">-</span><!-- ENDIF --></td>
|
<td><!-- IF ACTIVE_FORUM_PCT neq 0 --><b><a class="gen" href="{U_ACTIVE_FORUM}">{ACTIVE_FORUM}</a></b><br /><span class="genmed">[ {ACTIVE_FORUM_POSTS} / {ACTIVE_FORUM_PCT} ]</span><!-- ELSE --><span class="gen">-</span><!-- ENDIF --></td>
|
||||||
|
@ -68,6 +69,7 @@
|
||||||
<td class="gen" align="right" valign="top" nowrap="nowrap">{L_ACTIVE_IN_TOPIC}: </td>
|
<td class="gen" align="right" valign="top" nowrap="nowrap">{L_ACTIVE_IN_TOPIC}: </td>
|
||||||
<td><!-- IF ACTIVE_TOPIC_PCT neq 0 --><b><a class="gen" href="{U_ACTIVE_TOPIC}">{ACTIVE_TOPIC}</a></b><br /><span class="gensmall">[ {ACTIVE_TOPIC_POSTS} / {ACTIVE_TOPIC_PCT} ]</span><!-- ELSE --><span class="gen">-</span><!-- ENDIF --></td>
|
<td><!-- IF ACTIVE_TOPIC_PCT neq 0 --><b><a class="gen" href="{U_ACTIVE_TOPIC}">{ACTIVE_TOPIC}</a></b><br /><span class="gensmall">[ {ACTIVE_TOPIC_POSTS} / {ACTIVE_TOPIC_PCT} ]</span><!-- ELSE --><span class="gen">-</span><!-- ENDIF --></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<!-- ENDIF -->
|
||||||
</table></td>
|
</table></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
|
|
@ -56,6 +56,7 @@
|
||||||
<td align="right" valign="top" nowrap="nowrap"><b class="genmed">{L_TOTAL_POSTS}: </b></td>
|
<td align="right" valign="top" nowrap="nowrap"><b class="genmed">{L_TOTAL_POSTS}: </b></td>
|
||||||
<td><!-- IF POSTS_PCT neq 0 --><b class="gen">{POSTS}</b><br /><span class="genmed">[{POSTS_PCT} / {POSTS_DAY}]<br /><a href="{U_SEARCH_USER}">{L_SEARCH_USER_POSTS}</a></span><!-- ELSE --><b class="gen">{POSTS}<b><!-- ENDIF --></td>
|
<td><!-- IF POSTS_PCT neq 0 --><b class="gen">{POSTS}</b><br /><span class="genmed">[{POSTS_PCT} / {POSTS_DAY}]<br /><a href="{U_SEARCH_USER}">{L_SEARCH_USER_POSTS}</a></span><!-- ELSE --><b class="gen">{POSTS}<b><!-- ENDIF --></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<!-- IF S_SHOW_ACTIVITY -->
|
||||||
<tr>
|
<tr>
|
||||||
<td align="right" valign="top" nowrap="nowrap"><b class="genmed">{L_ACTIVE_IN_FORUM}: </b></td>
|
<td align="right" valign="top" nowrap="nowrap"><b class="genmed">{L_ACTIVE_IN_FORUM}: </b></td>
|
||||||
<td><!-- IF ACTIVE_FORUM_PCT neq 0 --><b><a class="gen" href="{U_ACTIVE_FORUM}">{ACTIVE_FORUM}</a></b><br /><span class="genmed">[ {ACTIVE_FORUM_POSTS} / {ACTIVE_FORUM_PCT} ]</span><!-- ELSE --><span class="gen">-</span><!-- ENDIF --></td>
|
<td><!-- IF ACTIVE_FORUM_PCT neq 0 --><b><a class="gen" href="{U_ACTIVE_FORUM}">{ACTIVE_FORUM}</a></b><br /><span class="genmed">[ {ACTIVE_FORUM_POSTS} / {ACTIVE_FORUM_PCT} ]</span><!-- ELSE --><span class="gen">-</span><!-- ENDIF --></td>
|
||||||
|
@ -64,6 +65,7 @@
|
||||||
<td align="right" valign="top" nowrap="nowrap"><b class="genmed">{L_ACTIVE_IN_TOPIC}: </b></td>
|
<td align="right" valign="top" nowrap="nowrap"><b class="genmed">{L_ACTIVE_IN_TOPIC}: </b></td>
|
||||||
<td><!-- IF ACTIVE_TOPIC_PCT neq 0 --><b><a class="gen" href="{U_ACTIVE_TOPIC}">{ACTIVE_TOPIC}</a></b><br /><span class="gensmall">[ {ACTIVE_TOPIC_POSTS} / {ACTIVE_TOPIC_PCT} ]</span><!-- ELSE --><span class="gen">-</span><!-- ENDIF --></td>
|
<td><!-- IF ACTIVE_TOPIC_PCT neq 0 --><b><a class="gen" href="{U_ACTIVE_TOPIC}">{ACTIVE_TOPIC}</a></b><br /><span class="gensmall">[ {ACTIVE_TOPIC_POSTS} / {ACTIVE_TOPIC_PCT} ]</span><!-- ELSE --><span class="gen">-</span><!-- ENDIF --></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<!-- ENDIF -->
|
||||||
<!-- IF WARNINGS -->
|
<!-- IF WARNINGS -->
|
||||||
<tr>
|
<tr>
|
||||||
<td align="right" valign="middle" nowrap="nowrap"><b class="genmed">{L_YOUR_WARNINGS}: </b></td>
|
<td align="right" valign="middle" nowrap="nowrap"><b class="genmed">{L_YOUR_WARNINGS}: </b></td>
|
||||||
|
|
Loading…
Add table
Reference in a new issue