晋太元中,武陵人捕鱼为业。缘溪行,忘路之远近。忽逢桃花林,夹岸数百步,中无杂树,芳草鲜美,落英缤纷。渔人甚异之,复前行,欲穷其林。 林尽水源,便得一山,山有小口,仿佛若有光。便舍船,从口入。初极狭,才通人。复行数十步,豁然开朗。土地平旷,屋舍俨然,有良田、美池、桑竹之属。阡陌交通,鸡犬相闻。其中往来种作,男女衣着,悉如外人。黄发垂髫,并怡然自乐。 见渔人,乃大惊,问所从来。具答之。便要还家,设酒杀鸡作食。村中闻有此人,咸来问讯。自云先世避秦时乱,率妻子邑人来此绝境,不复出焉,遂与外人间隔。问今是何世,乃不知有汉,无论魏晋。此人一一为具言所闻,皆叹惋。余人各复延至其家,皆出酒食。停数日,辞去。此中人语云:“不足为外人道也。”(间隔 一作:隔绝) 既出,得其船,便扶向路,处处志之。及郡下,诣太守,说如此。太守即遣人随其往,寻向所志,遂迷,不复得路。 南阳刘子骥,高尚士也,闻之,欣然规往。未果,寻病终。后遂无问津者。
|
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/include/Webservices/ |
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.
******************************************************************************/
require_once 'includes/runtime/Cache.php';
require_once 'vtlib/Vtiger/Runtime.php';
class WebserviceField{
private $fieldId;
private $uitype;
private $blockId;
private $blockName;
private $nullable;
private $default;
private $tableName;
private $columnName;
private $fieldName;
private $fieldLabel;
private $editable;
private $fieldType;
private $displayType;
private $mandatory;
private $massEditable;
private $tabid;
private $presence;
/**
*
* @var PearDatabase
*/
private $pearDB;
private $typeOfData;
private $fieldDataType;
private $dataFromMeta;
private static $tableMeta = array();
private static $fieldTypeMapping = array();
private $referenceList;
private $defaultValuePresent;
private $explicitDefaultValue;
private $genericUIType = 10;
private $readOnly = 0;
private $isunique = 0;
private function __construct($adb,$row){
$this->uitype = $row['uitype'];
$this->blockId = $row['block'];
$this->blockName = null;
$this->tableName = $row['tablename'];
$this->columnName = $row['columnname'];
$this->fieldName = $row['fieldname'];
$this->fieldLabel = $row['fieldlabel'];
$this->displayType = $row['displaytype'];
$this->massEditable = ($row['masseditable'] === '1')? true: false;
$this->presence = $row['presence'];
$this->isunique = ($row['isunique']) ? true : false;
$typeOfData = $row['typeofdata'];
$this->typeOfData = $typeOfData;
$typeOfData = explode("~",$typeOfData);
$this->mandatory = ($typeOfData[1] == 'M')? true: false;
if($this->uitype == 4){
$this->mandatory = false;
}
$this->fieldType = $typeOfData[0];
$this->tabid = $row['tabid'];
$this->fieldId = $row['fieldid'];
$this->pearDB = $adb;
$this->fieldDataType = null;
$this->dataFromMeta = false;
$this->defaultValuePresent = false;
$this->referenceList = null;
$this->explicitDefaultValue = false;
$this->readOnly = (isset($row['readonly']))? $row['readonly'] : 0;
if(array_key_exists('defaultvalue', $row)) {
$this->setDefault($row['defaultvalue']);
}
}
public static function fromQueryResult($adb,$result,$rowNumber){
return new WebserviceField($adb,$adb->query_result_rowdata($result,$rowNumber));
}
public static function fromArray($adb,$row){
return new WebserviceField($adb,$row);
}
public function getTableName(){
return $this->tableName;
}
public function getFieldName(){
return $this->fieldName;
}
public function getFieldLabelKey(){
return $this->fieldLabel;
}
public function getFieldType(){
return $this->fieldType;
}
public function isMandatory(){
return $this->mandatory;
}
public function getTypeOfData(){
return $this->typeOfData;
}
public function getDisplayType(){
return $this->displayType;
}
public function isUnique(){
return $this->isunique;
}
public function getMassEditable(){
return $this->massEditable;
}
public function getFieldId(){
return $this->fieldId;
}
public function getDefault(){
if($this->dataFromMeta !== true && $this->explicitDefaultValue !== true){
$this->fillColumnMeta();
}
return $this->default;
}
public function getColumnName(){
return $this->columnName;
}
public function getBlockId(){
return $this->blockId;
}
public function getBlockName(){
if(empty($this->blockName)) {
$this->blockName = getBlockName($this->blockId);
}
return $this->blockName;
}
public function getTabId(){
return $this->tabid;
}
public function isNullable(){
if($this->dataFromMeta !== true){
$this->fillColumnMeta();
}
return $this->nullable;
}
public function hasDefault(){
if($this->dataFromMeta !== true && $this->explicitDefaultValue !== true){
$this->fillColumnMeta();
}
return $this->defaultValuePresent;
}
public function getUIType(){
return $this->uitype;
}
public function isReadOnly() {
if($this->readOnly == 1) return true;
return false;
}
private function setNullable($nullable){
$this->nullable = $nullable;
}
public function setDefault($value){
$this->default = $value;
$this->explicitDefaultValue = true;
$this->defaultValuePresent = true;
}
public function setFieldDataType($dataType){
$this->fieldDataType = $dataType;
}
public function setReferenceList($referenceList){
$this->referenceList = $referenceList;
}
public function getTableFields(){
$tableFields = null;
if(isset(WebserviceField::$tableMeta[$this->getTableName()])){
$tableFields = WebserviceField::$tableMeta[$this->getTableName()];
}else{
$dbMetaColumns = $this->pearDB->database->MetaColumns($this->getTableName());
$tableFields = array();
foreach ($dbMetaColumns as $key => $dbField) {
$tableFields[$dbField->name] = $dbField;
}
WebserviceField::$tableMeta[$this->getTableName()] = $tableFields;
}
return $tableFields;
}
public function fillColumnMeta(){
$tableFields = $this->getTableFields();
foreach ($tableFields as $fieldName => $dbField) {
if(strcmp($fieldName,$this->getColumnName())===0){
$this->setNullable(!$dbField->not_null);
if($dbField->has_default === true && !$this->explicitDefaultValue){
$this->defaultValuePresent = $dbField->has_default;
$this->setDefault($dbField->default_value);
}
}
}
$this->dataFromMeta = true;
}
public function getFieldDataType(){
if($this->fieldDataType === null){
$fieldDataType = $this->getFieldTypeFromUIType();
if($fieldDataType === null){
$fieldDataType = $this->getFieldTypeFromTypeOfData();
}
if($fieldDataType == 'date' || $fieldDataType == 'datetime' || $fieldDataType == 'time') {
$tableFieldDataType = $this->getFieldTypeFromTable();
if($tableFieldDataType == 'datetime'){
$fieldDataType = $tableFieldDataType;
}
}
$this->fieldDataType = $fieldDataType;
}
return $this->fieldDataType;
}
public function getReferenceList($hideDisabledModules = true){
static $referenceList = array();
if($this->referenceList === null){
if(isset($referenceList[$this->getFieldId()])){
$this->referenceList = $referenceList[$this->getFieldId()];
return $referenceList[$this->getFieldId()];
}
if(!isset(WebserviceField::$fieldTypeMapping[$this->getUIType()])){
$this->getFieldTypeFromUIType();
}
$fieldTypeData = WebserviceField::$fieldTypeMapping[$this->getUIType()];
$referenceTypes = array();
if($this->getUIType() != $this->genericUIType){
$sql = "select type from vtiger_ws_referencetype where fieldtypeid=?";
$params = array($fieldTypeData['fieldtypeid']);
}else{
$sql = 'SELECT relmodule AS type FROM vtiger_fieldmodulerel WHERE fieldid=? ORDER BY sequence ASC';
$params = array($this->getFieldId());
}
$result = $this->pearDB->pquery($sql,$params);
$numRows = $this->pearDB->num_rows($result);
for($i=0;$i<$numRows;++$i){
array_push($referenceTypes,$this->pearDB->query_result($result,$i,"type"));
}
if($hideDisabledModules) {
global $current_user;
$types = vtws_listtypes(null, $current_user);
$accessibleTypes = $types['types'];
//If it is non admin user or the edit and view is there for profile then users module will be accessible
if(!is_admin($current_user)&& !in_array("Users",$accessibleTypes)) {
array_push($accessibleTypes, 'Users');
}
$referenceTypes = array_values(array_intersect($referenceTypes, $accessibleTypes));
}
$referenceList[$this->getFieldId()] = $referenceTypes;
$this->referenceList = $referenceTypes;
return $referenceTypes;
}
return $this->referenceList;
}
private function getFieldTypeFromTable(){
$tableFields = $this->getTableFields();
foreach ($tableFields as $fieldName => $dbField) {
if(strcmp($fieldName,$this->getColumnName())===0){
return $dbField->type;
}
}
//This should not be returned if entries in DB are correct.
return null;
}
private function getFieldTypeFromTypeOfData(){
switch($this->fieldType){
case 'T': return "time";
case 'D':
case 'DT': return "date";
case 'E': return "email";
case 'N':
case 'NN': return "double";
case 'P': return "password";
case 'I': return "integer";
case 'V':
default: return "string";
}
}
private function getFieldTypeFromUIType(){
// Cache all the information for futher re-use
if(empty(self::$fieldTypeMapping)) {
$result = $this->pearDB->pquery("select * from vtiger_ws_fieldtype", array());
while($resultrow = $this->pearDB->fetch_array($result)) {
self::$fieldTypeMapping[$resultrow['uitype']] = $resultrow;
}
}
if(isset(WebserviceField::$fieldTypeMapping[$this->getUIType()])){
if(WebserviceField::$fieldTypeMapping[$this->getUIType()] === false){
return null;
}
$row = WebserviceField::$fieldTypeMapping[$this->getUIType()];
return $row['fieldtype'];
} else {
WebserviceField::$fieldTypeMapping[$this->getUIType()] = false;
return null;
}
}
function getPicklistDetails(){
$cache = Vtiger_Cache::getInstance();
if($cache->getPicklistDetails($this->getTabId(),$this->getFieldName())){
return $cache->getPicklistDetails($this->getTabId(),$this->getFieldName());
} else {
//Inventory picklist values
if ($this->getDisplayType() == 5 && $this->getFieldName() === 'region_id') {
$picklistDetails = array();
$allRegions = getAllRegions();
foreach ($allRegions as $regionId => $regionDetails) {
$picklistDetails[] = array('value' => $regionId, 'label' => $regionDetails['name']);
}
} else {
$hardCodedPickListNames = array('hdntaxtype','email_flag');
$hardCodedPickListValues = array('hdntaxtype'=> array( array('label' => 'Individual', 'value' => 'individual'),
array('label' => 'Group', 'value' => 'group')),
'email_flag'=> array( array('label' => 'SAVED', 'value' => 'SAVED'),
array('label' => 'SENT', 'value' => 'SENT'),
array('label' => 'MAILSCANNER', 'value' => 'MAILSCANNER')));
if (in_array(strtolower($this->getFieldName()), $hardCodedPickListNames)) {
return $hardCodedPickListValues[strtolower($this->getFieldName())];
}
$picklistDetails = $this->getPickListOptions($this->getFieldName());
}
$cache->setPicklistDetails($this->getTabId(),$this->getFieldName(),$picklistDetails);
return $picklistDetails;
}
}
function getPickListOptions(){
$fieldName = $this->getFieldName();
$language = Vtiger_Language_Handler::getLanguage();
$default_charset = VTWS_PreserveGlobal::getGlobal('default_charset');
$options = array();
$sql = "select * from vtiger_picklist where name=?";
$result = $this->pearDB->pquery($sql,array($fieldName));
$numRows = $this->pearDB->num_rows($result);
$moduleName = getTabModuleName($this->getTabId());
if ($moduleName == 'Events') $moduleName = 'Calendar';
if($numRows == 0){
$sql = "select * from vtiger_$fieldName";
$result = $this->pearDB->pquery($sql,array());
$numRows = $this->pearDB->num_rows($result);
for($i=0;$i<$numRows;++$i){
$elem = array();
$picklistValue = $this->pearDB->query_result($result,$i,$fieldName);
$picklistValue = decode_html($picklistValue);
$elem["label"] = getTranslatedString($picklistValue, $moduleName, $language);
$elem["value"] = $picklistValue;
array_push($options,$elem);
}
}else{
$user = VTWS_PreserveGlobal::getGlobal('current_user');
$details = getPickListValues($fieldName,$user->roleid);
for($i=0;$i<sizeof($details);++$i){
$elem = array();
$picklistValue = decode_html($details[$i]);
$elem["label"] = getTranslatedString($picklistValue, $moduleName, $language);
$elem["value"] = $picklistValue;
array_push($options,$elem);
}
}
return $options;
}
function getPresence() {
return $this->presence;
}
}
?>