Added box for page comments
authorMarcel Werk <burntime@woltlab.com>
Mon, 18 Apr 2016 13:53:27 +0000 (15:53 +0200)
committerMarcel Werk <burntime@woltlab.com>
Mon, 18 Apr 2016 13:53:34 +0000 (15:53 +0200)
com.woltlab.wcf/box.xml
com.woltlab.wcf/objectType.xml
com.woltlab.wcf/templates/boxPageComments.tpl [new file with mode: 0644]
com.woltlab.wcf/userGroupOption.xml
wcfsetup/install/files/lib/acp/form/PageEditForm.class.php
wcfsetup/install/files/lib/system/box/PageCommentsBoxController.class.php [new file with mode: 0644]
wcfsetup/install/files/lib/system/comment/manager/PageCommentManager.class.php [new file with mode: 0644]
wcfsetup/install/lang/de.xml
wcfsetup/install/lang/en.xml

index c7c840ef35be52cf3097d423c33ae86a7ced3d28..cccf7d63a7182e559fef757eb5166ef8b77f6557 100644 (file)
                        <showHeader>1</showHeader>
                        <visibleEverywhere>0</visibleEverywhere>
                </box>
+               
+               <box identifier="com.woltlab.wcf.PageComments">
+                       <name language="de">Kommentare</name>
+                       <name language="en">Page Comments</name>
+                       <boxType>system</boxType>
+                       <controller>wcf\system\box\PageCommentsBoxController</controller>
+                       <position>contentBottom</position>
+                       <showHeader>1</showHeader>
+                       <visibleEverywhere>0</visibleEverywhere>
+               </box>
        </import>
 </data>
index ddb79aae23e5961c42d10b17302ac65e3e251738..91e6426c8ee6641aa5ea0549676d20e5667c47a8 100644 (file)
                        <classname><![CDATA[wcf\system\user\notification\object\type\ModerationQueueCommentResponseUserNotificationObjectType]]></classname>
                        <category>com.woltlab.wcf.moderation</category>
                </type>
+               
+               <type>
+                       <name>com.woltlab.wcf.page</name>
+                       <definitionname>com.woltlab.wcf.comment.commentableContent</definitionname>
+                       <classname><![CDATA[wcf\system\comment\manager\PageCommentManager]]></classname>
+               </type>
                <!-- /comments -->
                
                <!-- moderation -->
diff --git a/com.woltlab.wcf/templates/boxPageComments.tpl b/com.woltlab.wcf/templates/boxPageComments.tpl
new file mode 100644 (file)
index 0000000..d2e5a0d
--- /dev/null
@@ -0,0 +1,5 @@
+{include file='__commentJavaScript' commentContainerID='pageCommentList'}
+
+<ul id="pageCommentList" class="commentList containerList" data-can-add="{if $commentCanAdd}true{else}false{/if}" data-object-id="{@$pageID}" data-object-type-id="{@$commentObjectTypeID}" data-comments="{@$commentList->countObjects()}" data-last-comment-time="{@$lastCommentTime}">
+       {include file='commentList'}
+</ul>
index eb6cc9cecc7bd183107c2a93b231c9666d1e7d01..fdb84aa4a441c57eb07f2f9b15a3c496485e450a 100644 (file)
                                <parent>user.message</parent>
                        </category>
                        
+                       <category name="user.pageComment">
+                               <parent>user</parent>
+                       </category>
+                       
                        <category name="mod" />
                        <category name="mod.general">
                                <parent>mod</parent>
@@ -36,6 +40,9 @@
                        <category name="mod.profileComment">
                                <parent>mod.general</parent>
                        </category>
+                       <category name="mod.pageComment">
+                               <parent>mod.general</parent>
+                       </category>
                        
                        <category name="admin" />
                        
@@ -693,6 +700,25 @@ png]]></defaultvalue>
                        </option>
                        <!-- /user.profile -->
                        
