From 5720e8aaa37428e6243f03561c4325fae389ae32 Mon Sep 17 00:00:00 2001 From: Carl Bennett Date: Mon, 11 Feb 2019 05:22:37 +0000 Subject: [PATCH] Rip out activity feed for now I found it would not be possible to display an activity feed due to the event_log table not having enough data to display objects that were changed. A true change log table would need to be created to have an activity feed on the front page of BNETDocs. --- src/controllers/EventLog/Index.php | 1 + src/libraries/Event.php | 27 +++++++++++++++++++++++---- src/libraries/EventTypes.php | 2 ++ src/templates/FrontPage.phtml | 7 ------- 4 files changed, 26 insertions(+), 11 deletions(-) diff --git a/src/controllers/EventLog/Index.php b/src/controllers/EventLog/Index.php index 8933f17d..b8bf0109 100644 --- a/src/controllers/EventLog/Index.php +++ b/src/controllers/EventLog/Index.php @@ -71,6 +71,7 @@ public function &run(Router &$router, View &$view, array &$args) { if ($model->page > $model->pages) { $model->page = $model->pages; } $model->events = Event::getAllEvents( + null, $order, $model->limit, $model->limit * ( $model->page - 1 ) diff --git a/src/libraries/Event.php b/src/libraries/Event.php index 4a0d443f..e7c4d866 100644 --- a/src/libraries/Event.php +++ b/src/libraries/Event.php @@ -36,9 +36,17 @@ public function __construct( $data ) { } public static function &getAllEvents( - $order = null, $limit = null, $index = null + $filter_types = null, $order = null, $limit = null, $index = null ) { + if (empty($filter_types)) { + $where_clause = ''; + } else { + $where_clause = 'WHERE `event_type_id` IN (' + . implode( ',', $filter_types ) . ')' + ; + } + if (!(is_numeric($limit) || is_numeric($index))) { $limit_clause = ''; } else if (!is_numeric($index)) { @@ -49,7 +57,7 @@ public static function &getAllEvents( if (empty($limit_clause)) { - $cache_key = 'bnetdocs-events'; + $cache_key = 'bnetdocs-events-' . hash( 'md5', $where_clause ); $cache_val = Common::$cache->get( $cache_key ); if ( $cache_val !== false && !empty( $cache_val ) ) { @@ -81,6 +89,7 @@ public static function &getAllEvents( `meta_data`, `user_id` FROM `event_log` + ' . $where_clause . ' ORDER BY ' . ($order ? '`' . $order[0] . '` ' . $order[1] . ',' : '') . ' `id` ' . ($order ? $order[1] : 'ASC') . ' ' . $limit_clause . ';' @@ -118,14 +127,24 @@ public static function &getAllEvents( return null; } - public static function getEventCount() { + public static function getEventCount($filter_types = null) { if (!isset(Common::$database)) { Common::$database = DatabaseDriver::getDatabaseObject(); } try { - $stmt = Common::$database->prepare('SELECT COUNT(*) FROM `event_log`;'); + if (empty($filter_types)) { + $where_clause = ''; + } else { + $where_clause = ' WHERE event_type_id IN (' + . implode( ',', $filter_types ) . ')' + ; + } + + $stmt = Common::$database->prepare( + 'SELECT COUNT(*) FROM `event_log`' . $where_clause . ';' + ); if ( !$stmt->execute() ) { throw new QueryException( 'Cannot query event count' ); diff --git a/src/libraries/EventTypes.php b/src/libraries/EventTypes.php index dbdf50b1..98a9435b 100644 --- a/src/libraries/EventTypes.php +++ b/src/libraries/EventTypes.php @@ -2,6 +2,8 @@ namespace BNETDocs\Libraries; +use \SplEnum; + class EventTypes { const LOG_NOTE = 0; diff --git a/src/templates/FrontPage.phtml b/src/templates/FrontPage.phtml index a72e6176..540ebc84 100644 --- a/src/templates/FrontPage.phtml +++ b/src/templates/FrontPage.phtml @@ -32,13 +32,6 @@ require("./header.inc.phtml");
  • and suggest improvements to the site.
  • Help our community and documentation grow! Receive recognition for your work on our contributors page!

    - - -
    -
    Activity Feed
    -
    -

    Here's the latest of what's going on at BNETDocs.

    -

    Read News