<?php
-declare(strict_types=1);
namespace wcf\data\article;
use wcf\data\article\category\ArticleCategory;
use wcf\data\article\content\ArticleContent;
use wcf\data\AbstractDatabaseObjectAction;
use wcf\system\clipboard\ClipboardHandler;
use wcf\system\comment\CommentHandler;
+use wcf\system\exception\PermissionDeniedException;
use wcf\system\exception\UserInputException;
use wcf\system\language\LanguageFactory;
use wcf\system\like\LikeHandler;
* @throws UserInputException
*/
public function validateDelete() {
- WCF::getSession()->checkPermissions(['admin.content.article.canManageArticle']);
-
if (empty($this->objects)) {
$this->readObjects();
}
foreach ($this->getObjects() as $article) {
+ if (!$article->canDelete()) {
+ throw new PermissionDeniedException();
+ }
+
if (!$article->isDeleted) {
throw new UserInputException('objectIDs');
}
* @throws UserInputException
*/
public function validateTrash() {
- WCF::getSession()->checkPermissions(['admin.content.article.canManageArticle']);
-
if (empty($this->objects)) {
$this->readObjects();
}
foreach ($this->getObjects() as $article) {
+ if (!$article->canDelete()) {
+ throw new PermissionDeniedException();
+ }
+
if ($article->isDeleted) {
throw new UserInputException('objectIDs');
}
* @throws UserInputException
*/
public function validatePublish() {
- WCF::getSession()->checkPermissions(['admin.content.article.canManageArticle']);
-
if (empty($this->objects)) {
$this->readObjects();
}
foreach ($this->getObjects() as $article) {
+ if (!$article->canPublish()) {
+ throw new PermissionDeniedException();
+ }
+
if ($article->publicationStatus == Article::PUBLISHED) {
throw new UserInputException('objectIDs');
}
* @throws UserInputException
*/
public function validateUnpublish() {
- WCF::getSession()->checkPermissions(['admin.content.article.canManageArticle']);
-
if (empty($this->objects)) {
$this->readObjects();
}
foreach ($this->getObjects() as $article) {
+ if (!$article->canPublish()) {
+ throw new PermissionDeniedException();
+ }
+
if ($article->publicationStatus != Article::PUBLISHED) {
throw new UserInputException('objectIDs');
}