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