CCrmActivityConverter::IsCalEventConvertigRequired

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. CCrmActivityConverter
  4. IsCalEventConvertigRequired
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/classes/general/crm_activity_converter.php
  • Класс: \CCrmActivityConverter
  • Вызов: CCrmActivityConverter::IsCalEventConvertigRequired
static function IsCalEventConvertigRequired()
{
	if(!(IsModuleInstalled('calendar') && CModule::IncludeModule('calendar')))
	{
		return false;
	}

	$flag = COption::GetOptionString('crm', '~CRM_REQUIRE_CONVERT_CALENDAR_EVENTS', '');
	if($flag !== '')
	{
		return $flag === 'Y';
	}

	//TODO: Waiting for implementation of COUNT in CCalendarEvent::GetList
	$cacheTime = \CCalendar::CacheTime(0);
	$arEvents = CCalendarEvent::GetList(
		array(
			'arFilter' => array(
				'!UF_CRM_CAL_EVENT' => null,
				'DELETED' => 'N'
			),
			'setDefaultLimit' => true,
			'getUserfields' => true
		)
	);
	\CCalendar::CacheTime($cacheTime);

	$result = false;
	foreach($arEvents as $arEvent)
	{
		$count = CCrmActivity::GetCount(array('=CALENDAR_EVENT_ID' => $arEvent['ID']));
		if($count === 0)
		{
			$result = true;
			break;
		}
	}

	COption::SetOptionString('crm', '~CRM_REQUIRE_CONVERT_CALENDAR_EVENTS', $result ? 'Y' : 'N');
	return $result;
}

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