File tree Expand file tree Collapse file tree 7 files changed +25
-10
lines changed Expand file tree Collapse file tree 7 files changed +25
-10
lines changed Original file line number Diff line number Diff line change 2929 " OnManagerPageBeforeRender" ,
3030 " OnManagerLogin" ,
3131 " OnWebLogin" ,
32- " OnMODXInit"
32+ " OnMODXInit" ,
33+ " OnLoadWebDocument"
3334 ]
3435 }
3536 ]
Original file line number Diff line number Diff line change 2626 " OnManagerPageBeforeRender" ,
2727 " OnManagerLogin" ,
2828 " OnWebLogin" ,
29- " OnMODXInit"
29+ " OnMODXInit" ,
30+ " OnLoadWebDocument"
3031 ]
3132 }
3233 ],
Original file line number Diff line number Diff line change 22
33namespace Fred \Elements \Event ;
44
5- class OnLoadWebDocument
5+ class OnLoadWebDocument extends Event
66{
77 use \Fred \Traits \Elements \Event \OnLoadWebDocument;
88}
Original file line number Diff line number Diff line change @@ -9,10 +9,10 @@ trait OnLoadWebDocument
99 use User;
1010 public function run ()
1111 {
12- if (!$ this -> canFred ( )) {
12+ if (!isset ( $ _GET [ ' fred ' ] )) {
1313 return ;
1414 }
15- if ($ _GET [ ' fred ' ] && intval ( $ _GET [ ' fred ' ]) !== 2 ) {
15+ if (! $ this -> canFred () ) {
1616 return ;
1717 }
1818 $ this ->modx ->resource ->set ('cacheable ' , 0 );
Original file line number Diff line number Diff line change @@ -9,10 +9,10 @@ trait OnMODXInit
99 use User;
1010 public function run ()
1111 {
12- if (! $ this -> canFred () ) {
12+ if ($ _GET [ ' fred ' ] && intval ( $ _GET [ ' fred ' ]) !== 2 ) {
1313 return ;
1414 }
15- if ($ _GET [ ' fred ' ] && intval ( $ _GET [ ' fred ' ]) !== 2 ) {
15+ if (! $ this -> canFred () ) {
1616 return ;
1717 }
1818
@@ -21,9 +21,16 @@ public function run()
2121 if (empty ($ params ) || empty ($ params ['themeSettingsPrefix ' ]) || empty ($ params ['themeSettings ' ]) || !is_array ($ params ['themeSettings ' ])) {
2222 return ;
2323 }
24+ $ this ->modx ->setOption ('cache_resource ' , false );
25+ $ this ->modx ->setOption ('pageshrink.cache_resource_shrink ' , false );
26+ $ this ->modx ->setOption ('pageshrink.resource_shrink ' , false );
2427
2528 foreach ($ params ['themeSettings ' ] as $ name => $ value ) {
26- $ this ->modx ->setOption ($ params ['themeSettingsPrefix ' ] . '.setting. ' . $ name , $ value );
29+ $ key = $ params ['themeSettingsPrefix ' ] . '.setting. ' . $ name ;
30+ $ this ->modx ->setOption ($ key , $ value );
31+ if ($ this ->modx ->context ) {
32+ $ this ->modx ->context ->config [$ key ] = $ value ;
33+ }
2734 }
2835 }
2936}
Original file line number Diff line number Diff line change @@ -9,7 +9,13 @@ public function canFred(): bool
99 if (!$ this ->modx ->user ) {
1010 return false ;
1111 }
12- if (!($ this ->modx ->user ->hasSessionContext ('mgr ' ) || $ this ->modx ->user ->hasSessionContext ($ this ->modx ->resource ->context_key ))) {
12+ if (!(
13+ $ this ->modx ->user ->hasSessionContext ('mgr ' ) ||
14+ (
15+ $ this ->modx ->resource &&
16+ $ this ->modx ->user ->hasSessionContext ($ this ->modx ->resource ->context_key )
17+ )
18+ )) {
1319 return false ;
1420 }
1521 if (!$ this ->modx ->hasPermission ('fred ' )) {
Original file line number Diff line number Diff line change 22
33namespace Fred \v2 \Elements \Event ;
44
5- class OnLoadWebDocument
5+ class OnLoadWebDocument extends Event
66{
77 use \Fred \Traits \Elements \Event \OnLoadWebDocument;
88}
You can’t perform that action at this time.
0 commit comments