File tree 8 files changed +91
-41
lines changed
8 files changed +91
-41
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Fred \Elements \Event ;
4
+
5
+ class OnLoadWebDocument
6
+ {
7
+ use \Fred \Traits \Elements \Event \OnLoadWebDocument;
8
+ }
Original file line number Diff line number Diff line change 3
3
4
4
class OnMODXInit extends Event
5
5
{
6
-
7
- public function run ()
8
- {
9
- if ($ _GET ['fred ' ] && intval ($ _GET ['fred ' ]) !== 2 ) {
10
- return ;
11
- }
12
-
13
- $ params = json_decode (file_get_contents ('php://input ' ), true );
14
-
15
- if (empty ($ params ) || empty ($ params ['themeSettingsPrefix ' ]) || empty ($ params ['themeSettings ' ]) || !is_array ($ params ['themeSettings ' ])) {
16
- return ;
17
- }
18
-
19
- foreach ($ params ['themeSettings ' ] as $ name => $ value ) {
20
- $ this ->modx ->setOption ($ params ['themeSettingsPrefix ' ] . '.setting. ' . $ name , $ value );
21
- }
22
- }
6
+ use \Fred \Traits \Elements \Event \OnMODXInit;
23
7
}
8
+
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Fred \Traits \Elements \Event ;
4
+
5
+ use Fred \Traits \User ;
6
+
7
+ trait OnLoadWebDocument
8
+ {
9
+ use User;
10
+ public function run ()
11
+ {
12
+ if (!$ this ->canFred ()) {
13
+ return ;
14
+ }
15
+ if ($ _GET ['fred ' ] && intval ($ _GET ['fred ' ]) !== 2 ) {
16
+ return ;
17
+ }
18
+ $ this ->modx ->resource ->set ('cacheable ' , 0 );
19
+ }
20
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Fred \Traits \Elements \Event ;
4
+
5
+ use Fred \Traits \User ;
6
+
7
+ trait OnMODXInit
8
+ {
9
+ use User;
10
+ public function run ()
11
+ {
12
+ if (!$ this ->canFred ()) {
13
+ return ;
14
+ }
15
+ if ($ _GET ['fred ' ] && intval ($ _GET ['fred ' ]) !== 2 ) {
16
+ return ;
17
+ }
18
+
19
+ $ params = json_decode (file_get_contents ('php://input ' ), true );
20
+
21
+ if (empty ($ params ) || empty ($ params ['themeSettingsPrefix ' ]) || empty ($ params ['themeSettings ' ]) || !is_array ($ params ['themeSettings ' ])) {
22
+ return ;
23
+ }
24
+
25
+ foreach ($ params ['themeSettings ' ] as $ name => $ value ) {
26
+ $ this ->modx ->setOption ($ params ['themeSettingsPrefix ' ] . '.setting. ' . $ name , $ value );
27
+ }
28
+ }
29
+ }
Original file line number Diff line number Diff line change 3
3
namespace Fred \Traits \Elements \Event ;
4
4
5
5
use Firebase \JWT \JWT ;
6
+ use Fred \Traits \User ;
6
7
use Wa72 \HtmlPageDom \HtmlPageCrawler ;
7
8
8
9
trait OnWebPagePrerender
9
10
{
11
+ use User;
10
12
public function run ()
11
13
{
12
14
$ theme = $ this ->fred ->getTheme ($ this ->modx ->resource ->template );
13
15
if (!empty ($ theme )) {
14
- if (!$ this ->modx ->user ) {
15
- return ;
16
- }
17
- if (!($ this ->modx ->user ->hasSessionContext ('mgr ' ) || $ this ->modx ->user ->hasSessionContext ($ this ->modx ->resource ->context_key ))) {
18
- return ;
19
- }
20
- if (!$ this ->modx ->hasPermission ('fred ' )) {
16
+ if (!$ this ->canFred ()) {
21
17
return ;
22
18
}
23
19
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Fred \Traits ;
4
+
5
+ trait User
6
+ {
7
+ public function canFred (): bool
8
+ {
9
+ if (!$ this ->modx ->user ) {
10
+ return false ;
11
+ }
12
+ if (!($ this ->modx ->user ->hasSessionContext ('mgr ' ) || $ this ->modx ->user ->hasSessionContext ($ this ->modx ->resource ->context_key ))) {
13
+ return false ;
14
+ }
15
+ if (!$ this ->modx ->hasPermission ('fred ' )) {
16
+ return false ;
17
+ }
18
+ return true ;
19
+ }
20
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Fred \v2 \Elements \Event ;
4
+
5
+ class OnLoadWebDocument
6
+ {
7
+ use \Fred \Traits \Elements \Event \OnLoadWebDocument;
8
+ }
Original file line number Diff line number Diff line change 3
3
4
4
class OnMODXInit extends Event
5
5
{
6
-
7
- public function run ()
8
- {
9
- if ($ _GET ['fred ' ] && intval ($ _GET ['fred ' ]) !== 2 ) {
10
- return ;
11
- }
12
-
13
- $ params = json_decode (file_get_contents ('php://input ' ), true );
14
-
15
- if (empty ($ params ) || empty ($ params ['themeSettingsPrefix ' ]) || empty ($ params ['themeSettings ' ]) || !is_array ($ params ['themeSettings ' ])) {
16
- return ;
17
- }
18
-
19
- foreach ($ params ['themeSettings ' ] as $ name => $ value ) {
20
- $ this ->modx ->setOption ($ params ['themeSettingsPrefix ' ] . '.setting. ' . $ name , $ value );
21
- }
22
- }
6
+ use \Fred \Traits \Elements \Event \OnMODXInit;
23
7
}
You can’t perform that action at this time.
0 commit comments