- cachePrefValues($data_dir, $username);
-
- if (isset($prefs_cache[$string])) {
- unset($prefs_cache[$string]);
- }
-
- savePrefValues($data_dir, $username);
-}
-
-/**
- * Set a there preference $string to $value.
- */
-function setPref($data_dir, $username, $string, $value) {
- global $prefs_cache;
-
- cachePrefValues($data_dir, $username);
- if (isset($prefs_cache[$string]) && ($prefs_cache[$string] == $value)) {
- return;
- }
-
- if ($value === '') {
- removePref($data_dir, $username, $string);
- return;
- }
-
- $prefs_cache[$string] = $value;
- savePrefValues($data_dir, $username);
-}
-
-/**
- * Check for a preferences file. If one can not be found, create it.
- */
-function checkForPrefs($data_dir, $username, $filename = '') {
- /* First, make sure we have the filename. */
- if ($filename == '') {
- $filename = getHashedFile($username, $data_dir, '$username.pref');
- }
-
- /* Then, check if the file exists. */
- if (!@file_exists($filename) ) {
- /* First, check the $data_dir for the default preference file. */
- $default_pref = $data_dir . 'default_pref';
-
- /* If it is not there, check the internal data directory. */
- if (!@file_exists($default_pref)) {
- $default_pref = '../data/default_pref';
- }
-
- /* Otherwise, report an error. */
- if (!file_exists($default_pref)) {
- echo _("Error opening ") . $default_pref . "<br>\n";
- echo _("Default preference file not found!") . "<br>\n";
- echo _("Please contact your system administrator and report this error.") . "<br>\n";
- exit;
- } else if (!@copy($default_pref, $filename)) {
- echo _("Error opening ") . $default_pref . '<br>';
- echo _("Could not create initial preference file!") . "<br>\n";
- echo _("Please contact your system administrator and report this error.") . "<br>\n";
- exit;
- }
- }
-}
-
-/**
- * Write the User Signature.
- */
-function setSig($data_dir, $username, $value) {
- $filename = getHashedFile($username, $data_dir, "$username.sig");
- $file = fopen($filename, 'w');
- fwrite($file, $value);
- fclose($file);
-}
-
-/**
- * Get the signature.
- */
-function getSig($data_dir, $username) {
- #$filename = $data_dir . $username . '.sig';
- $filename = getHashedFile($username, $data_dir, "$username.sig");
- $sig = '';
- if (file_exists($filename)) {
- $file = fopen($filename, 'r');
- while (!feof($file)) {
- $sig .= fgets($file, 1024);
- }
- fclose($file);
- }
- return $sig;
-}