Skip to content

Commit 57aabc6

Browse files
authored
core (fix) add check for admin
core (fix) add check for admin in getDocumentObjectFromCacheFunction
1 parent 9616055 commit 57aabc6

File tree

1 file changed

+30
-28
lines changed

1 file changed

+30
-28
lines changed

core/src/Core.php

Lines changed: 30 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -658,7 +658,7 @@ public function checkCache($id, $loading = false)
658658
* @param bool $loading
659659
* @return string
660660
*/
661-
public function getDocumentObjectFromCache($id, $loading = false)
661+
public function getDocumentObjectFromCache($id, $loading = false)
662662
{
663663
$key = ($this->getConfig('cache_type') == 2) ? $this->makePageCacheKey($id) : $id;
664664
if ($loading) {
@@ -683,37 +683,39 @@ public function getDocumentObjectFromCache($id, $loading = false)
683683
else {
684684
$docObj = unserialize($a[0]); // rebuild document object
685685
// check page security
686-
if ($docObj['privatemgr'] && isset ($docObj['__MODxDocGroups__'])) {
687-
$pass = false;
688-
$usrGrps = $this->getUserDocGroups();
689-
$docGrps = explode(',', $docObj['__MODxDocGroups__']);
690-
// check is user has access to doc groups
691-
if (is_array($usrGrps)) {
692-
foreach ($usrGrps as $k => $v) {
693-
if (!in_array($v, $docGrps)) {
694-
continue;
686+
if ((!isset($_SESSION['mgrRole']) || $_SESSION['mgrRole'] != 1)) {
687+
if ($docObj['privatemgr'] && isset ($docObj['__MODxDocGroups__'])) {
688+
$pass = false;
689+
$usrGrps = $this->getUserDocGroups();
690+
$docGrps = explode(',', $docObj['__MODxDocGroups__']);
691+
// check is user has access to doc groups
692+
if (is_array($usrGrps)) {
693+
foreach ($usrGrps as $k => $v) {
694+
if (!in_array($v, $docGrps)) {
695+
continue;
696+
}
697+
$pass = true;
698+
break;
695699
}
696-
$pass = true;
697-
break;
698-
}
699-
}
700-
// diplay error pages if user has no access to cached doc
701-
if (!$pass) {
702-
if ($this->getConfig('unauthorized_page')) {
703-
// check if file is not public
704-
$documentGroups = DocumentGroup::where('document', $id);
705-
$total = $documentGroups->count();
706-
} else {
707-
$total = 0;
708700
}
701+
// diplay error pages if user has no access to cached doc
702+
if (!$pass) {
703+
if ($this->getConfig('unauthorized_page')) {
704+
// check if file is not public
705+
$documentGroups = DocumentGroup::where('document', $id);
706+
$total = $documentGroups->count();
707+
} else {
708+
$total = 0;
709+
}
709710

710-
if ($total > 0) {
711-
$this->sendUnauthorizedPage();
712-
} else {
713-
$this->sendErrorPage();
714-
}
711+
if ($total > 0) {
712+
$this->sendUnauthorizedPage();
713+
} else {
714+
$this->sendErrorPage();
715+
}
715716

716-
exit; // stop here
717+
exit; // stop here
718+
}
717719
}
718720
}
719721
// Grab the Scripts

0 commit comments

Comments
 (0)