Changeset 1432
- Timestamp:
- 2000-08-20T20:44:06+12:00 (24 years ago)
- Location:
- trunk/gsdl
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/lib/cfgread.cpp
r1421 r1432 69 69 } 70 70 fileout << "\n"; 71 return 0; 71 72 } 72 73 -
trunk/gsdl/src/recpt/authenaction.cpp
r1402 r1432 242 242 arg_er.clear(); 243 243 244 // needs to be decoded for use within forms 245 decode_cgi_arg (arg_er); 246 244 247 // redirect to this action 245 248 args_a = "a"; -
trunk/gsdl/src/recpt/collectoraction.cpp
r1425 r1432 34 34 #include "fileutil.h" 35 35 #include "cfgread.h" 36 #include "gsdltools.h" 36 37 37 38 #if !defined (__WIN32__) … … 44 45 recpt = NULL; 45 46 do_mkcol = false; 47 clone_failed = false; 46 48 47 49 cgiarginfo arg_ainfo; … … 110 112 argsinfo.addarginfo (NULL, arg_ainfo); 111 113 114 // set when cloning option has changed 115 arg_ainfo.shortname = "bc1clonechanged"; 116 arg_ainfo.longname = "collector specific"; 117 arg_ainfo.multiplechar = false; 118 arg_ainfo.defaultstatus = cgiarginfo::weak; 119 arg_ainfo.argdefault = "0"; 120 arg_ainfo.savedarginfo = cgiarginfo::mustnot; 121 argsinfo.addarginfo (NULL, arg_ainfo); 122 112 123 arg_ainfo.shortname = "bc1inputdir1"; 113 124 arg_ainfo.longname = "collector specific"; … … 160 171 arg_ainfo.argdefault = "0"; 161 172 arg_ainfo.savedarginfo = cgiarginfo::mustnot; 173 argsinfo.addarginfo (NULL, arg_ainfo); 174 175 arg_ainfo.shortname = "bc1dodelete"; 176 arg_ainfo.longname = "collector specific"; 177 arg_ainfo.multiplechar = false; 178 arg_ainfo.defaultstatus = cgiarginfo::weak; 179 arg_ainfo.argdefault = "0"; 180 arg_ainfo.savedarginfo = cgiarginfo::mustnot; 181 argsinfo.addarginfo (NULL, arg_ainfo); 182 183 // will be set if we arrived at the "configure collection" page 184 // via the "changing an existing collection" page 185 arg_ainfo.shortname = "bc1econf"; 186 arg_ainfo.longname = "collector specific"; 187 arg_ainfo.multiplechar = false; 188 arg_ainfo.defaultstatus = cgiarginfo::weak; 189 arg_ainfo.argdefault = "0"; 190 arg_ainfo.savedarginfo = cgiarginfo::must; 191 argsinfo.addarginfo (NULL, arg_ainfo); 192 193 // will be set if we arrived at the "source data" page 194 // via the "changing an existing collection" page 195 arg_ainfo.shortname = "bc1esrce"; 196 arg_ainfo.longname = "collector specific"; 197 arg_ainfo.multiplechar = false; 198 arg_ainfo.defaultstatus = cgiarginfo::weak; 199 arg_ainfo.argdefault = "0"; 200 arg_ainfo.savedarginfo = cgiarginfo::must; 162 201 argsinfo.addarginfo (NULL, arg_ainfo); 163 202 } … … 200 239 201 240 if (args["cp"] != "intro") { 202 // authenticate the user if authentication is avai able241 // authenticate the user if authentication is available 203 242 args["uan"] = 1; 204 243 args["ug"] = "colbuilder"; … … 215 254 args["bc1dirname"] = get_directory_name (args["bc1fullname"]); 216 255 do_mkcol = true; 217 218 256 } else { 219 257 // "collection information" has been changed after collection was made … … 230 268 } 231 269 270 if (args["bc1clonechanged"] == "1") { 271 // cloning option has been changed on "source data" page. if it was turned 272 // on we want to create a new collect.cfg file using the bc1clonecol cfg file 273 // as a model (we'll save the old file as collect.cfg.org). if cloning was 274 // turned off we'll revert to using the collect.cfg.org file (which will need 275 // updating in case the bc1 arguments have been altered since cloning was 276 // turned on). 277 update_cfgfile_clone (args, logout); 278 } 279 232 280 return true; 281 } 282 283 void collectoraction::update_cfgfile_clone (cgiargsclass &args, ostream &logout) { 284 285 text_t cfgfile = filename_cat(gsdlhome, "collect", args["bc1dirname"], "etc", "collect.cfg"); 286 text_t cfgfile_org = cfgfile + ".org"; 287 288 if (args["bc1clone"] == "1") { 289 // cloning was turned on 290 291 text_t cfgfile_clone = filename_cat(gsdlhome, "collect", args["bc1clonecol"], "etc", "collect.cfg"); 292 if (file_exists (cfgfile_clone)) { 293 // if .org file doesn't exist already create it 294 if (!file_exists (cfgfile_org)) { 295 file_copy (cfgfile, cfgfile_org); 296 } 297 // copy clone collections cfg file to new collection 298 file_copy (cfgfile_clone, cfgfile); 299 // update the new cfg file 300 update_cfgfile_partial (args, logout); 301 302 } else { 303 // can't clone non-existant collection 304 clone_failed = true; 305 } 306 307 } else { 308 // cloning has been turned off having been on at some point. the .org file 309 // should exist, if it doesn't we'll bail out and leave the user with the 310 // cloned copy 311 if (file_exists (cfgfile_org)) { 312 // copy original back again and update it with any recent changes 313 file_copy (cfgfile_org, cfgfile); 314 update_cfgfile_partial (args, logout); 315 } 316 } 233 317 } 234 318 … … 247 331 while (read_cfg_line(cfg_in, cfgline) >= 0) { 248 332 if (cfgline.size () >= 2) { 249 if (cfgline[0] == "creator" ) {333 if (cfgline[0] == "creator" || cfgline[0] == "maintainer") { 250 334 cfgline[1] = args["bc1contactemail"]; 251 335 } else if (cfgline[0] == "collectionmeta") { … … 262 346 263 347 // now write cfg file back out 348 #ifdef __WIN32__ 349 ofstream cfg_out (cfgfilec, ios::binary); 350 #else 264 351 ofstream cfg_out (cfgfilec); 352 #endif 265 353 if (cfg_out) { 266 354 // lock the file … … 285 373 286 374 } else { 287 logout << "collectoraction::update_cfgfile_partial: unable to open " 375 logout << "collectoraction::update_cfgfile_partial: unable to open " 288 376 << cfgfilec << " for output\n"; 289 377 } 290 378 291 379 } else { 292 logout << "collectoraction::update_cfgfile_partial: unable to open " 380 logout << "collectoraction::update_cfgfile_partial: unable to open " 293 381 << cfgfilec << " for input\n"; 294 382 } … … 302 390 text_t cfgfile = filename_cat(gsdlhome, "collect", args["bc1dirname"], "etc", "collect.cfg"); 303 391 char *cfgfilec = cfgfile.getcstr(); 392 #ifdef __WIN32__ 393 ofstream cfg_out (cfgfilec, ios::binary); 394 #else 304 395 ofstream cfg_out (cfgfilec); 396 #endif 305 397 306 398 if (cfg_out) { … … 405 497 } 406 498 407 text_t ¤tname = args["bc1clonecol"]; 408 text_t fullnamemenu; 409 bool first = true; 499 text_t ¤t_page = args["cp"]; 500 text_t currentname = args["bc1dirname"]; 501 if (current_page == "srce") currentname = args["bc1clonecol"]; 502 503 text_tarray dirnames; 504 text_tarray fullnames; 505 vector<bool> write_protected; 506 int selected_index = 0; 507 int index = 0; 410 508 411 509 recptprotolistclass::iterator rprotolist_here = protos->begin(); … … 422 520 text_tset metadata; 423 521 metadata.insert ("collectionname"); 424 425 522 while (collist_here != collist_end) { 426 427 523 ColInfoResponse_t *cinfo = recpt->get_collectinfo_ptr ((*rprotolist_here).p, *collist_here, logout); 428 524 if (cinfo != NULL) { … … 431 527 // get collection name from the collection cfg file 432 528 collectionname = cinfo->collectionmeta["collectionname"]; 433 434 529 } else if (get_info ("collection", *collist_here, metadata, false, 435 530 (*rprotolist_here).p, response, logout)) { … … 437 532 collectionname = response.docInfo[0].metadata["collectionname"].values[0]; 438 533 } 439 440 if (first) fullnamemenu = "<select name=\"bc1clonecol\">\n"; 441 fullnamemenu += "<option value=\"" + *collist_here; 442 fullnamemenu.push_back ('"'); 443 if (*collist_here == currentname) fullnamemenu += " selected"; 444 fullnamemenu.push_back ('>'); 445 fullnamemenu += collectionname; 446 534 dirnames.push_back(*collist_here); 535 fullnames.push_back(collectionname); 447 536 // check to see if the "collection" is writable 448 text_t cfg_fname = filename_cat(gsdlhome, "collect", *collist_here, "etc", "collect.cfg"); 449 if (!file_writable(cfg_fname)) fullnamemenu += " <b>(write protected)</b>"; 450 451 fullnamemenu += "\n"; 537 if (collection_protected (*collist_here)) write_protected.push_back(true); 538 else write_protected.push_back(false); 539 if (*collist_here == currentname) selected_index = index; 452 540 453 first = false;541 index ++; 454 542 } 455 543 collist_here ++; … … 459 547 rprotolist_here ++; 460 548 } 461 if (!first) { 462 fullnamemenu += "</select>\n"; 463 disp.setmacro ("fullnamemenu", "collector", fullnamemenu); 464 } 549 550 bool have_one = false; 551 text_t fullnamemenu = "<select name=\"bc1dirname\">\n"; 552 if (current_page == "srce") fullnamemenu = "<select name=\"bc1clonecol\">\n"; 553 for (int i = 0; i < index; i ++) { 554 // don't want write protected collections in list on "change existing 555 // collection" page 556 if (write_protected[i] && current_page == "existing") continue; 557 have_one = true; 558 fullnamemenu += "<option value=\"" + dirnames[i] + "\""; 559 if (i == selected_index) fullnamemenu += " selected"; 560 fullnamemenu.push_back ('>'); 561 fullnamemenu += fullnames[i]; 562 if (write_protected[i]) fullnamemenu += " <b>(write protected)</b>"; 563 } 564 fullnamemenu += "</select>\n"; 565 if (have_one) disp.setmacro ("fullnamemenu", "collector", fullnamemenu); 465 566 } 466 567 … … 506 607 // _collectorbar_ 507 608 // _pagescriptextra_ 508 // _fullnamemenu_ -- if displaying the "source data" page 609 // _fullnamemenu_ -- if displaying the "source data" page or the "changing existing 610 // collection" page 509 611 // _cfgfile_ -- if displaying the "configure collection" page 510 612 511 613 text_t &collector_page = args["cp"]; 614 int esrce = args["bc1esrce"].getint(); 615 int econf = args["bc1econf"].getint(); 512 616 513 617 // set _pagescriptextra_ macro to _cpagescriptextra_ … … 541 645 542 646 } else if (collector_page == "srce") { 543 collectorbar += get_button (collector_page, "yellow", "info", true); 647 if (esrce == 1) { 648 // if we came from the "change an existing collection" page previous button(s) 649 // are disabled 650 collectorbar += get_button (collector_page, "grey", "info", false); 651 } else { 652 collectorbar += get_button (collector_page, "yellow", "info", true); 653 } 544 654 collectorbar += "<td>_icongreyarrow_</td>\n"; 545 655 collectorbar += get_button (collector_page, "yellow", "srce", false); … … 553 663 554 664 } else if (collector_page == "conf") { 555 collectorbar += get_button (collector_page, "yellow", "info", true); 556 collectorbar += "<td>_icongreyarrow_</td>\n"; 557 collectorbar += get_button (collector_page, "yellow", "srce", true); 665 // disable appropriate buttons if we came from "change an existing collection" 666 // page 667 if (esrce == 1 || econf == 1) { 668 collectorbar += get_button (collector_page, "grey", "info", false); 669 } else { 670 collectorbar += get_button (collector_page, "yellow", "info", true); 671 } 672 collectorbar += "<td>_icongreyarrow_</td>\n"; 673 if (econf == 1) { 674 collectorbar += get_button (collector_page, "grey", "srce", false); 675 } else { 676 collectorbar += get_button (collector_page, "yellow", "srce", true); 677 } 558 678 collectorbar += "<td>_icongreyarrow_</td>\n"; 559 679 collectorbar += get_button (collector_page, "yellow", "conf", false); … … 572 692 disp.setmacro ("collectorbar", "collector", collectorbar); 573 693 574 if (collector_page == "srce") set_fullnamemenu (disp, args, protos, logout); 575 if (collector_page == "conf") set_cfgfile (disp, args["bc1dirname"], logout); 694 if (collector_page == "srce" || collector_page == "existing") 695 set_fullnamemenu (disp, args, protos, logout); 696 if (collector_page == "conf") 697 set_cfgfile (disp, args["bc1dirname"], logout); 576 698 } 577 699 … … 579 701 browsermapclass * /*browsers*/, displayclass &disp, 580 702 outconvertclass &outconvert, ostream &textout, 581 ostream & /*logout*/) {703 ostream &logout) { 582 704 583 705 text_t &collector_page = args["cp"]; 584 text_t error; 706 text_t &collection = args["bc1dirname"]; 707 text_t message; 585 708 586 709 if (do_mkcol) { … … 591 714 mkcol_cmd += " -title \"" + args["bc1fullname"] + "\""; 592 715 mkcol_cmd += " -about \"" + carriage_replace (args["bc1aboutdesc"], 0) + "\" "; 593 mkcol_cmd += args["bc1dirname"];716 mkcol_cmd += collection; 594 717 char *mkcol_cmdc = mkcol_cmd.getcstr(); 595 718 system (mkcol_cmdc); … … 597 720 598 721 // make sure it went ok 599 text_t cfgfile = filename_cat (gsdlhome, "collect", args["bc1dirname"],722 text_t cfgfile = filename_cat (gsdlhome, "collect", collection, 600 723 "etc", "collect.cfg"); 601 if (!file_writable (cfgfile)) error = "mkcolfail"; 724 if (!file_writable (cfgfile)) message = "mkcolfail"; 725 do_mkcol = false; // reset for fast-cgi 602 726 } 603 727 604 728 if (collector_page == "bild") { 605 729 // do the work (download, import, build) 730 text_t tmpdir = filename_cat (gsdlhome, "tmp", collection + ".bld"); 731 606 732 text_t build_cmd = "perl " + filename_cat (gsdlhome, "bin", "script", "build"); 733 build_cmd += " -append -remove_import"; 734 build_cmd += " -out \"" + tmpdir + "\""; 607 735 if (!args["bc1inputdir1"].empty()) { 608 736 build_cmd += " -download \"" + args["bc1inputdir1"] + "\""; … … 618 746 } 619 747 build_cmd.push_back (' '); 620 build_cmd += args["bc1dirname"];748 build_cmd += collection; 621 749 622 750 #if !defined (__WIN32__) … … 633 761 } 634 762 635 if (error.empty()) { 763 if (args["bc1dodelete"] == "1") { 764 // delete bcidirname collection 765 if (collection_protected (collection)) { 766 message = "delinvalid"; 767 768 } else { 769 770 text_t delete_cmd = "perl " + filename_cat (gsdlhome, "bin", "script", "delcol.pl"); 771 delete_cmd += " -f " + collection; 772 char *delete_cmdc = delete_cmd.getcstr(); 773 int rv = system (delete_cmdc); 774 delete delete_cmdc; 775 if (rv != 0) { 776 // deletion failed -- permissions? 777 message = "delpermission"; 778 } else { 779 message = "delsuccess"; 780 } 781 } 782 } 783 784 if (clone_failed) { 785 // clone_failed is set from check_cgiargs if an attempt was made 786 // to clone an invalid collection 787 message = "clonefail"; 788 clone_failed = false; 789 } 790 791 if (message.empty()) { 636 792 textout << outconvert << disp << ("_collector:header_\n") 637 793 << ("_collector:" + collector_page + "content_\n") … … 639 795 } else { 640 796 textout << outconvert << disp << ("_collector:header_\n") 641 << ("_collector:" + error+ "content_\n")797 << ("_collector:" + message + "content_\n") 642 798 << ("_collector:footer_\n"); 643 799 } … … 738 894 return shortname; 739 895 } 896 897 // tests if collection is write protected (currently just checks if 898 // collect.cfg file is writable 899 bool collectoraction::collection_protected (const text_t &collection) { 900 text_t cfgfile = filename_cat(gsdlhome, "collect", collection, "etc", "collect.cfg"); 901 if (file_writable(cfgfile)) return false; 902 return true; 903 } -
trunk/gsdl/src/recpt/collectoraction.h
r1425 r1432 40 40 41 41 bool do_mkcol; 42 bool clone_failed; 42 43 43 44 text_t get_button (const text_t &thispage, const text_t &color, … … 49 50 void set_cfgfile (displayclass &disp, const text_t &dirname, ostream &logout); 50 51 52 void update_cfgfile_clone (cgiargsclass &args, ostream &logout); 53 51 54 void update_cfgfile_partial (cgiargsclass &args, ostream &logout); 52 55 … … 56 59 57 60 text_t get_directory_name (const text_t &fullname); 61 62 bool collection_protected (const text_t &collection); 58 63 59 64 public:
Note:
See TracChangeset
for help on using the changeset viewer.