#include <fields.h>
Inheritance diagram for FIELD_DEFS:

Public Methods | |
| FIELD_DEFS (CONFDB *formconfig) | |
| FIELD_DEFS (CONFIG_FILE *formfile) | |
| FIELD_DEFS (const char *filename) | |
| FIELD_DEFS (void) | |
| void | delval (CONFDB *c_data, const char *key) |
| int | edit (void) |
| SSTRING* | getdefault (const char *sid) |
| FIELD_DEF* | getitem (int no) const |
| void | loadval (CONFDB *c_data, const char *key) |
| int | read (void) |
| void | saveval (CONFDB *c_data, const char *key) |
| void | setupdia (DIALOG&dia) |
| int | write (void) |
Public Attributes | |
| CONFIG_FILE* | f_form |
| CONFDB* | c_form |
|
|
Definition at line 199 of file fields.cc. 00200 {
00201 c_form = formconfig;
00202 }
|
|
|
Definition at line 205 of file fields.cc. 00206 {
00207 c_form = new CONFDB(*formfile);
00208 }
|
|
|
Definition at line 211 of file fields.cc. 00212 {
00213 f_form = new CONFIG_FILE(filename,help_field
00214 ,CONFIGF_MANAGED|CONFIGF_OPTIONAL
00215 ,"root","root",0600);
00216 c_form = new CONFDB(*f_form);
00217 }
|
|
|
Definition at line 193 of file fields.cc. 00194 {
00195
00196 }
|
|
|
Definition at line 188 of file fields.cc. Referenced by saveval(). 00189 {
00190 for (int i=0; i<getnb(); i++) getitem(i)->delval(c_data,key);
00191 }
|
|
|
Definition at line 289 of file fields.cc. Referenced by formprofile_edit(). 00290 {
00291 tbtype[0] = MSG_U(I_STRING,"Text"); // String value
00292 tbtype[1] = MSG_U(I_BOOL,"Checkbox"); // Checkbox value
00293 tbtype[2] = MSG_U(I_NUM,"Numeric"); // Numeric value
00294 tbtype[3] = MSG_U(I_ENUM,"Enumeration"); // Enum value
00295 tbtype[4] = MSG_U(I_PAD,"Pad"); // Insert a pad
00296 tbtype[5] = MSG_U(I_TITLE,"Title"); // Insert a title
00297 tbtype[6] = MSG_U(I_COMBO,"Combo"); // String value from picklist or user
00298 tbtype[7] = MSG_U(I_LIST,"List"); // String value from picklist only
00299
00300 int i;
00301 DIALOG_RECORDS dia;
00302 dia.newf_head ("",MSG_U(H_FIELDDEF,"Title\tType"));
00303 for (i=0; i<getnb(); i++){
00304 FIELD_DEF *d = getitem(i);
00305 dia.set_menuitem (i,d->title.get(),tbtype[d->type]);
00306 }
00307 dia.addwhat (MSG_U(I_ADDF,"a new field"));
00308
00309 int nof = 0;
00310 while (1){
00311 MENU_STATUS code = dia.editmenu (MSG_U(T_FIELDDEFS
00312 ,"Field definitions")
00313 ,MSG_U(I_FIELDDEFS,"Define all the fields to be used in this form\n")
00314 ,help_field
00315 ,nof
00316 ,MENUBUT_ADD);
00317 if(code == MENU_QUIT || code == MENU_ESCAPE){
00318 break;
00319 }else if (code == MENU_ADD){
00320 FIELD_DEF *d = new FIELD_DEF;
00321 if (editone(d)==0) {
00322 i++;
00323 dia.set_menuitem (i,d->title.get(),tbtype[d->type]);
00324 }
00325 }else {
00326 editone(nof);
00327 }
00328 }
00329 return 0;
00330 }
|
|
|
Definition at line 332 of file fields.cc. Referenced by ldap_form_adduser(). 00333 {
00334 // NOTE : we must compare with the id, not the title because the title may have been customized by user
00335 for (int i=0; i<getnb(); i++){
00336 FIELD_DEF *d = getitem(i);
00337 if (d && !strcasecmp(d->id.get(),sid)){
00338 if (d->fdefault.getlen()>0) {
00339 D(debugf(6,"FIELD_DEF::getdefault FOUND default for key %s : %s\n",sid,d->fdefault.get()));
00340 return &d->fdefault;
00341 }
00342 }
00343 }
00344 return NULL; // not found : this attribute is not defined in the form
00345 // or the value was empty so we didn't return in the loop
00346 }
|
|
|
Definition at line 168 of file fields.cc. Referenced by edit(), getdefault(), setupdia(), and write(). 00169 {
00170 return (FIELD_DEF*)ARRAY::getitem(no);
00171 }
|
|
|
Definition at line 174 of file fields.cc. Referenced by ldap_form_edituser(). 00175 {
00176 for (int i=0; i<getnb(); i++) getitem(i)->loadval(c_data,key);
00177 }
|
|
|
Definition at line 225 of file fields.cc. Referenced by formprofile_edit(), ldap_form_adduser(), ldap_form_edituser(), and ldap_formclient(). 00226 {
00227 SSTRINGS tb;
00228 c_form->getall (K_FORMCONF,K_ID,tb,false);
00229 for (int i=0; i<tb.getnb(); i++){
00230 FIELD_DEF *d = new FIELD_DEF;
00231 add (d);
00232 const char *id = tb.getitem(i)->get();
00233 d->id.setfrom (id);
00234 char key[100];
00235 snprintf (key,sizeof(key)-1,"%s",id);
00236 d->title.setfrom (c_form->getval (key,K_TITLE));
00237 d->type = c_form->getvalnum (key,K_TYPE,FLD_TYPE_STRING);
00238 d->must_fill = c_form->getvalnum (key,K_MUSTFILL,0);
00239 d->minimum = c_form->getvalnum (key,K_MINIMUM,0);
00240 d->maximum = c_form->getvalnum (key,K_MAXIMUM,8000000);
00241 d->fdefault.setfrom (c_form->getval (key,K_DEFAULT));
00242 if (d->fdefault.getlen()>0) {
00243 D(debugf(4,">>>FIELDS_DEFS::read key=%s, default=%s\n",key,d->fdefault.get()));
00244 }
00245 d->order = c_form->getvalnum (key,K_ORDER,100);
00246 c_form->getall (key,K_VALUE,d->values,true);
00247 }
00248 return 0;
00249 }
|
|
|
Definition at line 180 of file fields.cc. Referenced by ldap_form_edituser(), and USERINFO_COMNG::save(). |
|
|
Definition at line 348 of file fields.cc. Referenced by ldap_form_edituser(), ldap_formclient(), and USERINFO_COMNG::setupdia(). 00349 {
00350 for (int i=0; i<getnb(); i++){
00351 FIELD_DEF *d = getitem(i);
00352 int type = d->type;
00353 const char *title = d->title.get();
00354 d->field_num = dia.getnb();
00355 if (type == FLD_TYPE_STRING){
00356 dia.newf_str (title,d->val.str);
00357 if (d->must_fill) dia.last_noempty();
00358 }else if (type == FLD_TYPE_BOOL){
00359 dia.newf_chk (title,d->val.sel,"");
00360 }else if (type == FLD_TYPE_NUM){
00361 dia.newf_num (title,d->val.num);
00362 }else if (type == FLD_TYPE_ENUM){
00363 FIELD_ENUM *fenum = dia.newf_enum (title,d->val.num);
00364 for (int j=0; j<d->values.getnb(); j++){
00365 fenum->addopt (d->values.getitem(j)->get());
00366 }
00367 }else if (type == FLD_TYPE_COMBO){
00368 FIELD_COMBO *fcombo = dia.newf_combo (title,d->val.str);
00369 for (int j=0; j<d->values.getnb(); j++){
00370 fcombo->addopt (d->values.getitem(j)->get());
00371 }
00372 }else if (type == FLD_TYPE_LIST){
00373 FIELD_LIST *flist = dia.newf_list (title,d->val.str);
00374 for (int j=0; j<d->values.getnb(); j++){
00375 flist->addopt (d->values.getitem(j)->get());
00376 }
00377 }else if (type == FLD_TYPE_PAD){
00378 dia.newf_title(title,1,"",title);
00379 }else if (type == FLD_TYPE_TITLE){
00380 dia.newf_title("",title);
00381 }
00382 }
00383 }
|
|
|
Definition at line 255 of file fields.cc. Referenced by formprofile_edit(). 00256 {
00257 SSTRINGS tb;
00258 c_form->getall (K_FORMCONF,K_ID,tb,false);
00259 for (int i=0; i<tb.getnb(); i++){
00260 char key[100];
00261 snprintf (key,sizeof(key)-1,"%s",tb.getitem(i)->get());
00262 c_form->removeall (key,K_TITLE);
00263 c_form->removeall (key,K_TYPE);
00264 c_form->removeall (key,K_MUSTFILL);
00265 c_form->removeall (key,K_MINIMUM);
00266 c_form->removeall (key,K_MAXIMUM);
00267 c_form->removeall (key,K_VALUE);
00268 c_form->removeall (key,K_ORDER);
00269 c_form->removeall (key,K_DEFAULT);
00270 }
00271 c_form->removeall (K_FORMCONF,K_ID);
00272 for (int i=0; i<getnb(); i++){
00273 FIELD_DEF *d = getitem(i);
00274 c_form->add (K_FORMCONF,K_ID,d->id);
00275 char key[100];
00276 snprintf (key,sizeof(key)-1,"%s",d->id.get());
00277 c_form->add (key,K_TITLE,d->title);
00278 c_form->add (key,K_TYPE,d->type);
00279 c_form->add (key,K_MUSTFILL,d->must_fill);
00280 c_form->add (key,K_MINIMUM,d->minimum);
00281 c_form->add (key,K_MAXIMUM,d->maximum);
00282 c_form->add (key,K_ORDER,d->order);
00283 c_form->add (key,K_DEFAULT,d->fdefault);
00284 c_form->replace (key,K_VALUE,d->values);
00285 }
00286 return c_form->save();
00287 }
|
|
|
|
|
|
|
1.2.1 written by Dimitri van Heesch,
© 1997-2000