Results 1 to 4 of 4

Thread: Help, change the selection critiria based on the role

  1. #1
    sujiea is offline Sugar Community Member
    Join Date
    Nov 2007
    Location
    Melbourne, Australia
    Posts
    12

    Unhappy Help, change the selection critiria based on the role

    For an example, if a requirements is "When a lead converts to a contact, it is to be hidden in the lead look up for all B2C and B2B sales consultants. The Sales Manager and above will still be able to view and run reports on leads." Which file should I add code in? I am using 5.0 Beta 2 at the moment.
    Last edited by sujiea; 2007-11-15 at 04:06 AM.

  2. #2
    sujiea is offline Sugar Community Member
    Join Date
    Nov 2007
    Location
    Melbourne, Australia
    Posts
    12

    Talking Re: Help, change the selection critiria based on the role

    Solve the problem in a very stupid way!!!

    change get_list_view_data() in Lead.php file, adding a few rows of code:

    //For sales_B2C and sales_B2B user, they can not see the converted leads. Others will be able to see them
    $role_to_check1 = "Sales_B2C"; // change this to the name of the role that you want to do a check on
    $role_to_check2 = "Sales_B2B";

    global $current_user; // grab the $current_user object
    require_once("modules/ACLRoles/ACLRole.php");
    $acl_role_obj = new ACLRole();

    $user_roles = $acl_role_obj->getUserRoles($current_user->id); // grab a list of the current user's roles
    //print_r($user_roles);
    //die;
    $user_in_role = FALSE;
    foreach ($user_roles as $role) {
    if ($role == $role_to_check1 || $role== $role_to_check2) { // is the user in the role we're trying to restrict?
    $user_in_role = TRUE;
    break;
    }
    }

    if($user_in_role && $temp_array['STATUS'] == 'Converted')
    return null;
    else
    return $temp_array;


    And then I rewrite part of the listView.php and listViewData.php to match it.

    It's not a very good idea because it involves a lot of changes (which might bring a lot of bugs). But it's the only way I can think of. Please help me if there are better ways of doing this.

  3. #3
    sujiea is offline Sugar Community Member
    Join Date
    Nov 2007
    Location
    Melbourne, Australia
    Posts
    12

    Default Re: Help, change the selection critiria based on the role

    Up! Any comments will be appreciated.

  4. #4
    sujiea is offline Sugar Community Member
    Join Date
    Nov 2007
    Location
    Melbourne, Australia
    Posts
    12

    Default Re: Help, change the selection critiria based on the role

    FInd a better way:

    $role_to_check1 = "Sales_B2C"; // change this to the name of the role that you want to do a check on
    $role_to_check2 = "Sales_B2B";


    require_once("modules/ACLRoles/ACLRole.php");
    $acl_role_obj = new ACLRole();

    $user_roles = $acl_role_obj->getUserRoles($current_user->id); // grab a list of the current user's roles
    //print_r($user_roles);
    //die;
    $user_in_role = FALSE;
    foreach ($user_roles as $role) {
    if ($role == $role_to_check1 || $role== $role_to_check2) { // is the user in the role we're trying to restrict?
    $user_in_role = TRUE;
    break;
    }
    }

    if($user_in_role && !empty($_REQUEST['module']) && $_REQUEST['module']== 'Leads')
    if($where !="")
    $where .= " AND ( leads.status in ('New','In Process','Dead','Recycled')) ";
    else
    $where .=" ( leads.status in ('New','In Process','Dead','Recycled'))";

    //echo $where;
    //die;


    Insert the above code under getListViewData function under include/listView/listViewData.php.

    Maybe it's not perfect. But that's what I can do now.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. hericheacal role based security
    By bhawin13 in forum Developer Help
    Replies: 3
    Last Post: 2006-10-11, 12:09 PM
  2. Replies: 2
    Last Post: 2006-08-22, 09:38 AM
  3. role based hierarchy rather than user
    By lmewshaw in forum Developer Help
    Replies: 1
    Last Post: 2005-04-12, 03:58 PM
  4. Role based security
    By idenis in forum Feature Requests
    Replies: 0
    Last Post: 2005-01-31, 10:08 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •