more plugin fixups
[diogenes.git] / htdocs / toplevel / options_expert.php
1 <?php
2 require_once 'diogenes.common.inc.php';
3 require_once 'diogenes.toplevel.inc.php';
4 require_once 'diogenes/diogenes.table-editor.inc.php';
5
6 // set up the page
7 $page = new $globals->toplevel(true);
8 $page->assign("greeting",__("Global options"));
9 $page->toolbar(__("Mode"), array( array( __("standard"), "options.php" ), __("expert")));
10
11 $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : "";
12
13 switch ($action) {
14 case "cvs-rcs":
15 $page->info("converting spool from CVS to RCS..");
16 $res = $globals->db->query("select alias from diogenes_site");
17 while(list($site) = mysql_fetch_row($res)) {
18 $page->info("processing '$site'..");
19 $spool = new DiogenesSpool($page,$site);
20 $page->info("-> deleting 'CVS' subdirectories from spool..");
21 $goners = System::find($spool->datadir.' -type d');
22 foreach($goners as $goner) {
23 if (basename($goner) == "CVS")
24 System::rm("-r $goner");
25 }
26 $page->info("-> changing files in spool to read-only..");
27 $modfiles = System::find($spool->datadir.' -type f');
28 foreach($modfiles as $modfile) {
29 chmod($modfile,0444);
30 }
31 }
32 $globals->updateOption("rcs","DiogenesRcs");
33 break;
34
35 case "rcs-cvs":
36 $page->info("converting spool from RCS to CVS..");
37 if (!is_dir("{$globals->rcsroot}/CVSROOT")) {
38 $page->info("-> no CVSROOT not found, running init..");
39 if ($ret = shell_exec(escapeshellcmd("cvs -d".escapeshellarg($globals->rcsroot)." init")))
40 $page->info($ret);
41 }
42
43 // remove current spool dirs and do a clean checkout of each site
44 $res = $globals->db->query("select alias from diogenes_site");
45 while(list($site) = mysql_fetch_row($res)) {
46 $page->info("processing '$site'..");
47 $page->info("-> removing '{$globals->spoolroot}/$site'..");
48 System::rm("-r {$globals->spoolroot}/$site");
49 $page->info("-> doing a checkout of module '$site'..");
50 $spool = new DiogenesCvs($page,$site,$_SESSION['session']->username,true);
51 }
52 $globals->updateOption("rcs","DiogenesCvs");
53 break;
54 }
55
56 $page->assign('msg_convert',__("Convert"));
57 $page->assign('msg_vcs',__("version control system"));
58
59 switch ($globals->rcs) {
60 case "DiogenesRcs":
61 $page->assign('msg_current_vcs',__("You are currently using RCS as the version control system for your barrels."));
62 $page->append('conversions',array("rcs-cvs", __("You can switch to a full CVS repository by clicking here.")));
63 break;
64
65 case "DiogenesCvs":
66 $page->assign('msg_current_vcs',__("You are currently using CVS as the version control system for your barrels."));
67 $page->append('conversions',array("cvs-rcs", __("You can switch back to RCS by clicking here.")));
68 break;
69 }
70
71
72 // set up the editor
73 $editor = new DiogenesTableEditor($globals->table_global_options,"name",true);
74 $editor->add_where_condition("barrel=''");
75 $editor->hide('barrel', '');
76 $editor->describe("name", __("option"), false);
77 $editor->describe("value", __("value"), true);
78
79 // run the editor
80 $editor->table_style = "width:80%";
81 $editor->run($page,'editor_content');
82
83 $page->display('toplevel-options_expert.tpl');
84 ?>