Limiting # groups member can join

10 years 4 months ago #132071 by zapacoman
Limiting # groups member can join was created by zapacoman
I'd love for a future release to incorporate the ability to limit the number of groups a member can join. For now, I guess I'll have to hack it in...which I'd rather not do.

But I am stuck...

I assume that i have to edit the following file:
components/com_groupjive/gj/core/members.php

Particularly the function:
function activatemember()

[code:1]function activatemember( $groupid = null ) {

global $_CB_database, $Itemid, $_CB_framework, $gjConfig;



if ( ! $groupid ) {

$groupid = (int) cbGetParam( $_REQUEST, 'groupid', 0 );

}



if ( ! $_CB_framework->myId() ) {

HTML_wg::errorpage( GJ_NOTAUTH, null, $groupid, 'error' );

return;

}



$code = addslashes( cbGetParam( $_REQUEST, 'code', null ) );



$query = 'SELECT COUNT( ' . $_CB_database->NameQuote( 'id' ) . ' )'

. "\n FROM " . $_CB_database->NameQuote( '#__gj_active' )

. "\n WHERE " . $_CB_database->NameQuote( 'code' ) . " = " . $_CB_database->Quote( $code )

. "\n AND " . $_CB_database->NameQuote( 'too' ) . " = " . (int) $_CB_framework->myId()

. "\n AND " . $_CB_database->NameQuote( 'groups' ) . " = " . (int) $groupid;

$_CB_database->setQuery( $query );

$count = $_CB_database->loadResult();

if ( $_CB_database->getErrorNum() ) {

echo $_CB_database->stderr();

return;

}



if ( $count == 0 ) {

HTML_wg::errorpage( GJ_INVITE_NOT_EXIST, null, $groupid, 'error' );

return;

}



$query = 'UPDATE ' . $_CB_database->NameQuote( '#__gj_users' )

. "\n SET " . $_CB_database->NameQuote( 'status' ) . " = " . $_CB_database->Quote( 'active' )

. "\n WHERE " . $_CB_database->NameQuote( 'id_group' ) . " = " . (int) $groupid

. "\n AND " . $_CB_database->NameQuote( 'id_user' ) . " = " . (int) $_CB_framework->myId();

$_CB_database->setQuery( $query );

if ( ! $_CB_database->query() ) {

echo $_CB_database->stderr();

return;

}



$query = 'DELETE'

. "\n FROM " . $_CB_database->NameQuote( '#__gj_active' )

. "\n WHERE " . $_CB_database->NameQuote( 'code' ) . " = " . $_CB_database->Quote( $code )

. "\n AND " . $_CB_database->NameQuote( 'too' ) . " = " . $_CB_database->Quote( $_CB_framework->myUsername() );

$_CB_database->setQuery( $query );

if ( ! $_CB_database->query() ) {

echo $_CB_database->stderr();

return;

}



if ( $gjConfig ) {

$message = GJ_NEW_MEMBER;

$name = $_CB_framework->myUsername();



if ( $gjConfig ) {

$myId = $_CB_framework->myId();



if ( $myId ) {

$cbUser =& CBuser::getInstance( $myId );



if ( ! $cbUser ) {

$cbUser =& CBuser::getInstance( null );

}



$name = $cbUser->_cbuser->name;

}

}



notify( $groupid, $gjConfig, $message, $name );

}



$_CB_framework->redirect( 'index.php?option=com_groupjive&action=gj.core.groups.showgroup&groupid=' . $groupid . '&Itemid=' . $Itemid, GJ_WELCOME );

}[/code:1]

If anyone knows the code to add to this function to say: if(member belongs to another group) then error - it would be greatly appreciated!

P.S. if posting this question is a no-no, just let me know and I pre-apologize!

Please Log in to join the conversation.

10 years 4 months ago #132211 by bertm
Replied by bertm on topic Re:Limiting # groups member can join
Here is a hack that I was toying around with a few months back. Perhaps some of this might apply. If you work out a good solution please tell us.

http://www.joomlapolis.com/component/option,com_joomlaboard/Itemid,38/func,view/catid,36/id,109414/

Please Log in to join the conversation.

10 years 4 months ago #132421 by zapacoman
Replied by zapacoman on topic Re:Limiting # groups member can join
While I'm sure your solution works great for the groups page...I am actually trying to hide the group link (or better yet the entire tab) from the user's CB profile. I'm pretty sure the file modified would have to be /components/com_comprofiler/plugin/user/plug_cbgroupjive/cb.groupjive.php, but I have no clue how to do it!

Please Log in to join the conversation.

10 years 4 months ago #132832 by zapacoman
Replied by zapacoman on topic Re:Limiting # groups member can join
Do you have any idea of how your hack could be integrated into the cb.groupjive.php file so that it hides the tab if the user that is logged in is already subscribed to a group?

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.392 seconds

Facebook Twitter LinkedIn