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