Add the user to a (secondary) group.

@param \Tilmeld\Entities\Group $group The group.
@return mixed True if the user is already in the group. The resulting array
of groups if the user was not.
557050
public function addGroup($group) {
    if (!$group->inArray((array) $this->groups)) {
      $this->groups[] = $group;
      return $this->groups;
    }
    return true;
  }
1282801
public function assignGroup($group)
    {
        if (Group::count() === 0) {
            throw new \Exception('No groups have been created.');
        }

        return $this->groups()->save(
            Group::whereName($group)->firstOrFail()
        );
    }
318287
public function isLeaderOf($group): bool
    {
        $group = $this->resolveGroup($group);

        return $this->leadingGroups()->where('group_id', is_int($group) ? $group : $group->id)->exists();
    }
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;
	}
1011669
public function addGroup(GroupInterface $group)
    {
        if (!$this->hasGroup($group)) {
            $this->groups->set($group->getName(), $group);
            $group->addUser($this);
        }

        return $this;
    }
543687
public static function ungroup($group)
    {
        if (!static::isValidGroupId($group)) {
            return false;
        }
        $gateway_data             = GatewayProtocol::$empty;
        $gateway_data['cmd']      = GatewayProtocol::CMD_UNGROUP;
        $gateway_data['ext_data'] = $group;
        return static::sendToAllGateway($gateway_data);

    }
778592
private function instantiateGroup($group)
    {
        if ( !isset($group['instantiate']))
        {
            return;
        }

        foreach ($group['instantiate'] as $nickname => $className)
        {
            $this->objectRegistry->register($nickname, new $className());
        }
    }
893870
public function attachGroup(TagGroup $group)
    {
        if (!$this->hasGroup($group)) {
            $this->_groups[] = $group;
        }

        return $this;
    }
45898
public function clearGroup($group)
    {
        $key = $this->_config['prefix'] . $group;
        if (isset($this->data[$key])) {
            $this->data[$key]['val'] += 1;
        }

        return true;
    }
1039908
public function addUsersToGroup(Group $group, array $users)
    {
        $addedUsers = [];

        if (!$this->validateAddUsersToGroup($users, $group)) {
            throw new Exception\AddRoleException();
        }

        foreach ($users as $user) {
            if (!$group->containsUser($user)) {
                $addedUsers[] = $user;
                $group->addUser($user);
                $this->eventDispatcher->dispatch('log', 'Log\LogGroupAddUser', [$group, $user]);
            }
        }

        $this->om->persist($group);
        $this->om->flush();

        return $addedUsers;
    }
1212058
public function removeGroup(Group $group)
    {
        $this->hasGroupsProperty();

        if ($this->groups->contains($group)) {
            $this->groups->removeElement($group);
        }
    }
238719
public function addUserGroup(\Amulen\UserBundle\Entity\UserGroup $userGroup)
    {
        $this->groups[] = $userGroup;

        return $this;
    }
1192825
public function setGroup($group)
    {
        $this->group = $group instanceof SID ? $group : new SID($group);

        return $this;
    }
523066
public static function setDefaultGroup($group = 'di')
    {
        $group = strtolower(trim($group));

        if (!isset(static::$containers[$group])) {
            static::$containers[$group] = [
                'root' => null,
                'children' => []
            ];
        }

        static::$defaultGroup = $group;
    }
467046
public function removeGroup($group)
    {
        if (is_string($group)) {
            // If the group is a string, we'll assume the dev is passing
            // in a DN string of the group. We'll try to locate it.
            $group = $this->query->newInstance()->findByDn($group);
        }

        if ($group instanceof Group) {
            // If the group is Group model instance, we can
            // remove the current models DN from the group.
            return $group->removeMember($this->getDn());
        }

        return false;
    }
89376
public function removeAllUsersFromGroup(Group $group)
    {
        $users = $group->getUsers();

        foreach ($users as $user) {
            $group->removeUser($user);
        }

        $this->om->persist($group);
        $this->om->flush();
    }
1338819
public function inGroup($group = null) {
    if (is_numeric($group)) {
      $group = Group::factory((int) $group);
    }
    if (!isset($group->guid)) {
      return false;
    }
    return ($group->inArray((array) $this->groups) || $group->is($this->group));
  }