diff --git a/Controller/ApiController.php b/Controller/ApiController.php index 722e1a1..ec6fd2d 100755 --- a/Controller/ApiController.php +++ b/Controller/ApiController.php @@ -198,22 +198,22 @@ final class ApiController extends Controller foreach ($uploaded as $media) { $this->createModelRelation( $request->header->account, - $news->getId(), - $media->getId(), + $news->id, + $media->id, NewsArticleMapper::class, 'media', '', $request->getOrigin() ); - $accountPath = '/Accounts/' . $account->getId() . ' ' . $account->login + $accountPath = '/Accounts/' . $account->id . ' ' . $account->login . '/News/' . $news->createdAt->format('Y') . '/' . $news->createdAt->format('m') - . '/' . $news->getId(); + . '/' . $news->id; $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); @@ -222,19 +222,19 @@ final class ApiController extends Controller if ($collection === null) { $collection = MediaMapper::getParentCollection($path)->limit(1)->execute(); - if ($collection instanceof NullCollection) { + if ($collection->id === 0) { $collection = $this->app->moduleManager->get('Media')->createRecursiveMediaCollection( $accountPath, $request->header->account, - __DIR__ . '/../../../Modules/Media/Files/Accounts/' . $account->getId() . '/News/' . $news->createdAt->format('Y') . '/' . $news->createdAt->format('m') . '/' . $news->getId() + __DIR__ . '/../../../Modules/Media/Files/Accounts/' . $account->id . '/News/' . $news->createdAt->format('Y') . '/' . $news->createdAt->format('m') . '/' . $news->id ); } } $this->createModelRelation( $request->header->account, - $collection->getId(), - $ref->getId(), + $collection->id, + $ref->id, CollectionMapper::class, 'sources', '', @@ -249,7 +249,7 @@ final class ApiController extends Controller foreach ($mediaFiles as $media) { $this->createModelRelation( $request->header->account, - $news->getId(), + $news->id, (int) $media, NewsArticleMapper::class, 'media', @@ -273,7 +273,7 @@ final class ApiController extends Controller if ($collection === null) { $collection = MediaMapper::getParentCollection($path)->limit(1)->execute(); - if ($collection instanceof NullCollection) { + if ($collection->id === 0) { $collection = $this->app->moduleManager->get('Media')->createRecursiveMediaCollection( $path, $request->header->account, @@ -284,8 +284,8 @@ final class ApiController extends Controller $this->createModelRelation( $request->header->account, - $collection->getId(), - $ref->getId(), + $collection->id, + $ref->id, CollectionMapper::class, 'sources', '', @@ -310,7 +310,7 @@ final class ApiController extends Controller . $news->createdAt->format('Y') . '/' . $news->createdAt->format('m') . '/' . $news->createdAt->format('d') . '/' - . $news->getId(); + . $news->id; } /** @@ -337,7 +337,7 @@ final class ApiController extends Controller // allow comments if ($request->hasData('allow_comments') - && !(($commentApi = $this->app->moduleManager->get('Comments')) instanceof NullModule) + && ($commentApi = $this->app->moduleManager->get('Comments'))::ID > 0 ) { /** @var \Modules\Comments\Controller\ApiController $commentApi */ $commnetList = $commentApi->createCommentList(); diff --git a/Controller/BackendController.php b/Controller/BackendController.php index 7e86024..d271d6c 100755 --- a/Controller/BackendController.php +++ b/Controller/BackendController.php @@ -91,7 +91,7 @@ final class BackendController extends Controller implements DashboardElementInte $ids = []; foreach ($objs as $news) { - $ids[] = $news->getId(); + $ids[] = $news->id; } /** @var \Modules\News\Models\NewsSeen[] $seenObjects */ @@ -171,9 +171,9 @@ final class BackendController extends Controller implements DashboardElementInte $accountId = $request->header->account; - if ($article->createdBy->getId() !== $accountId + if ($article->createdBy->id !== $accountId && !$this->app->accountManager->get($accountId)->hasPermission( - PermissionType::READ, $this->app->unitId, $this->app->appId, self::NAME, PermissionCategory::NEWS, $article->getId()) + PermissionType::READ, $this->app->unitId, $this->app->appId, self::NAME, PermissionCategory::NEWS, $article->id) ) { $view->setTemplate('/Web/Backend/Error/403_inline'); $response->header->status = RequestStatusCode::R_403; @@ -186,7 +186,7 @@ final class BackendController extends Controller implements DashboardElementInte ->where('seenBy', $request->header->account) ->execute(); - if ($seen instanceof NullNewsSeen) { + if ($seen->id === 0) { $seen = new NewsSeen(); $seen->seenBy = (int) $request->header->account; $seen->news = (int) $request->getData('id'); @@ -199,12 +199,12 @@ final class BackendController extends Controller implements DashboardElementInte $view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1000601001, $request, $response)); $view->addData('news', $article); $view->addData('editable', $this->app->accountManager->get($accountId)->hasPermission( - PermissionType::MODIFY, $this->app->unitId, $this->app->appId, self::NAME, PermissionCategory::NEWS, $article->getId()) + PermissionType::MODIFY, $this->app->unitId, $this->app->appId, self::NAME, PermissionCategory::NEWS, $article->id) ); // allow comments if (!$article->comments !== null - && !($this->app->moduleManager->get('Comments') instanceof NullModule) + && $this->app->moduleManager->get('Comments')::ID > 0 ) { $commentCreateView = new \Modules\Comments\Theme\Backend\Components\Comment\CreateView($this->app->l11nManager, $request, $response); $commentListView = new \Modules\Comments\Theme\Backend\Components\Comment\ListView($this->app->l11nManager, $request, $response); diff --git a/Models/NewsArticle.php b/Models/NewsArticle.php index b9385fa..66cb341 100755 --- a/Models/NewsArticle.php +++ b/Models/NewsArticle.php @@ -39,7 +39,7 @@ class NewsArticle implements \JsonSerializable * @var int * @since 1.0.0 */ - protected int $id = 0; + public int $id = 0; /** * Title. @@ -71,7 +71,7 @@ class NewsArticle implements \JsonSerializable * @var int * @since 1.0.0 */ - private int $type = NewsType::ARTICLE; + public int $type = NewsType::ARTICLE; /** * News status. @@ -79,7 +79,7 @@ class NewsArticle implements \JsonSerializable * @var int * @since 1.0.0 */ - private int $status = NewsStatus::DRAFT; + public int $status = NewsStatus::DRAFT; /** * Language. @@ -87,7 +87,7 @@ class NewsArticle implements \JsonSerializable * @var string * @since 1.0.0 */ - private string $language = ISO639x1Enum::_EN; + public string $language = ISO639x1Enum::_EN; /** * Unit diff --git a/Models/NewsSeen.php b/Models/NewsSeen.php index af0af45..3849d59 100755 --- a/Models/NewsSeen.php +++ b/Models/NewsSeen.php @@ -30,7 +30,7 @@ class NewsSeen * @var int * @since 1.0.0 */ - protected int $id = 0; + public int $id = 0; public \DateTime $seenAt; diff --git a/Theme/Backend/dashboard-news.tpl.php b/Theme/Backend/dashboard-news.tpl.php index 33ea010..ba9185e 100755 --- a/Theme/Backend/dashboard-news.tpl.php +++ b/Theme/Backend/dashboard-news.tpl.php @@ -35,7 +35,7 @@ $newsList = $this->getData('news') ?? []; $news) : ++$count; - $url = UriFactory::build('{/base}/news/article?{?}&id=' . $news->getId()); + $url = UriFactory::build('{/base}/news/article?{?}&id=' . $news->id); $color = 'darkred'; if ($news->getType() === NewsType::ARTICLE) { $color = 'green'; } diff --git a/Theme/Backend/news-archive.tpl.php b/Theme/Backend/news-archive.tpl.php index bac0a2c..8c197ff 100755 --- a/Theme/Backend/news-archive.tpl.php +++ b/Theme/Backend/news-archive.tpl.php @@ -18,8 +18,8 @@ use phpOMS\Uri\UriFactory; /** @var \Modules\News\Models\NewsArticle[] $newsList */ $newsList = $this->getData('news') ?? []; -$previous = empty($newsList) ? 'news/archive' : 'news/archive?{?}&id=' . \reset($newsList)->getId() . '&ptype=p'; -$next = empty($newsList) ? 'news/archive' : 'news/archive?{?}&id=' . \end($newsList)->getId() . '&ptype=n'; +$previous = empty($newsList) ? 'news/archive' : 'news/archive?{?}&id=' . \reset($newsList)->id . '&ptype=p'; +$next = empty($newsList) ? 'news/archive' : 'news/archive?{?}&id=' . \end($newsList)->id . '&ptype=n'; echo $this->getData('nav')->render(); ?> @@ -84,12 +84,12 @@ echo $this->getData('nav')->render(); ?> $count = 0; foreach ($newsList as $key => $news) : ++$count; - $url = UriFactory::build('{/base}/news/article?{?}&id=' . $news->getId()); + $url = UriFactory::build('{/base}/news/article?{?}&id=' . $news->id); ?>