Add user to group.
5431
def group_add_user_action(model, request):
    
    user_id = request.params.get('id')
    if not user_id:
        user_ids = request.params.getall('id[]')
    else:
        user_ids = [user_id]
    try:
        group = model.model
        validate_add_users_to_groups(model, user_ids, [group.id])
        for user_id in user_ids:
            group.add(user_id)
        group()
        model.parent.invalidate(group.name)
        localizer = get_localizer(request)
        message = localizer.translate(_(
            'added_user_to_group',
            default="Added user '${uid}' to group '${gid}'.",
            mapping={
                'uid': ', '.join(user_ids),
                'gid': group.id
            }
        ))
        return {
            'success': True,
            'message': message
        }
    except ManageMembershipError as e:
        if e.reason is not LM_TARGET_UID_NOT_ALLOWED:
            raise Exception(u"Unknown ManageMembershipError reason.")
        localizer = get_localizer(request)
        message = localizer.translate(_(
            'lm_add_target_uid_not_allowed',
            default=(
                "Failed adding user '${uid}' to group '${gid}'. "
                "Manage membership denied for user."
            ),
            mapping={
                'uid': e.data,
                'gid': group.id
            }
        ))
        return {
            'success': False,
            'message': message
        }
    except Exception as e:
        return {
            'success': False,
            'message': str(e)
        }
1160307
def add_users_to_group(id, user_list = [])
      wf_usergroup_id?(id)
      validate_user_list(user_list)
      api.post([id, 'addUsers'].uri_concat, user_list, 'application/json')
    end
1112157
def groups_add_owner(self, room_id, user_id, **kwargs):
        """"""
        return self.__call_api_post('groups.addOwner', roomId=room_id, userId=user_id, kwargs=kwargs)
1353236
@Deprecated
    public void addUserToGroup(User user, Group group) throws RedmineException {
        transport.addUserToGroup(user.getId(), group.getId());
    }
1201598
def add(name, **kwargs):
    '''
    
    '''
    if not info(name):
        comp_obj = _get_computer_object()
        try:
            new_group = comp_obj.Create('group', name)
            new_group.SetInfo()
            log.info('Successfully created group %s', name)
        except pywintypes.com_error as exc:
            msg = 'Failed to create group {0}. {1}'.format(
                name, win32api.FormatMessage(exc.excepinfo[5]))
            log.error(msg)
            return False
    else:
        log.warning('The group %s already exists.', name)
        return False
    return True
1028100
protected function assignGroup()
    {
        if (!$this->config()->get('grant_user_access')) {
            return;
        }

        $group = $this->getUserGroup();

        // Must check if the method exists or else an error occurs when changing page type
        if ($this->hasMethod('Editors')) {
            foreach ([$this->Editors(), $this->Writers(), $this->Contributors()] as $levels) {
                foreach ($levels as $user) {
                    if (!$user->inGroup($group)) {
                        $user->Groups()->add($group);
                    }
                }
            }
        }
    }
425127
def add_user_to_group(self, username, groupname, raise_on_error=False):
        
        data = {
                'name': groupname,
        }
        response = self._post(self.rest_url + "/user/group/direct",
                              params={"username": username,},
                              data=json.dumps(data))

        if response.status_code == 201:
            return True

        if raise_on_error:
            raise RuntimeError(response.json()['message'])

        return False
1187161
def add_group(self, name, devices):
        
        device = self.add_device(name, "group")
        device.add_to_group(devices)
        return device
325775
def add_user(self, user):
        """"""
        if not isinstance(user, User):
            user = User(user)
        if user.nick in self.members:
            _log.warning("Ignoring request to add user '%s' to channel '%s' "
                         "because that user is already in the member list.",
                         user, self.name)
            return
        self.members[user.nick] = user
        _log.debug("Added '%s' to channel '%s'", user, self.name)
