-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
disable cache on Fred = 2 Signed-off-by: matdave <[email protected]>
- Loading branch information
Showing
8 changed files
with
91 additions
and
41 deletions.
There are no files selected for viewing
8 changes: 8 additions & 0 deletions
8
core/components/fred/src/Elements/Event/OnLoadWebDocument.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
|
||
namespace Fred\Elements\Event; | ||
|
||
class OnLoadWebDocument | ||
{ | ||
use \Fred\Traits\Elements\Event\OnLoadWebDocument; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
core/components/fred/src/Traits/Elements/Event/OnLoadWebDocument.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
namespace Fred\Traits\Elements\Event; | ||
|
||
use Fred\Traits\User; | ||
|
||
trait OnLoadWebDocument | ||
{ | ||
use User; | ||
public function run() | ||
{ | ||
if (!$this->canFred()) { | ||
return; | ||
} | ||
if ($_GET['fred'] && intval($_GET['fred']) !== 2) { | ||
return; | ||
} | ||
$this->modx->resource->set('cacheable', 0); | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
core/components/fred/src/Traits/Elements/Event/OnMODXInit.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
namespace Fred\Traits\Elements\Event; | ||
|
||
use Fred\Traits\User; | ||
|
||
trait OnMODXInit | ||
{ | ||
use User; | ||
public function run() | ||
{ | ||
if (!$this->canFred()) { | ||
return; | ||
} | ||
if ($_GET['fred'] && intval($_GET['fred']) !== 2) { | ||
return; | ||
} | ||
|
||
$params = json_decode(file_get_contents('php://input'), true); | ||
|
||
if (empty($params) || empty($params['themeSettingsPrefix']) || empty($params['themeSettings']) || !is_array($params['themeSettings'])) { | ||
return; | ||
} | ||
|
||
foreach ($params['themeSettings'] as $name => $value) { | ||
$this->modx->setOption($params['themeSettingsPrefix'] . '.setting.' . $name, $value); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
namespace Fred\Traits; | ||
|
||
trait User | ||
{ | ||
public function canFred(): bool | ||
{ | ||
if (!$this->modx->user) { | ||
return false; | ||
} | ||
if (!($this->modx->user->hasSessionContext('mgr') || $this->modx->user->hasSessionContext($this->modx->resource->context_key))) { | ||
return false; | ||
} | ||
if (!$this->modx->hasPermission('fred')) { | ||
return false; | ||
} | ||
return true; | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
core/components/fred/src/v2/Elements/Event/OnLoadWebDocument.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
|
||
namespace Fred\v2\Elements\Event; | ||
|
||
class OnLoadWebDocument | ||
{ | ||
use \Fred\Traits\Elements\Event\OnLoadWebDocument; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters