diff --git a/contrib/bulk_add/test.php b/contrib/bulk_add/test.php new file mode 100644 index 00000000..6eb23f27 --- /dev/null +++ b/contrib/bulk_add/test.php @@ -0,0 +1,15 @@ +log_in_as_admin(); + + $this->get_page('admin'); + $this->assertTitle("Admin Tools"); + $this->setField('dir', "contrib/simpletest"); + $this->click("Add"); + $this->delete_image($image_id); + + $this->log_out(); + } +} +?> diff --git a/contrib/pm/main.php b/contrib/pm/main.php index 5a176a76..437a7af9 100644 --- a/contrib/pm/main.php +++ b/contrib/pm/main.php @@ -65,6 +65,7 @@ class PM extends SimpleExtension { } public function onPageRequest($event) { + global $database, $page, $user; if($event->page_matches("pm")) { if(!$user->is_anonymous()) { switch($event->get_arg(0)) { @@ -93,7 +94,7 @@ class PM extends SimpleExtension { $database->execute("DELETE FROM private_message WHERE id = ?", array($pm_id)); log_info("pm", "Deleted PM #$pm_id"); $page->set_mode("redirect"); - $page->set_redirect(make_link("user")); + $page->set_redirect(make_link($_SERVER["REFERER"])); } else { // permission denied @@ -108,12 +109,16 @@ class PM extends SimpleExtension { $page->set_mode("redirect"); $page->set_redirect(make_link($_SERVER["REFERER"])); break; + default: + $this->theme->display_error($page, "Invalid action", "That's not something you can do with a PM"); + break; } } } } public function onSendPM($event) { + global $database; $database->execute(" INSERT INTO private_message( from_id, from_ip, to_id, @@ -122,7 +127,7 @@ class PM extends SimpleExtension { array($event->from_id, $event->from_ip, $event->to_id, $event->subject, $event->message) ); - log_info("pm", "Sent PM to User #$to_id"); + log_info("pm", "Sent PM to User #{$event->to_id}"); } diff --git a/contrib/pm/test.php b/contrib/pm/test.php new file mode 100644 index 00000000..905f7101 --- /dev/null +++ b/contrib/pm/test.php @@ -0,0 +1,42 @@ +log_in_as_admin(); + $this->get_page("user/test"); + $this->setField('subject', "message demo to test"); + $this->setField('message', "message contents"); + $this->click("Send"); + $this->log_out(); + + $this->log_in_as_user(); + $this->get_page("user"); + $this->assertText("message demo to test"); + $this->click("message demo to test"); + $this->assertText("message contents"); + $this->back(); + $this->click("Delete"); + $this->assertNoText("message demo to test"); + $this->log_out(); + } + + function testAdminAccess() { + $this->log_in_as_admin(); + $this->get_page("user/test"); + $this->setField('subject', "message demo to test"); + $this->setField('message', "message contents"); + $this->click("Send"); + + $this->get_page("user/test"); + $this->assertText("message demo to test"); + $this->click("message demo to test"); + $this->assertText("message contents"); + $this->back(); + $this->click("Delete"); + # Test for bug: after an admin deletes a user's PM, they were + # redirected to their own (the admin's) PM list + $this->assertTitle("test's page"); + $this->assertNoText("message demo to test"); + $this->log_out(); + } +} +?> diff --git a/contrib/pm/theme.php b/contrib/pm/theme.php index 757ecd11..7454d8f8 100644 --- a/contrib/pm/theme.php +++ b/contrib/pm/theme.php @@ -24,7 +24,10 @@ class PMTheme extends Themelet { if($pm["is_read"] == "N") $h_subject = "$h_subject"; $html .= "