晋太元中,武陵人捕鱼为业。缘溪行,忘路之远近。忽逢桃花林,夹岸数百步,中无杂树,芳草鲜美,落英缤纷。渔人甚异之,复前行,欲穷其林。 林尽水源,便得一山,山有小口,仿佛若有光。便舍船,从口入。初极狭,才通人。复行数十步,豁然开朗。土地平旷,屋舍俨然,有良田、美池、桑竹之属。阡陌交通,鸡犬相闻。其中往来种作,男女衣着,悉如外人。黄发垂髫,并怡然自乐。 见渔人,乃大惊,问所从来。具答之。便要还家,设酒杀鸡作食。村中闻有此人,咸来问讯。自云先世避秦时乱,率妻子邑人来此绝境,不复出焉,遂与外人间隔。问今是何世,乃不知有汉,无论魏晋。此人一一为具言所闻,皆叹惋。余人各复延至其家,皆出酒食。停数日,辞去。此中人语云:“不足为外人道也。”(间隔 一作:隔绝) 既出,得其船,便扶向路,处处志之。及郡下,诣太守,说如此。太守即遣人随其往,寻向所志,遂迷,不复得路。 南阳刘子骥,高尚士也,闻之,欣然规往。未果,寻病终。后遂无问津者。
|
Server : Apache System : Linux srv.rainic.com 4.18.0-553.47.1.el8_10.x86_64 #1 SMP Wed Apr 2 05:45:37 EDT 2025 x86_64 User : rainic ( 1014) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/akaindir/public_html/crm/modules/Mobile/api/ws/ |
Upload File : |
<?php
/*+**********************************************************************************
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
* ("License"); You may not use this file except in compliance with the License
* The Original Code is: vtiger CRM Open Source
* The Initial Developer of the Original Code is vtiger.
* Portions created by vtiger are Copyright (C) vtiger.
* All Rights Reserved.
************************************************************************************/
include_once 'include/Webservices/Retrieve.php';
include_once dirname(__FILE__) . '/FetchRecord.php';
include_once 'include/Webservices/DescribeObject.php';
class Mobile_WS_FetchRecordWithGrouping extends Mobile_WS_FetchRecord {
private $_cachedDescribeInfo = false;
private $_cachedDescribeFieldInfo = false;
protected function cacheDescribeInfo($describeInfo) {
$this->_cachedDescribeInfo = $describeInfo;
$this->_cachedDescribeFieldInfo = array();
if(!empty($describeInfo['fields'])) {
foreach($describeInfo['fields'] as $describeFieldInfo) {
$this->_cachedDescribeFieldInfo[$describeFieldInfo['name']] = $describeFieldInfo;
}
}
}
protected function cachedDescribeInfo() {
return $this->_cachedDescribeInfo;
}
protected function cachedDescribeFieldInfo($fieldname) {
if ($this->_cachedDescribeFieldInfo !== false) {
if(isset($this->_cachedDescribeFieldInfo[$fieldname])) {
return $this->_cachedDescribeFieldInfo[$fieldname];
}
}
return false;
}
protected function cachedEntityFieldnames($module) {
$describeInfo = $this->cachedDescribeInfo();
$labelFields = $describeInfo['labelFields'];
switch($module) {
case 'HelpDesk': $labelFields = 'ticket_title'; break;
case 'Documents': $labelFields = 'notes_title'; break;
}
return explode(',', $labelFields);
}
protected function isTemplateRecordRequest(Mobile_API_Request $request) {
$recordid = $request->get('record');
return (preg_match("/([0-9]+)x0/", $recordid));
}
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) {
$response = parent::process($request);
return $this->processWithGrouping($request, $response);
}
protected function processWithGrouping(Mobile_API_Request $request, $response) {
$isTemplateRecord = $this->isTemplateRecordRequest($request);
$result = $response->getResult();
$resultRecord = $result['record'];
$module = $this->detectModuleName($resultRecord['id']);
$modifiedRecord = $this->transformRecordWithGrouping($resultRecord, $module, $isTemplateRecord);
$response->setResult(array('record' => $modifiedRecord));
return $response;
}
protected function transformRecordWithGrouping($resultRecord, $module, $isTemplateRecord=false) {
$current_user = $this->getActiveUser();
$moduleFieldGroups = Mobile_WS_Utils::gatherModuleFieldGroupInfo($module);
$modifiedResult = array();
$blocks = array(); $labelFields = false;
foreach($moduleFieldGroups as $blocklabel => $fieldgroups) {
$fields = array();
foreach($fieldgroups as $fieldname => $fieldinfo) {
// Pickup field if its part of the result
if(isset($resultRecord[$fieldname])) {
$field = array(
'name' => $fieldname,
'value' => $resultRecord[$fieldname],
'label' => $fieldinfo['label'],
'uitype'=> $fieldinfo['uitype']
);
// Template record requested send more details if available
if ($isTemplateRecord) {
$describeFieldInfo = $this->cachedDescribeFieldInfo($fieldname);
if ($describeFieldInfo) {
foreach($describeFieldInfo as $k=>$v) {
if (isset($field[$k])) continue;
$field[$k] = $v;
}
}
// Entity fieldnames
$labelFields = $this->cachedEntityFieldnames($module);
}
// Fix the assigned to uitype
if ($field['uitype'] == '53') {
$field['type']['defaultValue'] = array('value' => "19x{$current_user->id}", 'label' => $current_user->column_fields['last_name']);
} else if($field['uitype'] == '117') {
$field['type']['defaultValue'] = $field['value'];
}
// Special case handling to pull configured Terms & Conditions given through webservices.
else if($field['name'] == 'terms_conditions' && in_array($module, array('Quotes','Invoice', 'SalesOrder', 'PurchaseOrder'))){
$field['type']['defaultValue'] = $field['value'];
}
//Special case handling to set defaultValue for visibility field in calendar.
else if ($field['name'] == 'visibility' && in_array($module, array('Calendar','Events'))){
$field['type']['defaultValue'] = $field['value'];
} else if($field['type']['name'] != 'reference') {
$field['type']['defaultValue'] = $field['default'];
}
$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;
if (isset($resultRecord['LineItems'])) {
$modifiedResult['LineItems'] = $resultRecord['LineItems'];
}
return $modifiedResult;
}
}