Improved the visibility filter for articles
authorAlexander Ebert <ebert@woltlab.com>
Thu, 31 Oct 2019 18:09:10 +0000 (19:09 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Thu, 31 Oct 2019 18:09:10 +0000 (19:09 +0100)
- Admin: All articles are shown
- Edit own articles only: All public articles + own regardless of status
- Anybody else: Only published and non-deleted articles

com.woltlab.wcf/templates/article.tpl
com.woltlab.wcf/templates/articleListItems.tpl
wcfsetup/install/files/lib/data/article/AccessibleArticleList.class.php
wcfsetup/install/files/lib/data/article/ViewableArticle.class.php
wcfsetup/install/lang/de.xml
wcfsetup/install/lang/en.xml

index 52bc634a06bd39140911b4f6968c17115ef632dd..3a66b24855a0dcba97781c4da25d3bb0f7a45936 100644 (file)
 
 {include file='header'}
 
+{if !$article->isPublished()}
+       <p class="info">{lang publicationDate=$article->publicationDate}wcf.article.publicationStatus.{@$article->publicationStatus}{/lang}</p>
+{/if}
+
 <div class="section">
        {if $articleContent->teaser}
                <div class="section articleTeaserContainer">
index 64682d77e95629065c6b65aa241a5f5137111c84..6458acd6378d5d8dc12052886ef89799405c5365 100644 (file)
@@ -9,6 +9,7 @@
                                                <div class="contentItemBadges">
                                                        {content}
                                                                {if $article->isDeleted}<span class="badge label red contentItemBadge contentItemBadgeIsDeleted">{lang}wcf.message.status.deleted{/lang}</span>{/if}
+                                                               {if !$article->isPublished()}<span class="badge label green contentItemBadge contentItemBadgeIsDisabled">{lang}wcf.message.status.disabled{/lang}</span>{/if}
                                                                {if ARTICLE_ENABLE_VISIT_TRACKING && $article->isNew()}<span class="badge label contentItemBadge contentItemBadgeNew">{lang}wcf.message.new{/lang}</span>{/if}
                                                                
                                                                {event name='contentItemBadges'}
index 6d56601c017c1a8c61992dc10af787ae848aed7e..ef8c1cad3f77f8236e453f4c71d092ecfb3019a4 100644 (file)
@@ -26,10 +26,15 @@ class AccessibleArticleList extends ViewableArticleList {
                }
                else {
                        $this->getConditionBuilder()->add('article.categoryID IN (?)', [$accessibleCategoryIDs]);
-                       $this->getConditionBuilder()->add('article.publicationStatus = ?', [Article::PUBLISHED]);
                        
                        if (!WCF::getSession()->getPermission('admin.content.article.canManageArticle')) {
-                               $this->getConditionBuilder()->add('article.isDeleted = ?', [0]);
+                               if (WCF::getSession()->getPermission('admin.content.article.canManageOwnArticles')) {
+                                       $this->getConditionBuilder()->add('(article.userID = ? OR (article.isDeleted = ? AND article.publicationStatus = ?))', [WCF::getUser()->userID, 0, Article::PUBLISHED]);
+                               }
+                               else {
+                                       $this->getConditionBuilder()->add('article.isDeleted = ?', [0]);
+                                       $this->getConditionBuilder()->add('article.publicationStatus = ?', [Article::PUBLISHED]);
+                               }
                        }
                }
        }
index 9b7b332599ac2c8904678ca7d733970c05dd9551..c523da874f23b2bcb37c63bd5295f64bd8bb079e 100644 (file)
@@ -205,6 +205,14 @@ class ViewableArticle extends DatabaseObjectDecorator {
                return !empty($this->labels);
        }
        
+       /**
+        * @return bool
+        * @since 5.2
+        */
+       public function isPublished() {
+               return $this->publicationStatus == Article::PUBLISHED;
+       }
+       
        /**
         * Returns the number of unread articles.
         *
index cba4c38f5b6473abe72b9d3d7337e10c1eed770a..47a9ff0ec24e31e80dc072f0e62a8aa484da9868 100644 (file)
@@ -3247,6 +3247,8 @@ Benutzerkontos nun in vollem Umfang nutzen.]]></item>
                <item name="wcf.article.search.error.tooShort"><![CDATA[Der Suchbegriff ist zu kurz.]]></item>
                <item name="wcf.article.search.name"><![CDATA[Titel durchsuchen]]></item>
                <item name="wcf.article.search.results"><![CDATA[Suchergebnisse]]></item>
+               <item name="wcf.article.publicationStatus.0"><![CDATA[Dieser Artikel wurde noch nicht veröffentlicht.]]></item>
+               <item name="wcf.article.publicationStatus.2"><![CDATA[Dieser Artikel wird am {@$publicationDate|plainTime} veröffentlicht.]]></item>
        </category>
        <category name="wcf.attachment">
                <item name="wcf.attachment.file.info"><![CDATA[({@$attachment->filesize|filesize}, <b>{#$attachment->downloads}</b> Mal heruntergeladen{if $attachment->downloads > 0}, zuletzt: {@$attachment->lastDownloadTime|time}{/if})]]></item>
index b1f1177d2be24d2596c2a034f7273b98e7fe188d..b2fca935ed9c5a1afc119aa88f0e48f12b896b53 100644 (file)
@@ -3171,6 +3171,8 @@ full extend.]]></item>
                <item name="wcf.article.search.error.tooShort"><![CDATA[The entered keyword is too short.]]></item>
                <item name="wcf.article.search.name"><![CDATA[Search Titles]]></item>
                <item name="wcf.article.search.results"><![CDATA[Search Results]]></item>
+               <item name="wcf.article.publicationStatus.0"><![CDATA[This article has not been published yet.]]></item>
+               <item name="wcf.article.publicationStatus.2"><![CDATA[This article will be published on {@$publicationDate|plainTime}.]]></item>
        </category>
        <category name="wcf.attachment">
                <item name="wcf.attachment.file.info"><![CDATA[({@$attachment->filesize|filesize}, downloaded <b>{#$attachment->downloads}</b> times{if $attachment->downloads > 0}, last: {@$attachment->lastDownloadTime|time}{/if})]]></item>