4949$ app ->load ('tform_actions ' );
5050
5151class page_action extends tform_actions {
52-
52+ var $ _theme_changed = false ;
53+
5354 function onLoad () {
5455 global $ app , $ conf , $ tform_def_file ;
5556
@@ -80,6 +81,7 @@ function onBeforeInsert() {
8081 if (!in_array ($ this ->dataRecord ['startmodule ' ],$ this ->dataRecord ['modules ' ])) {
8182 $ app ->tform ->errorMessage .= $ app ->tform ->wordbook ['startmodule_err ' ];
8283 }
84+ $ this ->updateSessionTheme ();
8385 }
8486
8587 function onInsert () {
@@ -94,8 +96,38 @@ function onBeforeUpdate() {
9496 if (@is_array ($ this ->dataRecord ['modules ' ]) && !in_array ($ this ->dataRecord ['startmodule ' ],$ this ->dataRecord ['modules ' ])) {
9597 $ app ->tform ->errorMessage .= $ app ->tform ->wordbook ['startmodule_err ' ];
9698 }
99+ $ this ->updateSessionTheme ();
97100 }
101+
102+ function updateSessionTheme () {
103+ global $ app , $ conf ;
104+
105+ if ($ this ->dataRecord ['app_theme ' ] != 'default ' ) {
106+ $ tmp_path = ISPC_THEMES_PATH ."/ " .$ this ->dataRecord ['app_theme ' ];
107+ if (!@is_dir ($ tmp_path ) || !@file_exists ($ tmp_path ."/ISPC_VERSION " ) || trim (file_get_contents ($ tmp_path ."/ISPC_VERSION " )) != ISPC_APP_VERSION ) {
108+ // fall back to default theme if this one is not compatible with current ispc version
109+ $ this ->dataRecord ['app_theme ' ] = 'default ' ;
110+ }
111+ }
112+ if ($ this ->dataRecord ['app_theme ' ] != $ _SESSION ['s ' ]['user ' ]['theme ' ]) $ this ->_theme_changed = true ;
113+ $ _SESSION ['s ' ]['theme ' ] = $ this ->dataRecord ['app_theme ' ];
114+ $ _SESSION ['s ' ]['user ' ]['theme ' ] = $ _SESSION ['s ' ]['theme ' ];
115+ $ _SESSION ['s ' ]['user ' ]['app_theme ' ] = $ _SESSION ['s ' ]['theme ' ];
116+ }
98117
118+ function onAfterInsert () {
119+ $ this ->onAfterUpdate ();
120+ }
121+ function onAfterUpdate () {
122+ if ($ this ->_theme_changed == true ) {
123+ // not the best way, but it works
124+ header ('Content-Type: text/html ' );
125+ print '<script type="text/javascript">document.location.reload();</script> ' ;
126+ exit ;
127+ }
128+ else parent ::onShow ();
129+ }
130+
99131
100132}
101133
0 commit comments