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 17dbbb7 commit 7c6b011
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions src/Derhaeuptling/SeoSerpPreview/PreviewModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -212,26 +212,28 @@ protected function runTestsForTable($module, $table)
$pages = $db->execute("SELECT * FROM tl_page");

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

// 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++;
// 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)) {
$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 && $userCount < $rootCount && ($test['errors'] > 0 || $test['warnings'] > 0)) {
$notes[] = $GLOBALS['TL_LANG']['MSC']['seo_serp_module.pagesNote'];
if ($userCount < $rootCount) {
$notes[] = $GLOBALS['TL_LANG']['MSC']['seo_serp_module.pagesNote'];
}
}

$return[] = [
Expand Down

0 comments on commit 7c6b011

Please sign in to comment.