00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include "openLogin.h"
00018 #include "cgiTemplates.h"
00019 #include "objectBase.h"
00020 #include "connectstring"
00021 #include "forms.h"
00022 #include "siteLimit.h"
00023
00024 class linkObject: public objectBase
00025 {
00026 string siteLimitation,sql;
00027 public:
00028 linkObject(openLogin &lin, cgiScript & script):objectBase(lin,script)
00029 {
00030 string siteLimitation = siteFocus(lin);
00031
00032 addField( "id", FIELD_TYPE_LONGLONG );
00033 addField( "site_id", FIELD_TYPE_LONGLONG );
00034 addField( "name", FIELD_TYPE_STRING );
00035 addField( "url", FIELD_TYPE_STRING );
00036 addField( "target", FIELD_TYPE_STRING );
00037
00038
00039 addControl( "id", staticEntry( "id", "10" ) );
00040 sql += "select id, name from sites";
00041 if( siteLimitation.length() != 0 )
00042 {
00043 sql += " where id ";
00044 sql += siteLimitation;
00045 }
00046 sql += " order by name";
00047 addControl( "site_id", cmboEntry( "site_id",
00048 sql ) );
00049 addControl( "name", textEntry( "name", "64" ) );
00050 addControl( "url", textEntry( "url", "64" ) );
00051 addControl( "target", textEntry( "target", "64" ) );
00052
00053
00054 setName("links");
00055 }
00056
00057 bool validate(void){ return true; }
00058
00059
00060 bool cleanup(void) { return true; }
00061 };
00062
00063 void linkForm(cgiScript & script, openLogin & login)
00064 {
00065 linkObject obj(login,script);
00066 cgiTemplates htmlDoc;
00067 htmlDoc.load("Templates/siteAdminForm.html");
00068 ocString top(htmlDoc.getParagraph("top"));
00069 cgiInput & args = script.ClientArguments();
00070
00071 script << top.replace( "_entity_", "Link" )
00072 .replace( "_link_", "linkList.cgi" )
00073 .replace( "__link__", "linkForm.cgi" ) << endl;
00074
00075 obj.go();
00076
00077 ocString listTemplate(htmlDoc.getParagraph("formitem"));
00078
00079 script << listTemplate.replace ( "_label_", "Id" )
00080 .replace ( "_form_item_", obj.getControl("id")->getHtml().c_str() );
00081
00082 script << listTemplate.replace ( "_label_", "Site Id" )
00083 .replace ( "_form_item_", obj.getControl("site_id")->getHtml().c_str() );
00084
00085 script << listTemplate.replace ( "_label_", "Name" )
00086 .replace ( "_form_item_", obj.getControl("name")->getHtml().c_str() );
00087
00088 script << listTemplate.replace ( "_label_", "URL" )
00089 .replace ( "_form_item_", obj.getControl("url")->getHtml().c_str() );
00090
00091 script << listTemplate.replace ( "_label_", "Window Target" )
00092 .replace ( "_form_item_", obj.getControl("target")->getHtml().c_str() );
00093
00094 ocString bottom(htmlDoc.getParagraph("bottom"));
00095 script << bottom.replace( "_form_buttons_", formButtons(args).c_str() )
00096 .replace( "__results__", obj.resultString().c_str() )
00097 .replace( "__js__", "document.forms[0].name.focus();" ) << endl;
00098 }
00099
00100 int main( int argcount, char ** args )
00101 {
00102 bool isSignedOn = false;
00103
00104
00105
00106 cgiScript script("text/html",false);
00107 openLogin login;
00108
00109
00110 if ( login.testLoginStatus() )
00111 {
00112 isSignedOn = true;
00113 }
00114 if( isSignedOn )
00115 {
00116 script.closeHeader();
00117 linkForm(script,login);
00118 }
00119 else
00120 {
00121 script.Redirect("signIn.html");
00122 script.closeHeader();
00123 return(0);
00124 }
00125 }