Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Modify permision to show owner records to the reporting user also. #131

Open
wants to merge 2 commits into from

3 participants

Sergi Almacellas Abellana John Mertic Eddy
Sergi Almacellas Abellana

Improves the user hierarchy defined by the report_to field from users by giving permision to work on your child users' assigned registers.

Bug report comming.

Sergi Almacellas Abellana pokoli Modify permision to show owner records to the reporting user also.
This allows to define a user hierarchy and you have permision to work on your child's assigned registers.
87bb14a
John Mertic

Thanks, looking forward to that bug report so we can pull this in.

Also, could you send me ( jmertic@sugarcrm.com ) this contribution agreement ( http://www.sugarforge.org/content/community/participate/agreement.html ) signed by you? Thanks!

Eddy
Collaborator

Thanks for taking the time to submit a pull request and open a bug report pokoli. Just letting you know this bug is currently in line to be reviewed by our Product Management Team.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 5, 2012
  1. Sergi Almacellas Abellana

    Modify permision to show owner records to the reporting user also.

    pokoli authored
    This allows to define a user hierarchy and you have permision to work on your child's assigned registers.
Commits on Apr 30, 2013
  1. Sergi Almacellas Abellana
This page is out of date. Refresh to see the latest.
Showing with 9 additions and 4 deletions.
  1. +9 −4 data/SugarBean.php
13 data/SugarBean.php
View
@@ -5135,16 +5135,21 @@ function isOwner($user_id)
{
return true;
}
+ $users=array();
+ $users[]=$user_id;
+ $res = $this->db->query("select id from users where reports_to_id = '$user_id'");
+ while($row = $this->db->fetchByAssoc($res))
+ $users[]=$row['id'];
//if there is an assigned_user that is the owner
if(isset($this->assigned_user_id))
{
- if($this->assigned_user_id == $user_id) return true;
+ if(in_array($this->assigned_user_id,$users)) return true;
return false;
}
else
{
//other wise if there is a created_by that is the owner
- if(isset($this->created_by) && $this->created_by == $user_id)
+ if(isset($this->created_by) && in_array($this->created_by,$users))
{
return true;
}
@@ -5161,11 +5166,11 @@ function getOwnerWhere($user_id)
{
if(isset($this->field_defs['assigned_user_id']))
{
- return " $this->table_name.assigned_user_id ='$user_id' ";
+ return " ( $this->table_name.assigned_user_id ='$user_id' or $this->table_name.assigned_user_id in (select id from users where reports_to_id = '$user_id') ) ";
}
if(isset($this->field_defs['created_by']))
{
- return " $this->table_name.created_by ='$user_id' ";
+ return " ( $this->table_name.created_by ='$user_id' or $this->table_name.created_by in (select id from users where reports_to_id = '$user_id') ) ";
}
return '';
}
Something went wrong with that request. Please try again.