* Licensed under the GNU GPL. For full terms see the file COPYING.
*
* This contains functions for manipulating user preferences in files
*
* Licensed under the GNU GPL. For full terms see the file COPYING.
*
* This contains functions for manipulating user preferences in files
*
*/
function cachePrefValues($data_dir, $username) {
global $prefs_are_cached, $prefs_cache;
*/
function cachePrefValues($data_dir, $username) {
global $prefs_are_cached, $prefs_cache;
/* Calculate the filename for the user's preference file */
$filename = getHashedFile($username, $data_dir, "$username.pref");
/* Calculate the filename for the user's preference file */
$filename = getHashedFile($username, $data_dir, "$username.pref");
sqsession_register($prefs_cache, 'prefs_cache');
sqsession_register($prefs_are_cached, 'prefs_are_cached');
}
sqsession_register($prefs_cache, 'prefs_cache');
sqsession_register($prefs_are_cached, 'prefs_are_cached');
}
- cachePrefValues($data_dir, $username);
- if (isset($prefs_cache[$string])) {
- $result = $prefs_cache[$string];
- } else {
- $result = do_hook_function('get_pref', array($username,$string));
- if (!$result) {
- $result = $default;
- }
- }
+ cachePrefValues($data_dir, $username);
+ if (isset($prefs_cache[$string])) {
+ $result = $prefs_cache[$string];
+ } else {
+ $result = do_hook_function('get_pref', array($username,$string));
+ if (!$result) {
+ $result = $default;
+ }
+ }
$filename = getHashedFile($username, $data_dir, "$username.pref");
/* Open the file for writing, or else display an error to the user. */
$filename = getHashedFile($username, $data_dir, "$username.pref");
/* Open the file for writing, or else display an error to the user. */
logout_error( sprintf( _("Preference file, %s, could not be written. Contact your system administrator to resolve this issue.") , $filename . '.tmp') );
exit;
}
logout_error( sprintf( _("Preference file, %s, could not be written. Contact your system administrator to resolve this issue.") , $filename . '.tmp') );
exit;
}
/* Then, check if the file exists. */
if (!@file_exists($filename) ) {
/* First, check the $data_dir for the default preference file. */
/* Then, check if the file exists. */
if (!@file_exists($filename) ) {
/* First, check the $data_dir for the default preference file. */
/* If it is not there, check the internal data directory. */
if (!@file_exists($default_pref)) {
/* If it is not there, check the internal data directory. */
if (!@file_exists($default_pref)) {
/* Otherwise, report an error. */
$errTitle = sprintf( _("Error opening %s"), $default_pref );
if (!is_readable($default_pref)) {
/* Otherwise, report an error. */
$errTitle = sprintf( _("Error opening %s"), $default_pref );
if (!is_readable($default_pref)) {
- $errString = $errTitle . "<br>\n" .
- _("Default preference file not found or not readable!") . "<br>\n" .
- _("Please contact your system administrator and report this error.") . "<br>\n";
+ $errString = $errTitle . "<br />\n" .
+ _("Default preference file not found or not readable!") . "<br />\n" .
+ _("Please contact your system administrator and report this error.") . "<br />\n";
logout_error( $errString, $errTitle );
exit;
} else if (!@copy($default_pref, $filename)) {
logout_error( $errString, $errTitle );
exit;
} else if (!@copy($default_pref, $filename)) {
* Write the User Signature.
*/
function setSig($data_dir, $username, $number, $value) {
* Write the User Signature.
*/
function setSig($data_dir, $username, $number, $value) {
$filename = getHashedFile($username, $data_dir, "$username.si$number");
/* Open the file for writing, or else display an error to the user. */
if(!$file = @fopen("$filename.tmp", 'w')) {
logout_error( sprintf( _("Signature file, %s, could not be opened. Contact your system administrator to resolve this issue."), $filename . '.tmp') );
exit;
}
$filename = getHashedFile($username, $data_dir, "$username.si$number");
/* Open the file for writing, or else display an error to the user. */
if(!$file = @fopen("$filename.tmp", 'w')) {
logout_error( sprintf( _("Signature file, %s, could not be opened. Contact your system administrator to resolve this issue."), $filename . '.tmp') );
exit;
}
logout_error( sprintf( _("Signature file, %s, could not be written. Contact your system administrator to resolve this issue.") , $filename . '.tmp'));
exit;
}
logout_error( sprintf( _("Signature file, %s, could not be written. Contact your system administrator to resolve this issue.") , $filename . '.tmp'));
exit;
}