View Issue Details

IDProjectCategoryView StatusLast Update
0005702mantisbtsecuritypublic2018-10-05 07:49
Reporterw_morozAssigned To 
PrioritynormalSeverityfeatureReproducibilityalways
Status acknowledgedResolutionopen 
Product Version 
Target VersionFixed in Version 
Summary0005702: Giving access to user who is monitoring bug
Description

Let's say we hve private project. User 1 (REPORTER) has added a private issue. administrator decided to send reminder to User 2 (REPORTER) of issue reported by user1. User 2 is monitoring issue but he do not have access to it.

It would be nice if administrator has an option to allow user2 to view private issue1.

Additional Information

I changed a lot in my conf files and .php files so please check out on "clean" mantis version

TagsNo tags attached.

Relationships

related to 0007642 new Sending reminder from private issue should grant person rights to view this issue 
related to 0007584 new Add reporter to view private bugs 
has duplicate 0005701 closedvboctor Giving access to user who is monitoring bug 
has duplicate 0004763 closeddregad Allow monitor access to private bug in private project 
has duplicate 0015505 closeddregad 'Monitor'-ing on a private issue is not working 
related to 0015466 new Reporter can't see an issue they have been made a monitor of 

Activities

vboctor

vboctor

2005-06-03 04:42

manager   ~0010340

This can probably be easily implemented by modifying access_has_bug_level() to check if the user is monitoring the issue, the same way it currently checks if the user is the reporter of the issue.

Whether this is to be configurable or not, will need to be decided.

vboctor

vboctor

2005-06-03 04:45

manager   ~0010341

The change I proposed above will only provide the user access to the issue, if he enters Jump to Issue, or clicks on a link in an email. It will not add it to the list of issues the user can see in the View Issues page (i.e. as a result of a query). Changing the filtering to return these issues can be down, but it will slow down the query.

w_moroz

w_moroz

2005-06-03 05:43

reporter   ~0010343

Yes i did it before reporting. At first I modified access_has_bug_level(), but as You noticed the bug is not displayed in my_view_page so i changed query. Thanks for checking out and still I think it would be nice featue to assign rights to certaing bugs.

istvanb

istvanb

2011-02-17 08:00

reporter   ~0028251

Would be a nice to have

jas0n

jas0n

2011-07-15 04:46

reporter   ~0029175

Last edited: 2011-07-15 04:47

View 2 revisions

w_moroz, can you describe changes you did?

toddpw

toddpw

2011-08-11 00:04

reporter   ~0029458

You will need to change access_has_bug_level() but that's not the only place. The mass queries for the My View and View Issues pages will probably need to construct different queries to ensure that you don't miss anything.

There are actually three cases I can think of offhand where adding monitors as a way of implementing access control lists could make varying amounts of sense:

  1. (your case) User could see bug if it were not private, monitoring bypasses the view status, user has whatever access they would normally have for public bugs in the same project. Most likely we would then want a new config option to determine what access level is required to add such a monitor, unless it is tied to those who can already view or edit view status on private issues.

  2. User cannot see bug because it is in a private project. Monitoring would bypass the private project check but then what access level would the user have? Global access might not be sufficient to see the bug, or (if we are abusing Monitors as access control lists) do other operations like handle, etc. Worst case I could see a per-project option that says what access level Monitors grant (a la adding the user to the project at that level).

  3. User cannot see bug because "reporters limited to own issues" is preventing them from seeing it. (BTW, why is that not "access required to see public bugs" ? Probably because it was a very specific request originally I guess.) Presumably we just bypass the reporter check and give them their original access level.

There would also be interactions with the reminders feature (which has its own access level options!) but I think the general principle should hold that if you can't already see a bug, you should not be able to Monitor it; but once you can see a bug, it's an open question (and probably yet more configuration options) as to how much additional access you should need to send reminders and add people as Monitors. (On one end of the spectrum, people granted access via Monitoring would be able to add others as Monitors; on the other end, only those with manager access to the bug -- or configurable/administrator! -- would be able to add Monitors that create exceptions to the normal access levels.)

cwipll

cwipll

2015-07-15 14:52

reporter   ~0051073

I recently ran into the same requirement and as this ticket has been around since 2005 without a solution I hacked one myself. In case someone needs it here's what I did in mantis 1.2.17:

