Skip to content

Commit

Permalink
Merge branch '4.0' into 'main'
Browse files Browse the repository at this point in the history
  • Loading branch information
thorsten committed Feb 8, 2025
2 parents 0d3da59 + 0e4b291 commit 4a9828f
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 7 deletions.
2 changes: 1 addition & 1 deletion phpmyfaq/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@
//
// Set actual template set name
//
TwigWrapper::setTemplateSetName($faqConfig->get('layout.templateSet'));
TwigWrapper::setTemplateSetName($faqConfig->getTemplateSet());

/*
* Initialize attachment factory
Expand Down
11 changes: 8 additions & 3 deletions phpmyfaq/src/phpMyFAQ/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,11 @@ public function getAdminEmail(): string
return $this->config['main.administrationMail'];
}

public function getTemplateSet(): string
{
return $this->config['layout.templateSet'] ?? 'default';
}

/**
* Returns the email address of the no-reply sender
*/
Expand Down Expand Up @@ -371,9 +376,9 @@ public function getElasticsearch(): Client
/**
* Sets the Elasticsearch configuration.
*/
public function setElasticsearchConfig(ElasticsearchConfiguration $elasticsearchConfiguration): void
public function setElasticsearchConfig(ElasticsearchConfiguration $esConfiguration): void
{
$this->config['core.elasticsearchConfig'] = $elasticsearchConfiguration;
$this->config['core.elasticsearchConfig'] = $esConfiguration;
}

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

public function triggerEvent(string $eventName, $data = null): void
public function triggerEvent(string $eventName, mixed $data = null): void
{
$this->pluginManager->triggerEvent($eventName, $data);
}
Expand Down
2 changes: 1 addition & 1 deletion phpmyfaq/src/phpMyFAQ/Controller/AbstractController.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public function __construct()
$this->container = $this->createContainer();
$this->configuration = $this->container->get('phpmyfaq.configuration');
$this->currentUser = $this->container->get('phpmyfaq.user.current_user');
TwigWrapper::setTemplateSetName($this->configuration->get('layout.templateSet'));
TwigWrapper::setTemplateSetName($this->configuration->getTemplateSet());
$this->isSecured();
}

Expand Down
17 changes: 15 additions & 2 deletions phpmyfaq/src/phpMyFAQ/Permission/MediumPermission.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ public function checkUserGroupRight(int $userId, int $rightId): bool
);

$res = $this->configuration->getDb()->query($select);
return $this->configuration->getDb()->numRows($res) === 1;
return $this->configuration->getDb()->numRows($res) !== 0;
}

/**
Expand Down Expand Up @@ -545,7 +545,7 @@ public function getGroupName(int $groupId): string
/**
* Returns an array that contains the right-IDs of all rights
* the user $userId owns. User-rights and the rights the user
* owns because of a group-membership are taken into account.
* owns because of a group-membership is taken into account.
*
* @param int $userId User ID
*
Expand All @@ -563,6 +563,19 @@ public function getAllUserRights(int $userId): array
return array_unique(array_merge($userRights, $groupRights));
}

/**
* Returns the number of user- and group-rights the user specified by
* user_id owns.
*
* @param CurrentUser $currentUser User object
*/
public function getUserRightsCount(CurrentUser $currentUser): int
{
$userRights = $this->getAllUserRights($currentUser->getUserId());

return is_countable($userRights) ? count($userRights) : 0;
}

/**
* Returns an array that contains the IDs of all rights the user
* $userId owns because of a group-membership.
Expand Down

0 comments on commit 4a9828f

Please sign in to comment.