Rev 753 | Rev 783 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 753 | Rev 772 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | <?php |
1 | <?php |
2 | 2 | ||
3 | /* |
3 | /* |
4 | * OIDplus 2.0 |
4 | * OIDplus 2.0 |
5 | * Copyright 2019 - 2021 Daniel Marschall, ViaThinkSoft |
5 | * Copyright 2019 - 2022 Daniel Marschall, ViaThinkSoft |
6 | * |
6 | * |
7 | * Licensed under the Apache License, Version 2.0 (the "License"); |
7 | * Licensed under the Apache License, Version 2.0 (the "License"); |
8 | * you may not use this file except in compliance with the License. |
8 | * you may not use this file except in compliance with the License. |
9 | * You may obtain a copy of the License at |
9 | * You may obtain a copy of the License at |
10 | * |
10 | * |
Line 312... | Line 312... | ||
312 | // Check if you have write rights on the parent (to create a new object) |
312 | // Check if you have write rights on the parent (to create a new object) |
313 | _CheckParamExists($params, 'parent'); |
313 | _CheckParamExists($params, 'parent'); |
314 | $objParent = OIDplusObject::parse($params['parent']); |
314 | $objParent = OIDplusObject::parse($params['parent']); |
315 | if ($objParent === null) throw new OIDplusException(_L('%1 action failed because parent object "%2" cannot be parsed!','INSERT',$params['parent'])); |
315 | if ($objParent === null) throw new OIDplusException(_L('%1 action failed because parent object "%2" cannot be parsed!','INSERT',$params['parent'])); |
316 | 316 | ||
317 | if (!$objParent::root() && (OIDplus::db()->query("select id from ###objects where id = ?", array($objParent->nodeId()))->num_rows() == 0)) { |
317 | if (!$objParent->isRoot() && (OIDplus::db()->query("select id from ###objects where id = ?", array($objParent->nodeId()))->num_rows() == 0)) { |
318 | throw new OIDplusException(_L('Parent object %1 does not exist','".($objParent->nodeId())."')); |
318 | throw new OIDplusException(_L('Parent object %1 does not exist','".($objParent->nodeId())."')); |
319 | } |
319 | } |
320 | 320 | ||
321 | if (!$objParent->userHasWriteRights()) throw new OIDplusException(_L('Authentication error. Please log in as the correct RA to insert an OID at this arc.')); |
321 | if (!$objParent->userHasWriteRights()) throw new OIDplusException(_L('Authentication error. Please log in as the correct RA to insert an OID at this arc.')); |
322 | 322 | ||
323 | // Check if the ID is valid |
323 | // Check if the ID is valid |
324 | _CheckParamExists($params, 'id'); |
324 | _CheckParamExists($params, 'id'); |
325 | if ($params['id'] == '') throw new OIDplusException(_L('ID may not be empty')); |
325 | if ($params['id'] == '') throw new OIDplusException(_L('ID may not be empty')); |
326 | 326 | ||
- | 327 | // For the root objects, let the user also enter a WEID |
|
- | 328 | if ($objParent::ns() == 'oid') { |
|
- | 329 | if (strtolower(substr(trim($params['id']),0,5)) === 'weid:') { |
|
- | 330 | if ($objParent->isRoot()) { |
|
- | 331 | $params['id'] = WeidOidConverter::weid2oid($params['id']); |
|
- | 332 | if ($params['id'] === false) { |
|
- | 333 | throw new OIDplusException(_L('Invalid WEID')); |
|
- | 334 | } |
|
- | 335 | } else { |
|
- | 336 | throw new OIDplusException(_L('You can use the WEID syntax only at your object tree root.')); |
|
- | 337 | } |
|
- | 338 | } |
|
- | 339 | } |
|
- | 340 | ||
327 | // Determine absolute OID name |
341 | // Determine absolute OID name |
328 | // Note: At addString() and parse(), the syntax of the ID will be checked |
342 | // Note: At addString() and parse(), the syntax of the ID will be checked |
329 | $id = $objParent->addString($params['id']); |
343 | $id = $objParent->addString($params['id']); |
330 | 344 | ||
331 | // Check, if the OID exists |
345 | // Check, if the OID exists |