403Webshell
Server IP : 80.87.202.40  /  Your IP : 216.73.216.169
Web Server : Apache
System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64
User : bitrix ( 600)
PHP Version : 8.2.27
Disable Function : NONE
MySQL : OFF |  cURL : ON |  WGET : ON |  Perl : ON |  Python : OFF |  Sudo : ON |  Pkexec : ON
Directory :  /home/bitrix/ext_www/rospirotorg.ru/bitrix/modules/bizproc/lib/copy/implement/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /home/bitrix/ext_www/rospirotorg.ru/bitrix/modules/bizproc/lib/copy/implement/trigger.php
<?php
namespace Bitrix\Bizproc\Copy\Implement;

use Bitrix\Bizproc\Automation\Trigger\Entity\TriggerTable;
use Bitrix\Main\Error;
use Bitrix\Main\Result;

class Trigger
{
	const TRIGGER_COPY_ERROR = "TRIGGER_COPY_ERROR";

	private $targetDocumentType = [];
	private $mapStatusIdsCopiedDocument = [];

	private $result;

	public function __construct($targetDocumentType = [], $mapStatusIdsCopiedDocument = [])
	{
		$this->targetDocumentType = $targetDocumentType;
		$this->mapStatusIdsCopiedDocument = $mapStatusIdsCopiedDocument;

		$this->result = new Result();
	}

	/**
	 * @param $triggerId
	 * @return array|false
	 * @throws \Bitrix\Main\ArgumentException
	 * @throws \Bitrix\Main\ObjectPropertyException
	 * @throws \Bitrix\Main\SystemException
	 */
	public function getFields($triggerId)
	{
		$queryResult = TriggerTable::getList(["filter" => ["=ID" => $triggerId]]);
		return (($fields = $queryResult->fetch()) ? $fields : []);
	}

	public function prepareFieldsToCopy(array $fields)
	{
		if (isset($fields["ID"]))
		{
			unset($fields["ID"]);
		}

		if ($this->targetDocumentType)
		{
			$fields["MODULE_ID"] = $this->targetDocumentType[0];
			$fields["ENTITY"] = $this->targetDocumentType[1];
			$fields["DOCUMENT_TYPE"] = $this->targetDocumentType[2];
		}

		if (array_key_exists($fields["DOCUMENT_STATUS"], $this->mapStatusIdsCopiedDocument))
		{
			$fields["DOCUMENT_STATUS"] = $this->mapStatusIdsCopiedDocument[$fields["DOCUMENT_STATUS"]];
		}

		return $fields;
	}

	/**
	 * @param array $fields
	 * @return array|bool|int
	 * @throws \Exception
	 */
	public function add(array $fields)
	{
		$result = false;

		if ($fields)
		{
			$addResult = TriggerTable::add($fields);
			$result = ($addResult->isSuccess() ? $addResult->getId() : false);
		}

		if (!$result)
		{
			$this->result->addError(new Error("Failed to copy trigger", self::TRIGGER_COPY_ERROR));
		}

		return $result;
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit