3 /* $Revision: 1.23 $ */
7 include('includes/session.inc');
8 $title = _('User Settings');
9 include('includes/header.inc');
11 if (isset($_POST['Modify'])) {
12 // no input errors assumed initially before we test
15 /* actions to take once the user has clicked the submit button
16 ie the page has called itself with some user input */
18 //first off validate inputs sensible
19 if ($_POST['DisplayRecordsMax'] <= 0){
21 prnMsg(_('The Maximum Number of Records on Display entered must not be negative') . '. ' . _('0 will default to system setting'),'error');
24 //!!!for the demo only - enable this check so password is not changed
26 if ($_POST['pass'] != ''){
28 prnMsg(_('Cannot change password in the demo or others would be locked out!'),'warn');
31 if ($_POST['pass'] != ''){
32 if ($_POST['pass'] != $_POST['passcheck']){
34 prnMsg(_('The password and password confirmation fields entered do not match'),'error');
39 if ($_POST['passcheck'] != ''){
40 if ($_POST['pass'] != $_POST['passcheck']){
42 prnMsg(_('The password and password confirmation fields entered do not match'),'error');
48 if ($InputError != 1) {
50 if ($update_pw != 'Y'){
51 $sql = "UPDATE www_users
52 SET displayrecordsmax=" . $_POST['DisplayRecordsMax'] . ",
53 theme='" . $_POST['Theme'] . "',
54 language='" . $_POST['Language'] . "',
55 email='". $_POST['email'] ."'
56 WHERE userid = '" . $_SESSION['UserID'] . "'";
58 $ErrMsg = _('The user alterations could not be processed because');
59 $DbgMsg = _('The SQL that was used to update the user and failed was');
61 $result = DB_query($sql,$db, $ErrMsg, $DbgMsg);
63 prnMsg( _('The user settings have been updated') . '. ' . _('Be sure to remember your password for the next time you login'),'success');
65 $sql = "UPDATE www_users
66 SET displayrecordsmax=" . $_POST['DisplayRecordsMax'] . ",
67 theme='" . $_POST['Theme'] . "',
68 language='" . $_POST['Language'] . "',
69 email='". $_POST['email'] ."',
70 password='" . CryptPass($_POST['pass']) . "'
71 WHERE userid = '" . $_SESSION['UserID'] . "'";
73 $ErrMsg = _('The user alterations could not be processed because');
74 $DbgMsg = _('The SQL that was used to update the user and failed was');
76 $result = DB_query($sql,$db, $ErrMsg, $DbgMsg);
78 prnMsg(_('The user settings have been updated'),'success');
80 // update the session variables to reflect user changes on-the-fly
81 $_SESSION['DisplayRecordsMax'] = $_POST['DisplayRecordsMax'];
82 $_SESSION['Theme'] = trim($_POST['Theme']); /*already set by session.inc but for completeness */
83 $theme = $_SESSION['Theme'];
84 $_SESSION['Language'] = trim($_POST['Language']);
86 include ('includes/LanguageSetup.php');
91 echo "<FORM METHOD='post' action=" . $_SERVER['PHP_SELF'] . '?' . SID
. '>';
93 If (!isset($_POST['DisplayRecordsMax']) OR $_POST['DisplayRecordsMax']=='') {
95 $_POST['DisplayRecordsMax'] = $_SESSION['DefaultDisplayRecordsMax'];
99 echo '<CENTER><TABLE><TR><TD>' . _('User ID') . ':</TD><TD>';
100 echo $_SESSION['UserID'] . '</TD></TR>';
102 echo '<TR><TD>' . _('User Name') . ':</TD><TD>';
103 echo $_SESSION['UsersRealName'] . '</TD></TR>';
106 <TD>' . _('Maximum Number of Records to Display') . ":</TD>
107 <TD><INPUT TYPE='Text' name='DisplayRecordsMax' SIZE=3 MAXLENGTH=3 VALUE=" . $_POST['DisplayRecordsMax'] . " ></TD>
112 <TD>' . _('Language') . ":</TD>
113 <TD><SELECT name='Language'>";
115 $LangDirHandle = dir('locale/');
118 while (false != ($LanguageEntry = $LangDirHandle->read())){
120 if (is_dir('locale/' . $LanguageEntry) AND $LanguageEntry != '..' AND $LanguageEntry != 'CVS' AND $LanguageEntry!='.'){
122 if ($_SESSION['Language'] == $LanguageEntry){
123 echo "<OPTION SELECTED VALUE='$LanguageEntry'>$LanguageEntry";
125 echo "<OPTION VALUE='$LanguageEntry'>$LanguageEntry";
130 echo '</SELECT></TD></TR>';
134 <TD>' . _('Theme') . ":</TD>
135 <TD><SELECT name='Theme'>";
137 $ThemeDirectory = dir('css/');
140 while (false != ($ThemeName = $ThemeDirectory->read())){
142 if (is_dir("css/$ThemeName") AND $ThemeName != '.' AND $ThemeName != '..' AND $ThemeName != 'CVS'){
144 if ($_SESSION['Theme'] == $ThemeName){
145 echo "<OPTION SELECTED VALUE='$ThemeName'>$ThemeName";
147 echo "<OPTION VALUE='$ThemeName'>$ThemeName";
152 echo '</SELECT></TD></TR>
153 <TR><TD>' . _('New Password') . ":</TD>
154 <TD><input type='password' name='pass' size=20 value='" . $_POST['pass'] . "'></TD></TR>
155 <TR><TD>" . _('Confirm Password') . ":</TD>
156 <TD><input type='password' name='passcheck' size=20 value='" . $_POST['passcheck'] . "'></TD></TR>
157 <tr><td colspan=2 align='center'><i>" . _('If you leave the password boxes empty your password will not change') . '</i></td></tr>
158 <TR><TD>' . _('Email') . ':</TD>';
160 $sql = "SELECT email from www_users WHERE userid = '" . $_SESSION['UserID'] . "'";
161 $result = DB_query($sql,$db);
162 $myrow = DB_fetch_array($result);
163 if(!isset($_POST['email'])){
164 $_POST['email'] = $myrow['email'];
167 echo "<TD><input type=text name='email' size=40 value='" . $_POST['email'] . "'></TD></TR>
169 <CENTER><input type='Submit' name='Modify' value=" . _('Modify') . '></CENTER>
172 include('includes/footer.inc');