Page 1 of 2 12 LastLast
Results 1 to 10 of 18

Thread: Disabling Modules via Roles

  1. #1
    cpscdave is offline Sugar Community Member
    Join Date
    Jun 2007
    Posts
    36

    Default Disabling Modules via Roles

    Hi Just a vefification question.

    We've tried to disable some modules via role setting the module to disbaled. For example campaigns on Associate role.

    I went thru and updated the Associate role and set Campaign to disabled. However whne I log in as an associate campaign still appears on the tool bar and I am still able to go to the module and enter/view/update data.

    So my question is Roles do roles not work off the shelf like this?

  2. #2
    eggsurplus's Avatar
    eggsurplus is offline Sugar Community Member
    Join Date
    Dec 2005
    Location
    Minnesota
    Posts
    2,343

    Default Re: Disabling Modules via Roles

    Hi cpscdave,

    You'll need to edit the user itself to hide tabs. If you want to hide tabs for everyone you can do that in Admin->Configure Tabs. The role change just disables their rights.

    Hope that helps!

  3. #3
    cpscdave is offline Sugar Community Member
    Join Date
    Jun 2007
    Posts
    36

    Default Re: Disabling Modules via Roles

    Thanks that is what we figured.

    1 other question. (I'll look thru myslef and see if I can find it but if ppl can save me time yay)

    Where in the db are user tab pref's stored? We'd like to make a script that sets these up for everyone in the roles.

    thanks again
    -Dave

  4. #4
    eggsurplus's Avatar
    eggsurplus is offline Sugar Community Member
    Join Date
    Dec 2005
    Location
    Minnesota
    Posts
    2,343

    Default Re: Disabling Modules via Roles

    cpscdave,

    It's in the content column of user_preferences.

    select * from user_preferences
    where category = 'global'

    Since it's all scrambled it may be easiest to write a stand-alone php script that you can either run from a command-line or from hitting a stand-alone page in your browser. You would set the users to update and update their preferences one-by-one.

    This hasn't been tested but it should be similar:
    PHP Code:
    <?php

    require_once('modules/Users/User.php');
    global 
    $db;

    $displayTabs = array('Home','Calendar','Activities','Contacts','Accounts','Leads','Opportunities','Cases','Bugs','Documents','Email');
    $hideTabs = array('Campaigns','Project','Dashboard');
    $removeTabs = array('Feeds','iFrames');
    $results $this->db->query('SELECT id FROM users WHERE deleted = 0');;
    while(
    $row $this->db->fetchByAssoc($results )) {
       
    $focus = new User();
       
    $focus->retrieve($row['id']);
       
    $focus->setPreference('display_tabs'$displayTabs);
       
    $focus->setPreference('hide_tabs'$hideTabs);
       
    $focus->setPreference('remove_tabs'$removeTabs);
    }

    ?>

  5. #5
    cpscdave is offline Sugar Community Member
    Join Date
    Jun 2007
    Posts
    36

    Default Re: Disabling Modules via Roles

    Awesome thank you very much, I'm in the process of writing what I need and will post it here when done for future ppl to use.
    *I'm adding a USER action to update all their pref's based on their role*

    But what is the difference between Hide and remove tab?

  6. #6
    cpscdave is offline Sugar Community Member
    Join Date
    Jun 2007
    Posts
    36

    Default Re: Disabling Modules via Roles

    So what I did is created a file tabUpdate.php in modules/User
    Then just goto that action and it will update that user's prefences

    Thanks for the insight eggsurplus

    PHP Code:
    <?php
    require_once('modules/Users/User.php');
    global 
    $db;
    $displayTabs = array('Home','Calendar','Activities','Contacts','A  ccounts','Leads','Opportunities','Cases','Bugs','D  ocuments','Email');
    $hideTabs = array('Campaigns','Project','Dashboard');
    $removeTabs = array('Feeds','iFrames');
    $results $db->query("SELECT id FROM users WHERE deleted = 0");

    while(
    $row $db->fetchByAssoc($results))
     {

       
    //get the role(s) for the user
       
    require_once('modules/ACLRoles/ACLRole.php');
       
    $theRoles ACLRole::getUserRoleNames($row['id']);
       
    $focus = new User();
       
    $focus->retrieve($row['id']);
       
    $role $theRoles[0];
       switch(
    $role)
       {
       default:
         print 
    "{$row['id']} Has no role or unknown role <br>";
       case 
    'SR. Associate':
         
    $displayTabs = array('Home','Calendar','Activities','Contacts','Accounts','Leads','Opportunities','Documents','Email');
         
    $hideTabs = array('Project','Dashboard');
         
    $removeTabs = array('Feeds','iFrames''Forecasts','Reports','Contracts''Campaigns','Cases''Bugs');
         break;
       case 
    'Executive Associate':
         
    $displayTabs = array('Home','Calendar','Activities','Contacts','Accounts','Leads','Opportunities','Documents','Email''Bugs','Forecasts');
         
    $hideTabs = array('Project','Dashboard');
         
    $removeTabs = array('Feeds','iFrames','Reports','Contracts''Campaigns','Cases',);
         break;
       case 
    'Human Resources':
       case 
    'Executive':
         
    $displayTabs = array('Home','Calendar','Activities','Contacts','Accounts','Leads','Opportunities','Documents','Email''Bugs','Forecasts','Campaig\
    ns'
    );
         
    $hideTabs = array('Project','Dashboard');
         
    $removeTabs = array('Feeds','iFrames','Reports','Contracts','Cases');

         break;
       case 
    'TechSupport':
       case 
    'Administration':

         
    $displayTabs = array('Home','Calendar','Activities','Contacts','Accounts','Leads','Opportunities','Documents','Email''Bugs','Forecasts','Campaig\
    \ns'
    ,'Project','Dashboard','Feeds','iFrames','Reports','Contracts','Cases');
         
    $hideTabs = array();
         
    $removeTabs = array();
         break;

       }

       
    $focus->setPreference('display_tabs'$displayTabs);
       
    $focus->setPreference('hide_tabs'$hideTabs);
       
    $focus->setPreference('remove_tabs'$removeTabs);
       
    $focus->savePreferecesToDB();
     }
    ?>

  7. #7
    Markku's Avatar
    Markku is offline Sugar Community Member
    Join Date
    Nov 2004
    Location
    Helsinki
    Posts
    910

    Default Re: Disabling Modules via Roles

    I believe this is very useful for many Sugar users, thanks much cpscdave and eggsurplus!

  8. #8
    andydreisch's Avatar
    andydreisch is offline Sugar Team Member
    Join Date
    Apr 2005
    Location
    San Jose
    Posts
    2,080

    Default Re: Disabling Modules via Roles

    We agree!! We've been closely following this thread. This seems to be a very useful utility.

    Now ... who wants to make a full-blown SugarForge project for this? In this way it can be better accessed, managed, described, promoted, etc.

    Any takers?

    Andy
    Andy Dreisch
    Vice President, Online Team


    Check out our Podcasts!
    Sugar University for training
    Sugar Wiki for developer and user help
    SugarForge for modules, themes, lang packs
    SugarExchange for production-ready extensions
    Enter/view bugs via the Sugar bug tracker

  9. #9
    Markku's Avatar
    Markku is offline Sugar Community Member
    Join Date
    Nov 2004
    Location
    Helsinki
    Posts
    910

    Default Re: Disabling Modules via Roles

    Hi Andy,

    This sounds like good SugarForge project for cpscdave and/or eggsurplus

  10. #10
    eggsurplus's Avatar
    eggsurplus is offline Sugar Community Member
    Join Date
    Dec 2005
    Location
    Minnesota
    Posts
    2,343

    Default Re: Disabling Modules via Roles

    Nice job cpscdave, that was fast!

Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. ability to load basic modules through module loader
    By Systems Navigator in forum Developer Help
    Replies: 0
    Last Post: 2007-06-15, 11:35 AM
  2. Modules for 4.5 + - that install forum
    By rtwgn in forum Downloads
    Replies: 0
    Last Post: 2006-10-03, 12:16 PM
  3. Roles seem backwards to me...
    By Xaox in forum General Discussion
    Replies: 0
    Last Post: 2006-07-19, 04:23 PM
  4. Replies: 2
    Last Post: 2006-02-19, 12:39 PM
  5. Disabling Modules
    By JStinson in forum Feature Requests
    Replies: 0
    Last Post: 2005-01-28, 07:54 PM

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
  •