Skip to content

Commit

Permalink
Compatibility Update for WSC 6.0 (#3)
Browse files Browse the repository at this point in the history
* Update XSD

* Prepare version 6.0.0

* Add required function type declaration

* Replace deprecated function

* Implement dirty fix for dynamic property creation

* Release 6.0.0

* Applied small optimizations

---------

Co-authored-by: Sascha Greuel <github@1-2.dev>
  • Loading branch information
IceQ1337 and SoftCreatR authored Dec 29, 2023
1 parent 1c183c9 commit 3bba2d3
Show file tree
Hide file tree
Showing 14 changed files with 224 additions and 140 deletions.
3 changes: 2 additions & 1 deletion box.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<data xmlns="http://www.woltlab.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.woltlab.com http://www.woltlab.com/XSD/2019/box.xsd">
<data xmlns="http://www.woltlab.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.woltlab.com https://www.woltlab.com/XSD/6.0/box.xsd">
<import>
<box identifier="com.uz.box.posts">
<name language="de">Mitglieder mit den meisten Beiträgen (X)</name>
Expand All @@ -15,6 +15,7 @@
<content language="de">
<title>Mitglieder mit den meisten Beiträgen</title>
</content>

<content language="en">
<title>Members with the most Posts</title>
</content>
Expand Down
27 changes: 18 additions & 9 deletions files/lib/system/box/UzBoxPostsBoxController.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

namespace wbb\system\box;

use wbb\system\cache\builder\UzBoxPostsCacheBuilder;
use wcf\system\box\AbstractDatabaseObjectListBoxController;
use wcf\system\event\EventHandler;
use wcf\system\exception\SystemException;
use wcf\system\request\LinkHandler;
use wcf\system\WCF;

Expand Down Expand Up @@ -53,14 +55,16 @@ class UzBoxPostsBoxController extends AbstractDatabaseObjectListBoxController
/**
* data
*/
protected $lasts = [];
protected array $lasts = [];

/**
* @inheritDoc
*
* @throws SystemException
*/
public function getLink()
public function getLink(): string
{
if (MODULE_MEMBERS_LIST) {
if ($this->hasLink()) {
$parameters = 'sortField=wbbPosts&sortOrder=DESC';

return LinkHandler::getInstance()->getLink('MembersList', [], $parameters);
Expand All @@ -71,14 +75,18 @@ public function getLink()

/**
* @inheritDoc
*
* @throws SystemException
*/
protected function getObjectList()
{
// get conditions as parameters for cache builder
$parameters = [];
foreach ($this->box->getConditions() as $condition) {

foreach ($this->box->getControllerConditions() as $condition) {
$parameters[] = $condition->conditionData;
}

$parameters[] = ['limit' => $this->limit];

$temp = UzBoxPostsCacheBuilder::getInstance()->getData($parameters);
Expand All @@ -91,7 +99,7 @@ protected function getObjectList()
/**
* @inheritDoc
*/
protected function getTemplate()
protected function getTemplate(): string
{
return WCF::getTPL()->fetch('boxUzPosts', 'wbb', [
'boxUserList' => $this->objectList,
Expand All @@ -101,8 +109,9 @@ protected function getTemplate()

/**
* @inheritDoc
* @throws SystemException
*/
public function hasContent()
public function hasContent(): bool
{
// module
if (!MODULE_LIKE) {
Expand All @@ -122,16 +131,16 @@ public function hasContent()
/**
* @inheritDoc
*/
protected function loadContent()
protected function loadContent(): void
{
$this->content = $this->getTemplate();
}

/**
* @inheritDoc
*/
public function hasLink()
public function hasLink(): bool
{
return MODULE_MEMBERS_LIST == 1;
return MODULE_MEMBERS_LIST === 1 && WCF::getSession()->getPermission('user.profile.canViewMembersList');
}
}
Loading

0 comments on commit 3bba2d3

Please sign in to comment.