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>
|
||||
*/
|
||||
public function dispatchRestService($uri, $config = array())
|
||||
public function dispatchRestService($uri, $config, $apiClassesPath = '')
|
||||
{
|
||||
require_once 'restler/restler.php';
|
||||
|
||||
@@ -5177,18 +5177,38 @@ function getDirectorySize($path,$maxmtime=0)
|
||||
$rest->setSupportedFormats('JsonFormat', 'XmlFormat');
|
||||
|
||||
// getting all services class
|
||||
$srvClasses = glob(PATH_SERVICES_REST . '*.php');
|
||||
$crudClasses = glob(PATH_SERVICES_REST . 'crud/*.php');
|
||||
$srvClasses = array_merge($srvClasses, $crudClasses);
|
||||
$restClasses = array();
|
||||
$restClassesList = G::rglob('*', 0, PATH_CORE . 'services/');
|
||||
foreach ($restClassesList as $classFile) {
|
||||
if (substr($classFile, -4) === '.php') {
|
||||
$restClasses[str_replace('.php', '', basename($classFile))] = $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();
|
||||
$srvClasses = array_merge($srvClasses, $pluginClasses);
|
||||
$restClasses = array_merge($restClasses, $pluginClasses);
|
||||
}
|
||||
|
||||
foreach ($restClasses as $classFile) {
|
||||
if (! file_exists($classFile)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach ($srvClasses as $classFile) {
|
||||
require_once $classFile;
|
||||
$namespace = 'Services_Rest_';
|
||||
$className = str_replace('.php', '', basename($classFile));
|
||||
|
||||
@@ -193,23 +193,24 @@ class Main extends Controller
|
||||
$availableLangArray = $this->getLanguagesList();
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
//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))) {
|
||||
if (($sflag == 1) && ((strtotime("now") > $nextBeatDate) || is_null($nextBeatDate))) {
|
||||
//To do: we need to change to ExtJs
|
||||
$this->setJSVar('flagHeartBeat', 1);
|
||||
} else {
|
||||
$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';
|
||||
$oConfiguration = new Configuration ();
|
||||
$oCriteria = new Criteria ('workflow');
|
||||
@@ -220,12 +221,11 @@ class Main extends Controller
|
||||
$oCriteria->add (ConfigurationPeer::USR_UID, '');
|
||||
$oCriteria->add (ConfigurationPeer::APP_UID, '');
|
||||
$flagGettingStarted = ConfigurationPeer::doCount ($oCriteria);
|
||||
if ($flagGettingStarted == 0) {
|
||||
$this->setJSVar('flagGettingStarted', 1);
|
||||
} else {
|
||||
$this->setJSVar('flagGettingStarted', 0);
|
||||
$this->memcache->set('flagGettingStarted', $flagGettingStarted, 8*3600) ;
|
||||
}
|
||||
|
||||
$this->setJSVar('flagGettingStarted', ($flagGettingStarted == 0));
|
||||
|
||||
G::loadClass('configuration');
|
||||
$oConf = new Configurations;
|
||||
$oConf->loadConfig($obj, 'ENVIRONMENT_SETTINGS','');
|
||||
|
||||
@@ -2,23 +2,7 @@
|
||||
|
||||
class Services_Rest_Case
|
||||
{
|
||||
public function get()
|
||||
{
|
||||
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)
|
||||
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)
|
||||
{
|
||||
if (empty($id)) {
|
||||
// getting all records.
|
||||
|
||||
@@ -428,14 +428,15 @@
|
||||
// disable until confirm that rest is enabled & configured on rest-config.ini file
|
||||
$isRestRequest = false;
|
||||
$confFile = '';
|
||||
$restApiClassPath = '';
|
||||
|
||||
// try load and getting rest configuration
|
||||
if (file_exists(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')) {
|
||||
$confFile = PATH_CONFIG . 'rest-config.ini';
|
||||
}
|
||||
|
||||
if (! empty($confFile) && $restConfig = @parse_ini_file($confFile, true)) {
|
||||
if (array_key_exists('enable_service', $restConfig)) {
|
||||
if ($restConfig['enable_service'] == 'true' || $restConfig['enable_service'] == '1') {
|
||||
@@ -725,7 +726,7 @@
|
||||
$controller->setHttpRequestData($_REQUEST);
|
||||
$controller->call($controllerAction);
|
||||
} elseif ($isRestRequest) {
|
||||
G::dispatchRestService(SYS_TARGET, $restConfig);
|
||||
G::dispatchRestService(SYS_TARGET, $restConfig, $restApiClassPath);
|
||||
} else {
|
||||
require_once $phpFile;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user