| 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 | $page = new $globals->toplevel(false); |
| 7 | $page->assign('greeting',__("Initial setup")); |
| 8 | |
| 9 | // check we are using native Diogenes authentication |
| 10 | if ((count($globals->tauth) != 1) or empty($globals->tauth["native"])) { |
| 11 | $page->assign('page_content', __("Sorry, this feature is only available using native Diogenes authentication.")); |
| 12 | $page->display(''); |
| 13 | exit; |
| 14 | } |
| 15 | |
| 16 | // check there are currently no admins |
| 17 | $res = $globals->db->query("select username from {$globals->tauth["native"]} where perms='admin'"); |
| 18 | if (list($username) = mysql_fetch_row($res)) { |
| 19 | $page->assign('page_content', __("The database is already configured.")); |
| 20 | $page->display(''); |
| 21 | exit; |
| 22 | } |
| 23 | |
| 24 | $editor = new DiogenesTableEditor("diogenes_auth","user_id"); |
| 25 | |
| 26 | $editor->add_join_table("diogenes_perm","uid",true); |
| 27 | |
| 28 | $editor->describe("username", __("username"), true); |
| 29 | $editor->describe("firstname", __("first name"), true); |
| 30 | $editor->describe("lastname", __("last name"), true); |
| 31 | $editor->describe("password", __("password"), false, "password"); |
| 32 | $editor->describe("perms", __("permissions"), true, "set"); |
| 33 | |
| 34 | $editor->lock("username", "root"); |
| 35 | $editor->lock("perms", "admin"); |
| 36 | if (empty($_REQUEST['action']) or ($_REQUEST['action'] != 'update')) |
| 37 | { |
| 38 | $_REQUEST['action'] = 'edit'; |
| 39 | } |
| 40 | |
| 41 | $editor->run($page,'page_content'); |
| 42 | |
| 43 | // check if we have completed initial setup |
| 44 | $res = $globals->db->query("select username from {$globals->tauth["native"]} where perms='admin'"); |
| 45 | if (list($username) = mysql_fetch_row($res)) { |
| 46 | $page->assign('page_content', __("The initial setup of the database was performed successfuly.")); |
| 47 | } |
| 48 | |
| 49 | $page->display(''); |
| 50 | ?> |