]> git.p6c8.net - selfforum.git/blobdiff - selfforum-cgi/shared/Template/Archive.pm
-n/a-
[selfforum.git] / selfforum-cgi / shared / Template / Archive.pm
index ec5ee22cbd83d3df14d51caa895838b169eac3e6..08d215cf7f1009718a55b74474373c1ef5237358 100644 (file)
@@ -73,7 +73,33 @@ sub print_month_as_HTML($$$) {
 
     my $template = new Template $tempfile;
 
-    my $threads = get_all_threads($mainfile, KILL_DELETED);
+    #
+    # check if XML file exists
+    #
+    unless (-e $mainfile) {
+        print ${$template->scrap(
+            $assign->{'error'},
+            {
+                $assign->{'errorText'}  => "Es existieren keine Nachrichten für diesen Monat."
+            }
+        )};
+        return;
+    }
+
+    #
+    # try locking and read/parse threads
+    #
+    my ($threads, $locked);
+    unless ($locked = lock_file($mainfile) and $threads = get_all_threads($mainfile, KILL_DELETED)) {
+        print ${$template->scrap(
+            $assign->{'error'},
+            {
+                $assign->{'errorText'}  => "Fehler beim Locking."
+            }
+        )};
+        return;
+    }
+    unlock_file($mainfile);
 
     my $tmplparam = {
             $assign->{'year'}           => $param->{'year'},
@@ -136,6 +162,19 @@ sub print_thread_as_HTML($$$) {
 
     my $template = new Template $tempfile;
 
+    #
+    # check if XML file exists
+    #
+    unless (-e $mainfile) {
+        print ${$template->scrap(
+            $assign->{'error'},
+            {
+                $assign->{'errorText'}  => "Der gewünschte Thread existiert nicht."
+            }
+        )};
+        return;
+    }
+
     my $view = get_view_params ({
         'adminDefault'  => $param->{'adminDefault'}
     });
@@ -173,7 +212,8 @@ sub print_thread_as_HTML($$$) {
 
     print ${$template->scrap(
         $assign->{'threadDocStart'},
-        $tmplparam
+        $tmplparam,
+        1
     )};
 
     #
@@ -184,7 +224,7 @@ sub print_thread_as_HTML($$$) {
         my $header = get_message_header($mnode);
         my $body = get_message_body($xml, 'm'.$_->{'mid'});
 
-        my $text = message_field (
+        my $text = message_field(
             $body,
             {
                 'quoteChars'    => plain($view->{'quoteChars'}),
@@ -206,7 +246,8 @@ sub print_thread_as_HTML($$$) {
                 $assign->{'msgCategory'}    => plain($header->{'category'}),
                 $assign->{'msgSubject'}     => plain($header->{'subject'}),
                 $assign->{'msgBody'}        => $text
-            }
+            },
+            1
         )};
     }
 
@@ -215,7 +256,8 @@ sub print_thread_as_HTML($$$) {
     #
     print ${$template->scrap(
         $assign->{'threadDocEnd'},
-        $tmplparam
+        $tmplparam,
+        1
     )};
 }
 

patrick-canterino.de