00001
00002
00003
00004
00005 #ifndef W3_Intranet_h
00006 #define W3_Intranet_h
00007
00008
00009
00010
00011 #include "affiliateLogin.h"
00012
00013 openLogin oLogin;
00014
00015 #include "connectstring"
00016 #include "cgiClass.h"
00017 #include "page.hpp"
00018 #include "page_control.hpp"
00019 #include "page_enhancements.hpp"
00020 #include "forms.h"
00021 #include "ocTypes.h"
00022 #include "read_write_base.hpp"
00023 #include "superlist_base.hpp"
00024 #include "forms.h"
00025 #include "forms_base.hpp"
00026 #include "lookup.hpp"
00027
00028
00029 bool intraMain(page & pg ,cgiScript & script);
00030
00031
00032 bool check(cgiScript & script)
00033 {
00034 bool isSignedOn = false;
00035 if ( (script.ClientArguments().count("login")==1) &&
00036 (script.ClientArguments().count("password")==1) &&
00037 (script.ClientArguments().count("group_id")==0) )
00038 {
00039
00040 aString & asLogin = script.ClientArguments()["login"];
00041 aString & asPassword = script.ClientArguments()["password"];
00042
00043 isSignedOn = oLogin.checkUser( asLogin.str(), asPassword.str() );
00044
00045 }
00046 else
00047 {
00048
00049
00050 if ( oLogin.testLoginStatus() )
00051 {
00052 if( script.ClientArguments().count("signoff") )
00053 {
00054 cgiCookie cookie;
00055 cookie.setTimeout( 1, 1, 1970, 0, 0 );
00056 cookie.setPath("/");
00057 cookie.set( "intraToken", "" );
00058
00059 isSignedOn = false;
00060 }
00061 else
00062 {
00063 isSignedOn = true;
00064 }
00065 }
00066 }
00067 return isSignedOn;
00068 }
00069
00070 class servicelist_functor: public base_functor
00071 {
00072 cgiScript & script;
00073 bool isSignedOn;
00074
00075
00076 string path;
00077 public:
00078
00079 servicelist_functor(page & ipg,cgiScript & script, bool isSignedOn)
00080 :base_functor(ipg),script(script),isSignedOn(isSignedOn){;}
00081 virtual ~servicelist_functor(){;}
00082
00083 virtual bool operator()( xmlNode & node )
00084 {
00085 bool bRet = false;
00086 string item;
00087 if( isSignedOn )
00088 {
00089 bRet = true;
00090
00091 ocString catheadingTemplate = pg.paragraph_string( "catheading" );
00092 ocString catitemTemplate = pg.paragraph_string( "catitem" );
00093 string lastCat;
00094 if( oLogin.fetchServices() )
00095 {
00096 serviceVector & svcNames = oLogin.ServiceNames();
00097 serviceMap & svcs = oLogin.Services();
00098 for(int ix=0;ix<svcNames.size();++ix)
00099 {
00100 openService & service = svcs[svcNames[ix]];
00101 if( lastCat != service.cat_name )
00102 {
00103 lastCat = service.cat_name;
00104 script << catheadingTemplate.replace("$content",lastCat.c_str());
00105 }
00106 script << catitemTemplate.replace("$level",service.tree_depth.c_str())
00107 .replace("$location", fixURI(service.uri).c_str())
00108 .replace("$label",service.menu_name.c_str());
00109 }
00110 }
00111 string loggedIn = oLogin.FullName();
00112 script << catheadingTemplate.replace("$content",loggedIn.c_str());
00113 script << catitemTemplate.replace("$level","1")
00114 .replace("$location","?signoff=true")
00115 .replace("$label","Sign Off");
00116 }
00117 return bRet;
00118 }
00119 string fixURI( ocString uri )
00120 {
00121
00122 if( uri.regExMatch(":") ) return uri;
00123
00124
00125 string fixedURI = "http://";
00126
00127
00128 fixedURI += script.ServerName().c_str();
00129
00130
00131 if( path.length() == 0 )
00132 {
00133 ocString sql = "select url from metasite.sites where id = ";
00134 sql.append(pg.site_id());
00135 path = tableLookup( sql );
00136 }
00137
00138
00139 if( uri.regExMatch("/") == false )
00140 {
00141
00142 fixedURI += path;
00143 }
00144
00145 fixedURI += uri;
00146 return fixedURI;
00147 }
00148 };
00149
00150 class form_functor: public base_functor
00151 {
00152 cgiScript & script;
00153 bool isSignedOn;
00154
00155
00156 public:
00157
00158 form_functor(page & ipg
00159 ,cgiScript & script
00160 ,bool isSignedOn
00161
00162
00163 )
00164 :base_functor(ipg)
00165 ,script(script)
00166 ,isSignedOn(isSignedOn)
00167
00168 {;}
00169 virtual ~form_functor(){;}
00170
00171 virtual bool operator()( xmlNode & node )
00172 {
00173 bool bRet = false;
00174
00175 if( isSignedOn || script.PathInfo() == "/Register" )
00176 {
00177 bRet = intraMain( pg , script);
00178 }
00179 else
00180 {
00181
00182 script << pg.paragraph_string( "sign_on_form" );
00183
00184 pg.get_page_paragraphs().clear();
00185 }
00186 return bRet;
00187 }
00188
00189 };
00190
00191
00192 #endif