Your IP : 18.222.188.218


Current Path : /var/www/axolotl/data/www/arhangelsk.axolotls.ru/a537b/
Upload File :
Current File : /var/www/axolotl/data/www/arhangelsk.axolotls.ru/a537b/savehistoryactivity.tar

lang/en/properties_dialog.php000064400000000310147736337500012324 0ustar00<?
$MESS ['BPSHA_PD_NAME'] = "Name of Entry in History";
$MESS ['BPSHA_PD_NAME_ALT'] = "Leave the field empty to obtain the name from the document";
$MESS ['BPSHA_PD_USER'] = "Log History As User";
?>lang/en/.description.php000064400000000156147736337500011222 0ustar00<?
$MESS ['BPSHA_DESCR_NAME'] = "Save History";
$MESS ['BPSHA_DESCR_DESCR'] = "Saves the document history";
?>lang/ru/properties_dialog.php000064400000000556147736337500012364 0ustar00<?
$MESS ['BPSHA_PD_NAME'] = "Название записи в историю";
$MESS ['BPSHA_PD_NAME_ALT'] = "Оставьте поле пустым для того, чтобы название бралось из документа";
$MESS ['BPSHA_PD_USER'] = "Пользователь, от имени которого записывается история";
?>lang/ru/.description.php000064400000000241147736337500011241 0ustar00<?
$MESS ['BPSHA_DESCR_NAME'] = "Сохранение истории";
$MESS ['BPSHA_DESCR_DESCR'] = "Сохранение истории документа";
?>lang/de/properties_dialog.php000064400000000363147736337500012322 0ustar00<?
$MESS ['BPSHA_PD_NAME'] = "Name des History-Eintrags";
$MESS ['BPSHA_PD_NAME_ALT'] = "Lassen Sie dieses Feld leer, damit der Name aus dem Dokument hinzugefügt wird";
$MESS ['BPSHA_PD_USER'] = "Benutzername für die Historyaufzeichnung";
?>lang/de/.description.php000064400000000174147736337500011210 0ustar00<?
$MESS ['BPSHA_DESCR_NAME'] = "Geschichte speichern";
$MESS ['BPSHA_DESCR_DESCR'] = "Speichert die Dokumentgeschichte";
?>savehistoryactivity.php000064400000007444147736337500011442 0ustar00<?
if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED!==true)die();