in core/access_api.php function access_has_bug_level
AFTER:

<<<<<
if( !$t_bug_is_user_reporter && bug_get_field( $p_bug_id, 'view_state' ) == VS_PRIVATE ) {
<<<<<

INSERT:

//check if user is monitor
$t_bug_monitor_table = db_get_table('mantis_bug_monitor_table');
$query = "SELECT 1 FROM $t_bug_monitor_table WHERE bug_id=" . db_param() . " AND user_id = " . db_param();

$result = db_query_bound($query, Array($p_bug_id, $p_user_id));
if (db_num_rows($result)) {
//treat as if bug was public
return access_compare_level($t_access_level, $p_access_level);
}

in core/filter_api.php function filter_get_bug_rows

REPLACE

<<<<<
$t_public_view_state_check = "( ( $t_bug_table.view_state = " . VS_PUBLIC . " ) OR ( $t_bug_table.reporter_id = $t_user_id ) )";
<<<<<

WITH

$t_public_view_state_check = "( ( $t_bug_table.view_state = " . VS_PUBLIC . " ) OR ( $t_bug_table.reporter_id = $t_user_id ) OR (SELECT 1 FROM $t_bug_monitor_table WHERE $t_bug_monitor_table.user_id = $t_user_id AND $t_bug_monitor_table.bug_id = $t_bug_table.id LIMIT 1))";

Using a subquery might not be the most elegant way, but it worked without major code changes. For a release this might also require a configuration switch.

0xFF

0xFF

2015-12-03 10:00

reporter   ~0052003

I needed this feature too since I have some reports which must be visible nominatively (addition as monitor being a perfect for this). So, I successfully applied the cwipll's code, above, in a MantiBT 1.2.14.

Just a point to take care of (obvious, but easy to forgot) : $t_access_level must be defined before (ie. above) the inserted code in core/access_api.php's access_has_bug_level function. Otherwise, the bug is well visible in the "View issues" page, but still unreachable (access denied).

aavagyan

aavagyan

2017-05-19 03:24

reporter   ~0056904

Would be nice feature. Can be done as config option - enable or disable this feature to satisfy everyone.

kabushka

kabushka

2017-11-07 07:23

reporter   ~0058155

It would be really helpful feature to add reporters and updaters into a private issue.
Right now I couldn't find an option how a reporter (who didn't create an issue) can participate in a discussion inside a private issue.

kabushka

kabushka

2017-12-20 07:45

reporter   ~0058427

cwipll, thank you, it works.

I modified your code little bit for mantis 2.9.0.
Patches is downloaded.



monitoring.patch (2,179 bytes)
diff -ur mantisbt-2.9.0/core/access_api.php mantis-2.9.0-AT/core/access_api.php
--- mantisbt-2.9.0/core/access_api.php	2017-12-04 06:57:48.000000000 +0500
+++ mantis-2.9.0-AT/core/access_api.php	2017-12-20 15:40:36.000000000 +0500
@@ -536,6 +536,18 @@
 	# If the bug is private and the user is not the reporter, then
 	# they must also have higher access than private_bug_threshold
 	if( !$t_bug_is_user_reporter && bug_get_field( $p_bug_id, 'view_state' ) == VS_PRIVATE ) {
+
+		// ====== check if user monitores ===== 
+		$t_bug_monitor_table = db_get_table('mantis_bug_monitor_table');
+		$query = "SELECT 1 FROM $t_bug_monitor_table WHERE bug_id=" . db_param() . " AND user_id = " . db_param();
+
+		$result = db_query_bound($query, Array($p_bug_id, $p_user_id));
+		if (db_num_rows($result)) {
+		//treat as if bug was public
+		return access_compare_level($t_access_level, $p_access_level);
+		}
+		//====== end ======
+
 		$t_private_bug_threshold = config_get( 'private_bug_threshold', null, $p_user_id, $t_project_id );
 		return access_compare_level( $t_access_level, $t_private_bug_threshold )
 			&& access_compare_level( $t_access_level, $p_access_level );

diff -ur mantisbt-2.9.0/core/filter_api.php mantis-2.9.0-AT/core/filter_api.php
--- mantisbt-2.9.0/core/filter_api.php	2017-12-04 06:57:48.000000000 +0500
+++ mantis-2.9.0-AT/core/filter_api.php	2017-12-20 15:41:26.000000000 +0500
@@ -1531,7 +1531,14 @@
 		}
 
 		$t_count_public_only_project_ids = count( $t_public_only_project_ids );
