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

« back to all changes in this revision

Viewing changes to www/php/phpBB3/includes/acp/acp_inactive.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 acp
5
 
* @version $Id: acp_inactive.php,v 1.19 2007/12/05 13:55:14 acydburn Exp $
6
 
* @copyright (c) 2006 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
 
* @package acp
21
 
*/
22
 
class acp_inactive
23
 
{
24
 
        var $u_action;
25
 
        var $p_master;
26
 
 
27
 
        function acp_inactive(&$p_master)
28
 
        {
29
 
                $this->p_master = &$p_master;
30
 
        }
31
 
 
32
 
        function main($id, $mode)
33
 
        {
34
 
                global $config, $db, $user, $auth, $template;
35
 
                global $phpbb_root_path, $phpbb_admin_path, $phpEx, $table_prefix;
36
 
 
37
 
                include($phpbb_root_path . 'includes/functions_user.' . $phpEx);
38
 
 
39
 
                $user->add_lang('memberlist');
40
 
 
41
 
                $action = request_var('action', '');
42
 
                $mark   = (isset($_REQUEST['mark'])) ? request_var('mark', array(0)) : array();
43
 
                $start  = request_var('start', 0);
44
 
                $submit = isset($_POST['submit']);
45
 
 
46
 
                // Sort keys
47
 
                $sort_days      = request_var('st', 0);
48
 
                $sort_key       = request_var('sk', 'i');
49
 
                $sort_dir       = request_var('sd', 'd');
50
 
 
51
 
                $form_key = 'acp_inactive';
52
 
                add_form_key($form_key);
53
 
 
54
 
                if ($submit && sizeof($mark))
55
 
                {
56
 
                        if ($action !== 'delete' && !check_form_key($form_key))
57
 
                        {
58
 
                                trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING);
59
 
                        }
60
 
 
61
 
                        switch ($action)
62
 
                        {
63
 
                                case 'activate':
64
 
                                case 'delete':
65
 
 
66
 
                                        $sql = 'SELECT user_id, username
67
 
                                                FROM ' . USERS_TABLE . '
68
 
                                                WHERE ' . $db->sql_in_set('user_id', $mark);
69
 
                                        $result = $db->sql_query($sql);
70
 
                                
71
 
                                        $user_affected = array();
72
 
                                        while ($row = $db->sql_fetchrow($result))
73
 
                                        {
74
 
                                                $user_affected[$row['user_id']] = $row['username'];
75
 
                                        }
76
 
                                        $db->sql_freeresult($result);
77
 
 
78
 
                                        if ($action == 'activate')
79
 
                                        {
80
 
                                                if ($config['require_activation'] == USER_ACTIVATION_ADMIN)
81
 
                                                {
82
 
                                                        // Get those 'being activated'...
83
 
                                                        $sql = 'SELECT user_id, username, user_email, user_lang
84
 
                                                                FROM ' . USERS_TABLE . '
85
 
                                                                WHERE ' . $db->sql_in_set('user_id', $mark) . '
86
 
                                                                        AND user_type = ' . USER_INACTIVE;
87
 
                                                        $result = $db->sql_query($sql);
88
 
 
89
 
                                                        $inactive_users = array();
90
 
                                                        while ($row = $db->sql_fetchrow($result))
91
 
                                                        {
92
 
                                                                $inactive_users[] = $row;
93
 
                                                        }
94
 
                                                        $db->sql_freeresult($result);
95
 
                                                }
96
 
 
97
 
                                                user_active_flip('activate', $mark);
98
 
 
99
 
                                                if ($config['require_activation'] == USER_ACTIVATION_ADMIN && !empty($inactive_users))
100
 
                                                {
101
 
                                                        include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx);
102
 
 
103
 
                                                        $messenger = new messenger();
104
 
 
105
 
                                                        foreach ($inactive_users as $row)
106
 
                                                        {
107
 
                                                                $messenger->template('admin_welcome_activated', $row['user_lang']);
108
 
 
109
 
                                                                $messenger->to($row['user_email'], $row['username']);
110
 
 
111
 
                                                                $messenger->headers('X-AntiAbuse: Board servername - ' . $config['server_name']);
112
 
                                                                $messenger->headers('X-AntiAbuse: User_id - ' . $user->data['user_id']);
113
 
                                                                $messenger->headers('X-AntiAbuse: Username - ' . $user->data['username']);
114
 
 
115
 
                                                                $messenger->assign_vars(array(
116
 
                                                                        'USERNAME'      => htmlspecialchars_decode($row['username']))
117
 
                                                                );
118
 
 
119
 
                                                                $messenger->send(NOTIFY_EMAIL);
120
 
                                                        }
121
 
 
122
 
                                                        $messenger->save_queue();
123
 
                                                }
124
 
                                        }
125
 
                                        else if ($action == 'delete')
126
 
                                        {
127
 
                                                if (confirm_box(true))
128
 
                                                {
129
 
                                                        if (!$auth->acl_get('a_userdel'))
130
 
                                                        {
131
 
                                                                trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING);
132
 
                                                        }
133
 
 
134
 
                                                        foreach ($mark as $user_id)
135
 
                                                        {
136
 
                                                                user_delete('retain', $user_id, $user_affected[$user_id]);
137
 
                                                        }
138
 
 
139
 
                                                        add_log('admin', 'LOG_INACTIVE_' . strtoupper($action), implode(', ', $user_affected));
140
 
                                                }
141
 
                                                else
142
 
                                                {
143
 
                                                        $s_hidden_fields = array(
144
 
                                                                'mode'                  => $mode,
145
 
                                                                'action'                => $action,
146
 
                                                                'mark'                  => $mark,
147
 
                                                                'submit'                => 1,
148
 
                                                                'start'                 => $start,
149
 
                                                        );
150
 
                                                        confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields($s_hidden_fields));
151
 
                                                }
152
 
                                        }