class CBPSaveHistoryActivity
	extends CBPActivity
{
	public function __construct($name)
	{
		parent::__construct($name);
		$this->arProperties = array(
			"Title" => "",
			"Name" => null,
			"UserId" => null,
		);
	}

	public function Execute()
	{
		$rootActivity = $this->GetRootActivity();
		$documentId = $rootActivity->GetDocumentId();

		$historyService = $this->workflow->GetService("HistoryService");
		$documentService = $this->workflow->GetService("DocumentService");

		$userId = $this->UserId;
		if (is_string($userId) && strpos($userId, "user_") !== false)
			$userId = intval(substr($userId, strlen("user_")));
		if ($userId == null || intval($userId) <= 0)
			$userId = 1;

		$historyIndex = $historyService->AddHistory(
			array(
				"DOCUMENT_ID" => $documentId,
				"NAME" => "New",
				"DOCUMENT" => null,
				"USER_ID" => $userId,
			)
		);

		$arDocument = $documentService->GetDocumentForHistory($documentId, $historyIndex);
		if (!is_array($arDocument))
			return CBPActivityExecutionStatus::Closed;

		$name = $this->Name;
		if ($name == null || strlen($name) <= 0)
		{
			if (array_key_exists("NAME", $arDocument) && is_string($arDocument["NAME"]) && strlen($arDocument["NAME"]) > 0)
				$name = $arDocument["NAME"];
			elseif (array_key_exists("TITLE", $arDocument) && is_string($arDocument["TITLE"]) && strlen($arDocument["TITLE"]) > 0)
				$name = $arDocument["TITLE"];
			else
				$name = Date("Y-m-d H:i:s");
		}

		$historyService->UpdateHistory(
			$historyIndex,
			array(
				"NAME" => $name,
				"DOCUMENT" => $arDocument,
			)
		);

		return CBPActivityExecutionStatus::Closed;
	}

	public static function ValidateProperties($arTestProperties = array(), CBPWorkflowTemplateUser $user = null)
	{
		$arErrors = array();
		return array_merge($arErrors, parent::ValidateProperties($arTestProperties, $user));
	}

	public static function GetPropertiesDialog($documentType, $activityName, $arWorkflowTemplate, $arWorkflowParameters, $arWorkflowVariables, $arCurrentValues = null, $formName = "")
	{
		$runtime = CBPRuntime::GetRuntime();

		$arMap = array(
			"Name" => "sh_name",
			"UserId" => "sh_user_id",
		);

		if (!is_array($arWorkflowParameters))
			$arWorkflowParameters = array();
		if (!is_array($arWorkflowVariables))
			$arWorkflowVariables = array();

		if (!is_array($arCurrentValues))
		{
			$arCurrentActivity = &CBPWorkflowTemplateLoader::FindActivityByName($arWorkflowTemplate, $activityName);
			if (is_array($arCurrentActivity["Properties"]))
			{
				foreach ($arMap as $k => $v)
				{
					if (array_key_exists($k, $arCurrentActivity["Properties"]))
						$arCurrentValues[$arMap[$k]] = $arCurrentActivity["Properties"][$k];
					else
						$arCurrentValues[$arMap[$k]] = "";
				}
			}
			else
			{
				foreach ($arMap as $k => $v)
					$arCurrentValues[$arMap[$k]] = "";
			}
		}

		return $runtime->ExecuteResourceFile(
			__FILE__,
			"properties_dialog.php",
			array(
				"arCurrentValues" => $arCurrentValues,
				"formName" => $formName,
			)
		);
	}

	public static function GetPropertiesDialogValues($documentType, $activityName, &$arWorkflowTemplate, &$arWorkflowParameters, &$arWorkflowVariables, $arCurrentValues, &$arErrors)
	{
		$arErrors = array();

		$runtime = CBPRuntime::GetRuntime();

		$arMap = array(
			"sh_name" => "Name",
			"sh_user_id" => "UserId",
		);

		$arProperties = array();
		foreach ($arMap as $key => $value)
			$arProperties[$value] = $arCurrentValues[$key];

		$arErrors = self::ValidateProperties($arProperties, new CBPWorkflowTemplateUser(CBPWorkflowTemplateUser::CurrentUser));
		if (count($arErrors) > 0)
			return false;

		$arCurrentActivity = &CBPWorkflowTemplateLoader::FindActivityByName($arWorkflowTemplate, $activityName);
		$arCurrentActivity["Properties"] = $arProperties;

		return true;
	}
}
?>properties_dialog.php000064400000001424147736337500011010 0ustar00<?
if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED!==true)die();
?>

<?
?>
<tr>
	<td align="right" width="40%"><?= GetMessage("BPSHA_PD_NAME") ?>:<br /><small><?= GetMessage("BPSHA_PD_NAME_ALT") ?></small></td>
	<td width="60%">
		<input type="text" name="sh_name" id="id_sh_name" value="<?= htmlspecialchars($arCurrentValues["sh_name"]) ?>" size="50">
		<input type="button" value="..." onclick="BPAShowSelector('id_sh_name', 'string');">
	</td>
</tr>
<tr>
	<td align="right" width="40%"><?= GetMessage("BPSHA_PD_USER") ?>:</td>
	<td width="60%">
		<input type="text" name="sh_user_id" id="id_sh_user_id" value="<?= htmlspecialchars($arCurrentValues["sh_user_id"]) ?>" size="50">
		<input type="button" value="..." onclick="BPAShowSelector('id_sh_user_id', 'user');">
	</td>
</tr>