Changeset 702 for trunk/forum/includes/acp/acp_users.php
- Timestamp:
- Mar 31, 2010, 6:32:40 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/forum/includes/acp/acp_users.php
r400 r702 3 3 * 4 4 * @package acp 5 * @version $Id : acp_users.php 8831 2008-09-05 19:02:36Z toonarmy$5 * @version $Id$ 6 6 * @copyright (c) 2005 phpBB Group 7 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License … … 386 386 user_active_flip('flip', $user_id); 387 387 388 if ($user_row['user_type'] == USER_INACTIVE) 389 { 390 if ($config['require_activation'] == USER_ACTIVATION_ADMIN) 391 { 392 include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx); 393 394 $messenger = new messenger(false); 395 396 $messenger->template('admin_welcome_activated', $user_row['user_lang']); 397 398 $messenger->to($user_row['user_email'], $user_row['username']); 399 400 $messenger->headers('X-AntiAbuse: Board servername - ' . $config['server_name']); 401 $messenger->headers('X-AntiAbuse: User_id - ' . $user->data['user_id']); 402 $messenger->headers('X-AntiAbuse: Username - ' . $user->data['username']); 403 $messenger->headers('X-AntiAbuse: User IP - ' . $user->ip); 404 405 $messenger->assign_vars(array( 406 'USERNAME' => htmlspecialchars_decode($user_row['username'])) 407 ); 408 409 $messenger->send(NOTIFY_EMAIL); 410 } 411 } 412 388 413 $message = ($user_row['user_type'] == USER_INACTIVE) ? 'USER_ADMIN_ACTIVATED' : 'USER_ADMIN_DEACTIVED'; 389 414 $log = ($user_row['user_type'] == USER_INACTIVE) ? 'LOG_USER_ACTIVE' : 'LOG_USER_INACTIVE'; … … 494 519 } 495 520 521 break; 522 523 case 'deloutbox': 524 525 if (confirm_box(true)) 526 { 527 $msg_ids = array(); 528 $lang = 'EMPTY'; 529 530 $sql = 'SELECT msg_id 531 FROM ' . PRIVMSGS_TO_TABLE . " 532 WHERE author_id = $user_id 533 AND folder_id = " . PRIVMSGS_OUTBOX; 534 $result = $db->sql_query($sql); 535 536 if ($row = $db->sql_fetchrow($result)) 537 { 538 if (!function_exists('delete_pm')) 539 { 540 include($phpbb_root_path . 'includes/functions_privmsgs.' . $phpEx); 541 } 542 543 do 544 { 545 $msg_ids[] = (int) $row['msg_id']; 546 } 547 while ($row = $db->sql_fetchrow($result)); 548 549 $db->sql_freeresult($result); 550 551 delete_pm($user_id, $msg_ids, PRIVMSGS_OUTBOX); 552 553 add_log('admin', 'LOG_USER_DEL_OUTBOX', $user_row['username']); 554 555 $lang = 'EMPTIED'; 556 } 557 $db->sql_freeresult($result); 558 559 trigger_error($user->lang['USER_OUTBOX_' . $lang] . adm_back_link($this->u_action . '&u=' . $user_id)); 560 } 561 else 562 { 563 confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array( 564 'u' => $user_id, 565 'i' => $id, 566 'mode' => $mode, 567 'action' => $action, 568 'update' => true)) 569 ); 570 } 496 571 break; 497 572 … … 651 726 652 727 break; 728 729 case 'leave_nr': 730 731 if (confirm_box(true)) 732 { 733 remove_newly_registered($user_id, $user_row); 734 735 add_log('admin', 'LOG_USER_REMOVED_NR', $user_row['username']); 736 trigger_error($user->lang['USER_LIFTED_NR'] . adm_back_link($this->u_action . '&u=' . $user_id)); 737 } 738 else 739 { 740 confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array( 741 'u' => $user_id, 742 'i' => $id, 743 'mode' => $mode, 744 'action' => $action, 745 'update' => true)) 746 ); 747 } 748 749 break; 653 750 } 654 751 … … 776 873 $sql_ary += array( 777 874 'user_email' => $update_email, 778 'user_email_hash' => crc32($update_email) . strlen($update_email)875 'user_email_hash' => phpbb_email_hash($update_email), 779 876 ); 780 877 … … 821 918 if ($user_id == $user->data['user_id']) 822 919 { 823 $quick_tool_ary = array('delsig' => 'DEL_SIG', 'delavatar' => 'DEL_AVATAR', 'moveposts' => 'MOVE_POSTS', 'delposts' => 'DEL_POSTS', 'delattach' => 'DEL_ATTACH'); 920 $quick_tool_ary = array('delsig' => 'DEL_SIG', 'delavatar' => 'DEL_AVATAR', 'moveposts' => 'MOVE_POSTS', 'delposts' => 'DEL_POSTS', 'delattach' => 'DEL_ATTACH', 'deloutbox' => 'DEL_OUTBOX'); 921 if ($user_row['user_new']) 922 { 923 $quick_tool_ary['leave_nr'] = 'LEAVE_NR'; 924 } 824 925 } 825 926 else … … 837 938 } 838 939 839 $quick_tool_ary += array('delsig' => 'DEL_SIG', 'delavatar' => 'DEL_AVATAR', 'moveposts' => 'MOVE_POSTS', 'delposts' => 'DEL_POSTS', 'delattach' => 'DEL_ATTACH' );940 $quick_tool_ary += array('delsig' => 'DEL_SIG', 'delavatar' => 'DEL_AVATAR', 'moveposts' => 'MOVE_POSTS', 'delposts' => 'DEL_POSTS', 'delattach' => 'DEL_ATTACH', 'deloutbox' => 'DEL_OUTBOX'); 840 941 841 942 if ($config['email_enable'] && ($user_row['user_type'] == USER_NORMAL || $user_row['user_type'] == USER_INACTIVE)) 842 943 { 843 944 $quick_tool_ary['reactivate'] = 'FORCE'; 945 } 946 947 if ($user_row['user_new']) 948 { 949 $quick_tool_ary['leave_nr'] = 'LEAVE_NR'; 844 950 } 845 951 } … … 918 1024 'U_MCP_QUEUE' => ($auth->acl_getf_global('m_approve')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue', true, $user->session_id) : '', 919 1025 920 'U_SWITCH_PERMISSIONS' => ($auth->acl_get('a_switchperm') && $user->data['user_id'] != $user_row['user_id']) ? append_sid("{$phpbb_root_path}ucp.$phpEx", "mode=switch_perm&u={$user_row['user_id']} ") : '',1026 'U_SWITCH_PERMISSIONS' => ($auth->acl_get('a_switchperm') && $user->data['user_id'] != $user_row['user_id']) ? append_sid("{$phpbb_root_path}ucp.$phpEx", "mode=switch_perm&u={$user_row['user_id']}&hash=" . generate_link_hash('switchperm')) : '', 921 1027 922 1028 'POSTS_IN_QUEUE' => $user_row['posts_in_queue'], … … 973 1079 $sql = 'DELETE FROM ' . LOG_TABLE . ' 974 1080 WHERE log_type = ' . LOG_USERS . " 1081 AND reportee_id = $user_id 975 1082 $where_sql"; 976 1083 $db->sql_query($sql); … … 1032 1139 ); 1033 1140 } 1141 1142 break; 1143 1144 case 'warnings': 1145 $user->add_lang('mcp'); 1146 1147 // Set up general vars 1148 $start = request_var('start', 0); 1149 $deletemark = (isset($_POST['delmarked'])) ? true : false; 1150 $deleteall = (isset($_POST['delall'])) ? true : false; 1151 $confirm = (isset($_POST['confirm'])) ? true : false; 1152 $marked = request_var('mark', array(0)); 1153 $message = utf8_normalize_nfc(request_var('message', '', true)); 1154 1155 // Sort keys 1156 $sort_days = request_var('st', 0); 1157 $sort_key = request_var('sk', 't'); 1158 $sort_dir = request_var('sd', 'd'); 1159 1160 // Delete entries if requested and able 1161 if ($deletemark || $deleteall || $confirm) 1162 { 1163 if (confirm_box(true)) 1164 { 1165 $where_sql = ''; 1166 $deletemark = request_var('delmarked', 0); 1167 $deleteall = request_var('delall', 0); 1168 if ($deletemark && $marked) 1169 { 1170 $where_sql = ' AND ' . $db->sql_in_set('warning_id', array_values($marked)); 1171 } 1172 1173 if ($where_sql || $deleteall) 1174 { 1175 $sql = 'DELETE FROM ' . WARNINGS_TABLE . " 1176 WHERE user_id = $user_id 1177 $where_sql"; 1178 $db->sql_query($sql); 1179 1180 if ($deleteall) 1181 { 1182 $log_warnings = $deleted_warnings = 0; 1183 } 1184 else 1185 { 1186 $num_warnings = (int) $db->sql_affectedrows(); 1187 $deleted_warnings = ' user_warnings - ' . $num_warnings; 1188 $log_warnings = ($num_warnings > 2) ? 2 : $num_warnings; 1189 } 1190 1191 $sql = 'UPDATE ' . USERS_TABLE . " 1192 SET user_warnings = $deleted_warnings 1193 WHERE user_id = $user_id"; 1194 $db->sql_query($sql); 1195 1196 switch ($log_warnings) 1197 { 1198 case 2: 1199 add_log('admin', 'LOG_WARNINGS_DELETED', $user_row['username'], $num_warnings); 1200 break; 1201 case 1: 1202 add_log('admin', 'LOG_WARNING_DELETED', $user_row['username']); 1203 break; 1204 default: 1205 add_log('admin', 'LOG_WARNINGS_DELETED_ALL', $user_row['username']); 1206 break; 1207 } 1208 } 1209 } 1210 else 1211 { 1212 $s_hidden_fields = array( 1213 'i' => $id, 1214 'mode' => $mode, 1215 'u' => $user_id, 1216 'mark' => $marked, 1217 ); 1218 if (isset($_POST['delmarked'])) 1219 { 1220 $s_hidden_fields['delmarked'] = 1; 1221 } 1222 if (isset($_POST['delall'])) 1223 { 1224 $s_hidden_fields['delall'] = 1; 1225 } 1226 if (isset($_POST['delall']) || (isset($_POST['delmarked']) && sizeof($marked))) 1227 { 1228 confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields($s_hidden_fields)); 1229 } 1230 } 1231 } 1232 1233 $sql = 'SELECT w.warning_id, w.warning_time, w.post_id, l.log_operation, l.log_data, l.user_id AS mod_user_id, m.username AS mod_username, m.user_colour AS mod_user_colour 1234 FROM ' . WARNINGS_TABLE . ' w 1235 LEFT JOIN ' . LOG_TABLE . ' l 1236 ON (w.log_id = l.log_id) 1237 LEFT JOIN ' . USERS_TABLE . ' m 1238 ON (l.user_id = m.user_id) 1239 WHERE w.user_id = ' . $user_id . ' 1240 ORDER BY w.warning_time DESC'; 1241 $result = $db->sql_query($sql); 1242 1243 while ($row = $db->sql_fetchrow($result)) 1244 { 1245 if (!$row['log_operation']) 1246 { 1247 // We do not have a log-entry anymore, so there is no data available 1248 $row['action'] = $user->lang['USER_WARNING_LOG_DELETED']; 1249 } 1250 else 1251 { 1252 $row['action'] = (isset($user->lang[$row['log_operation']])) ? $user->lang[$row['log_operation']] : '{' . ucfirst(str_replace('_', ' ', $row['log_operation'])) . '}'; 1253 if (!empty($row['log_data'])) 1254 { 1255 $log_data_ary = @unserialize($row['log_data']); 1256 $log_data_ary = ($log_data_ary === false) ? array() : $log_data_ary; 1257 1258 if (isset($user->lang[$row['log_operation']])) 1259 { 1260 // Check if there are more occurrences of % than arguments, if there are we fill out the arguments array 1261 // It doesn't matter if we add more arguments than placeholders 1262 if ((substr_count($row['action'], '%') - sizeof($log_data_ary)) > 0) 1263 { 1264 $log_data_ary = array_merge($log_data_ary, array_fill(0, substr_count($row['action'], '%') - sizeof($log_data_ary), '')); 1265 } 1266 $row['action'] = vsprintf($row['action'], $log_data_ary); 1267 $row['action'] = bbcode_nl2br(censor_text($row['action'])); 1268 } 1269 else if (!empty($log_data_ary)) 1270 { 1271 $row['action'] .= '<br />' . implode('', $log_data_ary); 1272 } 1273 } 1274 } 1275 1276 1277 $template->assign_block_vars('warn', array( 1278 'ID' => $row['warning_id'], 1279 'USERNAME' => ($row['log_operation']) ? get_username_string('full', $row['mod_user_id'], $row['mod_username'], $row['mod_user_colour']) : '-', 1280 'ACTION' => make_clickable($row['action']), 1281 'DATE' => $user->format_date($row['warning_time']), 1282 )); 1283 } 1284 $db->sql_freeresult($result); 1285 1286 $template->assign_vars(array( 1287 'S_WARNINGS' => true, 1288 )); 1034 1289 1035 1290 break; … … 1136 1391 1137 1392 // Update Custom Fields 1138 if (sizeof($cp_data)) 1139 { 1140 switch ($db->sql_layer) 1141 { 1142 case 'oracle': 1143 case 'firebird': 1144 case 'postgres': 1145 $right_delim = $left_delim = '"'; 1146 break; 1147 1148 case 'sqlite': 1149 case 'mssql': 1150 case 'mssql_odbc': 1151 $right_delim = ']'; 1152 $left_delim = '['; 1153 break; 1154 1155 case 'mysql': 1156 case 'mysql4': 1157 case 'mysqli': 1158 $right_delim = $left_delim = '`'; 1159 break; 1160 } 1161 1162 foreach ($cp_data as $key => $value) 1163 { 1164 $cp_data[$left_delim . $key . $right_delim] = $value; 1165 unset($cp_data[$key]); 1166 } 1167 1168 $sql = 'UPDATE ' . PROFILE_FIELDS_DATA_TABLE . ' 1169 SET ' . $db->sql_build_array('UPDATE', $cp_data) . " 1170 WHERE user_id = $user_id"; 1171 $db->sql_query($sql); 1172 1173 if (!$db->sql_affectedrows()) 1174 { 1175 $cp_data['user_id'] = (int) $user_id; 1176 1177 $db->sql_return_on_error(true); 1178 1179 $sql = 'INSERT INTO ' . PROFILE_FIELDS_DATA_TABLE . ' ' . $db->sql_build_array('INSERT', $cp_data); 1180 $db->sql_query($sql); 1181 1182 $db->sql_return_on_error(false); 1183 } 1184 } 1393 $cp->update_profile_field_data($user_id, $cp_data); 1185 1394 1186 1395 trigger_error($user->lang['USER_PROFILE_UPDATED'] . adm_back_link($this->u_action . '&u=' . $user_id)); … … 1208 1417 $now = getdate(); 1209 1418 $s_birthday_year_options = '<option value="0"' . ((!$data['bday_year']) ? ' selected="selected"' : '') . '>--</option>'; 1210 for ($i = $now['year'] - 100; $i < $now['year']; $i++)1419 for ($i = $now['year'] - 100; $i <= $now['year']; $i++) 1211 1420 { 1212 1421 $selected = ($i == $data['bday_year']) ? ' selected="selected"' : ''; … … 1475 1684 } 1476 1685 1686 if (!$config['allow_avatar'] && $user_row['user_avatar_type']) 1687 { 1688 $error[] = $user->lang['USER_AVATAR_NOT_ALLOWED']; 1689 } 1690 else if ((($user_row['user_avatar_type'] == AVATAR_UPLOAD) && !$config['allow_avatar_upload']) || 1691 (($user_row['user_avatar_type'] == AVATAR_REMOTE) && !$config['allow_avatar_remote']) || 1692 (($user_row['user_avatar_type'] == AVATAR_GALLERY) && !$config['allow_avatar_local'])) 1693 { 1694 $error[] = $user->lang['USER_AVATAR_TYPE_NOT_ALLOWED']; 1695 } 1696 1477 1697 // Generate users avatar 1478 $avatar_img = ($user_row['user_avatar']) ? get_user_avatar($user_row['user_avatar'], $user_row['user_avatar_type'], $user_row['user_avatar_width'], $user_row['user_avatar_height'] ) : '<img src="' . $phpbb_admin_path . 'images/no_avatar.gif" alt="" />';1698 $avatar_img = ($user_row['user_avatar']) ? get_user_avatar($user_row['user_avatar'], $user_row['user_avatar_type'], $user_row['user_avatar_width'], $user_row['user_avatar_height'], 'USER_AVATAR', true) : '<img src="' . $phpbb_admin_path . 'images/no_avatar.gif" alt="" />'; 1479 1699 1480 1700 $display_gallery = (isset($_POST['display_gallery'])) ? true : false; … … 1489 1709 $template->assign_vars(array( 1490 1710 'S_AVATAR' => true, 1491 'S_CAN_UPLOAD' => ($can_upload && $config['allow_avatar_upload']) ? true : false, 1492 'S_ALLOW_REMOTE' => ($config['allow_avatar_remote']) ? true : false, 1493 'S_DISPLAY_GALLERY' => ($config['allow_avatar_local'] && !$display_gallery) ? true : false, 1494 'S_IN_GALLERY' => ($config['allow_avatar_local'] && $display_gallery) ? true : false, 1711 'S_CAN_UPLOAD' => $can_upload, 1712 'S_UPLOAD_FILE' => ($config['allow_avatar'] && $can_upload && $config['allow_avatar_upload']) ? true : false, 1713 'S_REMOTE_UPLOAD' => ($config['allow_avatar'] && $can_upload && $config['allow_avatar_remote_upload']) ? true : false, 1714 'S_ALLOW_REMOTE' => ($config['allow_avatar'] && $config['allow_avatar_remote']) ? true : false, 1715 'S_DISPLAY_GALLERY' => ($config['allow_avatar'] && $config['allow_avatar_local'] && !$display_gallery) ? true : false, 1716 'S_IN_GALLERY' => ($config['allow_avatar'] && $config['allow_avatar_local'] && $display_gallery) ? true : false, 1495 1717 1496 1718 'AVATAR_IMAGE' => $avatar_img, … … 1550 1772 include_once($phpbb_root_path . 'includes/functions_display.' . $phpEx); 1551 1773 1552 $enable_bbcode = ($config['allow_sig_bbcode']) ? ( (request_var('disable_bbcode', !$user->optionget('bbcode'))) ? false : true) : false;1553 $enable_smilies = ($config['allow_sig_smilies']) ? ( (request_var('disable_smilies', !$user->optionget('smilies'))) ? false : true) : false;1554 $enable_urls = ($config['allow_sig_links']) ? ( (request_var('disable_magic_url', false)) ? false : true) : false;1774 $enable_bbcode = ($config['allow_sig_bbcode']) ? (bool) $this->optionget($user_row, 'sig_bbcode') : false; 1775 $enable_smilies = ($config['allow_sig_smilies']) ? (bool) $this->optionget($user_row, 'sig_smilies') : false; 1776 $enable_urls = ($config['allow_sig_links']) ? (bool) $this->optionget($user_row, 'sig_links') : false; 1555 1777 $signature = utf8_normalize_nfc(request_var('signature', (string) $user_row['user_sig'], true)); 1556 1778 … … 1560 1782 { 1561 1783 include_once($phpbb_root_path . 'includes/message_parser.' . $phpEx); 1784 1785 $enable_bbcode = ($config['allow_sig_bbcode']) ? ((request_var('disable_bbcode', false)) ? false : true) : false; 1786 $enable_smilies = ($config['allow_sig_smilies']) ? ((request_var('disable_smilies', false)) ? false : true) : false; 1787 $enable_urls = ($config['allow_sig_links']) ? ((request_var('disable_magic_url', false)) ? false : true) : false; 1562 1788 1563 1789 $message_parser = new parse_message($signature); … … 1578 1804 if (!sizeof($error) && $submit) 1579 1805 { 1806 $this->optionset($user_row, 'sig_bbcode', $enable_bbcode); 1807 $this->optionset($user_row, 'sig_smilies', $enable_smilies); 1808 $this->optionset($user_row, 'sig_links', $enable_urls); 1809 1580 1810 $sql_ary = array( 1581 1811 'user_sig' => (string) $message_parser->message, 1812 'user_options' => $user_row['user_options'], 1582 1813 'user_sig_bbcode_uid' => (string) $message_parser->bbcode_uid, 1583 1814 'user_sig_bbcode_bitfield' => (string) $message_parser->bbcode_bitfield … … 1847 2078 1848 2079 $error = array(); 2080 2081 // The delete action was successful - therefore update the user row... 2082 $sql = 'SELECT u.*, s.* 2083 FROM ' . USERS_TABLE . ' u 2084 LEFT JOIN ' . SESSIONS_TABLE . ' s ON (s.session_user_id = u.user_id) 2085 WHERE u.user_id = ' . $user_id . ' 2086 ORDER BY s.session_time DESC'; 2087 $result = $db->sql_query($sql); 2088 $user_row = $db->sql_fetchrow($result); 2089 $db->sql_freeresult($result); 1849 2090 } 1850 2091 else … … 1860 2101 1861 2102 break; 2103 2104 case 'approve': 2105 2106 if (confirm_box(true)) 2107 { 2108 if (!$group_id) 2109 { 2110 trigger_error($user->lang['NO_GROUP'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); 2111 } 2112 group_user_attributes($action, $group_id, $user_id); 2113 } 2114 else 2115 { 2116 confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array( 2117 'u' => $user_id, 2118 'i' => $id, 2119 'mode' => $mode, 2120 'action' => $action, 2121 'g' => $group_id)) 2122 ); 2123 } 2124 2125 break; 1862 2126 } 1863 2127 … … 1952 2216 'U_DEMOTE_PROMOTE' => $this->u_action . '&action=' . (($data['group_leader']) ? 'demote' : 'promote') . "&u=$user_id&g=" . $data['group_id'], 1953 2217 'U_DELETE' => $this->u_action . "&action=delete&u=$user_id&g=" . $data['group_id'], 2218 'U_APPROVE' => ($group_type == 'pending') ? $this->u_action . "&action=approve&u=$user_id&g=" . $data['group_id'] : '', 1954 2219 1955 2220 'GROUP_NAME' => ($group_type == 'special') ? $user->lang['G_' . $data['group_name']] : $data['group_name'], 1956 2221 'L_DEMOTE_PROMOTE' => ($data['group_leader']) ? $user->lang['GROUP_DEMOTE'] : $user->lang['GROUP_PROMOTE'], 1957 2222 2223 'S_IS_MEMBER' => ($group_type != 'pending') ? true : false, 1958 2224 'S_NO_DEFAULT' => ($user_row['group_id'] != $data['group_id']) ? true : false, 1959 2225 'S_SPECIAL_GROUP' => ($group_type == 'special') ? true : false,
Note:
See TracChangeset
for help on using the changeset viewer.