diff options
author | jeff <jeff> | 2010-01-08 16:05:04 +0000 |
---|---|---|
committer | jeff <jeff> | 2010-01-08 16:05:04 +0000 |
commit | 43e42a04ae37ca7a84c05d9ff8b94d9f8cde6dcf (patch) | |
tree | de3a12b93ad38d24bc15511d87e65ff5a6d3b9cd | |
parent | 20b563c398c5c9264a998d31ae0d3d95454d526e (diff) |
add a logout link (RT 1330 & 5518)
-rw-r--r-- | Makefile | 1 | ||||
-rw-r--r-- | htetc/freeside-base1.99.conf | 10 | ||||
-rw-r--r-- | htetc/freeside-base1.conf | 10 | ||||
-rw-r--r-- | htetc/freeside-base2.conf | 10 | ||||
-rw-r--r-- | htetc/htpasswd.logout | 1 | ||||
-rw-r--r-- | httemplate/elements/header.html | 4 | ||||
-rw-r--r-- | httemplate/elements/logout.html | 44 | ||||
-rw-r--r-- | httemplate/elements/rs_init_object.html | 29 | ||||
-rw-r--r-- | httemplate/elements/xmlhttp.html | 19 |
9 files changed, 109 insertions, 19 deletions
@@ -171,6 +171,7 @@ install-docs: docs cp -r masondocs ${FREESIDE_DOCUMENT_ROOT} chown -R freeside:freeside ${FREESIDE_DOCUMENT_ROOT} cp htetc/handler.pl ${MASON_HANDLER} + cp htetc/htpasswd.logout ${FREESIDE_CONF} [ ! -e ${MASONDATA} ] && mkdir ${MASONDATA} || true chown -R freeside ${MASONDATA} diff --git a/htetc/freeside-base1.99.conf b/htetc/freeside-base1.99.conf index afda3819e..f3f767651 100644 --- a/htetc/freeside-base1.99.conf +++ b/htetc/freeside-base1.99.conf @@ -26,3 +26,13 @@ SetHandler perl-script PerlHandler HTML::Mason </Directory> +<Directory %%%FREESIDE_DOCUMENT_ROOT%%%/loginout> +AuthName Freeside +AuthType Basic +AuthUserFile %%%FREESIDE_CONF%%%/htpasswd.logout +require valid-user +<Files ~ "(\.cgi|\.html)$"> +SetHandler default-handler +</Files> +</Directory> + diff --git a/htetc/freeside-base1.conf b/htetc/freeside-base1.conf index 0834505bc..16e1e147d 100644 --- a/htetc/freeside-base1.conf +++ b/htetc/freeside-base1.conf @@ -23,3 +23,13 @@ PerlHandler HTML::Mason require "%%%MASON_HANDLER%%%"; </Perl> +<Directory %%%FREESIDE_DOCUMENT_ROOT%%%/loginout> +AuthName Freeside +AuthType Basic +AuthUserFile %%%FREESIDE_CONF%%%/htpasswd.logout +require valid-user +<Files ~ "(\.cgi|\.html)$"> +SetHandler default-handler +</Files> +</Directory> + diff --git a/htetc/freeside-base2.conf b/htetc/freeside-base2.conf index 2f1afcf6e..76e79976e 100644 --- a/htetc/freeside-base2.conf +++ b/htetc/freeside-base2.conf @@ -26,3 +26,13 @@ SetHandler perl-script PerlHandler HTML::Mason </Directory> +<Directory %%%FREESIDE_DOCUMENT_ROOT%%%/loginout> +AuthName Freeside +AuthType Basic +AuthUserFile %%%FREESIDE_CONF%%%/htpasswd.logout +require valid-user +<Files ~ "(\.cgi|\.html)$"> +SetHandler default-handler +</Files> +</Directory> + diff --git a/htetc/htpasswd.logout b/htetc/htpasswd.logout new file mode 100644 index 000000000..3523f2357 --- /dev/null +++ b/htetc/htpasswd.logout @@ -0,0 +1 @@ +magic:Jgvaxb502SIqQ diff --git a/httemplate/elements/header.html b/httemplate/elements/header.html index 495923c4d..5c4d736d2 100644 --- a/httemplate/elements/header.html +++ b/httemplate/elements/header.html @@ -37,6 +37,8 @@ Example: %> <% include('init_overlib.html') |n %> + <% include('rs_init_object.html') |n %> + <% include('logout.html') |n %> <SCRIPT TYPE="text/javascript"> @@ -82,7 +84,7 @@ Example: <td align=left BGCOLOR="#ffffff"> <!-- valign="top" --> <font size=6><% $company_name || 'ExampleCo' %></font> </td> - <td align=right valign=top BGCOLOR="#ffffff"><FONT SIZE="-1">Logged in as <b><% getotaker %> </b><br></FONT><FONT SIZE="-2"><a href="<%$fsurl%>pref/pref.html" STYLE="color: #000000">Preferences</a> + <td align=right valign=top BGCOLOR="#ffffff"><FONT SIZE="-1">Logged in as <b><% getotaker %> </b> <FONT SIZE="-2">[ <a href="javascript:void(0);" onClick="logout();">logout</a> ]</FONT><br></FONT><FONT SIZE="-2"><a href="<%$fsurl%>pref/pref.html" STYLE="color: #000000">Preferences</a> % if ( $conf->config("ticket_system") % && FS::TicketSystem->access_right(\%session, 'ModifySelf') ) { | <a href="<%$fsurl%>rt/User/Prefs.html" STYLE="color: #000000">Ticketing preferences</a> diff --git a/httemplate/elements/logout.html b/httemplate/elements/logout.html new file mode 100644 index 000000000..313dbfaf1 --- /dev/null +++ b/httemplate/elements/logout.html @@ -0,0 +1,44 @@ +<%doc> + +Example: + + include( '/elements/logout.html'); + This is the <a href="javascript:void()" onClick="logout();">logout</a> link. + +</%doc> +<SCRIPT TYPE="text/javascript"> + + function logout() { + // count args; build URL + var url = "<% $fsurl. 'loginout/logout.html' %>"; + + var xmlhttp = rs_init_object(); + xmlhttp.open("GET", url, false, "magic", "notyet"); + xmlhttp.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT"); + xmlhttp.send(null); + + if (xmlhttp.readyState != 4) { + alert("Logout failed: readyState is " + xmlhttp.readyState); + return; + } + + if (xmlhttp.status != 200) { + alert("Logout failed: status is " + xmlhttp.status); + } else { + var data = xmlhttp.responseText; + // alert('received response: ' + data); + if ( data.indexOf("<b>System error</b>") > -1 ) { + var w; + if ( w = window.open("about:blank") ) { + w.document.write(data); + } else { + // popup blocking? should use an overlib popup instead + alert("Error popup disabled; try disabling popup blocking to see"); + } + } else { + window.location = "<% $fsurl. 'loginout/logout.html' %>"; + } + } + } + +</SCRIPT> diff --git a/httemplate/elements/rs_init_object.html b/httemplate/elements/rs_init_object.html new file mode 100644 index 000000000..3bb0b4279 --- /dev/null +++ b/httemplate/elements/rs_init_object.html @@ -0,0 +1,29 @@ +<%doc> + +Example: + + include( '/elements/rs_init_object.html' ); + +</%doc> +<SCRIPT TYPE="text/javascript"> + + function rs_init_object() { + var A; + try { + A=new ActiveXObject("Msxml2.XMLHTTP"); + } catch (e) { + try { + A=new ActiveXObject("Microsoft.XMLHTTP"); + } catch (oc) { + A=null; + } + } + if(!A && typeof XMLHttpRequest != "undefined") + A = new XMLHttpRequest(); + if (!A) + alert("Can't create XMLHttpRequest object"); + return A; + + } + +</SCRIPT> diff --git a/httemplate/elements/xmlhttp.html b/httemplate/elements/xmlhttp.html index d0c799095..2df3c42c9 100644 --- a/httemplate/elements/xmlhttp.html +++ b/httemplate/elements/xmlhttp.html @@ -14,26 +14,9 @@ Example: ); </%doc> +<% include( '/elements/rs_init_object.html' ) %> <SCRIPT TYPE="text/javascript"> - function rs_init_object() { - var A; - try { - A=new ActiveXObject("Msxml2.XMLHTTP"); - } catch (e) { - try { - A=new ActiveXObject("Microsoft.XMLHTTP"); - } catch (oc) { - A=null; - } - } - if(!A && typeof XMLHttpRequest != "undefined") - A = new XMLHttpRequest(); - if (!A) - alert("Can't create XMLHttpRequest object"); - return A; - - } % foreach my $func ( @{$opt{'subs'}} ) { % % my $furl = $url; |