<?php
+
namespace wcf\data\user\profile\visitor;
-use wcf\data\user\UserProfile;
+
use wcf\data\AbstractDatabaseObjectAction;
use wcf\data\IGroupedUserListAction;
+use wcf\data\user\UserProfile;
use wcf\system\cache\runtime\UserProfileRuntimeCache;
use wcf\system\exception\PermissionDeniedException;
+ use wcf\system\exception\UserInputException;
use wcf\system\user\GroupedUserList;
use wcf\system\WCF;
/**
* Executes profile visitor-related actions.
- *
- * @author Alexander Ebert
- * @copyright 2001-2019 WoltLab GmbH
- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @package WoltLabSuite\Core\Data\User\Profile\Visitor
- *
- * @method UserProfileVisitor create()
- * @method UserProfileVisitorEditor[] getObjects()
- * @method UserProfileVisitorEditor getSingleObject()
+ *
+ * @author Alexander Ebert
+ * @copyright 2001-2019 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package WoltLabSuite\Core\Data\User\Profile\Visitor
+ *
+ * @method UserProfileVisitor create()
+ * @method UserProfileVisitorEditor[] getObjects()
+ * @method UserProfileVisitorEditor getSingleObject()
*/
-class UserProfileVisitorAction extends AbstractDatabaseObjectAction implements IGroupedUserListAction {
- /**
- * @inheritDoc
- */
- protected $allowGuestAccess = ['getGroupedUserList'];
-
- /**
- * user profile object
- * @var UserProfile;
- */
- public $userProfile = null;
-
- /**
- * @inheritDoc
- */
- public function validateGetGroupedUserList() {
- $this->readInteger('pageNo');
- $this->readInteger('userID');
-
- $this->userProfile = UserProfileRuntimeCache::getInstance()->getObject($this->parameters['userID']);
- if (!$this->userProfile) {
- throw new UserInputException('userID');
- }
- if ($this->userProfile->isProtected()) {
- throw new PermissionDeniedException();
- }
- }
-
- /**
- * @inheritDoc
- */
- public function getGroupedUserList() {
- // resolve page count
- $sql = "SELECT COUNT(*)
- FROM wcf".WCF_N."_user_profile_visitor
- WHERE ownerID = ?";
- $statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute([$this->parameters['userID']]);
- $pageCount = ceil($statement->fetchSingleColumn() / 20);
-
- // get user ids
- $sql = "SELECT userID
- FROM wcf".WCF_N."_user_profile_visitor
- WHERE ownerID = ?
- ORDER BY time DESC";
- $statement = WCF::getDB()->prepareStatement($sql, 20, ($this->parameters['pageNo'] - 1) * 20);
- $statement->execute([$this->parameters['userID']]);
- $userIDs = $statement->fetchAll(\PDO::FETCH_COLUMN);
-
- // create group
- $group = new GroupedUserList();
- $group->addUserIDs($userIDs);
-
- // load user profiles
- GroupedUserList::loadUsers();
-
- WCF::getTPL()->assign([
- 'groupedUsers' => [$group]
- ]);
-
- return [
- 'pageCount' => $pageCount,
- 'template' => WCF::getTPL()->fetch('groupedUserList')
- ];
- }
-
- /**
- * Inserts a new visitor if it does not already exist, or updates it if it does.
- * @since 5.2
- */
- public function registerVisitor() {
- $sql = "INSERT INTO wcf".WCF_N."_user_profile_visitor
- (ownerID, userID, time)
- VALUES (?, ?, ?)
- ON DUPLICATE KEY UPDATE time = VALUES(time)";
- $statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute([
- $this->parameters['data']['ownerID'],
- $this->parameters['data']['userID'],
- $this->parameters['data']['time'] ?? TIME_NOW,
- ]);
- }
+class UserProfileVisitorAction extends AbstractDatabaseObjectAction implements IGroupedUserListAction
+{
+ /**
+ * @inheritDoc
+ */
+ protected $allowGuestAccess = ['getGroupedUserList'];
+
+ /**
+ * user profile object
+ * @var UserProfile;
+ */
+ public $userProfile;
+
+ /**
+ * @inheritDoc
+ */
+ public function validateGetGroupedUserList()
+ {
+ $this->readInteger('pageNo');
+ $this->readInteger('userID');
+
+ $this->userProfile = UserProfileRuntimeCache::getInstance()->getObject($this->parameters['userID']);
++ if (!$this->userProfile) {
++ throw new UserInputException('userID');
++ }
+ if ($this->userProfile->isProtected()) {
+ throw new PermissionDeniedException();
+ }
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function getGroupedUserList()
+ {
+ // resolve page count
+ $sql = "SELECT COUNT(*)
+ FROM wcf" . WCF_N . "_user_profile_visitor
+ WHERE ownerID = ?";
+ $statement = WCF::getDB()->prepareStatement($sql);
+ $statement->execute([$this->parameters['userID']]);
+ $pageCount = \ceil($statement->fetchSingleColumn() / 20);
+
+ // get user ids
+ $sql = "SELECT userID
+ FROM wcf" . WCF_N . "_user_profile_visitor
+ WHERE ownerID = ?
+ ORDER BY time DESC";
+ $statement = WCF::getDB()->prepareStatement($sql, 20, ($this->parameters['pageNo'] - 1) * 20);
+ $statement->execute([$this->parameters['userID']]);
+ $userIDs = $statement->fetchAll(\PDO::FETCH_COLUMN);
+
+ // create group
+ $group = new GroupedUserList();
+ $group->addUserIDs($userIDs);
+
+ // load user profiles
+ GroupedUserList::loadUsers();
+
+ WCF::getTPL()->assign([
+ 'groupedUsers' => [$group],
+ ]);
+
+ return [
+ 'pageCount' => $pageCount,
+ 'template' => WCF::getTPL()->fetch('groupedUserList'),
+ ];
+ }
+
+ /**
+ * Inserts a new visitor if it does not already exist, or updates it if it does.
+ * @since 5.2
+ */
+ public function registerVisitor()
+ {
+ $sql = "INSERT INTO wcf" . WCF_N . "_user_profile_visitor
+ (ownerID, userID, time)
+ VALUES (?, ?, ?)
+ ON DUPLICATE KEY UPDATE time = VALUES(time)";
+ $statement = WCF::getDB()->prepareStatement($sql);
+ $statement->execute([
+ $this->parameters['data']['ownerID'],
+ $this->parameters['data']['userID'],
+ $this->parameters['data']['time'] ?? TIME_NOW,
+ ]);
+ }
}
use wcf\system\WCF;
/**
- * Provides user trophy actions.
+ * Provides user trophy actions.
*
- * @author Joshua Ruesweg
- * @copyright 2001-2019 WoltLab GmbH
- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @package WoltLabSuite\Core\Data\User\Trophy
- * @since 3.1
+ * @author Joshua Ruesweg
+ * @copyright 2001-2019 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package WoltLabSuite\Core\Data\User\Trophy
+ * @since 3.1
*
- * @method UserTrophyEditor[] getObjects()
- * @method UserTrophyEditor getSingleObject()
+ * @method UserTrophyEditor[] getObjects()
+ * @method UserTrophyEditor getSingleObject()
*/
-class UserTrophyAction extends AbstractDatabaseObjectAction {
- /**
- * @inheritDoc
- */
- protected $permissionsDelete = ['admin.trophy.canAwardTrophy'];
-
- /**
- * @inheritDoc
- */
- protected $allowGuestAccess = ['getGroupedUserTrophyList'];
-
- /**
- * @var UserProfile
- */
- public $userProfile;
-
- /**
- * @inheritDoc
- */
- public function create() {
- /** @var UserTrophy $userTrophy */
- $userTrophy = parent::create();
-
- if (!$userTrophy->getTrophy()->isDisabled()) {
- $userAction = new UserAction([$userTrophy->userID], 'update', [
- 'counters' => [
- 'trophyPoints' => 1
- ]
- ]);
- $userAction->executeAction();
-
- // checks if the user still has space to add special trophies
- if (count($userTrophy->getUserProfile()->getSpecialTrophies()) < $userTrophy->getUserProfile()->getPermission('user.profile.trophy.maxUserSpecialTrophies')) {
- $hasTrophy = false;
- foreach (UserTrophyList::getUserTrophies([$userTrophy->getUserProfile()->userID])[$userTrophy->getUserProfile()->userID] as $trophy) {
- if ($trophy->trophyID == $userTrophy->trophyID && $trophy->userTrophyID !== $userTrophy->userTrophyID) {
- $hasTrophy = true;
- break;
- }
- }
-
- if (!$hasTrophy) {
- $userProfileAction = new UserProfileAction([$userTrophy->getUserProfile()->getDecoratedObject()], 'updateSpecialTrophies', [
- 'trophyIDs' => array_unique(array_merge(array_map(function($trophy) {
- return $trophy->trophyID;
- }, $userTrophy->getUserProfile()->getSpecialTrophies()), [$userTrophy->trophyID]))
- ]);
- $userProfileAction->executeAction();
- }
- }
- }
-
- UserActivityEventHandler::getInstance()->fireEvent('com.woltlab.wcf.userTrophy.recentActivityEvent.trophyReceived', $userTrophy->getObjectID(), null, $userTrophy->userID);
-
- UserNotificationHandler::getInstance()->fireEvent('received', 'com.woltlab.wcf.userTrophy.notification', new UserTrophyNotificationObject($userTrophy), [
- $userTrophy->userID
- ]);
-
- return $userTrophy;
- }
-
- /**
- * @inheritDoc
- */
- public function validateDelete() {
- parent::validateDelete();
-
- /** @var UserTrophy $object */
- foreach ($this->objects as $object) {
- if ($object->getTrophy()->awardAutomatically) {
- throw new PermissionDeniedException();
- }
- }
- }
-
- /**
- * @inheritDoc
- */
- public function delete() {
- if (empty($this->objects)) {
- $this->readObjects();
- }
-
- $trophyIDs = $userIDs = [];
- foreach ($this->getObjects() as $object) {
- $trophyIDs[] = $object->trophyID;
- $userIDs[] = $object->userID;
- }
-
- $returnValues = parent::delete();
-
- if (!empty($this->objects)) {
- // update user special trophies trophies
- $userTrophies = UserTrophyList::getUserTrophies($userIDs);
-
- foreach ($userTrophies as $userID => $trophies) {
- $userTrophyIDs = [];
- foreach ($trophies as $trophy) {
- $userTrophyIDs[] = $trophy->trophyID;
- }
-
- $conditionBuilder = new PreparedStatementConditionBuilder();
- if (!empty($userTrophyIDs)) $conditionBuilder->add('trophyID NOT IN (?)', [array_unique($userTrophyIDs)]);
- $conditionBuilder->add('userID = ?', [$userID]);
-
- $sql = "DELETE FROM wcf". WCF_N ."_user_special_trophy ". $conditionBuilder;
- $statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute($conditionBuilder->getParameters());
-
- UserStorageHandler::getInstance()->reset([$userID], 'specialTrophies');
- }
-
- $updateUserTrophies = [];
- foreach ($this->getObjects() as $object) {
- if (!$object->getTrophy()->isDisabled()) {
- if (!isset($updateUserTrophies[$object->userID])) $updateUserTrophies[$object->userID] = 0;
- $updateUserTrophies[$object->userID]--;
- }
- }
-
- foreach ($updateUserTrophies as $userID => $count) {
- $userAction = new UserAction([$userID], 'update', [
- 'counters' => [
- 'trophyPoints' => $count
- ]
- ]);
- $userAction->executeAction();
- }
- }
-
- return $returnValues;
- }
-
- /**
- * Validates the getGroupedUserTrophyList method.
- */
- public function validateGetGroupedUserTrophyList() {
- if (!MODULE_TROPHY) {
- throw new IllegalLinkException();
- }
-
- WCF::getSession()->checkPermissions(['user.profile.trophy.canSeeTrophies']);
-
- $this->readInteger('pageNo');
- $this->readInteger('userID');
-
- $this->userProfile = UserProfileRuntimeCache::getInstance()->getObject($this->parameters['userID']);
- if (!$this->userProfile) {
- throw new UserInputException('userID');
- }
- if (!$this->userProfile->isAccessible('canViewTrophies') && $this->userProfile->userID != WCF::getSession()->userID) {
- throw new PermissionDeniedException();
- }
- }
-
- /**
- * Returns a viewable user trophy list for a specific user.
- */
- public function getGroupedUserTrophyList() {
- $userTrophyList = new UserTrophyList();
- $userTrophyList->getConditionBuilder()->add('userID = ?', [$this->parameters['userID']]);
- if (!empty($userTrophyList->sqlJoins)) $userTrophyList->sqlJoins .= ' ';
- if (!empty($userTrophyList->sqlConditionJoins)) $userTrophyList->sqlConditionJoins .= ' ';
- $userTrophyList->sqlJoins .= 'LEFT JOIN wcf'. WCF_N . '_trophy trophy ON user_trophy.trophyID = trophy.trophyID';
- $userTrophyList->sqlConditionJoins .= 'LEFT JOIN wcf'. WCF_N . '_trophy trophy ON user_trophy.trophyID = trophy.trophyID';
-
- // trophy category join
- $userTrophyList->sqlJoins .= ' LEFT JOIN wcf'. WCF_N . '_category category ON trophy.categoryID = category.categoryID';
- $userTrophyList->sqlConditionJoins .= ' LEFT JOIN wcf'. WCF_N . '_category category ON trophy.categoryID = category.categoryID';
-
- $userTrophyList->getConditionBuilder()->add('trophy.isDisabled = ?', [0]);
- $userTrophyList->getConditionBuilder()->add('category.isDisabled = ?', [0]);
- $userTrophyList->sqlLimit = 10;
- $userTrophyList->sqlOffset = ($this->parameters['pageNo'] - 1) * 10;
- $userTrophyList->sqlOrderBy = 'time DESC';
- $pageCount = ceil($userTrophyList->countObjects() / 10);
- $userTrophyList->readObjects();
-
- return [
- 'pageCount' => $pageCount,
- 'title' => WCF::getLanguage()->getDynamicVariable('wcf.user.trophy.dialogTitle', ['username' => $this->userProfile->username]),
- 'template' => WCF::getTPL()->fetch('groupedUserTrophyList', 'wcf', [
- 'userTrophyList' => $userTrophyList
- ])
- ];
- }
+class UserTrophyAction extends AbstractDatabaseObjectAction
+{
+ /**
+ * @inheritDoc
+ */
+ protected $permissionsDelete = ['admin.trophy.canAwardTrophy'];
+
+ /**
+ * @inheritDoc
+ */
+ protected $allowGuestAccess = ['getGroupedUserTrophyList'];
+
+ /**
+ * @var UserProfile
+ */
+ public $userProfile;
+
+ /**
+ * @inheritDoc
+ */
+ public function create()
+ {
+ /** @var UserTrophy $userTrophy */
+ $userTrophy = parent::create();
+
+ if (!$userTrophy->getTrophy()->isDisabled()) {
+ $userAction = new UserAction([$userTrophy->userID], 'update', [
+ 'counters' => [
+ 'trophyPoints' => 1,
+ ],
+ ]);
+ $userAction->executeAction();
+
+ // checks if the user still has space to add special trophies
+ if (\count($userTrophy->getUserProfile()->getSpecialTrophies()) < $userTrophy->getUserProfile()->getPermission('user.profile.trophy.maxUserSpecialTrophies')) {
+ $hasTrophy = false;
+ foreach (UserTrophyList::getUserTrophies([$userTrophy->getUserProfile()->userID])[$userTrophy->getUserProfile()->userID] as $trophy) {
+ if ($trophy->trophyID == $userTrophy->trophyID && $trophy->userTrophyID !== $userTrophy->userTrophyID) {
+ $hasTrophy = true;
+ break;
+ }
+ }
+
+ if (!$hasTrophy) {
+ $userProfileAction = new UserProfileAction(
+ [$userTrophy->getUserProfile()->getDecoratedObject()],
+ 'updateSpecialTrophies',
+ [
+ 'trophyIDs' => \array_unique(\array_merge(\array_map(static function ($trophy) {
+ return $trophy->trophyID;
+ }, $userTrophy->getUserProfile()->getSpecialTrophies()), [$userTrophy->trophyID])),
+ ]
+ );
+ $userProfileAction->executeAction();
+ }
+ }
+ }
+
+ UserActivityEventHandler::getInstance()->fireEvent(
+ 'com.woltlab.wcf.userTrophy.recentActivityEvent.trophyReceived',
+ $userTrophy->getObjectID(),
+ null,
+ $userTrophy->userID
+ );
+
+ UserNotificationHandler::getInstance()->fireEvent(
+ 'received',
+ 'com.woltlab.wcf.userTrophy.notification',
+ new UserTrophyNotificationObject($userTrophy),
+ [
+ $userTrophy->userID,
+ ]
+ );
+
+ return $userTrophy;
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function validateDelete()
+ {
+ parent::validateDelete();
+
+ /** @var UserTrophy $object */
+ foreach ($this->objects as $object) {
+ if ($object->getTrophy()->awardAutomatically) {
+ throw new PermissionDeniedException();
+ }
+ }
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function delete()
+ {
+ if (empty($this->objects)) {
+ $this->readObjects();
+ }
+
+ $trophyIDs = $userIDs = [];
+ foreach ($this->getObjects() as $object) {
+ $trophyIDs[] = $object->trophyID;
+ $userIDs[] = $object->userID;
+ }
+
+ $returnValues = parent::delete();
+
+ if (!empty($this->objects)) {
+ // update user special trophies trophies
+ $userTrophies = UserTrophyList::getUserTrophies($userIDs);
+
+ foreach ($userTrophies as $userID => $trophies) {
+ $userTrophyIDs = [];
+ foreach ($trophies as $trophy) {
+ $userTrophyIDs[] = $trophy->trophyID;
+ }
+
+ $conditionBuilder = new PreparedStatementConditionBuilder();
+ if (!empty($userTrophyIDs)) {
+ $conditionBuilder->add('trophyID NOT IN (?)', [\array_unique($userTrophyIDs)]);
+ }
+ $conditionBuilder->add('userID = ?', [$userID]);
+
+ $sql = "DELETE FROM wcf" . WCF_N . "_user_special_trophy
+ " . $conditionBuilder;
+ $statement = WCF::getDB()->prepareStatement($sql);
+ $statement->execute($conditionBuilder->getParameters());
+
+ UserStorageHandler::getInstance()->reset([$userID], 'specialTrophies');
+ }
+
+ $updateUserTrophies = [];
+ foreach ($this->getObjects() as $object) {
+ if (!$object->getTrophy()->isDisabled()) {
+ if (!isset($updateUserTrophies[$object->userID])) {
+ $updateUserTrophies[$object->userID] = 0;
+ }
+ $updateUserTrophies[$object->userID]--;
+ }
+ }
+
+ foreach ($updateUserTrophies as $userID => $count) {
+ $userAction = new UserAction([$userID], 'update', [
+ 'counters' => [
+ 'trophyPoints' => $count,
+ ],
+ ]);
+ $userAction->executeAction();
+ }
+ }
+
+ return $returnValues;
+ }
+
+ /**
+ * Validates the getGroupedUserTrophyList method.
+ */
+ public function validateGetGroupedUserTrophyList()
+ {
+ if (!MODULE_TROPHY) {
+ throw new IllegalLinkException();
+ }
+
+ WCF::getSession()->checkPermissions(['user.profile.trophy.canSeeTrophies']);
+
+ $this->readInteger('pageNo');
+ $this->readInteger('userID');
+
+ $this->userProfile = UserProfileRuntimeCache::getInstance()->getObject($this->parameters['userID']);
- if (!$this->userProfile->isAccessible('canViewTrophies') && !($this->userProfile->userID == WCF::getSession()->userID)) {
++ if (!$this->userProfile) {
++ throw new UserInputException('userID');
++ }
++ if (!$this->userProfile->isAccessible('canViewTrophies') && $this->userProfile->userID != WCF::getSession()->userID) {
+ throw new PermissionDeniedException();
+ }
+ }
+
+ /**
+ * Returns a viewable user trophy list for a specific user.
+ */
+ public function getGroupedUserTrophyList()
+ {
+ $userTrophyList = new UserTrophyList();
+ $userTrophyList->getConditionBuilder()->add('userID = ?', [$this->parameters['userID']]);
+ if (!empty($userTrophyList->sqlJoins)) {
+ $userTrophyList->sqlJoins .= ' ';
+ }
+ if (!empty($userTrophyList->sqlConditionJoins)) {
+ $userTrophyList->sqlConditionJoins .= ' ';
+ }
+ $userTrophyList->sqlJoins .= '
+ LEFT JOIN wcf' . WCF_N . '_trophy trophy
+ ON user_trophy.trophyID = trophy.trophyID';
+ $userTrophyList->sqlConditionJoins .= '
+ LEFT JOIN wcf' . WCF_N . '_trophy trophy
+ ON user_trophy.trophyID = trophy.trophyID';
+
+ // trophy category join
+ $userTrophyList->sqlJoins .= '
+ LEFT JOIN wcf' . WCF_N . '_category category
+ ON trophy.categoryID = category.categoryID';
+ $userTrophyList->sqlConditionJoins .= '
+ LEFT JOIN wcf' . WCF_N . '_category category
+ ON trophy.categoryID = category.categoryID';
+
+ $userTrophyList->getConditionBuilder()->add('trophy.isDisabled = ?', [0]);
+ $userTrophyList->getConditionBuilder()->add('category.isDisabled = ?', [0]);
+ $userTrophyList->sqlLimit = 10;
+ $userTrophyList->sqlOffset = ($this->parameters['pageNo'] - 1) * 10;
+ $userTrophyList->sqlOrderBy = 'time DESC';
+ $pageCount = \ceil($userTrophyList->countObjects() / 10);
+ $userTrophyList->readObjects();
+
+ return [
+ 'pageCount' => $pageCount,
+ 'title' => WCF::getLanguage()->getDynamicVariable(
+ 'wcf.user.trophy.dialogTitle',
+ ['username' => $this->userProfile->username]
+ ),
+ 'template' => WCF::getTPL()->fetch('groupedUserTrophyList', 'wcf', [
+ 'userTrophyList' => $userTrophyList,
+ ]),
+ ];
+ }
}
/**
* Runtime cache implementation for comment responses.
- *
- * @author Matthias Schmidt
- * @copyright 2001-2019 WoltLab GmbH
- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @package WoltLabSuite\Core\System\Cache\Runtime
- * @since 3.0
- *
- * @method CommentResponse[] getCachedObjects()
- * @method CommentResponse|null getObject($objectID)
- * @method CommentResponse[] getObjects(array $objectIDs)
+ *
+ * @author Matthias Schmidt
+ * @copyright 2001-2019 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package WoltLabSuite\Core\System\Cache\Runtime
+ * @since 3.0
+ *
- * @method CommentResponse[] getCachedObjects()
- * @method CommentResponse getObject($objectID)
- * @method CommentResponse[] getObjects(array $objectIDs)
++ * @method CommentResponse[] getCachedObjects()
++ * @method CommentResponse|null getObject($objectID)
++ * @method CommentResponse[] getObjects(array $objectIDs)
*/
-class CommentResponseRuntimeCache extends AbstractRuntimeCache {
- /**
- * @inheritDoc
- */
- protected $listClassName = CommentResponseList::class;
+class CommentResponseRuntimeCache extends AbstractRuntimeCache
+{
+ /**
+ * @inheritDoc
+ */
+ protected $listClassName = CommentResponseList::class;
}
/**
* Runtime cache implementation for comments.
- *
- * @author Matthias Schmidt
- * @copyright 2001-2019 WoltLab GmbH
- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @package WoltLabSuite\Core\System\Cache\Runtime
- * @since 3.0
- *
- * @method Comment[] getCachedObjects()
- * @method Comment|null getObject($objectID)
- * @method Comment[] getObjects(array $objectIDs)
+ *
+ * @author Matthias Schmidt
+ * @copyright 2001-2019 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package WoltLabSuite\Core\System\Cache\Runtime
+ * @since 3.0
+ *
- * @method Comment[] getCachedObjects()
- * @method Comment getObject($objectID)
- * @method Comment[] getObjects(array $objectIDs)
++ * @method Comment[] getCachedObjects()
++ * @method Comment|null getObject($objectID)
++ * @method Comment[] getObjects(array $objectIDs)
*/
-class CommentRuntimeCache extends AbstractRuntimeCache {
- /**
- * @inheritDoc
- */
- protected $listClassName = CommentList::class;
+class CommentRuntimeCache extends AbstractRuntimeCache
+{
+ /**
+ * @inheritDoc
+ */
+ protected $listClassName = CommentList::class;
}
/**
* Runtime cache implementation for shared media.
- *
- * @author Alexander Ebert
- * @copyright 2001-2019 WoltLab GmbH
- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @package WoltLabSuite\Core\System\Cache\Runtime
- * @since 3.0
- *
- * @method Media[] getCachedObjects()
- * @method Media|null getObject($objectID)
- * @method Media[] getObjects(array $objectIDs)
+ *
+ * @author Alexander Ebert
+ * @copyright 2001-2019 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package WoltLabSuite\Core\System\Cache\Runtime
+ * @since 3.0
+ *
+ * @method Media[] getCachedObjects()
- * @method Media getObject($objectID)
++ * @method Media|null getObject($objectID)
+ * @method Media[] getObjects(array $objectIDs)
*/
-class MediaRuntimeCache extends AbstractRuntimeCache {
- /**
- * @inheritDoc
- */
- protected $listClassName = MediaList::class;
+class MediaRuntimeCache extends AbstractRuntimeCache
+{
+ /**
+ * @inheritDoc
+ */
+ protected $listClassName = MediaList::class;
}
/**
* Runtime cache implementation for user profiles.
*
- * @author Alexander Ebert, Matthias Schmidt
- * @copyright 2001-2019 WoltLab GmbH
- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @package WoltLabSuite\Core\System\Cache\Runtime
- * @since 3.0
- *
- * @method UserProfile[] getCachedObjects()
- * @method UserProfile|null getObject($objectID)
- * @method UserProfile[] getObjects(array $objectIDs)
+ * @author Alexander Ebert, Matthias Schmidt
+ * @copyright 2001-2019 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package WoltLabSuite\Core\System\Cache\Runtime
+ * @since 3.0
+ *
- * @method UserProfile[] getCachedObjects()
- * @method UserProfile getObject($objectID)
- * @method UserProfile[] getObjects(array $objectIDs)
++ * @method UserProfile[] getCachedObjects()
++ * @method UserProfile|null getObject($objectID)
++ * @method UserProfile[] getObjects(array $objectIDs)
*/
-class UserProfileRuntimeCache extends AbstractRuntimeCache {
- /**
- * @inheritDoc
- */
- protected $listClassName = UserProfileList::class;
-
- /**
- * Adds a user profile to the cache. This is an internal method that should
- * not be used on a regular basis.
- *
- * @param UserProfile $profile
- * @since 3.1
- */
- public function addUserProfile(UserProfile $profile) {
- $objectID = $profile->getObjectID();
-
- if (!isset($this->objects[$objectID])) {
- $this->objects[$objectID] = $profile;
- }
- }
+class UserProfileRuntimeCache extends AbstractRuntimeCache
+{
+ /**
+ * @inheritDoc
+ */
+ protected $listClassName = UserProfileList::class;
+
+ /**
+ * Adds a user profile to the cache. This is an internal method that should
+ * not be used on a regular basis.
+ *
+ * @param UserProfile $profile
+ * @since 3.1
+ */
+ public function addUserProfile(UserProfile $profile)
+ {
+ $objectID = $profile->getObjectID();
+
+ if (!isset($this->objects[$objectID])) {
+ $this->objects[$objectID] = $profile;
+ }
+ }
}
/**
* Runtime cache implementation for users.
*
- * @author Matthias Schmidt
- * @copyright 2001-2019 WoltLab GmbH
- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @package WoltLabSuite\Core\System\Cache\Runtime
- * @since 3.0
- *
- * @method User[] getCachedObjects()
- * @method User|null getObject($objectID)
- * @method User[] getObjects(array $objectIDs)
+ * @author Matthias Schmidt
+ * @copyright 2001-2019 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package WoltLabSuite\Core\System\Cache\Runtime
+ * @since 3.0
+ *
+ * @method User[] getCachedObjects()
- * @method User getObject($objectID)
++ * @method User|null getObject($objectID)
+ * @method User[] getObjects(array $objectIDs)
*/
-class UserRuntimeCache extends AbstractRuntimeCache {
- /**
- * @inheritDoc
- */
- protected $listClassName = UserList::class;
+class UserRuntimeCache extends AbstractRuntimeCache
+{
+ /**
+ * @inheritDoc
+ */
+ protected $listClassName = UserList::class;
}
/**
* Runtime cache implementation for viewable article contents.
*
- * @author Joshua Ruesweg
- * @copyright 2001-2019 WoltLab GmbH
- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @package WoltLabSuite\Core\System\Cache\Runtime
- * @since 5.2
+ * @author Joshua Ruesweg
+ * @copyright 2001-2019 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package WoltLabSuite\Core\System\Cache\Runtime
+ * @since 5.2
*
- * @method ViewableArticleContent[] getCachedObjects()
- * @method ViewableArticleContent|null getObject($objectID)
- * @method ViewableArticleContent[] getObjects(array $objectIDs)
+ * @method ViewableArticleContent[] getCachedObjects()
- * @method ViewableArticleContent getObject($objectID)
++ * @method ViewableArticleContent|null getObject($objectID)
+ * @method ViewableArticleContent[] getObjects(array $objectIDs)
*/
-class ViewableArticleContentRuntimeCache extends AbstractRuntimeCache {
- /**
- * @inheritDoc
- */
- protected $listClassName = ViewableArticleContentList::class;
+class ViewableArticleContentRuntimeCache extends AbstractRuntimeCache
+{
+ /**
+ * @inheritDoc
+ */
+ protected $listClassName = ViewableArticleContentList::class;
}
/**
* Runtime cache implementation for viewable articles.
*
- * @author Marcel Werk
- * @copyright 2001-2019 WoltLab GmbH
- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @package WoltLabSuite\Core\System\Cache\Runtime
- * @since 3.0
- *
- * @method ViewableArticle[] getCachedObjects()
- * @method ViewableArticle|null getObject($objectID)
- * @method ViewableArticle[] getObjects(array $objectIDs)
+ * @author Marcel Werk
+ * @copyright 2001-2019 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package WoltLabSuite\Core\System\Cache\Runtime
+ * @since 3.0
+ *
+ * @method ViewableArticle[] getCachedObjects()
- * @method ViewableArticle getObject($objectID)
++ * @method ViewableArticle|null getObject($objectID)
+ * @method ViewableArticle[] getObjects(array $objectIDs)
*/
-class ViewableArticleRuntimeCache extends AbstractRuntimeCache {
- /**
- * @inheritDoc
- */
- protected $listClassName = ViewableArticleList::class;
+class ViewableArticleRuntimeCache extends AbstractRuntimeCache
+{
+ /**
+ * @inheritDoc
+ */
+ protected $listClassName = ViewableArticleList::class;
}
/**
* Runtime cache implementation for viewable media.
- *
- * @author Alexander Ebert
- * @copyright 2001-2019 WoltLab GmbH
- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @package WoltLabSuite\Core\System\Cache\Runtime
- * @since 3.0
- *
- * @method ViewableMedia[] getCachedObjects()
- * @method ViewableMedia|null getObject($objectID)
- * @method ViewableMedia[] getObjects(array $objectIDs)
+ *
+ * @author Alexander Ebert
+ * @copyright 2001-2019 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package WoltLabSuite\Core\System\Cache\Runtime
+ * @since 3.0
+ *
+ * @method ViewableMedia[] getCachedObjects()
- * @method ViewableMedia getObject($objectID)
++ * @method ViewableMedia|null getObject($objectID)
+ * @method ViewableMedia[] getObjects(array $objectIDs)
*/
-class ViewableMediaRuntimeCache extends AbstractRuntimeCache {
- /**
- * @inheritDoc
- */
- protected $listClassName = ViewableMediaList::class;
+class ViewableMediaRuntimeCache extends AbstractRuntimeCache
+{
+ /**
+ * @inheritDoc
+ */
+ protected $listClassName = ViewableMediaList::class;
}