Skip to content
Snippets Groups Projects
Unverified Commit ba1fb383 authored by Peter Rotich's avatar Peter Rotich Committed by GitHub
Browse files

Merge pull request #4780 from aydreeihn/issue/faqs

FAQ Issues
parents 4bf11e65 ce3d69ae
Branches
Tags
No related merge requests found
......@@ -160,7 +160,6 @@ class Category extends VerySimpleModel {
function delete() {
try {
parent::delete();
$this->faqs->expunge();
}
catch (OrmException $e) {
return false;
......
......@@ -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.
......
......@@ -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.'),
......
......@@ -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.'),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment