save pdftext only if needed, changed error message if write failed

This commit is contained in:
Roland Gruber 2003-11-16 09:20:31 +00:00
parent 87751f5bb9
commit cb6c900276
2 changed files with 5 additions and 2 deletions

View File

@ -138,7 +138,7 @@ class Config {
var $pwdhash;
// text to include in user PDF files
var $pdftext;
var $pdftext = "";
// name of configuration file
var $file;
@ -675,7 +675,10 @@ class Config {
// $value: string containing the text
// returns true if $value has correct format and could be saved
function set_pdftext($value) {
// check if text changed
if ($value == $this->pdftext) return true;
if (is_string($value)) {
// save to file
$pdffile = substr(__FILE__, 0, strlen(__FILE__) - 15) . "/config/pdf/" . $this->file . ".txt";
$file = @fopen($pdffile, "w");
if ($file) {

View File

@ -198,7 +198,7 @@ if (!$conf->set_pwdhash($pwdhash)) {
}
if (!$conf->set_pdftext($pdftext)) {
echo ("<font color=\"red\"><b>" . _("PDF text is invalid!") . "</b></font>");
echo ("<font color=\"red\"><b>" . _("Saving PDF text failed!") . "</b></font>");
echo ("\n<br><br><br><a href=\"javascript:history.back()\">" . _("Back to preferences...") . "</a>");
exit;
}