2 /************************************************************************
3 * Mailer v0.2.1-FINAL 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')) {
49 // Action not performed by default
53 if (fetchUserData(getRequestElement('userid'))) {
54 // Is a lock reason set?
55 if ((isPostRequestElementSet('lock')) && (getUserData('status') != 'LOCKED')) {
56 // Ok, lock the account!
57 if (getExtensionVersion('user') >= '0.3.5') {
59 SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `status`='LOCKED', `lock_reason`='%s', `lock_timestamp`=NOW() WHERE `userid`=%s LIMIT 1",
60 array(postRequestElement('reason'), bigintval(getRequestElement('userid'))), __FILE__, __LINE__);
62 // Lock with no lock reason saved
63 SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `status`='LOCKED' WHERE `userid`=%s LIMIT 1",
64 array(bigintval(getRequestElement('userid'))), __FILE__, __LINE__);
68 if (SQL_AFFECTEDROWS() == 1) {
69 // Send an email to the user! In later version you can optionally switch this feature off
70 $message = loadEmailTemplate('lock-user', array('text' => postRequestElement('reason')), bigintval(getRequestElement('userid')));
73 sendEmail(bigintval(getRequestElement('userid')), getMessage('ADMIN_LOCKED_SUBJ'), $message);
77 $message = getMaskedMessage('USER_ACCOUNT_LOCKED', getRequestElement('userid'));
79 } elseif ((isPostRequestElementSet('unlock')) && (getUserData('status') == 'LOCKED')) {
80 // Ok, unlock the account!
81 if (getExtensionVersion('user') >= '0.3.5') {
82 // Reset lock reason as well
84 `{?_MYSQL_PREFIX?}_user_data`
88 `lock_timestamp`='0000-00-00 00:00'
92 array(bigintval(getRequestElement('userid'))), __FILE__, __LINE__);
94 // No lock reason to reset
95 SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `status`='CONFIRMED' WHERE `userid`=%s LIMIT 1",
96 array(bigintval(getRequestElement('userid'))), __FILE__, __LINE__);
100 if (SQL_AFFECTEDROWS() == 1) {
101 // Send an email to the user! In later version you can optionally switch this feature off
102 $message = loadEmailTemplate('unlock-user', array('text' => postRequestElement('reason')), bigintval(getRequestElement('userid')));
105 sendEmail(bigintval(getRequestElement('userid')), getMessage('ADMIN_UNLOCKED_SUBJ'), $message);
106 if (isExtensionActive('rallye')) {
107 addUserToReferalRallye(getRequestElement('userid'));
112 $message = getMaskedMessage('USER_ACCOUNT_UNLOCKED', getRequestElement('userid'));
114 } elseif (isPostRequestElementSet('del')) {
115 // Delete the account
117 loadIncludeOnce('inc/modules/admin/what-del_user.php');
118 } elseif (isPostRequestElementSet('no')) {
119 // Do not lock him...
120 $URL = adminCreateUserLink(getRequestElement('userid'));
122 // Load user data we need
123 if (fetchUserData(getRequestElement('userid'))) {
124 // Transfer data to constants for the template
125 $content['email'] = generateEmailLink(getUserData('email'), 'user_data');
126 $content['surname'] = getUserData('surname');
127 $content['family'] = getUserData('family');
128 $content['status'] = getUserData('status');
129 $content['userid'] = bigintval(getRequestElement('userid'));
131 // Realy want to lock?
132 switch ($content['status']) {
133 case 'CONFIRMED': // Yes, lock him down... ;-)
134 $content['ok'] = 'lock';
135 $content['header'] = getMaskedMessage('ADMIN_HEADER_LOCK_ACCOUNT', $content['userid']);
136 $content['text'] = getMaskedMessage('ADMIN_TEXT_LOCK_ACCOUNT', $content['userid']);
139 case 'LOCKED': // Unlock the user
140 $content['ok'] = 'unlock';
141 $content['header'] = getMaskedMessage('ADMIN_HEADER_UNLOCK_ACCOUNT', $content['userid']);
142 $content['text'] = getMaskedMessage('ADMIN_TEXT_UNLOCK_ACCOUNT', $content['userid']);
145 case 'UNCONFIRMED': // Unconfirmed accounts cannot be unlocked!
146 $content['ok'] = 'del';
147 $content['header'] = getMaskedMessage('ADMIN_HEADER_DEL_ACCOUNT', $content['userid']);
148 $content['text'] = getMaskedMessage('ADMIN_TEXT_DEL_ACCOUNT', $content['userid']);
152 // Translate user status
153 $content['status'] = translateUserStatus($content['status']);
156 loadTemplate('admin_lock_user', false, $content);
158 // Account does not exists!
159 loadTemplate('admin_settings_saved', false, '<div class="admin_failed">' . getMaskedMessage('ADMIN_MEMBER_404', getRequestElement('userid')) . '</div>');
168 // An action was performed...
169 if (!empty($message)) {
170 loadTemplate('admin_settings_saved', false, '<div class="admin_failed">' . $message . '</div>');
172 loadTemplate('admin_settings_saved', false, '<div class="admin_failed">' . getMessage('ADMIN_USER_UPDATED') . '</div>');
176 // Account does not exists!
177 loadTemplate('admin_settings_saved', false, '<div class="admin_failed">' . getMaskedMessage('ADMIN_MEMBER_404', getRequestElement('userid')) . '</div>');
181 addMemberSelectionBox();