diff --git a/core/src/Metadata/Admin/Api/MetadataAdminManager.php b/core/src/Metadata/Admin/Api/MetadataAdminManager.php index 1cb98444..816ad2be 100644 --- a/core/src/Metadata/Admin/Api/MetadataAdminManager.php +++ b/core/src/Metadata/Admin/Api/MetadataAdminManager.php @@ -50,5 +50,10 @@ class MetadataAdminManager extends AbstractModuleManager $restEndPoint = new MetadataRestEndPoint(); $restEndPoint->process('getCountries', []); }); + + \Classes\Macaw::get(REST_API_PATH.'meta/mobile-modules', function () { + $restEndPoint = new MetadataRestEndPoint(); + $restEndPoint->process('getMobileModules', []); + }); } } diff --git a/core/src/Metadata/Rest/MetadataRestEndPoint.php b/core/src/Metadata/Rest/MetadataRestEndPoint.php index 5e238eff..b7a96321 100644 --- a/core/src/Metadata/Rest/MetadataRestEndPoint.php +++ b/core/src/Metadata/Rest/MetadataRestEndPoint.php @@ -2,7 +2,9 @@ namespace Metadata\Rest; use Classes\Data\Query\DataQuery; +use Classes\IceResponse; use Classes\RestEndPoint; +use Modules\Common\Model\Module; use Users\Common\Model\User; class MetadataRestEndPoint extends RestEndPoint @@ -20,4 +22,28 @@ class MetadataRestEndPoint extends RestEndPoint $query->setLength(500); return $this->listByQuery($query); } + + public function getMobileModules(User $user) + { + $mobileModules = [ + 'leaves' => false, + 'attendance' => false, + 'staffdirectory' => false, + 'expenses' => false, + ]; + + foreach ($mobileModules as $key => $value) { + $mobileModules[$key] = $this->isUserModuleEnabled($key); + } + + return new IceResponse(IceResponse::SUCCESS, ['data' => $mobileModules]); + } + + private function isUserModuleEnabled($name) + { + $module = new Module(); + $modules = $module->Find('name = ? and mod_group = ? and status = ?', [$name, 'user', 'Enabled']); + + return count($modules) > 0; + } }