Open venturitsoft opened 7 years ago
hi
Could you enable this plugin in the recent version of Mantis BT 2.21 or higher?
thanks
I'm sorry but there's a long time that I don't mess with MantisBT and I can't do it in a short term. Feel free to open a PR though 👍🏼
`<?php
/**
Updated for compatibility with MantisBT 2.0 */ class IssueViewersPlugin extends MantisPlugin { function register() { $this->name = 'Issue Viewers'; $this->description = 'This plugin stores and shows issue viewers and their view count'; $this->page = '';
$this->version = '2.0'; // Updated version for MantisBT 2.0 compatibility
$this->requires = array(
'MantisCore' => '2.0.0', // Updated required MantisCore version
);
$this->author = 'Dentxinho';
$this->contact = 'https://github.com/Dentxinho';
$this->url = 'https://github.com/Dentxinho';
}
function hooks() { return array( 'EVENT_VIEW_BUG_DETAILS' => 'store_viewer', 'EVENT_VIEW_BUG_EXTRA' => 'display_viewers' ); }
function schema() { return array( array( "CreateTableSQL", array( plugin_table( "bug_viewer_data" ), " id I NOTNULL UNSIGNED AUTOINCREMENT PRIMARY, bug_id I NOTNULL, user_id I DEFAULT NULL, view_date I NOTNULL ", array( "mysql" => "DEFAULT CHARSET=utf8" ))), array( 'CreateIndexSQL', array( 'idx_bug_id', plugin_table( 'bug_viewer_data' ), 'bug_id' )), array( 'CreateIndexSQL', array( 'idx_user_id', plugin_table( 'bug_viewer_data' ), 'user_id' )), ); }
function store_viewer($p_event, $bug_id) { if (current_user_is_anonymous() || !auth_is_user_authenticated()) $user_id = NULL; else $user_id = auth_get_current_user_id();
$dbtable = plugin_table("bug_viewer_data");
$dbquery = "INSERT INTO {$dbtable} (bug_id, user_id, view_date) VALUES (" . db_param() . "," . db_param() . "," . db_now() . ")";
db_query($dbquery, array($bug_id, $user_id));
}
function display_viewers($p_event, $bug_id) { $dbtable = plugin_table("bug_viewer_data"); $dbquery = "SELECT IFNULL(user_id, 'anon') AS user_id, COUNT(IFNULL(user_id,'anon')) AS count, MAX(view_date) AS last_view FROM {$dbtable} WHERE bug_id = " . db_param() . " GROUP BY user_id ORDER BY MAX(view_date) DESC";
$result = db_query($dbquery, array($bug_id));
$viewers = array();
$view_count = 0;
$last_view = FALSE;
while ($row = db_fetch_array($result)) {
$viewers[$row['user_id']] = $row['count'];
$view_count += $row['count'];
$last_view = $row['last_view'];
}
$this->_print_viewers_layout($viewers, $view_count, $last_view);
}
private function _print_viewers_layout($viewers, $view_count, $last_view) { echo '
' . plugin_lang_get('total_views') . ': ' . $view_count . '
'; echo '' . plugin_lang_get('last_view') . ': ' . ($last_view ? date(config_get('normal_date_format'), $last_view) : '-') . '
'; echo '
hi
Could you enable this plugin in the recent version of Mantis BT 2.1.0 or higher?
thanks