0ea04e89856b9e21cffe1921cda1d8bc5d968ffd
[diogenes.git] / users.php
1 <?php
2 require_once 'diogenes.common.inc.php';
3 require_once 'diogenes.admin.inc.php';
4
5 $page = new DiogenesAdmin;
6
7 $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : "";
8 switch($action) {
9 case "add":
10 if (isset($_REQUEST['auth']) && isset($_REQUEST['username'])) {
11 $auth = $_REQUEST['auth'];
12 if ($uid = call_user_func(array($globals->session,'getUserId'),$auth,$_REQUEST['username']))
13 $globals->db->query("insert into diogenes_perm set alias='{$page->alias}',auth='$auth',uid='$uid',perms='user'");
14 else
15 $page->info(__("Could not find requested user")." '{$_REQUEST['username']}'");
16 }
17 break;
18 case "remove":
19 if (isset($_REQUEST['auth']) && isset($_REQUEST['uid']))
20 $globals->db->query("delete from diogenes_perm where alias='{$page->alias}' and auth='{$_REQUEST['auth']}' and uid='{$_REQUEST['uid']}' and perms='user'");
21 break;
22 }
23
24 $page->assign('greeting',__("Users administration"));
25 $page->assign('msg_users',__("Registered users"));
26 $page->assign('msg_admins',__("Administrators"));
27 $page->assign('post',$page->script_self());
28 $page->assign('user',__("user"));
29 $page->assign('action',__("action"));
30
31 // retrieve the list of users
32 $res = $globals->db->query("select uid,auth from diogenes_perm where alias='{$page->alias}' and perms='user'");
33 while (list($uid,$auth) = mysql_fetch_row($res)) {
34 $username = call_user_func(array($globals->session,'getUsername'),$auth,$uid);
35 $page->append('users',array($username,$globals->tlabel[$auth],array(__("remove"),"?action=remove&amp;auth=$auth&amp;uid=$uid")));
36 }
37 mysql_free_result($res);
38
39 // retrieve the list of admins
40 $res = $globals->db->query("select uid,auth from diogenes_perm where alias='{$page->alias}' and perms='admin'");
41 while (list($uid,$auth) = mysql_fetch_row($res)) {
42 $username = call_user_func(array($globals->session,'getUsername'),$auth,$uid);
43 $page->append('admins',array($username,$globals->tlabel[$auth]));
44 }
45 mysql_free_result($res);
46
47 // auth methods
48 foreach ($globals->tauth as $key=>$val)
49 $auths[$key]=$globals->tlabel[$key];
50 $page->assign('auths',$auths);
51 $page->display('admin-users.tpl');
52
53 ?>