From ea1e0056022fc004fcee43b0ed7511fc2b2b37e9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Joshua=20R=C3=BCsweg?= Date: Fri, 9 Jun 2017 12:42:17 +0200 Subject: [PATCH] add article sitemap See #2286 --- com.woltlab.wcf/objectType.xml | 8 ++++ .../object/ArticleSitemapObject.class.php | 39 +++++++++++++++++++ wcfsetup/install/lang/de.xml | 1 + wcfsetup/install/lang/en.xml | 1 + 4 files changed, 49 insertions(+) create mode 100644 wcfsetup/install/files/lib/system/sitemap/object/ArticleSitemapObject.class.php diff --git a/com.woltlab.wcf/objectType.xml b/com.woltlab.wcf/objectType.xml index 22a7c9e4e8..e3bfd42259 100644 --- a/com.woltlab.wcf/objectType.xml +++ b/com.woltlab.wcf/objectType.xml @@ -1267,6 +1267,14 @@ weekly 2592000 + + com.woltlab.wcf.sitemap.object.article + com.woltlab.wcf.sitemap.object + wcf\system\sitemap\object\ArticleSitemapObject + 0.5 + monthly + 259200 + diff --git a/wcfsetup/install/files/lib/system/sitemap/object/ArticleSitemapObject.class.php b/wcfsetup/install/files/lib/system/sitemap/object/ArticleSitemapObject.class.php new file mode 100644 index 0000000000..77ed7c3214 --- /dev/null +++ b/wcfsetup/install/files/lib/system/sitemap/object/ArticleSitemapObject.class.php @@ -0,0 +1,39 @@ + + * @package WoltLabSuite\Core\Sitemap\Object + * @since 3.1 + */ +class ArticleSitemapObject extends AbstractSitemapObjectObjectType { + /** + * @inheritDoc + */ + public function getObjectClass() { + return ArticleContent::class; + } + + /** + * @inheritDoc + */ + public function canView(DatabaseObject $object) { + /** @var $object ArticleContent */ + if ($object->getArticle()->publicationStatus != Article::PUBLISHED) { + return false; + } + + if ($object->getArticle()->getCategory()) { + return $object->getArticle()->getCategory()->isAccessible(self::getGuestUserProfile()->getDecoratedObject()); + } + + return self::getGuestUserProfile()->getPermission('user.article.canRead'); + } +} diff --git a/wcfsetup/install/lang/de.xml b/wcfsetup/install/lang/de.xml index 4590be15cc..7657abe5e0 100644 --- a/wcfsetup/install/lang/de.xml +++ b/wcfsetup/install/lang/de.xml @@ -1600,6 +1600,7 @@ GmbH=Gesellschaft mit beschränkter Haftung]]> + diff --git a/wcfsetup/install/lang/en.xml b/wcfsetup/install/lang/en.xml index 0d4cd1b9cd..70a8683d88 100644 --- a/wcfsetup/install/lang/en.xml +++ b/wcfsetup/install/lang/en.xml @@ -1551,6 +1551,7 @@ + -- 2.20.1