Prechádzať zdrojové kódy

Catched some empty MySQL-Results

Moritz Schmidt 10 rokov pred
rodič
commit
4357459c65

+ 4 - 0
includes/call.inc.php

@@ -81,6 +81,10 @@ class Call {
 
          $return = array();
 
+         if(!$calls) {
+             return false;
+         }
+
          foreach($calls as $call) {
              $return[] = new Call($call->id, $call->call_date, $call->caller_telnr, $call->label_id, $call->notes, $call->reminder_id);
          }

+ 4 - 0
includes/document.inc.php

@@ -83,6 +83,10 @@ class Document {
         $return = array();
         $documents = $db->selectQuery("SELECT * FROM `documents` WHERE `label_id` = " . $labelId . ";");
 
+        if(!$documents) {
+            return false;
+        }
+
         foreach($documents as $document) {
             $return[] = new Document($document->id, $document->filename, $document->path, $document->label_id, $document->draft, $document->created, $document->last_change);
         }

+ 11 - 8
templates/calllist.php

@@ -9,14 +9,17 @@
         </tr>
     </thead>
 <?php
-foreach($this->_['calls'] as $call) {
-    echo '<tr>';
-    echo '<td>' . $call->getCallDate() . '</td>';
-    echo '<td>' . $call->getCallerTelNr() . '</td>';
-    echo '<td>' . getExcerptFromString($call->getNotes()) . '</td>';
-    echo '<td><i class="fa fa-clock-o"></i></td>';
-    echo '<td><a class="edit-call fancybox.ajax" href="ajax.php?action=editCall&callID=' . $call->getID() . '"><i class="fa fa-wrench"></i></a></td>';
-    echo '</tr>';
+
+if($this->_['calls']) {
+    foreach($this->_['calls'] as $call) {
+        echo '<tr>';
+        echo '<td>' . $call->getCallDate() . '</td>';
+        echo '<td>' . $call->getCallerTelNr() . '</td>';
+        echo '<td>' . getExcerptFromString($call->getNotes()) . '</td>';
+        echo '<td><i class="fa fa-clock-o"></i></td>';
+        echo '<td><a class="edit-call fancybox.ajax" href="ajax.php?action=editCall&callID=' . $call->getID() . '"><i class="fa fa-wrench"></i></a></td>';
+        echo '</tr>';
+    }
 }
 ?>
 </table>

+ 11 - 9
templates/documentlist.php

@@ -10,15 +10,17 @@
         </tr>
     </thead>
 <?php
-foreach($this->_['documents'] as $document) {
-    echo '<tr>';
-    //echo '<td>' . $document->getType() . '</td>'; // type icon based on extension
-    echo '<td>' . $document->getFileName() . '</td>';
-    echo '<td>' . $document->getDraft() . '</td>';
-    echo '<td>' . $document->getCreated() . '</td>';
-    echo '<td>' . $document->getLastChange() . '</td>';
-    echo '<td></td>';
-    echo '</tr>';
+if($this->_['documents']) {
+    foreach($this->_['documents'] as $document) {
+        echo '<tr>';
+        //echo '<td>' . $document->getType() . '</td>'; // type icon based on extension
+        echo '<td>' . $document->getFileName() . '</td>';
+        echo '<td>' . $document->getDraft() . '</td>';
+        echo '<td>' . $document->getCreated() . '</td>';
+        echo '<td>' . $document->getLastChange() . '</td>';
+        echo '<td></td>';
+        echo '</tr>';
+    }
 }
 ?>
 </table>

+ 14 - 12
templates/maillist.php

@@ -10,19 +10,21 @@
     </thead>
 <?php
 
-foreach($this->_['mails'] as $mail) {
-    $checked = "";
-    if($mail->getProcessed() == 1) {
-        $checked = "checked";
-    }
+if($this->_['mails']) {
+    foreach($this->_['mails'] as $mail) {
+        $checked = "";
+        if($mail->getProcessed() == 1) {
+            $checked = "checked";
+        }
 
-    echo '<tr>';
-    echo '<td><input type="checkbox" value="1" ' . $checked . ' id="mail-processed-' . $mail->getID() . '" class="mail-processed"></td>';
-    echo '<td>' . $mail->getMailSender() . '</td>';
-    echo '<td>' . $mail->getMailRecipient() . '</td>';
-    echo '<td>' . $mail->getSubject() . '</td>';
-    echo '<td><a href="#" data-mail-id="' . $mail->getID() . '" class="reply-mail"><i class="fa fa-reply"></i></a></td>';
-    echo '</tr>';
+        echo '<tr>';
+        echo '<td><input type="checkbox" value="1" ' . $checked . ' id="mail-processed-' . $mail->getID() . '" class="mail-processed"></td>';
+        echo '<td>' . $mail->getMailSender() . '</td>';
+        echo '<td>' . $mail->getMailRecipient() . '</td>';
+        echo '<td>' . $mail->getSubject() . '</td>';
+        echo '<td><a href="#" data-mail-id="' . $mail->getID() . '" class="reply-mail"><i class="fa fa-reply"></i></a></td>';
+        echo '</tr>';
+    }
 }
 ?>
 </table>