153
 
 
154
 
                                break;
155
 
 
156
 
                                case 'remind':
157
 
                                        if (empty($config['email_enable']))
158
 
                                        {
159
 
                                                trigger_error($user->lang['EMAIL_DISABLED'] . adm_back_link($this->u_action), E_USER_WARNING);
160
 
                                        }
161
 
 
162
 
                                        $sql = 'SELECT user_id, username, user_email, user_lang, user_jabber, user_notify_type, user_regdate, user_actkey
163
 
                                                FROM ' . USERS_TABLE . '
164
 
                                                WHERE ' . $db->sql_in_set('user_id', $mark);
165
 
                                        $result = $db->sql_query($sql);
166
 
 
167
 
                                        if ($row = $db->sql_fetchrow($result))
168
 
                                        {
169
 
                                                // Send the messages
170
 
                                                include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx);
171
 
 
172
 
                                                $messenger = new messenger();
173
 
                                                $usernames = array();
174
 
 
175
 
                                                do
176
 
                                                {
177
 
                                                        $messenger->template('user_remind_inactive', $row['user_lang']);
178
 
 
179
 
                                                        $messenger->to($row['user_email'], $row['username']);
180
 
                                                        $messenger->im($row['user_jabber'], $row['username']);
181
 
 
182
 
                                                        $messenger->assign_vars(array(
183
 
                                                                'USERNAME'              => htmlspecialchars_decode($row['username']),
184
 
                                                                'REGISTER_DATE' => $user->format_date($row['user_regdate']),
185
 
                                                                'U_ACTIVATE'    => generate_board_url() . "/ucp.$phpEx?mode=activate&u=" . $row['user_id'] . '&k=' . $row['user_actkey'])
186
 
                                                        );
187
 
 
188
 
                                                        $messenger->send($row['user_notify_type']);
189
 
 
190
 
                                                        $usernames[] = $row['username'];
191
 
                                                }
