Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 30 additions & 6 deletions classes/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,11 @@ public function __construct(Parameters $parameters) {
*/
public function buildAndSelect($calcRows = false) {
global $wgNonincludableNamespaces;

// Get namespace permission from Lockdown extension
global $wgNamespacePermissionLockdown;
// Get user object from current logged in user
global $wgUser;

$options = [];

$parameters = $this->parameters->getAllParameters();
Expand Down Expand Up @@ -199,11 +203,31 @@ public function buildAndSelect($calcRows = false) {
}
//Always add nonincludeable namespaces.
if (is_array($wgNonincludableNamespaces) && count($wgNonincludableNamespaces)) {
$this->addNotWhere(
[
$this->tableNames['page'] . '.page_namespace' => $wgNonincludableNamespaces
]
);
// Check if Lockdown installed
if (!empty($wgNamespacePermissionLockdown)) {
$addNotWhere = [];
// Check for each "NonincludableNamespace" if permission to read is granted for current user (group)
foreach ($wgNonincludableNamespaces as $namespaceId) {
if (isset($wgNamespacePermissionLockdown[$namespaceId])) {
// Check for "read" permissions of current user on NonincludableNamespaces, not empty = read permissions!
$outp = array_intersect($wgNamespacePermissionLockdown[$namespaceId]['read'], $wgUser->getGroups());
if (empty($outp)) {
$addNotWhere[] = $namespaceId;
}
}
}
} else {
// If Lockdown not installed take the normal NonincludableNamespaces
$addNotWhere = $wgNonincludableNamespaces;
}
// Recheck if still NS in (new) array, than kill all namespaces that shouldn't be included
if (is_array($addNotWhere) && count($addNotWhere)) {
$this->addNotWhere(
[
$this->tableNames['page'].'.page_namespace' => $addNotWhere // Changed var
]
);
}
}

if ($this->offset !== false) {
Expand Down