Another column fix
[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  *                                                                      *
14  * -------------------------------------------------------------------- *
15  * Copyright (c) 2003 - 2008 by Roland Haeder                           *
16  * For more information visit: http://www.mxchange.org                  *
17  *                                                                      *
18  * This program is free software; you can redistribute it and/or modify *
19  * it under the terms of the GNU General Public License as published by *
20  * the Free Software Foundation; either version 2 of the License, or    *
21  * (at your option) any later version.                                  *
22  *                                                                      *
23  * This program is distributed in the hope that it will be useful,      *
24  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
25  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
26  * GNU General Public License for more details.                         *
27  *                                                                      *
28  * You should have received a copy of the GNU General Public License    *
29  * along with this program; if not, write to the Free Software          *
30  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
31  * MA  02110-1301  USA                                                  *
32  ************************************************************************/
33
34 // Some security stuff...
35 if ((!defined('__SECURITY')) || (!IS_ADMIN())) {
36         $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
37         require($INC);
38 }
39
40 // Add description as navigation point
41 ADD_DESCR("admin", basename(__FILE__));
42
43 if (!empty($_GET['u_id']))
44 {
45         $result_user = SQL_QUERY_ESC("SELECT status, gender, surname, family, email FROM "._MYSQL_PREFIX."_user_data WHERE userid=%s LIMIT 1",
46          array(bigintval($_GET['u_id'])), __FILE__, __LINE__);
47         $ACT = false;
48         if (SQL_NUMROWS($result_user) == 1)
49         {
50                 // User found
51                 list($status, $gender, $sname, $fname, $email) = SQL_FETCHROW($result_user);
52                 SQL_FREERESULT($result_user);
53                 if (empty($_GET['u_id']))
54                 {
55                         // Output selection form with all confirmed user accounts listed
56                         ADD_MEMBER_SELECTION_BOX();
57                 } elseif (!empty($_POST['lock'])) {
58                         // Ok, lock the account!
59                         $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_user_data SET status='LOCKED' WHERE userid=%s LIMIT 1",
60                          array(bigintval($_GET['u_id'])), __FILE__, __LINE__);
61                         if (SQL_AFFECTEDROWS() == 1)
62                         {
63                                 // Send an email to the user! In later version you can optionally switch this feature off
64                                 $msg = LOAD_EMAIL_TEMPLATE("lock-user", array('text' => $_POST['reason']), bigintval($_GET['u_id']));
65
66                                 // Send away...
67                                 SEND_EMAIL(bigintval($_GET['u_id']), ADMIN_LOCKED_SUBJ, $msg);
68                         }
69
70                         // Prepare message
71                         $MSG = USER_ACCOUNT_LOCKED_1.$_GET['u_id'].USER_ACCOUNT_LOCKED_2;
72                         $ACT = true;
73                 } elseif (!empty($_POST['unlock'])) {
74                         // Ok, unlock the account!
75                         $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_user_data SET status='CONFIRMED' WHERE userid=%s LIMIT 1",
76                          array(bigintval($_GET['u_id'])), __FILE__, __LINE__);
77                         if (SQL_AFFECTEDROWS() == 1)
78                         {
79                                 // Send an email to the user! In later version you can optionally switch this feature off
80                                 $msg = LOAD_EMAIL_TEMPLATE("unlock-user", array('text' => $_POST['reason']), bigintval($_GET['u_id']));
81
82                                 // Send away...
83                                 SEND_EMAIL(bigintval($_GET['u_id']), ADMIN_UNLOCKED_SUBJ, $msg);
84                                 if (EXT_IS_ACTIVE("rallye"))
85                                 {
86                                         RALLYE_AUTOADD_USER($_GET['u_id']);
87                                 }
88                         }
89
90                         // Prepare message
91                         $MSG = USER_ACCOUNT_UNLOCKED_1.$_GET['u_id'].USER_ACCOUNT_UNLOCKED_2;
92                         $ACT = true;
93                 }
94                  elseif (isset($_POST['del']))
95                 {
96                         // Delete the account
97                         $ACT = true;
98                         require_once(PATH."inc/modules/admin/what-del_user.php");
99                 }
100                  elseif (!empty($_POST['no']))
101                 {
102                         // Do not lock him...
103                         $URL = URL."/modules.php?module=admin&amp;what=list_user&amp;u_id=".$_GET['u_id'];
104                 }
105                  else
106                 {
107                         $result = SQL_QUERY_ESC("SELECT email, surname, family FROM "._MYSQL_PREFIX."_user_data WHERE userid=%s LIMIT 1",
108                          array(bigintval($_GET['u_id'])), __FILE__, __LINE__);
109                         if (SQL_NUMROWS($result) == 1)
110                         {
111                                 // Load data
112                                 list ($email, $sname, $fname) = SQL_FETCHROW($result);
113                                 SQL_FREERESULT($result);
114
115                                 // Transfer data to constants for the template
116                                 define('__EMAIL', CREATE_EMAIL_LINK($email, "user_data"));
117                                 define('__SNAME', $sname);
118                                 define('__FNAME', $fname);
119                                 define('__UID'  , $_GET['u_id']);
120
121                                 // Transfer data to constants for the template
122                                 define('__UID_VALUE', $_GET['u_id']);
123
124                                 // Realy want to lock?
125                                 switch ($status)
126                                 {
127                                 case "CONFIRMED": // Yes, lock him down... ;-)
128                                         define('__OK_VALUE'    , "lock");
129                                         define('__HEADER_VALUE', ADMIN_HEADER_LOCK_ACCOUNT_1.__UID_VALUE.ADMIN_HEADER_LOCK_ACCOUNT_2);
130                                         define('__TEXT_VALUE'  , ADMIN_TEXT_LOCK_ACCOUNT_1.__UID_VALUE.ADMIN_TEXT_LOCK_ACCOUNT_2);
131                                         break;
132
133                                 case "LOCKED": // Unlock the user
134                                         define('__OK_VALUE'    , "unlock");
135                                         define('__HEADER_VALUE', ADMIN_HEADER_UNLOCK_ACCOUNT_1.__UID_VALUE.ADMIN_HEADER_UNLOCK_ACCOUNT_2);
136                                         define('__TEXT_VALUE'  , ADMIN_TEXT_UNLOCK_ACCOUNT_1.__UID_VALUE.ADMIN_TEXT_UNLOCK_ACCOUNT_2);
137                                         break;
138
139                                 case "UNCONFIRMED": // Unconfirmed accounts cannot be unlocked!
140                                         define('__OK_VALUE'    , "del");
141                                         define('__HEADER_VALUE', ADMIN_HEADER_DEL_ACCOUNT_1.__UID_VALUE.ADMIN_HEADER_DEL_ACCOUNT_2);
142                                         define('__TEXT_VALUE'  , ADMIN_TEXT_DEL_ACCOUNT_1.__UID_VALUE.ADMIN_TEXT_DEL_ACCOUNT_2);
143                                         break;
144                                 }
145
146                                 // Output form
147                                 LOAD_TEMPLATE("admin_lock_user");
148                         }
149                          else
150                         {
151                                 // Account does not exists!
152                                 OUTPUT_HTML("<STRONG class=\"admin_failed\">".ADMIN_MEMBER_404_1.$_GET['u_id'].ADMIN_MEMBER_404_2."</STRONG>");
153                         }
154                 }
155                 if (!empty($URL))
156                 {
157                         // Reload and die...
158                         LOAD_URL($URL);
159                 }
160                  elseif ($ACT)
161                 {
162                         // An action was performed...
163                         if (!empty($MSG))
164                         {
165                                 LOAD_TEMPLATE("admin_settings_saved", false, "<STRONG class=\"admin_green\">".$MSG."</STRONG>");
166                         }
167                          else
168                         {
169                                 LOAD_TEMPLATE("admin_settings_saved", false, "<STRONG class=\"admin_green\">".ADMIN_USER_UPDATED."</STRONG>");
170                         }
171                 }
172         }
173          else
174         {
175                 // Account does not exists!
176                 OUTPUT_HTML("<STRONG class=\"admin_failed\">".ADMIN_MEMBER_404_1.$_GET['u_id'].ADMIN_MEMBER_404_2."</STRONG>");
177         }
178 } else {
179         // List all users
180         ADD_MEMBER_SELECTION_BOX();
181 }
182
183 //
184 ?>