本文整理汇总了PHP中CBPHelper::usersStringToArray方法的典型用法代码示例。如果您正苦于以下问题:PHP CBPHelper::usersStringToArray方法的具体用法?PHP CBPHelper::usersStringToArray怎么用?PHP CBPHelper::usersStringToArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CBPHelper
的用法示例。
在下文中一共展示了CBPHelper::usersStringToArray方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: GetPropertiesDialogValues
public static function GetPropertiesDialogValues($documentType, $activityName, &$workflowTemplate, &$workflowParameters, &$workflowVariables, $currentValues, &$errors)
{
$runtime = CBPRuntime::GetRuntime();
$errors = array();
$map = array('setstatusmessage' => 'SetStatusMessage', 'statusmessage' => 'StatusMessage', 'usesubscription' => 'UseSubscription', 'timeoutduration' => 'TimeoutDuration', 'timeoutdurationtype' => 'TimeoutDurationType');
$properties = array();
foreach ($map as $key => $value) {
$properties[$value] = $currentValues[$key];
}
$activityData = self::getRestActivityData();
$activityProperties = isset($activityData['PROPERTIES']) && is_array($activityData['PROPERTIES']) ? $activityData['PROPERTIES'] : array();
/** @var CBPDocumentService $documentService */
$documentService = $runtime->GetService('DocumentService');
$activityDocumentType = is_array($activityData['DOCUMENT_TYPE']) ? $activityData['DOCUMENT_TYPE'] : $documentType;
foreach ($activityProperties as $name => $property) {
$requestName = strtolower($name);
if (isset($properties[$requestName])) {
continue;
}
$errors = array();
$properties[$name] = $documentService->GetFieldInputValue($activityDocumentType, $property, $requestName, $currentValues, $errors);
if (count($errors) > 0) {
return false;
}
}
if (static::checkAdminPermissions()) {
$properties['AuthUserId'] = CBPHelper::usersStringToArray($currentValues['authuserid'], $documentType, $errors);
if (count($errors) > 0) {
return false;
}
} else {
unset($properties['AuthUserId']);
}
if (!empty($activityData['USE_SUBSCRIPTION'])) {
$properties['UseSubscription'] = $activityData['USE_SUBSCRIPTION'];
}
$errors = self::ValidateProperties($properties, new CBPWorkflowTemplateUser(CBPWorkflowTemplateUser::CurrentUser));
if (count($errors) > 0) {
return false;
}
$currentActivity =& CBPWorkflowTemplateLoader::FindActivityByName($workflowTemplate, $activityName);
$currentActivity["Properties"] = $properties;
return true;
}
示例2: GetFieldInputValue
public function GetFieldInputValue($documentType, $fieldType, $fieldName, $request, &$errors)
{
$iblockId = intval(substr($documentType, strlen("iblock_")));
if ($iblockId <= 0) {
throw new CBPArgumentOutOfRangeException("documentType", $documentType);
}
$result = array();
if ($fieldType["Type"] == "user") {
$value = $request[$fieldName["Field"]];
if (strlen($value) > 0) {
$result = CBPHelper::usersStringToArray($value, array("lists", get_called_class(), $documentType), $errors);
if (count($errors) > 0) {
foreach ($errors as $e) {
$errors[] = $e;
}
}
} else {
$result = null;
}
} elseif (array_key_exists($fieldName["Field"], $request) || array_key_exists($fieldName["Field"] . "_text", $request)) {
$valueArray = array();
if (array_key_exists($fieldName["Field"], $request)) {
$valueArray = $request[$fieldName["Field"]];
if (!is_array($valueArray) || is_array($valueArray) && CBPHelper::isAssociativeArray($valueArray)) {
$valueArray = array($valueArray);
}
}
if (array_key_exists($fieldName["Field"] . "_text", $request)) {
$valueArray[] = $request[$fieldName["Field"] . "_text"];
}
foreach ($valueArray as $value) {
if (is_array($value) || !is_array($value) && !\CBPDocument::IsExpression(trim($value))) {
if ($fieldType["Type"] == "int") {
if (strlen($value) > 0) {
$value = str_replace(" ", "", $value);
if ($value . "|" == intval($value) . "|") {
$value = intval($value);
} else {
$value = null;
$errors[] = array("code" => "ErrorValue", "message" => GetMessage("LISTS_BIZPROC_INVALID_INT"), "parameter" => $fieldName["Field"]);
}
} else {
$value = null;
}
} elseif ($fieldType["Type"] == "double") {
if (strlen($value) > 0) {
$value = str_replace(" ", "", str_replace(",", ".", $value));
if (is_numeric($value)) {
$value = doubleval($value);
} else {
$value = null;
$errors[] = array("code" => "ErrorValue", "message" => GetMessage("LISTS_BIZPROC_INVALID_INT"), "parameter" => $fieldName["Field"]);
}
} else {
$value = null;
}
} elseif ($fieldType["Type"] == "select") {
if (!is_array($fieldType["Options"]) || count($fieldType["Options"]) <= 0 || strlen($value) <= 0) {
$value = null;
} else {
$ar = array_values($fieldType["Options"]);
if (is_array($ar[0])) {
$b = false;
foreach ($ar as $a) {
if ($a[0] == $value) {
$b = true;
break;
}
}
if (!$b) {
$value = null;
$errors[] = array("code" => "ErrorValue", "message" => GetMessage("LISTS_BIZPROC_INVALID_SELECT"), "parameter" => $fieldName["Field"]);
}
} else {
if (!array_key_exists($value, $fieldType["Options"])) {
$value = null;
$errors[] = array("code" => "ErrorValue", "message" => GetMessage("LISTS_BIZPROC_INVALID_SELECT"), "parameter" => $fieldName["Field"]);
}
}
}
} elseif ($fieldType["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;
$errors[] = array("code" => "ErrorValue", "message" => GetMessage("BPCGWTL_INVALID45"), "parameter" => $fieldName["Field"]);
}
} else {
$value = null;
}
}
//.........这里部分代码省略.........
示例3: extractValue
/**
* @param FieldType $fieldType Document field type.
* @param array $field Form field.
* @param array $request Request data.
* @return array|null
*/
protected static function extractValue(FieldType $fieldType, array $field, array $request)
{
$value = parent::extractValue($fieldType, $field, $request);
$result = null;
if (is_string($value) && strlen($value) > 0) {
$errors = array();
$result = \CBPHelper::usersStringToArray($value, $fieldType->getDocumentType(), $errors);
if (sizeof($errors) > 0) {
static::addErrors($errors);
}
}
return $result;
}