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