1236109
async def add(gc: GroupControl, slaves):
    """"""
    click.echo("Adding to existing group: %s" % slaves)
    click.echo(await gc.add(slaves))
541619
def add_user(self, nick, prefixes=None):
        """"""
        if nick not in self._user_nicks:
            self._user_nicks.append(nick)

        self.prefixes[nick] = prefixes
990776
function addGroup(group, options) {
  options = _.opts(options, {gid: null});
  if (!runningAsRoot()) return;
  if (!group) throw new Error('You must provide a group');
  if (groupExists(group)) {
    return;
  }

  if (isPlatform('linux')) {
    _addGroupLinux(group, options);
  } else if (isPlatform('osx')) {
    _addGroupOsx(group, options);
  } else if (isPlatform('windows')) {
    throw new Error(`Don't know how to add group ${group} on Windows`);
  } else {
    throw new Error(`Don't know how to add group ${group} in current platform`);
  }
}
922515
def add_user(self, user, is_admin=False):
        
        users_count = self.users.all().count()
        if users_count == 0:
            is_admin = True
        # TODO get specific org user?
        org_user = self._org_user_model.objects.create(
            user=user, organization=self, is_admin=is_admin
        )
        if users_count == 0:
            # TODO get specific org user?
            self._org_owner_model.objects.create(
                organization=self, organization_user=org_user
            )

        # User added signal
        user_added.send(sender=self, user=user)
        return org_user
557181
def add_peer_to_group(self, group_jid, peer_jid):
        
        log.info("[+] Requesting to add user {} into the group {}".format(peer_jid, group_jid))
        return self._send_xmpp_element(group_adminship.AddToGroupRequest(group_jid, peer_jid))
923679
public boolean associateUserWithGroup(String user, String group)
	{
		if (!isUserExist(user))
		{
			throw new SystemException(String.format("User '%s' does not exist.", user));
		}

		if (!isGroupExist(group))
		{
			throw new SystemException(String.format("Group '%s' does not exist.", group));
		}

		List<String> userGroups = allAssociations.get(user);

		if (userGroups == null)
		{
			userGroups = new ArrayList<String>();
		}
		else if (userGroups.contains(group))
		{
			return false;
		}

		userGroups.add(group);

		allAssociations.put(user, userGroups);

		return true;
	}
470201
def adduser(name, username):
    '''
    
    '''
    # Note: pw exits with code 65 if group is unknown
    retcode = __salt__['cmd.retcode']('pw groupmod {0} -m {1}'.format(
        name, username), python_shell=False)

    return not retcode
421216
def user_add_to_group_action(model, request):
    
    group_id = request.params.get('id')
    if not group_id:
        group_ids = request.params.getall('id[]')
    else:
        group_ids = [group_id]
    try:
        user = model.model
        validate_add_users_to_groups(model, [user.id], group_ids)
        groups = user.root.groups
        for group_id in group_ids:
            groups[group_id].add(user.name)
        groups()
        model.parent.invalidate(user.name)
        localizer = get_localizer(request)
        message = localizer.translate(_(
            'added_user_to_group',
            default="Added user '${uid}' to group '${gid}'.",
            mapping={
                'uid': user.id,
                'gid': ', '.join(group_ids)
            }
        ))
        return {
            'success': True,
            'message': message
        }
    except ManageMembershipError as e:
        if e.reason is not LM_TARGET_GID_NOT_ALLOWED:
            raise Exception(u"Unknown ManageMembershipError reason.")
        localizer = get_localizer(request)
        message = localizer.translate(_(
            'lm_add_target_gid_not_allowed',
            default=(
                "Failed adding user '${uid}' to group '${gid}'. "
                "Manage membership denied for target group."
            ),
            mapping={
                'uid': user.id,
                'gid': e.data
            }
        ))
        return {
            'success': False,
            'message': message
        }
    except Exception as e:
        return {
            'success': False,
            'message': str(e)
        }