"Assigned to me" with resolved ones

Post about your customizations to share with others.

Moderators: Developer, Contributor

Post Reply
pdario
Posts: 10
Joined: 03 Feb 2021, 14:55

"Assigned to me" with resolved ones

Post by pdario »

Hello,

I need to see in my homepage the list of issues "assigned to me" but with the resolved oned, too.

Is this possible?

Thank you!
cas
Posts: 1023
Joined: 11 Mar 2006, 16:08
Contact:

Re: "Assigned to me" with resolved ones

Post by cas »

not possible out of the box, you would need to:
-define another box on the my_view page
-adjust a core script
In both cases something you would need to do again with each upgrade.
pdario
Posts: 10
Joined: 03 Feb 2021, 14:55

Re: "Assigned to me" with resolved ones

Post by pdario »

Ok, I can manage this: can you help me with the steps?
cas
Posts: 1023
Joined: 11 Mar 2006, 16:08
Contact:

Re: "Assigned to me" with resolved ones

Post by cas »

Ok, here is the quick and dirty solution.
open core/file_api.php
find function filter_create_assigned_to_unresolved which looks like:

Code: Select all

function filter_create_assigned_to_unresolved( $p_project_id, $p_user_id ) {
	$t_filter = filter_get_default();

	if( $p_user_id == 0 ) {
		$t_filter[FILTER_PROPERTY_HANDLER_ID] = array( '0' => META_FILTER_NONE );
	} else {
		$t_filter[FILTER_PROPERTY_HANDLER_ID] = array( '0' => $p_user_id );
	}

	$t_bug_resolved_status_threshold = config_get( 'bug_resolved_status_threshold', null, $p_user_id, $p_project_id );
	$t_filter[FILTER_PROPERTY_HIDE_STATUS] = array( '0' => $t_bug_resolved_status_threshold );

	if( $p_project_id != ALL_PROJECTS ) {
		$t_filter[FILTER_PROPERTY_PROJECT_ID] = array( '0' => $p_project_id );
	}

	return filter_ensure_valid_filter( $t_filter );
}
 
change this into:

Code: Select all

function filter_create_assigned_to_unresolved( $p_project_id, $p_user_id ) {
	$t_filter = filter_get_default();

	if( $p_user_id == 0 ) {
		$t_filter[FILTER_PROPERTY_HANDLER_ID] = array( '0' => META_FILTER_NONE );
	} else {
		$t_filter[FILTER_PROPERTY_HANDLER_ID] = array( '0' => $p_user_id );
	}
	if( $p_project_id != ALL_PROJECTS ) {
		$t_filter[FILTER_PROPERTY_PROJECT_ID] = array( '0' => $p_project_id );
	}

	return filter_ensure_valid_filter( $t_filter );
}
 
this does mean that wherever the function is used, also resolved/closed items will be shown.
pdario
Posts: 10
Joined: 03 Feb 2021, 14:55

Re: "Assigned to me" with resolved ones

Post by pdario »

I assume this will change the behavior for all users; is it possible to have a different defined function to be added to my home page?
cas
Posts: 1023
Joined: 11 Mar 2006, 16:08
Contact:

Re: "Assigned to me" with resolved ones

Post by cas »

Correct, this would change it for all users. If you would like it to be only for you, new code (replacing old one)would look like:

Code: Select all

function filter_create_assigned_to_unresolved( $p_project_id, $p_user_id ) {
	$t_filter = filter_get_default();

	if ($p_user_id) <> 23) {
		if( $p_user_id == 0 ) {
			$t_filter[FILTER_PROPERTY_HANDLER_ID] = array( '0' => META_FILTER_NONE );
		} else {
			$t_filter[FILTER_PROPERTY_HANDLER_ID] = array( '0' => $p_user_id );
		}

		$t_bug_resolved_status_threshold = config_get( 'bug_resolved_status_threshold', null, $p_user_id, $p_project_id );
		$t_filter[FILTER_PROPERTY_HIDE_STATUS] = array( '0' => $t_bug_resolved_status_threshold );

		if( $p_project_id != ALL_PROJECTS ) {
			$t_filter[FILTER_PROPERTY_PROJECT_ID] = array( '0' => $p_project_id );
		}
	} else {
		if( $p_user_id == 0 ) {
			$t_filter[FILTER_PROPERTY_HANDLER_ID] = array( '0' => META_FILTER_NONE );
		} else {
			$t_filter[FILTER_PROPERTY_HANDLER_ID] = array( '0' => $p_user_id );
		}
		if( $p_project_id != ALL_PROJECTS ) {
			$t_filter[FILTER_PROPERTY_PROJECT_ID] = array( '0' => $p_project_id );
		}

	}

	return filter_ensure_valid_filter( $t_filter );
}
Be sure to put your user_id in this line
if ($p_user_id) <> 23) {
So replace 23 with your user_id ( admin => 1)
pdario
Posts: 10
Joined: 03 Feb 2021, 14:55

Re: "Assigned to me" with resolved ones

Post by pdario »

Ok, I understand, but is it possibile to add a new section to my home page with a new custom function as the one you wrote?
cas
Posts: 1023
Joined: 11 Mar 2006, 16:08
Contact:

Re: "Assigned to me" with resolved ones

Post by cas »

yes, of course is possible, this section will then be visible for all unless you use a condition to show or not (like in the code I gave you).
But that is almost writing a plugin ( which could be the best solution for you anyway) which goes beyond a simple answer :mrgreen:
Post Reply