admins.php

00001 <?php
00002 require_once 'diogenes.common.inc.php';
00003 require_once 'diogenes.toplevel.inc.php';
00004 
00005 $page = new $globals->toplevel(true);
00006 $page->assign('post',$page->script_self());
00007 $page->assign('greeting', __("Site administrators"));
00008 $page->assign('msg_site',__("site"));
00009 $page->assign('msg_admin',__("administrator"));
00010 $page->assign('msg_actions',__("actions"));
00011 
00012 $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : "";
00013 switch($action) {
00014 case "add":
00015   if (isset($_REQUEST['target']) && isset($_REQUEST['auth']) && isset($_REQUEST['username'])) {
00016     $auth = $_REQUEST['auth'];
00017     if ($uid = call_user_func(array($globals->session,'getUserId'),$auth,$_REQUEST['username']))
00018       $globals->db->query("replace into diogenes_perm set alias='{$_REQUEST['target']}',auth='$auth',uid='$uid',perms='admin'");
00019     else
00020       $page->info(__("Could not find requested user")." '{$_REQUEST['username']}'");
00021   }
00022   break;
00023 
00024 case "demote":
00025   if (isset($_REQUEST['target']) && isset($_REQUEST['uid']))
00026       $globals->db->query("replace into diogenes_perm set alias='{$_REQUEST['target']}',auth='{$_REQUEST['auth']}',uid='{$_REQUEST['uid']}',perms='user'");
00027   break;
00028 
00029 case "remove":
00030   if (isset($_REQUEST['target']) && isset($_REQUEST['uid']))
00031     $globals->db->query("delete from diogenes_perm where alias='{$_REQUEST['target']}' and auth='{$_REQUEST['auth']}' and uid='{$_REQUEST['uid']}'");
00032   break;
00033 }
00034 
00035 // add alias/username entries
00036 $odd = false;
00037 $res = $globals->db->query("select s.alias,s.vhost,auth,uid from diogenes_perm as p".
00038                            " left join diogenes_site as s on s.alias=p.alias".
00039                            " where p.perms='admin' order by alias,auth");
00040 while (list($target,$vhost,$auth,$uid) = mysql_fetch_row($res)) {
00041   $username = call_user_func(array($globals->session,'getUsername'),$auth,$uid);
00042   $actions = array(
00043     array(__("site users"), $page->urlBarrel($target,$vhost,"admin/users")),
00044     array(__("demote to user"),"?action=demote&amp;target=$target&amp;auth=$auth&amp;uid=$uid"),
00045     array(__("remove"),"?action=remove&amp;target=$target&amp;auth=$auth&amp;uid=$uid"),
00046     array(__("view log"),"logger.php?logauth=$auth&amp;loguser=$username")
00047 
00048   );
00049   $page->append('entries',array($odd ? "odd" : "even",$target,$globals->tlabel[$auth],$username,$actions));
00050   $odd = !$odd;
00051 }
00052 mysql_free_result($res);
00053 
00054 // add the sites
00055 $res = $globals->db->query("select alias from diogenes_site");
00056 $sites = array();
00057 while (list($target) = mysql_fetch_row($res))
00058   $sites[$target]=$target;
00059 $page->assign('sites', $sites);
00060 mysql_free_result($res);
00061 
00062 // auth methods
00063 foreach ($globals->tauth as $key=>$val)
00064   $auths[$key]=$globals->tlabel[$key];
00065 $page->assign('auths',$auths);
00066 
00067 $page->display('toplevel-admins.tpl');
00068 ?>

Generated on Fri Jan 11 01:20:08 2008 for Diogenes by  doxygen 1.5.1