function webforms_getUserData($ownerId, $describeFields, $source) { $userData = array(); for ($i = 0; $i < sizeof($describeFields); ++$i) { $fieldName = $describeFields[$i]['name']; if (isset($source[$fieldName]) || $describeFields[$i]['type']['name'] == 'owner') { /*if($describeFields[$i]['type']['name'] == 'reference'){ }*/ if ($describeFields[$i]['type']['name'] == 'owner') { $userData[$fieldName] = $ownerId; } else { $value = vtws_getParameter($source, $fieldName); if ($value !== null) { $userData[$fieldName] = $value; } } } else { if ($describeFields[$i]['mandatory'] == true) { return null; } } } return $userData; }
function webforms_getUserData($ownerId, $describeFields, $source) { $userData = array(); $len = sizeof($describeFields); for ($i = 0; $i < $len; ++$i) { $fieldName = $describeFields[$i]['name']; // Handle meta fields right away if ($describeFields[$i]['type']['name'] == 'owner') { $userData[$fieldName] = $ownerId; continue; } /* TODO: if($describeFields[$i]['type']['name'] == 'reference'){ continue; }*/ /** * Support for specifying (fieldname or label:fieldlabel) */ // NOTE: Spaces in parameter key will be converted to _ $transformedFieldLabel = str_replace(' ', '_', $describeFields[$i]['label']); $valuekey = false; if (isset($source[$fieldName])) { $valuekey = $fieldName; } else { if (isset($source["label:{$transformedFieldLabel}"])) { $valuekey = "label:{$transformedFieldLabel}"; } } if ($valuekey) { $value = vtws_getParameter($source, $valuekey); if ($value !== null) { $userData[$fieldName] = $value; } } else { if ($describeFields[$i]['mandatory'] == true) { return null; } } } return $userData; }
$sessionManager = new SessionManager(); $operationManager = new OperationManager($adb, $operation, $format, $sessionManager); try { if (!$sessionId || strcasecmp($sessionId, "null") === 0) { $sessionId = null; } $input = $operationManager->getOperationInput(); $adoptSession = false; if (strcasecmp($operation, "extendsession") === 0) { if (isset($input['operation'])) { // Workaround fix for PHP 5.3.x: $_REQUEST doesn't have PHPSESSID if (isset($_REQUEST['PHPSESSID'])) { $sessionId = vtws_getParameter($_REQUEST, "PHPSESSID"); } else { // NOTE: Need to evaluate for possible security issues $sessionId = vtws_getParameter($_COOKIE, 'PHPSESSID'); } // END $adoptSession = true; } else { writeErrorOutput($operationManager, new WebServiceException(WebServiceErrorCode::$AUTHREQUIRED, "Authentication required")); return; } } $sid = $sessionManager->startSession($sessionId, $adoptSession); if (!$sessionId && !$operationManager->isPreLoginOperation()) { writeErrorOutput($operationManager, new WebServiceException(WebServiceErrorCode::$AUTHREQUIRED, "Authentication required")); return; } if (!$sid) { writeErrorOutput($operationManager, $sessionManager->getError());
function sanitizeInputForType($input) { $sanitizedInput = array(); foreach ($this->operationParams as $ind => $columnDetails) { foreach ($columnDetails as $columnName => $type) { $sanitizedInput[$columnName] = $this->handleType($type, vtws_getParameter($input, $columnName)); } } return $sanitizedInput; }
} $operation = vtws_getParameter($_REQUEST, "operation"); $operation = strtolower($operation); $format = vtws_getParameter($_REQUEST, "format", "json"); $sessionId = vtws_getParameter($_REQUEST, "sessionName"); $sessionManager = new SessionManager(); $operationManager = new OperationManager($adb, $operation, $format, $sessionManager); try { if (!$sessionId || strcasecmp($sessionId, "null") === 0) { $sessionId = null; } $input = $operationManager->getOperationInput(); $adoptSession = false; if (strcasecmp($operation, "extendsession") === 0) { if (isset($input['operation'])) { $sessionId = vtws_getParameter($_REQUEST, "PHPSESSID"); $adoptSession = true; } else { writeErrorOutput($operationManager, new WebServiceException(WebServiceErrorCode::$AUTHREQUIRED, "Authencation required")); return; } } $sid = $sessionManager->startSession($sessionId, $adoptSession); if (!$sessionId && !$operationManager->isPreLoginOperation()) { writeErrorOutput($operationManager, new WebServiceException(WebServiceErrorCode::$AUTHREQUIRED, "Authencation required")); return; } if (!$sid) { writeErrorOutput($operationManager, $sessionManager->getError()); return; }