CAllCrmQuote::LocalComponentCausedUpdater

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. CAllCrmQuote
  4. LocalComponentCausedUpdater
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/classes/general/crm_quote.php
  • Класс: \CAllCrmQuote
  • Вызов: CAllCrmQuote::LocalComponentCausedUpdater
static function LocalComponentCausedUpdater()
{
	global $stackCacheManager;

	$bResult = true;
	$errMsg = array();
	$bError = false;

	// at first, check last update version
	if (COption::GetOptionString('crm', '~CRM_QUOTE_14_1_11', 'N') === 'Y')
		return $bResult;

	try
	{
		// Copy perms from deals to quotes
		$CCrmRole = new CCrmRole();
		$dbRoles = $CCrmRole->GetList();

		while($arRole = $dbRoles->Fetch())
		{
			$arPerms = $CCrmRole->GetRolePerms($arRole['ID']);

			if(!isset($arPerms['QUOTE']) && is_array($arPerms['DEAL'] ?? null))
			{
				foreach ($arPerms['DEAL'] as $key => $value)
				{
					if(isset($value['-']))
						$arPerms['QUOTE'][$key]['-'] = $value['-'];
					else
						$arPerms['QUOTE'][$key]['-'] = null;
				}
			}

			$arFields = array('RELATION' => $arPerms);
			$CCrmRole->Update($arRole['ID'], $arFields);
		}

		// Create default quote status list (if not exists)
		$arStatus = CCrmStatus::GetStatus('QUOTE_STATUS');
		if (empty($arStatus))
		{
			CCrmStatus::InstallDefault('QUOTE_STATUS');
		}
		unset($arStatus);
	}
	catch (Exception $e)
	{
		$errMsg[] = $e->getMessage();
		$bError = true;
	}

	if (!$bError)
	{
		COption::SetOptionString('crm', '~CRM_QUOTE_14_1_11', 'Y');
	}
	else
	{
		$errString = implode('
', $errMsg); ShowError($errString); $bResult = false; } return $bResult; }

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