diff --git a/include/class.category.php b/include/class.category.php index d8cbb72f27de63b4fe25e2256f49cb20f740ab59..1c2991bd1de6c39ed250dcdda90c861de8297711 100644 --- a/include/class.category.php +++ b/include/class.category.php @@ -160,7 +160,6 @@ class Category extends VerySimpleModel { function delete() { try { parent::delete(); - $this->faqs->expunge(); } catch (OrmException $e) { return false; diff --git a/include/class.faq.php b/include/class.faq.php index 4eb1c2d83df46c4953ed0712c1cb03c5a8d913ba..9525ae4a5be56d360cf704d6d48830945ae47b61 100644 --- a/include/class.faq.php +++ b/include/class.faq.php @@ -301,7 +301,7 @@ class FAQ extends VerySimpleModel { try { parent::delete(); // Cleanup help topics. - $this->topics->delete(); + $this->topics->expunge(); // Cleanup attachments. $this->attachments->deleteAll(); } @@ -391,11 +391,11 @@ class FAQ extends VerySimpleModel { $this->notes = Format::sanitize($vars['notes']); $this->keywords = ' '; - $this->updateTopics($vars['topics']); - if (!$this->save()) return false; + $this->updateTopics($vars['topics']); + // General attachments (for all languages) // --------------------- // Delete removed attachments. diff --git a/scp/categories.php b/scp/categories.php index bea8e9a24cf8a730471d9ba9c73b3d827aa46627..b408d6955ed2884e439e7dfec9ecb37585d3cf63 100644 --- a/scp/categories.php +++ b/scp/categories.php @@ -96,15 +96,23 @@ if($_POST){ } break; case 'delete': - $i = Category::objects()->filter(array( + $categories = Category::objects()->filter(array( 'category_id__in'=>$_POST['ids'] - ))->delete(); + )); + foreach ($categories as $c) { + if ($faqs = FAQ::objects() + ->filter(array('category_id'=>$c->getId()))) { + foreach ($faqs as $key => $faq) + $faq->delete(); + } + $c->delete(); + } - if ($i==$count) + if (count($categories)==$count) $msg = sprintf(__('Successfully deleted %s.'), _N('selected category', 'selected categories', $count)); - elseif ($i > 0) - $warn = sprintf(__('%1$d of %2$d %3$s deleted'), $i, $count, + elseif ($categories > 0) + $warn = sprintf(__('%1$d of %2$d %3$s deleted'), $categories, $count, _N('selected category', 'selected categories', $count)); elseif (!$errors['err']) $errors['err'] = sprintf(__('Unable to delete %s.'), diff --git a/scp/helptopics.php b/scp/helptopics.php index b00c231d500211a30c4ea30d35a2b8c87a7b38d4..68db1e4d7c8096378daa8e5c963b014e84b02076 100644 --- a/scp/helptopics.php +++ b/scp/helptopics.php @@ -102,15 +102,18 @@ if($_POST){ } break; case 'delete': - $i = Topic::objects()->filter(array( + $topics = Topic::objects()->filter(array( 'topic_id__in'=>$_POST['ids'] - ))->delete(); + )); + + foreach ($topics as $t) + $t->delete(); - if($i && $i==$count) + if($topics && $topics==$count) $msg = sprintf(__('Successfully deleted %s.'), _N('selected help topic', 'selected help topics', $count)); - elseif($i>0) - $warn = sprintf(__('%1$d of %2$d %3$s deleted'), $i, $count, + elseif($topics>0) + $warn = sprintf(__('%1$d of %2$d %3$s deleted'), $topics, $count, _N('selected help topic', 'selected help topics', $count)); elseif(!$errors['err']) $errors['err'] = sprintf(__('Unable to delete %s.'),