~azzar1/unity/add-show-desktop-key

« back to all changes in this revision

Viewing changes to www/php/phpBB3/includes/mcp/mcp_notes.php

  • Committer: William Grant
  • Date: 2009-02-23 23:47:02 UTC
  • mfrom: (1099.1.211 new-dispatch)
  • Revision ID: grantw@unimelb.edu.au-20090223234702-db4b1llly46ignwo
Merge from lp:~ivle-dev/ivle/new-dispatch.

Pretty much everything changes. Reread the setup docs. Backup your databases.
Every file is now in a different installed location, the configuration system
is rewritten, the dispatch system is rewritten, URLs are different, the
database is different, worksheets and exercises are no longer on the
filesystem, we use a templating engine, jail service protocols are rewritten,
we don't repeat ourselves, we have authorization rewritten, phpBB is gone,
and probably lots of other things that I cannot remember.

This is certainly the biggest commit I have ever made, and hopefully
the largest I ever will.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<?php
2
 
/**
3
 
*
4
 
* @package mcp
5
 
* @version $Id: mcp_notes.php,v 1.43 2007/10/05 14:36:33 acydburn Exp $
6
 
* @copyright (c) 2005 phpBB Group
7
 
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
8
 
*
9
 
*/
10
 
 
11
 
/**
12
 
* @ignore
13
 
*/
14
 
if (!defined('IN_PHPBB'))
15
 
{
16
 
        exit;
17
 
}
18
 
 
19
 
/**
20
 
* mcp_notes
21
 
* Displays notes about a user
22
 
* @package mcp
23
 
*/
24
 
class mcp_notes
25
 
