Restrict Agents from viewing tickets/users created by others

Moderator: crythias

Locked
hmmmm3
Znuny newbie
Posts: 57
Joined: 17 Feb 2012, 07:48
Znuny Version: 3

Restrict Agents from viewing tickets/users created by others

Post by hmmmm3 »

I was working on a way to restrict agents from seeing customers that other agents created. I'm not sure if my approach is the best, but it seems to work for me. The way it works is that the logged-in user can only see tickets of customers that he/she created. Likewise, they can only see a listing of customers that they created. I want to restrict my agents just to their departments, and restrict any info they see. I figured since I had seen this question before, it wouldn't hurt if I posted it.

These changes apply to results shown on the tickets page, and the customers name shown in the jquery fields on the new ticket pages. If you try this out, let me know if you find some areas that this doesn't cover. This is a work in progress. I am using version 3.0. I am not a perl programmer, so this is a hacked-up hack. Hopefully I documented all my changes.

Is there a better way to do this?

The files that I edited are:

1.) Modules/AdminCustomerUser.pm
around line 532

Code: Select all

    if ( $Param{Search} ) {
        my %List = $Self->{CustomerUserObject}->CustomerSearch(
            Search => $Param{Search},
            Valid  => 0,
            User => $Self->{UserID},      #this line adds the check for the current logged-in agent
2.) Kernel/System/CustomerUser.pm
around line 145:

Code: Select all

    my %List = $CustomerUserObject->CustomerSearch(
        Search => '*some*', # also 'hans+huber' possible
        Valid  => 1, # not required, default 1
        User   =>  3,  # i honestly don't remember why I put 3 here
    );

    my %List = $CustomerUserObject->CustomerSearch(
        UserLogin => '*some*',
        Valid     => 1, # not required, default 1
        User      =>  3,  # i honestly don't remember why I put 3 here
    );

    my %List = $CustomerUserObject->CustomerSearch(
        PostMasterSearch => 'email@example.com',
        Valid            => 1, # not required, default 1
        User             =>  3,   # i honestly don't remember why I put 3 here
    );

3.) /System/CustomerUser/DB.pm
around line 250:

Code: Select all

if ($Param{User} eq 2){  #2 is the id for my admin that I want to have access to all customers  - I call him SuperDuperAdmin
  		$SQL .= " FROM $Self->{CustomerTable} WHERE ";
	} 
	else{  # if this is a regular mortal agent
             $SQL .= " FROM $Self->{CustomerTable} WHERE create_by='".$Param{User}."'  AND ";
	}
4.) Kernel/Modules/AgentCustomerSearch.pm
around line 69

Code: Select all

   # get customer list
        my %CustomerUserList = $Self->{CustomerUserObject}->CustomerSearch(
            Search => $Search,
            User => $Self->{UserID}, #added this to limit the search

        );
Hopefully, I didnt forget anything.
Locked