Commit | Line | Data |
---|---|---|
285b1d92 MW |
1 | <?php |
2 | namespace wcf\system\comment\manager; | |
0d76d267 MS |
3 | use wcf\data\comment\response\CommentResponse; |
4 | use wcf\data\comment\Comment; | |
285b1d92 MW |
5 | use wcf\data\user\UserProfile; |
6 | use wcf\system\request\LinkHandler; | |
7 | use wcf\system\WCF; | |
8 | ||
9 | /** | |
10 | * User profile comment manager implementation. | |
11 | * | |
12 | * @author Alexander Ebert | |
ca4ba303 | 13 | * @copyright 2001-2014 WoltLab GmbH |
285b1d92 | 14 | * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php> |
f4f05aa5 | 15 | * @package com.woltlab.wcf |
285b1d92 MW |
16 | * @subpackage system.comment.manager |
17 | * @category Community Framework | |
18 | */ | |
19 | class UserProfileCommentManager extends AbstractCommentManager { | |
20 | /** | |
0ad90fc3 | 21 | * @see \wcf\system\comment\manager\AbstractCommentManager::$permissionAdd |
285b1d92 MW |
22 | */ |
23 | protected $permissionAdd = 'user.profileComment.canAddComment'; | |
24 | ||
25 | /** | |
0ad90fc3 | 26 | * @see \wcf\system\comment\manager\AbstractCommentManager::$permissionCanModerate |
285b1d92 MW |
27 | */ |
28 | protected $permissionCanModerate = 'mod.profileComment.canModerateComment'; | |
29 | ||
30 | /** | |
0ad90fc3 | 31 | * @see \wcf\system\comment\manager\AbstractCommentManager::$permissionDelete |
285b1d92 MW |
32 | */ |
33 | protected $permissionDelete = 'user.profileComment.canDeleteComment'; | |
34 | ||
35 | /** | |
0ad90fc3 | 36 | * @see \wcf\system\comment\manager\AbstractCommentManager::$permissionEdit |
285b1d92 MW |
37 | */ |
38 | protected $permissionEdit = 'user.profileComment.canEditComment'; | |
39 | ||
40 | /** | |
0ad90fc3 | 41 | * @see \wcf\system\comment\manager\AbstractCommentManager::$permissionModDelete |
285b1d92 MW |
42 | */ |
43 | protected $permissionModDelete = 'mod.profileComment.canDeleteComment'; | |
44 | ||
45 | /** | |
0ad90fc3 | 46 | * @see \wcf\system\comment\manager\AbstractCommentManager::$permissionModEdit |
285b1d92 MW |
47 | */ |
48 | protected $permissionModEdit = 'mod.profileComment.canEditComment'; | |
49 | ||
50 | /** | |
0ad90fc3 | 51 | * @see \wcf\system\comment\manager\ICommentManager::isAccessible() |
285b1d92 MW |
52 | */ |
53 | public function isAccessible($objectID, $validateWritePermission = false) { | |
54 | // check object id | |
55 | $userProfile = UserProfile::getUserProfile($objectID); | |
56 | if ($userProfile === null) { | |
57 | return false; | |
58 | } | |
59 | ||
60 | // check visibility | |
61 | if ($userProfile->isProtected()) { | |
62 | return false; | |
63 | } | |
64 | ||
65 | // check target user settings | |
66 | if ($validateWritePermission) { | |
67 | if (!$userProfile->isAccessible('canWriteProfileComments') && $userProfile->userID != WCF::getUser()->userID) { | |
68 | return false; | |
69 | } | |
70 | ||
71 | if ($userProfile->isIgnoredUser(WCF::getUser()->userID)) { | |
72 | return false; | |
73 | } | |
74 | } | |
75 | ||
76 | return true; | |
77 | } | |
78 | ||
79 | /** | |
0ad90fc3 | 80 | * @see \wcf\system\comment\manager\ICommentManager::getLink() |
285b1d92 MW |
81 | */ |
82 | public function getLink($objectTypeID, $objectID) { | |
83 | return LinkHandler::getInstance()->getLink('User', array('id' => $objectID)); | |
84 | } | |
85 | ||
86 | /** | |
0ad90fc3 | 87 | * @see \wcf\system\comment\manager\ICommentManager::getTitle() |
285b1d92 MW |
88 | */ |
89 | public function getTitle($objectTypeID, $objectID, $isResponse = false) { | |
90 | if ($isResponse) return WCF::getLanguage()->get('wcf.user.profile.content.wall.commentResponse'); | |
91 | ||
92 | return WCF::getLanguage()->getDynamicVariable('wcf.user.profile.content.wall.comment'); | |
93 | } | |
94 | ||
95 | /** | |
0ad90fc3 | 96 | * @see \wcf\system\comment\manager\ICommentManager::updateCounter() |
285b1d92 | 97 | */ |
0d76d267 MS |
98 | public function updateCounter($objectID, $value) { |
99 | // does nothing | |
100 | } | |
101 | ||
102 | /** | |
103 | * @see \wcf\system\comment\manager\ICommentManager::canDeleteComment() | |
104 | */ | |
105 | public function canDeleteComment(Comment $comment) { | |
106 | if ($comment->objectID == WCF::getUser()->userID && WCF::getSession()->getPermission('user.profileComment.canDeleteCommentInOwnProfile')) { | |
107 | return true; | |
108 | } | |
109 | ||
110 | return parent::canDeleteComment($comment); | |
111 | } | |
112 | ||
113 | /** | |
114 | * @see \wcf\system\comment\manager\ICommentManager::canDeleteResponse() | |
115 | */ | |
116 | public function canDeleteResponse(CommentResponse $response) { | |
117 | if ($response->getComment()->objectID == WCF::getUser()->userID && WCF::getSession()->getPermission('user.profileComment.canDeleteCommentInOwnProfile')) { | |
118 | return true; | |
119 | } | |
120 | ||
121 | return parent::canDeleteResponse($response); | |
122 | } | |
285b1d92 | 123 | } |