-		$t_public_view_state_check = '( ( {bug}.view_state = ' . VS_PUBLIC . ' ) OR ( {bug}.reporter_id = ' . $t_user_id . ') )';
+// ====== monitored issue view ===== 
+		$t_public_view_state_check = '( 
+			( {bug}.view_state = ' . VS_PUBLIC . ' ) 
+			OR ( {bug}.reporter_id = ' . $t_user_id . ') 
+			OR (SELECT true FROM {bug_monitor} 
+				WHERE {bug_monitor}.user_id = ' . $t_user_id . ' LIMIT 1) 
+		)';
+// ======= end ===========
 		if( $t_count_public_only_project_ids == 1 ) {
 			$t_public_only_query = '( ( {bug}.project_id = ' . $t_public_only_project_ids[0] . ' ) AND ' . $t_public_view_state_check . ')';
 		} else if( $t_count_public_only_project_ids > 1 ) {
monitoring.patch (2,179 bytes)
saebi

saebi

2018-02-04 04:53

reporter   ~0058735

I have same problem with my_view page, and I wrote it on issue 25314 ( https://www.mantisbt.org/forums/viewtopic.php?f=3&amp;t=25314&amp;p=64473#p64473 ),
I will be thankful if someone help me.

kabushka

kabushka

2018-03-21 09:45

reporter   ~0059265

I'm sorry, there is a mistake in my previous path.
New patch is correct for php 7.0 and mantis 2.9.0



monitoring-2.patch (2,353 bytes)
diff -ur mantisbt-2.9.0/core/access_api.php mantis-2.9.0-AT/core/access_api.php
--- mantisbt-2.9.0/core/access_api.php	2017-12-04 06:57:48.000000000 +0500
+++ mantis-2.9.0-AT/core/access_api.php	2017-12-20 15:40:36.000000000 +0500
@@ -536,6 +536,18 @@
 	# If the bug is private and the user is not the reporter, then
 	# they must also have higher access than private_bug_threshold
 	if( !$t_bug_is_user_reporter && bug_get_field( $p_bug_id, 'view_state' ) == VS_PRIVATE ) {
+
+		// ====== check if user monitores ===== 
+		$t_bug_monitor_table = db_get_table('mantis_bug_monitor_table');
+		$query = "SELECT 1 FROM $t_bug_monitor_table WHERE bug_id=" . db_param() . " AND user_id = " . db_param();
+
+		$result = db_query_bound($query, Array($p_bug_id, $p_user_id));
+		if (db_num_rows($result)) {
+		//treat as if bug was public
+		return access_compare_level($t_access_level, $p_access_level);
+		}
+		//====== end ======
+
 		$t_private_bug_threshold = config_get( 'private_bug_threshold', null, $p_user_id, $t_project_id );
 		return access_compare_level( $t_access_level, $t_private_bug_threshold )
 			&& access_compare_level( $t_access_level, $p_access_level );

diff -ur mantisbt-2.9.0/core/filter_api.php mantis-2.9.0-AT/core/filter_api.php
--- mantisbt-2.9.0/core/filter_api.php	2017-12-04 06:57:48.000000000 +0500
+++ mantis-2.9.0-AT/core/filter_api.php	2017-12-20 15:41:26.000000000 +0500
@@ -1531,7 +1531,14 @@
 		}
 
 		$t_count_public_only_project_ids = count( $t_public_only_project_ids );
-		$t_public_view_state_check = '( ( {bug}.view_state = ' . VS_PUBLIC . ' ) OR ( {bug}.reporter_id = ' . $t_user_id . ') )';
+// ====== monitored issue view ===== 
+		$t_public_view_state_check = '( 
+                       ( {bug}.view_state = ' . VS_PUBLIC . ' ) 
+                        OR ( {bug}.reporter_id = ' . $t_user_id . ') 
+                        OR (SELECT true FROM {bug_monitor} 
+                                WHERE {bug_monitor}.user_id = ' . $t_user_id . ' 
+                                AND {bug_monitor}.bug_id = {bug}.id LIMIT 1) 
+                )';
+// ======= end ===========
 		if( $t_count_public_only_project_ids == 1 ) {
 			$t_public_only_query = '( ( {bug}.project_id = ' . $t_public_only_project_ids[0] . ' ) AND ' . $t_public_view_state_check . ')';
 		} else if( $t_count_public_only_project_ids > 1 ) {
monitoring-2.patch (2,353 bytes)
kokerp

kokerp

2018-05-14 03:53

reporter   ~0059778

Last edited: 2018-07-18 21:03

View 3 revisions

Dear all
I had refer 0005702:0059265 (monitoring-2.patch ), and try to do it.

On my test environment
Add new issue #0000045,and add ID:M0503 to monitored this issue.
use ID:M0503 log in,
At 'My View' can't see #0000045
But use link can see it .

On My View-->Monitored by Me How can i set see it
Or am I having a setup error over there?
Thank you.

================================================================
update note 2018-07-19
on the live environment try again monitoring-2.patch, it can work.
live environment version is 2.12.2.
test environment version is 2.14.0 or more high (i forget test version)
so i not sure the cause is version problem or add many plugins
anyway the ver 2.12.2 is can show on 'Monitored by Me',
Thank you.



20180514.docx (286,385 bytes)
On86

On86

2018-07-18 09:50

reporter   ~0060278

Last edited: 2018-07-18 09:51

View 2 revisions

Hello all,

I have MantisBT Version 2.15.0 and after implementing modification proposed by user: Kabushka, user who is monitoring issue can access post only by using URL link.
Can someone help me with modifying PHP code so that user that is monitoring the issue can see it under "Monitored by Me" (main page) ?

Modification in filter_api.php file, proposed by kabushka and cwipll don't work in latest Mantis version...

Best Regards,
Maciej

emet

emet

2018-10-05 07:49

reporter   ~0060750

Hey,

Has anyone managed to correct the code in the latest version of Mantis?
Modification in filter_api.php file don't work in latest Mantis version :(

Thanks

Issue History

Date Modified Username Field Change
2005-06-02 08:21 w_moroz New Issue
2005-06-02 09:13 vboctor Relationship added has duplicate 0005701
2005-06-03 04:42 vboctor Note Added: 0010340
2005-06-03 04:42 vboctor Status new => acknowledged
2005-06-03 04:45 vboctor Note Added: 0010341
2005-06-03 05:43 w_moroz Note Added: 0010343
2011-02-17 08:00 istvanb Note Added: 0028251
2011-07-15 04:46 jas0n Note Added: 0029175
2011-07-15 04:47 jas0n Note Edited: 0029175 View Revisions
2011-08-11 00:04 toddpw Note Added: 0029458
2011-08-11 03:38 dregad Relationship added has duplicate 0004763
2013-02-06 10:52 atrol Relationship added related to 0007642
2013-02-06 10:52 atrol Relationship added related to 0007584
2013-02-06 10:54 atrol Relationship added related to 0015466
2013-02-14 15:15 dregad Relationship added has duplicate 0015505
2015-07-15 14:52 cwipll Note Added: 0051073
2015-12-03 10:00 0xFF Note Added: 0052003
2017-05-19 03:24 aavagyan Note Added: 0056904
2017-11-07 07:23 kabushka Note Added: 0058155
2017-12-20 07:45 kabushka File Added: monitoring.patch
2017-12-20 07:45 kabushka Note Added: 0058427
2018-02-04 04:53 saebi Note Added: 0058735
2018-03-21 09:45 kabushka File Added: monitoring-2.patch
2018-03-21 09:45 kabushka Note Added: 0059265
2018-05-14 03:53 kokerp File Added: 20180514.docx
2018-05-14 03:53 kokerp Note Added: 0059778
2018-07-18 09:50 On86 Note Added: 0060278
2018-07-18 09:51 On86 Note Edited: 0060278 View Revisions
2018-07-18 21:02 kokerp Note Edited: 0059778 View Revisions
2018-07-18 21:03 kokerp Note Edited: 0059778 View Revisions
2018-10-05 07:49 emet Note Added: 0060750