ListControls::toggleGroupByGroups

  1. Bitrix24 API (v. 23.675.0)
  2. tasks
  3. ListControls
  4. toggleGroupByGroups
  • Модуль: tasks
  • Путь к файлу: ~/bitrix/modules/tasks/lib/dispatcher/publicaction/ui/listcontrols.php
  • Класс: BitrixTasksDispatcherPublicActionUiListControls
  • Вызов: ListControls::toggleGroupByGroups
public function toggleGroupByGroups($userId = null)
{
	if (!User::isAuthorized())
	{
		throw new TasksException("Authentication is required.");
	}

	if (!is_null($userId))
	{
		$userId = (int) $userId;
	}

	if (!$userId)
	{
		$userId = User::getId();
	}

	$instance = CTaskListState::getInstance($userId);
	$state = $instance->getState();
	$submodes = $state['SUBMODES'];
	$groupByGroups = $submodes['VIEW_SUBMODE_WITH_GROUPS']['SELECTED'] == 'Y';

	if ($groupByGroups)
	{
		$instance->switchOffSubmode(CTaskListState::VIEW_SUBMODE_WITH_GROUPS);
	}
	else
	{
		$instance->switchOnSubmode(CTaskListState::VIEW_SUBMODE_WITH_GROUPS);
	}
	$instance->saveState();

	// test
	$state = $instance->getState();
	$groupByGroups = $state['SUBMODES']['VIEW_SUBMODE_WITH_GROUPS']['SELECTED'] == 'Y';

	return array('RESULT' => $groupByGroups);
}

Добавить комментарий