extendable user stats rather than hardcoded with assumptions of extensions
This commit is contained in:
@ -124,6 +124,15 @@ class ImageIO extends SimpleExtension {
|
||||
$event->image->delete();
|
||||
}
|
||||
|
||||
public function onUserPageBuilding($event) {
|
||||
$u_id = url_escape($event->display_user->id);
|
||||
$i_image_count = Image::count_images(array("user_id={$event->display_user->id}"));
|
||||
$i_days_old = ((time() - strtotime($event->display_user->join_date)) / 86400) + 1;
|
||||
$h_image_rate = sprintf("%.1f", ($i_image_count / $i_days_old));
|
||||
$images_link = make_link("post/list/user_id=$u_id/1");
|
||||
$event->add_stats("<a href='$images_link'>Images uploaded</a>: $i_image_count, $h_image_rate per day");
|
||||
}
|
||||
|
||||
public function onSetupBuilding($event) {
|
||||
$sb = new SetupBlock("Image Options");
|
||||
$sb->position = 30;
|
||||
|
18
ext/image/test.php
Normal file
18
ext/image/test.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
class ImageTest extends ShimmieWebTestCase {
|
||||
public function testUserStats() {
|
||||
$this->log_in_as_user();
|
||||
$image_id = $this->post_image("ext/simpletest/data/pbx_screenshot.jpg", "test");
|
||||
|
||||
$this->get_page("user/test");
|
||||
$this->assertText("Images uploaded: 1");
|
||||
$this->click("Images uploaded");
|
||||
$this->assertTitle("Image $image_id: test");
|
||||
$this->log_out();
|
||||
|
||||
$this->log_in_as_admin();
|
||||
$this->delete_image($image_id);
|
||||
$this->log_out();
|
||||
}
|
||||
}
|
||||
?>
|
Reference in New Issue
Block a user