Commit | Line | Data |
---|---|---|
6855525e JL |
1 | <?php |
2 | require_once 'diogenes.common.inc.php'; | |
3 | require_once 'diogenes.toplevel.inc.php'; | |
4 | ||
5 | $page = new $globals->toplevel(true); | |
6 | $page->assign('post',$page->script_self()); | |
7 | $page->assign('greeting', __("Site administrators")); | |
8 | $page->assign('msg_site',__("site")); | |
9 | $page->assign('msg_admin',__("administrator")); | |
10 | $page->assign('msg_actions',__("actions")); | |
11 | ||
12 | $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : ""; | |
13 | switch($action) { | |
14 | case "add": | |
15 | if (isset($_REQUEST['target']) && isset($_REQUEST['auth']) && isset($_REQUEST['username'])) { | |
16 | $auth = $_REQUEST['auth']; | |
17 | if ($uid = call_user_func(array($globals->session,'getUserId'),$auth,$_REQUEST['username'])) | |
18 | $globals->db->query("replace into diogenes_perm set alias='{$_REQUEST['target']}',auth='$auth',uid='$uid',perms='admin'"); | |
19 | else | |
20 | $page->info(__("Could not find requested user")." '{$_REQUEST['username']}'"); | |
21 | } | |
22 | break; | |
23 | ||
24 | case "demote": | |
25 | if (isset($_REQUEST['target']) && isset($_REQUEST['uid'])) | |
26 | $globals->db->query("replace into diogenes_perm set alias='{$_REQUEST['target']}',auth='{$_REQUEST['auth']}',uid='{$_REQUEST['uid']}',perms='user'"); | |
27 | break; | |
28 | ||
29 | case "remove": | |
30 | if (isset($_REQUEST['target']) && isset($_REQUEST['uid'])) | |
31 | $globals->db->query("delete from diogenes_perm where alias='{$_REQUEST['target']}' and auth='{$_REQUEST['auth']}' and uid='{$_REQUEST['uid']}'"); | |
32 | break; | |
33 | } | |
34 | ||
35 | // add alias/username entries | |
36 | $odd = false; | |
37 | $res = $globals->db->query("select s.alias,s.vhost,auth,uid from diogenes_perm as p". | |
38 | " left join diogenes_site as s on s.alias=p.alias". | |
39 | " where p.perms='admin' order by alias,auth"); | |
40 | while (list($target,$vhost,$auth,$uid) = mysql_fetch_row($res)) { | |
41 | $username = call_user_func(array($globals->session,'getUsername'),$auth,$uid); | |
42 | $actions = array( | |
43 | array(__("site users"), $page->urlBarrel($target,$vhost,"admin/users")), | |
44 | array(__("demote to user"),"?action=demote&target=$target&auth=$auth&uid=$uid"), | |
45 | array(__("remove"),"?action=remove&target=$target&auth=$auth&uid=$uid"), | |
46 | array(__("view log"),"logger.php?logauth=$auth&loguser=$username") | |
47 | ||
48 | ); | |
49 | $page->append('entries',array($odd ? "odd" : "even",$target,$globals->tlabel[$auth],$username,$actions)); | |
50 | $odd = !$odd; | |
51 | } | |
52 | mysql_free_result($res); | |
53 | ||
54 | // add the sites | |
55 | $res = $globals->db->query("select alias from diogenes_site"); | |
56 | $sites = array(); | |
57 | while (list($target) = mysql_fetch_row($res)) | |
58 | $sites[$target]=$target; | |
59 | $page->assign('sites', $sites); | |
60 | mysql_free_result($res); | |
61 | ||
62 | // auth methods | |
63 | foreach ($globals->tauth as $key=>$val) | |
64 | $auths[$key]=$globals->tlabel[$key]; | |
65 | $page->assign('auths',$auths); | |
66 | ||
67 | $page->display('toplevel-admins.tpl'); | |
68 | ?> |