fixed redirect in comments (baaw!) incidentally I've added a new option for panels to define mandatory argument; why? BECAUSE I CAN! BAWAHAHAHA; really because I hadn't any other idea, and this sounded nice; I'll have to port the other panels for simmetry, but in the meantime they should still work ok.

This commit is contained in:
real_nowhereman 2008-02-17 20:24:04 +00:00
parent ae4ed473f7
commit 69f4510433
4 changed files with 34 additions and 18 deletions

View File

@ -96,6 +96,7 @@
var $smarty = null;
var $events = array();
var $commands = array();
var $args = array();
var $langres = '';
@ -109,6 +110,13 @@
function exec() {
foreach($this->args as $mandatory_argument) {
if (!isset($_GET[$mandatory_argument])) {
return PANEL_REDIRECT_DEFAULT;
}
}
$this->setup();
$result = 0; // if !=0, defaultaction for this panel is called
@ -248,4 +256,4 @@
?>
?>

View File

@ -89,7 +89,7 @@
$smarty->assign('success', sess_remove("success_{$panel}"));
$retval = $fp_admin_action->exec();
if ($retval > 0) {
if ($retval > 0) { // if has REDIRECT option
// clear postdata by a redirect
sess_add("success_{$panel}", $smarty->get_template_vars('success'));
@ -97,8 +97,17 @@
$to_action = $retval > 1 ? ('&action=' . $action) : '';
$with_mod = isset($_GET['mod'])? ('&mod=' . $_GET['mod']) : '';
utils_redirect("admin.php?p={$panel}{$to_action}{$with_mod}");
$with_arguments = '';
if ($retval == PANEL_REDIRECT_CURRENT) {
foreach ($fp_admin_action->args as $mandatory_argument) {
$with_arguments .= '&' . $mandatory_argument .
'=' . $_GET[$mandatory_argument];
}
}
$url = "admin.php?p={$panel}{$to_action}{$with_mod}{$with_arguments}";
utils_redirect($url);
}

View File

@ -16,29 +16,23 @@
class admin_entry_commentlist extends AdminPanelAction {
var $commands = array('delete');
var $commands = array('delete');
var $args = array('entry');
function dodelete($commentid) {
$this->smarty->assign('success',
comment_delete($_GET['entry'], $commentid)? 6 : -6
comment_delete($_GET['entry'], $commentid)? 1 : -1
);
return PANEL_REDIRECT_CURRENT;
}
function main() {
global $fpdb;
if (isset($_GET['entry'])) {
$fpdb->query("id:{$_GET['entry']},fullparse:true");
$fpdb->query("id:{$_GET['entry']},fullparse:true");
return 0;
return 0;
}
return 1;
}
}

View File

@ -63,9 +63,6 @@
2 => 'Entry has been deleted successfully',
-2 => 'An error occurred while trying to delete
the entry',
6 => 'Comment has been deleted successfully',
-6 => 'An error occurred while trying to delete
the comment',
);
@ -98,6 +95,14 @@
'nocomments' => 'This entry have not been commented, yet.',
);
$lang['admin']['entry']['commentlist']['msgs'] =
array(
1 => 'Comment has been deleted successfully',
-1 => 'An error occurred while trying to delete
the comment',
);
/* delete action */