diff --git a/Admin/Installer.php b/Admin/Installer.php index d4107e1..e9c1a8e 100755 --- a/Admin/Installer.php +++ b/Admin/Installer.php @@ -150,7 +150,7 @@ final class Installer extends InstallerAbstract /** @var \Modules\Editor\Models\EditorDocType $type */ $type = $responseData['response']; - $id = $type->getId(); + $id = $type->id; $isFirst = true; foreach ($data['l11n'] as $l11n) { diff --git a/Controller/ApiController.php b/Controller/ApiController.php index 367f7f4..2a76f31 100755 --- a/Controller/ApiController.php +++ b/Controller/ApiController.php @@ -280,23 +280,23 @@ final class ApiController extends Controller $collection = null; foreach ($uploaded as $media) { - $accountPath = '/Accounts/' . $account->getId() . ' ' . $account->login + $accountPath = '/Accounts/' . $account->id . ' ' . $account->login . '/Editor/' . $doc->createdAt->format('Y') . '/' . $doc->createdAt->format('m') - . '/' . $doc->getId(); + . '/' . $doc->id; if ($collection === null) { $collection = $this->app->moduleManager->get('Media')->createRecursiveMediaCollection( $accountPath, $request->header->account, - __DIR__ . '/../../../Modules/Media/Files/Accounts/' . $account->getId() . '/Editor/' . $doc->createdAt->format('Y') . '/' . $doc->createdAt->format('m') . '/' . $doc->getId() + __DIR__ . '/../../../Modules/Media/Files/Accounts/' . $account->id . '/Editor/' . $doc->createdAt->format('Y') . '/' . $doc->createdAt->format('m') . '/' . $doc->id ); } $this->createModelRelation( $request->header->account, - $doc->getId(), - $media->getId(), + $doc->id, + $media->id, EditorDocMapper::class, 'media', '', @@ -305,7 +305,7 @@ final class ApiController extends Controller $ref = new Reference(); $ref->name = $media->name; - $ref->source = new NullMedia($media->getId()); + $ref->source = new NullMedia($media->id); $ref->createdBy = new NullAccount($request->header->account); $ref->setVirtualPath($accountPath); @@ -313,8 +313,8 @@ final class ApiController extends Controller $this->createModelRelation( $request->header->account, - $collection->getId(), - $ref->getId(), + $collection->id, + $ref->id, CollectionMapper::class, 'sources', '', @@ -336,7 +336,7 @@ final class ApiController extends Controller $this->createModelRelation( $request->header->account, - $doc->getId(), + $doc->id, (int) $media, EditorDocMapper::class, 'media', @@ -355,8 +355,8 @@ final class ApiController extends Controller $this->createModel($request->header->account, $ref, ReferenceMapper::class, 'media_reference', $request->getOrigin()); $this->createModelRelation( $request->header->account, - $collection->getId(), - $ref->getId(), + $collection->id, + $ref->id, CollectionMapper::class, 'sources', '', @@ -381,7 +381,7 @@ final class ApiController extends Controller . $doc->createdAt->format('Y') . '/' . $doc->createdAt->format('m') . '/' . $doc->createdAt->format('d') . '/' - . $doc->getId(); + . $doc->id; } /** @@ -586,7 +586,7 @@ final class ApiController extends Controller foreach ($uploaded as $file) { $this->createModelRelation( $request->header->account, - $file->getId(), + $file->id, $request->getDataInt('type'), MediaMapper::class, 'types', @@ -599,7 +599,7 @@ final class ApiController extends Controller $this->createModelRelation( $request->header->account, (int) $request->getData('doc'), - \reset($uploaded)->getId(), + \reset($uploaded)->id, EditorDocMapper::class, 'media', '', $request->getOrigin() ); diff --git a/Controller/BackendController.php b/Controller/BackendController.php index 96d7f07..e4c5bff 100755 --- a/Controller/BackendController.php +++ b/Controller/BackendController.php @@ -142,9 +142,9 @@ final class BackendController extends Controller $accountId = $request->header->account; - if ($doc->createdBy->getId() !== $accountId + if ($doc->createdBy->id !== $accountId && !$this->app->accountManager->get($accountId)->hasPermission( - PermissionType::READ, $this->app->unitId, $this->app->appId, self::NAME, PermissionCategory::DOC, $doc->getId()) + PermissionType::READ, $this->app->unitId, $this->app->appId, self::NAME, PermissionCategory::DOC, $doc->id) ) { $view->setTemplate('/Web/Backend/Error/403_inline'); $response->header->status = RequestStatusCode::R_403; @@ -162,7 +162,7 @@ final class BackendController extends Controller $view->addData('tagSelector', $tagSelector); $view->addData('editable', $this->app->accountManager->get($accountId)->hasPermission( - PermissionType::MODIFY, $this->app->unitId, $this->app->appId, self::NAME, PermissionCategory::DOC, $doc->getId()) + PermissionType::MODIFY, $this->app->unitId, $this->app->appId, self::NAME, PermissionCategory::DOC, $doc->id) ); return $view; @@ -188,9 +188,9 @@ final class BackendController extends Controller $doc = EditorDocMapper::get()->where('id', (int) $request->getData('id'))->execute(); $accountId = $request->header->account; - if ($doc->createdBy->getId() !== $accountId + if ($doc->createdBy->id !== $accountId && !$this->app->accountManager->get($accountId)->hasPermission( - PermissionType::READ, $this->app->unitId, $this->app->appId, self::NAME, PermissionCategory::DOC, $doc->getId()) + PermissionType::READ, $this->app->unitId, $this->app->appId, self::NAME, PermissionCategory::DOC, $doc->id) ) { $view->setTemplate('/Web/Backend/Error/403_inline'); $response->header->status = RequestStatusCode::R_403; diff --git a/Models/EditorDoc.php b/Models/EditorDoc.php index 8c17563..94cfef9 100755 --- a/Models/EditorDoc.php +++ b/Models/EditorDoc.php @@ -35,7 +35,7 @@ class EditorDoc implements \JsonSerializable * @var int * @since 1.0.0 */ - protected int $id = 0; + public int $id = 0; /** * Version. diff --git a/Models/EditorDocHistory.php b/Models/EditorDocHistory.php index 019e2e4..6be2f4d 100755 --- a/Models/EditorDocHistory.php +++ b/Models/EditorDocHistory.php @@ -33,7 +33,7 @@ class EditorDocHistory implements \JsonSerializable * @var int * @since 1.0.0 */ - protected int $id = 0; + public int $id = 0; /** * Doc ID. @@ -114,7 +114,7 @@ class EditorDocHistory implements \JsonSerializable public static function createFromDoc(EditorDoc $doc) : self { $hist = new self(); - $hist->doc = $doc->getId(); + $hist->doc = $doc->id; $hist->createdBy = $doc->createdBy; $hist->title = $doc->title; $hist->plain = $doc->plain; diff --git a/Models/EditorDocType.php b/Models/EditorDocType.php index 5e10b8a..57f46a9 100755 --- a/Models/EditorDocType.php +++ b/Models/EditorDocType.php @@ -33,7 +33,7 @@ class EditorDocType implements \JsonSerializable * @var int * @since 1.0.0 */ - protected int $id = 0; + public int $id = 0; /** * Name. diff --git a/Theme/Backend/editor-create.tpl.php b/Theme/Backend/editor-create.tpl.php index 7b12d47..7dc4551 100755 --- a/Theme/Backend/editor-create.tpl.php +++ b/Theme/Backend/editor-create.tpl.php @@ -17,7 +17,7 @@ use phpOMS\Uri\UriFactory; /** @var \Modules\Editor\Models\EditorDoc $doc */ $doc = $this->getData('doc') ?? new NullEditorDoc(); -$isNewDoc = $doc instanceof NullEditorDoc; +$isNewDoc = $doc->id === 0; /** @var \phpOMS\Views\View $this */ echo $this->getData('nav')->render(); ?> diff --git a/Theme/Backend/editor-list.tpl.php b/Theme/Backend/editor-list.tpl.php index 5d75e18..9606ac0 100755 --- a/Theme/Backend/editor-list.tpl.php +++ b/Theme/Backend/editor-list.tpl.php @@ -25,10 +25,10 @@ $collections = $this->getData('collections'); $mediaPath = \urldecode($this->getData('path') ?? '/'); $account = $this->getData('account'); -$accountDir = $account->getId() . ' ' . $account->login; +$accountDir = $account->id . ' ' . $account->login; -$previous = empty($docs) ? '{/base}/editor/list' : '{/base}/editor/list?{?}&id=' . \reset($docs)->getId() . '&ptype=p'; -$next = empty($docs) ? '{/base}/editor/list' : '{/base}/editor/list?{?}&id=' . \end($docs)->getId() . '&ptype=n'; +$previous = empty($docs) ? '{/base}/editor/list' : '{/base}/editor/list?{?}&id=' . \reset($docs)->id . '&ptype=p'; +$next = empty($docs) ? '{/base}/editor/list' : '{/base}/editor/list?{?}&id=' . \end($docs)->id . '&ptype=n'; $docs = $this->getData('docs'); @@ -134,11 +134,11 @@ echo $this->getData('nav')->render(); ?>