00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #include <string>
00014
00015 #include "openLogger.h"
00016 using namespace std;
00017 #include "roles.hpp"
00018
00019 string baseUrl;
00020
00021 #include "w3intranet.h"
00022 #include "sublist_base.hpp"
00023
00024
00025 class role_services_List: public sublist_base
00026 {
00027
00028 public:
00029 ocString Parent_Id;
00030
00031 role_services_List(cgiScript&sc):sublist_base(sc){;}
00032 ~role_services_List(){;}
00033
00034 bool list_display( void )
00035 {
00036 bool breturn = true;
00037 string sql = "select rs.id, "
00038 "s.menu_name, "
00039 "rs.enabled, "
00040 "rs.xml_params "
00041 "from role_services rs "
00042 "inner join roles r on r.id = rs.role_id "
00043 "inner join services s on s.id = rs.service_id "
00044 "where rs.role_id = " ;
00045 sql += Parent_Id;
00046 hotCol=-2;
00047 editLink = listTemplate.getParagraph("hotcolumn");
00048 editLink = editLink.replace("$prog$","role_services_Popup.cgi");
00049 string heading = "Id|"
00050 "service|"
00051 "enabled|"
00052 "xml_params"
00053 ;
00054
00055 emitHeadings(heading);
00056
00057 if( getData( sql ) )
00058 {
00059 emitData();
00060 }
00061
00062 ocString list_new = listTemplate.getParagraph("list_new");
00063 ocString url = "role_services_Popup.cgi?role_id=";
00064 url += Parent_Id;
00065 webIO << list_new.replace("$location",url.c_str()).replace("$cols","5");
00066 emitEnd();
00067 return breturn;
00068 }
00069 };
00070 class roles_List: public list_base
00071 {
00072 public:
00073
00074 roles_List(cgiScript&sc,Session_Obj & session):list_base(sc,session){;}
00075 ~roles_List(){;}
00076
00077 bool list_display( void )
00078 {
00079 bool breturn = true;
00080
00081 hotCol=-2;
00082 editLink = listTemplate.getParagraph("hotcolumn");
00083 editLink = editLink.replace("$prog$","rolesUI.meta");
00084 emitFilter( "rolesUI.meta",
00085 " <B>FILTER (by Name)</B>" );
00086 string heading =
00087 "<a class='sortcol' href='rolesUI.meta?sort=id'>id</a>|"
00088 "<a class='sortcol' href='rolesUI.meta?sort=name'>name</a>|"
00089 "<a class='sortcol' href='rolesUI.meta?sort=comment'>comment</a>"
00090 ;
00091 emitHeadings(heading);
00092 getFilteredData(
00093 "id, "
00094 "name, "
00095 "comment "
00096 ,"roles",
00097 "name like '$filter$%'" );
00098 emitData();
00099 emitNavigation("rolesUI.meta");
00100 emitEnd();
00101 return breturn;
00102 }
00103 };
00104
00105 class roles_form: public roles_Obj, public forms_base
00106 {
00107 public:
00108 roles_form(cgiScript & script):roles_Obj(),forms_base(script){setKey(*this);}
00109 virtual ~roles_form(){;}
00110
00111 void form_id_transfer( void )
00112 {
00113 llongFXfer( "id", id );
00114 }
00115 void form_data_transfer( void )
00116 {
00117 stringFXfer( "name", name);
00118 stringFXfer( "comment", comment);
00119 }
00120
00121
00122 bool dsupplemental( void )
00123 {
00124 return deleteServices();
00125 }
00126
00127 bool dbf_action( string mode, changeMap & changes )
00128 {
00129 return db_action( mode, changes );
00130 }
00131
00132
00133 bool form_display( void )
00134 {
00135 bool breturn = true;
00136 ocString sql;
00137
00138 script << makeTop("rolesUI.meta", "Roles")
00139 << formTemplate.getParagraph("advanced_begin");
00140 script << makeStaticBox("id", "id", id ,"8");
00141 script << "<br class='clearall'>" << endl;
00142 script << formTemplate.getParagraph("advanced_end");
00143
00144 script << makeTextBox("name", "name", name ,"125", "25");
00145 script << "<br class='clearall'>" << endl;
00146 script << makeTextBox("comment", "comment", comment ,"125","25");
00147 script << "<br class='clearall'>" << endl;
00148 script << makeButtons( key() );
00149
00150 if( key() )
00151 {
00152 role_services_List cList(script);
00153 cList.Parent_Id.append(key());
00154 cList.loadListTemplates("Templates/spawninglist.htmp");
00155 script << "<h5>Role services:</h5>" << endl;
00156 cList.list_display();
00157 }
00158
00159 script << makeBottom( m_result ) << endl;
00160 return breturn;
00161 }
00162 };
00163
00164 bool intraMain(page & pg ,cgiScript & script)
00165 {
00166
00167 roles_form myFrm(script);
00168 roles_List mylist(script,oLogin.Session());
00169
00170
00171 myFrm.loadControlTemplates("Templates/divform.htmp");
00172 myFrm.form_action();
00173 myFrm.form_display();
00174
00175 mylist.loadListTemplates("Templates/navlist.htmp");
00176 mylist.list_display();
00177
00178
00179 return true;
00180 }
00181
00182
00183 int main(int argc, char ** argv)
00184 {
00185 baseUrl = "rolesUI.meta";
00186
00187 cgiScript script("text/html",false);
00188 bool isSignedOn = check(script);
00189 script.closeHeader();
00190
00191
00192
00193 script.ScriptName() =
00194 ocString( script.ScriptName().c_str()).replace("rolesUI.meta","services").c_str();
00195
00196 page pg(script);
00197
00198 writelog( "load page" );
00199 if( pg.load() )
00200 {
00201 writelog( "instance of page control" );
00202 page_control ctrl(pg);
00203 ctrl.addOp ( "servicelist", new servicelist_functor(pg,script,isSignedOn) );
00204 ctrl.addOp ( "userinterface", new form_functor(pg,script,isSignedOn) );
00205 writelog( "page control emit" );
00206 ctrl.emit();
00207 }
00208 else
00209 {
00210 script << "<html><head><title>Page Unavailable</title></head>" << endl
00211 << "<body><h1>Sorry</h1>" << endl
00212 << "<p>The page you requested is not available</p></body></html>";
00213 }
00214 return 0;
00215 }
00216
00217
00218 #include "read_write_base.cpp"
00219 #include "forms_base.cpp"
00220