A lot texts rewritten and exclamation signs removed
[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  * @TODO Add support for ext-country                                    *
21  * -------------------------------------------------------------------- *
22  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
23  * For more information visit: http://www.mxchange.org                  *
24  *                                                                      *
25  * This program is free software; you can redistribute it and/or modify *
26  * it under the terms of the GNU General Public License as published by *
27  * the Free Software Foundation; either version 2 of the License, or    *
28  * (at your option) any later version.                                  *
29  *                                                                      *
30  * This program is distributed in the hope that it will be useful,      *
31  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
32  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
33  * GNU General Public License for more details.                         *
34  *                                                                      *
35  * You should have received a copy of the GNU General Public License    *
36  * along with this program; if not, write to the Free Software          *
37  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
38  * MA  02110-1301  USA                                                  *
39  ************************************************************************/
40
41 // Some security stuff...
42 if ((!defined('__SECURITY')) || (!isAdmin())) {
43         die();
44 } // END - if
45
46 // Add description as navigation point
47 addMenuDescription('admin', __FILE__);
48
49 // Fix a notice
50 $result_main = false;
51 if (isGetRequestElementSet('userid')) {
52         // Load user entry
53         $result_main = SQL_QUERY_ESC("SELECT
54         `userid`, `gender`, `surname`, `family`, `street_nr`, `zip`, `city`, `country`,
55         `email`,
56         `birth_day`, `birth_month`, `birth_year`,
57         `max_mails`
58 FROM
59         `{?_MYSQL_PREFIX?}_user_data`
60 WHERE
61         `userid`=%s
62 LIMIT 1",
63                 array(
64                         bigintval(getRequestElement('userid'))
65                 ), __FILE__, __LINE__);
66 } // END - if
67
68 if ((SQL_NUMROWS($result_main) == 1) || (!isGetRequestElementSet('userid'))) {
69         // User found
70         if (!isGetRequestElementSet('userid')) {
71                 // Output selection form with all confirmed user accounts listed
72                 addMemberSelectionBox();
73         } elseif (isPostRequestElementSet('edit')) {
74                 // Ok, change the account...
75                 $updateUser = false; $add = '';
76                 if ((!isPostRequestElementSet('pass1')) && (!isPostRequestElementSet('pass2'))) {
77                         // Don't change the password
78                         $updateUser = true;
79                 } elseif ((postRequestElement('pass1') == postRequestElement('pass2'))) {
80                         // Change the password
81                         $updateUser = true;
82                         $add = ", `password`='" . generateHash(postRequestElement('pass1')) . "'";
83                 }
84
85                 if ($updateUser === true) {
86                         // We have to add the following things: birthday and max receive mails
87                         SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET
88 `gender`='%s',
89 `surname`='%s',
90 `family`='%s',
91 `street_nr`='%s',
92 `country`='%s',
93 `zip`=%s,
94 `city`='%s',
95 `email`='%s'
96 ".$add."
97 WHERE `userid`=%s LIMIT 1",
98                         array(
99                                 substr(postRequestElement('gender'), 0, 1),
100                                 postRequestElement('surname'),
101                                 postRequestElement('family'),
102                                 postRequestElement('street_nr'),
103                                 postRequestElement('country'),
104                                 bigintval(postRequestElement('zip')),
105                                 postRequestElement('city'),
106                                 postRequestElement('email'),
107                                 bigintval(getRequestElement('userid')),
108                         ), __FILE__, __LINE__);
109                         $content = getMessage('USER_ACCOUNT_SAVED');
110                 } else {
111                         // Problem while saving data
112                         $content = getMessage('USER_ACCOUNT_NOT_SAVED');
113                 }
114
115                 // Load template
116                 loadTemplate('admin_settings_saved', false, $content);
117         } else {
118                 // Load entry
119                 $content = SQL_FETCHARRAY($result_main);
120
121                 // Init entries
122                 foreach (array('gender_m','gender_f','gender_c') as $entry) {
123                         $content[$entry] = '';
124                 } // END - foreach
125
126                 // Prepare selections
127                 $content['gender_' . strtolower($content['gender'])] = ' selected="selected"';
128
129                 // Load template
130                 loadTemplate('admin_edit_user', false, $content);
131         }
132 } else {
133         // Account does not exists!
134         loadTemplate('admin_settings_saved', false, "<div class=\"admin_failed\">".sprintf(getMessage('ADMIN_MEMBER_404'), getRequestElement('userid'))."</div>");
135 }
136
137 // Free the result
138 SQL_FREERESULT($result_main);
139
140 // [EOF]
141 ?>