Subversion Repositories oidplus

Compare Revisions

Regard whitespace Rev 1290 → Rev 1291

/trunk/plugins/viathinksoft/publicPages/000_objects/OIDplusPagePublicObjects.class.php
143,11 → 143,11
 
if (OIDplusObject::exists($id)) {
// TODO: Problem: The superior RA cannot set title/description, so they cannot perform the PUT command!
$output = self::action('Update', $params);
$output = self::action_Update($params);
} else {
$params['parent'] = $obj->getParent();
$params['id_fully_qualified'] = true;
$output = self::action('Insert', $params);
$output = self::action_Insert($params);
}
 
$output['status_bits'] = [];
165,7 → 165,7
$params['parent'] = $obj->getParent();
$params['id_fully_qualified'] = true;
$params['id'] = $id;
$output = self::action('Insert', $params);
$output = self::action_Insert($params);
 
$output['status_bits'] = [];
if (($output['status'] & 1) == 1) $output['status_bits'][1] = 'RA is not registered, but it can be invited';
178,7 → 178,7
} else if ($requestMethod == "PATCH"/*Modify*/) {
$params = $json_in;
$params['id'] = $id;
$output = self::action('Update', $params);
$output = self::action_Update($params);
 
$output['status_bits'] = [];
if (($output['status'] & 1) == 1) $output['status_bits'][1] = 'RA is not registered, but it can be invited';
191,7 → 191,7
} else if ($requestMethod == "DELETE"/*Delete*/) {
$params = $json_in;
$params['id'] = $id;
$output = self::action('Delete', $params);
$output = self::action_Delete($params);
 
$output['status_bits'] = [];
 
305,18 → 305,12
}
 
/**
* @param string $actionID
* @param array $params
* @return array
* @param array $params id
* @return array status<0 Error, =0 Success
* @throws OIDplusConfigInitializationException
* @throws OIDplusException
*/
public function action(string $actionID, array $params): array {
 
// Action: Delete
// Parameters: id
// Outputs: <0 Error, =0 Success
if ($actionID == 'Delete') {
private function action_Delete(array $params): array {
_CheckParamExists($params, 'id');
$id = $params['id'];
$obj = OIDplusObject::parse($id);
375,14 → 369,17
return array("status" => 0);
}
 
// Action: Update
// Parameters: id, ra_email, comment, iris, asn1ids, confidential, title, description
// Outputs: <0 Error, =0 Success, with following bitfields for further information:
// x+1 = RA is not registered, but it can be invited
// x+2 = RA is not registered and it cannot be invited
// x+4 = OID is a well-known OID, so RA, ASN.1, and IRI identifiers were reset
// x+8 = User has write rights to the freshly created OID
else if ($actionID == 'Update') {
/**
* @param array $params id, ra_email, comment, iris, asn1ids, confidential, title, description
* @return array status<0 Error, =0 Success, with the following bitfields for further information:
* x+1 = RA is not registered, but it can be invited
* x+2 = RA is not registered and it cannot be invited
* x+4 = OID is a well-known OID, so RA, ASN.1, and IRI identifiers were reset
* x+8 = User has write rights to the freshly created OID
* @throws OIDplusConfigInitializationException
* @throws OIDplusException
*/
public function action_Update(array $params): array {
_CheckParamExists($params, 'id');
$id = $params['id'];
$obj = OIDplusObject::parse($id);
539,25 → 536,17
return array("status" => $status);
}
 
// Generate UUID
else if ($actionID == 'generate_uuid') {
$uuid = gen_uuid(OIDplus::config()->getValue('uuid_prefer_timebased', '1') == '1');
if (!$uuid) return array("status" => 1);
return array(
"status" => 0,
"uuid" => $uuid,
"intval" => substr(uuid_to_oid($uuid),strlen('2.25.'))
);
}
 
// Action: Insert
// Parameters: parent, id (relative!), ra_email, comment, iris, asn1ids, confidential, title, description
// Outputs: status=<0 Error, =0 Success, with following bitfields for further information:
// x+1 = RA is not registered, but it can be invited
// x+2 = RA is not registered and it cannot be invited
// x+4 = OID is a well-known OID, so RA, ASN.1, and IRI identifiers were reset
// x+8 = User has write rights to the freshly created OID
else if ($actionID == 'Insert') {
/**
* @param array $params parent, id (relative!), ra_email, comment, iris, asn1ids, confidential, title, description
* @return array status=<0 Error, =0 Success, with the following bitfields for further information:
* x+1 = RA is not registered, but it can be invited
* x+2 = RA is not registered and it cannot be invited
* x+4 = OID is a well-known OID, so RA, ASN.1, and IRI identifiers were reset
* x+8 = User has write rights to the freshly created OID
* @throws OIDplusConfigInitializationException
* @throws OIDplusException
*/
public function action_Insert(array $params): array {
// Check if you have write rights on the parent (to create a new object)
_CheckParamExists($params, 'parent');
$objParent = OIDplusObject::parse($params['parent']);
593,13 → 582,15
 
// Determine absolute OID name
// Note: At addString() and parse(), the syntax of the ID will be checked
if (isset($params['id_fully_qualified']) && is_string($params['id_fully_qualified'])) $params['id_fully_qualified'] = $params['id_fully_qualified'] == 'true';
if ($params['id_fully_qualified'] ?? false) {
$is_absolute = isset($params['id_fully_qualified']) && $params['id_fully_qualified'] == 'true';;
if ($is_absolute) {
// For REST API, the ID is absolute (because this is what is in the URL). We need to verify that ID and Parent matches.
$id = $params['id'];
$obj = OIDplusObject::parse($id);
$objParentTest = $obj->getParent();
$objParentTest = !$obj ? null : $obj->getParent();
if (!$objParentTest || !$objParentTest->equals($objParent)) throw new OIDplusException(_L('Cannot verify that %1 has parent %2', $obj->nodeId(), $objParent->nodeId()));
} else {
// For AJAX/UI, the ID is relative to the parent. The absolute ID will be created by PHP's addString(), because JavaScript cannot know the syntax of the Object Type plugin
$id = $objParent->addString($params['id']);
$obj = OIDplusObject::parse($id);
}
717,6 → 708,31
"status" => $status,
"inserted_id" => $id
);
}
 
/**
* @param string $actionID
* @param array $params
* @return array
* @throws OIDplusConfigInitializationException
* @throws OIDplusException
*/
public function action(string $actionID, array $params): array {
if ($actionID == 'Delete') {
return $this->action_Delete($params);
} else if ($actionID == 'Update') {
return $this->action_Update($params);
} else if ($actionID == 'Insert') {
return $this->action_Insert($params);
} else if ($actionID == 'generate_uuid') {
// Generate UUID (will be used by a few plugins)
$uuid = gen_uuid(OIDplus::config()->getValue('uuid_prefer_timebased', '1') == '1');
if (!$uuid) return array("status" => 1);
return array(
"status" => 0,
"uuid" => $uuid,
"intval" => substr(uuid_to_oid($uuid),strlen('2.25.'))
);
} else {
return parent::action($actionID, $params);
}