• Модуль: calendar
  • Путь к файлу: ~/bitrix/modules/calendar/lib/sync/googleapisync.php
  • Класс: BitrixCalendarSyncGoogleApiSync
  • Вызов: GoogleApiSync::setColors
private function setColors()
{
	if ($this->calendarColors === false || $this->eventColors === false)
	{
		$cacheTime = 86400 * 7;
		$colorData = null;

		if ($cacheTime)
		{
			$cache = BitrixMainDataCache::createInstance();
			$cacheId = "google_colors";
			$cachePath = 'googlecolors';

			if ($cache->initCache($cacheTime, $cacheId, $cachePath))
			{
				$res = $cache->getVars();
				$colorData = $res["colorData"];
			}
		}

		if (!$cacheTime || empty($colorData))
		{
			$colorData = $this->syncTransport->getColors();
			if ($cacheTime && isset($cache, $cacheId, $cachePath))
			{
				$cache->startDataCache($cacheTime, $cacheId, $cachePath);
				$cache->endDataCache(array(
					"colorData" => $colorData
				));
			}
		}

		$this->calendarColors = array();
		$this->eventColors = array();
		if (is_array($colorData) && !empty($colorData['calendar']) && !empty($colorData['event']))
		{
			foreach ($colorData['calendar'] as $key => $color)
			{
				$this->calendarColors[$key] = $color;
			}

			foreach ($colorData['event'] as $key => $color)
			{
				$this->eventColors[$key] = $color;
			}
		}
	}
}