本文整理汇总了PHP中CBPRuntime类的典型用法代码示例。如果您正苦于以下问题:PHP CBPRuntime类的具体用法?PHP CBPRuntime怎么用?PHP CBPRuntime使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CBPRuntime类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
}
示例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));
}
示例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;
}
示例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'));
}
}
示例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);
}
示例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));
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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) {
}
}
示例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;
}
示例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;
}