* Support zero column tables
* Add first & last links to nav. Double number of pages shown.
* German update from Markus Bertheau
+* Allow granting privileges WITH GRANT OPTION for 7.4
* Display new PostgreSQL 7.4 grant options and grantor in privileges
Version 3.0
/**
* Class to hold various commonly used functions
*
- * $Id: Misc.php,v 1.36 2003/07/25 08:39:25 chriskl Exp $
+ * $Id: Misc.php,v 1.37 2003/07/28 07:50:32 chriskl Exp $
*/
class Misc {
echo "<td width=\"20%\"><a href=\"privileges.php?{$vars}&type=database&object=", urlencode($_REQUEST['database']), "\">{$lang['strprivileges']}</a></td>\n";
}
echo "<td width=\"20%\"><a href=\"database.php?{$vars}&action=sql\">{$lang['strsql']}</a></td>\n";
+ echo "<td width=\"20%\"><a href=\"database.php?{$vars}&action=find\">{$lang['strfind']}</a></td>\n";
echo "<td width=\"20%\"><a href=\"database.php?{$vars}&action=admin\">{$lang['stradmin']}</a></td>\n";
//echo "<td width=\"20%\"><a href=\"database.php?{$vars}&action=export\">{$lang['strexport']}</a></td></tr>\n";
echo "</tr></table>\n";
* A class that implements the DB interface for Postgres
* Note: This class uses ADODB and returns RecordSets.
*
- * $Id: Postgres.php,v 1.126 2003/06/21 09:54:37 chriskl Exp $
+ * $Id: Postgres.php,v 1.127 2003/07/28 07:50:32 chriskl Exp $
*/
// @@@ THOUGHT: What about inherits? ie. use of ONLY???
* @param $usernames The array of usernames to grant privs to.
* @param $groupnames The array of group names to grant privs to.
* @param $privileges The array of privileges to grant (eg. ('SELECT', 'ALL PRIVILEGES', etc.) )
+ * @param $grantoption True if has grant option, false otherwise
* @return 0 success
* @return -1 invalid type
* @return -2 invalid entity
* @return -4 not granting to anything
* @return -4 invalid mode
*/
- function setPrivileges($mode, $type, $object, $public, $usernames, $groupnames, $privileges) {
+ function setPrivileges($mode, $type, $object, $public, $usernames, $groupnames, $privileges, $grantoption) {
$this->fieldArrayClean($usernames);
$this->fieldArrayClean($groupnames);
}
}
+ // Grant option
+ if ($this->hasGrantOption() && $mode == 'GRANT' && $grantoption) {
+ $sql .= ' WITH GRANT OPTION';
+ }
+
return $this->execute($sql);
}
/**
* Manage schemas within a database
*
- * $Id: database.php,v 1.15 2003/05/19 15:08:09 chriskl Exp $
+ * $Id: database.php,v 1.16 2003/07/28 07:50:31 chriskl Exp $
*/
// Include application functions
if (!isset($msg)) $msg = '';
$PHP_SELF = $_SERVER['PHP_SELF'];
+ /**
+ * Searches for a named database object
+ */
+ function doFind($confirm = true, $msg = '') {
+ global $PHP_SELF, $data, $localData, $misc;
+ global $lang;
+
+ if (!isset($_GET['term'])) $_GET['term'] = '';
+
+ $misc->printDatabaseNav();
+ echo "<h2>", $misc->printVal($_REQUEST['database']), ": {$lang['strfind']}</h2>\n";
+ $misc->printMsg($msg);
+
+ echo "<form action=\"$PHP_SELF\" method=\"get\">\n";
+ echo "<p><input name=\"term\" value=\"", htmlspecialchars($_GET['term']),
+ "\" size=\"32\" maxlength=\"{$data->_maxNameLen}\" />\n";
+ echo "<input type=\"submit\" value=\"{$lang['strfind']}\" />\n";
+ echo $misc->form;
+ echo "<input type=\"hidden\" name=\"action\" value=\"find\" />\n";
+ echo "</form>\n";
+
+ if ($_GET['term'] != '') {
+ $rs = &$localData->findObject($_GET['term']);
+ if ($rs->recordCount() > 0) {
+ $curr = '';
+ while (!$rs->EOF) {
+ if ($rs->f['type'] != $curr) {
+ if ($curr != '') echo "</ul>\n";
+ $curr = $rs->f['type'];
+ echo "<h2>";
+ switch ($curr) {
+ case 'SCHEMA':
+ echo $lang['strschemas'];
+ break;
+ case 'TABLE':
+ echo $lang['strtables'];
+ break;
+ case 'VIEW':
+ echo $lang['strviews'];
+ break;
+ case 'SEQUENCE':
+ echo $lang['strsequences'];
+ break;
+ }
+ echo "</h2>";
+ echo "<ul>\n";
+ }
+ switch ($curr) {
+ case 'SCHEMA':
+ echo "<li>", htmlspecialchars($rs->f['name']), "</li>\n";
+ break;
+ case 'TABLE':
+ echo "<li><a href=\"tblproperties.php?{$misc->href}&schema=", urlencode($rs->f['schemaname']), "&table=", urlencode($rs->f['name']), "\">", htmlspecialchars($rs->f['name']), "</a></li>\n";
+ break;
+ case 'VIEW':
+ echo "<li><a href=\"views.php?action=properties&{$misc->href}&schema=", urlencode($rs->f['schemaname']), "&view=", urlencode($rs->f['name']), "\">", htmlspecialchars($rs->f['name']), "</a></li>\n";
+ break;
+ case 'SEQUENCE':
+ echo "<li><a href=\"sequences.php?action=properties&{$misc->href}&schema=", urlencode($rs->f['schemaname']), "&sequence=", urlencode($rs->f['name']), "\">", htmlspecialchars($rs->f['name']), "</a></li>\n";
+ break;
+ }
+ $rs->moveNext();
+ }
+ echo "</ul>\n";
+ }
+ else echo $lang['strnodata'];
+ }
+ }
+
/**
* Allow database administration and tuning tasks
*/
$misc->printBody();
switch ($action) {
+ case 'find':
+ if (isset($_GET['term'])) doFind(false);
+ else doFind(true);
+ break;
case 'analyze':
doAdmin('analyze');
break;
* English language file for phpPgAdmin. Use this as a basis
* for new translations.
*
- * $Id: english.php,v 1.84 2003/07/28 07:14:08 chriskl Exp $
+ * $Id: english.php,v 1.85 2003/07/28 07:50:32 chriskl Exp $
*/
// Language and character set
$lang['strcollapse'] = 'Collapse';
$lang['strexplain'] = 'Explain';
$lang['strfind'] = 'Find';
+ $lang['stroptions'] = 'Options';
// Error handling
$lang['strnoframes'] = 'You need a frames-enabled browser to use this application.';
* English language file for phpPgAdmin. Use this as a basis
* for new translations.
*
- * $Id: english.php,v 1.36 2003/07/28 07:14:08 chriskl Exp $
+ * $Id: english.php,v 1.37 2003/07/28 07:50:32 chriskl Exp $
*/
// Language and character set
$lang['strcollapse'] = 'Collapse';
$lang['strexplain'] = 'Explain';
$lang['strfind'] = 'Find';
+ $lang['stroptions'] = 'Options';
// Error handling
$lang['strnoframes'] = 'You need a frames-enabled browser to use this application.';
/**
* Manage privileges in a database
*
- * $Id: privileges.php,v 1.16 2003/07/28 07:14:08 chriskl Exp $
+ * $Id: privileges.php,v 1.17 2003/07/28 07:50:31 chriskl Exp $
*/
// Include application functions
echo "<form action=\"$PHP_SELF\" method=\"post\">\n";
echo "<table>\n";
echo "<tr><th class=\"data\">{$lang['strusers']}</th>\n";
- echo "<td class=\"data1\"><select name=\"username[]\" multiple=\"multiple\" size=\"6\">\n";
+ echo "<td class=\"data1\"><select name=\"username[]\" multiple=\"multiple\" size=\"", min(6, $users->recordCount()), "\">\n";
while (!$users->EOF) {
$uname = htmlspecialchars($users->f[$data->uFields['uname']]);
echo "<option value=\"{$uname}\"",
echo "<input type=\"checkbox\" name=\"public\"", (isset($_REQUEST['public']) ? ' selected="selected"' : ''), " />PUBLIC\n";
// Only show groups if there are groups!
if ($groups->recordCount() > 0) {
- echo "<br /><select name=\"groupname[]\" multiple=\"multiple\" size=\"6\">\n";
+ echo "<br /><select name=\"groupname[]\" multiple=\"multiple\" size=\"", min(6, $groups->recordCount()), "\">\n";
while (!$groups->EOF) {
$gname = htmlspecialchars($groups->f[$data->grpFields['groname']]);
echo "<option value=\"{$gname}\"",
isset($_REQUEST['privilege'][$v]) ? ' selected="selected"' : '', ">{$v}<br />\n";
}
echo "</td></tr>\n";
+ // Grant option
+ if ($data->hasGrantOption()) {
+ echo "<tr><th class=\"data\">{$lang['stroptions']}</th>\n";
+ echo "<td class=\"data1\">\n";
+ echo "<input type=\"checkbox\" name=\"grantoption\"",
+ isset($_REQUEST['grantoption']) ? ' selected="selected"' : '', ">GRANT OPTION<br />\n";
+ echo "</td></tr>\n";
+ }
echo "</table>\n";
echo "<input type=\"hidden\" name=\"action\" value=\"save\" />\n";
}
else {
$status = $localData->setPrivileges(isset($_REQUEST['grant']) ? 'GRANT' : 'REVOKE', $_REQUEST['type'], $_REQUEST['object'],
- isset($_REQUEST['public']), $_REQUEST['username'], $_REQUEST['groupname'], array_keys($_REQUEST['privilege']));
+ isset($_REQUEST['public']), $_REQUEST['username'], $_REQUEST['groupname'], array_keys($_REQUEST['privilege']),
+ isset($_REQUEST['grantoption']) && isset($_REQUEST['grant']));
if ($status == 0)
doDefault($lang['strgranted']);
elseif ($status == -3 || $status == -4)