<ul class="sidebarBoxList">
{foreach from=$eventList item=event}
- <li class="box24">
+ <li class="box24{if $__wcf->getUserProfileHandler()->isIgnoredUser($event->getUserProfile()->userID)} ignoredUserContent{/if}">
<a href="{link controller='User' object=$event->getUserProfile()}{/link}" title="{$event->getUserProfile()->username}">{@$event->getUserProfile()->getAvatar()->getImageTag(24)}</a>
<div class="sidebarBoxHeadline">
{foreach from=$eventList item=event}
<li>
- <div class="box48">
+ <div class="box48{if $__wcf->getUserProfileHandler()->isIgnoredUser($event->getUserProfile()->userID)} ignoredUserContent{/if}">
<a href="{link controller='User' object=$event->getUserProfile()}{/link}" title="{$event->getUserProfile()->username}">{@$event->getUserProfile()->getAvatar()->getImageTag(48)}</a>
<div>
'wcf.user.button.unignore': '{lang}wcf.user.button.unignore{/lang}'
});
- new UiUserProfileMenuItemFollow({@$user->userID}, {if $__wcf->getUserProfileHandler()->isFollowing($user->userID)}true{else}false{/if});
+ {if !$user->isIgnoredUser($__wcf->user->userID)}
+ new UiUserProfileMenuItemFollow({@$user->userID}, {if $__wcf->getUserProfileHandler()->isFollowing($user->userID)}true{else}false{/if});
+ {/if}
{if !$user->getPermission('user.profile.cannotBeIgnored')}
- new UiUserProfileMenuItemIgnore({@$user->userID}, {if $__wcf->getUserProfileHandler()->isIgnoredUser($user->userID)}true{else}false{/if});
+ new UiUserProfileMenuItemIgnore({@$user->userID}, {if $__wcf->getUserProfileHandler()->isIgnoredUser($user->userID)}true{else}false{/if});
{/if}
});
{/if}
define(
[
'Ajax', 'WoltLab/WCF/Bootstrap', 'WoltLab/WCF/Controller/Sitemap', 'WoltLab/WCF/Controller/Style/Changer',
- 'WoltLab/WCF/Controller/Popover', 'WoltLab/WCF/Ui/Page/JumpToTop'
+ 'WoltLab/WCF/Controller/Popover', 'WoltLab/WCF/Ui/Page/JumpToTop', 'WoltLab/WCF/Ui/User/Ignore'
],
function(
Ajax, Bootstrap, ControllerSitemap, ControllerStyleChanger,
- ControllerPopover, UiPageJumpToTop
+ ControllerPopover, UiPageJumpToTop, UiUserIgnore
)
{
"use strict";
this._invokeBackgroundQueue(options.backgroundQueue.url, options.backgroundQueue.force);
new UiPageJumpToTop();
+
+ UiUserIgnore.init();
},
/**
--- /dev/null
+/**
+ * Provides global helper methods to interact with ignored content.
+ *
+ * @author Alexander Ebert
+ * @copyright 2001-2016 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @module WoltLab/WCF/Ui/User/Ignore
+ */
+define(['List', 'Dom/ChangeListener'], function(List, DomChangeListener) {
+ "use strict";
+
+ var _availableMessages = elByClass('ignoredUserMessage');
+ var _callback = null;
+ var _knownMessages = new List();
+
+ /**
+ * @exports WoltLab/WCF/Ui/User/Ignore
+ */
+ return {
+ /**
+ * Initializes the click handler for each ignored message and listens for
+ * newly inserted messages.
+ */
+ init: function () {
+ _callback = this._removeClass.bind(this);
+
+ this._rebuild();
+
+ DomChangeListener.add('WoltLab/WCF/Ui/User/Ignore', this._rebuild.bind(this));
+ },
+
+ /**
+ * Adds ignored messages to the collection.
+ *
+ * @protected
+ */
+ _rebuild: function() {
+ var message;
+ for (var i = 0, length = _availableMessages.length; i < length; i++) {
+ message = _availableMessages[i];
+
+ if (!_knownMessages.has(message)) {
+ message.addEventListener(WCF_CLICK_EVENT, _callback);
+
+ _knownMessages.add(message);
+ }
+ }
+ },
+
+ /**
+ * Reveals a message on click/tap and disables the listener.
+ *
+ * @param {Event} event event object
+ * @protected
+ */
+ _removeClass: function(event) {
+ event.preventDefault();
+
+ var message = event.currentTarget;
+ message.classList.remove('ignoredUserMessage');
+ message.removeEventListener(WCF_CLICK_EVENT, _callback);
+ _knownMessages.delete(message);
+ }
+ };
+});
public function validateFollow() {
$this->readInteger('userID', false, 'data');
- // validate if you're retarded
if ($this->parameters['data']['userID'] == WCF::getUser()->userID) {
throw new PermissionDeniedException();
}
+
+ // check if current user is ignored by target user
+ $sql = "SELECT ignoreID
+ FROM wcf".WCF_N."_user_ignore
+ WHERE userID = ?
+ AND ignoreUserID = ?";
+ $statement = WCF::getDB()->prepareStatement($sql);
+ $statement->execute([
+ $this->parameters['data']['userID'],
+ WCF::getUser()->userID
+ ]);
+
+ $ignoreID = $statement->fetchSingleColumn();
+ if ($ignoreID !== false) {
+ throw new PermissionDeniedException();
+ }
}
/**
<?php
namespace wcf\data\user\ignore;
use wcf\data\AbstractDatabaseObjectAction;
+use wcf\data\user\follow\UserFollow;
+use wcf\data\user\follow\UserFollowEditor;
use wcf\system\cache\runtime\UserProfileRuntimeCache;
use wcf\system\exception\IllegalLinkException;
use wcf\system\exception\PermissionDeniedException;
* Executes ignored user-related actions.
*
* @author Alexander Ebert
- * @copyright 2001-2015 WoltLab GmbH
+ * @copyright 2001-2016 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @package com.woltlab.wcf
* @subpackage data.user.ignore
$ignore = UserIgnore::getIgnore($this->parameters['data']['userID']);
if (!$ignore->ignoreID) {
- UserIgnoreEditor::create(array(
+ UserIgnoreEditor::create([
'ignoreUserID' => $this->parameters['data']['userID'],
'time' => TIME_NOW,
'userID' => WCF::getUser()->userID,
- ));
+ ]);
- UserStorageHandler::getInstance()->reset(array(WCF::getUser()->userID), 'ignoredUserIDs');
+ UserStorageHandler::getInstance()->reset([WCF::getUser()->userID], 'ignoredUserIDs');
+
+ // check if target user is following the current user
+ $sql = "SELECT *
+ FROM wcf".WCF_N."_user_follow
+ WHERE userID = ?
+ AND followUserID = ?";
+ $statement = WCF::getDB()->prepareStatement($sql);
+ $statement->execute([
+ $this->parameters['data']['userID'],
+ WCF::getUser()->userID
+ ]);
+
+ $follow = $statement->fetchObject(UserFollow::class);
+
+ // remove follower
+ if ($follow !== null) {
+ $followEditor = new UserFollowEditor($follow);
+ $followEditor->delete();
+
+ // reset storage
+ UserStorageHandler::getInstance()->reset([WCF::getUser()->userID], 'followerUserIDs');
+ UserStorageHandler::getInstance()->reset([$this->parameters['data']['userID']], 'followingUserIDs');
+ }
}
- return array('isIgnoredUser' => 1);
+ return ['isIgnoredUser' => 1];
}
/**
$ignoreEditor = new UserIgnoreEditor($ignore);
$ignoreEditor->delete();
- UserStorageHandler::getInstance()->reset(array(WCF::getUser()->userID), 'ignoredUserIDs');
+ UserStorageHandler::getInstance()->reset([WCF::getUser()->userID], 'ignoredUserIDs');
}
- return array('isIgnoredUser' => 0);
+ return ['isIgnoredUser' => 0];
}
/**
$returnValues = parent::delete();
// reset storage
- UserStorageHandler::getInstance()->reset(array(WCF::getUser()->userID), 'ignoredUserIDs');
+ UserStorageHandler::getInstance()->reset([WCF::getUser()->userID], 'ignoredUserIDs');
return $returnValues;
}
--- /dev/null
+/* reduces the visual impact of content by ignored users */
+.ignoredUserContent {
+ /* no grayscale filter in IE11 due to completely lacking support */
+
+ filter: grayscale(100%) !important; /* Firefox, Edge */
+ -webkit-filter: grayscale(100%) !important; /* Chrome, Safari, Opera */
+
+ &:not(:hover) {
+ opacity: .5 !important;
+ }
+}
+
+.ignoredUserMessage {
+ background-color: $wcfStatusInfoBackground !important;
+ border-left: 5px solid $wcfStatusInfoBorder !important;
+ color: $wcfStatusInfoText !important;
+ cursor: pointer !important;
+
+ &::before {
+ content: attr(data-ignored-user-message);
+
+ @include screen-md-up {
+ padding: 10px 20px;
+ }
+
+ @include screen-sm-down {
+ padding: 10px;
+ }
+ }
+
+ > * {
+ display: none;
+ }
+}