+                       <option name="user.pageComment.canAddComment">
+                               <categoryname>user.pageComment</categoryname>
+                               <optiontype>boolean</optiontype>
+                               <defaultvalue>1</defaultvalue>
+                       </option>
+                       <option name="user.pageComment.canEditComment">
+                               <categoryname>user.pageComment</categoryname>
+                               <optiontype>boolean</optiontype>
+                               <defaultvalue>1</defaultvalue>
+                               <usersonly>1</usersonly>
+                       </option>
+                       <option name="user.pageComment.canDeleteComment">
+                               <categoryname>user.pageComment</categoryname>
+                               <optiontype>boolean</optiontype>
+                               <defaultvalue>0</defaultvalue>
+                               <admindefaultvalue>1</admindefaultvalue>
+                               <usersonly>1</usersonly>
+                       </option>
+                       
                        <option name="mod.general.canUseModeration">
                                <categoryname>mod.general</categoryname>
                                <optiontype>boolean</optiontype>
@@ -739,6 +765,28 @@ png]]></defaultvalue>
                        </option>
                        <!-- /mod.general -->
                        
+                       <option name="mod.pageComment.canEditComment">
+                               <categoryname>mod.pageComment</categoryname>
+                               <optiontype>boolean</optiontype>
+                               <defaultvalue>0</defaultvalue>
+                               <moddefaultvalue>1</moddefaultvalue>
+                               <usersonly>1</usersonly>
+                       </option>
+                       <option name="mod.pageComment.canDeleteComment">
+                               <categoryname>mod.pageComment</categoryname>
+                               <optiontype>boolean</optiontype>
+                               <defaultvalue>0</defaultvalue>
+                               <moddefaultvalue>1</moddefaultvalue>
+                               <usersonly>1</usersonly>
+                       </option>
+                       <option name="mod.pageComment.canModerateComment">
+                               <categoryname>mod.pageComment</categoryname>
+                               <optiontype>boolean</optiontype>
+                               <defaultvalue>0</defaultvalue>
+                               <moddefaultvalue>1</moddefaultvalue>
+                               <usersonly>1</usersonly>
+                       </option>
+                       
                        <!-- user.profileComment -->
                        <option name="user.profileComment.canAddComment">
                                <categoryname>user.profileComment</categoryname>
