touchup stylesheets
[diogenes.git] / htdocs / toplevel / admins.php
CommitLineData
6855525e
JL
1<?php
2require_once 'diogenes.common.inc.php';
3require_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'] : "";
13switch($action) {
14case "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
24case "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
29case "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");
40while (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&amp;target=$target&amp;auth=$auth&amp;uid=$uid"),
45 array(__("remove"),"?action=remove&amp;target=$target&amp;auth=$auth&amp;uid=$uid"),
46 array(__("view log"),"logger.php?logauth=$auth&amp;loguser=$username")
47
48 );
49 $page->append('entries',array($odd ? "odd" : "even",$target,$globals->tlabel[$auth],$username,$actions));
50 $odd = !$odd;
51}
52mysql_free_result($res);
53
54// add the sites
55$res = $globals->db->query("select alias from diogenes_site");
56$sites = array();
57while (list($target) = mysql_fetch_row($res))
58 $sites[$target]=$target;
59$page->assign('sites', $sites);
60mysql_free_result($res);
61
62// auth methods
63foreach ($globals->tauth as $key=>$val)
64 $auths[$key]=$globals->tlabel[$key];
65$page->assign('auths',$auths);
66
67$page->display('toplevel-admins.tpl');
68?>