extendable user stats rather than hardcoded with assumptions of extensions
This commit is contained in:
@ -57,6 +57,14 @@ class Favorites extends SimpleExtension {
|
||||
}
|
||||
}
|
||||
|
||||
public function onUserPageBuilding($event) {
|
||||
$i_favorites_count = Image::count_images(array("favorited_by={$event->display_user->name}"));
|
||||
$i_days_old = ((time() - strtotime($event->display_user->join_date)) / 86400) + 1;
|
||||
$h_favorites_rate = sprintf("%.1f", ($i_favorites_count / $i_days_old));
|
||||
$favorites_link = make_link("post/list/favorited_by={$event->display_user->name}/1");
|
||||
$event->add_stats("<a href='$favorites_link'>Images favorited</a>: $i_favorites_count, $h_favorites_rate per day");
|
||||
}
|
||||
|
||||
public function onImageInfoSet($event) {
|
||||
global $user;
|
||||
if(($_POST['favorite_action'] == "set") || ($_POST['favorite_action'] == "unset")) {
|
||||
|
@ -15,6 +15,11 @@ class FavoritesTest extends ShimmieWebTestCase {
|
||||
$this->assertTitle("Image $image_id: test");
|
||||
$this->assertText("Favorited By");
|
||||
|
||||
$this->get_page("user/test");
|
||||
$this->assertText("Images favorited: 1");
|
||||
$this->click("Images favorited");
|
||||
$this->assertTitle("Image $image_id: test");
|
||||
|
||||
$this->click("Un-Favorite");
|
||||
$this->assertNoText("Favorited By");
|
||||
|
||||
|
Reference in New Issue
Block a user