use wcf\data\comment\response\StructuredCommentResponse;
use wcf\data\user\User;
use wcf\data\user\UserProfile;
-use wcf\data\user\UserProfileCache;
use wcf\data\DatabaseObjectDecorator;
+use wcf\system\cache\runtime\UserProfileRuntimeCache;
/**
* Provides methods to handle responses for this comment.
*
* @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.comment
*/
class StructuredComment extends DatabaseObjectDecorator implements \Countable, \Iterator {
/**
- * @see \wcf\data\DatabaseObjectDecorator::$baseClass
+ * @inheritDoc
*/
- public static $baseClass = 'wcf\data\comment\Comment';
+ public static $baseClass = Comment::class;
/**
* list of ordered responses
- * @var array<\wcf\data\comment\response\StructuredCommentResponse>
+ * @var StructuredCommentResponse[]
*/
- protected $responses = array();
+ protected $responses = [];
/**
* deletable by current user
private $position = 0;
/**
- * user profile object
- * @var \wcf\data\user\UserProfile
+ * user profile object of the comment author
+ * @var UserProfile
*/
public $userProfile = null;
/**
* Adds an response
*
- * @param \wcf\data\comment\response\StructuredCommentResponse $response
+ * @param StructuredCommentResponse $response
*/
public function addResponse(StructuredCommentResponse $response) {
$this->responses[] = $response;
/**
* Returns the last responses for this comment.
*
- * @return array<\wcf\data\comment\response\StructuredCommentResponse>
+ * @return StructuredCommentResponse[]
*/
public function getResponses() {
return $this->responses;
/**
* Sets the user's profile.
*
- * @param \wcf\data\user\UserProfile $userProfile
+ * @param UserProfile $userProfile
*/
public function setUserProfile(UserProfile $userProfile) {
$this->userProfile = $userProfile;
/**
* Returns the user's profile.
*
- * @return \wcf\data\user\UserProfile
+ * @return UserProfile
*/
public function getUserProfile() {
if ($this->userProfile === null) {
if ($this->userID) {
- $this->userProfile = UserProfileCache::getInstance()->getUserProfile($this->userID);
+ $this->userProfile = UserProfileRuntimeCache::getInstance()->getObject($this->userID);
}
else {
- $this->userProfile = new UserProfile(new User(null, array(
+ $this->userProfile = new UserProfile(new User(null, [
'username' => $this->username
- )));
+ ]));
}
}
namespace wcf\data\comment;
use wcf\data\comment\response\CommentResponseList;
use wcf\data\comment\response\StructuredCommentResponse;
-use wcf\data\user\UserProfileCache;
+use wcf\data\like\object\LikeObject;
+use wcf\system\cache\runtime\UserProfileRuntimeCache;
use wcf\system\comment\manager\ICommentManager;
use wcf\system\like\LikeHandler;
* Provides a structured comment list fetching last responses for every comment.
*
* @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.comment
class StructuredCommentList extends CommentList {
/**
* comment manager object
- * @var \wcf\system\comment\manager\ICommentManager
+ * @var ICommentManager
*/
public $commentManager = null;
/**
* ids of the responses of the comments in the list
- * @var array<integer>
+ * @var integer[]
*/
- public $responseIDs = array();
+ public $responseIDs = [];
/**
- * @see \wcf\data\DatabaseObjectList::$decoratorClassName
+ * @inheritDoc
*/
public $decoratorClassName = StructuredComment::class;
/**
- * @see \wcf\data\DatabaseObjectList::$sqlLimit
+ * @inheritDoc
*/
public $sqlLimit = 30;
/**
- * @see \wcf\data\DatabaseObjectList::$sqlOrderBy
+ * @inheritDoc
*/
public $sqlOrderBy = 'comment.time DESC';
/**
* Creates a new structured comment list.
*
- * @param \wcf\system\comment\manager\ICommentManager $commentManager
- * @param integer $objectTypeID
- * @param integer $objectID
+ * @param ICommentManager $commentManager
+ * @param integer $objectTypeID
+ * @param integer $objectID
*/
public function __construct(ICommentManager $commentManager, $objectTypeID, $objectID) {
parent::__construct();
$this->objectTypeID = $objectTypeID;
$this->objectID = $objectID;
- $this->getConditionBuilder()->add("comment.objectTypeID = ?", array($objectTypeID));
- $this->getConditionBuilder()->add("comment.objectID = ?", array($objectID));
+ $this->getConditionBuilder()->add("comment.objectTypeID = ?", [$objectTypeID]);
+ $this->getConditionBuilder()->add("comment.objectID = ?", [$objectID]);
$this->sqlLimit = $this->commentManager->getCommentsPerPage();
}
/**
- * @see \wcf\data\DatabaseObjectList::readObjects()
+ * @inheritDoc
*/
public function readObjects() {
parent::readObjects();
// fetch response ids
- $responseIDs = $userIDs = array();
+ $responseIDs = $userIDs = [];
foreach ($this->objects as $comment) {
if (!$this->minCommentTime || $comment->time < $this->minCommentTime) $this->minCommentTime = $comment->time;
$commentResponseIDs = $comment->getResponseIDs();
// cache user ids
if (!empty($userIDs)) {
- UserProfileCache::getInstance()->cacheUserIDs(array_unique($userIDs));
+ UserProfileRuntimeCache::getInstance()->cacheObjectIDs(array_unique($userIDs));
}
}
/**
* Fetches the like data.
*
- * @return array
+ * @return LikeObject[][]
*/
public function getLikeData() {
- if (empty($this->objectIDs)) return array();
+ if (empty($this->objectIDs)) return [];
- $likeData = array();
+ $likeData = [];
$commentObjectType = LikeHandler::getInstance()->getObjectType('com.woltlab.wcf.comment');
LikeHandler::getInstance()->loadLikeObjects($commentObjectType, $this->getObjectIDs());
$likeData['comment'] = LikeHandler::getInstance()->getLikeObjects($commentObjectType);
/**
* Returns the comment manager object.
*
- * @return \wcf\system\comment\manager\ICommentManager
+ * @return ICommentManager
*/
public function getCommentManager() {
return $this->commentManager;
namespace wcf\data\comment;
use wcf\data\user\User;
use wcf\data\user\UserProfile;
-use wcf\data\user\UserProfileCache;
use wcf\data\DatabaseObjectDecorator;
use wcf\data\TLegacyUserPropertyAccess;
+use wcf\system\cache\runtime\UserProfileRuntimeCache;
/**
* Represents a viewable comment.
*
* @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.comment
use TLegacyUserPropertyAccess;
/**
- * @see \wcf\data\DatabaseObjectDecorator::$baseClass
+ * @inheritDoc
*/
- protected static $baseClass = 'wcf\data\comment\Comment';
+ protected static $baseClass = Comment::class;
/**
- * user profile object
- * @var \wcf\data\user\UserProfile
+ * user profile of the comment author
+ * @var UserProfile
*/
protected $userProfile = null;
/**
* Returns the user profile object.
*
- * @return \wcf\data\user\UserProfile
+ * @return UserProfile
*/
public function getUserProfile() {
if ($this->userProfile === null) {
if ($this->userID) {
- $this->userProfile = UserProfileCache::getInstance()->getUserProfile($this->userID);
+ $this->userProfile = UserProfileRuntimeCache::getInstance()->getObject($this->userID);
}
else {
- $this->userProfile = new UserProfile(new User(null, array(
+ $this->userProfile = new UserProfile(new User(null, [
'username' => $this->username
- )));
+ ]));
}
}
}
/**
- * Gets a specific comment decorated as comment entry.
+ * Returns a specific comment decorated as comment entry.
*
* @param integer $commentID
- * @return \wcf\data\comment\ViewableComment
+ * @return ViewableComment
*/
public static function getComment($commentID) {
$list = new ViewableCommentList();
- $list->setObjectIDs(array($commentID));
+ $list->setObjectIDs([$commentID]);
$list->readObjects();
$objects = $list->getObjects();
if (isset($objects[$commentID])) return $objects[$commentID];
<?php
namespace wcf\data\comment;
-use wcf\data\user\UserProfileCache;
+use wcf\system\cache\runtime\UserProfileRuntimeCache;
/**
* Represents a list of decorated comment objects.
*
* @author Marcel Werk
- * @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.comment
*/
class ViewableCommentList extends CommentList {
/**
- * @see \wcf\data\DatabaseObjectList::$decoratorClassName
+ * @inheritDoc
*/
- public $decoratorClassName = 'wcf\data\comment\ViewableComment';
+ public $decoratorClassName = ViewableComment::class;
+ /**
+ * @inheritDoc
+ */
public function readObjects() {
parent::readObjects();
if (!empty($this->objects)) {
- $userIDs = array();
+ $userIDs = [];
foreach ($this->objects as $comment) {
if ($comment->userID) {
$userIDs[] = $comment->userID;
}
if (!empty($userIDs)) {
- UserProfileCache::getInstance()->cacheUserIDs($userIDs);
+ UserProfileRuntimeCache::getInstance()->cacheObjectIDs($userIDs);
}
}
}
namespace wcf\data\comment\response;
use wcf\data\user\User;
use wcf\data\user\UserProfile;
-use wcf\data\user\UserProfileCache;
use wcf\data\DatabaseObjectDecorator;
+use wcf\system\cache\runtime\UserProfileRuntimeCache;
/**
* Provides methods to handle response data.
*
* @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.comment.response
*/
class StructuredCommentResponse extends DatabaseObjectDecorator {
/**
- * @see \wcf\data\DatabaseObjectDecorator::$baseClass
+ * @inheritDoc
*/
- public static $baseClass = 'wcf\data\comment\response\CommentResponse';
+ public static $baseClass = CommentResponse::class;
/**
* deletable by current user
public $editable = false;
/**
- * user profile object
- * @var \wcf\data\user\UserProfile
+ * user profile of the comment response author
+ * @var UserProfile
*/
public $userProfile = null;
/**
* Sets the user's profile.
*
- * @param \wcf\data\user\UserProfile $userProfile
+ * @param UserProfile $userProfile
*/
public function setUserProfile(UserProfile $userProfile) {
$this->userProfile = $userProfile;
/**
* Returns the user's profile.
*
- * @return \wcf\data\user\UserProfile
+ * @return UserProfile
*/
public function getUserProfile() {
if ($this->userProfile === null) {
if ($this->userID) {
- $this->userProfile = UserProfileCache::getInstance()->getUserProfile($this->userID);
+ $this->userProfile = UserProfileRuntimeCache::getInstance()->getObject($this->userID);
}
else {
$this->userProfile = new UserProfile(new User(null, array(
* Returns a structured response.
*
* @param integer $responseID
- * @return \wcf\data\comment\response\StructuredCommentResponse
+ * @return StructuredCommentResponse
*/
public static function getResponse($responseID) {
$response = new CommentResponse($responseID);
// cache user profile
if ($response->userID) {
- UserProfileCache::getInstance()->cacheUserID($response->userID);
+ UserProfileRuntimeCache::getInstance()->cacheObjectID($response->userID);
}
return $response;
<?php
namespace wcf\data\comment\response;
use wcf\data\comment\Comment;
-use wcf\data\user\UserProfileCache;
+use wcf\data\like\object\LikeObject;
+use wcf\system\cache\runtime\UserProfileRuntimeCache;
use wcf\system\comment\manager\ICommentManager;
use wcf\system\like\LikeHandler;
* Provides a structured comment response list.
*
* @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.comment.response
class StructuredCommentResponseList extends CommentResponseList {
/**
* comment object
- * @var \wcf\data\comment\Comment;
+ * @var Comment;
*/
public $comment = null;
/**
* comment manager
- * @var \wcf\system\comment\manager\ICommentManager
+ * @var ICommentManager
*/
public $commentManager = null;
public $minResponseTime = 0;
/**
- * @see \wcf\data\DatabaseObjectList::$decoratorClassName
+ * @inheritDoc
*/
public $decoratorClassName = StructuredCommentResponse::class;
/**
- * @see \wcf\data\DatabaseObjectList::$sqlLimit
+ * @inheritDoc
*/
public $sqlLimit = 50;
/**
* Creates a new structured comment response list.
*
- * @param \wcf\system\comment\manager\ICommentManager $commentManager
- * @param \wcf\data\comment\Comment $comment
+ * @param ICommentManager $commentManager
+ * @param Comment $comment
*/
public function __construct(ICommentManager $commentManager, Comment $comment) {
parent::__construct();
$this->comment = $comment;
$this->commentManager = $commentManager;
- $this->getConditionBuilder()->add("comment_response.commentID = ?", array($this->comment->commentID));
+ $this->getConditionBuilder()->add("comment_response.commentID = ?", [$this->comment->commentID]);
$this->sqlLimit = $this->commentManager->getCommentsPerPage();
}
/**
- * @see \wcf\data\DatabaseObjectList::readObjects()
+ * @inheritDoc
*/
public function readObjects() {
parent::readObjects();
// get user ids
- $userIDs = array();
+ $userIDs = [];
foreach ($this->objects as $response) {
if (!$this->minResponseTime || $response->time < $this->minResponseTime) $this->minResponseTime = $response->time;
$userIDs[] = $response->userID;
// cache user ids
if (!empty($userIDs)) {
- UserProfileCache::getInstance()->cacheUserIDs(array_unique($userIDs));
+ UserProfileRuntimeCache::getInstance()->cacheObjectIDs(array_unique($userIDs));
}
}
/**
* Fetches the like data.
*
- * @return array
+ * @return LikeObject[][]
*/
public function getLikeData() {
- if (empty($this->objectIDs)) return array();
+ if (empty($this->objectIDs)) return [];
$objectType = LikeHandler::getInstance()->getObjectType('com.woltlab.wcf.comment.response');
LikeHandler::getInstance()->loadLikeObjects($objectType, $this->objectIDs);
- $likeData = array('response' => LikeHandler::getInstance()->getLikeObjects($objectType));
+ $likeData = ['response' => LikeHandler::getInstance()->getLikeObjects($objectType)];
return $likeData;
}
namespace wcf\data\comment\response;
use wcf\data\user\User;
use wcf\data\user\UserProfile;
-use wcf\data\user\UserProfileCache;
use wcf\data\DatabaseObjectDecorator;
use wcf\data\TLegacyUserPropertyAccess;
+use wcf\system\cache\runtime\UserProfileRuntimeCache;
/**
* Represents a viewable comment response.
*
* @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.comment.response
use TLegacyUserPropertyAccess;
/**
- * @see \wcf\data\DatabaseObjectDecorator::$baseClass
+ * @inheritDoc
*/
- protected static $baseClass = 'wcf\data\comment\response\CommentResponse';
+ protected static $baseClass = CommentResponse::class;
/**
- * user profile object
- * @var \wcf\data\user\UserProfile
+ * user profile of the comment author
+ * @var UserProfile
*/
protected $userProfile = null;
/**
* Returns the user profile object.
*
- * @return \wcf\data\user\UserProfile
+ * @return UserProfile
*/
public function getUserProfile() {
if ($this->userProfile === null) {
if ($this->userID) {
- $this->userProfile = UserProfileCache::getInstance()->getUserProfile($this->userID);
+ $this->userProfile = UserProfileRuntimeCache::getInstance()->getObject($this->userID);
}
else {
- $this->userProfile = new UserProfile(new User(null, array(
+ $this->userProfile = new UserProfile(new User(null, [
'username' => $this->username
- )));
+ ]));
}
}
}
/**
- * Gets a specific comment response decorated as viewable comment response.
+ * Returns a specific comment response decorated as viewable comment response.
*
* @param integer $responseID
- * @return \wcf\data\comment\response\ViewableCommentResponse
+ * @return ViewableCommentResponse
*/
public static function getResponse($responseID) {
$list = new ViewableCommentResponseList();
- $list->setObjectIDs(array($responseID));
+ $list->setObjectIDs([$responseID]);
$list->readObjects();
$objects = $list->getObjects();
if (isset($objects[$responseID])) return $objects[$responseID];
<?php
namespace wcf\data\comment\response;
-use wcf\data\user\UserProfileCache;
+use wcf\system\cache\runtime\UserProfileRuntimeCache;
/**
* Represents a list of decorated comment response objects.
*
* @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.comment.response
*/
class ViewableCommentResponseList extends CommentResponseList {
/**
- * @see \wcf\data\DatabaseObjectList::$decoratorClassName
+ * @inheritDoc
*/
- public $decoratorClassName = 'wcf\data\comment\response\ViewableCommentResponse';
+ public $decoratorClassName = ViewableCommentResponse::class;
+ /**
+ * @inheritDoc
+ */
public function readObjects() {
parent::readObjects();
if (!empty($this->objects)) {
- $userIDs = array();
+ $userIDs = [];
foreach ($this->objects as $response) {
if ($response->userID) {
$userIDs[] = $response->userID;
}
if (!empty($userIDs)) {
- UserProfileCache::getInstance()->cacheUserIDs($userIDs);
+ UserProfileRuntimeCache::getInstance()->cacheObjectIDs($userIDs);
}
}
}
namespace wcf\data\like;
use wcf\data\object\type\ObjectTypeCache;
use wcf\data\user\UserProfile;
-use wcf\data\user\UserProfileCache;
use wcf\data\DatabaseObjectDecorator;
+use wcf\system\cache\runtime\UserProfileRuntimeCache;
/**
* Provides methods for viewable likes.
*
* @author Marcel Werk
- * @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.like
*/
class ViewableLike extends DatabaseObjectDecorator {
/**
- * @see \wcf\data\DatabaseObjectDecorator::$baseClass
+ * @inheritDoc
*/
- public static $baseClass = 'wcf\data\like\Like';
+ public static $baseClass = Like::class;
/**
* event text
/**
* user profile
- * @var \wcf\data\user\UserProfile
+ * @var UserProfile
*/
protected $userProfile = null;
/**
* Sets user profile.
*
- * @param \wcf\data\user\UserProfile $userProfile
+ * @param UserProfile $userProfile
*/
public function setUserProfile(UserProfile $userProfile) {
$this->userProfile = $userProfile;
/**
* Returns user profile.
*
- * @return \wcf\data\user\UserProfile
+ * @return UserProfile
*/
public function getUserProfile() {
if ($this->userProfile === null) {
- $this->userProfile = UserProfileCache::getInstance()->getUserProfile($this->userID);
+ $this->userProfile = UserProfileRuntimeCache::getInstance()->getObject($this->userID);
}
return $this->userProfile;
<?php
namespace wcf\data\like;
use wcf\data\object\type\ObjectTypeCache;
-use wcf\data\user\UserProfileCache;
+use wcf\system\cache\runtime\UserProfileRuntimeCache;
use wcf\system\like\IViewableLikeProvider;
/**
* Represents a list of viewable likes.
*
* @author Marcel Werk
- * @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.like
*/
class ViewableLikeList extends LikeList {
/**
- * @see \wcf\data\DatabaseObjectList::$className
+ * @inheritDoc
*/
- public $className = 'wcf\data\like\Like';
+ public $className = Like::class;
/**
- * @see \wcf\data\DatabaseObjectList::$decoratorClassName
+ * @inheritDoc
*/
public $decoratorClassName = ViewableLike::class;
/**
- * @see \wcf\data\DatabaseObjectList::$sqlLimit
+ * @inheritDoc
*/
public $sqlLimit = 20;
/**
- * @see \wcf\data\DatabaseObjectList::$sqlOrderBy
+ * @inheritDoc
*/
public $sqlOrderBy = 'like_table.time DESC';
/**
- * @see \wcf\data\DatabaseObjectList::readObjects()
+ * @inheritDoc
*/
public function readObjects() {
parent::readObjects();
// set user profiles
if (!empty($userIDs)) {
- UserProfileCache::getInstance()->cacheUserIDs(array_unique($userIDs));
+ UserProfileRuntimeCache::getInstance()->cacheObjectIDs(array_unique($userIDs));
}
// parse like
use wcf\data\object\type\ObjectTypeCache;
use wcf\data\user\User;
use wcf\data\user\UserProfile;
-use wcf\data\user\UserProfileCache;
use wcf\data\DatabaseObjectDecorator;
use wcf\data\ILinkableObject;
use wcf\data\ITitledObject;
use wcf\data\IUserContent;
use wcf\system\bbcode\SimpleMessageParser;
+use wcf\system\cache\runtime\UserProfileRuntimeCache;
use wcf\system\moderation\queue\ModerationQueueManager;
use wcf\system\visitTracker\VisitTracker;
* Represents a viewable moderation queue entry.
*
* @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.moderation.queue
public function getUserProfile() {
if ($this->affectedObject !== null && $this->userProfile === null) {
if ($this->affectedObject->getUserID()) {
- $this->userProfile = UserProfileCache::getInstance()->getUserProfile($this->affectedObject->getUserID());
+ $this->userProfile = UserProfileRuntimeCache::getInstance()->getObject($this->affectedObject->getUserID());
}
else {
$this->userProfile = new UserProfile(new User(null, []));
<?php
namespace wcf\data\moderation\queue;
-use wcf\data\user\UserProfileCache;
+use wcf\system\cache\runtime\UserProfileRuntimeCache;
use wcf\system\moderation\queue\ModerationQueueManager;
use wcf\system\WCF;
* would not work (MySQL is retarded).
*
* @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.moderation.queue
public $loadUserProfiles = false;
/**
- * @see \wcf\data\DatabaseObjectList::$decoratorClassName
+ * @inheritDoc
*/
public $decoratorClassName = ViewableModerationQueue::class;
/**
- * @see \wcf\data\DatabaseObjectList::$useQualifiedShorthand
+ * @inheritDoc
*/
public $useQualifiedShorthand = false;
/**
- * @see \wcf\data\DatabaseObjectList::__construct()
+ * @inheritDoc
*/
public function __construct() {
parent::__construct();
$this->sqlJoins .= " LEFT JOIN wcf".WCF_N."_user assigned_user ON (assigned_user.userID = moderation_queue.assignedUserID)";
$this->sqlJoins .= " LEFT JOIN wcf".WCF_N."_user user_table ON (user_table.userID = moderation_queue.userID)";
$this->getConditionBuilder()->add("moderation_queue_to_user.queueID = moderation_queue.queueID");
- $this->getConditionBuilder()->add("moderation_queue_to_user.userID = ?", array(WCF::getUser()->userID));
- $this->getConditionBuilder()->add("moderation_queue_to_user.isAffected = ?", array(1));
+ $this->getConditionBuilder()->add("moderation_queue_to_user.userID = ?", [WCF::getUser()->userID]);
+ $this->getConditionBuilder()->add("moderation_queue_to_user.isAffected = ?", [1]);
}
/**
- * @see \wcf\data\DatabaseObjectList::readObjects()
+ * @inheritDoc
*/
public function readObjects() {
parent::readObjects();
if (!empty($this->objects)) {
- $objects = array();
+ $objects = [];
foreach ($this->objects as &$object) {
if (!isset($objects[$object->objectTypeID])) {
- $objects[$object->objectTypeID] = array();
+ $objects[$object->objectTypeID] = [];
}
$objects[$object->objectTypeID][] = $object;
}
// check for non-existant items
- $queueIDs = array();
+ $queueIDs = [];
foreach ($this->objects as $index => $object) {
if ($object->isOrphaned()) {
$queueIDs[] = $object->queueID;
}
if ($this->loadUserProfiles) {
- $userIDs = array();
+ $userIDs = [];
foreach ($this->objects as $object) {
$userIDs[] = $object->getAffectedObject()->getUserID();
}
- UserProfileCache::getInstance()->cacheUserIDs(array_unique($userIDs));
+ UserProfileRuntimeCache::getInstance()->cacheObjectIDs(array_unique($userIDs));
}
}
}
namespace wcf\data\user;
use wcf\data\user\avatar\DefaultAvatar;
use wcf\data\user\avatar\Gravatar;
+use wcf\data\user\avatar\IUserAvatar;
use wcf\data\user\avatar\UserAvatar;
use wcf\data\user\group\UserGroup;
use wcf\data\user\online\UserOnline;
use wcf\system\breadcrumb\Breadcrumb;
use wcf\system\breadcrumb\IBreadcrumbProvider;
use wcf\system\cache\builder\UserGroupPermissionCacheBuilder;
+use wcf\system\cache\runtime\UserProfileRuntimeCache;
use wcf\system\request\LinkHandler;
use wcf\system\user\online\location\UserOnlineLocationHandler;
use wcf\system\user\signature\SignatureCache;
* Decorates the user object and provides functions to retrieve data for user profiles.
*
* @author Marcel Werk
- * @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
*/
class UserProfile extends DatabaseObjectDecorator implements IBreadcrumbProvider {
/**
- * @see \wcf\data\DatabaseObjectDecorator::$baseClass
+ * @inheritDoc
*/
- protected static $baseClass = 'wcf\data\user\User';
+ protected static $baseClass = User::class;
/**
* cached list of user profiles
- * @var array<\wcf\data\user\UserProfile>
+ * @var UserProfile[]
*/
- protected static $userProfiles = array();
+ protected static $userProfiles = [];
/**
* list of ignored user ids
- * @var array<integer>
+ * @var integer[]
*/
protected $ignoredUserIDs = null;
/**
* list of follower user ids
- * @var array<integer>
+ * @var integer[]
*/
protected $followerUserIDs = null;
/**
* list of following user ids
- * @var array<integer>
+ * @var integer[]
*/
protected $followingUserIDs = null;
/**
* user avatar
- * @var \wcf\data\user\avatar\IUserAvatar
+ * @var IUserAvatar
*/
protected $avatar = null;
/**
* user rank object
- * @var \wcf\data\user\rank\UserRank
+ * @var UserRank
*/
protected $rank = null;
const ACCESS_NOBODY = 3;
/**
- * @see \wcf\data\user\User::__toString()
+ * @inheritDoc
*/
public function __toString() {
return $this->getDecoratedObject()->__toString();
/**
* Returns a list of all user ids being followed by current user.
*
- * @return array<integer>
+ * @return integer[]
*/
public function getFollowingUsers() {
if ($this->followingUserIDs === null) {
- $this->followingUserIDs = array();
+ $this->followingUserIDs = [];
if ($this->userID) {
// get ids
FROM wcf".WCF_N."_user_follow
WHERE userID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($this->userID));
+ $statement->execute([$this->userID]);
while ($row = $statement->fetchArray()) {
$this->followingUserIDs[] = $row['followUserID'];
}
/**
* Returns a list of user ids following current user.
*
- * @return array<integer>
+ * @return integer[]
*/
public function getFollowers() {
if ($this->followerUserIDs === null) {
- $this->followerUserIDs = array();
+ $this->followerUserIDs = [];
if ($this->userID) {
// get ids
FROM wcf".WCF_N."_user_follow
WHERE followUserID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($this->userID));
+ $statement->execute([$this->userID]);
while ($row = $statement->fetchArray()) {
$this->followerUserIDs[] = $row['userID'];
}
/**
* Returns a list of ignored user ids.
*
- * @return array<integer>
+ * @return integer[]
*/
public function getIgnoredUsers() {
if ($this->ignoredUserIDs === null) {
- $this->ignoredUserIDs = array();
+ $this->ignoredUserIDs = [];
if ($this->userID) {
// get ids
FROM wcf".WCF_N."_user_ignore
WHERE userID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(array($this->userID));
+ $statement->execute([$this->userID]);
while ($row = $statement->fetchArray()) {
$this->ignoredUserIDs[] = $row['ignoreUserID'];
}
}
/**
- * Gets the user's avatar.
+ * Returns the user's avatar.
*
- * @return \wcf\data\user\avatar\IUserAvatar
+ * @return IUserAvatar
*/
public function getAvatar() {
if ($this->avatar === null) {
public function getCurrentLocation() {
if ($this->currentLocation === null) {
$this->currentLocation = '';
- $this->currentLocation = UserOnlineLocationHandler::getInstance()->getLocation(new UserOnline(new User(null, array(
+ $this->currentLocation = UserOnlineLocationHandler::getInstance()->getLocation(new UserOnline(new User(null, [
'controller' => $this->controller,
'objectID' => $this->locationObjectID
- ))));
+ ])));
}
return $this->currentLocation;
* Returns a new user profile object.
*
* @param integer $userID
- * @return \wcf\data\user\UserProfile
- * @deprecated use UserProfileCache::getUserProfile()
+ * @return UserProfile
+ * @deprecated since 2.2, use UserProfileRuntimeCache::getObject()
*/
public static function getUserProfile($userID) {
- return UserProfileCache::getInstance()->getUserProfile($userID);
+ return UserProfileRuntimeCache::getInstance()->getObject($userID);
}
/**
* Returns a list of user profiles.
*
- * @param array $userIDs
- * @return array<\wcf\data\user\UserProfile>
- * @deprecated use UserProfileCache::getUserProfiles()
+ * @param integer[] $userIDs
+ * @return UserProfile[]
+ * @deprecated since 2.2, use UserProfileRuntimeCache::getObjects()
*/
public static function getUserProfiles(array $userIDs) {
- $users = UserProfileCache::getInstance()->getUserProfiles($userIDs);
+ $users = UserProfileRuntimeCache::getInstance()->getObjects($userIDs);
// this method does not return null for non-existing user profiles
foreach ($users as $userID => $user) {
/**
* Returns the user profile of the user with the given name.
*
- * @param string $username
- * @return \wcf\data\user\UserProfile
- * @todo move to UserProfileCache?
+ * @param string $username
+ * @return UserProfile
*/
public static function getUserProfileByUsername($username) {
- $users = self::getUserProfilesByUsername(array($username));
+ $users = self::getUserProfilesByUsername([$username]);
return $users[$username];
}
/**
* Returns the user profiles of the users with the given names.
*
- * @param array<string> $usernames
- * @return array<\wcf\data\user\UserProfile>
- * @todo move to UserProfileCache?
+ * @param string[] $usernames
+ * @return UserProfile[]
*/
public static function getUserProfilesByUsername(array $usernames) {
- $users = array();
+ $users = [];
// save case sensitive usernames
- $caseSensitiveUsernames = array();
+ $caseSensitiveUsernames = [];
foreach ($usernames as &$username) {
$tmp = mb_strtolower($username);
$caseSensitiveUsernames[$tmp] = $username;
unset($username);
// check cache
- $userProfiles = UserProfileCache::getInstance()->getCachedUserProfiles();
+ $userProfiles = UserProfileRuntimeCache::getInstance()->getCachedObjects();
foreach ($usernames as $index => $username) {
foreach ($userProfiles as $user) {
if (mb_strtolower($user->username) === $username) {
if (!empty($usernames)) {
$userList = new UserProfileList();
- $userList->getConditionBuilder()->add("user_table.username IN (?)", array($usernames));
+ $userList->getConditionBuilder()->add("user_table.username IN (?)", [$usernames]);
$userList->readObjects();
foreach ($userList as $user) {
/**
* Returns the user rank.
*
- * @return \wcf\data\user\rank\UserRank
+ * @return UserRank
*/
public function getRank() {
if ($this->rank === null) {
if (MODULE_USER_RANK && $this->rankID) {
if ($this->rankTitle) {
- $this->rank = new UserRank(null, array(
+ $this->rank = new UserRank(null, [
'rankID' => $this->rankID,
'groupID' => $this->groupID,
'requiredPoints' => $this->requiredPoints,
'rankImage' => $this->rankImage,
'repeatImage' => $this->repeatImage,
'requiredGender' => $this->requiredGender
- ));
+ ]);
}
else {
// load storage data
// get group data from cache
$this->groupData = UserGroupPermissionCacheBuilder::getInstance()->getData($this->getGroupIDs());
if (isset($this->groupData['groupIDs']) && $this->groupData['groupIDs'] != $this->getGroupIDs()) {
- $this->groupData = array();
+ $this->groupData = [];
}
}
}
/**
- * @see \wcf\system\breadcrumb\IBreadcrumbProvider::getBreadcrumb()
+ * @inheritDoc
*/
public function getBreadcrumb() {
- return new Breadcrumb($this->username, LinkHandler::getInstance()->getLink('User', array(
+ return new Breadcrumb($this->username, LinkHandler::getInstance()->getLink('User', [
'object' => $this
- )));
+ ]));
}
/**
* @return string
*/
public function getAnchorTag() {
- $link = LinkHandler::getInstance()->getLink('User', array('object' => $this->getDecoratedObject()));
+ $link = LinkHandler::getInstance()->getLink('User', ['object' => $this->getDecoratedObject()]);
return '<a href="'.$link.'" class="userLink" data-user-id="'.$this->userID.'">'.StringUtil::encodeHtml($this->username).'</a>';
}
<?php
namespace wcf\data\user;
+use wcf\system\cache\runtime\UserProfileRuntimeCache;
use wcf\system\SingletonFactory;
/**
* @subpackage data.user
* @category Community Framework
* @since 2.2
+ *
+ * @todo remove this class again
*/
class UserProfileCache extends SingletonFactory {
/**
- * cached user ids whose profiles will be loaded during the next request
- * @var array<integer>
- */
- protected $userIDs = array();
-
- /**
- * locally cached user profiles
- * @var array<\wcf\data\user\UserProfile>
- */
- protected $userProfiles = array();
-
- /**
- * Caches the given user id.
- *
- * @param integer $userID
+ * @see UserProfiltRuntimeCache::cacheObjectID()
*/
public function cacheUserID($userID) {
- $this->userIDs[] = $userID;
+ UserProfileRuntimeCache::getInstance()->cacheObjectID($userID);
}
/**
- * Caches the given user ids.
- *
- * @param array<integer> $userIDs
+ * @see UserProfiltRuntimeCache::cacheUserIDs()
*/
public function cacheUserIDs(array $userIDs) {
- $this->userIDs = array_merge($this->userIDs, $userIDs);
+ UserProfileRuntimeCache::getInstance()->cacheObjectIDs($userIDs);
}
/**
- * Returns all currently cached user profile objects.
- *
- * @return array<\wcf\data\user\UserProfile>
+ * @see UserProfiltRuntimeCache::getCachedObjects()
*/
public function getCachedUserProfiles() {
- return $this->userProfiles;
+ return UserProfileRuntimeCache::getInstance()->getCachedObjects();
}
/**
- * Returns the user profile of the user with the given user id. If no such
- * user profile exists, null is returned.
- *
- * @param integer $userID
- * @return \wcf\data\user\UserProfile
+ * @see UserProfiltRuntimeCache::getObject()
*/
public function getUserProfile($userID) {
- if (array_key_exists($userID, $this->userProfiles)) {
- return $this->userProfiles[$userID];
- }
-
- return $this->getUserProfiles(array($userID))[$userID];
+ return UserProfileRuntimeCache::getInstance()->getObject($userID);
}
/**
- * Returns the user profiles of the users with the given user ids. For ids
- * without a user profile, null is returned.
- *
- * @param array<integer> $userIDs
- * @return array<\wcf\data\user\UserProfile>
+ * @see UserProfiltRuntimeCache::getObjects()
*/
public function getUserProfiles(array $userIDs) {
- $userProfiles = array();
- foreach ($userIDs as $key => $userID) {
- if (array_key_exists($userID, $this->userProfiles)) {
- $userProfiles[$userID] = $this->userProfiles[$userID];
-
- unset($userIDs[$key]);
- }
- }
-
- if (empty($userIDs)) {
- return $userProfiles;
- }
-
- $this->userIDs = array_unique(array_merge($this->userIDs, $userIDs));
-
- $userProfileList = new UserProfileList();
- $userProfileList->setObjectIDs($this->userIDs);
- $userProfileList->readObjects();
- $readUserProfiles = $userProfileList->getObjects();
-
- foreach ($this->userIDs as $userID) {
- if (!isset($readUserProfiles[$userID])) {
- $this->userProfiles[$userID] = null;
- }
- else {
- $this->userProfiles[$userID] = $readUserProfiles[$userID];
- }
- }
-
- $this->userIDs = array();
-
- foreach ($userIDs as $userID) {
- $userProfiles[$userID] = $this->userProfiles[$userID];
- }
-
- return $userProfiles;
+ return UserProfileRuntimeCache::getInstance()->getObjects($userIDs);
}
}
<?php
namespace wcf\data\user\activity\event;
use wcf\data\user\UserProfile;
-use wcf\data\user\UserProfileCache;
use wcf\data\DatabaseObjectDecorator;
+use wcf\system\cache\runtime\UserProfileRuntimeCache;
use wcf\system\user\activity\event\UserActivityEventHandler;
/**
* Provides methods for viewable user activity events.
*
* @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.activity.event
*/
class ViewableUserActivityEvent extends DatabaseObjectDecorator {
/**
- * @see \wcf\data\DatabaseObjectDecorator::$baseClass
+ * @inheritDoc
*/
- public static $baseClass = 'wcf\data\user\activity\event\UserActivityEvent';
+ public static $baseClass = UserActivityEvent::class;
/**
* event text
/**
* user profile
- * @var \wcf\data\user\UserProfile
+ * @var UserProfile
*/
protected $userProfile = null;
/**
* Sets user profile.
*
- * @param \wcf\data\user\UserProfile $userProfile
+ * @param UserProfile $userProfile
*/
public function setUserProfile(UserProfile $userProfile) {
$this->userProfile = $userProfile;
/**
* Returns user profile.
*
- * @return \wcf\data\user\UserProfile
+ * @return UserProfile
*/
public function getUserProfile() {
if ($this->userProfile === null) {
- $this->userProfile = UserProfileCache::getInstance()->getUserProfile($this->userID);
+ $this->userProfile = UserProfileRuntimeCache::getInstance()->getObject($this->userID);
}
return $this->userProfile;
<?php
namespace wcf\data\user\activity\event;
-use wcf\data\user\UserProfileCache;
+use wcf\system\cache\runtime\UserProfileRuntimeCache;
use wcf\system\language\LanguageFactory;
use wcf\system\user\activity\event\UserActivityEventHandler;
use wcf\system\WCF;
* Represents a list of viewable user activity events.
*
* @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.activity.event
*/
class ViewableUserActivityEventList extends UserActivityEventList {
/**
- * @see \wcf\data\DatabaseObjectList::$className
+ * @inheritDoc
*/
- public $className = 'wcf\data\user\activity\event\UserActivityEvent';
+ public $className = UserActivityEvent::class;
/**
* @see \wcf\data\DatabaseObjectList::$decoratorClassName
public $decoratorClassName = ViewableUserActivityEvent::class;
/**
- * @see \wcf\data\DatabaseObjectList::$sqlLimit
+ * @inheritDoc
*/
public $sqlLimit = 20;
/**
- * @see \wcf\data\DatabaseObjectList::$sqlOrderBy
+ * @inheritDoc
*/
public $sqlOrderBy = 'user_activity_event.time DESC, user_activity_event.eventID DESC';
/**
- * Creates a new ViewableUserActivityEventList object.
+ * @inheritDoc
*/
public function __construct() {
parent::__construct();
if (LanguageFactory::getInstance()->multilingualismEnabled() && count(WCF::getUser()->getLanguageIDs())) {
- $this->getConditionBuilder()->add('(user_activity_event.languageID IN (?) OR user_activity_event.languageID IS NULL)', array(WCF::getUser()->getLanguageIDs()));
+ $this->getConditionBuilder()->add('(user_activity_event.languageID IN (?) OR user_activity_event.languageID IS NULL)', [WCF::getUser()->getLanguageIDs()]);
}
}
/**
- * @see \wcf\data\DatabaseObjectList::readObjects()
+ * @inheritDoc
*/
public function readObjects() {
parent::readObjects();
- $userIDs = array();
- $eventGroups = array();
+ $userIDs = [];
+ $eventGroups = [];
foreach ($this->objects as $event) {
$userIDs[] = $event->userID;
if (!isset($eventGroups[$event->objectTypeID])) {
$objectType = UserActivityEventHandler::getInstance()->getObjectType($event->objectTypeID);
- $eventGroups[$event->objectTypeID] = array(
+ $eventGroups[$event->objectTypeID] = [
'className' => $objectType->className,
- 'objects' => array()
- );
+ 'objects' => []
+ ];
}
$eventGroups[$event->objectTypeID]['objects'][] = $event;
// set user profiles
if (!empty($userIDs)) {
- UserProfileCache::getInstance()->cacheUserIDs(array_unique($userIDs));
+ UserProfileRuntimeCache::getInstance()->cacheObjectIDs(array_unique($userIDs));
}
// parse events
foreach ($eventGroups as $eventData) {
- $eventClass = call_user_func(array($eventData['className'], 'getInstance'));
+ $eventClass = call_user_func([$eventData['className'], 'getInstance']);
$eventClass->prepare($eventData['objects']);
}
}
/**
* Validates event permissions and returns a list of orphaned event ids.
*
- * @return array<integer>
+ * @return integer[]
*/
public function validateEvents() {
- $orphanedEventIDs = array();
+ $orphanedEventIDs = [];
foreach ($this->objects as $index => $event) {
if ($event->isOrphaned()) {
--- /dev/null
+<?php
+namespace wcf\system\cache\runtime;
+use wcf\data\DatabaseObject;
+use wcf\data\DatabaseObjectList;
+use wcf\system\SingletonFactory;
+
+/**
+ * Abstract implementation of a runtime cache.
+ *
+ * @author Matthias Schmidt
+ * @copyright 2001-2016 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package com.woltlab.wcf
+ * @subpackage system.cache.runtime
+ * @category Community Framework
+ * @since 2.2
+ */
+abstract class AbstractRuntimeCache extends SingletonFactory implements IRuntimeCache {
+ /**
+ * name of the DatabaseObjectList class
+ * @var string
+ */
+ protected $listClassName = '';
+
+ /**
+ * ids of objects which will be fetched next
+ * @var integer[]
+ */
+ protected $objectIDs = [];
+
+ /**
+ * cached DatabaseObject objects
+ * @var DatabaseObject[]
+ */
+ protected $objects = [];
+
+ /**
+ * @inheritDoc
+ */
+ public function cacheObjectID($objectID) {
+ $this->cacheObjectIDs([$objectID]);
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function cacheObjectIDs(array $objectIDs) {
+ foreach ($objectIDs as $objectID) {
+ if (!array_key_exists($objectID, $this->objects) && !in_array($objectID, $this->objectIDs)) {
+ $this->objectIDs[] = $objectID;
+ }
+ }
+ }
+
+ /**
+ * Fetches the objects for the pending object ids.
+ */
+ protected function fetchObjects() {
+ /** @var DatabaseObjectList $objectList */
+ $objectList = new $this->listClassName;
+ $objectList->setObjectIDs($this->objectIDs);
+ $objectList->readObjects();
+ $this->objects += $objectList->getObjects();
+
+ // create null entries for non-existing objects
+ foreach ($this->objectIDs as $objectID) {
+ if (!array_key_exists($objectID, $this->objects)) {
+ $this->objects[$objectID] = null;
+ }
+ }
+
+ $this->objectIDs = [];
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function getCachedObjects() {
+ return $this->objects;
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function getObject($objectID) {
+ if (array_key_exists($objectID, $this->objects)) {
+ return $this->objects[$objectID];
+ }
+
+ $this->cacheObjectID($objectID);
+
+ $this->fetchObjects();
+
+ return $this->objects[$objectID];
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function getObjects(array $objectIDs) {
+ $objects = [];
+
+ // set already cached objects
+ foreach ($objectIDs as $key => $objectID) {
+ if (array_key_exists($objectID, $this->objects)) {
+ $objects[$objectID] = $this->objects[$objectID];
+ unset($objectIDs[$key]);
+ }
+ }
+
+ if (!empty($objectIDs)) {
+ $this->cacheObjectIDs($objectIDs);
+
+ $this->fetchObjects();
+
+ // set newly loaded cached objects
+ foreach ($objectIDs as $objectID) {
+ $objects[$objectID] = $this->objects[$objectID];
+ }
+ }
+
+ return $objects;
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function removeObject($objectID) {
+ $this->removeObjects([$objectID]);
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function removeObjects(array $objectIDs){
+ foreach ($objectIDs as $objectID) {
+ if (array_key_exists($objectID, $this->objects)) {
+ unset($this->objects[$objectID]);
+ }
+ }
+ }
+}
--- /dev/null
+<?php
+namespace wcf\system\cache\runtime;
+use wcf\data\comment\Comment;
+use wcf\data\comment\CommentList;
+
+/**
+ * Runtime cache implementation for comments.
+ *
+ * @author Matthias Schmidt
+ * @copyright 2001-2016 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package com.woltlab.wcf
+ * @subpackage system.cache.runtime
+ * @category Community Framework
+ * @since 2.2
+ *
+ * @method Comment getObject($objectID)
+ * @method Comment[] getObjects(array $objectIDs)
+ */
+class CommentRuntimeCache extends AbstractRuntimeCache {
+ /**
+ * @inheritDoc
+ */
+ protected $listClassName = CommentList::class;
+}
--- /dev/null
+<?php
+namespace wcf\system\cache\runtime;
+use wcf\data\DatabaseObject;
+
+/**
+ * Handles runtime caches to centrally store objects fetched during tuntime for reuse.
+ *
+ * @author Matthias Schmidt
+ * @copyright 2001-2016 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package com.woltlab.wcf
+ * @subpackage system.cache.runtime
+ * @category Community Framework
+ * @since 2.2
+ */
+interface IRuntimeCache {
+ /**
+ * Caches the given object id so that during the next object fetch, the object with
+ * this id will also be fetched.
+ *
+ * @param integer $objectID
+ */
+ public function cacheObjectID($objectID);
+
+ /**
+ * Caches the given object ids so that during the next object fetch, the objects with
+ * these ids will also be fetched.
+ *
+ * @param integer[] $objectIDs
+ */
+ public function cacheObjectIDs(array $objectIDs);
+
+ /**
+ * Returns all currently cached objects.
+ *
+ * @return DatabaseObject[]
+ */
+ public function getCachedObjects();
+
+ /**
+ * Returns the object with the given id or null if no such object exists.
+ * If the given object id should not have been cached before, it will be cached
+ * during this method call and the object, if existing, will be returned.
+ *
+ * @param integer $objectID
+ * @return DatabaseObject|null
+ */
+ public function getObject($objectID);
+
+ /**
+ * Returns the objects with the given ids. If an object does not exist, the array element
+ * wil be null.
+ * If the given object ids should not have been cached before, they will be cached
+ * during this method call and the objects, if existing, will be returned.
+ *
+ * @param integer[] $objectIDs
+ * @return DatabaseObject[]
+ */
+ public function getObjects(array $objectIDs);
+
+ /**
+ * Removes the object with the given id from the runtime cache if it has already been loaded.
+ *
+ * @param integer $objectID
+ */
+ public function removeObject($objectID);
+
+
+ /**
+ * Removes the objects with the given ids from the runtime cache if they have already been loaded.
+ *
+ * @param integer $objectID
+ */
+ public function removeObjects(array $objectIDs);
+}
--- /dev/null
+<?php
+namespace wcf\system\cache\runtime;
+use wcf\data\user\UserProfile;
+use wcf\data\user\UserProfileList;
+
+/**
+ * Runtime cache implementation for user profiles.
+ *
+ * @author Matthias Schmidt
+ * @copyright 2001-2016 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package com.woltlab.wcf
+ * @subpackage system.cache.runtime
+ * @category Community Framework
+ * @since 2.2
+ *
+ * @method UserProfile getObject($objectID)
+ * @method UserProfile[] getObjects(array $objectIDs)
+ */
+class UserProfileRuntimeCache extends AbstractRuntimeCache {
+ /**
+ * @inheritDoc
+ */
+ protected $listClassName = UserProfileList::class;
+}
<?php
namespace wcf\system\comment;
-use wcf\data\comment\CommentList;
-use wcf\data\user\UserProfile;
+use wcf\system\cache\runtime\CommentRuntimeCache;
+use wcf\system\cache\runtime\UserProfileRuntimeCache;
use wcf\system\SingletonFactory;
/**
* Handles common data resources for comment-related user notifications
*
* @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 system.comment
* @category Community Framework
+ * @deprecated since 2.2, use CommentRuntimeCache and UserProfileRuntimeCache
*/
class CommentDataHandler extends SingletonFactory {
/**
- * list of comment ids
- * @var array<integer>
- */
- protected $commentIDs = array();
-
- /**
- * list of cached comment objects
- * @var array<\wcf\data\comment\Comment>
- */
- protected $comments = array();
-
- /**
- * list of user ids
- * @var array<integer>
- */
- protected $userIDs = array();
-
- /**
- * Caches a comment id.
- *
- * @param integer $commentID
+ * @see CommentRuntimeCache::cacheObjectID()
*/
public function cacheCommentID($commentID) {
- if (!in_array($commentID, $this->commentIDs)) {
- $this->commentIDs[] = $commentID;
- }
+ CommentRuntimeCache::getInstance()->cacheObjectID($commentID);
}
/**
- * Caches a user id.
- *
- * @param integer $userID
+ * @see UserProfileRuntimeCache::cacheObjectID()
*/
public function cacheUserID($userID) {
- if (!in_array($userID, $this->userIDs)) {
- $this->userIDs[] = $userID;
- }
+ UserProfileRuntimeCache::getInstance()->cacheObjectID($userID);
}
/**
- * Returns a comment by id, fetches comments on first call.
- *
- * @param integer $commentID
- * @return \wcf\data\comment\Comment
+ * @see CommentRuntimeCache::getComment()
*/
public function getComment($commentID) {
- if (!empty($this->commentIDs)) {
- $this->commentIDs = array_diff($this->commentIDs, array_keys($this->comments));
-
- if (!empty($this->commentIDs)) {
- $commentList = new CommentList();
- $commentList->setObjectIDs($this->commentIDs);
- $commentList->readObjects();
- $this->comments += $commentList->getObjects();
- $this->commentIDs = array();
- }
- }
-
- if (isset($this->comments[$commentID])) {
- return $this->comments[$commentID];
- }
-
- return null;
+ return CommentRuntimeCache::getInstance()->getObject($commentID);
}
/**
- * Returns a user profile by id, fetches user profiles on first call.
- *
- * @param integer $userID
- * @return \wcf\data\user\UserProfile
+ * @see UserProfileRuntimeCache::getObject()
*/
public function getUser($userID) {
- if (!empty($this->userIDs)) {
- UserProfile::getUserProfiles($this->userIDs);
- $this->userIDs = array();
- }
-
- return UserProfile::getUserProfile($userID);
+ return UserProfileRuntimeCache::getInstance()->getObject($userID);
}
}
<?php
namespace wcf\system\dashboard\box;
use wcf\data\dashboard\box\DashboardBox;
-use wcf\data\user\UserProfileCache;
use wcf\data\DatabaseObject;
use wcf\page\IPage;
use wcf\system\cache\builder\MostActiveMembersCacheBuilder;
+use wcf\system\cache\runtime\UserProfileRuntimeCache;
use wcf\system\request\LinkHandler;
use wcf\system\WCF;
* Shows a list of the most active members.
*
* @author Marcel Werk
- * @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 system.dashboard.box
class MostActiveMembersDashboardBox extends AbstractSidebarDashboardBox {
/**
* ids of the most active members
- * @var array<integer>
+ * @var integer[]
*/
- public $mostActiveMemberIDs = array();
+ public $mostActiveMemberIDs = [];
/**
- * @see \wcf\system\dashboard\box\AbstractDashboardBoxContent::init()
+ * @inheritDoc
*/
public function init(DashboardBox $box, IPage $page) {
parent::init($box, $page);
// get ids
$this->mostActiveMemberIDs = MostActiveMembersCacheBuilder::getInstance()->getData();
if (!empty($this->mostActiveMemberIDs)) {
- UserProfileCache::getInstance()->cacheUserIDs($this->mostActiveMemberIDs);
+ UserProfileRuntimeCache::getInstance()->cacheObjectIDs($this->mostActiveMemberIDs);
}
$this->fetched();
}
/**
- * @see \wcf\system\dashboard\box\AbstractContentDashboardBox::render()
+ * @inheritDoc
*/
protected function render() {
if (empty($this->mostActiveMemberIDs)) return '';
if (MODULE_MEMBERS_LIST) {
- $this->titleLink = LinkHandler::getInstance()->getLink('MembersList', array(), 'sortField=activityPoints&sortOrder=DESC');
+ $this->titleLink = LinkHandler::getInstance()->getLink('MembersList', [], 'sortField=activityPoints&sortOrder=DESC');
}
- $mostActiveMembers = UserProfileCache::getInstance()->getUserProfiles($this->mostActiveMemberIDs);
+ $mostActiveMembers = UserProfileRuntimeCache::getInstance()->getObjects($this->mostActiveMemberIDs);
DatabaseObject::sort($mostActiveMembers, 'activityPoints', 'DESC');
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'mostActiveMembers' => $mostActiveMembers
- ));
+ ]);
return WCF::getTPL()->fetch('dashboardBoxMostActiveMembers');
}
}
<?php
namespace wcf\system\dashboard\box;
use wcf\data\dashboard\box\DashboardBox;
-use wcf\data\user\UserProfileCache;
use wcf\data\DatabaseObject;
use wcf\page\IPage;
use wcf\system\cache\builder\MostLikedMembersCacheBuilder;
+use wcf\system\cache\runtime\UserProfileRuntimeCache;
use wcf\system\request\LinkHandler;
use wcf\system\WCF;
* Shows a list of the most liked members.
*
* @author Marcel Werk
- * @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 system.dashboard.box
class MostLikedMembersDashboardBox extends AbstractSidebarDashboardBox {
/**
* ids of the most liked members
- * @var array<integer>
+ * @var integer[]
*/
- public $mostLikedMemberIDs = array();
+ public $mostLikedMemberIDs = [];
/**
- * @see \wcf\system\dashboard\box\IDashboardBox::init()
+ * @inheritDoc
*/
public function init(DashboardBox $box, IPage $page) {
parent::init($box, $page);
$this->fetched();
if (!empty($this->mostLikedMemberIDs)) {
- UserProfileCache::getInstance()->cacheUserIDs($this->mostLikedMemberIDs);
+ UserProfileRuntimeCache::getInstance()->cacheObjectIDs($this->mostLikedMemberIDs);
}
}
/**
- * @see \wcf\system\dashboard\box\AbstractContentDashboardBox::render()
+ * @inheritDoc
*/
protected function render() {
if (empty($this->mostLikedMemberIDs)) return '';
if (MODULE_MEMBERS_LIST) {
- $this->titleLink = LinkHandler::getInstance()->getLink('MembersList', array(), 'sortField=likesReceived&sortOrder=DESC');
+ $this->titleLink = LinkHandler::getInstance()->getLink('MembersList', [], 'sortField=likesReceived&sortOrder=DESC');
}
- $mostLikedMembers = UserProfileCache::getInstance()->getUserProfiles($this->mostLikedMemberIDs);
+ $mostLikedMembers = UserProfileRuntimeCache::getInstance()->getObjects($this->mostLikedMemberIDs);
DatabaseObject::sort($mostLikedMembers, 'likesReceived', 'DESC');
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'mostLikedMembers' => $mostLikedMembers
- ));
+ ]);
return WCF::getTPL()->fetch('dashboardBoxMostLikedMembers');
}
}
<?php
namespace wcf\system\dashboard\box;
use wcf\data\dashboard\box\DashboardBox;
-use wcf\data\user\UserProfileCache;
use wcf\data\DatabaseObject;
use wcf\page\IPage;
use wcf\system\cache\builder\NewestMembersCacheBuilder;
+use wcf\system\cache\runtime\UserProfileRuntimeCache;
use wcf\system\request\LinkHandler;
use wcf\system\WCF;
* Shows a list of the newest members.
*
* @author Marcel Werk
- * @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 system.dashboard.box
class NewestMembersDashboardBox extends AbstractSidebarDashboardBox {
/**
* ids of the newest members
- * @var array<integer>
+ * @var integer[]
*/
- public $newestMemberIDs = array();
+ public $newestMemberIDs = [];
/**
- * @see \wcf\system\dashboard\box\IDashboardBox::init()
+ * @inheritDoc
*/
public function init(DashboardBox $box, IPage $page) {
parent::init($box, $page);
// get ids
$this->newestMemberIDs = NewestMembersCacheBuilder::getInstance()->getData();
if (!empty($this->newestMemberIDs)) {
- UserProfileCache::getInstance()->cacheUserIDs($this->newestMemberIDs);
+ UserProfileRuntimeCache::getInstance()->cacheObjectIDs($this->newestMemberIDs);
}
$this->fetched();
}
/**
- * @see \wcf\system\dashboard\box\AbstractContentDashboardBox::render()
+ * @inheritDoc
*/
protected function render() {
if (empty($this->newestMemberIDs)) return '';
if (MODULE_MEMBERS_LIST) {
- $this->titleLink = LinkHandler::getInstance()->getLink('MembersList', array(), 'sortField=registrationDate&sortOrder=DESC');
+ $this->titleLink = LinkHandler::getInstance()->getLink('MembersList', [], 'sortField=registrationDate&sortOrder=DESC');
}
- $newestMembers = UserProfileCache::getInstance()->getUserProfiles($this->newestMemberIDs);
+ $newestMembers = UserProfileRuntimeCache::getInstance()->getObjects($this->newestMemberIDs);
DatabaseObject::sort($newestMembers, 'registrationDate', 'DESC');
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'newestMembers' => $newestMembers
- ));
+ ]);
return WCF::getTPL()->fetch('dashboardBoxNewestMembers');
}
}
<?php
namespace wcf\system\dashboard\box;
use wcf\data\dashboard\box\DashboardBox;
-use wcf\data\user\UserProfileCache;
+use wcf\data\user\UserProfile;
use wcf\page\IPage;
use wcf\system\cache\builder\UserOptionCacheBuilder;
+use wcf\system\cache\runtime\UserProfileRuntimeCache;
use wcf\system\user\UserBirthdayCache;
use wcf\system\WCF;
use wcf\util\DateUtil;
* Shows today's birthdays.
*
* @author Marcel Werk
- * @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 system.dashboard.box
class TodaysBirthdaysDashboardBox extends AbstractSidebarDashboardBox {
/**
* user profiles
- * @var array<\wcf\data\user\UserProfile>
+ * @var UserProfile[]
*/
- public $userProfiles = array();
+ public $userProfiles = [];
/**
- * @see \wcf\system\dashboard\box\IDashboardBox::init()
+ * @inheritDoc
*/
public function init(DashboardBox $box, IPage $page) {
parent::init($box, $page);
$userIDs = UserBirthdayCache::getInstance()->getBirthdays($date[1], $date[2]);
if (!empty($userIDs)) {
- $userOptions = UserOptionCacheBuilder::getInstance()->getData(array(), 'options');
+ $userOptions = UserOptionCacheBuilder::getInstance()->getData([], 'options');
if (isset($userOptions['birthday'])) {
$birthdayUserOption = $userOptions['birthday'];
- $userProfiles = UserProfileCache::getInstance()->getUserProfiles($userIDs);
+ $userProfiles = UserProfileRuntimeCache::getInstance()->getObjects($userIDs);
$i = 0;
foreach ($userProfiles as $userProfile) {
}
/**
- * @see \wcf\system\dashboard\box\AbstractContentDashboardBox::render()
+ * @inheritDoc
*/
protected function render() {
if (empty($this->userProfiles)) {
return '';
}
- WCF::getTPL()->assign(array(
+ WCF::getTPL()->assign([
'birthdayUserProfiles' => $this->userProfiles
- ));
+ ]);
return WCF::getTPL()->fetch('dashboardBoxTodaysBirthdays');
}
}
namespace wcf\system\dashboard\box;
use wcf\data\dashboard\box\DashboardBox;
use wcf\data\user\UserProfile;
-use wcf\data\user\UserProfileCache;
use wcf\page\IPage;
+use wcf\system\cache\runtime\UserProfileRuntimeCache;
use wcf\system\user\UserBirthdayCache;
use wcf\system\WCF;
use wcf\util\DateUtil;
* Shows today's birthdays of users the active user is following.
*
* @author Marcel Werk
- * @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 system.dashboard.box
$userIDs = array_intersect($userIDs, WCF::getUserProfileHandler()->getFollowingUsers());
if (!empty($userIDs)) {
- $userProfiles = UserProfileCache::getInstance()->getUserProfiles($userIDs);
+ $userProfiles = UserProfileRuntimeCache::getInstance()->getObjects($userIDs);
$i = 0;
foreach ($userProfiles as $userProfile) {
<?php
namespace wcf\system\html\output\node;
use wcf\data\user\UserProfile;
-use wcf\data\user\UserProfileCache;
+use wcf\system\cache\runtime\UserProfileRuntimeCache;
use wcf\system\html\output\HtmlOutputNodeProcessor;
use wcf\system\WCF;
use wcf\util\StringUtil;
}
if (!empty($userIds)) {
- $this->userProfiles = UserProfileCache::getInstance()->getUserProfiles($userIds);
+ $this->userProfiles = UserProfileRuntimeCache::getInstance()->getObjects($userIds);
}
}
<?php
namespace wcf\system\message\embedded\object;
use wcf\data\user\UserList;
-use wcf\data\user\UserProfileCache;
+use wcf\system\cache\runtime\UserProfileRuntimeCache;
/**
* IMessageEmbeddedObjectHandler implementation for quotes.
*
* @author Marcel Werk
- * @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 system.message.embedded.object
*/
class QuoteMessageEmbeddedObjectHandler extends AbstractMessageEmbeddedObjectHandler {
/**
- * @see \wcf\system\message\embedded\object\IMessageEmbeddedObjectHandler::parseMessage()
+ * @inheritDoc
*/
public function parseMessage($message) {
$usernames = self::getFirstParameters($message, 'quote');
if (!empty($usernames)) {
$userList = new UserList();
- $userList->getConditionBuilder()->add("user_table.username IN (?)", array($usernames));
+ $userList->getConditionBuilder()->add("user_table.username IN (?)", [$usernames]);
$userList->readObjectIDs();
return $userList->getObjectIDs();
}
}
/**
- * @see \wcf\system\message\embedded\object\IMessageEmbeddedObjectHandler::loadObjects()
+ * @inheritDoc
*/
public function loadObjects(array $objectIDs) {
- return UserProfileCache::getInstance()->getUserProfiles($objectIDs);
+ return UserProfileRuntimeCache::getInstance()->getObjects($objectIDs);
}
}
namespace wcf\system\user\activity\event;
use wcf\data\comment\response\CommentResponseList;
use wcf\data\comment\CommentList;
-use wcf\data\user\UserProfileCache;
+use wcf\system\cache\runtime\UserProfileRuntimeCache;
use wcf\system\SingletonFactory;
use wcf\system\WCF;
* User activity event implementation for profile comment responses.
*
* @author Marcel Werk
- * @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 system.user.activity.event
*/
class ProfileCommentResponseUserActivityEvent extends SingletonFactory implements IUserActivityEvent {
/**
- * @see \wcf\system\user\activity\event\IUserActivityEvent::prepare()
+ * @inheritDoc
*/
public function prepare(array $events) {
if (!WCF::getSession()->getPermission('user.profile.canViewUserProfile')) {
return;
}
- $responses = $responseIDs = array();
+ $responses = $responseIDs = [];
foreach ($events as $event) {
$responseIDs[] = $event->objectID;
}
$responses = $responseList->getObjects();
// fetch comments
- $commentIDs = $comments = array();
+ $commentIDs = $comments = [];
foreach ($responses as $response) {
$commentIDs[] = $response->commentID;
}
}
// fetch users
- $userIDs = $users = array();
+ $userIDs = $users = [];
foreach ($comments as $comment) {
$userIDs[] = $comment->objectID;
$userIDs[] = $comment->userID;
}
if (!empty($userIDs)) {
- $users = UserProfileCache::getInstance()->getUserProfiles($userIDs);
+ $users = UserProfileRuntimeCache::getInstance()->getObjects($userIDs);
}
// set message
$event->setIsAccessible();
// title
- $text = WCF::getLanguage()->getDynamicVariable('wcf.user.profile.recentActivity.profileCommentResponse', array(
+ $text = WCF::getLanguage()->getDynamicVariable('wcf.user.profile.recentActivity.profileCommentResponse', [
'commentAuthor' => $users[$comment->userID],
'user' => $users[$comment->objectID]
- ));
+ ]);
$event->setTitle($text);
// description
<?php
namespace wcf\system\user\activity\event;
use wcf\data\comment\CommentList;
-use wcf\data\user\UserProfileCache;
+use wcf\system\cache\runtime\UserProfileRuntimeCache;
use wcf\system\SingletonFactory;
use wcf\system\WCF;
* User activity event implementation for profile comments.
*
* @author Marcel Werk
- * @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 system.user.activity.event
*/
class ProfileCommentUserActivityEvent extends SingletonFactory implements IUserActivityEvent {
/**
- * @see \wcf\system\user\activity\event\IUserActivityEvent::prepare()
+ * @inheritDoc
*/
public function prepare(array $events) {
if (!WCF::getSession()->getPermission('user.profile.canViewUserProfile')) {
$userIDs[] = $comment->objectID;
}
if (!empty($userIDs)) {
- $users = UserProfileCache::getInstance()->getUserProfiles($userIDs);
+ $users = UserProfileRuntimeCache::getInstance()->getObjects($userIDs);
}
// set message
use wcf\data\user\User;
use wcf\data\moderation\queue\ViewableModerationQueue;
use wcf\data\object\type\ObjectTypeCache;
-use wcf\system\comment\CommentDataHandler;
+use wcf\data\user\UserProfile;
+use wcf\system\cache\runtime\CommentRuntimeCache;
+use wcf\system\cache\runtime\UserProfileRuntimeCache;
use wcf\system\moderation\queue\report\IModerationQueueReportHandler;
use wcf\system\WCF;
]);
}
- $comment = CommentDataHandler::getInstance()->getComment($this->userNotificationObject->commentID);
+ $comment = CommentRuntimeCache::getInstance()->getComment($this->userNotificationObject->commentID);
if ($comment->userID) {
- $commentAuthor = CommentDataHandler::getInstance()->getUser($comment->userID);
+ $commentAuthor = UserProfileRuntimeCache::getInstance()->getObject($comment->userID);
}
else {
- $commentAuthor = new User(null, [
+ $commentAuthor = new UserProfile(new User(null, [
'username' => $comment->username
- ]);
+ ]));
}
return $this->getLanguage()->getDynamicVariable($this->getLanguageItemPrefix().'.commentResponse.mail', [
]);
}
- $comment = CommentDataHandler::getInstance()->getComment($this->userNotificationObject->commentID);
+ $comment = CommentRuntimeCache::getInstance()->getObject($this->userNotificationObject->commentID);
if ($comment->userID) {
- $commentAuthor = CommentDataHandler::getInstance()->getUser($comment->userID);
+ $commentAuthor = UserProfileRuntimeCache::getInstance()->getObject($comment->userID);
}
else {
- $commentAuthor = new User(null, [
+ $commentAuthor = new UserProfile(new User(null, [
'username' => $comment->username
- ]);
+ ]));
}
return $this->getLanguage()->getDynamicVariable($this->getLanguageItemPrefix().'.commentResponse.message', [
*/
public function getModerationQueue() {
if (!$this->moderationQueueLoaded) {
- $comment = CommentDataHandler::getInstance()->getComment($this->userNotificationObject->commentID);
+ $comment = CommentRuntimeCache::getInstance()->getObject($this->userNotificationObject->commentID);
$this->moderationQueue = ViewableModerationQueue::getViewableModerationQueue($comment->objectID);
$this->moderationQueueLoaded = true;
* @inheritDoc
*/
protected function prepare() {
- CommentDataHandler::getInstance()->cacheCommentID($this->userNotificationObject->commentID);
- CommentDataHandler::getInstance()->cacheUserID($this->additionalData['userID']);
+ CommentRuntimeCache::getInstance()->cacheObjectID($this->userNotificationObject->commentID);
+ UserProfileRuntimeCache::getInstance()->cacheObjectID($this->additionalData['userID']);
}
}
<?php
namespace wcf\system\user\notification\event;
-use wcf\system\comment\CommentDataHandler;
+use wcf\system\cache\runtime\UserProfileRuntimeCache;
use wcf\system\request\LinkHandler;
use wcf\system\WCF;
* User notification event for profile commment likes.
*
* @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 system.user.notification.event
*/
class UserProfileCommentLikeUserNotificationEvent extends AbstractSharedUserNotificationEvent {
/**
- * @see \wcf\system\user\notification\event\AbstractUserNotificationEvent::$stackable
+ * @inheritDoc
*/
protected $stackable = true;
/**
- * @see \wcf\system\user\notification\event\AbstractUserNotificationEvent::prepare()
+ * @inheritDoc
*/
protected function prepare() {
- CommentDataHandler::getInstance()->cacheUserID($this->additionalData['objectID']);
+ UserProfileRuntimeCache::getInstance()->cacheObjectID($this->additionalData['objectID']);
}
/**
- * @see \wcf\system\user\notification\event\IUserNotificationEvent::getTitle()
+ * @inheritDoc
*/
public function getTitle() {
$count = count($this->getAuthors());
if ($count > 1) {
- return $this->getLanguage()->getDynamicVariable('wcf.user.notification.comment.like.title.stacked', array(
+ return $this->getLanguage()->getDynamicVariable('wcf.user.notification.comment.like.title.stacked', [
'count' => $count,
'timesTriggered' => $this->notification->timesTriggered
- ));
+ ]);
}
return $this->getLanguage()->get('wcf.user.notification.comment.like.title');
}
/**
- * @see \wcf\system\user\notification\event\IUserNotificationEvent::getMessage()
+ * @inheritDoc
*/
public function getMessage() {
$authors = array_values($this->getAuthors());
$count = count($authors);
$owner = null;
if ($this->additionalData['objectID'] != WCF::getUser()->userID) {
- $owner = CommentDataHandler::getInstance()->getUser($this->additionalData['objectID']);
+ $owner = UserProfileRuntimeCache::getInstance()->getObject($this->additionalData['objectID']);
}
if ($count > 1) {
- return $this->getLanguage()->getDynamicVariable('wcf.user.notification.comment.like.message.stacked', array(
+ return $this->getLanguage()->getDynamicVariable('wcf.user.notification.comment.like.message.stacked', [
'author' => $this->author,
'authors' => $authors,
'count' => $count,
'others' => $count - 1,
'owner' => $owner
- ));
+ ]);
}
- return $this->getLanguage()->getDynamicVariable('wcf.user.notification.comment.like.message', array(
+ return $this->getLanguage()->getDynamicVariable('wcf.user.notification.comment.like.message', [
'author' => $this->author,
'owner' => $owner
- ));
+ ]);
}
/**
- * @see \wcf\system\user\notification\event\IUserNotificationEvent::getEmailMessage()
+ * @inheritDoc
*/
- public function getEmailMessage($notificationType = 'instant') { /* not supported */ }
+ public function getEmailMessage($notificationType = 'instant') {
+ // not supported
+ }
/**
- * @see \wcf\system\user\notification\event\IUserNotificationEvent::getLink()
+ * @inheritDoc
*/
public function getLink() {
$owner = WCF::getUser();
if ($this->additionalData['objectID'] != WCF::getUser()->userID) {
- $owner = CommentDataHandler::getInstance()->getUser($this->additionalData['objectID']);
+ $owner = UserProfileRuntimeCache::getInstance()->getObject($this->additionalData['objectID']);
}
- return LinkHandler::getInstance()->getLink('User', array(
- 'object' => $owner
- ), '#wall');
+ return LinkHandler::getInstance()->getLink('User', ['object' => $owner], '#wall');
}
/**
- * @see \wcf\system\user\notification\event\IUserNotificationEvent::getEventHash()
+ * @inheritDoc
*/
public function getEventHash() {
return sha1($this->eventID . '-' . $this->additionalData['objectID']);
}
/**
- * @see \wcf\system\user\notification\event\IUserNotificationEvent::supportsEmailNotification()
+ * @inheritDoc
*/
public function supportsEmailNotification() {
return false;
<?php
namespace wcf\system\user\notification\event;
-use wcf\system\comment\CommentDataHandler;
+use wcf\system\cache\runtime\UserProfileRuntimeCache;
use wcf\system\request\LinkHandler;
use wcf\system\WCF;
* User notification event for profile commment response likes.
*
* @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 system.user.notification.event
*/
class UserProfileCommentResponseLikeUserNotificationEvent extends AbstractSharedUserNotificationEvent {
/**
- * @see \wcf\system\user\notification\event\AbstractUserNotificationEvent::$stackable
+ * @inheritDoc
*/
protected $stackable = true;
/**
- * @see \wcf\system\user\notification\event\AbstractUserNotificationEvent::prepare()
+ * @inheritDoc
*/
protected function prepare() {
- CommentDataHandler::getInstance()->cacheUserID($this->additionalData['objectID']);
- CommentDataHandler::getInstance()->cacheUserID($this->additionalData['commentUserID']);
+ UserProfileRuntimeCache::getInstance()->cacheObjectID($this->additionalData['objectID']);
+ UserProfileRuntimeCache::getInstance()->cacheObjectID($this->additionalData['commentUserID']);
}
/**
- * @see \wcf\system\user\notification\event\IUserNotificationEvent::getTitle()
+ * @inheritDoc
*/
public function getTitle() {
$count = count($this->getAuthors());
if ($count > 1) {
- return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponse.like.title.stacked', array(
+ return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponse.like.title.stacked', [
'count' => $count,
'timesTriggered' => $this->notification->timesTriggered
- ));
+ ]);
}
return $this->getLanguage()->get('wcf.user.notification.commentResponse.like.title');
}
/**
- * @see \wcf\system\user\notification\event\IUserNotificationEvent::getMessage()
+ * @inheritDoc
*/
public function getMessage() {
$authors = array_values($this->getAuthors());
$count = count($authors);
$commentUser = $owner = null;
if ($this->additionalData['objectID'] != WCF::getUser()->userID) {
- $owner = CommentDataHandler::getInstance()->getUser($this->additionalData['objectID']);
+ $owner = UserProfileRuntimeCache::getInstance()->getObject($this->additionalData['objectID']);
}
if ($this->additionalData['commentUserID'] != WCF::getUser()->userID) {
- $commentUser = CommentDataHandler::getInstance()->getUser($this->additionalData['commentUserID']);
+ $commentUser = UserProfileRuntimeCache::getInstance()->getObject($this->additionalData['commentUserID']);
}
if ($count > 1) {
- return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponse.like.message.stacked', array(
+ return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponse.like.message.stacked', [
'author' => $this->author,
'authors' => $authors,
'commentUser' => $commentUser,
'count' => $count,
'others' => $count - 1,
'owner' => $owner
- ));
+ ]);
}
- return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponse.like.message', array(
+ return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponse.like.message', [
'author' => $this->author,
'owner' => $owner
- ));
+ ]);
}
/**
- * @see \wcf\system\user\notification\event\IUserNotificationEvent::getEmailMessage()
+ * @inheritDoc
*/
- public function getEmailMessage($notificationType = 'instant') { /* not supported */ }
+ public function getEmailMessage($notificationType = 'instant') {
+ // not supported
+ }
/**
- * @see \wcf\system\user\notification\event\IUserNotificationEvent::getLink()
+ * @inheritDoc
*/
public function getLink() {
$owner = WCF::getUser();
if ($this->additionalData['objectID'] != WCF::getUser()->userID) {
- $owner = CommentDataHandler::getInstance()->getUser($this->additionalData['objectID']);
+ $owner = UserProfileRuntimeCache::getInstance()->getObject($this->additionalData['objectID']);
}
- return LinkHandler::getInstance()->getLink('User', array(
- 'object' => $owner
- ), '#wall');
+ return LinkHandler::getInstance()->getLink('User', ['object' => $owner], '#wall');
}
/**
- * @see \wcf\system\user\notification\event\IUserNotificationEvent::getEventHash()
+ * @inheritDoc
*/
public function getEventHash() {
return sha1($this->eventID . '-' . $this->additionalData['commentID']);
}
/**
- * @see \wcf\system\user\notification\event\IUserNotificationEvent::supportsEmailNotification()
+ * @inheritDoc
*/
public function supportsEmailNotification() {
return false;
namespace wcf\system\user\notification\event;
use wcf\data\comment\Comment;
use wcf\data\user\User;
-use wcf\system\comment\CommentDataHandler;
+use wcf\data\user\UserProfile;
+use wcf\system\cache\runtime\CommentRuntimeCache;
+use wcf\system\cache\runtime\UserProfileRuntimeCache;
use wcf\system\request\LinkHandler;
use wcf\system\WCF;
* User notification event for profile's owner for commment responses.
*
* @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 system.user.notification.event
*/
class UserProfileCommentResponseOwnerUserNotificationEvent extends AbstractSharedUserNotificationEvent {
/**
- * @see \wcf\system\user\notification\event\AbstractUserNotificationEvent::$stackable
+ * @inheritDoc
*/
protected $stackable = true;
/**
- * @see \wcf\system\user\notification\event\AbstractUserNotificationEvent::prepare()
+ * @inheritDoc
*/
protected function prepare() {
- CommentDataHandler::getInstance()->cacheCommentID($this->userNotificationObject->commentID);
- CommentDataHandler::getInstance()->cacheUserID($this->additionalData['userID']);
+ CommentRuntimeCache::getInstance()->cacheObjectID($this->userNotificationObject->commentID);
+ UserProfileRuntimeCache::getInstance()->cacheObjectID($this->additionalData['userID']);
}
/**
- * @see \wcf\system\user\notification\event\IUserNotificationEvent::getTitle()
+ * @inheritDoc
*/
public function getTitle() {
$count = count($this->getAuthors());
if ($count > 1) {
- return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponseOwner.title.stacked', array(
+ return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponseOwner.title.stacked', [
'count' => $count,
'timesTriggered' => $this->notification->timesTriggered
- ));
+ ]);
}
return $this->getLanguage()->get('wcf.user.notification.commentResponseOwner.title');
}
/**
- * @see \wcf\system\user\notification\event\IUserNotificationEvent::getMessage()
+ * @inheritDoc
*/
public function getMessage() {
- $comment = CommentDataHandler::getInstance()->getComment($this->userNotificationObject->commentID);
+ $comment = CommentRuntimeCache::getInstance()->getObject($this->userNotificationObject->commentID);
if ($comment->userID) {
- $commentAuthor = CommentDataHandler::getInstance()->getUser($comment->userID);
+ $commentAuthor = UserProfileRuntimeCache::getInstance()->getObject($comment->userID);
}
else {
- $commentAuthor = new User(null, array(
+ $commentAuthor = new UserProfile(new User(null, [
'username' => $comment->username
- ));
+ ]));
}
$authors = $this->getAuthors();
}
$count = count($authors);
- return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponseOwner.message.stacked', array(
+ return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponseOwner.message.stacked', [
'author' => $commentAuthor,
'authors' => array_values($authors),
'count' => $count,
'others' => $count - 1,
'guestTimesTriggered' => $this->notification->guestTimesTriggered
- ));
+ ]);
}
- return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponseOwner.message', array(
+ return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponseOwner.message', [
'author' => $this->author,
'commentAuthor' => $commentAuthor
- ));
+ ]);
}
/**
- * @see \wcf\system\user\notification\event\IUserNotificationEvent::getEmailMessage()
+ * @inheritDoc
*/
public function getEmailMessage($notificationType = 'instant') {
$comment = new Comment($this->userNotificationObject->commentID);
$commentAuthor = new User($comment->userID);
}
else {
- $commentAuthor = new User(null, array(
+ $commentAuthor = new User(null, [
'username' => $comment->username
- ));
+ ]);
}
$authors = $this->getAuthors();
}
$count = count($authors);
- return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponseOwner.mail.stacked', array(
+ return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponseOwner.mail.stacked', [
'author' => $this->author,
'authors' => array_values($authors),
'commentAuthor' => $commentAuthor,
'owner' => $owner,
'response' => $this->userNotificationObject,
'guestTimesTriggered' => $this->notification->guestTimesTriggered
- ));
+ ]);
}
- return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponseOwner.mail', array(
+ return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponseOwner.mail', [
'response' => $this->userNotificationObject,
'author' => $this->author,
'commentAuthor' => $commentAuthor,
'owner' => $owner,
'notificationType' => $notificationType
- ));
+ ]);
}
/**
- * @see \wcf\system\user\notification\event\IUserNotificationEvent::getLink()
+ * @inheritDoc
*/
public function getLink() {
- return LinkHandler::getInstance()->getLink('User', array('object' => WCF::getUser()), '#wall');
+ return LinkHandler::getInstance()->getLink('User', ['object' => WCF::getUser()], '#wall');
}
/**
- * @see \wcf\system\user\notification\event\IUserNotificationEvent::getEventHash()
+ * @inheritDoc
*/
public function getEventHash() {
return sha1($this->eventID . '-' . $this->userNotificationObject->commentID);
<?php
namespace wcf\system\user\notification\event;
-use wcf\system\comment\CommentDataHandler;
+use wcf\system\cache\runtime\CommentRuntimeCache;
+use wcf\system\cache\runtime\UserProfileRuntimeCache;
use wcf\system\request\LinkHandler;
/**
* User notification event for profile commment responses.
*
* @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 system.user.notification.event
*/
class UserProfileCommentResponseUserNotificationEvent extends AbstractSharedUserNotificationEvent {
/**
- * @see \wcf\system\user\notification\event\AbstractUserNotificationEvent::$stackable
+ * @inheritDoc
*/
protected $stackable = true;
/**
- * @see \wcf\system\user\notification\event\AbstractUserNotificationEvent::prepare()
+ * @inheritDoc
*/
protected function prepare() {
- CommentDataHandler::getInstance()->cacheCommentID($this->userNotificationObject->commentID);
- CommentDataHandler::getInstance()->cacheUserID($this->additionalData['objectID']);
- CommentDataHandler::getInstance()->cacheUserID($this->additionalData['userID']);
+ CommentRuntimeCache::getInstance()->cacheObjectID($this->userNotificationObject->commentID);
+ UserProfileRuntimeCache::getInstance()->cacheObjectID($this->additionalData['objectID']);
+ UserProfileRuntimeCache::getInstance()->cacheObjectID($this->additionalData['userID']);
}
/**
- * @see \wcf\system\user\notification\event\IUserNotificationEvent::getTitle()
+ * @inheritDoc
*/
public function getTitle() {
$count = count($this->getAuthors());
if ($count > 1) {
- return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponse.title.stacked', array(
+ return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponse.title.stacked', [
'count' => $count,
'timesTriggered' => $this->notification->timesTriggered
- ));
+ ]);
}
return $this->getLanguage()->get('wcf.user.notification.commentResponse.title');
}
/**
- * @see \wcf\system\user\notification\event\IUserNotificationEvent::getMessage()
+ * @inheritDoc
*/
public function getMessage() {
- $comment = CommentDataHandler::getInstance()->getComment($this->userNotificationObject->commentID);
- $owner = CommentDataHandler::getInstance()->getUser($comment->objectID);
+ $comment = CommentRuntimeCache::getInstance()->getObject($this->userNotificationObject->commentID);
+ $owner = UserProfileRuntimeCache::getInstance()->getObject($comment->objectID);
$authors = $this->getAuthors();
if (count($authors) > 1) {
}
$count = count($authors);
- return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponse.message.stacked', array(
+ return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponse.message.stacked', [
'authors' => array_values($authors),
'count' => $count,
'others' => $count - 1,
'owner' => $owner,
'guestTimesTriggered' => $this->notification->guestTimesTriggered
- ));
+ ]);
}
- return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponse.message', array(
+ return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponse.message', [
'author' => $this->author,
'owner' => $owner
- ));
+ ]);
}
/**
- * @see \wcf\system\user\notification\event\IUserNotificationEvent::getEmailMessage()
+ * @inheritDoc
*/
public function getEmailMessage($notificationType = 'instant') {
- $comment = CommentDataHandler::getInstance()->getComment($this->userNotificationObject->commentID);
- $owner = CommentDataHandler::getInstance()->getUser($comment->objectID);
+ $comment = CommentRuntimeCache::getInstance()->getObject($this->userNotificationObject->commentID);
+ $owner = UserProfileRuntimeCache::getInstance()->getObject($comment->objectID);
$authors = $this->getAuthors();
if (count($authors) > 1) {
}
$count = count($authors);
- return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponse.mail.stacked', array(
+ return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponse.mail.stacked', [
'author' => $this->author,
'authors' => array_values($authors),
'count' => $count,
'owner' => $owner,
'response' => $this->userNotificationObject,
'guestTimesTriggered' => $this->notification->guestTimesTriggered
- ));
+ ]);
}
- return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponse.mail', array(
+ return $this->getLanguage()->getDynamicVariable('wcf.user.notification.commentResponse.mail', [
'response' => $this->userNotificationObject,
'author' => $this->author,
'owner' => $owner,
'notificationType' => $notificationType
- ));
+ ]);
}
/**
- * @see \wcf\system\user\notification\event\IUserNotificationEvent::getLink()
+ * @inheritDoc
*/
public function getLink() {
- $comment = CommentDataHandler::getInstance()->getComment($this->userNotificationObject->commentID);
- $user = CommentDataHandler::getInstance()->getUser($comment->objectID);
+ $comment = CommentRuntimeCache::getInstance()->getObject($this->userNotificationObject->commentID);
+ $user = UserProfileRuntimeCache::getInstance()->getObject($comment->objectID);
- return LinkHandler::getInstance()->getLink('User', array('object' => $user), '#wall');
+ return LinkHandler::getInstance()->getLink('User', ['object' => $user], '#wall');
}
/**
- * @see \wcf\system\user\notification\event\IUserNotificationEvent::getEventHash()
+ * @inheritDoc
*/
public function getEventHash() {
return sha1($this->eventID . '-' . $this->userNotificationObject->commentID);
namespace wcf\system\user\notification\object\type;
use wcf\data\comment\Comment;
use wcf\data\user\UserProfile;
-use wcf\data\user\UserProfileCache;
+use wcf\system\cache\runtime\UserProfileRuntimeCache;
use wcf\system\comment\CommentHandler;
use wcf\system\database\util\PreparedStatementConditionBuilder;
use wcf\system\user\storage\UserStorageHandler;
// make sure that all users (still) have permission to access moderation
if (!$recipientIDs) {
UserStorageHandler::getInstance()->loadStorage($recipientIDs);
- $userProfiles = UserProfileCache::getInstance()->getUserProfiles($recipientIDs);
+ $userProfiles = UserProfileRuntimeCache::getInstance()->getObjects($recipientIDs);
$recipientIDs = array_keys(array_filter($userProfiles, function(UserProfile $userProfile) {
return $userProfile->getPermission('mod.general.canUseModeration');
}));