Users groups display is not correct when customs groups are added

Need help with the Administration of your Joomla! 1.5 site? This is the spot for you.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
Locked
User avatar
spiderglobe
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 151
Joined: Mon Apr 03, 2006 1:45 pm
Location: Netherlands

Users groups display is not correct when customs groups are added

Post by spiderglobe » Sun Sep 02, 2007 7:06 am

Ls,

I use custom user groups (user roles) within Joomla 1.5. For example under the registered users group I've added several subgroups:
myproject
  customers
      customer A admin
  product manager
      product manager admin
  etc....

I use these groups within my extension to set the permissions.

When I add the groups into the jos_core_acl_aro_groups table and set the relations correctly the groups in the user management are not displayed correctly (e.q. the administrator groups disappear). For displaying the groups correctly you will have to change the code of :
/administrator/components/com_users/admin.users.php line 285:

Code: Select all

	if ( $userGroupName == $myGroupName && $myGroupName == 'administrator' )
	{
		// administrators can't change each other
		$lists['gid'] = '<input type="hidden" name="gid" value="'. $user->get('gid') .'" /><strong>'. JText::_( 'Administrator' ) .'</strong>';
	}
	else
	{
		$gtree = $acl->get_group_children_tree( null, 'USERS', false );
into

Code: Select all

	if ( $userGroupName == $myGroupName && $myGroupName == 'administrator' )
	{
		// administrators can't change each other
		$lists['gid'] = '<input type="hidden" name="gid" value="'. $user->get('gid') .'" /><strong>'. JText::_( 'Administrator' ) .'</strong>';
	}
	else
	{
		$gtree = $acl->get_group_children_tree( null, 'USERS', true);
If you like to add your self custom groups do the following:

Edit the jos_core_acl_aro_groups table  and add your custom groups (for example with phpmyadmin). When you add a new group make sure that you assign the correct parent to the added group. For example: the joomla registered group has the ID 19, when you assign a subgroup to it make sure that the parent_id is 19. Dont assign the lft and rght fields yet but use the code below to rebuild the groups tree correctly:

Code: Select all

<?php

mysql_connect("localhost", "xxxx", "xxxxx") or
    die("Could not connect: " . mysql_error());
	mysql_select_db("joomla15");

// 0-> parent_id in Joomla this is the value of the parent_id field of the Root record
// 1-> start the left tree at 1
rebuild_tree ( 0 , 1);


function rebuild_tree($parent_id, $left) {
   
 
// the right value of this node is the left value + 1
   $right = $left+1;

   // get all children of this node
   $result = mysql_query('SELECT id FROM jos_core_acl_aro_groups '.
                          'WHERE parent_id="'.$parent_id.'";');
   while ($row = mysql_fetch_array($result)) {
       // recursive execution of this function for each
       // child of this node
       // $right is the current right value, which is
       // incremented by the rebuild_tree function
       $right = rebuild_tree($row['id'], $right);
	  }

   // we've got the left value, and now that we've processed
   // the children of this node we also know the right value
   mysql_query('UPDATE jos_core_acl_aro_groups SET lft='.$left.', rgt='.
                $right.' WHERE id="'.$parent_id.'";');

   // return the right value of this node + 1
   return $right+1;
}
?>

When you want to use the custom groups to assign to your articles so that for example only the customers can view specific articles you need to add these groups into the jos_groups, just assign the ID + name of the group whereby the name must be equal to the groups names you added into the jos_core_acl_aro_groups table

Have fun.

R.
Last edited by spiderglobe on Sun Sep 02, 2007 7:12 am, edited 1 time in total.

eroesch
Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Thu Nov 08, 2007 11:08 pm

Re: Users groups display is not correct when customs groups are added

Post by eroesch » Mon Nov 12, 2007 1:30 pm

Hi .. Everything seems to work well for me, until the moment when I am to define the access levels of the articles. I did update the table jos_groups accordingly, making sure the name of the new group is the same than the one in jos_core_acl_aro_groups, but the new group does not appear in the field "Access level" to be modified in the articles ...

(Also, but I am not sure it's related, I cannot find the file admin.users.php .. I am using the last build of Joomla 1.5, so there may have been changes on that topic since the initial post).

Thanks much for your help!

Modificiation of the post:
Actually, .. when I think about it, I am not sure that creating custom roles would answer my needs: I would like to have 3 types of user groups with group1 being able to browse specific sections of the site, group2 being able to browse group1 sections + specific group2 sections, and group3 being able to browse group1 sections + group2 section + specific group3 sections.
I am not sure how I can do that .. any idea more than welcome! Thanks!

~etienne
Last edited by eroesch on Mon Nov 12, 2007 2:23 pm, edited 1 time in total.

metalmonster
Joomla! Apprentice
Joomla! Apprentice
Posts: 18
Joined: Mon Apr 26, 2010 9:38 am

Re: Users groups display is not correct when customs groups

Post by metalmonster » Mon May 10, 2010 2:58 pm

Hi, i want just to create some groups at the same level of the Registered users.
For example, using Docman, i want to create a Group for users that can download that specific document, and a group for users that must pay to download something from the site.
I tried to create a new group directly with phpmyadmin in the Groups table but i didn't see it in the list when creating a new user.

How can i do this ?

Thanks


Locked

Return to “Administration 1.5”