From ba6f40ce2542b87c7110dd9e38e4c0386b22da81 Mon Sep 17 00:00:00 2001 From: Graham Eames Date: Mon, 28 Nov 2005 21:01:40 +0000 Subject: [PATCH] Initial commit of user note support for the mcp git-svn-id: file:///svn/phpbb/trunk@5314 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/mcp/mcp_main.php | 20 -- phpBB/includes/mcp/mcp_notes.php | 231 ++++++++++++++++++ phpBB/includes/mcp/mcp_queue.php | 20 -- phpBB/mcp.php | 8 + .../subSilver/template/mcp_notes_front.html | 21 ++ .../subSilver/template/mcp_notes_user.html | 86 +++++++ .../subSilver/template/viewtopic_body.html | 2 +- 7 files changed, 347 insertions(+), 41 deletions(-) create mode 100755 phpBB/includes/mcp/mcp_notes.php create mode 100755 phpBB/styles/subSilver/template/mcp_notes_front.html create mode 100755 phpBB/styles/subSilver/template/mcp_notes_user.html diff --git a/phpBB/includes/mcp/mcp_main.php b/phpBB/includes/mcp/mcp_main.php index 22e9d520f5..cbe8227bae 100644 --- a/phpBB/includes/mcp/mcp_main.php +++ b/phpBB/includes/mcp/mcp_main.php @@ -183,26 +183,6 @@ class mcp_main trigger_error("Unknown mode: $mode"); } } - - function install() - { - } - - function uninstall() - { - } - - function module() - { - $details = array( - 'name' => 'MCP - Main', - 'description' => 'Front end for Moderator Control Panel', - 'filename' => 'main', - 'version' => '0.1.0', - 'phpbbversion' => '2.2.0' - ); - return $details; - } } /** diff --git a/phpBB/includes/mcp/mcp_notes.php b/phpBB/includes/mcp/mcp_notes.php new file mode 100755 index 0000000000..890b3d0a81 --- /dev/null +++ b/phpBB/includes/mcp/mcp_notes.php @@ -0,0 +1,231 @@ +p_master = &$p_master; + } + + function main($id, $mode) + { + global $auth, $db, $user, $template; + global $config, $phpbb_root_path, $phpEx, $SID; + + $action = request_var('action', array('' => '')); + + if (is_array($action)) + { + list($action, ) = each($action); + } + + switch ($mode) + { + case 'front': + $template->assign_vars(array( + 'U_FIND_MEMBER' => "memberlist.$phpEx$SID&mode=searchuser&field=username", + 'U_POST_ACTION' => "mcp.$phpEx$SID&i=notes&mode=user_notes", + ) + ); + + $this->tpl_name = 'mcp_notes_front'; + break; + case 'user_notes': + mcp_notes_user_view($id, $mode, $action); + $this->tpl_name = 'mcp_notes_user'; + break; + } + } +} + +/** +* @package module_install +*/ +class mcp_notes_info +{ + function module() + { + return array( + 'filename' => 'mcp_notes', + 'title' => 'MCP_NOTES', + 'version' => '1.0.0', + 'modes' => array( + 'front' => array('title' => 'MCP_NOTES_FRONT', 'auth' => 'acl_m_'), + 'user_notes' => array('title' => 'MCP_NOTES_USER', 'auth' => 'acl_m_'), + ), + ); + } + + function install() + { + } + + function uninstall() + { + } +} + +// +// Functions +// + +function mcp_notes_user_view($id, $mode, $action) +{ + global $SID, $phpEx, $phpbb_root_path, $config; + global $template, $db, $user, $auth; + + $user_id = request_var('u', 0); + $username = request_var('username', ''); + $start = request_var('start', 0); + $st = request_var('st', 0); + $sk = request_var('sk', 'a'); + $sd = request_var('sd', 'd'); + + $sql_where = ($user_id) ? "user_id = $user_id" : "username = '" . $db->sql_escape($username) . "'"; + + $sql = 'SELECT * FROM ' . USERS_TABLE . " WHERE $sql_where"; + $result = $db->sql_query($sql); + + if (!$userrow = $db->sql_fetchrow($result)) + { + trigger_error($user->lang['NO_USER']); + } + $db->sql_freeresult($result); + + $user_id = $userrow['user_id']; + + $deletemark = ($action == 'del_marked') ? true : false; + $deleteall = ($action == 'del_all') ? true : false; + $marked = request_var('marknote', 0); + $usernote = request_var('usernote', ''); + + // Handle any actions + if (($deletemark || $deleteall) && $auth->acl_get('a_clearlogs')) + { + $where_sql = ''; + if ($deletemark && $marked) + { + $sql_in = array(); + foreach ($marked as $mark) + { + $sql_in[] = $mark; + } + $where_sql = ' AND log_id IN (' . implode(', ', $sql_in) . ')'; + unset($sql_in); + } + + $sql = 'DELETE FROM ' . LOG_TABLE . ' + WHERE log_type = ' . LOG_USERS . " + $where_sql"; + $db->sql_query($sql); + + add_log('admin', 'LOG_USERS_CLEAR'); + + $msg = ($deletemark) ? 'MARKED_DELETED' : 'ALL_DELETED'; + $redirect = "mcp.$phpEx$SID&i=$id&mode=$mode&u=$user_id"; + meta_refresh(2, $redirect); + trigger_error($user->lang[$msg] . '

