How to create your own usergroups in Joomla 1.5...

Locked
ssbechtold3
Joomla! Fledgling
Joomla! Fledgling
Posts: 2
Joined: Thu Jan 24, 2008 11:51 pm

How to create your own usergroups in Joomla 1.5...

Post by ssbechtold3 » Sun Jan 27, 2008 2:18 am

Warning, I am no coding expert, but after hours of playing around with things I found a work around thanks to this post:

http://forum.joomla.org/index.php/topic,208180.0.html

I am not going to be replying to this post, so don't expect for me to answer.  All I can say is that what I did worked for my website.  I do not know about permissions such as for author, administrator, etc, the groups I made were just differently titled registered users.  I would ASSUME that the child group would have the same permissions as the parent group, however I do not know this for sure it is only a guess.

Ok, so here we go, I edited the original post as necessary and also have two attachments to make things easier for you guys. Enjoy!
spiderglobe wrote: 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/views/user/view.html.php line 112:

NOTE I ATTACHED THE FILE SO ALL YOU HAVE TO DO IS OVERWRITE THE PREVIOUS ONE, HOWEVER IF YOU DON'T TRUST ME YOU CAN FOLLOW THE INSTRUCTIONS BELOW.

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:

THIS IS WHAT I DID BECAUSE I COULDN'T FIGURE OUT HOW TO GET HIS CODE TO WORK, IF YOU CAN GET IT TO WORK FIND IT BELOW THESE INSTRUCTIONS:

For lft add 1 to the last id's lft value.  For rgt subtract 1 from the last id's rgt value.  I attached a screenshot so you guys can see what I did.

END INSTRUCTIONS.

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;
}
?>
LIKE I SAID ABOVE, I DO NOT KNOW ABOUT PERMISSIONS, BUT YOU CAN TRY WHAT HE SUGGESTS IF YOU WANT.

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.
You do not have the required permissions to view the files attached to this post.
Last edited by ssbechtold3 on Sun Jan 27, 2008 2:21 am, edited 1 time in total.

herb200mph
Joomla! Virtuoso
Joomla! Virtuoso
Posts: 3592
Joined: Sun Jun 25, 2006 12:12 am
Location: Salisbury, NC/USA (N. of Charlotte)
Contact:

Re: How to create your own usergroups in Joomla 1.5...

Post by herb200mph » Sun Feb 10, 2008 6:53 pm

Check latest extensions ... JACL type extension was released.
Author: Joomla! 5: Boots on the Ground, Volume 1 @ Amazon.com
Author: Joomla! 4: BASIC TRAINING - Boots on the Ground @ Amazon.com
Joomla! Magazine - https://magazine.joomla.org/all-issues/ ... c-training

Cougar Draven
Joomla! Fledgling
Joomla! Fledgling
Posts: 2
Joined: Mon Feb 11, 2008 11:13 am

Re: How to create your own usergroups in Joomla 1.5...

Post by Cougar Draven » Mon Feb 11, 2008 12:14 pm

Now, I'm curious. Does the same work in 1.0.x, or do I have to upgrade to make this work?

herb200mph
Joomla! Virtuoso
Joomla! Virtuoso
Posts: 3592
Joined: Sun Jun 25, 2006 12:12 am
Location: Salisbury, NC/USA (N. of Charlotte)
Contact:

Re: How to create your own usergroups in Joomla 1.5...

Post by herb200mph » Mon Feb 11, 2008 1:46 pm

Search the extensions for JACL and other User Management items.  Lots of them for 1.0x I believe.
Author: Joomla! 5: Boots on the Ground, Volume 1 @ Amazon.com
Author: Joomla! 4: BASIC TRAINING - Boots on the Ground @ Amazon.com
Joomla! Magazine - https://magazine.joomla.org/all-issues/ ... c-training


Locked

Return to “Tips & Tricks - Moving”