Skip to content

Commit 4a9828f

Browse files
committed
Merge branch '4.0' into 'main'
2 parents 0d3da59 + 0e4b291 commit 4a9828f

File tree

4 files changed

+25
-7
lines changed

4 files changed

+25
-7
lines changed

phpmyfaq/index.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@
115115
//
116116
// Set actual template set name
117117
//
118-
TwigWrapper::setTemplateSetName($faqConfig->get('layout.templateSet'));
118+
TwigWrapper::setTemplateSetName($faqConfig->getTemplateSet());
119119

120120
/*
121121
* Initialize attachment factory

phpmyfaq/src/phpMyFAQ/Configuration.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,11 @@ public function getAdminEmail(): string
176176
return $this->config['main.administrationMail'];
177177
}
178178

179+
public function getTemplateSet(): string
180+
{
181+
return $this->config['layout.templateSet'] ?? 'default';
182+
}
183+
179184
/**
180185
* Returns the email address of the no-reply sender
181186
*/
@@ -371,9 +376,9 @@ public function getElasticsearch(): Client
371376
/**
372377
* Sets the Elasticsearch configuration.
373378
*/
374-
public function setElasticsearchConfig(ElasticsearchConfiguration $elasticsearchConfiguration): void
379+
public function setElasticsearchConfig(ElasticsearchConfiguration $esConfiguration): void
375380
{
376-
$this->config['core.elasticsearchConfig'] = $elasticsearchConfiguration;
381+
$this->config['core.elasticsearchConfig'] = $esConfiguration;
377382
}
378383

379384
/**
@@ -542,7 +547,7 @@ public function getPluginManager(): PluginManager
542547
return $this->config['core.pluginManager'];
543548
}
544549

545-
public function triggerEvent(string $eventName, $data = null): void
550+
public function triggerEvent(string $eventName, mixed $data = null): void
546551
{
547552
$this->pluginManager->triggerEvent($eventName, $data);
548553
}

phpmyfaq/src/phpMyFAQ/Controller/AbstractController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public function __construct()
7272
$this->container = $this->createContainer();
7373
$this->configuration = $this->container->get('phpmyfaq.configuration');
7474
$this->currentUser = $this->container->get('phpmyfaq.user.current_user');
75-
TwigWrapper::setTemplateSetName($this->configuration->get('layout.templateSet'));
75+
TwigWrapper::setTemplateSetName($this->configuration->getTemplateSet());
7676
$this->isSecured();
7777
}
7878

phpmyfaq/src/phpMyFAQ/Permission/MediumPermission.php

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ public function checkUserGroupRight(int $userId, int $rightId): bool
166166
);
167167

168168
$res = $this->configuration->getDb()->query($select);
169-
return $this->configuration->getDb()->numRows($res) === 1;
169+
return $this->configuration->getDb()->numRows($res) !== 0;
170170
}
171171

172172
/**
@@ -545,7 +545,7 @@ public function getGroupName(int $groupId): string
545545
/**
546546
* Returns an array that contains the right-IDs of all rights
547547
* the user $userId owns. User-rights and the rights the user
548-
* owns because of a group-membership are taken into account.
548+
* owns because of a group-membership is taken into account.
549549
*
550550
* @param int $userId User ID
551551
*
@@ -563,6 +563,19 @@ public function getAllUserRights(int $userId): array
563563
return array_unique(array_merge($userRights, $groupRights));
564564
}
565565

566+
/**
567+
* Returns the number of user- and group-rights the user specified by
568+
* user_id owns.
569+
*
570+
* @param CurrentUser $currentUser User object
571+
*/
572+
public function getUserRightsCount(CurrentUser $currentUser): int
573+
{
574+
$userRights = $this->getAllUserRights($currentUser->getUserId());
575+
576+
return is_countable($userRights) ? count($userRights) : 0;
577+
}
578+
566579
/**
567580
* Returns an array that contains the IDs of all rights the user
568581
* $userId owns because of a group-membership.

0 commit comments

Comments
 (0)