Skip to content
This repository has been archived by the owner on Sep 19, 2020. It is now read-only.

Commit

Permalink
Display the page note in preview module only if the user has less mou…
Browse files Browse the repository at this point in the history
…nted root pages than all root pages
  • Loading branch information
qzminski committed Jul 30, 2016
1 parent cbf829c commit 17dbbb7
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/Derhaeuptling/SeoSerpPreview/PreviewModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -212,11 +212,25 @@ protected function runTestsForTable($module, $table)
$pages = $db->execute("SELECT * FROM tl_page");

if ($pages->numRows) {
$test = $this->runTests($table, $pages);
$notes = [];
$notes = [];
$rootCount = 0;
$userCount = 0;

// Count the total root pages and thoes the user has access to
while ($pages->next()) {
if ($pages->type === 'root') {
$rootCount++;

if (in_array($pages->id, (array)$user->pagemounts)) {
$userCount++;
}
}
}

$test = $this->runTests($table, $pages->reset());

// Add the note if the user is not admin and there are some errors or warnings
if (!$user->isAdmin && ($test['errors'] > 0 || $test['warnings'] > 0)) {
if (!$user->isAdmin && $userCount < $rootCount && ($test['errors'] > 0 || $test['warnings'] > 0)) {
$notes[] = $GLOBALS['TL_LANG']['MSC']['seo_serp_module.pagesNote'];
}

Expand Down

0 comments on commit 17dbbb7

Please sign in to comment.