index bca4e3ceee573364871858126b00d1bfc9f587f5..a81b81e22ef75b5ec02b8d6a8ad34011c034ecbb 100644 (file)
@@ -94,7 +94,7 @@ class PageEditForm extends PageAddForm {
                
                if ($this->pageType == 'system') {
                        $data['controllerCustomURL'] = (!empty($_POST['customURL'][0]) ? $_POST['customURL'][0] : '');
-                       $this->objectAction = new PageAction(array($this->page), 'update', array('data' => array_merge($this->additionalFields, $data)));
+                       $this->objectAction = new PageAction(array($this->page), 'update', array('data' => array_merge($this->additionalFields, $data), 'boxToPage' => $this->getBoxToPage()));
                        $this->objectAction->executeAction();
                }
                else {
diff --git a/wcfsetup/install/files/lib/system/box/PageCommentsBoxController.class.php b/wcfsetup/install/files/lib/system/box/PageCommentsBoxController.class.php
new file mode 100644 (file)
index 0000000..85a00a6
--- /dev/null
@@ -0,0 +1,50 @@
+<?php
+namespace wcf\system\box;
+use wcf\system\comment\CommentHandler;
+use wcf\system\request\RequestHandler;
+use wcf\system\WCF;
+
+/**
+ * Box for page comments.
+ *
+ * @author     Marcel Werk
+ * @copyright  2001-2016 WoltLab GmbH
+ * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package    com.woltlab.wcf
+ * @subpackage system.box
+ * @category   Community Framework
+ */
+class PageCommentsBoxController extends AbstractBoxController {
+       /**
+        * @inheritDoc
+        */
+       protected $supportedPositions = ['contentTop', 'contentBottom'];
+       
+       /**
+        * @inheritDoc
+        */
+       public function getTitle() {
+               return WCF::getLanguage()->get('wcf.page.comments');
+       }
+       
+       /**
+        * @inheritDoc
+        */
+       protected function loadContent() {
+               $commentObjectTypeID = CommentHandler::getInstance()->getObjectTypeID('com.woltlab.wcf.page');
+               $commentManager = CommentHandler::getInstance()->getObjectType($commentObjectTypeID)->getProcessor();
+               $commentList = CommentHandler::getInstance()->getCommentList($commentManager, $commentObjectTypeID, RequestHandler::getInstance()->getActiveRequest()->getPageID());
+               
+               if (WCF::getSession()->getPermission('user.pageComment.canAddComment') || count($commentList)) {
+                       WCF::getTPL()->assign([
+                               'pageID' => RequestHandler::getInstance()->getActiveRequest()->getPageID(),
+                               'commentCanAdd' => WCF::getSession()->getPermission('user.pageComment.canAddComment'),
+                               'commentList' => $commentList,
+                               'commentObjectTypeID' => $commentObjectTypeID,
+                               'lastCommentTime' => $commentList->getMinCommentTime()
+                       ]);
+                       
+                       $this->content = WCF::getTPL()->fetch('boxPageComments');
+               }       
+       }
+}
diff --git a/wcfsetup/install/files/lib/system/comment/manager/PageCommentManager.class.php b/wcfsetup/install/files/lib/system/comment/manager/PageCommentManager.class.php
new file mode 100644 (file)
index 0000000..4f67d9c
--- /dev/null
@@ -0,0 +1,81 @@
+<?php
+namespace wcf\system\comment\manager;
+use wcf\system\request\LinkHandler;
+
+/**
+ * Page comment manager implementation.
+ *
+ * @author     Marcel Werk
+ * @copyright  2001-2016 WoltLab GmbH
+ * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package    com.woltlab.wcf
+ * @subpackage system.comment.manager
+ * @category   Community Framework
+ */
+class PageCommentManager extends AbstractCommentManager {
+       /**
+        * @inheritDoc
+        */
+       protected $permissionAdd = 'user.pageComment.canAddComment';
+       
+       /**
+        * @inheritDoc
+        */
+       protected $permissionDelete = 'user.pageComment.canDeleteComment';
+       
+       /**
+        * @inheritDoc
+        */
+       protected $permissionEdit = 'user.pageComment.canEditComment';
+       
+       /**
+        * @inheritDoc
+        */
+       protected $permissionModDelete = 'mod.pageComment.canDeleteComment';
+       
+       /**
+        * @inheritDoc
+        */
+       protected $permissionModEdit = 'mod.pageComment.canEditComment';
+       
+       /**
+        * @inheritDoc
+        */
+       public function isAccessible($objectID, $validateWritePermission = false) {
+               // @todo
+               return true;
+       }
+       
+       /**
+        * @inheritDoc
+        */
+       public function getLink($objectTypeID, $objectID) {
+               return LinkHandler::getInstance()->getCmsLink($objectID);
+       }
+       
+       /**
+        * @inheritDoc
+        */
+       public function getTitle($objectTypeID, $objectID, $isResponse = false) {
+               return '';
+       }
+       
+       /**
+        * @inheritDoc
+        */
+       public function updateCounter($objectID, $value) {}
+       
+       /**
+        * @inheritDoc
+        */
+       public function supportsLike() {
+               return false;
+       }
+       
+       /**
+        * @inheritDoc
+        */
+       public function supportsReport() {
+               return false;
+       }
+}
index bd1e6ed120d0880030d63b3554155d9903caf4d9..4797657fc353c6d1e9d2e0cc1aac342db2936b22 100644 (file)
@@ -2567,6 +2567,7 @@ Fehler sind beispielsweise:
                <item name="wcf.page.onlineLocation.com.woltlab.wcf.AvatarEdit"><![CDATA[Avatar-Verwaltung]]></item>
                <item name="wcf.page.onlineLocation.com.woltlab.wcf.Settings"><![CDATA[Einstellungen]]></item>
                <item name="wcf.page.onlineLocation.com.woltlab.wcf.SignatureEdit"><![CDATA[Signatur-Verwaltung]]></item>
+               <item name="wcf.page.comments"><![CDATA[Kommentare]]></item>
        </category>
        
        <category name="wcf.paidSubscription">
index 2234c3d5e7ac6635c1f5a03d3a8b57f2cba0674b..96e6b176b6478e1e23a6986ec6ae8adcbaa357f8 100644 (file)
@@ -2604,6 +2604,7 @@ Errors are:
                <item name="wcf.page.onlineLocation.com.woltlab.wcf.AvatarEdit"><![CDATA[Avatar Management]]></item>
                <item name="wcf.page.onlineLocation.com.woltlab.wcf.Settings"><![CDATA[Settings]]></item>
                <item name="wcf.page.onlineLocation.com.woltlab.wcf.SignatureEdit"><![CDATA[Signature Management]]></item>
+               <item name="wcf.page.comments"><![CDATA[Comments]]></item>
        </category>
        
        <category name="wcf.paidSubscription">