{
26
 
        var $p_master;
27
 
        var $u_action;
28
 
 
29
 
        function mcp_notes(&$p_master)
30
 
        {
31
 
                $this->p_master = &$p_master;
32
 
        }
33
 
 
34
 
        function main($id, $mode)
35
 
        {
36
 
                global $auth, $db, $user, $template;
37
 
                global $config, $phpbb_root_path, $phpEx;
38
 
 
39
 
                $action = request_var('action', array('' => ''));
40
 
 
41
 
                if (is_array($action))
42
 
                {
43
 
                        list($action, ) = each($action);
44
 
                }
45
 
 
46
 
                $this->page_title = 'MCP_NOTES';
47
 
 
48
 
                switch ($mode)
49
 
                {
50
 
                        case 'front':
51
 
                                $template->assign_vars(array(
52
 
                                        'U_FIND_USERNAME'       => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=searchuser&amp;form=mcp&amp;field=username&amp;select_single=true'),
53
 
                                        'U_POST_ACTION'         => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=notes&amp;mode=user_notes'),
54
 
 
55
 
                                        'L_TITLE'                       => $user->lang['MCP_NOTES'],
56
 
                                ));
57
 
 
58
 
                                $this->tpl_name = 'mcp_notes_front';
59
 
                        break;
60
 
 
61
 
                        case 'user_notes':
62
 
                                $user->add_lang('acp/common');
63
 
 
64
 
                                $this->mcp_notes_user_view($action);
65
 
                                $this->tpl_name = 'mcp_notes_user';
66
 
                        break;
67
 
                }
68
 
        }
69
 
 
70
 
        /**
71
 
        * Display user notes
72
 
        */
73
 
        function mcp_notes_user_view($action)
74
 
        {
75
 
                global $phpEx, $phpbb_root_path, $config;
76
 
                global $template, $db, $user, $auth;
77
 
 
78
 
                $user_id = request_var('u', 0);
79
 
                $username = request_var('username', '', true);
80
 
                $start = request_var('start', 0);
81
 
                $st     = request_var('st', 0);
82
 
                $sk     = request_var('sk', 'b');
83
 
                $sd     = request_var('sd', 'd');
84
 
 
85
 
                add_form_key('mcp_notes');
86
 
 
87
 
                $sql_where = ($user_id) ? "user_id = $user_id" : "username_clean = '" . $db->sql_escape(utf8_clean_string($username)) . "'";
88
 
 
89
 
                $sql = 'SELECT *
90
 
                        FROM ' . USERS_TABLE . "
91
 
                        WHERE $sql_where";
92
 
                $result = $db->sql_query($sql);
93
 
                $userrow = $db->sql_fetchrow($result);
94
 
                $db->sql_freeresult($result);
95
 
 
96
 
                if (!$userrow)
97
 
                {
98
 
                        trigger_error('NO_USER');
99
 
                }
100
 
 
101
 
                $user_id = $userrow['user_id'];
102
 
 
103
 
                // Populate user id to the currently active module (this module)
104
 
                // The following method is another way of adjusting module urls. It is the easy variant if we want
105
 
                // to directly adjust the current module url based on data retrieved within the same module.
106
 
                if (strpos($this->u_action, "&amp;u=$user_id") === false)
107
 
                {
108
 
                        $this->p_master->adjust_url('&amp;u=' . $user_id);
109
 
                        $this->u_action .= "&amp;u=$user_id";
110
 
                }
111
 
 
112
 
                $deletemark = ($action == 'del_marked') ? true : false;
113
 
                $deleteall      = ($action == 'del_all') ? true : false;
114
 
                $marked         = request_var('marknote', array(0));
115
 
                $usernote       = utf8_normalize_nfc(request_var('usernote', '', true));
116
 
 
117
 
                // Handle any actions
118
 
                if (($deletemark || $deleteall) && $auth->acl_get('a_clearlogs'))
119
 
                {
120
 
                        $where_sql = '';
121
 
                        if ($deletemark && $marked)
122
 
                        {
123
 
                                $sql_in = array();
124
 
                                foreach ($marked as $mark)
125
 
                                {
126
 
                                        $sql_in[] = $mark;
127
 
                                }
128
 
                                $where_sql = ' AND ' . $db->sql_in_set('log_id', $sql_in);
129
 
                                unset($sql_in);
130
 
                        }
131
 
 
132
 
                        if ($where_sql || $deleteall)
133
 
                        {
134
 
                                if (check_form_key('mcp_notes'))
135
 
                                {
136
 
                                        $sql = 'DELETE FROM ' . LOG_TABLE . '
137
 
                                                WHERE log_type = ' . LOG_USERS . "
138
 
                                                        AND reportee_id = $user_id
139
 
                                                        $where_sql";
140
 
                                        $db->sql_query($sql);
141
 
 
142
 
                                        add_log('admin', 'LOG_CLEAR_USER', $userrow['username']);
143
 
 
144
 
                                        $msg = ($deletemark) ? 'MARKED_NOTES_DELETED' : 'ALL_NOTES_DELETED';
145
 
                                }
146
 
                                else
147
 
                                {
148
 
                                        $msg = 'FORM_INVALID';
149
 
                                }
150
 
                                $redirect = $this->u_action . '&amp;u=' . $user_id;
151
 
                                meta_refresh(3, $redirect);
152
 
                                trigger_error($user->lang[$msg] . '<br /><br />' . sprintf($user->lang['RETURN_PAGE'], '<a href="' . $redirect . '">', '</a>'));
153
 
                        }
154
 
                }
155
 
 
156
 
                if ($usernote && $action == 'add_feedback')
157
 
                {
158
 
                        if (check_form_key('mcp_notes'))
159
 
                        {
160
 
                                add_log('admin', 'LOG_USER_FEEDBACK', $userrow['username']);
161
 
                                add_log('mod', 0, 0, 'LOG_USER_FEEDBACK', $userrow['username']);
162
 
 
163
 
                                add_log('user', $user_id, 'LOG_USER_GENERAL', $usernote);
164
 
                                $msg = $user->lang['USER_FEEDBACK_ADDED'];
165
 
                        }
166
 
                        else
167
 
                        {
168
 
                                $msg = $user->lang['FORM_INVALID'];
169
 
                        }
170
 
                        $redirect = $this->u_action;
171
 
                        meta_refresh(3, $redirect);
172
 
 
173
 
                        trigger_error($msg .  '<br /><br />' . sprintf($user->lang['RETURN_PAGE'], '<a href="' . $redirect . '">', '</a>'));
174
 
                }
175
 
 
176
 
                // Generate the appropriate user information for the user we are looking at
177
 
                if (!function_exists('get_user_avatar'))
178
 
                {
179
 
                        include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
180
 
                }
181
 
 
182
 
                $rank_title = $rank_img = '';
183
 
                $avatar_img = get_user_avatar($userrow['user_avatar'], $userrow['user_avatar_type'], $userrow['user_avatar_width'], $userrow['user_avatar_height']);
184
 
 
185
 
                $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'], 365 => $user->lang['1_YEAR']);
186
 
                $sort_by_text = array('a' => $user->lang['SORT_USERNAME'], 'b' => $user->lang['SORT_DATE'], 'c' => $user->lang['SORT_IP'], 'd' => $user->lang['SORT_ACTION']);
187
 
                $sort_by_sql = array('a' => 'u.username_clean', 'b' => 'l.log_time', 'c' => 'l.log_ip', 'd' => 'l.log_operation');
188
 
 
189
 
                $s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = '';
190
 
                gen_sort_selects($limit_days, $sort_by_text, $st, $sk, $sd, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param);
191
 
 
192
 
                // Define where and sort sql for use in displaying logs
193
 
                $sql_where = ($st) ? (time() - ($st * 86400)) : 0;
194
 
                $sql_sort = $sort_by_sql[$sk] . ' ' . (($sd == 'd') ? 'DESC' : 'ASC');
195
 
 
196
 
                $log_data = array();
197
 
                $log_count = 0;
198
 
                view_log('user', $log_data, $log_count, $config['posts_per_page'], $start, 0, 0, $user_id, $sql_where, $sql_sort);
199
 
 
200
 
                if ($log_count)
201
 
                {
202
 
                        $template->assign_var('S_USER_NOTES', true);
203
 
 
204
 
                        foreach ($log_data as $row)
205
 
                        {
206
 
                                $template->assign_block_vars('usernotes', array(
207
 
                                        'REPORT_BY'             => $row['username_full'],
208
 
                                        'REPORT_AT'             => $user->format_date($row['time']),
209
 
                                        'ACTION'                => $row['action'],
210
 
                                        'IP'                    => $row['ip'],
211
 
                                        'ID'                    => $row['id'])
212
 
                                );
213
 
                        }
214
 
                }
215
 
 
216
 
                $template->assign_vars(array(
217
 
                        'U_POST_ACTION'                 => $this->u_action,
218
 
                        'S_CLEAR_ALLOWED'               => ($auth->acl_get('a_clearlogs')) ? true : false,
219
 
                        'S_SELECT_SORT_DIR'             => $s_sort_dir,
220
 
                        'S_SELECT_SORT_KEY'             => $s_sort_key,
221
 
                        'S_SELECT_SORT_DAYS'    => $s_limit_days,
222
 
 
223
 
                        'L_TITLE'                       => $user->lang['MCP_NOTES_USER'],
224
 
 
225
 
                        'PAGE_NUMBER'           => on_page($log_count, $config['posts_per_page'], $start),
226
 
                        'PAGINATION'            => generate_pagination($this->u_action . "&amp;st=$st&amp;sk=$sk&amp;sd=$sd", $log_count, $config['posts_per_page'], $start),
227
 
                        'TOTAL_REPORTS'         => ($log_count == 1) ? $user->lang['LIST_REPORT'] : sprintf($user->lang['LIST_REPORTS'], $log_count),
228
 
 
229
 
                        'USERNAME'                      => $userrow['username'],
230
 
                        'USER_COLOR'            => (!empty($userrow['user_colour'])) ? $userrow['user_colour'] : '',
231
 
                        'RANK_TITLE'            => $rank_title,
232
 
                        'JOINED'                        => $user->format_date($userrow['user_regdate']),
233
 
                        'POSTS'                         => ($userrow['user_posts']) ? $userrow['user_posts'] : 0,
234
 
                        'WARNINGS'                      => ($userrow['user_warnings']) ? $userrow['user_warnings'] : 0,
235
 
 
236
 
                        'AVATAR_IMG'            => $avatar_img,
237
 
                        'RANK_IMG'                      => $rank_img,
238
 
                        )
239
 
                );
240
 
        }
241
 
 
242
 
}
243
 
 
244
 
?>
 
 
b'\\ No newline at end of file'