getUsers(); // Get groups from the database $groups = $data->getGroups(); $misc->printTrail($_REQUEST['subject']); switch ($mode) { case 'grant': $misc->printTitle($lang['strgrant'],'pg.privilege.grant'); break; case 'revoke': $misc->printTitle($lang['strrevoke'],'pg.privilege.revoke'); break; } $misc->printMsg($msg); echo "
\n"; } else { // Determine whether object should be ref'd by name or oid. if (isset($_REQUEST[$_REQUEST['subject'].'_oid'])) $object = $_REQUEST[$_REQUEST['subject'].'_oid']; else $object = $_REQUEST[$_REQUEST['subject']]; if (isset($_REQUEST['table'])) $table = $_REQUEST['table']; else $table = null; $status = $data->setPrivileges(($mode == 'grant') ? 'GRANT' : 'REVOKE', $_REQUEST['subject'], $object, isset($_REQUEST['public']), $_REQUEST['username'], $_REQUEST['groupname'], array_keys($_REQUEST['privilege']), isset($_REQUEST['grantoption']), isset($_REQUEST['cascade']), $table); if ($status == 0) doDefault($lang['strgranted']); elseif ($status == -3 || $status == -4) doAlter(true, $_REQUEST['mode'], $lang['strgrantbad']); else doAlter(true, $_REQUEST['mode'], $lang['strgrantfailed']); } } /** * Show permissions on a database, namespace, relation, language or function */ function doDefault($msg = '') { global $data, $misc, $database; global $lang; $misc->printTrail($_REQUEST['subject']); # @@@FIXME: This switch is just a temporary solution, # need a better way, maybe every type of object should # have a tab bar??? switch ($_REQUEST['subject']) { case 'server': case 'database': case 'schema': case 'table': case 'column': case 'view': $misc->printTabs($_REQUEST['subject'], 'privileges'); break; default: $misc->printTitle($lang['strprivileges'], 'pg.privilege'); } $misc->printMsg($msg); // Determine whether object should be ref'd by name or oid. if (isset($_REQUEST[$_REQUEST['subject'].'_oid'])) $object = $_REQUEST[$_REQUEST['subject'].'_oid']; else $object = $_REQUEST[$_REQUEST['subject']]; // Get the privileges on the object, given its type if ($_REQUEST['subject'] == 'column') $privileges = $data->getPrivileges($object, 'column', $_REQUEST['table']); else $privileges = $data->getPrivileges($object, $_REQUEST['subject']); if (sizeof($privileges) > 0) { echo "{$lang['strrole']} | "; else echo "|||
---|---|---|---|
{$lang['strtype']} | {$lang['struser']}/{$lang['strgroup']} | "; foreach ($data->privlist[$_REQUEST['subject']] as $v2) { // Skip over ALL PRIVILEGES if ($v2 == 'ALL PRIVILEGES') continue; echo "{$v2} | \n"; } if ($data->hasGrantOption()) { echo "{$lang['strgrantor']} | "; } echo "
", $misc->printVal($v[0]), " | \n"; echo "", $misc->printVal($v[1]), " | \n"; foreach ($data->privlist[$_REQUEST['subject']] as $v2) { // Skip over ALL PRIVILEGES if ($v2 == 'ALL PRIVILEGES') continue; echo ""; if (in_array($v2, $v[2])) echo $lang['stryes']; else echo $lang['strno']; // If we have grant option for this, end mark if ($data->hasGrantOption() && in_array($v2, $v[4])) echo $lang['strasterisk']; echo " | \n"; } if ($data->hasGrantOption()) { echo "", $misc->printVal($v[3]), " | \n"; } echo "
{$lang['strnoprivileges']}
\n"; } // Links for granting to a user or group switch ($_REQUEST['subject']) { case 'table': case 'view': case 'sequence': case 'function': case 'tablespace': $alllabel = "showall{$_REQUEST['subject']}s"; $allurl = "{$_REQUEST['subject']}s.php"; $alltxt = $lang["strshowall{$_REQUEST['subject']}s"]; break; case 'schema': $alllabel = "showallschemas"; $allurl = "schemas.php"; $alltxt = $lang["strshowallschemas"]; break; case 'database': $alllabel = "showalldatabases"; $allurl = 'all_db.php'; $alltxt = $lang['strshowalldatabases']; break; } $subject = $_REQUEST['subject']; $object = $_REQUEST[$_REQUEST['subject']]; if ($_REQUEST['subject'] == 'function') { $objectoid = $_REQUEST[$_REQUEST['subject'].'_oid']; $urlvars = array ( 'action' => 'alter', 'server' => $_REQUEST['server'], 'database' => $_REQUEST['database'], 'schema' => $_REQUEST['schema'], $subject => $object, "{$subject}_oid" => $objectoid, 'subject'=> $subject ); } else if ($_REQUEST['subject'] == 'column') { $urlvars = array ( 'action' => 'alter', 'server' => $_REQUEST['server'], 'database' => $_REQUEST['database'], 'schema' => $_REQUEST['schema'], $subject => $object, 'subject'=> $subject ); if (isset($_REQUEST['table'])) $urlvars['table'] = $_REQUEST['table']; else $urlvars['view'] = $_REQUEST['view']; } else { $urlvars = array ( 'action' => 'alter', 'server' => $_REQUEST['server'], 'database' => $_REQUEST['database'], $subject => $object, 'subject'=> $subject ); if (isset($_REQUEST['schema'])) { $urlvars['schema'] = $_REQUEST['schema']; } } $navlinks = array ( 'grant' => array ( 'attr'=> array ( 'href' => array ( 'url' => 'privileges.php', 'urlvars' => array_merge($urlvars, array('mode' => 'grant')) ) ), 'content' => $lang['strgrant'] ), 'revoke' => array ( 'attr'=> array ( 'href' => array ( 'url' => 'privileges.php', 'urlvars' => array_merge($urlvars, array('mode' => 'revoke')) ) ), 'content' => $lang['strrevoke'] ) ); if (isset($allurl)) { $navlinks[$alllabel] = array ( 'attr'=> array ( 'href' => array ( 'url' => $allurl, 'urlvars' => array ( 'server' => $_REQUEST['server'], 'database' => $_REQUEST['database'] ) ) ), 'content' => $alltxt ); if (isset($_REQUEST['schema'])) { $navlinks[$alllabel]['attr']['href']['urlvars']['schema'] = $_REQUEST['schema']; } } $misc->printNavLinks($navlinks, 'privileges-privileges', get_defined_vars()); } $misc->printHeader($lang['strprivileges']); $misc->printBody(); switch ($action) { case 'save': if (isset($_REQUEST['cancel'])) doDefault(); else doAlter(false, $_REQUEST['mode']); break; case 'alter': doAlter(true, $_REQUEST['mode']); break; default: doDefault(); break; } $misc->printFooter(); ?>