Subversion Repositories oidplus

Compare Revisions

Regard whitespace Rev 1274 → Rev 1275

/trunk/plugins/viathinksoft/language/dede/messages.xml
198,6 → 198,14
</message>
<message>
<source><![CDATA[
<0 is error, >=0 is success
]]></source>
<target><![CDATA[
<0 ist Fehler, >=0 ist Erfolg
]]></target>
</message>
<message>
<source><![CDATA[
<a %1>Click here</a> for more information about privacy related topics.
]]></source>
<target><![CDATA[
3366,6 → 3374,14
</message>
<message>
<source><![CDATA[
Invalid JSON data received
]]></source>
<target><![CDATA[
Ungültige JSON-Daten erhalten
]]></target>
</message>
<message>
<source><![CDATA[
Invalid OID %1
]]></source>
<target><![CDATA[
5990,6 → 6006,14
</message>
<message>
<source><![CDATA[
REST endpoint not found
]]></source>
<target><![CDATA[
REST-Endpunkt wurde nicht gefunden
]]></target>
</message>
<message>
<source><![CDATA[
RFC Internet Draft
]]></source>
<target><![CDATA[
8846,6 → 8870,14
</message>
<message>
<source><![CDATA[
if an error occurred
]]></source>
<target><![CDATA[
wenn ein Fehler aufgetreten ist
]]></target>
</message>
<message>
<source><![CDATA[
if it was created
]]></source>
<target><![CDATA[
/trunk/plugins/viathinksoft/publicPages/000_objects/OIDplusPagePublicObjects.class.php
26,7 → 26,7
class OIDplusPagePublicObjects extends OIDplusPagePluginPublic
implements INTF_OID_1_3_6_1_4_1_37476_2_5_2_3_1, /* oobeEntry, oobeRequested */
INTF_OID_1_3_6_1_4_1_37476_2_5_2_3_8, /* getNotifications */
INTF_OID_1_3_6_1_4_1_37476_2_5_2_3_9 /* restApiCall */
INTF_OID_1_3_6_1_4_1_37476_2_5_2_3_9 /* restApi* */
// Important: Do NOT implement INTF_OID_1_3_6_1_4_1_37476_2_5_2_3_7, because our getAlternativesForQuery() is the one that calls others!
{
 
62,9 → 62,11
* Implements INTF_OID_1_3_6_1_4_1_37476_2_5_2_3_9
* @param string $requestMethod
* @param string $endpoint
* @param array $json_in
* @return array|false
*/
public function restApiCall(string $requestMethod, string $endpoint) {
public function restApiCall(string $requestMethod, string $endpoint, array $json_in) {
// TODO: Translate status bit-fields that are returned from action() into human readable JSON boolean fields
if (str_starts_with($endpoint, 'objects/')) {
$id = substr($endpoint, strlen('objects/'));
if ($requestMethod == "GET"/*Select*/) {
102,13 → 104,13
 
$params = array();
$params['id'] = $id;
$params['ra_email'] = $_POST['ra_email'] ?? '';
$params['comment'] = $_POST['comment'] ?? '';
$params['confidential'] = $_POST['confidential'] ?? false;
$params['title'] = $_POST['title'] ?? '';
$params['description'] = $_POST['description'] ?? '';
$params['asn1ids'] = $_POST['asn1ids'] ?? array();
$params['iris'] = $_POST['iris'] ?? array();
$params['ra_email'] = $json_in['ra_email'] ?? '';
$params['comment'] = $json_in['comment'] ?? '';
$params['confidential'] = $json_in['confidential'] ?? false;
$params['title'] = $json_in['title'] ?? '';
$params['description'] = $json_in['description'] ?? '';
$params['asn1ids'] = $json_in['asn1ids'] ?? array();
$params['iris'] = $json_in['iris'] ?? array();
 
if (OIDplusObject::exists($id)) {
// TODO: Problem: The superior RA cannot set title/description, so they cannot perform the PUT command!
121,7 → 123,7
http_response_code(200);
return $res;
} else if ($requestMethod == "POST"/*Insert*/) {
$params = $_POST;
$params = $json_in;
$obj = OIDplusObject::parse($id);
if (!$obj) throw new OIDplusException(_L('%1 action failed because object "%2" cannot be parsed!', 'GET', $id), null, 400);
$params['parent'] = $obj->getParent();
131,13 → 133,13
http_response_code(200);
return $res;
} else if ($requestMethod == "PATCH"/*Modify*/) {
$params = $_POST;
$params = $json_in;
$params['id'] = $id;
$res = self::action('Update', $params);
http_response_code(200);
return $res;
} else if ($requestMethod == "DELETE"/*Delete*/) {
$params = $_POST;
$params = $json_in;
$params['id'] = $id;
$res = self::action('Delete', $params);
http_response_code(200);
187,7 → 189,8
'<i>'._L('None').'</i>'
],
_L('Output parameters') => [
'status|error',
'status ('._L('<0 is error, >=0 is success').')',
'error ('._L('if an error occurred').')',
'ra_email',
'comment',
'iris',
209,7 → 212,8
'description ('._L('optional').')'
],
_L('Output parameters') => [
'status|error',
'status ('._L('<0 is error, >=0 is success').')',
'error ('._L('if an error occurred').')',
'inserted_id ('._L('if it was created').')'
]
],
225,7 → 229,8
'description ('._L('optional').')'
],
_L('Output parameters') => [
'status|error',
'status ('._L('<0 is error, >=0 is success').')',
'error ('._L('if an error occurred').')',
'inserted_id'
]
],
241,7 → 246,8
'description ('._L('optional').')'
],
_L('Output parameters') => [
'status|error'
'status ('._L('<0 is error, >=0 is success').')',
'error ('._L('if an error occurred').')',
]
],
_L('Remove') => [
250,7 → 256,8
'<i>'._L('None').'</i>'
],
_L('Output parameters') => [
'status|error'
'status ('._L('<0 is error, >=0 is success').')',
'error ('._L('if an error occurred').')',
]
]
];
398,8 → 405,8
$current_ra = $obj->getRaMail() ?? '';
if ($new_ra != $current_ra) {
OIDplus::logger()->log("V2:[INFO]OID(%1)+[OK/INFO]SUPOIDRA(%1)+[OK/INFO]A", "RA of object '%1' changed from '%2' to '%3'", $id, $current_ra, $new_ra);
OIDplus::logger()->log("V2:[WARN]RA(%2)", "Lost ownership of object '%1' due to RA transfer of superior RA / admin.", $id, $current_ra, $new_ra);
OIDplus::logger()->log("V2:[INFO]RA(%3)", "Gained ownership of object '%1' due to RA transfer of superior RA / admin.", $id, $current_ra, $new_ra);
if (!empty($current_ra)) OIDplus::logger()->log("V2:[WARN]RA(%2)", "Lost ownership of object '%1' due to RA transfer of superior RA / admin.", $id, $current_ra, $new_ra);
if (!empty($new_ra)) OIDplus::logger()->log("V2:[INFO]RA(%3)", "Gained ownership of object '%1' due to RA transfer of superior RA / admin.", $id, $current_ra, $new_ra);
if ($parentObj = $obj->getParent()) {
$parent_oid = $parentObj->nodeId();
OIDplus::logger()->log("V2:[INFO]OID(%4)", "RA of object '%1' changed from '%2' to '%3'", $id, $current_ra, $new_ra, $parent_oid);
/trunk/plugins/viathinksoft/publicPages/002_rest_api/INTF_OID_1_3_6_1_4_1_37476_2_5_2_3_9.class.php
28,9 → 28,10
/**
* @param string $requestMethod
* @param string $endpoint
* @param array $json_in
* @return array|false
*/
public function restApiCall(string $requestMethod, string $endpoint);
public function restApiCall(string $requestMethod, string $endpoint, array $json_in);
 
/**
* Outputs information about valid endpoints
/trunk/plugins/viathinksoft/publicPages/002_rest_api/OIDplusPagePublicRestApi.class.php
43,20 → 43,23
$requestMethod = $_SERVER["REQUEST_METHOD"];
 
try {
$cont = @file_get_contents('php://input');
$json_in = empty($cont) ? [] : @json_decode($cont, true);
if (!is_array($json_in)) throw new OIDplusException(_L('Invalid JSON data received'), null, 400);
 
$json_out = false;
foreach (OIDplus::getAllPlugins() as $plugin) {
if ($plugin instanceof INTF_OID_1_3_6_1_4_1_37476_2_5_2_3_9) {
$json_out = $plugin->restApiCall($requestMethod, $rel_url);
$json_out = $plugin->restApiCall($requestMethod, $rel_url, $json_in);
if ($json_out !== false) break;
}
}
if ($json_out === false) {
http_response_code(404);
$json_out = array("error" => "Endpoint not found");
throw new OIDplusException(_L('REST endpoint not found'), null, 404);
}
} catch (\Exception $e) {
http_response_code($e instanceof OIDplusException ? $e->getHttpStatus() : 500);
$json_out = array("error" => $e->getMessage());
$json_out = array("status" => -1, "error" => $e->getMessage());
}
 
OIDplus::invoke_shutdown();