diff options
author | Christian Klinger | 2016-08-02 15:56:58 +0200 |
---|---|---|
committer | Christian Klinger | 2016-08-02 15:56:58 +0200 |
commit | 9d9dbd8ce908a3c24ae45ee3990dc260a57efb70 (patch) | |
tree | a0569ead72cb6ad67c575f29ed7595c64d4ec5c1 /modules-available/dozmod | |
parent | mail template editor. (diff) | |
parent | [statistics] Fix class name typo (diff) | |
download | slx-admin-9d9dbd8ce908a3c24ae45ee3990dc260a57efb70.tar.gz slx-admin-9d9dbd8ce908a3c24ae45ee3990dc260a57efb70.tar.xz slx-admin-9d9dbd8ce908a3c24ae45ee3990dc260a57efb70.zip |
Merge branch 'modularization' of git.openslx.org:openslx-ng/slx-admin into modularization
Diffstat (limited to 'modules-available/dozmod')
-rw-r--r-- | modules-available/dozmod/api.inc.php | 51 |
1 files changed, 48 insertions, 3 deletions
diff --git a/modules-available/dozmod/api.inc.php b/modules-available/dozmod/api.inc.php index 17ead3c1..dc9788fc 100644 --- a/modules-available/dozmod/api.inc.php +++ b/modules-available/dozmod/api.inc.php @@ -17,7 +17,7 @@ if (!Module::isAvailable('locations')) { define('LIST_URL', CONFIG_DOZMOD_URL . '/vmchooser/list'); define('VMX_URL', CONFIG_DOZMOD_URL . '/vmchooser/lecture'); -$availableRessources = ['list', 'vmx', 'test', 'netrules']; +$availableRessources = ['list', 'vmx', 'test', 'netrules', 'runscript']; /* BEGIN: A simple caching mechanism ---------------------------- */ @@ -148,9 +148,12 @@ function outputLectureXmlForLocation($locationIds) return getListForLocations($locationIds, true); } -function _getVMX($lecture_uuid) +function _getVmData($lecture_uuid, $subResource = false) { $url = VMX_URL . '/' . $lecture_uuid; + if ($subResource !== false) { + $url .= '/' . $subResource; + } $response = Download::asString($url, 60, $code); return $response; } @@ -162,7 +165,35 @@ function outputVMX($lecture_uuid) if (cache_has($key)) { cache_get_passthru($key); } else { - $value = _getVMX($lecture_uuid); + $value = _getVmData($lecture_uuid); + if ($value === false) + return false; + cache_put($key, $value); + die($value); + } +} + +function outputNetrules($lecture_uuid) +{ + $key = 'netrules_' . $lecture_uuid; + if (cache_has($key)) { + cache_get_passthru($key); + } else { + $value = _getVmData($lecture_uuid, 'netrules'); + if ($value === false) + return false; + cache_put($key, $value); + die($value); + } +} + +function outputRunscript($lecture_uuid) +{ + $key = 'netrules_' . $lecture_uuid; + if (cache_has($key)) { + cache_get_passthru($key); + } else { + $value = _getVmData($lecture_uuid, 'runscript'); if ($value === false) return false; cache_put($key, $value); @@ -226,6 +257,20 @@ if ($resource === 'vmx') { fatalDozmodUnreachable(); } +if ($resource === 'netrules') { + $lecture = readLectureParam(); + outputNetrules($lecture); + // no return on success + fatalDozmodUnreachable(); +} + +if ($resource === 'runscript') { + $lecture = readLectureParam(); + outputRunscript($lecture); + // no return on success + fatalDozmodUnreachable(); +} + if ($resource === 'list') { outputLectureXmlForLocation($location_ids); // Won't return on success... |