' . sprintf($user->lang['RETURN_PAGE'], '', '')); + } + + if ($usernote && $action == 'add_feedback') + { + add_log('admin', 'LOG_USER_FEEDBACK', $userrow['username']); + add_log('user', $user_id, 'LOG_USER_GENERAL', $usernote); + + $redirect = "mcp.$phpEx$SID&i=$id&mode=$mode&u=$user_id"; + meta_refresh(2, $redirect); + trigger_error($user->lang['USER_FEEDBACK_ADDED'] . '

' . sprintf($user->lang['RETURN_PAGE'], '', '')); + } + + // Generate the appropriate user information for the user we are looking at + $rank_title = $rank_img = ''; +// get_user_rank($userrow['user_rank'], $userrow['user_posts'], $rank_title, $rank_img); + + $avatar_img = ''; + if (!empty($userrow['user_avatar'])) + { + switch ($userrow['user_avatar_type']) + { + case AVATAR_UPLOAD: + $avatar_img = $config['avatar_path'] . '/'; + break; + case AVATAR_GALLERY: + $avatar_img = $config['avatar_gallery_path'] . '/'; + break; + } + $avatar_img .= $userrow['user_avatar']; + + $avatar_img = ''; + } + else + { + $avatar_img = ''; + } + + $limit_days = array(0 => $user->lang['ALL_ENTRIES'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 364 => $user->lang['1_YEAR']); + $sort_by_text = array('a' => $user->lang['SORT_USERNAME'], 'b' => $user->lang['SORT_DATE'], 'c' => $user->lang['SORT_IP'], 'd' => $user->lang['SORT_ACTION']); + $sort_by_sql = array('a' => 'l.user_id', 'b' => 'l.log_time', 'c' => 'l.log_ip', 'd' => 'l.log_operation'); + + $s_limit_days = $s_sort_key = $s_sort_dir = ''; + gen_sort_selects($limit_days, $sort_by_text, $st, $sk, $sd, $s_limit_days, $s_sort_key, $s_sort_dir); + + // Define where and sort sql for use in displaying logs + $sql_where = ($st) ? (time() - ($st * 86400)) : 0; + $sql_sort = $sort_by_sql[$sk] . ' ' . (($sd == 'd') ? 'DESC' : 'ASC'); + + $log_data = array(); + $log_count = 0; + view_log('user', $log_data, $log_count, $config['posts_per_page'], $start, 0, 0, $user_id, $sql_where, $sql_sort); + + if ($log_count) + { + $template->assign_var('S_USER_NOTES', true); + + foreach ($log_data as $row) + { + $template->assign_block_vars('usernotes', array( + 'REPORT_BY' => $row['username'], + 'REPORT_AT' => $user->format_date($row['time']), + 'ACTION' => $row['action'], + 'ID' => $row['id']) + ); + } + } + + $pagination = generate_pagination("mcp.$phpEx$SID&i=$id&mode=$mode&u=$user_id&st=$st&sk=$sk&sd=$sd", $log_count, $config['posts_per_page'], $start); + + $template->assign_vars(array( + 'U_POST_ACTION' => "mcp.$phpEx$SID&i=$id&mode=$mode&u=$user_id", + 'S_CLEAR_ALLOWED' => ($auth->acl_get('a_clearlogs')) ? true : false, + 'PAGINATION' => $pagination, + + 'USERNAME' => $userrow['username'], + 'USER_COLOR' => (!empty($userrow['user_colour'])) ? $userrow['user_colour'] : '', + 'RANK_TITLE' => $rank_title, + 'JOINED' => $user->format_date($userrow['user_regdate'], $user->lang['DATE_FORMAT']), + 'POSTS' => ($data['user_posts']) ? $data['user_posts'] : 0, + + 'AVATAR_IMG' => $avatar_img, + 'RANK_IMG' => $rank_img, + ) + ); + +} + +?> \ No newline at end of file diff --git a/phpBB/includes/mcp/mcp_queue.php b/phpBB/includes/mcp/mcp_queue.php index db0291f7ad..f188de4633 100644 --- a/phpBB/includes/mcp/mcp_queue.php +++ b/phpBB/includes/mcp/mcp_queue.php @@ -289,26 +289,6 @@ class mcp_queue break; } } - - function install() - { - } - - function uninstall() - { - } - - function module() - { - $details = array( - 'name' => 'MCP - Queue', - 'description' => 'Module for management of items waiting for approval', - 'filename' => 'queue', - 'version' => '0.1.0', - 'phpbbversion' => '2.2.0' - ); - return $details; - } } // Approve Post/Topic diff --git a/phpBB/mcp.php b/phpBB/mcp.php index 06ccc6d58e..ab6cfc38b8 100644 --- a/phpBB/mcp.php +++ b/phpBB/mcp.php @@ -99,6 +99,9 @@ if (!$quickmod) $post_id = request_var('p', 0); $topic_id = request_var('t', 0); $forum_id = request_var('f', 0); + $user_id = request_var('u', 0); + $username = request_var('username', ''); + if ($post_id) { @@ -150,6 +153,7 @@ if (!$quickmod) if (!$post_id) { $module->set_display('post_details', false); + $module->set_display('post', false); } if (!$topic_id) { @@ -159,6 +163,10 @@ if (!$quickmod) { $module->set_display('forum_view', false); } + if (!$user_id && $username == '') + { + $module->set_display('user_notes', false); + } // Load and execute the relevant module $module->load_active(); diff --git a/phpBB/styles/subSilver/template/mcp_notes_front.html b/phpBB/styles/subSilver/template/mcp_notes_front.html new file mode 100755 index 0000000000..1a2e6d588a --- /dev/null +++ b/phpBB/styles/subSilver/template/mcp_notes_front.html @@ -0,0 +1,21 @@ + + + +
+ + + + + + + + + + + +
{L_SELECT_USER}
{L_FIND_USERNAME}:
[ {L_FIND_USERNAME} ]
+
+ +

