aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/mcp/mcp_notes.php
diff options
context:
space:
mode:
authorGraham Eames <grahamje@users.sourceforge.net>2005-11-28 21:01:40 +0000
committerGraham Eames <grahamje@users.sourceforge.net>2005-11-28 21:01:40 +0000
commitba6f40ce2542b87c7110dd9e38e4c0386b22da81 (patch)
treea50ce939593b14962190a22d7f428cdea151396c /phpBB/includes/mcp/mcp_notes.php
parent6d101df7dc3dc6f5542ccb11d626dcacbd148de6 (diff)
downloadforums-ba6f40ce2542b87c7110dd9e38e4c0386b22da81.tar
forums-ba6f40ce2542b87c7110dd9e38e4c0386b22da81.tar.gz
forums-ba6f40ce2542b87c7110dd9e38e4c0386b22da81.tar.bz2
forums-ba6f40ce2542b87c7110dd9e38e4c0386b22da81.tar.xz
forums-ba6f40ce2542b87c7110dd9e38e4c0386b22da81.zip
Initial commit of user note support for the mcp
git-svn-id: file:///svn/phpbb/trunk@5314 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/includes/mcp/mcp_notes.php')
-rwxr-xr-xphpBB/includes/mcp/mcp_notes.php231
1 files changed, 231 insertions, 0 deletions
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 @@
+<?php
+/**
+*
+* @package mcp
+* @version $Id$
+* @copyright (c) 2005 phpBB Group
+* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+*
+*/
+
+/**
+* @package mcp
+* mcp_notes
+* Displays notes about a user
+*/
+class mcp_notes
+{
+
+ var $p_master;
+
+ function mcp_main(&$p_master)
+ {
+ $this->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&amp;mode=searchuser&amp;field=username",
+ 'U_POST_ACTION' => "mcp.$phpEx$SID&amp;i=notes&amp;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&amp;i=$id&amp;mode=$mode&amp;u=$user_id";
+ meta_refresh(2, $redirect);
+ trigger_error($user->lang[$msg] . '<br /><br />' . sprintf($user->lang['RETURN_PAGE'], '<a href="' . $redirect . '">', '</a>'));
+ }
+
+ 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&amp;i=$id&amp;mode=$mode&amp;u=$user_id";
+ meta_refresh(2, $redirect);
+ trigger_error($user->lang['USER_FEEDBACK_ADDED'] . '<br /><br />' . sprintf($user->lang['RETURN_PAGE'], '<a href="' . $redirect . '">', '</a>'));
+ }
+
+ // 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 = '<img src="' . $avatar_img . '" width="' . $userrow['user_avatar_width'] . '" height="' . $userrow['user_avatar_height'] . '" border="0" alt="" />';
+ }
+ else
+ {
+ $avatar_img = '<img src="adm/images/no_avatar.gif" alt="" />';
+ }
+
+ $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&amp;i=$id&amp;mode=$mode&amp;u=$user_id&amp;st=$st&amp;sk=$sk&amp;sd=$sd", $log_count, $config['posts_per_page'], $start);
+
+ $template->assign_vars(array(
+ 'U_POST_ACTION' => "mcp.$phpEx$SID&amp;i=$id&amp;mode=$mode&amp;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