4

I am trying to integrate jomsocial events with jomsocial groups. What i am trying to achieve is to automatically create a group when the event is being created.

Would anyone have some hints regarding such functionality? The approach i have in mind is to utilize a function onEventCreate($event) from jomsocial API to call the group creation mechanism. Is that the right way to do it?

iki
  • 73
  • 6
  • As JomSocial is a commercial extension, you might be better off contacting the developers of JomSocial as I wouldn't have thought many people on here have it. – Lodder Jul 24 '12 at 22:43

1 Answers1

1

Yes, this is the approach I'd take.

You can find method save() in groups.php controller. There you've got all of the required code to implement this.

The rough code :

$my         =& CFactory::getUser();
$config         =& CFactory::getConfig();
$group          =& JTable::getInstance( 'Group' , 'CTable' );

$group->name        = $name;
$group->description = $description;
$group->categoryid  = $categoryId; // Category Id must not be empty and will cause failure on this group if its empty.
$group->website     = $website;
$group->ownerid     = $my->id;
$group->created     = gmdate('Y-m-d H:i:s');
$group->approvals   = 0;

$params         = new CParameter( '' );
// Here you need some code from private _bindParams()

$group->params      = $params->toString();
$group->published   = ( $config->get('moderategroupcreation') ) ? 0 : 1;
$group->store();

// Other useful stuff:
// - store the creator / admin into the groups members table
// - add into activity stream
WooDzu
  • 4,771
  • 6
  • 31
  • 61