diff --git a/include/class.dept.php b/include/class.dept.php index 3f623b41100dd4ad715ad0c40d25460546ef8c9b..98d3fd80e218e1c7993b2f770e399dd95fdeacc1 100644 --- a/include/class.dept.php +++ b/include/class.dept.php @@ -121,15 +121,15 @@ class Dept extends VerySimpleModel { ->filter(Q::any(array( 'dept_id' => $this->getId(), new Q(array( - 'group__depts__id' => $this->getId(), - 'group__depts__group_membership' => self::ALERTS_DEPT_AND_GROUPS, + 'group__depts__dept_id' => $this->getId(), + 'group__depts__dept__group_membership' => self::ALERTS_DEPT_AND_GROUPS, )), 'staff_id' => $this->manager_id ))); if ($criteria && $criteria['available']) $members->filter(array( - 'group__group_enabled' => 1, + 'group__flags__hasbit' => Group::FLAG_ENABLED, 'isactive' => 1, 'onvacation' => 0, )); diff --git a/include/class.faq.php b/include/class.faq.php index 4e0fe8f456d10bb198636f87afe1ed4d546e307a..f4bb27b0081f2a6d68d8a992a8233b58bec2b211 100644 --- a/include/class.faq.php +++ b/include/class.faq.php @@ -14,6 +14,7 @@ **********************************************************************/ require_once('class.file.php'); require_once('class.category.php'); +require_once('class.thread.php'); class FAQ extends VerySimpleModel { @@ -28,15 +29,14 @@ class FAQ extends VerySimpleModel { 'constraint' => array( 'category_id' => 'Category.category_id' ), - ), + ), /* XXX: Not yet implemented 'attachments' => array( 'constraint' => array( "'F'" => 'GenericAttachment.type', 'faq_id' => 'GenericAttachment.object_id', ), 'list' => true, - 'null' => true, - ), + ), */ 'topics' => array( 'constraint' => array( 'faq_id' => 'FaqTopic.faq_id' @@ -76,7 +76,7 @@ class FAQ extends VerySimpleModel { return Format::truncate(Format::striptags($this->answer), 150); } function getSearchableAnswer() { - return ThreadBody::fromFormattedText($this->answer, 'html') + return ThreadEntryBody::fromFormattedText($this->answer, 'html') ->getSearchable(); } function getNotes() { return $this->notes; } @@ -378,12 +378,11 @@ class FAQ extends VerySimpleModel { } static function findIdByQuestion($question) { - $object = self::objects()->filter(array( + $row = self::objects()->filter(array( 'question'=>$question - ))->values_flat('faq_id')->one(); + ))->values_flat('faq_id')->first(); - if ($object) - return $object[0]; + return ($row) ? $row[0] : null; } static function findByQuestion($question) { diff --git a/include/class.thread.php b/include/class.thread.php index 71dc5525f4a1c41f5db5ed95f74f2053a5be62b5..55273469ce5624f7306149c6761cc0c508a5063b 100644 --- a/include/class.thread.php +++ b/include/class.thread.php @@ -159,10 +159,10 @@ class Thread { function deleteAttachments() { // Clear reference table - $sql = 'DELETE FROM '.ATTACHMENT_TABLE. ' a ' - . 'INNER JOIN '.THREAD_ENTRY_TABLE.' e - ON(e.id = a.object_id AND a.`type`= "H") ' - . ' WHERE e.thread_id='.db_input($this->getId()); + $sql = 'DELETE `a`.* FROM '.ATTACHMENT_TABLE. ' `a` ' + . 'INNER JOIN '.THREAD_ENTRY_TABLE.' `e` + ON(`e`.id = `a`.object_id AND `a`.`type`= "H") ' + . ' WHERE `e`.thread_id='.db_input($this->getId()); $deleted=0; if (($res=db_query($sql)) && ($deleted=db_affected_rows()))