add a logout link (RT 1330 & 5518)
authorjeff <jeff>
Fri, 8 Jan 2010 16:05:04 +0000 (16:05 +0000)
committerjeff <jeff>
Fri, 8 Jan 2010 16:05:04 +0000 (16:05 +0000)
Makefile
htetc/freeside-base1.99.conf
htetc/freeside-base1.conf
htetc/freeside-base2.conf
htetc/htpasswd.logout [new file with mode: 0644]
httemplate/elements/header.html
httemplate/elements/logout.html [new file with mode: 0644]
httemplate/elements/rs_init_object.html [new file with mode: 0644]
httemplate/elements/xmlhttp.html

index 6d0b2c0..41b3e8c 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -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}
 
index afda381..f3f7676 100644 (file)
@@ -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>
+
index 0834505..16e1e14 100644 (file)
@@ -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>
+
index 2f1afcf..76e7997 100644 (file)
@@ -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 (file)
index 0000000..3523f23
--- /dev/null
@@ -0,0 +1 @@
+magic:Jgvaxb502SIqQ
index 495923c..5c4d736 100644 (file)
@@ -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 %>&nbsp;</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 %>&nbsp;</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 (file)
index 0000000..313dbfa
--- /dev/null
@@ -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 (file)
index 0000000..3bb0b42
--- /dev/null
@@ -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>
index d0c7990..2df3c42 100644 (file)
@@ -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;