diff --git a/app/Controller/EventsController.php b/app/Controller/EventsController.php index 16a6dcb14..cc8fb1d8d 100644 --- a/app/Controller/EventsController.php +++ b/app/Controller/EventsController.php @@ -3723,7 +3723,7 @@ class EventsController extends AppController { public function importModule($module, $eventId) { $this->loadModel('Module'); - $module = $this->Module->getEnabledModule($module, 'import'); + $module = $this->Module->getEnabledModule($module, 'Import'); if (!is_array($module)) throw new MethodNotAllowedException($module); if (!isset($module['mispattributes']['inputSource'])) $module['mispattributes']['inputSource'] = array('paste'); if ($this->request->is('post')) { @@ -3764,7 +3764,7 @@ class EventsController extends AppController { } if (!$fail) { $modulePayload['data'] = base64_encode($modulePayload['data']); - $result = $this->Module->queryModuleServer('/query', json_encode($modulePayload, true), false, $moduleFamily = 'import'); + $result = $this->Module->queryModuleServer('/query', json_encode($modulePayload, true), false, $moduleFamily = 'Import'); if (!$result) throw new Exception('Import service not reachable.'); if (isset($result['error'])) $this->Session->setFlash($result['error']); if (!is_array($result)) throw new Exception($result); diff --git a/app/Model/Module.php b/app/Model/Module.php index 7db57515e..f0de462cf 100644 --- a/app/Model/Module.php +++ b/app/Model/Module.php @@ -6,13 +6,13 @@ class Module extends AppModel { private $__validTypes = array( 'Enrichment' => array('hover', 'expansion'), - 'import' => array('import'), - 'Export' => array('export') + 'Import' => array('Import'), + 'Export' => array('Export') ); private $__typeToFamily = array( - 'import' => 'import', - 'export' => 'export', + 'Import' => 'Import', + 'Export' => 'Export', 'hover' => 'Enrichment', 'expansion' => 'Enrichment' ); @@ -82,7 +82,7 @@ class Module extends AppModel { $modules = $this->getModules($type, $moduleFamily); if (is_array($modules)) { foreach ($modules['modules'] as $k => &$module) { - if (!Configure::read('Plugin.' . $moduleFamily . '_' . $module['name'] . '_enabled') || ($type && in_array($type, $module['meta']['module-type']))) { + if (!Configure::read('Plugin.' . $moduleFamily . '_' . $module['name'] . '_enabled') || ($type && in_array(strtolower($type), $module['meta']['module-type']))) { unset($modules['modules'][$k]); } } @@ -91,8 +91,8 @@ class Module extends AppModel { if (isset($modules['modules']) && !empty($modules['modules'])) $modules['modules'] = array_values($modules['modules']); if (!is_array($modules)) return array(); foreach ($modules['modules'] as $temp) { - if (isset($temp['meta']['module-type']) && in_array('import', $temp['meta']['module-type'])) $modules['import'] = $temp['name']; - else if (isset($temp['meta']['module-type']) && in_array('export', $temp['meta']['module-type'])) $modules['export'] = $temp['name']; + if (isset($temp['meta']['module-type']) && in_array('Import', $temp['meta']['module-type'])) $modules['Import'] = $temp['name']; + else if (isset($temp['meta']['module-type']) && in_array('Export', $temp['meta']['module-type'])) $modules['Export'] = $temp['name']; else { foreach ($temp['mispattributes']['input'] as $input) { if (!isset($temp['meta']['module-type']) || in_array('expansion', $temp['meta']['module-type'])) $modules['types'][$input][] = $temp['name']; @@ -104,15 +104,15 @@ class Module extends AppModel { } public function getEnabledModule($name, $type) { - $moduleFamily = $this->__typeToFamily[$type]; + $moduleFamily = $this->__typeToFamily[$type]; $url = $this->__getModuleServer($moduleFamily); - $modules = $this->getModules($type); + $modules = $this->getModules($type, $moduleFamily); $module = false; if (!Configure::read('Plugin.' . $moduleFamily . '_' . $name . '_enabled')) return 'The requested module is not enabled.'; if (is_array($modules)) { foreach ($modules['modules'] as $k => &$module) { if ($module['name'] == $name) { - if ($type && in_array($type, $module['meta']['module-type'])) { + if ($type && in_array(strtolower($type), $module['meta']['module-type'])) { return $module; } else { return 'The requested module is not available for the requested action.'; @@ -124,8 +124,8 @@ class Module extends AppModel { } private function __getModuleServer($moduleFamily = 'Enrichment') { - $this->Server = ClassRegistry::init('Server'); if (!Configure::read('Plugin.' . $moduleFamily . '_services_enable')) return false; + $this->Server = ClassRegistry::init('Server'); $url = Configure::read('Plugin.' . $moduleFamily . '_services_url') ? Configure::read('Plugin.' . $moduleFamily . '_services_url') : $this->Server->serverSettings['Plugin'][$moduleFamily . '_services_url']['value']; $port = Configure::read('Plugin.' . $moduleFamily . '_services_port') ? Configure::read('Plugin.' . $moduleFamily . '_services_port') : $this->Server->serverSettings['Plugin'][$moduleFamily . '_services_port']['value']; return $url . ':' . $port; diff --git a/app/Model/Server.php b/app/Model/Server.php index d861a147b..4262d395f 100644 --- a/app/Model/Server.php +++ b/app/Model/Server.php @@ -1821,7 +1821,7 @@ class Server extends AppModel { public function getCurrentServerSettings() { $this->Module = ClassRegistry::init('Module'); $serverSettings = $this->serverSettings; - $moduleTypes = array('Enrichment', 'import', 'export'); + $moduleTypes = array('Enrichment', 'Import', 'Export'); foreach ($moduleTypes as $moduleType) { if (Configure::read('Plugin.' . $moduleType . '_services_enable')) { $results = $this->Module->getModuleSettings($moduleType);