CBPRuntime::includeActivityFile

  1. Bitrix24 API (v. 23.675.0)
  2. bizproc
  3. CBPRuntime
  4. includeActivityFile
  • Модуль: bizproc
  • Путь к файлу: ~/bitrix/modules/bizproc/classes/general/runtime.php
  • Класс: CBPRuntime
  • Вызов: CBPRuntime::includeActivityFile
public function includeActivityFile($code)
{
	if (in_array($code, $this->loadedActivities))
		return true;

	if (preg_match("#[^a-zA-Z0-9_]#", $code))
		return false;
	if ($code == '')
		return false;

	$code = mb_strtolower($code);
	if (mb_substr($code, 0, 3) == "cbp")
		$code = mb_substr($code, 3);
	if ($code == '')
		return false;
	if (in_array($code, $this->loadedActivities))
		return true;

	$filePath = "";
	$fileDir = "";
	foreach ($this->activityFolders as $folder)
	{
		if (file_exists($folder."/".$code."/".$code.".php") && is_file($folder."/".$code."/".$code.".php"))
		{
			$filePath = $folder."/".$code."/".$code.".php";
			$fileDir = $folder."/".$code;
			break;
		}
	}

	if ($filePath <> '')
	{
		$this->LoadActivityLocalization($fileDir, $code.".php");
		include_once($filePath);
		$this->loadedActivities[] = $code;
		return true;
	}

	if (mb_strpos($code, static::REST_ACTIVITY_PREFIX) === 0)
	{
		$code = mb_substr($code, mb_strlen(static::REST_ACTIVITY_PREFIX));
		$result = RestActivityTable::getList(array(
			'select' => array('ID'),
			'filter' => array('=INTERNAL_CODE' => $code)
		));
		$activity = $result->fetch();
		eval('class CBP'.static::REST_ACTIVITY_PREFIX.$code.' extends CBPRestActivity {const REST_ACTIVITY_ID = '.($activity? $activity['ID'] : 0).';}');
		$this->loadedActivities[] = static::REST_ACTIVITY_PREFIX.$code;
		return true;
	}

	return false;
}

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