Rev 1291 | Rev 1294 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1291 | Rev 1292 | ||
---|---|---|---|
Line 377... | Line 377... | ||
377 | * x+4 = OID is a well-known OID, so RA, ASN.1, and IRI identifiers were reset |
377 | * x+4 = OID is a well-known OID, so RA, ASN.1, and IRI identifiers were reset |
378 | * x+8 = User has write rights to the freshly created OID |
378 | * x+8 = User has write rights to the freshly created OID |
379 | * @throws OIDplusConfigInitializationException |
379 | * @throws OIDplusConfigInitializationException |
380 | * @throws OIDplusException |
380 | * @throws OIDplusException |
381 | */ |
381 | */ |
382 | public function action_Update(array $params): array { |
382 | private function action_Update(array $params): array { |
383 | _CheckParamExists($params, 'id'); |
383 | _CheckParamExists($params, 'id'); |
384 | $id = $params['id']; |
384 | $id = $params['id']; |
385 | $obj = OIDplusObject::parse($id); |
385 | $obj = OIDplusObject::parse($id); |
386 | if (!$obj) throw new OIDplusException(_L('%1 action failed because object "%2" cannot be parsed!','UPDATE',$id)); |
386 | if (!$obj) throw new OIDplusException(_L('%1 action failed because object "%2" cannot be parsed!','UPDATE',$id)); |
387 | 387 | ||
Line 544... | Line 544... | ||
544 | * x+4 = OID is a well-known OID, so RA, ASN.1, and IRI identifiers were reset |
544 | * x+4 = OID is a well-known OID, so RA, ASN.1, and IRI identifiers were reset |
545 | * x+8 = User has write rights to the freshly created OID |
545 | * x+8 = User has write rights to the freshly created OID |
546 | * @throws OIDplusConfigInitializationException |
546 | * @throws OIDplusConfigInitializationException |
547 | * @throws OIDplusException |
547 | * @throws OIDplusException |
548 | */ |
548 | */ |
549 | public function action_Insert(array $params): array { |
549 | private function action_Insert(array $params): array { |
550 | // Check if you have write rights on the parent (to create a new object) |
550 | // Check if you have write rights on the parent (to create a new object) |
551 | _CheckParamExists($params, 'parent'); |
551 | _CheckParamExists($params, 'parent'); |
552 | $objParent = OIDplusObject::parse($params['parent']); |
552 | $objParent = OIDplusObject::parse($params['parent']); |
553 | if (!$objParent) throw new OIDplusException(_L('%1 action failed because parent object "%2" cannot be parsed!','INSERT',$params['parent'])); |
553 | if (!$objParent) throw new OIDplusException(_L('%1 action failed because parent object "%2" cannot be parsed!','INSERT',$params['parent'])); |
554 | 554 | ||
Line 709... | Line 709... | ||
709 | "inserted_id" => $id |
709 | "inserted_id" => $id |
710 | ); |
710 | ); |
711 | } |
711 | } |
712 | 712 | ||
713 | /** |
713 | /** |
- | 714 | * Generate UUID (will be used by a few plugins) |
|
- | 715 | * @param array $params Nothing |
|
- | 716 | * @return array status=0 success, status<0 error. If success, then also uuid, intval |
|
- | 717 | * @throws OIDplusConfigInitializationException |
|
- | 718 | * @throws OIDplusException |
|
- | 719 | */ |
|
- | 720 | private function action_UuidGen(array $params): array { |
|
- | 721 | $uuid = gen_uuid(OIDplus::config()->getValue('uuid_prefer_timebased', '1') == '1'); |
|
- | 722 | if (!$uuid) return array("status" => -1); |
|
- | 723 | return array( |
|
- | 724 | "status" => 0, |
|
- | 725 | "uuid" => $uuid, |
|
- | 726 | "intval" => substr(uuid_to_oid($uuid),strlen('2.25.')) |
|
- | 727 | ); |
|
- | 728 | } |
|
- | 729 | ||
- | 730 | /** |
|
714 | * @param string $actionID |
731 | * @param string $actionID |
715 | * @param array $params |
732 | * @param array $params |
716 | * @return array |
733 | * @return array |
717 | * @throws OIDplusConfigInitializationException |
734 | * @throws OIDplusConfigInitializationException |
718 | * @throws OIDplusException |
735 | * @throws OIDplusException |
Line 723... | Line 740... | ||
723 | } else if ($actionID == 'Update') { |
740 | } else if ($actionID == 'Update') { |
724 | return $this->action_Update($params); |
741 | return $this->action_Update($params); |
725 | } else if ($actionID == 'Insert') { |
742 | } else if ($actionID == 'Insert') { |
726 | return $this->action_Insert($params); |
743 | return $this->action_Insert($params); |
727 | } else if ($actionID == 'generate_uuid') { |
744 | } else if ($actionID == 'generate_uuid') { |
728 | // Generate UUID (will be used by a few plugins) |
- | |
729 | $uuid = gen_uuid(OIDplus::config()->getValue('uuid_prefer_timebased', '1') == '1'); |
- | |
730 | if (!$uuid) return array("status" => 1); |
745 | return $this->action_UuidGen($params); |
731 | return array( |
- | |
732 | "status" => 0, |
- | |
733 | "uuid" => $uuid, |
- | |
734 | "intval" => substr(uuid_to_oid($uuid),strlen('2.25.')) |
- | |
735 | ); |
- | |
736 | } else { |
746 | } else { |
737 | return parent::action($actionID, $params); |
747 | return parent::action($actionID, $params); |
738 | } |
748 | } |
739 | } |
749 | } |
740 | 750 |