+ + \ No newline at end of file diff --git a/phpBB/styles/subSilver/template/mcp_notes_user.html b/phpBB/styles/subSilver/template/mcp_notes_user.html new file mode 100755 index 0000000000..46520d7694 --- /dev/null +++ b/phpBB/styles/subSilver/template/mcp_notes_user.html @@ -0,0 +1,86 @@ + + + + +
+ + + + + + + + + +
{USERNAME}
+ + + + + + + + + + + + + + + + + + +
{USERNAME}
{RANK}
{RANK_IMG}
{AVATAR_IMG}
+ + + + + + + + +
{L_JOINED}: {JOINED}
{L_TOTAL_POSTS}: {POSTS}
+ + + + + + + + colspan="2">{L_REPORT_BY}: {usernotes.REPORT_BY} {L_ON} {usernotes.REPORT_AT}
{usernotes.ACTION} +
+ + + + + + + + + + + + +
{L_FEEDBACK}
 
{L_NO_USER_NOTES}
+
+ + + + + + + + + + + + + +
{L_ADD_FEEDBACK}
{L_ADD_FEEDBACK_EXPLAIN}
  
+ +
+ +

+ + \ No newline at end of file diff --git a/phpBB/styles/subSilver/template/viewtopic_body.html b/phpBB/styles/subSilver/template/viewtopic_body.html index c20c8832db..7aaeb8c4e8 100644 --- a/phpBB/styles/subSilver/template/viewtopic_body.html +++ b/phpBB/styles/subSilver/template/viewtopic_body.html @@ -244,7 +244,7 @@ {L_RATE}: {L_RATE_GOOD} / {L_RATE_BAD} - {REPORT_IMG} {INFO_IMG} {DELETE_IMG} + {REPORT_IMG} {INFO_IMG} {WARN_IMG} {DELETE_IMG}