-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathedituser.php
266 lines (259 loc) · 12.5 KB
/
edituser.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
<?php
/**
* Administrative User Interface.
*
* Genmod: Genealogy Viewer
* Copyright (C) 2005 - 2012 Genmod Development Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* This Page Is Valid XHTML 1.0 Transitional! > 19 August 2005
*
* @package Genmod
* @subpackage Admin
* @version $Id: edituser.php 29 2022-07-17 13:18:20Z Boudewijn $
*/
/**
* Inclusion of the configuration file
*/
require "config.php";
if (!isset($action)) $action="";
if (isset($firstname)) $firstname = stripslashes($firstname);
if (isset($lastname)) $lastname = stripslashes($lastname);
if (!isset($pass1)) $pass1 = "";
if (!isset($pass2)) $pass2 = "";
$successmessage = "";
//-- make sure that they have admin status before they can use this page
//-- otherwise have them login again
if (empty($gm_username)||$_SESSION["cookie_login"]) {
if (LOGIN_URL == "") header("Location: login.php?url=edituser.php");
else header("Location: ".LOGIN_URL."?url=edituser.php");
exit;
}
if (!isset($gm_user->default_tab)) $gm_user->default_tab = 9;
//-- prevent users with editing account disabled from being able to edit their account
if (!$gm_user->editaccount) {
header("Location: index.php?command=user");
exit;
}
PrintHeader("Genmod ".GM_LANG_user_admin);
print "<div id=\"EditUserContent\">\n";
//-- section to update a user by first deleting them
//-- and then adding them again
if ($action=="edituser2") {
if ($username != $oldusername && !$gm_user->is_empty) {
print "<span class=\"Error\">".GM_LANG_duplicate_username."</span><br />";
}
else if ($pass1==$pass2) {
$alphabet = GetAlphabet();
$alphabet .= "_-. ";
$i = 1;
$pass = TRUE;
while (strlen($username) > $i) {
if (stristr($alphabet, $username{$i}) != TRUE){
$pass = FALSE;
break;
}
$i++;
}
if ($pass) {
$sync_data_changed = false;
$olduser =& User::GetInstance($oldusername);
$newuser = CloneObj($olduser);
if (empty($pass1)) $newuser->password = $olduser->password;
else $newuser->password = password_hash($pass1, PASSWORD_DEFAULT);
UserController::DeleteUser($oldusername, "changed");
$newuser->username = $username;
$newuser->firstname = $firstname;
$newuser->lastname = $lastname;
$newuser->rootid[GedcomConfig::$GEDCOMID] = $rootid;
if (isset($user_language)) $newuser->language = $user_language;
if ($olduser->email != $user_email) $sync_data_changed = true;
$newuser->email = $user_email;
if (isset($user_theme)) $newuser->theme = $user_theme;
if (isset($new_contact_method)) $newuser->contactmethod = $new_contact_method;
if ((isset($new_visibleonline))&&($new_visibleonline=='yes')) $newuser->visibleonline = true;
else $newuser->visibleonline = false;
if (isset($new_default_tab)) $newuser->default_tab = $new_default_tab;
$successmessage = (UserController::AddUser($newuser, "changed") ? GM_LANG_update_successful : GM_LANG_update_fail);
$gm_user = CloneObj($newuser);
//-- update Gedcom record with new email address
if ($sync_data_changed) AdminFunctions::UpdateUserIndiEmail($newuser);
}
else {
print "<span class=\"Error\">".GM_LANG_invalid_username."</span><br />";
}
}
else {
print "<span class=\"Error\">".GM_LANG_password_mismatch."</span><br />";
$action="edituser";
}
}
//-- print the form to edit a user
?>
<script language="JavaScript" type="text/javascript">
<!--
function checkform(frm) {
if (frm.username.value=="") {
alert("<?php print GM_LANG_enter_username; ?>");
frm.username.focus();
return false;
}
if (frm.firstname.value=="") {
alert("<?php print GM_LANG_enter_fullname; ?>");
frm.firstname.focus();
return false;
}
if (frm.lastname.value=="") {
alert("<?php print GM_LANG_enter_fullname; ?>");
frm.lastname.focus();
return false;
}
if ((frm.user_email.value=="")||(frm.user_email.value.indexOf("@")==-1)) {
alert("<?php print GM_LANG_enter_email; ?>");
frm.user_email.focus();
return false;
}
return true;
}
var pastefield;
function paste_id(value) {
pastefield.value=value;
pastefield.focus();
}
//-->
</script>
<form name="editform" method="post" action="" onsubmit="return checkform(this);">
<input type="hidden" name="action" value="edituser2" />
<input type="hidden" name="oldusername" value="<?php print $gm_user->username; ?>" />
<?php $tab=0; ?>
<table class="ListTable EditUserTable">
<tr>
<td class="NavBlockHeader" colspan="2"><?php print GM_LANG_editowndata.(empty($successmessage) ? "" : "<br /><span class=\"Error\">".$successmessage."</span>");?></td>
</tr>
<tr>
<td class="NavBlockLabel"><div class="HelpIconContainer"><?php PrintHelpLink("edituser_username_help", "qm"); print "</div>".GM_LANG_username;?></td>
<td class="NavBlockField"><input type="text" name="username" tabindex="<?php $tab++; print $tab; ?>" value="<?php print $gm_user->username?>" /></td>
</tr>
<tr>
<td class="NavBlockLabel"><div class="HelpIconContainer"><?php PrintHelpLink("edituser_firstname_help", "qm"); print "</div>".GM_LANG_firstname;?></td>
<td class="NavBlockField"><input type="text" name="firstname" tabindex="<?php $tab++; print $tab; ?>" value="<?php print $gm_user->firstname?>" /></td>
</tr>
<tr>
<td class="NavBlockLabel"><div class="HelpIconContainer"><?php PrintHelpLink("edituser_lastname_help", "qm"); print "</div>".GM_LANG_lastname;?></td>
<td class="NavBlockField"><input type="text" name="lastname" tabindex="<?php $tab++; print $tab; ?>" value="<?php print $gm_user->lastname?>" /></td>
</tr>
<tr>
<td class="NavBlockLabel"><div class="HelpIconContainer"><?php PrintHelpLink("edituser_gedcomid_help", "qm"); print "</div>".GM_LANG_gedcomid;?></td>
<td class="NavBlockField">
<?php
if (!empty($gm_user->gedcomid[GedcomConfig::$GEDCOMID])) {
$person =& Person::GetInstance($gm_user->gedcomid[GedcomConfig::$GEDCOMID], "", GedcomConfig::$GEDCOMID);
$person->PrintListPerson(false);
}
else print " ";
?>
</td>
</tr>
<tr>
<td class="NavBlockLabel"><div class="HelpIconContainer"><?php PrintHelpLink("edituser_rootid_help", "qm"); print "</div>".GM_LANG_rootid;?></td>
<td class="NavBlockField"><input type="text" name="rootid" id="rootid" tabindex="<?php $tab++; print $tab; ?>" value="<?php if (isset($gm_user->rootid[GedcomConfig::$GEDCOMID])) print $gm_user->rootid[GedcomConfig::$GEDCOMID]; ?>" />
<?php LinkFunctions::PrintFindIndiLink("rootid",GedcomConfig::$GEDCOMID); ?>
</td>
</tr>
<tr>
<td class="NavBlockLabel"><div class="HelpIconContainer"><?php PrintHelpLink("edituser_password_help", "qm"); print "</div>".GM_LANG_password;?></td>
<td class="NavBlockField"><input type="password" name="pass1" tabindex="<?php $tab++; print $tab; ?>" /><br /><?php print GM_LANG_leave_blank;?></td>
</tr>
<tr>
<td class="NavBlockLabel"><div class="HelpIconContainer"><?php PrintHelpLink("edituser_conf_password_help", "qm"); print "</div>".GM_LANG_confirm;?></td>
<td class="NavBlockField"><input type="password" name="pass2" tabindex="<?php $tab++; print $tab; ?>" /></td>
</tr>
<tr>
<td class="NavBlockLabel"><div class="HelpIconContainer"><?php PrintHelpLink("edituser_change_lang_help", "qm"); print "</div>".GM_LANG_change_lang;?></td>
<td class="NavBlockField" valign="top"><?php
if (GedcomConfig::$ENABLE_MULTI_LANGUAGE) {
$tab++;
print "<select name=\"user_language\" tabindex=\"".$tab."\">";
foreach ($gm_language as $key => $value) {
if ($language_settings[$key]["gm_lang_use"]) {
print "\n\t\t\t<option value=\"$key\"";
if ($key == $gm_user->language) print " selected=\"selected\"";
print ">" . constant("GM_LANG_lang_name_".$key) . "</option>";
}
}
print "</select>\n\t\t";
}
else print " ";?></td>
</tr>
<tr>
<td class="NavBlockLabel"><div class="HelpIconContainer"><?php PrintHelpLink("edituser_email_help", "qm"); print "</div>".GM_LANG_emailadress;?></td>
<td class="NavBlockField" valign="top"><input type="text" name="user_email" tabindex="<?php $tab++; print $tab; ?>" value="<?php print $gm_user->email; ?>" size="50" onchange="sndReq('errem', 'checkemail', true, 'email', this.value);" /> <span id="errem"></span></td>
</tr>
<?php if (SystemConfig::$ALLOW_USER_THEMES) { ?>
<tr>
<td class="NavBlockLabel"><div class="HelpIconContainer"><?php PrintHelpLink("edituser_user_theme_help", "qm"); print "</div>".GM_LANG_user_theme;?></td>
<td class="NavBlockField" valign="top">
<select name="user_theme" tabindex="<?php $tab++; print $tab; ?>">
<option value=""><?php print GM_LANG_site_default; ?></option>
<?php
$themes = GetThemeNames();
foreach($themes as $indexval => $themedir) {
print "<option value=\"".$themedir["dir"]."\"";
if ($themedir["dir"] == $gm_user->theme) print " selected=\"selected\"";
print ">".$themedir["name"]."</option>\n";
}
?>
</select></td>
</tr>
<?php } ?>
<tr>
<td class="NavBlockLabel"><div class="HelpIconContainer"><?php PrintHelpLink("edituser_user_contact_help", "qm"); print "</div>".GM_LANG_user_contact_method;?></td>
<td class="NavBlockField"><select name="new_contact_method" tabindex="<?php $tab++; print $tab; ?>">
<?php if (SystemConfig::$GM_STORE_MESSAGES) { ?>
<option value="messaging" <?php if ($gm_user->contactmethod=='messaging') print "selected=\"selected\""; ?>><?php print GM_LANG_messaging;?></option>
<option value="messaging2" <?php if ($gm_user->contactmethod=='messaging2') print "selected=\"selected\""; ?>><?php print GM_LANG_messaging2;?></option>
<?php } else { ?>
<option value="messaging3" <?php if ($gm_user->contactmethod=='messaging3') print "selected=\"selected\""; ?>><?php print GM_LANG_messaging3;?></option>
<?php } ?>
<option value="mailto" <?php if ($gm_user->contactmethod=='mailto') print "selected=\"selected\""; ?>><?php print GM_LANG_mailto;?></option>
<option value="none" <?php if ($gm_user->contactmethod=='none') print "selected=\"selected\""; ?>><?php print GM_LANG_no_messaging;?></option>
</select>
</td>
</tr>
<tr>
<td class="NavBlockLabel"><div class="HelpIconContainer"><?php PrintHelpLink("useradmin_visibleonline_help", "qm"); print "</div>".GM_LANG_visibleonline;?></td>
<td class="NavBlockField"><input type="checkbox" name="new_visibleonline" tabindex="<?php $tab++; print $tab; ?>" value="yes" <?php if ($gm_user->visibleonline) print "checked=\"checked\""; ?> /></td>
</tr>
<tr>
<td class="NavBlockLabel"><div class="HelpIconContainer"><?php PrintHelpLink("edituser_user_default_tab_help", "qm"); print "</div>".GM_LANG_user_default_tab;?></td>
<td class="NavBlockField"><select name="new_default_tab" tabindex="<?php $tab++; print $tab; ?>">
<option value="9" <?php if ($gm_user->default_tab==9) print "selected=\"selected\""; ?>><?php print GM_LANG_site_default; ?></option>
<option value="0" <?php if ($gm_user->default_tab==0) print "selected=\"selected\""; ?>><?php print GM_LANG_personal_facts;?></option>
<option value="1" <?php if ($gm_user->default_tab==1) print "selected=\"selected\""; ?>><?php print GM_LANG_notes;?></option>
<option value="2" <?php if ($gm_user->default_tab==2) print "selected=\"selected\""; ?>><?php print GM_LANG_ssourcess;?></option>
<option value="3" <?php if ($gm_user->default_tab==3) print "selected=\"selected\""; ?>><?php print GM_LANG_media;?></option>
<option value="4" <?php if ($gm_user->default_tab==4) print "selected=\"selected\""; ?>><?php print GM_LANG_relatives;?></option>
<option value="6" <?php if ($gm_user->default_tab==6) print "selected=\"selected\""; ?>><?php print GM_LANG_all;?></option>
</select>
</td>
</tr>
<tr><td class="NavBlockFooter" colspan="2"><input type="submit" tabindex="<?php $tab++; print $tab; ?>" value="<?php print GM_LANG_update_myaccount; ?>" /></td></tr>
</table>
</form>
</div>
<?php
PrintFooter();
?>