CCrmLiveFeedComponent::getValue

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. CCrmLiveFeedComponent
  4. getValue
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/classes/general/livefeed.php
  • Класс: \CCrmLiveFeedComponent
  • Вызов: CCrmLiveFeedComponent::getValue
private function getValue($value_code)
{
	if (!is_array($value_code))
	{
		if (mb_strpos($value_code, "COMBI_") === 0)
		{
			$arFieldName = explode("/", mb_substr($value_code, 6));
			if (is_array($arFieldName))
			{
				$arReturn = array();

				foreach($arFieldName as $fieldName)
				{
					if (mb_strpos($fieldName, "EVENT_PARAMS_") === 0)
					{
						$key = mb_substr($fieldName, 13);
					}
					elseif (mb_strpos($fieldName, "ACTIVITY_") === 0)
					{
						$key = mb_substr($fieldName, 9);
					}
					elseif (mb_strpos($fieldName, "INVOICE_") === 0)
					{
						$key = mb_substr($fieldName, 8);
					}
					else
					{
						$key = $fieldName;
					}

					if (mb_strpos($key, "CONTACT_ID") !== false)
					{
						$key = "CONTACT_ID";
					}
					elseif (mb_strpos($key, "LAST_NAME") !== false)
					{
						$key = "CONTACT_LAST_NAME";
					}
					elseif (mb_strpos($key, "SECOND_NAME") !== false)
					{
						$key = "CONTACT_SECOND_NAME";
					}
					elseif (mb_strpos($key, "NAME") !== false)
					{
						$key = "CONTACT_NAME";
					}
					elseif (mb_strpos($key, "COMPANY_TITLE") !== false)
					{
						$key = "COMPANY_TITLE";
					}
					elseif (mb_strpos($key, "COMPANY_ID") !== false)
					{
						$key = "COMPANY_ID";
					}
					elseif (
						mb_strpos($key, "TITLE") !== false
						|| mb_strpos($key, "ORDER_TOPIC") !== false
						|| mb_strpos($key, "SUBJECT") !== false
					)
					{
						$key = "TITLE";
					}
					elseif (mb_strpos($key, "ENTITY_ID") !== false)
					{
						$key = "ENTITY_ID";
					}
					elseif (mb_strpos($key, "PHOTO_ID") !== false)
					{
						$key = "PHOTO_ID";
					}
					elseif (mb_strpos($key, "LOGO_ID") !== false)
					{
						$key = "LOGO_ID";
					}
					elseif (mb_strpos($key, "START_STATUS_ID") !== false)
					{
						$key = "STAGE_ID";
					}
					elseif (mb_strpos($key, "FINAL_STATUS_ID") !== false)
					{
						$key = "STAGE_ID";
					}
					elseif (mb_strpos($key, "STAGE_ID") !== false)
					{
						$key = "STAGE_ID";
					}
					elseif (mb_strpos($key, "CATEGORY_ID") !== false)
					{
						$key = "CATEGORY_ID";
					}
					elseif (mb_strpos($key, "ID") !== false)
					{
						$key = "ID";
					}
					elseif ($key === "ACCOUNT_NUMBER")
					{
						$key = "ID";
					}

					$arReturn[$key] = $this->getValue($fieldName);
				}

				return $arReturn;
			}
		}
		elseif (mb_strpos($value_code, "EVENT_PARAMS_") === 0)
		{
			if (is_array($this->eventParams[mb_substr($value_code, 13)]))
			{
				array_walk($this->eventParams[mb_substr($value_code, 13)], array($this, '__htmlspecialcharsbx'));
				return $this->eventParams[mb_substr($value_code, 13)];
			}

			if (array_key_exists(mb_substr($value_code, 13), $this->eventParams))
			{
				return htmlspecialcharsbx($this->eventParams[mb_substr($value_code, 13)]);
			}

			return '';
		}
		elseif (mb_strpos($value_code, "ACTIVITY_ONCLICK") === 0)
		{
			return "BX.CrmActivityEditor.viewActivity('livefeed', ".$this->activity["ID"].", { 'enableInstantEdit':true, 'enableEditButton':true });";
		}
		elseif (mb_strpos($value_code, "ACTIVITY_") === 0)
		{
			$realKey = mb_substr($value_code, 9);

			if (is_array($this->activity[$realKey]))
			{
				array_walk($this->activity[$realKey], array($this, '__htmlspecialcharsbx'));
				return $this->activity[$realKey];
			}

			if (
				empty($this->activity[$realKey])
				&& $realKey === "SUBJECT"
			)
			{
				return GetMessage('C_CRM_LF_SUBJECT_TITLE_EMPTY');
			}

			if ($realKey === 'LOCATION' && Loader::includeModule('calendar'))
			{
				return htmlspecialcharsbx(CCalendar::GetTextLocation($this->activity[$realKey]));
			}

			return htmlspecialcharsbx($this->activity[$realKey]);
		}
		elseif (mb_strpos($value_code, "INVOICE_") === 0)
		{
			if (
				isset($this->activity[mb_substr($value_code, 9)])
				&& is_array($this->activity[mb_substr($value_code, 9)])
			)
			{
				array_walk($this->invoice[mb_substr($value_code, 8)], array($this, '__htmlspecialcharsbx'));

				return $this->invoice[mb_substr($value_code, 8)];
			}

			return htmlspecialcharsbx($this->invoice[mb_substr($value_code, 8)]);
		}
		else
		{
			if (
				isset($this->activity[mb_substr($value_code, 9)])
				&& is_array($this->activity[mb_substr($value_code, 9)])
			)
			{
				array_walk($this->fields[$value_code], array($this, '__htmlspecialcharsbx'));
				return $this->fields[$value_code];
			}

			return htmlspecialcharsbx($this->fields[$value_code]);
		}
	}
	else
	{
		$arReturn = [];
		foreach ($value_code as $key_tmp => $value_tmp)
		{
			$arReturn[$key_tmp] = $this->getValue($value_tmp);
		}

		return $arReturn;
	}
}

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