From 50d2a349949fcad3c7a6289975df0010f5883892 Mon Sep 17 00:00:00 2001
From: Jared Hancock <gravydish@gmail.com>
Date: Mon, 18 Jun 2012 09:20:59 -0500
Subject: [PATCH] Fix dept::getAvailableMembers()

And fix various lint issues, include adding the yet-undefined-but-referenced
deleteAttachment() function for canned-responses and faq entries
---
 include/class.canned.php | 11 +++++++++++
 include/class.dept.php   |  2 +-
 include/class.faq.php    | 11 +++++++++++
 include/class.ticket.php |  4 ++--
 4 files changed, 25 insertions(+), 3 deletions(-)

diff --git a/include/class.canned.php b/include/class.canned.php
index 51d39ca48..09a3877ad 100644
--- a/include/class.canned.php
+++ b/include/class.canned.php
@@ -144,6 +144,17 @@ class Canned {
         return $i;
     }
 
+    function deleteAttachment($file_id) {
+        $deleted = 0;
+        $sql='DELETE FROM '.CANNED_ATTACHMENT_TABLE
+            .' WHERE canned_id='.db_input($this->getId())
+            .'   AND file_id='.db_input($file_id);
+        if(db_query($sql) && db_affected_rows()) {
+            $deleted = AttachmentFile::deleteOrphans();
+        }
+        return ($deleted > 0);
+    }
+
     function deleteAttachments(){
 
         $deleted=0;
diff --git a/include/class.dept.php b/include/class.dept.php
index bf82b7652..9a1626bae 100644
--- a/include/class.dept.php
+++ b/include/class.dept.php
@@ -98,7 +98,7 @@ class Dept {
                 .'ORDER BY s.lastname, s.firstname';
             if(($res=db_query($sql)) && db_num_rows($res)){
                 while(list($id)=db_fetch_row($res))
-                    if($staff= Staff::lookup($id) && $staff->isAvailable())
+                    if(($staff=Staff::lookup($id)) && $staff->isAvailable())
                         $this->members[]= $staff;
             }
         }
diff --git a/include/class.faq.php b/include/class.faq.php
index b0fdc4ac2..78b1a799e 100644
--- a/include/class.faq.php
+++ b/include/class.faq.php
@@ -218,6 +218,17 @@ class FAQ {
         return $i;
     }
 
+    function deleteAttachment($file_id) {
+        $deleted = 0;
+        $sql='DELETE FROM '.FAQ_ATTACHMENT_TABLE
+            .' WHERE faq_id='.db_input($this->getId())
+            .'   AND file_id='.db_input($file_id);
+        if(db_query($sql) && db_affected_rows()) {
+            $deleted = AttachmentFile::deleteOrphans();
+        }
+        return ($deleted > 0);
+    }
+
     function deleteAttachments(){
 
         $deleted=0;
diff --git a/include/class.ticket.php b/include/class.ticket.php
index 6a27d981b..a40233c9e 100644
--- a/include/class.ticket.php
+++ b/include/class.ticket.php
@@ -540,7 +540,7 @@ class Ticket{
     }
 
     function getClientThread() {
-        return $this->getThreadwithoutNotes();
+        return $this->getThreadWithoutNotes();
     }
 
     function getThreadWithNotes() {
@@ -557,7 +557,7 @@ class Ticket{
         if($includeNotes) //Include notes??
             $treadtypes[] = 'N';
 
-        return $this->getThreadbyType($treadtypes, $order);
+        return $this->getThreadByType($treadtypes, $order);
     }
         
     function getThreadByType($type, $order='ASC') {
-- 
GitLab