Fixed error that prevented TagImplication from being deleted (issue #44).

Also removed some commented code and added some curly brackets (can't avoid it).
This commit is contained in:
Parziphal 2014-01-05 22:17:37 -05:00
parent a1a65f3509
commit 1bd69c151e

View File

@ -13,16 +13,14 @@ class TagImplicationController extends ApplicationController
public function create() public function create()
{ {
$tag_implication = $this->params()->tag_implication; $tag_implication = $this->params()->tag_implication;
// $tag_implication['new_predicate'] = $tag_implication['predicate'];
// $tag_implication['new_consequent'] = $tag_implication['consequent'];
$tag_implication['is_pending'] = true; $tag_implication['is_pending'] = true;
// vpe($tag_implication);
$ti = new TagImplication($tag_implication); $ti = new TagImplication($tag_implication);
// vpe($ti, $tag_implication);
if ($ti->save()) if ($ti->save()) {
$this->notice("Tag implication created"); $this->notice("Tag implication created");
else } else {
$this->notice("Error: " . $ti->errors()->fullMessages(', ')); $this->notice("Error: " . $ti->errors()->fullMessages(', '));
}
$this->redirectTo("#index"); $this->redirectTo("#index");
} }
@ -64,14 +62,16 @@ class TagImplicationController extends ApplicationController
$tis[] = $ti; $tis[] = $ti;
} }
if (current_user()->is_mod_or_higher() && $can_delete) { if (current_user()->is_mod_or_higher() || $can_delete) {
foreach ($tis as $ti) foreach ($tis as $ti) {
$ti->destroy_and_notify(current_user(), $this->params()->reason); $ti->destroy_and_notify(current_user(), $this->params()->reason);
}
$this->notice("Tag implications deleted"); $this->notice("Tag implications deleted");
$this->redirectTo("#index"); $this->redirectTo("#index");
} else } else {
$this->access_denied(); $this->access_denied();
}
break; break;
case "Approve": case "Approve":
@ -87,8 +87,9 @@ class TagImplicationController extends ApplicationController
$this->notice("Tag implication approval jobs created"); $this->notice("Tag implication approval jobs created");
$this->redirectTo('job_task#index'); $this->redirectTo('job_task#index');
} else } else {
$this->access_denied(); $this->access_denied();
}
break; break;
default: default: