Skip to content

Commit 5720e8a

Browse files
committed
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.
1 parent 19345d7 commit 5720e8a

File tree

4 files changed

+26
-11
lines changed

4 files changed

+26
-11
lines changed

src/controllers/EventLog/Index.php

+1
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ public function &run(Router &$router, View &$view, array &$args) {
7171
if ($model->page > $model->pages) { $model->page = $model->pages; }
7272

7373
$model->events = Event::getAllEvents(
74+
null,
7475
$order,
7576
$model->limit,
7677
$model->limit * ( $model->page - 1 )

src/libraries/Event.php

+23-4
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,17 @@ public function __construct( $data ) {
3636
}
3737

3838
public static function &getAllEvents(
39-
$order = null, $limit = null, $index = null
39+
$filter_types = null, $order = null, $limit = null, $index = null
4040
) {
4141

42+
if (empty($filter_types)) {
43+
$where_clause = '';
44+
} else {
45+
$where_clause = 'WHERE `event_type_id` IN ('
46+
. implode( ',', $filter_types ) . ')'
47+
;
48+
}
49+
4250
if (!(is_numeric($limit) || is_numeric($index))) {
4351
$limit_clause = '';
4452
} else if (!is_numeric($index)) {
@@ -49,7 +57,7 @@ public static function &getAllEvents(
4957

5058
if (empty($limit_clause)) {
5159

52-
$cache_key = 'bnetdocs-events';
60+
$cache_key = 'bnetdocs-events-' . hash( 'md5', $where_clause );
5361
$cache_val = Common::$cache->get( $cache_key );
5462

5563
if ( $cache_val !== false && !empty( $cache_val ) ) {
@@ -81,6 +89,7 @@ public static function &getAllEvents(
8189
`meta_data`,
8290
`user_id`
8391
FROM `event_log`
92+
' . $where_clause . '
8493
ORDER BY
8594
' . ($order ? '`' . $order[0] . '` ' . $order[1] . ',' : '') . '
8695
`id` ' . ($order ? $order[1] : 'ASC') . ' ' . $limit_clause . ';'
@@ -118,14 +127,24 @@ public static function &getAllEvents(
118127
return null;
119128
}
120129

121-
public static function getEventCount() {
130+
public static function getEventCount($filter_types = null) {
122131
if (!isset(Common::$database)) {
123132
Common::$database = DatabaseDriver::getDatabaseObject();
124133
}
125134

126135
try {
127136

128-
$stmt = Common::$database->prepare('SELECT COUNT(*) FROM `event_log`;');
137+
if (empty($filter_types)) {
138+
$where_clause = '';
139+
} else {
140+
$where_clause = ' WHERE event_type_id IN ('
141+
. implode( ',', $filter_types ) . ')'
142+
;
143+
}
144+
145+
$stmt = Common::$database->prepare(
146+
'SELECT COUNT(*) FROM `event_log`' . $where_clause . ';'
147+
);
129148

130149
if ( !$stmt->execute() ) {
131150
throw new QueryException( 'Cannot query event count' );

src/libraries/EventTypes.php

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
namespace BNETDocs\Libraries;
44

5+
use \SplEnum;
6+
57
class EventTypes {
68

79
const LOG_NOTE = 0;

src/templates/FrontPage.phtml

-7
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,6 @@ require("./header.inc.phtml");
3232
<li>and <a href="<?php echo Common::relativeUrlToAbsolute('https://github.com/BNETDocs/bnetdocs-web/issues'); ?>">suggest improvements</a> to the site.</li>
3333
</ul></p>
3434
<p>Help our community and documentation grow! Receive recognition for your work on our <a href="<?php echo Common::relativeUrlToAbsolute('/credits'); ?>">contributors</a> page!</p>
35-
</section>
36-
</article>
37-
<article>
38-
<header>Activity Feed</header>
39-
<section>
40-
<p>Here's the latest of what's going on at BNETDocs.</p>
41-
<?php include('./NYI.inc.phtml'); ?>
4235
<hr/>
4336
<p>
4437
<a class="button" href="<?php echo Common::relativeUrlToAbsolute('/news'); ?>">Read News</a>

0 commit comments

Comments
 (0)