2 /************************************************************************
3 * MXChange v0.2.1 Start: 09/28/2003 *
4 * =============== Last change: 06/10/2004 *
6 * -------------------------------------------------------------------- *
7 * File : what-lock_user.php *
8 * -------------------------------------------------------------------- *
9 * Short description : Lock members *
10 * -------------------------------------------------------------------- *
11 * Kurzbeschreibung : Mitglieder sperren *
12 * -------------------------------------------------------------------- *
15 * $Tag:: 0.2.1-FINAL $ *
17 * Needs to be in all Files and every File needs "svn propset *
18 * svn:keywords Date Revision" (autoprobset!) at least!!!!!! *
19 * -------------------------------------------------------------------- *
20 * Copyright (c) 2003 - 2009 by Roland Haeder *
21 * For more information visit: http://www.mxchange.org *
23 * This program is free software; you can redistribute it and/or modify *
24 * it under the terms of the GNU General Public License as published by *
25 * the Free Software Foundation; either version 2 of the License, or *
26 * (at your option) any later version. *
28 * This program is distributed in the hope that it will be useful, *
29 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
30 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
31 * GNU General Public License for more details. *
33 * You should have received a copy of the GNU General Public License *
34 * along with this program; if not, write to the Free Software *
35 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
37 ************************************************************************/
39 // Some security stuff...
40 if ((!defined('__SECURITY')) || (!isAdmin())) {
44 // Add description as navigation point
45 addMenuDescription('admin', __FILE__);
48 if (isGetRequestElementSet('userid')) {
50 $result_user = SQL_QUERY_ESC("SELECT status, gender, surname, family, email FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `userid`=%s LIMIT 1",
51 array(bigintval(getRequestElement('userid'))), __FILE__, __LINE__);
53 if (SQL_NUMROWS($result_user) == 1) {
55 list($status, $gender, $surname, $family, $email) = SQL_FETCHROW($result_user);
58 SQL_FREERESULT($result_user);
60 // Is a lock reason set?
61 if ((isPostRequestElementSet('lock')) && ($status != 'LOCKED')) {
62 // Ok, lock the account!
63 if (getExtensionVersion('user') >= '0.3.5') {
65 SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `status`='LOCKED',lock_reason='%s',lock_timestamp=NOW() WHERE `userid`=%s LIMIT 1",
66 array(postRequestElement('reason'), bigintval(getRequestElement('userid'))), __FILE__, __LINE__);
68 // Lock with no lock reason saved
69 SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `status`='LOCKED' WHERE `userid`=%s LIMIT 1",
70 array(bigintval(getRequestElement('userid'))), __FILE__, __LINE__);
74 if (SQL_AFFECTEDROWS() == 1) {
75 // Send an email to the user! In later version you can optionally switch this feature off
76 $message = loadEmailTemplate('lock-user', array('text' => postRequestElement('reason')), bigintval(getRequestElement('userid')));
79 sendEmail(bigintval(getRequestElement('userid')), ADMIN_LOCKED_SUBJ, $message);
83 $message = sprintf(getMessage('USER_ACCOUNT_LOCKED'), getRequestElement('userid'));
85 } elseif ((isPostRequestElementSet(('unlock'))) && ($status == 'LOCKED')) {
86 // Ok, unlock the account!
87 if (getExtensionVersion('user') >= '0.3.5') {
88 // Reset lock reason as well
90 `{?_MYSQL_PREFIX?}_user_data`
94 `lock_timestamp`='0000-00-00 00:00'
98 array(bigintval(getRequestElement('userid'))), __FILE__, __LINE__);
100 // No lock reason to reset
101 SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `status`='CONFIRMED' WHERE `userid`=%s LIMIT 1",
102 array(bigintval(getRequestElement('userid'))), __FILE__, __LINE__);
106 if (SQL_AFFECTEDROWS() == 1) {
107 // Send an email to the user! In later version you can optionally switch this feature off
108 $message = loadEmailTemplate('unlock-user', array('text' => postRequestElement('reason')), bigintval(getRequestElement('userid')));
111 sendEmail(bigintval(getRequestElement('userid')), getMessage('ADMIN_UNLOCKED_SUBJ'), $message);
112 if (isExtensionActive('rallye')) {
113 addUserToReferalRallye(getRequestElement('userid'));
118 $message = sprintf(getMessage('USER_ACCOUNT_UNLOCKED'), getRequestElement('userid'));
120 } elseif (isPostRequestElementSet('del')) {
121 // Delete the account
123 loadIncludeOnce('inc/modules/admin/what-del_user.php');
124 } elseif (isPostRequestElementSet('no')) {
125 // Do not lock him...
126 $URL = adminCreateUserLink(getRequestElement('userid'));
128 // Load user data we need
129 $result = SQL_QUERY_ESC("SELECT `email`, `surname`, `family` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `userid`=%s LIMIT 1",
130 array(bigintval(getRequestElement('userid'))), __FILE__, __LINE__);
133 if (SQL_NUMROWS($result) == 1) {
135 $DATA = SQL_FETCHARRAY($result);
137 // Transfer data to constants for the template
138 // @TODO Rewrite these all constants
139 $content['email'] = generateEmailLink($DATA['email'], 'user_data');
140 $content['surname'] = $DATA['surname'];
141 $content['fname'] = $DATA['family'];
142 $content['userid'] = bigintval(getRequestElement('userid'));
144 // Realy want to lock?
146 case 'CONFIRMED': // Yes, lock him down... ;-)
147 $content['ok'] = 'lock';
148 $content['header'] = sprintf(getMessage('ADMIN_HEADER_LOCK_ACCOUNT'), $content['userid']);
149 $content['text'] = sprintf(getMessage('ADMIN_TEXT_LOCK_ACCOUNT'), $content['userid']);
152 case 'LOCKED': // Unlock the user
153 $content['ok'] = $lock;
154 $content['header'] = sprintf(getMessage('ADMIN_HEADER_UNLOCK_ACCOUNT'), $content['userid']);
155 $content['text'] = sprintf(getMessage('ADMIN_TEXT_UNLOCK_ACCOUNT'), $content['userid']);
158 case 'UNCONFIRMED': // Unconfirmed accounts cannot be unlocked!
159 $content['ok'] = 'del';
160 $content['header'] = sprintf(getMessage('ADMIN_HEADER_DEL_ACCOUNT'), $content['userid']);
161 $content['text'] = sprintf(getMessage('ADMIN_TEXT_DEL_ACCOUNT'), $content['userid']);
166 loadTemplate('admin_lock_user', false, $content);
168 // Account does not exists!
169 loadTemplate('admin_settings_saved', false, "<div class=\"admin_failed\">".sprintf(getMessage('ADMIN_MEMBER_404'), getRequestElement('userid'))."</div>");
173 SQL_FREERESULT($result);
181 // An action was performed...
182 if (!empty($message)) {
183 loadTemplate('admin_settings_saved', false, "<div class=\"admin_green\">".$message."</div>");
185 loadTemplate('admin_settings_saved', false, "<div class=\"admin_green\">".getMessage('ADMIN_USER_UPDATED')."</div>");
189 // Account does not exists!
190 loadTemplate('admin_settings_saved', false, "<div class=\"admin_failed\">".sprintf(getMessage('ADMIN_MEMBER_404'), getRequestElement('userid'))."</div>");
194 addMemberSelectionBox();