/** * @param FieldType $fieldType * @param array $field * @param array $request * @return null|int */ protected static function extractValue(FieldType $fieldType, array $field, array $request) { $value = Base::extractValue($fieldType, $field, $request); if ($value !== null && is_string($value) && strlen($value) > 0) { if (\CBPActivity::isExpression($value)) { return $value; } $value = str_replace(' ', '', $value); if (preg_match('#^[0-9\\-]+$#', $value)) { $value = (int) $value; } else { $value = null; static::addError(array('code' => 'ErrorValue', 'message' => Loc::getMessage('BPDT_INT_INVALID'), 'parameter' => static::generateControlName($field))); } } else { $value = null; } return $value; }
/** * @param FieldType $fieldType Document field type. * @param array $field Form field. * @param array $request Request data. * @return array */ public static function extractValueMultiple(FieldType $fieldType, array $field, array $request) { static::cleanErrors(); $name = $field['Field']; $value = isset($request[$name]) ? $request[$name] : array(); if (!is_array($value) || is_array($value) && \CBPHelper::isAssociativeArray($value)) { $value = array($value); } foreach ($value as $k => $v) { $field['Index'] = $k; $result = static::extractValue($fieldType, $field, $request); if ($result === null || $result === '') { unset($value[$k]); } else { $value[$k] = $result; } } //apppend selector value $nameText = $field['Field'] . '_text'; $text = isset($request[$nameText]) ? $request[$nameText] : null; if (\CBPActivity::isExpression($text)) { $value[] = $text; } return array_values($value); }
function GetFieldInputValue($documentType, $arFieldType, $arFieldName, $arRequest, &$arErrors) { $v = substr($documentType, strlen("type_")); if (intval($v) . "!" != $v . "!") { return null; } $iblockId = intval($v); $result = array(); if ($arFieldType["Type"] == "S:UserID") { $value = $arRequest[$arFieldName["Field"]]; if (strlen($value) > 0) { $arErrorsTmp1 = array(); $result = CBPHelper::UsersStringToArray($value, array("bizproc", "CBPVirtualDocument", $documentType), $arErrorsTmp1); if (count($arErrorsTmp1) > 0) { foreach ($arErrorsTmp1 as $e) { $arErrors[] = $e; } } } } elseif (array_key_exists($arFieldName["Field"], $arRequest) || array_key_exists($arFieldName["Field"] . "_text", $arRequest)) { $arValue = array(); if (array_key_exists($arFieldName["Field"], $arRequest)) { $arValue = $arRequest[$arFieldName["Field"]]; if (!is_array($arValue) || is_array($arValue) && CBPHelper::IsAssociativeArray($arValue)) { $arValue = array($arValue); } } if (array_key_exists($arFieldName["Field"] . "_text", $arRequest)) { $arValue[] = $arRequest[$arFieldName["Field"] . "_text"]; } foreach ($arValue as $value) { if (is_array($value) || !is_array($value) && !CBPActivity::isExpression($value)) { if ($arFieldType["Type"] == "N") { if (strlen($value) > 0) { $value = str_replace(" ", "", str_replace(",", ".", $value)); if (is_numeric($value)) { $value = doubleval($value); } else { $value = null; $arErrors[] = array("code" => "ErrorValue", "message" => GetMessage("BPCGWTL_INVALID1N"), "parameter" => $arFieldName["Field"]); } } else { $value = null; } } elseif ($arFieldType["Type"] == "L") { if (!is_array($arFieldType["Options"]) || count($arFieldType["Options"]) <= 0 || strlen($value) <= 0) { $value = null; } else { $ar = array_values($arFieldType["Options"]); if (is_array($ar[0])) { $b = false; foreach ($ar as $a) { if ($a[0] == $value) { $b = true; break; } } if (!$b) { $value = null; $arErrors[] = array("code" => "ErrorValue", "message" => GetMessage("BPCGWTL_INVALID3N"), "parameter" => $arFieldName["Field"]); } } else { if (!array_key_exists($value, $arFieldType["Options"])) { $value = null; $arErrors[] = array("code" => "ErrorValue", "message" => GetMessage("BPCGWTL_INVALID3N"), "parameter" => $arFieldName["Field"]); } } } } elseif ($arFieldType["Type"] == "B") { if ($value !== "Y" && $value !== "N") { if ($value === true) { $value = "Y"; } elseif ($value === false) { $value = "N"; } elseif (strlen($value) > 0) { $value = strtolower($value); if (in_array($value, array("y", "yes", "true", "1"))) { $value = "Y"; } elseif (in_array($value, array("n", "no", "false", "0"))) { $value = "N"; } else { $value = null; $arErrors[] = array("code" => "ErrorValue", "message" => GetMessage("BPCGWTL_INVALID4N"), "parameter" => $arFieldName["Field"]); } } else { $value = null; } } } elseif ($arFieldType["Type"] == "F") { if (array_key_exists("name", $value) && strlen($value["name"]) > 0) { if (!array_key_exists("MODULE_ID", $value)) { $value["MODULE_ID"] = "bizproc"; } $value = CFile::SaveFile($value, "bizproc_wf", true); if (!$value) { $value = null; $arErrors[] = array("code" => "ErrorValue", "message" => GetMessage("BPCGWTL_INVALID9N"), "parameter" => $arFieldName["Field"]); } } else { $value = null; } } elseif (strpos($arFieldType["Type"], ":") !== false) { $arCustomType = CIBlockProperty::GetUserType(substr($arFieldType["Type"], 2)); if (array_key_exists("GetLength", $arCustomType)) { if (call_user_func_array($arCustomType["GetLength"], array(array("LINK_IBLOCK_ID" => $arFieldType["Options"]), array("VALUE" => $value))) <= 0) { $value = null; } } else { if (!is_array($value) && strlen($value) == 0 || is_array($value) && (count($value) == 0 || count($value) == 1 && isset($value["VALUE"]) && !is_array($value["VALUE"]) && strlen($value["VALUE"]) == 0)) { $value = null; } } if ($value !== null && array_key_exists("CheckFields", $arCustomType)) { $arErrorsTmp1 = call_user_func_array($arCustomType["CheckFields"], array(array("LINK_IBLOCK_ID" => $arFieldType["Options"]), array("VALUE" => $value))); if (count($arErrorsTmp1) > 0) { $value = null; foreach ($arErrorsTmp1 as $e) { $arErrors[] = array("code" => "ErrorValue", "message" => $e, "parameter" => $arFieldName["Field"]); } } } if ($value !== null && $arFieldType["Type"] == "S:employee" && COption::GetOptionString("bizproc", "employee_compatible_mode", "N") != "Y") { $value = "user_" . $value; } } else { if (!is_array($value) && strlen($value) <= 0) { $value = null; } } } if ($value !== null) { $result[] = $value; } } } if (!$arFieldType["Multiple"]) { if (count($result) > 0) { $result = $result[0]; } else { $result = null; } } return $result; }
echo GetMessage("CPAD_DP_TIME_D"); ?> </option> </select> </td> </tr> <tr id="tr_time_type_selector_time"> <td align="right" width="40%"><?php echo GetMessage("CPAD_DP_TIME1"); ?> :</td> <td width="60%"> <?php $v = ""; $v_x = trim($arCurrentValues["delay_date"]); if (!CBPActivity::isExpression($v_x)) { $v = $v_x; $v_x = ""; } require_once $_SERVER["DOCUMENT_ROOT"] . BX_ROOT . "/modules/main/interface/init_admin.php"; echo CAdminCalendar::CalendarDate("delay_date", $v, 19, true); ?> <input type="text" name="delay_date_x" id="id_delay_date_x" value="<?php echo htmlspecialcharsbx($v_x); ?> " size="20" /> <input type="button" value="..." onclick="BPAShowSelector('id_delay_date_x', 'datetime');" /> </td> </tr> <script type="text/javascript"> SetDelayMode(<?php
/** * @param FieldType $fieldType * @param array $field * @param mixed $value * @param bool $allowSelection * @param int $renderMode * @return string */ protected static function renderControl(FieldType $fieldType, array $field, $value, $allowSelection, $renderMode) { $selectorValue = null; $typeValue = array(); if (!is_array($value) || is_array($value) && \CBPHelper::isAssociativeArray($value)) { $value = array($value); } foreach ($value as $v) { if (\CBPActivity::isExpression($v)) { $selectorValue = $v; } else { $typeValue[] = $v; } } // need to show at least one control if (empty($typeValue)) { $typeValue[] = null; } $renderResult = '<select id="' . htmlspecialcharsbx(static::generateControlId($field)) . '" name="' . htmlspecialcharsbx(static::generateControlName($field)) . ($fieldType->isMultiple() ? '[]' : '') . '"' . ($fieldType->isMultiple() ? ' size="5" multiple' : '') . '>'; if (!$fieldType->isRequired()) { $renderResult .= '<option value="">[' . Loc::getMessage('BPCGHLP_NOT_SET') . ']</option>'; } $options = static::getFieldOptions($fieldType); foreach ($options as $k => $v) { $ind = array_search($k, $typeValue); $renderResult .= '<option value="' . htmlspecialcharsbx($k) . '"' . ($ind !== false ? ' selected' : '') . '>' . htmlspecialcharsbx($v) . '</option>'; } $renderResult .= '</select>'; if ($allowSelection) { $renderResult .= static::renderControlSelector($field, $selectorValue, true); } return $renderResult; }
/** * @param FieldType $fieldType * @param array $field * @param array $request * @return float|null */ protected static function extractValue(FieldType $fieldType, $field, $request) { $value = parent::extractValue($fieldType, $field, $request); if ($value !== null && is_string($value) && strlen($value) > 0) { if (\CBPActivity::isExpression($value)) { return $value; } $value = str_replace(' ', '', str_replace(',', '.', $value)); if (is_numeric($value)) { $value = (double) $value; } else { $value = null; static::addError(array('code' => 'ErrorValue', 'message' => Loc::getMessage('BPDT_DOUBLE_INVALID'), 'parameter' => static::generateControlName($field))); } } else { $value = null; } return $value; }
function GetFieldInputValue($documentType, $arFieldType, $arFieldName, $arRequest, &$arErrors) { $result = array(); if ($arFieldType["Type"] == "user") { $value = $arRequest[$arFieldName["Field"]]; if (strlen($value) > 0) { $result = CBPHelper::UsersStringToArray($value, $documentType, $arErrors); if (count($arErrors) > 0) { foreach ($arErrors as $e) { $arErrors[] = $e; } } } } elseif (array_key_exists($arFieldName["Field"], $arRequest) || array_key_exists($arFieldName["Field"] . "_text", $arRequest)) { $arValue = array(); if (array_key_exists($arFieldName["Field"], $arRequest)) { $arValue = $arRequest[$arFieldName["Field"]]; if (!is_array($arValue) || is_array($arValue) && CBPHelper::IsAssociativeArray($arValue)) { $arValue = array($arValue); } } if (array_key_exists($arFieldName["Field"] . "_text", $arRequest)) { $arValue[] = $arRequest[$arFieldName["Field"] . "_text"]; } foreach ($arValue as $value) { if (!CBPActivity::isExpression($value)) { if ($arFieldType["Type"] == "int") { if (strlen($value) > 0) { $value = str_replace(" ", "", $value); if ($value . "|" == intval($value) . "|") { $value = intval($value); } else { $value = null; $arErrors[] = array("code" => "ErrorValue", "message" => GetMessage("BPCGWTL_INVALID1"), "parameter" => $arFieldName["Field"]); } } else { $value = null; } } elseif ($arFieldType["Type"] == "double") { if (strlen($value) > 0) { $value = str_replace(" ", "", str_replace(",", ".", $value)); if ($value . "|" == doubleval($value) . "|") { $value = doubleval($value); } else { $value = null; $arErrors[] = array("code" => "ErrorValue", "message" => GetMessage("BPCGWTL_INVALID11"), "parameter" => $arFieldName["Field"]); } } else { $value = null; } } elseif ($arFieldType["Type"] == "select") { if (!is_array($arFieldType["Options"]) || count($arFieldType["Options"]) <= 0 || strlen($value) <= 0) { $value = null; } elseif (!array_key_exists($value, $arFieldType["Options"])) { $value = null; $arErrors[] = array("code" => "ErrorValue", "message" => GetMessage("BPCGWTL_INVALID35"), "parameter" => $arFieldName["Field"]); } } elseif ($arFieldType["Type"] == "bool") { if ($value !== "Y" && $value !== "N") { if ($value === true) { $value = "Y"; } elseif ($value === false) { $value = "N"; } elseif (strlen($value) > 0) { $value = strtolower($value); if (in_array($value, array("y", "yes", "true", "1"))) { $value = "Y"; } elseif (in_array($value, array("n", "no", "false", "0"))) { $value = "N"; } else { $value = null; $arErrors[] = array("code" => "ErrorValue", "message" => GetMessage("BPCGWTL_INVALID45"), "parameter" => $arFieldName["Field"]); } } else { $value = null; } } } elseif ($arFieldType["Type"] == "file") { if (array_key_exists("name", $value) && strlen($value["name"]) > 0) { if (!array_key_exists("MODULE_ID", $value) || strlen($value["MODULE_ID"]) <= 0) { $value["MODULE_ID"] = "bizproc"; } $value = CFile::SaveFile($value, "bizproc_wf", true, true); if (!$value) { $value = null; $arErrors[] = array("code" => "ErrorValue", "message" => GetMessage("BPCGWTL_INVALID915"), "parameter" => $arFieldName["Field"]); } } else { $value = null; } } else { if (!is_array($value) && strlen($value) <= 0) { $value = null; } } } if ($value != null) { $result[] = $value; } } } if (!$arFieldType["Multiple"]) { if (count($result) > 0) { $result = $result[0]; } else { $result = null; } } return $result; }
public static function GetPropertiesDialog($documentType, $activityName, $arWorkflowTemplate, $arWorkflowParameters, $arWorkflowVariables, $arCurrentValues = null, $formName = "") { $runtime = CBPRuntime::GetRuntime(); $arMap = array("Users" => "review_users", "ApproveType" => "approve_type", "OverdueDate" => "review_overdue_date", "Name" => "review_name", "Description" => "review_description", "Parameters" => "review_parameters", "StatusMessage" => "status_message", "SetStatusMessage" => "set_status_message", "TaskButtonMessage" => "task_button_message", "CommentLabelMessage" => "comment_label_message", "ShowComment" => "show_comment", "TimeoutDuration" => "timeout_duration", "TimeoutDurationType" => "timeout_duration_type", "AccessControl" => "access_control"); 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"])) { if ($k == "Users") { $arCurrentValues[$arMap[$k]] = CBPHelper::UsersArrayToString($arCurrentActivity["Properties"][$k], $arWorkflowTemplate, $documentType); } elseif ($k == "TimeoutDuration") { $arCurrentValues["timeout_duration"] = $arCurrentActivity["Properties"]["TimeoutDuration"]; if (!CBPActivity::isExpression($arCurrentValues["timeout_duration"]) && !array_key_exists("TimeoutDurationType", $arCurrentActivity["Properties"])) { $arCurrentValues["timeout_duration"] = intval($arCurrentValues["timeout_duration"]); $arCurrentValues["timeout_duration_type"] = "s"; if ($arCurrentValues["timeout_duration"] % (3600 * 24) == 0) { $arCurrentValues["timeout_duration"] = $arCurrentValues["timeout_duration"] / (3600 * 24); $arCurrentValues["timeout_duration_type"] = "d"; } elseif ($arCurrentValues["timeout_duration"] % 3600 == 0) { $arCurrentValues["timeout_duration"] = $arCurrentValues["timeout_duration"] / 3600; $arCurrentValues["timeout_duration_type"] = "h"; } elseif ($arCurrentValues["timeout_duration"] % 60 == 0) { $arCurrentValues["timeout_duration"] = $arCurrentValues["timeout_duration"] / 60; $arCurrentValues["timeout_duration_type"] = "m"; } } } else { $arCurrentValues[$arMap[$k]] = $arCurrentActivity["Properties"][$k]; } } else { if (!is_array($arCurrentValues) || !array_key_exists($arMap[$k], $arCurrentValues)) { $arCurrentValues[$arMap[$k]] = ""; } } } } else { foreach ($arMap as $k => $v) { $arCurrentValues[$arMap[$k]] = ""; } } } if (strlen($arCurrentValues['status_message']) <= 0) { $arCurrentValues['status_message'] = GetMessage("BPAR_ACT_INFO"); } if (strlen($arCurrentValues['comment_label_message']) <= 0) { $arCurrentValues['comment_label_message'] = GetMessage("BPAR_ACT_COMMENT"); } if (strlen($arCurrentValues['task_button_message']) <= 0) { $arCurrentValues['task_button_message'] = GetMessage("BPAR_ACT_BUTTON2"); } if (strlen($arCurrentValues["timeout_duration_type"]) <= 0) { $arCurrentValues["timeout_duration_type"] = "s"; } $documentService = $runtime->GetService("DocumentService"); $arDocumentFields = $documentService->GetDocumentFields($documentType); return $runtime->ExecuteResourceFile(__FILE__, "properties_dialog.php", array("arCurrentValues" => $arCurrentValues, "arDocumentFields" => $arDocumentFields, "formName" => $formName)); }
public static function GetPropertiesDialogValues($documentType, $activityName, &$arWorkflowTemplate, &$arWorkflowParameters, &$arWorkflowVariables, $arCurrentValues, &$arErrors) { $arErrors = array(); $runtime = CBPRuntime::GetRuntime(); $arProperties = array(); if ($arCurrentValues["time_type_selector"] == "time") { if (strlen($arCurrentValues["delay_date"]) > 0 && ($d = MakeTimeStamp($arCurrentValues["delay_date"]))) { $arProperties["TimeoutTime"] = $d; } elseif (strlen($arCurrentValues["delay_date_x"]) > 0 && CBPActivity::isExpression($arCurrentValues["delay_date_x"])) { $arProperties["TimeoutTime"] = $arCurrentValues["delay_date_x"]; } } else { $arProperties["TimeoutDuration"] = $arCurrentValues["delay_time"]; $arProperties["TimeoutDurationType"] = $arCurrentValues["delay_type"]; } $arErrors = self::ValidateProperties($arProperties, new CBPWorkflowTemplateUser(CBPWorkflowTemplateUser::CurrentUser)); if (count($arErrors) > 0) { return false; } $arCurrentActivity =& CBPWorkflowTemplateLoader::FindActivityByName($arWorkflowTemplate, $activityName); $arCurrentActivity["Properties"] = $arProperties; return true; }
/** * @param FieldType $fieldType Document field object. * @param array $field Form field information. * @param mixed $value Field value. * @param bool $allowSelection Allow selection flag. * @param int $renderMode Control render mode. * @return string */ public static function renderControlMultiple(FieldType $fieldType, array $field, $value, $allowSelection, $renderMode) { $selectorValue = null; $typeValue = array(); if (!is_array($value) || is_array($value) && \CBPHelper::isAssociativeArray($value)) { $value = array($value); } foreach ($value as $v) { if (\CBPActivity::isExpression($v)) { $selectorValue = $v; } else { $typeValue[] = $v; } } // need to show at least one control if (empty($typeValue)) { $typeValue[] = null; } $controls = array(); foreach ($typeValue as $k => $v) { $singleField = $field; $singleField['Index'] = $k; $controls[] = static::renderControl($fieldType, $singleField, $v, $allowSelection, $renderMode); } $renderResult = static::wrapCloneableControls($controls, static::generateControlName($field)); if ($allowSelection) { $renderResult .= static::renderControlSelector($field, $selectorValue, true); } return $renderResult; }
/** * @param FieldType $fieldType Document field object. * @param array $field Form field information. * @param mixed $value Field value. * @param bool $allowSelection Allow selection flag. * @param int $renderMode Control render mode. * @return string */ public static function renderControlMultiple(FieldType $fieldType, array $field, $value, $allowSelection, $renderMode) { $selectorValue = null; $typeValue = array(); if (!is_array($value) || is_array($value) && \CBPHelper::isAssociativeArray($value)) { $value = array($value); } foreach ($value as $v) { if (\CBPActivity::isExpression($v)) { $selectorValue = $v; } else { $typeValue[] = $v; } } $userType = static::getUserType($fieldType); if (!empty($userType['GetPublicEditHTMLMulty'])) { foreach ($typeValue as $k => &$fld) { if (!isset($fld['VALUE'])) { $fld = array('VALUE' => $fld); } if ($fld['VALUE'] === null) { unset($typeValue[$k]); } } $typeValue = array_values($typeValue); $renderResult = call_user_func_array($userType['GetPublicEditHTMLMulty'], array(array('LINK_IBLOCK_ID' => $fieldType->getOptions()), $typeValue, array('FORM_NAME' => $field['Form'], 'VALUE' => static::generateControlName($field)), true)); } else { $controls = array(); // need to show at least one control if (empty($typeValue)) { $typeValue[] = null; } foreach ($typeValue as $k => $v) { $singleField = $field; $singleField['Index'] = $k; $controls[] = static::renderControlSingle($fieldType, $singleField, $v, $allowSelection, $renderMode); } $renderResult = static::wrapCloneableControls($controls, static::generateControlName($field)); } if ($allowSelection) { $renderResult .= static::renderControlSelector($field, $selectorValue, true); } return $renderResult; }
/** * @param FieldType $fieldType Document field object. * @param array $field Form field information. * @param mixed $value Field value. * @param bool $allowSelection Allow selection flag. * @param int $renderMode Control render mode. * @return string */ public static function renderControlMultiple(FieldType $fieldType, array $field, $value, $allowSelection, $renderMode) { $value = static::fixUserPrefix($value); $renderResult = parent::renderControlMultiple($fieldType, $field, $value, false, $renderMode); if ($allowSelection) { $selectorValue = null; if (!is_array($value) || is_array($value) && \CBPHelper::isAssociativeArray($value)) { $value = array($value); } foreach ($value as $v) { if (\CBPActivity::isExpression($v)) { $selectorValue = $v; } } $renderResult .= static::renderControlSelector($field, $selectorValue, true, 'employee'); } return $renderResult; }
/** * Bizproc expression checker. Required for usage from external modules! * Examples: {=Document:IBLOCK_ID}, {=Document:CREATED_BY>printable}, {=SequentialWorkflowActivity1:DocumentApprovers>user,printable} * @param $value * @return bool */ public static function IsExpression($value) { //go to internal alias return CBPActivity::isExpression($value); }
/** * @param FieldType $fieldType Document field object. * @param array $field Form field information. * @param mixed $value Field value. * @param bool $allowSelection Allow selection flag. * @param int $renderMode Control render mode. * @return string */ public static function renderControlMultiple(FieldType $fieldType, array $field, $value, $allowSelection, $renderMode) { if ($allowSelection) { $selectorValue = null; if (is_array($value)) { $value = current($value); } if (\CBPActivity::isExpression($value)) { $selectorValue = $value; $value = null; } return static::renderControlSelector($field, $selectorValue, true); } if ($renderMode & FieldType::RENDER_MODE_DESIGNER) { return ''; } $userType = static::getUserType($fieldType); $iblockId = self::getIblockId($fieldType); if (!empty($userType['GetPublicEditHTML'])) { if (is_array($value) && isset($value['VALUE'])) { $value = $value['VALUE']; } $fieldName = static::generateControlName($field); $renderResult = call_user_func_array($userType['GetPublicEditHTML'], array(array('IBLOCK_ID' => $iblockId, 'IS_REQUIRED' => $fieldType->isRequired() ? 'Y' : 'N', 'PROPERTY_USER_TYPE' => $userType), array('VALUE' => $value), array('FORM_NAME' => $field['Form'], 'VALUE' => $fieldName, 'DESCRIPTION' => ''), true)); } else { $renderResult = static::renderControl($fieldType, $field, $value, $allowSelection, $renderMode); } return $renderResult; }