Created
October 15, 2015 01:55
-
-
Save eggsurplus/8e548f96947c048935f5 to your computer and use it in GitHub Desktop.
Add a default SecurityGroup for any newly created user
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); | |
/** | |
* Add a default SecurityGroup for any newly created user | |
*/ | |
class AddSecurityGroup | |
{ | |
function add_default_group($bean, $event, $arguments) | |
{ | |
if(empty($bean->id) || $bean->new_with_id == true) | |
{ | |
$default_group = BeanFactory::getBean('SecurityGroups'); | |
$default_group->retrieve_by_string_fields(array('name'=>'Owner_Only_Group','deleted'=>0)); | |
$default_group->load_relationship('users'); | |
$default_group->users->add($bean->id); | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment