Distinguish Admins

Post about your customizations to share with others.

Moderators: Developer, Contributor

Post Reply
Gav
Posts: 1
Joined: 01 Oct 2014, 21:53

Distinguish Admins

Post by Gav »

Hey,

Is there anyway to distinguish the admins/devs/managers etc color in the ticket view?

Example:

Image

There is no CSS class and I cannot figure out how to add one to specific groups?

Any help would be appreciated.
RedSpider
Posts: 36
Joined: 30 Jan 2015, 19:47

Re: Distinguish Admins

Post by RedSpider »

I really need this too, spent the whole day trying to make it work with no success :(

Can anyone help?
n - i - i
Posts: 10
Joined: 01 Feb 2015, 19:51

Re: Distinguish Admins

Post by n - i - i »

I wrote a little plugin that afternoon; yeah... quick and dirty, I know, but it should do the job or at least give you some ideas of how to implement something similar. :wink: Mantis version is 1.2.19.
EDIT: Note: This version of the plugin does not work properly with Mantis v1.3.0. See below for the required changes for Mantis version 1.3.0.

To use it, do the following:
1) Add the code below to the bottom of your .css-file.
2) Since there were no usable event_signal()'s, I had to add a few lines to the bugnote_view_inc.php. You can just replace bugnote_view_inc.php with the attached version or you can use the attached diff-file. Note: The attached script is based on the original script of MantisBT version 1.2.19. By using the attached script, any of your changes to bugnote_view_inc.php will be lost.
3) Extract the BugnoteHighlighting folder to the /plugins/ folder and install the BugnoteHighlighting plugin.

By default the highlighting for administrator level is already activated. To "activate" highlighting for other access levels, change the color_active_[access_level] value to ON (config()-function in /plugins/BugnoteHighlighting/BugnoteHighlighting.php). You can then change the color via the css-classes below.

Code: Select all

