Some language strings fixed, renamed. Copyright notice updated
[mailer.git] / inc / modules / admin / what-lock_user.php
1 <?php
2 /************************************************************************
3  * Mailer v0.2.1-FINAL                                Start: 09/28/2003 *
4  * ===================                          Last change: 06/10/2004 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : what-lock_user.php                               *
8  * -------------------------------------------------------------------- *
9  * Short description : Lock members                                     *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Mitglieder sperren                               *
12  * -------------------------------------------------------------------- *
13  * $Revision::                                                        $ *
14  * $Date::                                                            $ *
15  * $Tag:: 0.2.1-FINAL                                                 $ *
16  * $Author::                                                          $ *
17  * -------------------------------------------------------------------- *
18  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
19  * Copyright (c) 2009 - 2011 by Mailer Developer Team                   *
20  * For more information visit: http://www.mxchange.org                  *
21  *                                                                      *
22  * This program is free software; you can redistribute it and/or modify *
23  * it under the terms of the GNU General Public License as published by *
24  * the Free Software Foundation; either version 2 of the License, or    *
25  * (at your option) any later version.                                  *
26  *                                                                      *
27  * This program is distributed in the hope that it will be useful,      *
28  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
29  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
30  * GNU General Public License for more details.                         *
31  *                                                                      *
32  * You should have received a copy of the GNU General Public License    *
33  * along with this program; if not, write to the Free Software          *
34  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
35  * MA  02110-1301  USA                                                  *
36  ************************************************************************/
37
38 // Some security stuff...
39 if ((!defined('__SECURITY')) || (!isAdmin())) {
40         die();
41 } // END - if
42
43 // Add description as navigation point
44 addYouAreHereLink('admin', __FILE__);
45
46 // Is a userid set?
47 if (isGetRequestParameterSet('userid')) {
48         // Action not performed by default
49         $isActive = false;
50
51         // Load user's data
52         if (fetchUserData(getRequestParameter('userid'))) {
53                 // Is a lock reason set?
54                 if ((isFormSent('lock')) && (getUserData('status') != 'LOCKED')) {
55                         // Ok, lock the account!
56                         if (isExtensionInstalledAndNewer('user', '0.3.5')) {
57                                 // Lock with reason
58                                 SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `status`='LOCKED', `lock_reason`='%s', `lock_timestamp`=NOW() WHERE `userid`=%s LIMIT 1",
59                                         array(postRequestParameter('reason'), bigintval(getRequestParameter('userid'))), __FILE__, __LINE__);
60                         } else {
61                                 // Lock with no lock reason saved
62                                 SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `status`='LOCKED' WHERE `userid`=%s LIMIT 1",
63                                         array(bigintval(getRequestParameter('userid'))), __FILE__, __LINE__);
64                         }
65
66                         // Entry updated?
67                         if (!SQL_HASZEROAFFECTED()) {
68                                 // Send an email to the user! In later version you can optionally switch this feature off
69                                 $message = loadEmailTemplate('lock-user', array('text' => postRequestParameter('reason')), bigintval(getRequestParameter('userid')));
70
71                                 // Send away...
72                                 sendEmail(bigintval(getRequestParameter('userid')), '{--ADMIN_LOCKED_SUBJECT--}', $message);
73                         } // END - if
74
75                         // Prepare message
76                         $message = getMaskedMessage('ADMIN_USER_ACCOUNT_LOCKED', bigintval(getRequestParameter('userid')));
77                         $isActive = true;
78                 } elseif ((isPostRequestParameterSet('unlock')) && (getUserData('status') == 'LOCKED')) {
79                         // Ok, unlock the account!
80                         if (isExtensionInstalledAndNewer('user', '0.3.5')) {
81                                 // Reset lock reason as well
82                                 SQL_QUERY_ESC("UPDATE
83         `{?_MYSQL_PREFIX?}_user_data`
84 SET
85         `status`='CONFIRMED',
86         `lock_reason`='',
87         `lock_timestamp`=NULL
88 WHERE
89         `userid`=%s
90 LIMIT 1",
91                                         array(bigintval(getRequestParameter('userid'))), __FILE__, __LINE__);
92                         } else {
93                                 // No lock reason to reset
94                                 SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `status`='CONFIRMED' WHERE `userid`=%s LIMIT 1",
95                                         array(bigintval(getRequestParameter('userid'))), __FILE__, __LINE__);
96                         }
97
98                         // Entry updated?
99                         if (!SQL_HASZEROAFFECTED()) {
100                                 // Send an email to the user! In later version you can optionally switch this feature off
101                                 $message = loadEmailTemplate('unlock-user', array('text' => postRequestParameter('reason')), bigintval(getRequestParameter('userid')));
102
103                                 // Send away...
104                                 sendEmail(bigintval(getRequestParameter('userid')), '{--ADMIN_UNLOCKED_SUBJECT--}', $message);
105                                 if (isExtensionActive('rallye')) {
106                                         addUserToReferalRallye(getRequestParameter('userid'));
107                                 } // END - if
108                         } // END - if
109
110                         // Prepare message
111                         $message = getMaskedMessage('ADMIN_USER_ACCOUNT_UNLOCKED', bigintval(getRequestParameter('userid')));
112                         $isActive = true;
113                 } elseif (isFormSent('delete')) {
114                         // Delete the account
115                         $isActive = true;
116                         loadIncludeOnce('inc/modules/admin/what-del_user.php');
117                 } elseif (isPostRequestParameterSet('no')) {
118                         // Do not lock him...
119                         $url = adminCreateUserLink(getRequestParameter('userid'));
120                 } else {
121                         // Load user data we need
122                         if (fetchUserData(getRequestParameter('userid'))) {
123                                 // Transfer data to constants for the template
124                                 $content['userid']  = getRequestParameter('userid');
125
126                                 // Realy want to lock?
127                                 switch (getUserData('status')) {
128                                         case 'CONFIRMED': // Yes, lock him down... ;-)
129                                                 $content['ok']     = 'lock';
130                                                 $content['header'] = getMaskedMessage('ADMIN_HEADER_LOCK_ACCOUNT', $content['userid']);
131                                                 $content['text']   = getMaskedMessage('ADMIN_TEXT_LOCK_ACCOUNT', $content['userid']);
132                                                 break;
133
134                                         case 'LOCKED': // Unlock the user
135                                                 $content['ok']     = 'unlock';
136                                                 $content['header'] = getMaskedMessage('ADMIN_HEADER_UNLOCK_ACCOUNT', $content['userid']);
137                                                 $content['text']   = getMaskedMessage('ADMIN_TEXT_UNLOCK_ACCOUNT', $content['userid']);
138                                                 break;
139
140                                         case 'UNCONFIRMED': // Unconfirmed accounts cannot be unlocked!
141                                                 $content['ok'] = 'delete';
142                                                 $content['header'] = getMaskedMessage('ADMIN_HEADER_DELETE_ACCOUNT', $content['userid']);
143                                                 $content['text']   = getMaskedMessage('ADMIN_TEXT_DELETE_ACCOUNT', $content['userid']);
144                                                 break;
145                                 }
146
147                                 // Output form
148                                 loadTemplate('admin_lock_user', false, $content);
149                         } else {
150                                 // Account does not exists!
151                                 loadTemplate('admin_settings_unsaved', false, getMaskedMessage('ADMIN_MEMBER_404', bigintval(getRequestParameter('userid'))) . '</div>');
152                         }
153                 }
154
155                 // Is an URL set?
156                 if (!empty($url)) {
157                         // Reload and die...
158                         redirectToUrl($url);
159                 } elseif ($isActive) {
160                         // An action was performed...
161                         if (!empty($message)) {
162                                 loadTemplate('admin_settings_unsaved', false, $message);
163                         } else {
164                                 loadTemplate('admin_settings_saved', false, '{--ADMIN_USER_UPDATED--}');
165                         }
166                 }
167         } else {
168                 // Account does not exists!
169                 loadTemplate('admin_settings_unsaved', false, getMaskedMessage('ADMIN_MEMBER_404', bigintval(getRequestParameter('userid'))));
170         }
171 } else {
172         // List all users
173         addMemberSelectionBox();
174 }
175
176 // [EOF]
177 ?>