00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef users_HPP
00012 #define users_HPP
00013
00014 #include "read_write_base.hpp"
00015
00016 class users_Obj: public read_write_base
00017 {
00018 public:
00019 identifier id;
00020 string first;
00021 string last;
00022 string login;
00023 string password;
00024 string phone;
00025 string mobile;
00026 string fax;
00027 string email;
00028
00029
00030
00031 ocString user_roles;
00032
00033 users_Obj():read_write_base()
00034 ,id(0LL)
00035 ,first("")
00036 ,last("")
00037 ,login("")
00038 ,password("")
00039 ,phone("")
00040 ,email("")
00041 {
00042
00043 data_name("users");
00044
00045 addDXMap( new llongXfer("id", &id ));
00046 addDXMap( new stringXfer("first", &first ));
00047 addDXMap( new stringXfer("last", &last ));
00048 addDXMap( new stringXfer("login", &login ));
00049 addDXMap( new stringXfer("password", &password ));
00050 addDXMap( new stringXfer("phone", &phone ));
00051 addDXMap( new stringXfer("mobile", &mobile ));
00052 addDXMap( new stringXfer("fax", &fax ));
00053 addDXMap( new stringXfer("email", &email ));
00054
00055 }
00056
00057 virtual bool setRoles( void )
00058 {
00059 bool bRet = false;
00060 if( user_roles.length() )
00061 {
00062 ocString sql;
00063 ocString sqlStart = "insert into user_roles (user_id,role_id,enabled) values (";
00064 sqlStart.append(id);
00065 sqlStart += ",";
00066 user_roles.parseInit();
00067 while( !user_roles.endOfParse() )
00068 {
00069 sql = sqlStart;
00070 sql += user_roles.parse("|");
00071 sql += ",1)";
00072 bRet = cmd.execute(sql);
00073 if(!bRet) break;
00074 }
00075 }
00076
00077 return bRet;
00078 }
00079
00080
00081 virtual bool deleteRoles( void )
00082 {
00083 bool bRet = false;
00084 ocString sql = "delete from user_roles where user_id = ";
00085 sql.append(id);
00086 bRet = cmd.execute(sql);
00087 return bRet;
00088 }
00089
00090
00091 virtual bool retrieveRoles( void )
00092 {
00093 bool bRet = false;
00094 user_roles = "";
00095 ocString sql = "select role_id from user_roles where user_id = ";
00096 sql.append(id);
00097 if( rs.open(sql) )
00098 {
00099 bRet = true;
00100 bool moreData = true;
00101 do
00102 {
00103 user_roles += rs.getField(0).format();
00104 moreData = rs.next();
00105 if( moreData ) user_roles += "|";
00106 }
00107 while( moreData );
00108 }
00109 return bRet;
00110 }
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125 };
00126 #endif
00127