192
 
                                                while ($row = $db->sql_fetchrow($result));
193
 
 
194
 
                                                $messenger->save_queue();
195
 
 
196
 
                                                add_log('admin', 'LOG_INACTIVE_REMIND', implode(', ', $usernames));
197
 
                                                unset($usernames);
198
 
                                        }
199
 
                                        $db->sql_freeresult($result);
200
 
                
201
 
                                break;
202
 
                        }
203
 
                }
204
 
 
205
 
                // Sorting
206
 
                $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']);
207
 
                $sort_by_text = array('i' => $user->lang['SORT_INACTIVE'], 'j' => $user->lang['SORT_REG_DATE'], 'l' => $user->lang['SORT_LAST_VISIT'], 'r' => $user->lang['SORT_REASON'], 'u' => $user->lang['SORT_USERNAME']);
208
 
                $sort_by_sql = array('i' => 'user_inactive_time', 'j' => 'user_regdate', 'l' => 'user_lastvisit', 'r' => 'user_inactive_reason', 'u' => 'username_clean');
209
 
 
210
 
                $s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = '';
211
 
                gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param);
212
 
 
213
 
                // Define where and sort sql for use in displaying logs
214
 
                $sql_where = ($sort_days) ? (time() - ($sort_days * 86400)) : 0;
215
 
                $sql_sort = $sort_by_sql[$sort_key] . ' ' . (($sort_dir == 'd') ? 'DESC' : 'ASC');
216
 
 
217
 
                $inactive = array();
218
 
                $inactive_count = 0;
219
 
 
220
 
                $start = view_inactive_users($inactive, $inactive_count, $config['topics_per_page'], $start, $sql_where, $sql_sort);
221
 
 
222
 
                foreach ($inactive as $row)
223
 
                {
224
 
                        $template->assign_block_vars('inactive', array(
225
 
                                'INACTIVE_DATE' => $user->format_date($row['user_inactive_time']),
226
 
                                'JOINED'                => $user->format_date($row['user_regdate']),
227
 
                                'LAST_VISIT'    => (!$row['user_lastvisit']) ? ' - ' : $user->format_date($row['user_lastvisit']),
228
 
                                'REASON'                => $row['inactive_reason'],
229
 
                                'USER_ID'               => $row['user_id'],
230
 
                                'USERNAME'              => $row['username'],
231
 
                                'U_USER_ADMIN'  => append_sid("{$phpbb_admin_path}index.$phpEx", "i=users&amp;mode=overview&amp;u={$row['user_id']}"))
232
 
                        );
233
 
                }
234
 
 
235
 
                $option_ary = array('activate' => 'ACTIVATE', 'delete' => 'DELETE');
236
 
                if ($config['email_enable'])
237
 
                {
238
 
                        $option_ary += array('remind' => 'REMIND');
239
 
                }
240
 
 
241
 
                $template->assign_vars(array(
242
 
                        'S_INACTIVE_USERS'              => true,
243
 
                        'S_INACTIVE_OPTIONS'    => build_select($option_ary),
244
 
 
245
 
                        'S_LIMIT_DAYS'  => $s_limit_days,
246
 
                        'S_SORT_KEY'    => $s_sort_key,
247
 
                        'S_SORT_DIR'    => $s_sort_dir,
248
 
                        'S_ON_PAGE'             => on_page($inactive_count, $config['topics_per_page'], $start),
249
 
                        'PAGINATION'    => generate_pagination($this->u_action . "&amp;$u_sort_param", $inactive_count, $config['topics_per_page'], $start, true),
250
 
                        
251
 
                        'U_ACTION'              => $this->u_action . '&amp;start=' . $start,
252
 
                ));
253
 
 
254
 
                $this->tpl_name = 'acp_inactive';
255
 
                $this->page_title = 'ACP_INACTIVE_USERS';
256
 
        }
257
 
}
258
 
 
259
 
?>
 
 
b'\\ No newline at end of file'