Merge remote branch 'upstream/master' into BUG-9630
This commit is contained in:
@@ -5169,7 +5169,7 @@ function getDirectorySize($path,$maxmtime=0)
|
|||||||
*
|
*
|
||||||
* @author Erik Amaru Ortiz <aortiz.erik@gmail.com>
|
* @author Erik Amaru Ortiz <aortiz.erik@gmail.com>
|
||||||
*/
|
*/
|
||||||
public function dispatchRestService($uri, $config = array())
|
public function dispatchRestService($uri, $config, $apiClassesPath = '')
|
||||||
{
|
{
|
||||||
require_once 'restler/restler.php';
|
require_once 'restler/restler.php';
|
||||||
|
|
||||||
@@ -5177,18 +5177,38 @@ function getDirectorySize($path,$maxmtime=0)
|
|||||||
$rest->setSupportedFormats('JsonFormat', 'XmlFormat');
|
$rest->setSupportedFormats('JsonFormat', 'XmlFormat');
|
||||||
|
|
||||||
// getting all services class
|
// getting all services class
|
||||||
$srvClasses = glob(PATH_SERVICES_REST . '*.php');
|
$restClasses = array();
|
||||||
$crudClasses = glob(PATH_SERVICES_REST . 'crud/*.php');
|
$restClassesList = G::rglob('*', 0, PATH_CORE . 'services/');
|
||||||
$srvClasses = array_merge($srvClasses, $crudClasses);
|
foreach ($restClassesList as $classFile) {
|
||||||
|
if (substr($classFile, -4) === '.php') {
|
||||||
// hook to get rest api classes from plugins
|
$restClasses[str_replace('.php', '', basename($classFile))] = $classFile;
|
||||||
if ( class_exists( 'PMPluginRegistry' ) ) {
|
}
|
||||||
$pluginRegistry = & PMPluginRegistry::getSingleton();
|
|
||||||
$pluginClasses = $pluginRegistry->getRegisteredRestClassFiles();
|
|
||||||
$srvClasses = array_merge($srvClasses, $pluginClasses);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($srvClasses as $classFile) {
|
if (! empty($apiClassesPath)) {
|
||||||
|
$pluginRestClasses = array();
|
||||||
|
$restClassesList = G::rglob('*', 0, $apiClassesPath . 'services/');
|
||||||
|
foreach ($restClassesList as $classFile) {
|
||||||
|
if (substr($classFile, -4) === '.php') {
|
||||||
|
$pluginRestClasses[str_replace('.php', '', basename($classFile))] = $classFile;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$restClasses = array_merge($restClasses, $pluginRestClasses);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// hook to get rest api classes from plugins
|
||||||
|
if (class_exists('PMPluginRegistry')) {
|
||||||
|
$pluginRegistry = & PMPluginRegistry::getSingleton();
|
||||||
|
$pluginClasses = $pluginRegistry->getRegisteredRestClassFiles();
|
||||||
|
$restClasses = array_merge($restClasses, $pluginClasses);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($restClasses as $classFile) {
|
||||||
|
if (! file_exists($classFile)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
require_once $classFile;
|
require_once $classFile;
|
||||||
$namespace = 'Services_Rest_';
|
$namespace = 'Services_Rest_';
|
||||||
$className = str_replace('.php', '', basename($classFile));
|
$className = str_replace('.php', '', basename($classFile));
|
||||||
|
|||||||
@@ -193,39 +193,39 @@ class Main extends Controller
|
|||||||
$availableLangArray = $this->getLanguagesList();
|
$availableLangArray = $this->getLanguagesList();
|
||||||
|
|
||||||
G::LoadClass ('serverConfiguration');
|
G::LoadClass ('serverConfiguration');
|
||||||
|
if (($nextBeatDate = $this->memcache->get('nextBeatDate')) === false) {
|
||||||
|
//get the serverconf singleton, and check if we can send the heartbeat
|
||||||
|
$oServerConf = & serverConf::getSingleton ();
|
||||||
|
$sflag = $oServerConf->getHeartbeatProperty('HB_OPTION','HEART_BEAT_CONF');
|
||||||
|
$sflag = (trim($sflag)!='')? $sflag : '1';
|
||||||
|
//get date of next beat
|
||||||
|
$nextBeatDate = $oServerConf->getHeartbeatProperty('HB_NEXT_BEAT_DATE','HEART_BEAT_CONF');
|
||||||
|
$this->memcache->set('nextBeatDate', $nextBeatDate, 1*3600);
|
||||||
|
}
|
||||||
|
|
||||||
$oServerConf = & serverConf::getSingleton ();
|
if (($sflag == 1) && ((strtotime("now") > $nextBeatDate) || is_null($nextBeatDate))) {
|
||||||
$sflag = $oServerConf->getHeartbeatProperty('HB_OPTION', 'HEART_BEAT_CONF');
|
|
||||||
$sflag = (trim($sflag) != '') ? $sflag : '1';
|
|
||||||
|
|
||||||
//get date of next beat
|
|
||||||
$nextBeatDate = $oServerConf->getHeartbeatProperty('HB_NEXT_BEAT_DATE', 'HEART_BEAT_CONF');
|
|
||||||
|
|
||||||
//if flag to send heartbeat is enabled, and it is time to send heartbeat, sent it using asynchronous beat.
|
|
||||||
if (($sflag == "1") && ((strtotime("now") > $nextBeatDate) || is_null($nextBeatDate))) {
|
|
||||||
//To do: we need to change to ExtJs
|
//To do: we need to change to ExtJs
|
||||||
$this->setJSVar('flagHeartBeat', 1);
|
$this->setJSVar('flagHeartBeat', 1);
|
||||||
} else {
|
} else {
|
||||||
$this->setJSVar('flagHeartBeat', 0);
|
$this->setJSVar('flagHeartBeat', 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
//check if we show the panel with the getting started info
|
if (($flagGettingStarted = $this->memcache->get('flagGettingStarted')) === false) {
|
||||||
require_once 'classes/model/Configuration.php';
|
require_once 'classes/model/Configuration.php';
|
||||||
$oConfiguration = new Configuration ();
|
$oConfiguration = new Configuration ();
|
||||||
$oCriteria = new Criteria ('workflow');
|
$oCriteria = new Criteria ('workflow');
|
||||||
$oCriteria->add (ConfigurationPeer::CFG_UID, 'getStarted');
|
$oCriteria->add (ConfigurationPeer::CFG_UID, 'getStarted');
|
||||||
$oCriteria->add (ConfigurationPeer::OBJ_UID, '');
|
$oCriteria->add (ConfigurationPeer::OBJ_UID, '');
|
||||||
$oCriteria->add (ConfigurationPeer::CFG_VALUE, '1');
|
$oCriteria->add (ConfigurationPeer::CFG_VALUE, '1');
|
||||||
$oCriteria->add (ConfigurationPeer::PRO_UID, '');
|
$oCriteria->add (ConfigurationPeer::PRO_UID, '');
|
||||||
$oCriteria->add (ConfigurationPeer::USR_UID, '');
|
$oCriteria->add (ConfigurationPeer::USR_UID, '');
|
||||||
$oCriteria->add (ConfigurationPeer::APP_UID, '');
|
$oCriteria->add (ConfigurationPeer::APP_UID, '');
|
||||||
$flagGettingStarted = ConfigurationPeer::doCount ($oCriteria);
|
$flagGettingStarted = ConfigurationPeer::doCount ($oCriteria);
|
||||||
if ($flagGettingStarted == 0) {
|
$this->memcache->set('flagGettingStarted', $flagGettingStarted, 8*3600) ;
|
||||||
$this->setJSVar('flagGettingStarted', 1);
|
|
||||||
} else {
|
|
||||||
$this->setJSVar('flagGettingStarted', 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->setJSVar('flagGettingStarted', ($flagGettingStarted == 0));
|
||||||
|
|
||||||
G::loadClass('configuration');
|
G::loadClass('configuration');
|
||||||
$oConf = new Configurations;
|
$oConf = new Configurations;
|
||||||
$oConf->loadConfig($obj, 'ENVIRONMENT_SETTINGS','');
|
$oConf->loadConfig($obj, 'ENVIRONMENT_SETTINGS','');
|
||||||
|
|||||||
@@ -2,23 +2,7 @@
|
|||||||
|
|
||||||
class Services_Rest_Case
|
class Services_Rest_Case
|
||||||
{
|
{
|
||||||
public function get()
|
protected function get($id = '', $start=null, $limit=null, $type=null, $filter=null, $search=null, $process=null, $user=null, $status=null, $typeResource=null, $dateFrom=null, $dateTo=null)
|
||||||
{
|
|
||||||
echo 'hello world';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function options22()
|
|
||||||
{
|
|
||||||
echo 'opts';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function post()
|
|
||||||
{
|
|
||||||
header('Content-Type: application/json');
|
|
||||||
echo '{"response": "hello post"}';
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function get11($id = '', $start=null, $limit=null, $type=null, $filter=null, $search=null, $process=null, $user=null, $status=null, $typeResource=null, $dateFrom=null, $dateTo=null)
|
|
||||||
{
|
{
|
||||||
if (empty($id)) {
|
if (empty($id)) {
|
||||||
// getting all records.
|
// getting all records.
|
||||||
|
|||||||
@@ -428,14 +428,15 @@
|
|||||||
// disable until confirm that rest is enabled & configured on rest-config.ini file
|
// disable until confirm that rest is enabled & configured on rest-config.ini file
|
||||||
$isRestRequest = false;
|
$isRestRequest = false;
|
||||||
$confFile = '';
|
$confFile = '';
|
||||||
|
$restApiClassPath = '';
|
||||||
|
|
||||||
// try load and getting rest configuration
|
// try load and getting rest configuration
|
||||||
if (file_exists(PATH_DATA_SITE . 'rest-config.ini')) {
|
if (file_exists(PATH_DATA_SITE . 'rest-config.ini')) {
|
||||||
$confFile = PATH_DATA_SITE . 'rest-config.ini';
|
$confFile = PATH_DATA_SITE . 'rest-config.ini';
|
||||||
|
$restApiClassPath = PATH_DATA_SITE;
|
||||||
} elseif (file_exists(PATH_CONFIG . 'rest-config.ini')) {
|
} elseif (file_exists(PATH_CONFIG . 'rest-config.ini')) {
|
||||||
$confFile = PATH_CONFIG . 'rest-config.ini';
|
$confFile = PATH_CONFIG . 'rest-config.ini';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! empty($confFile) && $restConfig = @parse_ini_file($confFile, true)) {
|
if (! empty($confFile) && $restConfig = @parse_ini_file($confFile, true)) {
|
||||||
if (array_key_exists('enable_service', $restConfig)) {
|
if (array_key_exists('enable_service', $restConfig)) {
|
||||||
if ($restConfig['enable_service'] == 'true' || $restConfig['enable_service'] == '1') {
|
if ($restConfig['enable_service'] == 'true' || $restConfig['enable_service'] == '1') {
|
||||||
@@ -725,7 +726,7 @@
|
|||||||
$controller->setHttpRequestData($_REQUEST);
|
$controller->setHttpRequestData($_REQUEST);
|
||||||
$controller->call($controllerAction);
|
$controller->call($controllerAction);
|
||||||
} elseif ($isRestRequest) {
|
} elseif ($isRestRequest) {
|
||||||
G::dispatchRestService(SYS_TARGET, $restConfig);
|
G::dispatchRestService(SYS_TARGET, $restConfig, $restApiClassPath);
|
||||||
} else {
|
} else {
|
||||||
require_once $phpFile;
|
require_once $phpFile;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user