protected function processRetrieve(Mobile_API_Request $request) { $recordid = $request->get('record'); // Create a template record for use if ($this->isTemplateRecordRequest($request)) { $current_user = $this->getActiveUser(); $module = $this->detectModuleName($recordid); $describeInfo = vtws_describe($module, $current_user); Mobile_WS_Utils::fixDescribeFieldInfo($module, $describeInfo); $this->cacheDescribeInfo($describeInfo); $templateRecord = array(); foreach ($describeInfo['fields'] as $describeField) { $templateFieldValue = ''; if (isset($describeField['type']) && isset($describeField['type']['defaultValue'])) { $templateFieldValue = $describeField['type']['defaultValue']; } else { if (isset($describeField['default'])) { $templateFieldValue = $describeField['default']; } } $templateRecord[$describeField['name']] = $templateFieldValue; } if (isset($templateRecord['assigned_user_id'])) { $templateRecord['assigned_user_id'] = sprintf("%sx%s", Mobile_WS_Utils::getEntityModuleWSId('Users'), $current_user->id); } // Reset the record id $templateRecord['id'] = $recordid; return $templateRecord; } // Or else delgate the action to parent return parent::processRetrieve($request); }
function process(Mobile_API_Request $request) { $current_user = $this->getActiveUser(); $module = $request->get('module'); $describeInfo = vtws_describe($module, $current_user); Mobile_WS_Utils::fixDescribeFieldInfo($module, $describeInfo); $response = new Mobile_API_Response(); $response->setResult(array('describe' => $describeInfo)); return $response; }
protected function transformToBlocks($module) { $current_user = $this->getActiveUser(); $moduleFieldGroups = Mobile_WS_Utils::gatherModuleFieldGroupInfo($module); $describeInfo = vtws_describe($module, $current_user); Mobile_WS_Utils::fixDescribeFieldInfo($module, $describeInfo, $current_user); $modifiedResult = array(); $blocks = array(); $labelFields = false; foreach ($moduleFieldGroups as $blocklabel => $fieldgroups) { $fields = array(); foreach ($fieldgroups as $fieldname => $fieldinfo) { $field['name'] = $fieldname; $field['value'] = ''; $field['label'] = $fieldinfo['label']; $field['uitype'] = $fieldinfo['uitype']; $field['typeofdata'] = $fieldinfo['typeofdata']; foreach ($describeInfo['fields'] as $describeField) { if ($describeField['name'] == $fieldname) { $field['type'] = ''; if (isset($describeField['type']) && $describeField['type'] != '') { $picklistValues = $describeField['type']['picklistValues']; $field['type']['value'] = array('value' => $picklistValues, 'name' => $fieldname); } } } if ($field['uitype'] == '51' || $field['uitype'] == '59' || $field['uitype'] == '10') { $field['relatedmodule'] = Mobile_WS_Utils::getEntityName($field['name'], $module); } $fields[] = $field; } $blocks[] = array('label' => $blocklabel, 'fields' => $fields); } $sections = array(); $moduleFieldGroupKeys = array_keys($moduleFieldGroups); foreach ($moduleFieldGroupKeys as $blocklabel) { // eliminate empty blocks if (isset($groups[$blocklabel]) && !empty($groups[$blocklabel])) { $sections[] = array('label' => $blocklabel, 'count' => count($groups[$blocklabel])); } } $modifiedResult = array('blocks' => $blocks, 'id' => $resultRecord['id']); if ($labelFields) { $modifiedResult['labelFields'] = $labelFields; } return $modifiedResult; }