66,23 → 66,27 |
* @throws OIDplusException |
*/ |
public function gui(string $id, array &$out, bool &$handled) { |
$tmp = explode('$',$id); |
$classname = $tmp[1] ?? ''; |
$parts = explode('$',$id,3); |
$ra_email = $parts[1] ?? ''; |
$subpage = $parts[2] ?? ''; |
|
$parts = explode('.',$tmp[0],2); |
if ($parts[0] != 'oidplus:rest_api_information_ra') return; |
if (empty($ra_email)) return; |
|
if ($parts[0] == 'oidplus:rest_api_information_ra') { |
$handled = true; |
|
if (str_starts_with($classname, 'endpoints:')) { |
$plugin = OIDplus::getPluginByOid(explode(':',$classname)[1]); |
if (str_starts_with($subpage, 'endpoints:')) { |
// Note: This page can be accessed WITHOUT login! |
$plugin = OIDplus::getPluginByOid(explode(':',$subpage)[1]); |
if (!$plugin || !($plugin instanceof INTF_OID_1_3_6_1_4_1_37476_2_5_2_3_9)) throw new OIDplusException(_L("No endpoints for this plugin found"), null, 404); |
$out['title'] = _L('REST API').' - '.$plugin->getManifest()->getName() . ' ' . _L('Endpoints'); |
$out['icon'] = file_exists(__DIR__.'/img/endpoints_icon.png') ? OIDplus::webpath(__DIR__,OIDplus::PATH_RELATIVE).'img/endpoints_icon.png' : ''; |
$out['text'] = '<p><a '.OIDplus::gui()->link('oidplus:rest_api_information_ra').'><img src="img/arrow_back.png" width="16" alt="'._L('Go back').'"> '._L('Go back').'</a></p>'; |
$out['text'] = ''; |
if (!OIDplus::authUtils()->isRaLoggedIn($ra_email) && !OIDplus::authUtils()->isAdminLoggedIn()) { |
$out['text'] .= '<p><a '.OIDplus::gui()->link('oidplus:rest_api_information_ra').'><img src="img/arrow_back.png" width="16" alt="'._L('Go back').'"> '._L('Go back').'</a></p>'; |
} |
$out['text'] .= $plugin->restApiInfo('html'); |
} else { |
$ra_email = explode('$',$id)[1]; |
|
$out['title'] = _L('REST API'); |
$out['icon'] = file_exists(__DIR__.'/img/main_icon.png') ? OIDplus::webpath(__DIR__,OIDplus::PATH_RELATIVE).'img/main_icon.png' : ''; |
|
111,7 → 115,7 |
$endpoints = ''; |
foreach (OIDplus::getAllPlugins() as $plugin) { |
if ($plugin instanceof INTF_OID_1_3_6_1_4_1_37476_2_5_2_3_9) { |
$link = 'oidplus:rest_api_information_ra$endpoints:'.$plugin->getManifest()->getOid(); |
$link = 'oidplus:rest_api_information_ra$'.$ra_email.'$endpoints:'.$plugin->getManifest()->getOid(); |
$endpoints .= '<li><a '.OIDplus::gui()->link($link).'>'.htmlentities($plugin->getManifest()->getName()).'</a></li>'; |
} |
} |
140,6 → 144,7 |
$out['text'] .= '<button type="button" name="btn_blacklist_jwt" id="btn_blacklist_jwt" class="btn btn-danger btn-xs" onclick="OIDplusPageRaRestApi.blacklistJWT('.js_escape($ra_email).')">'._L('Blacklist all previously generated tokens').'</button>'; |
} |
} |
} |
|
/** |
* @param array $json |
169,7 → 174,7 |
foreach (OIDplus::getAllPlugins() as $plugin) { |
if ($plugin instanceof INTF_OID_1_3_6_1_4_1_37476_2_5_2_3_9) { |
$submenu[] = [ |
'id' => 'oidplus:rest_api_information_ra$endpoints:'.$plugin->getManifest()->getOid(), |
'id' => 'oidplus:rest_api_information_ra$'.$ra_email.'$endpoints:'.$plugin->getManifest()->getOid(), |
'icon' => $tree_icon_endpoints, |
'text' => $plugin->getManifest()->getName() . ' ' . _L('Endpoints') |
]; |
177,7 → 182,7 |
} |
|
$json[] = array( |
'id' => 'oidplus:rest_api_information_ra', |
'id' => 'oidplus:rest_api_information_ra$'.$ra_email, |
'icon' => $tree_icon, |
'text' => _L('REST API'), |
'children' => $submenu |