CCrmOwnerType::GetEditUrl

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. CCrmOwnerType
  4. GetEditUrl
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/classes/general/crm_owner_type.php
  • Класс: \CCrmOwnerType
  • Вызов: CCrmOwnerType::GetEditUrl
static function GetEditUrl($typeID, $ID, $bCheckPermissions = false, array $options = null)
{
	$typeID = intval($typeID);
	$ID = intval($ID);

	if($ID <= 0)
	{
		$ID = 0;
	}

	switch($typeID)
	{
		case self::Lead:
		{
			if ($bCheckPermissions && !($ID > 0 ? CCrmLead::CheckUpdatePermission($ID) : CCrmLead::CheckCreatePermission()))
			{
				return '';
			}

			return CComponentEngine::MakePathFromTemplate(
				COption::GetOptionString('crm', 'path_to_lead_edit'),
				array('lead_id' => $ID)
			);
		}
		case self::Contact:
		{
			if ($bCheckPermissions && !($ID > 0 ? CCrmContact::CheckUpdatePermission($ID) : CCrmContact::CheckCreatePermission()))
			{
				return '';
			}

			return CComponentEngine::MakePathFromTemplate(
				COption::GetOptionString('crm', 'path_to_contact_edit'),
				array('contact_id' => $ID)
			);
		}
		case self::Company:
		{
			if ($bCheckPermissions && !($ID > 0 ? CCrmCompany::CheckUpdatePermission($ID) : CCrmCompany::CheckCreatePermission()))
			{
				return '';
			}

			return CComponentEngine::MakePathFromTemplate(
				COption::GetOptionString('crm', 'path_to_company_edit'),
				array('company_id' => $ID)
			);
		}
		case self::Deal:
		{
			$settings = is_array($options) && isset($options['ENTITY_SETTINGS']) ? $options['ENTITY_SETTINGS'] : array();
			$categoryId = isset($settings['categoryId']) ? (int)$settings['categoryId'] : -1;

			if ($bCheckPermissions && !($ID > 0 ? CCrmDeal::CheckUpdatePermission($ID) : CCrmDeal::CheckCreatePermission(null, $categoryId)))
			{
				return '';
			}

			$url = CComponentEngine::MakePathFromTemplate(
				COption::GetOptionString('crm', 'path_to_deal_edit'),
				array('deal_id' => $ID)
			);

			if($ID <= 0 && $categoryId >= 0)
			{
				$url = \CCrmUrlUtil::AddUrlParams($url, array('category_id' => $categoryId));
			}
			return $url;
		}
		case self::Invoice:
		{
			if ($bCheckPermissions && !($ID > 0 ? CCrmInvoice::CheckUpdatePermission($ID) : CCrmInvoice::CheckCreatePermission()))
			{
				return '';
			}

			return CComponentEngine::MakePathFromTemplate(
				COption::GetOptionString('crm', 'path_to_invoice_edit'),
				array('invoice_id' => $ID)
			);
		}
		case self::Quote:
		{
			if ($bCheckPermissions && !($ID > 0 ? CCrmQuote::CheckUpdatePermission($ID) : CCrmQuote::CheckCreatePermission()))
			{
				return '';
			}

			return CComponentEngine::MakePathFromTemplate(
				COption::GetOptionString('crm', 'path_to_quote_edit'),
				array('quote_id' => $ID)
			);
		}
		case self::Order:
		{
			if ($bCheckPermissions && !($ID > 0 ? \Bitrix\Crm\Order\Permissions\Order::checkUpdatePermission($ID) : \Bitrix\Crm\Order\Permissions\Order::checkCreatePermission()))
			{
				return '';
			}

			return self::GetDetailsUrl($typeID, $ID, $bCheckPermissions, $options);
		}
		case self::Activity:
		{
			return CComponentEngine::MakePathFromTemplate(
				COption::GetOptionString('crm', 'path_to_activity_edit'),
				array('activity_id' => $ID)
			);
		}
		default:
			return '';
	}
}

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