Skip to content
Snippets Groups Projects
Commit 1922920a authored by Jared Hancock's avatar Jared Hancock
Browse files

oops: Fix several small, general issues

  * Fix fatal errors adding a new FAQ (fixes #1648)
  * Fix removal of attachments when deleting a thread (fixes #1650)
  * Fix crash discovering department members for alerts (fixes #1652)
parent 79cc5338
No related branches found
No related tags found
No related merge requests found
......@@ -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,
));
......
......@@ -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) {
......
......@@ -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()))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment