• Модуль: socialnetwork
  • Путь к файлу: ~/bitrix/modules/socialnetwork/lib/copy/implement/usergrouphelper.php
  • Класс: BitrixSocialnetworkCopyImplementUserGroupHelper
  • Вызов: UserGroupHelper::changeModerators
public function changeModerators($groupId)
{
	$currentModeratorsIds = $this->getCurrentModerators($groupId);

	$addIds = array_diff($this->moderatorsIds, $currentModeratorsIds);
	$deleteIds = array_diff($currentModeratorsIds, $this->moderatorsIds);

	if ($addIds)
	{
		UserToGroup::addModerators([
			"group_id" => $groupId,
			"user_id" => $addIds,
			"current_user_id" => $this->executiveUserId
		]);
	}

	if ($deleteIds)
	{
		$resRelation = UserToGroupTable::getList([
			"filter" => [
				"GROUP_ID" => $groupId,
				"@USER_ID" => $deleteIds
			],
			"select" => ["ID"]
		]);
		while ($relation = $resRelation->fetch())
		{
			CSocNetUserToGroup::delete($relation["ID"]);
		}
	}
}