From 10dba9b4c2348a7c4c0f88fc7f0c1c2f3c5c0d7b Mon Sep 17 00:00:00 2001 From: jrd288 Date: Mon, 15 Dec 2014 17:17:03 -0500 Subject: [PATCH 1/3] Offer login instead of error When a user accesses a view but receives an error, and is not logged on, he is offered a login prompt instead. The login prompt saves the original query URL in a hidden field, and postlogin redirects back to the original URL once the user has logged on. If the user is logged in and there is an error, no login prompt is shown. This allows the user to click an event link in an e-mail and then log in before being shown the event, instead of requiring going back through the front ZM page to log in. --- web/index.php | 11 ++++++++++ web/skins/classic/views/js/postlogin.js.php | 23 +++++++++++++++++++++ web/skins/classic/views/login.php | 1 + 3 files changed, 35 insertions(+) create mode 100644 web/skins/classic/views/js/postlogin.js.php diff --git a/web/index.php b/web/index.php index f6ca44ff2..84880d70b 100644 --- a/web/index.php +++ b/web/index.php @@ -142,7 +142,18 @@ else Fatal( "View '$view' does not exist" ); require_once $includeFile; } + // If the view overrides $view to 'error', and the user is not logged in, then the + // issue is probably resolvable by logging in, so provide the opportunity to do so. + // The login view should handle redirecting to the correct location afterward. + if ( $view == 'error' && !isset($user) ) + { + $view = 'login'; + foreach ( getSkinIncludes( 'views/login.php', true, true ) as $includeFile ) + require_once $includeFile; + } } + // If the view is missing or the view still returned error with the user logged in, + // then it is not recoverable. if ( !$includeFiles || $view == 'error' ) { foreach ( getSkinIncludes( 'views/error.php', true, true ) as $includeFile ) diff --git a/web/skins/classic/views/js/postlogin.js.php b/web/skins/classic/views/js/postlogin.js.php new file mode 100644 index 000000000..fea68ec70 --- /dev/null +++ b/web/skins/classic/views/js/postlogin.js.php @@ -0,0 +1,23 @@ + + +( + function () + { + // Append '?(GET query)' to URL if the GET query is not empty. + var querySuffix = ""; + + var newUrl = thisUrl + querySuffix; + window.location.replace(newUrl); + } +).delay( 500 ); diff --git a/web/skins/classic/views/login.php b/web/skins/classic/views/login.php index a322ab663..a7562e5fa 100644 --- a/web/skins/classic/views/login.php +++ b/web/skins/classic/views/login.php @@ -29,6 +29,7 @@ xhtmlHeaders(__FILE__, $SLANG['Login'] );
+ From f4289cd2530d908e54ba0ae7ff58894f1d1b68e8 Mon Sep 17 00:00:00 2001 From: jrd288 Date: Mon, 15 Dec 2014 17:38:18 -0500 Subject: [PATCH 2/3] postlogin.js replaced by postlogin.js.php --- web/skins/classic/views/js/postlogin.js | 1 - 1 file changed, 1 deletion(-) delete mode 100644 web/skins/classic/views/js/postlogin.js diff --git a/web/skins/classic/views/js/postlogin.js b/web/skins/classic/views/js/postlogin.js deleted file mode 100644 index 06033187c..000000000 --- a/web/skins/classic/views/js/postlogin.js +++ /dev/null @@ -1 +0,0 @@ -(function () { window.location.replace( thisUrl ); }).delay( 500 ); From 52d3ec71424dd0da0e84aed8b4efe9d014ea5628 Mon Sep 17 00:00:00 2001 From: jrd288 Date: Mon, 15 Dec 2014 18:11:06 -0500 Subject: [PATCH 3/3] Fixed autotools build to reflect file name change postlogin.js -> postlolgin.js.php --- web/skins/classic/views/js/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/skins/classic/views/js/Makefile.am b/web/skins/classic/views/js/Makefile.am index ba1845e0c..a06927367 100644 --- a/web/skins/classic/views/js/Makefile.am +++ b/web/skins/classic/views/js/Makefile.am @@ -33,7 +33,7 @@ dist_web_DATA = \ montage.js \ montage.js.php \ options.js.php \ - postlogin.js \ + postlogin.js.php \ state.js \ state.js.php \ timeline.js \