tr .bnhl_10         { background-color: #ffffff; }
tr .bnhl_note_10    { background-color: #ffffff; }
tr .bnhl_25         { background-color: #ffffff; }
tr .bnhl_note_25    { background-color: #ffffff; }
tr .bnhl_40         { background-color: #ffffff; }
tr .bnhl_note_40    { background-color: #ffffff; }
tr .bnhl_55         { background-color: #ffffff; }
tr .bnhl_note_55    { background-color: #ffffff; }
tr .bnhl_70         { background-color: #ffffff; }
tr .bnhl_note_70    { background-color: #ffffff; }
tr .bnhl_90         { background-color: #c08603; }
tr .bnhl_note_90    { background-color: #f0a804; }
These are the css-classes for the defaul access-levels of MantisBT (10: viewer, 25: reporter, 40: updater, 55: developer, 70: manager, 90: administrator). You can change the hexadecimal color codes to whatever color you prefer. Note that there are two classes per user access level. The image below explains where the two classes are applied (in this case .bnhl_90 and .bnhl_note_90 for administrator level).
bnhl_example.png
bnhl_example.png (17.12 KiB) Viewed 20575 times
As I said, quick and dirty, no configuration page or stuff like that. :wink: But it should at least give you an idea. I can think of a few more features to implement, but I don't have the time for that. Feel free to add more features!
Attachments
BugnoteHighlighting.rar
(4.18 KiB) Downloaded 705 times
Last edited by n - i - i on 18 Aug 2016, 16:43, edited 2 times in total.
RedSpider
Posts: 36
Joined: 30 Jan 2015, 19:47

Re: Distinguish Admins

Post by RedSpider »

You sir, are a LEGEND, thank you :D
RedSpider
Posts: 36
Joined: 30 Jan 2015, 19:47

Re: Distinguish Admins

Post by RedSpider »

hi, i notice this doesn't seem to work on the 1.3 branch of Mantis, I hate to be a pain but is there any way this can be changed to work? I tried adding in the changes to the bugnote_view_inc.php but it causes bug history not load on the page at all (incl comments)
n - i - i
Posts: 10
Joined: 01 Feb 2015, 19:51

Re: Distinguish Admins

Post by n - i - i »

Yup, there's a way - and it's actually not that complicated. There are a few changes required for Mantis version 1.3.0:

1) The required css classes changed a little bit:

Code: Select all

.bnhl_10 > td.bugnote-meta   { background-color: #ffffff; }
.bnhl_10 > td.bugnote-note   { background-color: #ffffff; }
.bnhl_25 > td.bugnote-meta   { background-color: #ffffff; }
.bnhl_25 > td.bugnote-note   { background-color: #ffffff; }
.bnhl_40 > td.bugnote-meta   { background-color: #ffffff; }
.bnhl_40 > td.bugnote-note   { background-color: #ffffff; }
.bnhl_55 > td.bugnote-meta   { background-color: #ffffff; }
.bnhl_55 > td.bugnote-note   { background-color: #ffffff; }
.bnhl_70 > td.bugnote-meta   { background-color: #ffffff; }
.bnhl_70 > td.bugnote-note   { background-color: #ffffff; }
.bnhl_90 > td.bugnote-meta   { background-color: #c08603; }
.bnhl_90 > td.bugnote-note   { background-color: #f0a804; }
The picture below shows how the css classes are applied:
bnhl_example_v13.png
bnhl_example_v13.png (11.52 KiB) Viewed 19228 times
2) You have to change the requirements for the plugin to MantisCore v1.3.0 in /plugins/BugnoteHighlighting.php:

Code: Select all

		$this->requires = array(
			'MantisCore' => '1.3.0',
		);
3) You should apply the changed event_signal() call in bugnote_view_inc.php, otherwise you'll maybe get a warning (the plugin still should work even with the event_signal() from the old plugin version):

Code: Select all

		if( VS_PRIVATE == $t_bugnote->view_state ) {
			$t_bugnote_css		= 'bugnote-private';
		} else {
			$t_bugnote_css		= 'bugnote-public';
      
            # BugnoteHighlighting begin 
            if( plugin_is_loaded( 'BugnoteHighlighting' ) ){
                $t_bnhl_class = event_signal( 'EVENT_BNHL_CHECK_ACCESS_LEVEL', array( $t_bugnote->reporter_id ) );
                
                $t_bugnote_css .= $t_bnhl_class["BugnoteHighlighting"]["bnhlCheckAccessLevel"];
            }
            # Bugnote Highlighting end
		}
That's around line 146 in bugnote_view_inc.php.

You can also use the attached plugin version and bugnote_view_inc.php.
Attachments
BugnoteHighlighting_v1.3.zip
(4.41 KiB) Downloaded 649 times
RedSpider
Posts: 36
Joined: 30 Jan 2015, 19:47

Re: Distinguish Admins

Post by RedSpider »

ahhh, perfect, thank you! :)
RedSpider
Posts: 36
Joined: 30 Jan 2015, 19:47

Re: Distinguish Admins

Post by RedSpider »

ok sorry to be a pain again, just updated to v2 and struggling to get this to work now within the bugnote_view_inc.php :oops:
n - i - i
Posts: 10
Joined: 01 Feb 2015, 19:51

Re: Distinguish Admins

Post by n - i - i »

The required changes are a bit more complicated now and I don't have the time at the moment. I'll try to look into it within the next few days, but I can't promise.
RedSpider
Posts: 36
Joined: 30 Jan 2015, 19:47

Re: Distinguish Admins

Post by RedSpider »

n - i - i wrote:The required changes are a bit more complicated now and I don't have the time at the moment. I'll try to look into it within the next few days, but I can't promise.
Thanks, I would appreciate that :D

EDIT:
Actually, If it's easier, maybe we could just make the little badge things a different colour?
Image
n - i - i
Posts: 10
Joined: 01 Feb 2015, 19:51

Re: Distinguish Admins

Post by n - i - i »

Changing the badges was actually way easier. I attached a new version of the plugin, it's tested for MantisBT Version 2.3.

The required changes are:

1) Change the required css classes to the following (or use the attached default.css file):

Code: Select all

.bnhl_10{ background-color: #000000 !important;}
.bnhl_10::after{ border-color: #000000 transparent #000000 !important; }
.bnhl_25{ background-color: #000000 !important; }
.bnhl_25::after{ border-color: #000000 transparent #000000 !important; }
.bnhl_40{ background-color: #000000 !important; }
.bnhl_40::after{ border-color: #000000 transparent #000000 !important; }
.bnhl_55{ background-color: #000000 !important; }
.bnhl_55::after{border-color: #000000 transparent #000000 !important; }
.bnhl_70{ background-color: #000000 !important; }
.bnhl_70::after{border-color: #000000 transparent #000000 !important; }
.bnhl_90{ background-color: #FF0000 !important; }
.bnhl_90::after{ border-color: #FF0000 transparent #FF0000 !important; }
2) Add the following lines to bugnote_view_inc.php, if you already added customizations (otherwise you can also use the attached file, it's based on the default version from MBT Version 2.3!):

Code: Select all

if( user_exists( $t_activity['user_id'] ) ) {
				$t_access_level = access_get_project_level( null, $t_activity['user_id'] );
				$t_label = layout_is_rtl() ? 'arrowed-right' : 'arrowed-in-right';

				#Bugnote Highlighting begin
				if( plugin_is_loaded('BugnoteHighlighting' ) ){
				    $t_bnhl_class = event_signal( "EVENT_BNHL_CHECK_ACCESS_LEVEL", array( $t_access_level ) );
				    $t_label .= $t_bnhl_class['BugnoteHighlighting']['bnhlCheckAccessLevel'];
                }
                #Bugnote Highlighting end

				echo '<span class="label label-sm label-default ' . $t_label . '">', access_level_get_string( $t_access_level ), '</span>';
			}
That's around line 180 in bugnote_view_inc.php from Version 2.3.

3) Install the attached plugin.

That should be it.
Attachments
BugnoteHighlighting_v2.3.zip
(5.65 KiB) Downloaded 608 times
RedSpider
Posts: 36
Joined: 30 Jan 2015, 19:47

Re: Distinguish Admins

Post by RedSpider »

Thank you sir, you are a legend.

Mantis should totally make this a standard feature! :D
Post Reply