本文整理汇总了PHP中CBPRuntime类的典型用法代码示例。如果您正苦于以下问题:PHP CBPRuntime类的具体用法?PHP CBPRuntime怎么用?PHP CBPRuntime使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CBPRuntime类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: SetState
public function SetState($workflowId, $arState, $arStatePermissions = array())
{
global $DB;
$workflowId = trim($workflowId);
if (strlen($workflowId) <= 0) {
throw new Exception("workflowId");
}
$state = trim($arState["STATE"]);
$stateTitle = trim($arState["TITLE"]);
$stateParameters = "";
if (count($arState["PARAMETERS"]) > 0) {
$stateParameters = serialize($arState["PARAMETERS"]);
}
$DB->Query("UPDATE b_bp_workflow_state SET " . "\tSTATE = " . (strlen($state) > 0 ? "'" . $DB->ForSql($state) . "'" : "NULL") . ", " . "\tSTATE_TITLE = " . (strlen($stateTitle) > 0 ? "'" . $DB->ForSql($stateTitle) . "'" : "NULL") . ", " . "\tSTATE_PARAMETERS = " . (strlen($stateParameters) > 0 ? "'" . $DB->ForSql($stateParameters) . "'" : "NULL") . ", " . "\tMODIFIED = " . $DB->CurrentTimeFunction() . " " . "WHERE ID = '" . $DB->ForSql($workflowId) . "' ");
if ($arStatePermissions !== false) {
$DB->Query("DELETE FROM b_bp_workflow_permissions " . "WHERE WORKFLOW_ID = '" . $DB->ForSql($workflowId) . "' ");
foreach ($arStatePermissions as $permission => $arObjects) {
foreach ($arObjects as $object) {
$DB->Query("INSERT INTO b_bp_workflow_permissions (WORKFLOW_ID, OBJECT_ID, PERMISSION) " . "VALUES ('" . $DB->ForSql($workflowId) . "', '" . $DB->ForSql($object) . "', '" . $DB->ForSql($permission) . "')");
}
}
$arState = self::GetWorkflowState($workflowId);
$runtime = $this->runtime;
if (!isset($runtime) || !is_object($runtime)) {
$runtime = CBPRuntime::GetRuntime();
}
$documentService = $runtime->GetService("DocumentService");
$documentService->SetPermissions($arState["DOCUMENT_ID"], $workflowId, $arStatePermissions, true);
}
}
开发者ID:k-kalashnikov,项目名称:geekcon.local,代码行数:30,代码来源:stateservice.php
示例2: GetPropertiesDialog
public static function GetPropertiesDialog($documentType, $activityName, $arWorkflowTemplate, $arWorkflowParameters, $arWorkflowVariables, $arCurrentValues = null, $formName = "")
{
$runtime = CBPRuntime::GetRuntime();
$arMap = array("GroupName" => "group_name", "OwnerId" => "owner_id", "Users" => 'users');
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"])) {
if ($k == "OwnerId" || $k == "Users") {
$arCurrentValues[$arMap[$k]] = CBPHelper::UsersArrayToString($arCurrentActivity["Properties"][$k], $arWorkflowTemplate, $documentType);
} else {
$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));
}
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:26,代码来源:createworkgroup.php
示例3: GetPropertiesDialogValues
public static function GetPropertiesDialogValues($documentType, $activityName, &$arWorkflowTemplate, &$arWorkflowParameters, &$arWorkflowVariables, $arCurrentValues, &$arErrors)
{
$arErrors = array();
$runtime = CBPRuntime::GetRuntime();
$documentService = $runtime->GetService("DocumentService");
$arFieldTypes = $documentService->GetDocumentFieldTypes($documentType);
$arProperties = array("VariableValue" => array());
if (!is_array($arWorkflowVariables)) {
$arWorkflowVariables = array();
}
if (count($arWorkflowVariables) <= 0) {
$arErrors[] = array("code" => "EmptyVariables", "parameter" => "", "message" => GetMessage("BPSVA_EMPTY_VARS"));
return false;
}
$l = strlen("variable_field_");
foreach ($arCurrentValues as $key => $varCode) {
if (substr($key, 0, $l) === "variable_field_") {
$ind = substr($key, $l);
if ($ind . "!" === intval($ind) . "!") {
if (array_key_exists($varCode, $arWorkflowVariables)) {
$arProperties["VariableValue"][$varCode] = $documentService->GetFieldInputValue($documentType, $arWorkflowVariables[$varCode], $varCode, $arCurrentValues, $arErrors);
}
}
}
}
$arErrors = self::ValidateProperties($arProperties, new CBPWorkflowTemplateUser(CBPWorkflowTemplateUser::CurrentUser));
if (count($arErrors) > 0) {
return false;
}
$arCurrentActivity =& CBPWorkflowTemplateLoader::FindActivityByName($arWorkflowTemplate, $activityName);
$arCurrentActivity["Properties"] = $arProperties;
return true;
}
开发者ID:Satariall,项目名称:izurit,代码行数:33,代码来源:setvariableactivity.php
示例4: executeComponent
public function executeComponent()
{
$id = $this->getWorkflowId();
$this->arResult = array('NeedAuth' => $this->isAuthorizationNeeded() ? 'Y' : 'N', 'FatalErrorMessage' => '', 'ErrorMessage' => '');
if ($id) {
$workflowState = \CBPStateService::getWorkflowState($id);
if (!$workflowState) {
$this->arResult['FatalErrorMessage'] = Loc::getMessage('BPWFI_WORKFLOW_NOT_FOUND');
} else {
$this->arResult['WorkflowState'] = $workflowState;
$this->arResult['WorkflowTrack'] = \CBPTrackingService::DumpWorkflow($id);
if ($workflowState['STARTED_BY'] && ($photo = $this->getStartedByPhoto($workflowState['STARTED_BY']))) {
$this->arResult['startedByPhotoSrc'] = $photo['src'];
}
$runtime = CBPRuntime::GetRuntime();
$runtime->StartRuntime();
/**
* @var CBPDocumentService $documentService
*/
$documentService = $runtime->GetService('DocumentService');
try {
$this->arResult['DOCUMENT_NAME'] = $documentService->getDocumentName($workflowState['DOCUMENT_ID']);
$this->arResult['DOCUMENT_ICON'] = $documentService->getDocumentIcon($workflowState['DOCUMENT_ID']);
} catch (Main\ArgumentException $e) {
$this->arResult['FatalErrorMessage'] = $e->getMessage();
}
}
}
$this->includeComponentTemplate();
if ($this->arParams['SET_TITLE']) {
$this->setPageTitle(Loc::getMessage('BPWFI_PAGE_TITLE'));
}
}
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:33,代码来源:class.php
示例5: CallStaticMethod
public static function CallStaticMethod($code, $method, $arParameters = array())
{
$runtime = CBPRuntime::GetRuntime();
$runtime->IncludeActivityFile($code);
$code = preg_replace("[^a-zA-Z0-9]", "", $code);
$classname = 'CBP' . $code;
return call_user_func_array(array($classname, $method), $arParameters);
}
开发者ID:k-kalashnikov,项目名称:geekcon_new,代码行数:8,代码来源:activitycondition.php
示例6: GetPropertiesDialog
public static function GetPropertiesDialog($documentType, $arWorkflowTemplate, $arWorkflowParameters, $arWorkflowVariables, $defaultValue, $arCurrentValues = null)
{
$runtime = CBPRuntime::GetRuntime();
if (!is_array($arCurrentValues)) {
$arCurrentValues = array("php_code_condition" => $defaultValue == null ? "" : $defaultValue);
}
return $runtime->ExecuteResourceFile(__FILE__, "properties_dialog.php", array("arCurrentValues" => $arCurrentValues));
}
开发者ID:k-kalashnikov,项目名称:geekcon,代码行数:8,代码来源:codecondition.php
示例7: GetHistoryService
private static function GetHistoryService()
{
if (self::$historyService == null && CModule::IncludeModule('bizproc')) {
$runtime = CBPRuntime::GetRuntime();
$runtime->StartRuntime();
self::$historyService = $runtime->GetService("HistoryService");
}
return self::$historyService;
}
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:9,代码来源:iblockbizprochistory.php
示例8: GetPropertiesDialogValues
public static function GetPropertiesDialogValues($documentType, $activityName, &$arWorkflowTemplate, &$arWorkflowParameters, &$arWorkflowVariables, $arCurrentValues, &$arErrors)
{
$arErrors = array();
$runtime = CBPRuntime::GetRuntime();
$arProperties = array();
$arCurrentActivity =& CBPWorkflowTemplateLoader::FindActivityByName($arWorkflowTemplate, $activityName);
$arCurrentActivity["Properties"] = $arProperties;
return true;
}
开发者ID:webgksupport,项目名称:alpina,代码行数:9,代码来源:emptyblockactivity.php
示例9: CallStaticMethod
public static function CallStaticMethod($code, $method, $arParameters = array())
{
$runtime = CBPRuntime::GetRuntime();
$runtime->IncludeActivityFile($code);
if (preg_match("#[^a-zA-Z0-9_]#", $code)) {
throw new Exception("Activity '" . $code . "' is not valid");
}
$classname = 'CBP' . $code;
return call_user_func_array(array($classname, $method), $arParameters);
}
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:10,代码来源:activitycondition.php
示例10: GetPropertiesDialogValues
public static function GetPropertiesDialogValues($documentType, $activityName, &$arWorkflowTemplate, &$arWorkflowParameters, &$arWorkflowVariables, $arCurrentValues, &$arErrors)
{
$arErrors = array();
$runtime = CBPRuntime::GetRuntime();
$arProperties = array("ExecuteCode" => $arCurrentValues["execute_code"]);
$arErrors = self::ValidateProperties($arProperties, new CBPWorkflowTemplateUser(CBPWorkflowTemplateUser::CurrentUser));
if (count($arErrors) > 0) {
return false;
}
$arCurrentActivity =& CBPWorkflowTemplateLoader::FindActivityByName($arWorkflowTemplate, $activityName);
$arCurrentActivity["Properties"] = $arProperties;
return true;
}
开发者ID:k-kalashnikov,项目名称:geekcon,代码行数:13,代码来源:codeactivity.php
示例11: getDocumentSelectFields
/**
* @param FieldType $fieldType
* @return array
*/
private static function getDocumentSelectFields(FieldType $fieldType)
{
$runtime = \CBPRuntime::getRuntime();
$runtime->startRuntime();
$documentService = $runtime->getService("DocumentService");
$result = array();
$fields = $documentService->getDocumentFields($fieldType->getDocumentType());
foreach ($fields as $key => $field) {
if ($field['Type'] == 'select' && substr($key, -10) != '_PRINTABLE') {
$result[$key] = $field;
}
}
return $result;
}
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:18,代码来源:internalselect.php
示例12: GetPropertiesDialogValues
public static function GetPropertiesDialogValues($documentType, $activityName, &$arWorkflowTemplate, &$arWorkflowParameters, &$arWorkflowVariables, $arCurrentValues, &$arErrors)
{
$arErrors = array();
$runtime = CBPRuntime::GetRuntime();
$state = strlen($arCurrentValues["target_state_name_1"]) > 0 ? $arCurrentValues["target_state_name_1"] : $arCurrentValues["target_state_name"];
$cancelCurrentState = isset($arCurrentValues['cancel_current_state']) && $arCurrentValues['cancel_current_state'] == 'Y' ? 'Y' : 'N';
$arProperties = array('TargetStateName' => $state, 'CancelCurrentState' => $cancelCurrentState);
$arErrors = self::ValidateProperties($arProperties, new CBPWorkflowTemplateUser(CBPWorkflowTemplateUser::CurrentUser));
if (count($arErrors) > 0) {
return false;
}
$arCurrentActivity =& CBPWorkflowTemplateLoader::FindActivityByName($arWorkflowTemplate, $activityName);
$arCurrentActivity["Properties"] = $arProperties;
return true;
}
开发者ID:Satariall,项目名称:izurit,代码行数:15,代码来源:setstateactivity.php
示例13: OnEvent
public static function OnEvent($workflowId, $eventName, $arEventParameters = array())
{
$num = func_num_args();
if ($num > 3) {
for ($i = 3; $i < $num; $i++) {
$arEventParameters[] = func_get_arg($i);
}
}
if ($arEventParameters["EntityId"] != null && $arEventParameters["EntityId"] != $arEventParameters[0]) {
return;
}
try {
CBPRuntime::SendExternalEvent($workflowId, $eventName, $arEventParameters);
} catch (Exception $e) {
}
}
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:16,代码来源:schedulerservice.php
示例14: GetPropertiesDialogValues
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;
}
开发者ID:Satariall,项目名称:izurit,代码行数:17,代码来源:savehistoryactivity.php
示例15: UpdateHistory
function UpdateHistory($ID, $IBLOCK_ID, $modifyComment = false)
{
global $USER;
$rIBlock = CIBlock::getList(array(), array('ID' => $IBLOCK_ID, 'CHECK_PERMISSIONS' => 'N'));
$arIBlock = $rIBlock->GetNext();
// add changes history
if ($arIBlock['BIZPROC'] == 'Y' && CModule::IncludeModule('bizproc')) {
$cRuntime = CBPRuntime::GetRuntime();
$cRuntime->StartRuntime();
$documentService = $cRuntime->GetService('DocumentService');
$historyIndex = CBPHistoryService::Add(array('DOCUMENT_ID' => array('iblock', 'CWikiDocument', $ID), 'NAME' => 'New', 'DOCUMENT' => null, 'USER_ID' => $USER->GetID()));
$arDocument = $documentService->GetDocumentForHistory(array('iblock', 'CWikiDocument', $ID), $historyIndex);
$arDocument["MODIFY_COMMENT"] = $modifyComment ? $modifyComment : '';
if (is_array($arDocument)) {
CBPHistoryService::Update($historyIndex, array('NAME' => $arDocument['NAME'], 'DOCUMENT' => $arDocument));
}
return true;
}
return false;
}
开发者ID:Satariall,项目名称:izurit,代码行数:20,代码来源:wiki.php
示例16: GetPropertiesDialogValues
public static function GetPropertiesDialogValues($documentType, $activityName, &$arWorkflowTemplate, &$arWorkflowParameters, &$arWorkflowVariables, $arCurrentValues, &$arErrors)
{
$arErrors = array();
$runtime = CBPRuntime::GetRuntime();
$arProperties = array("Permission" => array(), "Rewrite" => true);
$documentService = $runtime->GetService("DocumentService");
$arAllowableOperations = $documentService->GetAllowableOperations($documentType);
foreach ($arAllowableOperations as $operationKey => $operationValue) {
$arProperties["Permission"][$operationKey] = CBPHelper::UsersStringToArray($arCurrentValues["permission_" . $operationKey], $documentType, $arErrors);
if (count($arErrors) > 0) {
return false;
}
}
$arProperties["Rewrite"] = $arCurrentValues["rewrite"] == "Y" ? "Y" : "N";
$arErrors = self::ValidateProperties($arProperties, new CBPWorkflowTemplateUser(CBPWorkflowTemplateUser::CurrentUser));
if (count($arErrors) > 0) {
return false;
}
$arCurrentActivity =& CBPWorkflowTemplateLoader::FindActivityByName($arWorkflowTemplate, $activityName);
$arCurrentActivity["Properties"] = $arProperties;
return true;
}
开发者ID:k-kalashnikov,项目名称:geekcon_new,代码行数:22,代码来源:setpermissionsactivity.php
示例17: GetPropertiesDialogValues
public static function GetPropertiesDialogValues($documentType, $activityName, &$arWorkflowTemplate, &$arWorkflowParameters, &$arWorkflowVariables, $arCurrentValues, &$arErrors)
{
$arErrors = array();
$runtime = CBPRuntime::GetRuntime();
$arMap = array("message_user_from" => "MessageUserFrom", "message_user_to" => "MessageUserTo", "message_text" => "MessageText");
$arProperties = array();
foreach ($arMap as $key => $value) {
if ($key == "message_user_from" || $key == "message_user_to") {
continue;
}
$arProperties[$value] = $arCurrentValues[$key];
}
global $USER;
if ($USER->IsAdmin() || CModule::IncludeModule("bitrix24") && CBitrix24::IsPortalAdmin($USER->GetID())) {
$arProperties["MessageUserFrom"] = CBPHelper::UsersStringToArray($arCurrentValues["message_user_from"], $documentType, $arErrors);
if (count($arErrors) > 0) {
return false;
}
} else {
$arProperties["MessageUserFrom"] = "user_" . $USER->GetID();
}
//global $USER;
//if (!$USER->IsAdmin())
// $arProperties["MessageUserFrom"] = "user_".$USER->GetID();
$arProperties["MessageUserTo"] = CBPHelper::UsersStringToArray($arCurrentValues["message_user_to"], $documentType, $arErrors);
if (count($arErrors) > 0) {
return false;
}
$arErrors = self::ValidateProperties($arProperties, new CBPWorkflowTemplateUser(CBPWorkflowTemplateUser::CurrentUser));
if (count($arErrors) > 0) {
return false;
}
$arCurrentActivity =& CBPWorkflowTemplateLoader::FindActivityByName($arWorkflowTemplate, $activityName);
$arCurrentActivity["Properties"] = $arProperties;
return true;
}
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:36,代码来源:socnetmessageactivity.php
示例18: SaveOrderDataCompanyBP
private function SaveOrderDataCompanyBP($companyId, $isNewCompany, $arParameters = array())
{
$companyId = intval($companyId);
if ($companyId <= 0) {
return;
}
static $isBPIncluded = null;
if ($isBPIncluded === null) {
$isBPIncluded = CModule::IncludeModule("bizproc");
}
if (!$isBPIncluded) {
return;
}
static $arBPTemplates = null;
if ($arBPTemplates === null) {
$arBPTemplates = CBPWorkflowTemplateLoader::SearchTemplatesByDocumentType(array('crm', 'CCrmDocumentCompany', 'COMPANY'), $isNewCompany ? CBPDocumentEventType::Create : CBPDocumentEventType::Edit);
}
if (!is_array($arBPTemplates)) {
return;
}
if (!is_array($arParameters)) {
$arParameters = array($arParameters);
}
if (!array_key_exists("TargetUser", $arParameters)) {
$assignedById = intval(COption::GetOptionString("crm", "sale_deal_assigned_by_id", "0"));
if ($assignedById > 0) {
$arParameters["TargetUser"] = "user_" . $assignedById;
}
}
$runtime = CBPRuntime::GetRuntime();
foreach ($arBPTemplates as $wt) {
try {
$wi = $runtime->CreateWorkflow($wt["ID"], array('crm', 'CCrmDocumentCompany', 'COMPANY_' . $companyId), $arParameters);
$wi->Start();
} catch (Exception $e) {
$this->AddError($e->getCode(), $e->getMessage());
}
}
}
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:39,代码来源:crm_external_sale_import.php
示例19: LocalRedirect
LocalRedirect($backUrl);
}
}
}
require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_admin_after.php";
$aMenu = array(array("TEXT" => GetMessage("BPAT_BACK"), "LINK" => $backUrl, "ICON" => "btn_list"));
if ($showType == 'Form' && $allowAdminAccess) {
$aMenu[] = array("TEXT" => GetMessage('BPAT_ACTION_DELEGATE'), 'ONCLICK' => 'bizprocShowDelegateDialog();');
}
$context = new CAdminContextMenu($aMenu);
$context->Show();
$APPLICATION->SetTitle(str_replace("#ID#", $taskId, GetMessage("BPAT_TITLE")));
if (strlen($errorMessage) > 0) {
CAdminMessage::ShowMessage($errorMessage);
}
$runtime = CBPRuntime::GetRuntime();
$runtime->StartRuntime();
$documentService = $runtime->GetService("DocumentService");
if (empty($arTask["PARAMETERS"]["DOCUMENT_ID"])) {
CAdminMessage::ShowMessage(GetMessage('BPAT_NO_STATE'));
$showType = 'Success';
} else {
try {
$documentType = $documentService->GetDocumentType($arTask["PARAMETERS"]["DOCUMENT_ID"]);
if (!array_key_exists("BP_AddShowParameterInit_" . $documentType[0] . "_" . $documentType[1] . "_" . $documentType[2], $GLOBALS)) {
$GLOBALS["BP_AddShowParameterInit_" . $documentType[0] . "_" . $documentType[1] . "_" . $documentType[2]] = 1;
CBPDocument::AddShowParameterInit($documentType[0], "only_users", $documentType[2], $documentType[1]);
}
} catch (Exception $e) {
CAdminMessage::ShowMessage(GetMessage('BPAT_NO_STATE'));
$showType = 'Success';
开发者ID:Satariall,项目名称:izurit,代码行数:31,代码来源:task.php
示例20: ImportTemplate
public static function ImportTemplate($id, $documentType, $autoExecute, $name, $description, $datum, $systemCode = null, $systemImport = false)
{
$id = intval($id);
if ($id <= 0) {
$id = 0;
}
$datumTmp = CheckSerializedData($datum) ? @unserialize($datum) : null;
if (!is_array($datumTmp) || is_array($datumTmp) && !array_key_exists("TEMPLATE", $datumTmp)) {
if (function_exists("gzcompress")) {
$datumTmp = @gzuncompress($datum);
$datumTmp = CheckSerializedData($datumTmp) ? @unserialize($datumTmp) : null;
}
}
if (!is_array($datumTmp) || is_array($datumTmp) && !array_key_exists("TEMPLATE", $datumTmp)) {
throw new Exception(GetMessage("BPCGWTL_WRONG_TEMPLATE"));
}
if (array_key_exists("VERSION", $datumTmp) && $datumTmp["VERSION"] == 2) {
$datumTmp["TEMPLATE"] = self::ConvertArrayCharset($datumTmp["TEMPLATE"], BP_EI_DIRECTION_IMPORT);
$datumTmp["PARAMETERS"] = self::ConvertArrayCharset($datumTmp["PARAMETERS"], BP_EI_DIRECTION_IMPORT);
$datumTmp["VARIABLES"] = self::ConvertArrayCharset($datumTmp["VARIABLES"], BP_EI_DIRECTION_IMPORT);
$datumTmp["CONSTANTS"] = isset($datumTmp["CONSTANTS"]) ? self::ConvertArrayCharset($datumTmp["CONSTANTS"], BP_EI_DIRECTION_IMPORT) : array();
$datumTmp["DOCUMENT_FIELDS"] = self::ConvertArrayCharset($datumTmp["DOCUMENT_FIELDS"], BP_EI_DIRECTION_IMPORT);
}
if (!$systemImport) {
if (!self::WalkThroughWorkflowTemplate($datumTmp["TEMPLATE"], array("CBPWorkflowTemplateLoader", "ImportTemplateChecker"), new CBPWorkflowTemplateUser(CBPWorkflowTemplateUser::CurrentUser))) {
return false;
}
} elseif ($id > 0 && !empty($datumTmp["CONSTANTS"])) {
$userConstants = self::getTemplateConstants($id);
if (!empty($userConstants)) {
foreach ($userConstants as $constantName => $constantData) {
if (isset($datumTmp["CONSTANTS"][$constantName])) {
$datumTmp["CONSTANTS"][$constantName]['Default'] = $constantData['Default'];
}
}
}
}
$templateData = array("DOCUMENT_TYPE" => $documentType, "AUTO_EXECUTE" => $autoExecute, "NAME" => $name, "DESCRIPTION" => $description, "TEMPLATE" => $datumTmp["TEMPLATE"], "PARAMETERS" => $datumTmp["PARAMETERS"], "VARIABLES" => $datumTmp["VARIABLES"], "CONSTANTS" => $datumTmp["CONSTANTS"], "USER_ID" => $systemImport ? 1 : $GLOBALS["USER"]->GetID(), "MODIFIER_USER" => new CBPWorkflowTemplateUser($systemImport ? 1 : CBPWorkflowTemplateUser::CurrentUser));
if (!is_null($systemCode)) {
$templateData["SYSTEM_CODE"] = $systemCode;
}
if ($id <= 0) {
$templateData['ACTIVE'] = 'Y';
}
if ($id > 0) {
self::Update($id, $templateData, $systemImport);
} else {
$id = self::Add($templateData, $systemImport);
}
$runtime = CBPRuntime::GetRuntime();
$runtime->StartRuntime();
$documentService = $runtime->GetService("DocumentService");
$arDocumentFields = $documentService->GetDocumentFields($documentType);
if (is_array($datumTmp["DOCUMENT_FIELDS"])) {
$len = strlen("_PRINTABLE");
$arFieldsTmp = array();
foreach ($datumTmp["DOCUMENT_FIELDS"] as $code => $field) {
if (!array_key_exists($code, $arDocumentFields) && strtoupper(substr($code, -$len)) != "_PRINTABLE") {
$arFieldsTmp[$code] = array("name" => $field["Name"], "code" => $code, "type" => $field["Type"], "multiple" => $field["Multiple"], "required" => $field["Required"]);
if (is_array($field["Options"]) && count($field["Options"]) > 0) {
foreach ($field["Options"] as $k => $v) {
$arFieldsTmp[$code]["options"] .= "[" . $k . "]" . $v . "\n";
}
}
unset($field["Name"], $field["Type"], $field["Multiple"], $field["Required"], $field["Options"]);
$arFieldsTmp[$code] = array_merge($arFieldsTmp[$code], $field);
}
}
if (!empty($arFieldsTmp)) {
\Bitrix\Main\Type\Collection::sortByColumn($arFieldsTmp, "sort");
foreach ($arFieldsTmp as $fieldTmp) {
$documentService->AddDocumentField($documentType, $fieldTmp);
}
}
}
return $id;
}
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:77,代码来源:workflowtemplateloader.php
注:本文中的CBPRuntime类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论