From: <rc...@us...> - 2017-04-12 15:50:49
|
Revision: 7750 http://sourceforge.net/p/web-erp/reponame/7750 Author: rchacon Date: 2017-04-12 15:50:47 +0000 (Wed, 12 Apr 2017) Log Message: ----------- Improve code readability. Modified Paths: -------------- trunk/UserSettings.php Modified: trunk/UserSettings.php =================================================================== --- trunk/UserSettings.php 2017-04-09 20:10:23 UTC (rev 7749) +++ trunk/UserSettings.php 2017-04-12 15:50:47 UTC (rev 7750) @@ -13,10 +13,12 @@ _('User Settings'), '" /> ',// Icon title. _('User Settings'), '</p>';// Page title. -$PDFLanguages = array(_('Latin Western Languages - Times'), - _('Eastern European Russian Japanese Korean Hebrew Arabic Thai'), - _('Chinese'), - _('Free Serif')); +$PDFLanguages = array( + _('Latin Western Languages - Times'), + _('Eastern European Russian Japanese Korean Hebrew Arabic Thai'), + _('Chinese'), + _('Free Serif') +); if(isset($_POST['Modify'])) { // no input errors assumed initially before we test @@ -26,13 +28,13 @@ ie the page has called itself with some user input */ //first off validate inputs sensible - if ($_POST['DisplayRecordsMax'] <= 0){ + if($_POST['DisplayRecordsMax'] <= 0) { $InputError = 1; prnMsg(_('The Maximum Number of Records on Display entered must not be negative') . '. ' . _('0 will default to system setting'),'error'); } //!!!for the demo only - enable this check so password is not changed - if ($AllowDemoMode AND $_POST['Password'] != ''){ + if($AllowDemoMode AND $_POST['Password'] != '') { $InputError = 1; prnMsg(_('Cannot change password in the demo or others would be locked out!'),'warn'); } @@ -39,26 +41,26 @@ $UpdatePassword = 'N'; - if ($_POST['PasswordCheck'] != ''){ - if (mb_strlen($_POST['Password'])<5){ + if($_POST['PasswordCheck'] != '') { + if(mb_strlen($_POST['Password']) < 5) { $InputError = 1; prnMsg(_('The password entered must be at least 5 characters long'),'error'); - } elseif (mb_strstr($_POST['Password'],$_SESSION['UserID'])!= False){ + } elseif(mb_strstr($_POST['Password'],$_SESSION['UserID'])!= False) { $InputError = 1; - prnMsg(_('The password cannot contain the user id'),'error'); + prnMsg(_('The password cannot contain the user id'), 'error'); } - if ($_POST['Password'] != $_POST['PasswordCheck']){ + if($_POST['Password'] != $_POST['PasswordCheck']) { $InputError = 1; - prnMsg(_('The password and password confirmation fields entered do not match'),'error'); - }else{ + prnMsg(_('The password and password confirmation fields entered do not match'), 'error'); + } else { $UpdatePassword = 'Y'; } } - if ($InputError != 1) { + if($InputError != 1) { // no errors - if ($UpdatePassword != 'Y'){ + if($UpdatePassword != 'Y') { $sql = "UPDATE www_users SET displayrecordsmax='" . $_POST['DisplayRecordsMax'] . "', theme='" . $_POST['Theme'] . "', @@ -68,9 +70,9 @@ showfieldhelp='" . $_POST['ShowFieldHelp'] . "', pdflanguage='" . $_POST['PDFLanguage'] . "' WHERE userid = '" . $_SESSION['UserID'] . "'"; - $ErrMsg = _('The user alterations could not be processed because'); + $ErrMsg = _('The user alterations could not be processed because'); $DbgMsg = _('The SQL that was used to update the user and failed was'); - $result = DB_query($sql, $ErrMsg, $DbgMsg); + $Result = DB_query($sql, $ErrMsg, $DbgMsg); prnMsg( _('The user settings have been updated') . '. ' . _('Be sure to remember your password for the next time you login'),'success'); } else { $sql = "UPDATE www_users @@ -83,9 +85,9 @@ pdflanguage='" . $_POST['PDFLanguage'] . "', password='" . CryptPass($_POST['Password']) . "' WHERE userid = '" . $_SESSION['UserID'] . "'"; - $ErrMsg = _('The user alterations could not be processed because'); + $ErrMsg = _('The user alterations could not be processed because'); $DbgMsg = _('The SQL that was used to update the user and failed was'); - $result = DB_query($sql, $ErrMsg, $DbgMsg); + $Result = DB_query($sql, $ErrMsg, $DbgMsg); prnMsg(_('The user settings have been updated'),'success'); } // Update the session variables to reflect user changes on-the-fly: @@ -96,7 +98,7 @@ $_SESSION['ShowPageHelp'] = $_POST['ShowPageHelp']; $_SESSION['ShowFieldHelp'] = $_POST['ShowFieldHelp']; $_SESSION['PDFLanguage'] = $_POST['PDFLanguage']; - include ('includes/LanguageSetup.php'); // After last changes in LanguageSetup.php, is it required to update? + include('includes/LanguageSetup.php');// After last changes in LanguageSetup.php, is it required to update? } } @@ -110,20 +112,17 @@ echo '<table class="selection"> <tr> - <td>' . _('User ID') . ':</td> - <td>' . $_SESSION['UserID'] . '</td> + <td>', _('User ID'), ':</td> + <td>', $_SESSION['UserID'], '</td> + </tr> + <tr> + <td>', _('User Name'), ':</td> + <td>', $_SESSION['UsersRealName'], '<input name="RealName" type="hidden" value="', $_SESSION['UsersRealName'], '" /></td></tr> + <tr> + <td>', _('Maximum Number of Records to Display'), ':</td> + <td><input class="integer" maxlength="3" name="DisplayRecordsMax" required="required" size="3" title="', _('The input must be positive integer'), '" type="text" value="', $_POST['DisplayRecordsMax'], '" /></td> </tr>'; -echo '<tr> - <td>' . _('User Name') . ':</td> - <td>' . $_SESSION['UsersRealName'] . ' - <input type="hidden" name="RealName" value="'.$_SESSION['UsersRealName'].'" /></td></tr>'; - -echo '<tr> - <td>' . _('Maximum Number of Records to Display') . ':</td> - <td><input type="text" class="integer" required="required" title="'._('The input must be positive integer').'" name="DisplayRecordsMax" size="3" maxlength="3" value="' . $_POST['DisplayRecordsMax'] . '" /></td> - </tr>'; - // Select language: echo '<tr> <td>', _('Language'), ':</td> @@ -151,9 +150,9 @@ foreach ($ThemeDirectories as $ThemeName) { - if (is_dir('css/' . $ThemeName) AND $ThemeName != '.' AND $ThemeName != '..' AND $ThemeName != '.svn'){ + if(is_dir('css/' . $ThemeName) AND $ThemeName != '.' AND $ThemeName != '..' AND $ThemeName != '.svn') { - if ($_SESSION['Theme'] == $ThemeName){ + if($_SESSION['Theme'] == $ThemeName) { echo '<option selected="selected" value="' . $ThemeName . '">' . $ThemeName . '</option>'; } else { echo '<option value="' . $ThemeName . '">' . $ThemeName . '</option>'; @@ -161,26 +160,28 @@ } } -if (!isset($_POST['PasswordCheck'])) { +if(!isset($_POST['PasswordCheck'])) { $_POST['PasswordCheck']=''; } -if (!isset($_POST['Password'])) { +if(!isset($_POST['Password'])) { $_POST['Password']=''; } -echo '</select></td></tr> +echo '</select> + </td> + </tr> <tr> - <td>' . _('New Password') . ':</td> - <td><input type="password" name="Password" pattern="(?!^'.$_SESSION['UserID'].'$).{5,}" title="'._('Must be more than 5 characters and cannot be as same as userid').'" placeholder="'._('More than 5 characters').'" size="20" value="' . $_POST['Password'] . '" /></td> + <td>', _('New Password'), ':</td> + <td><input name="Password" pattern="(?!^', $_SESSION['UserID'], '$).{5,}" placeholder="', _('More than 5 characters'), '" size="20" title="', _('Must be more than 5 characters and cannot be as same as userid'), '" type="password" value="', $_POST['Password'], '" /></td> </tr> <tr> - <td>' . _('Confirm Password') . ':</td> - <td><input type="password" name="PasswordCheck" pattern="(?!^'.$_SESSION['UserID'].'$).{5,}" title="'._('Must be more than 5 characters and cannot be as same as userid').'" placeholder="'._('More than 5 characters').'" size="20" value="' . $_POST['PasswordCheck'] . '" /></td> + <td>', _('Confirm Password'), ':</td> + <td><input name="PasswordCheck" pattern="(?!^', $_SESSION['UserID'], '$).{5,}" placeholder="', _('More than 5 characters'), '" size="20" title="', _('Must be more than 5 characters and cannot be as same as userid'), '" type="password" value="', $_POST['PasswordCheck'], '" /></td> </tr> <tr> - <td colspan="2" align="center"><i>' . _('If you leave the password boxes empty your password will not change') . '</i></td> + <td align="center" colspan="2"><i>', _('If you leave the password boxes empty your password will not change'), '</i></td> </tr> <tr> - <td>' . _('Email') . ':</td>'; + <td>', _('Email'), ':</td>'; $sql = "SELECT email, @@ -187,16 +188,16 @@ showpagehelp, showfieldhelp from www_users WHERE userid = '" . $_SESSION['UserID'] . "'"; -$result = DB_query($sql); -$myrow = DB_fetch_array($result); +$Result = DB_query($sql); +$myrow = DB_fetch_array($Result); -if(!isset($_POST['email'])){ +if(!isset($_POST['email'])) { $_POST['email'] = $myrow['email']; } $_POST['ShowPageHelp'] = $myrow['showpagehelp']; $_POST['ShowFieldHelp'] = $myrow['showfieldhelp']; -echo '<td><input type="email" name="email" size="40" value="' . $_POST['email'] . '" /></td> +echo '<td><input name="email" size="40" type="email" value="', $_POST['email'], '" /></td> </tr>'; // Turn off/on page help: @@ -230,17 +231,17 @@ '</td> </tr>'; // PDF Language Support: -if (!isset($_POST['PDFLanguage'])){ +if(!isset($_POST['PDFLanguage'])) { $_POST['PDFLanguage']=$_SESSION['PDFLanguage']; } echo '<tr> - <td>' . _('PDF Language Support') . ': </td> + <td>', _('PDF Language Support'), ': </td> <td><select name="PDFLanguage">'; -for($i=0;$i<count($PDFLanguages);$i++){ - if ($_POST['PDFLanguage']==$i){ - echo '<option selected="selected" value="' . $i .'">' . $PDFLanguages[$i] . '</option>'; +for($i=0; $i<count($PDFLanguages); $i++) { + if($_POST['PDFLanguage'] == $i) { + echo '<option selected="selected" value="', $i, '">', $PDFLanguages[$i], '</option>'; } else { - echo '<option value="' . $i .'">' . $PDFLanguages[$i]. '</option>'; + echo '<option value="', $i, '">', $PDFLanguages[$i], '</option>'; } } echo '</select></td> @@ -247,8 +248,8 @@ </tr> </table> <br /> - <div class="centre"><input type="submit" name="Modify" value="' . _('Modify') . '" /></div> - </div> + <div class="centre"><input name="Modify" type="submit" value="', _('Modify'), '" /></div> + </div> </form>'; include('includes/footer.inc'); |