• Модуль: intranet
  • Путь к файлу: ~/bitrix/modules/intranet/classes/general/rest.php
  • Класс: CIntranetRestService
  • Вызов: CIntranetRestService::departmentUpdate
static function departmentUpdate($params)
{
	if(self::canEdit())
	{
		CModule::IncludeModule('iblock');

		$params = array_change_key_case($params, CASE_UPPER);

		$arDept = self::getDepartment($params['ID']);
		if(is_array($arDept))
		{
			$arFields = array();

			if(isset($params['NAME']))
				$arFields['NAME'] = $params['NAME'];
			if(isset($params['SORT']))
				$arFields['SORT'] = $params['SORT'];
			if(isset($params['PARENT']))
				$arFields['IBLOCK_SECTION_ID'] = $params['PARENT'];
			if(isset($params['UF_HEAD']))
				$arFields['UF_HEAD'] = $params['UF_HEAD'];

			if(count($arFields) > 0)
			{
				$ob = new CIBlockSection();
				if(!$ob->Update($arDept['ID'], $arFields))
				{
					throw new Exception($ob->LAST_ERROR);
				}
			}

			return true;
		}
		else
		{
			throw new Exception('Department not found');
		}
	}
	else
	{
		throw new Exception('Access denied!');
	}
}