document <protect> </protect> tags
[diogenes.git] / htdocs / toplevel / boot.php
... / ...
CommitLineData
1<?php
2require_once 'diogenes.common.inc.php';
3require_once 'diogenes.toplevel.inc.php';
4require_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
10if ((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'");
18if (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");
36if (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'");
45if (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?>