Damn typo fixed... ;-)
[mailer.git] / inc / modules / admin / what-edit_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-edit_user.php                               *
8  * -------------------------------------------------------------------- *
9  * Short description : Edit member's profiles                           *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Mitgliederprofile aendern                        *
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 // Fix a notice
49 $result_main = false;
50 if (REQUEST_ISSET_GET(('uid'))) {
51         //                                    0      1        2         3      4     5      6       7         8          9           10         11
52         $result_main = SQL_QUERY_ESC("SELECT gender, surname, family, street_nr, zip, city, country, email, birth_day, birth_month, birth_year, max_mails
53 FROM `{!_MYSQL_PREFIX!}_user_data`
54 WHERE userid=%s
55 LIMIT 1",
56                 array(bigintval(REQUEST_GET('uid'))), __FILE__, __LINE__);
57 }
58
59 if ((SQL_NUMROWS($result_main) == 1) || (!REQUEST_ISSET_GET(('uid'))))
60 {
61         // User found
62         if (!REQUEST_ISSET_GET(('uid')))
63         {
64                 // Output selection form with all confirmed user accounts listed
65                 ADD_MEMBER_SELECTION_BOX();
66         }
67          elseif (REQUEST_ISSET_POST('edit'))
68         {
69                 // Ok, change the account...
70                 $PASS = false; $ADD = "";
71                 if ((!REQUEST_ISSET_POST(('pass1'))) && (!REQUEST_ISSET_POST(('pass2'))))
72                 {
73                         // Don't change the password
74                         $PASS = true;
75                 }
76                  elseif ((REQUEST_POST('pass1') == REQUEST_POST('pass2')))
77                 {
78                         // Change the password
79                         $PASS = true;
80                         $ADD = ", password='".generateHash(REQUEST_POST('pass1'))."'";
81                 }
82                 if ($PASS)
83                 {
84                         // We have to add the following things: birthday and max receive mails
85                         SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_user_data` SET
86 gender='%s',
87 surname='%s',
88 family='%s',
89 street_nr='%s',
90 country='%s',
91 zip=%s,
92 city='%s',
93 email='%s'
94 ".$ADD."
95 WHERE userid=%s LIMIT 1",
96  array(
97         substr(REQUEST_POST('gender'), 0, 1),
98         REQUEST_POST('surname'),
99         REQUEST_POST('family'),
100         REQUEST_POST('street_nr'),
101         REQUEST_POST('country'),
102         bigintval(REQUEST_POST('zip')),
103         REQUEST_POST('city'),
104         REQUEST_POST('email'),
105         bigintval(REQUEST_GET('uid')),
106 ), __FILE__, __LINE__);
107                         $content = USER_ACCOUNT_SAVED;
108                 }
109                  else
110                 {
111                         // Problem while saving data
112                         $content = USER_ACCOUNT_NOT_SAVED;
113                 }
114
115                 // Load template
116                 LOAD_TEMPLATE("admin_settings_saved", false, $content);
117         }
118          else
119         {
120                 // Display form to edit
121                 list($gender, $surname, $family, $street, $zip, $city, $country, $email, $bday, $bmonth, $byear, $max) = SQL_FETCHROW($result_main);
122                 SQL_FREERESULT($result_main);
123
124                 // Transfer data to constants for the template
125                 switch ($gender)
126                 {
127                 case "M":
128                         define('_GENDER_M', " selected=\"selected\"");
129                         define('_GENDER_F', "");
130                         define('_GENDER_C', "");
131                         break;
132
133                 case "F":
134                         define('_GENDER_M', "");
135                         define('_GENDER_F', " selected=\"selected\"");
136                         define('_GENDER_C', "");
137                         break;
138
139                 case "C":
140                         define('_GENDER_M', "");
141                         define('_GENDER_F', "");
142                         define('_GENDER_C', " selected=\"selected\"");
143                         break;
144                 }
145
146                 define('_SURNAME', $surname); define('_FAMILY', $family); define('_CITY'     , $city);
147                 define('_STREET' , $street);  define('_ZIP'   , $zip);    define('_MAX_MAILS', $max);
148                 define('_COUNTRY', $country); define('_EMAIL' , $email);
149
150                 // Load template
151                 LOAD_TEMPLATE("admin_edit_user", false, bigintval(REQUEST_GET('uid')));
152         }
153 } else {
154         // Account does not exists!
155         LOAD_TEMPLATE("admin_settings_saved", false, "<div class=\"admin_failed\">".sprintf(getMessage('ADMIN_MEMBER_404'), REQUEST_GET('uid'))."</div>");
156 }
157
158 //
159 ?>