Damn typo fixed... ;-)
[mailer.git] / inc / modules / admin / what-lock_user.php
1 <?php
2 /************************************************************************
3  * MXChange v0.2.1                                    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  * 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 - 2008 by Roland Haeder                           *
21  * For more information visit: http://www.mxchange.org                  *
22  *                                                                      *
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.                                  *
27  *                                                                      *
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.                         *
32  *                                                                      *
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,               *
36  * MA  02110-1301  USA                                                  *
37  ************************************************************************/
38
39 // Some security stuff...
40 if ((!defined('__SECURITY')) || (!IS_ADMIN())) {
41         $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
42         require($INC);
43 }
44
45 // Add description as navigation point
46 ADD_DESCR("admin", __FILE__);
47
48 // Is a userid set?
49 if (REQUEST_ISSET_GET(('uid'))) {
50         // Load user's data
51         $result_user = SQL_QUERY_ESC("SELECT status, gender, surname, family, email FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s LIMIT 1",
52          array(bigintval(REQUEST_GET('uid'))), __FILE__, __LINE__);
53         $ACT = false;
54         if (SQL_NUMROWS($result_user) == 1) {
55                 // User found
56                 list($status, $gender, $sname, $fname, $email) = SQL_FETCHROW($result_user);
57
58                 // Free result
59                 SQL_FREERESULT($result_user);
60
61                 // Is a lock reason set?
62                 if ((REQUEST_ISSET_POST(('lock'))) && ($status != "LOCKED")) {
63                         // Ok, lock the account!
64                         if (GET_EXT_VERSION("user") >= "0.3.5") {
65                                 // Lock with reason
66                                 SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_user_data` SET `status`='LOCKED',lock_reason='%s',lock_timestamp=NOW() WHERE userid=%s LIMIT 1",
67                                         array(REQUEST_POST('reason'), bigintval(REQUEST_GET('uid'))), __FILE__, __LINE__);
68                         } else {
69                                 // Lock with no lock reason saved
70                                 SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_user_data` SET `status`='LOCKED' WHERE userid=%s LIMIT 1",
71                                         array(bigintval(REQUEST_GET('uid'))), __FILE__, __LINE__);
72                         }
73
74                         // Entry updated?
75                         if (SQL_AFFECTEDROWS() == 1) {
76                                 // Send an email to the user! In later version you can optionally switch this feature off
77                                 $msg = LOAD_EMAIL_TEMPLATE("lock-user", array('text' => REQUEST_POST('reason')), bigintval(REQUEST_GET('uid')));
78
79                                 // Send away...
80                                 SEND_EMAIL(bigintval(REQUEST_GET('uid')), ADMIN_LOCKED_SUBJ, $msg);
81                         } // END - if
82
83                         // Prepare message
84                         $MSG = USER_ACCOUNT_LOCKED_1.REQUEST_GET('uid').USER_ACCOUNT_LOCKED_2;
85                         $ACT = true;
86                 } elseif ((REQUEST_ISSET_POST(('unlock'))) && ($status == "LOCKED")) {
87                         // Ok, unlock the account!
88                         if (GET_EXT_VERSION("user") >= "0.3.5") {
89                                 // Reset lock reason as well
90                                 SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_user_data` SET `status`='CONFIRMED',lock_reason='',lock_timestamp='0000-00-00 00:00' WHERE userid=%s LIMIT 1",
91                                         array(bigintval(REQUEST_GET('uid'))), __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(REQUEST_GET('uid'))), __FILE__, __LINE__);
96                         }
97
98                         // Entry updated?
99                         if (SQL_AFFECTEDROWS() == 1) {
100                                 // Send an email to the user! In later version you can optionally switch this feature off
101                                 $msg = LOAD_EMAIL_TEMPLATE("unlock-user", array('text' => REQUEST_POST('reason')), bigintval(REQUEST_GET('uid')));
102
103                                 // Send away...
104                                 SEND_EMAIL(bigintval(REQUEST_GET('uid')), getMessage('ADMIN_UNLOCKED_SUBJ'), $msg);
105                                 if (EXT_IS_ACTIVE("rallye")) {
106                                         RALLYE_AUTOADD_USER(REQUEST_GET('uid'));
107                                 } // END - if
108                         } // END - if
109
110                         // Prepare message
111                         $MSG = USER_ACCOUNT_UNLOCKED_1.REQUEST_GET('uid').USER_ACCOUNT_UNLOCKED_2;
112                         $ACT = true;
113                 } elseif (REQUEST_ISSET_POST('del')) {
114                         // Delete the account
115                         $ACT = true;
116                         LOAD_INC_ONCE("inc/modules/admin/what-del_user.php");
117                 } elseif (REQUEST_ISSET_POST(('no'))) {
118                         // Do not lock him...
119                         $URL = "modules.php?module=admin&amp;what=list_user&amp;uid=".bigintval(REQUEST_GET('uid'));
120                 } else {
121                         $result = SQL_QUERY_ESC("SELECT email, surname, family FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s LIMIT 1",
122                                 array(bigintval(REQUEST_GET('uid'))), __FILE__, __LINE__);
123
124                         // Entry found?
125                         if (SQL_NUMROWS($result) == 1) {
126                                 // Load data
127                                 list ($email, $sname, $fname) = SQL_FETCHROW($result);
128
129                                 // Free result
130                                 SQL_FREERESULT($result);
131
132                                 // Transfer data to constants for the template
133                                 define('__EMAIL', CREATE_EMAIL_LINK($email, "user_data"));
134                                 define('__SNAME', $sname);
135                                 define('__FNAME', $fname);
136                                 define('__UID'  , bigintval(REQUEST_GET('uid')));
137
138                                 // Realy want to lock?
139                                 switch ($status)
140                                 {
141                                 case "CONFIRMED": // Yes, lock him down... ;-)
142                                         define('__OK_VALUE'    , "lock");
143                                         define('__HEADER_VALUE', ADMIN_HEADER_LOCK_ACCOUNT_1.__UID.ADMIN_HEADER_LOCK_ACCOUNT_2);
144                                         define('__TEXT_VALUE'  , ADMIN_TEXT_LOCK_ACCOUNT_1.__UID.ADMIN_TEXT_LOCK_ACCOUNT_2);
145                                         break;
146
147                                 case "LOCKED": // Unlock the user
148                                         define('__OK_VALUE'    , "unlock");
149                                         define('__HEADER_VALUE', ADMIN_HEADER_UNLOCK_ACCOUNT_1.__UID.ADMIN_HEADER_UNLOCK_ACCOUNT_2);
150                                         define('__TEXT_VALUE'  , ADMIN_TEXT_UNLOCK_ACCOUNT_1.__UID.ADMIN_TEXT_UNLOCK_ACCOUNT_2);
151                                         break;
152
153                                 case "UNCONFIRMED": // Unconfirmed accounts cannot be unlocked!
154                                         define('__OK_VALUE'    , "del");
155                                         define('__HEADER_VALUE', ADMIN_HEADER_DEL_ACCOUNT_1.__UID.ADMIN_HEADER_DEL_ACCOUNT_2);
156                                         define('__TEXT_VALUE'  , ADMIN_TEXT_DEL_ACCOUNT_1.__UID.ADMIN_TEXT_DEL_ACCOUNT_2);
157                                         break;
158                                 }
159
160                                 // Output form
161                                 LOAD_TEMPLATE("admin_lock_user");
162                         } else {
163                                 // Account does not exists!
164                                 LOAD_TEMPLATE("admin_settings_saved", false, "<div class=\"admin_failed\">".sprintf(getMessage('ADMIN_MEMBER_404'), REQUEST_GET('uid'))."</div>");
165                         }
166                 }
167
168                 // Is an URL set?
169                 if (!empty($URL)) {
170                         // Reload and die...
171                         LOAD_URL($URL);
172                 } elseif ($ACT) {
173                         // An action was performed...
174                         if (!empty($MSG)) {
175                                 LOAD_TEMPLATE("admin_settings_saved", false, "<div class=\"admin_green\">".$MSG."</div>");
176                         } else {
177                                 LOAD_TEMPLATE("admin_settings_saved", false, "<div class=\"admin_green\">".getMessage('ADMIN_USER_UPDATED')."</div>");
178                         }
179                 }
180         } else {
181                 // Account does not exists!
182                 LOAD_TEMPLATE("admin_settings_saved", false, "<div class=\"admin_failed\">".sprintf(getMessage('ADMIN_MEMBER_404'), REQUEST_GET('uid'))."</div>");
183         }
184 } else {
185         // List all users
186         ADD_MEMBER_SELECTION_BOX();
187 }
188
189 //
190 ?>