* A class that implements the DB interface for Postgres
* Note: This class uses ADODB and returns RecordSets.
*
- * $Id: Postgres.php,v 1.136 2003/08/11 05:48:04 chriskl Exp $
+ * $Id: Postgres.php,v 1.137 2003/08/11 09:15:32 chriskl Exp $
*/
// @@@ THOUGHT: What about inherits? ie. use of ONLY???
* @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
+ * @param $cascade True for cascade revoke, 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, $grantoption) {
+ function setPrivileges($mode, $type, $object, $public, $usernames, $groupnames, $privileges, $grantoption, $cascade) {
$this->fieldArrayClean($usernames);
$this->fieldArrayClean($groupnames);
(!$public && sizeof($usernames) == 0 && sizeof($groupnames) == 0)) return -4;
if ($mode != 'GRANT' && $mode != 'REVOKE') return -5;
+ $sql = $mode;
+
+ // Grant option
+ if ($this->hasGrantOption() && $mode == 'REVOKE' && $grantoption) {
+ $sql .= ' GRANT OPTION FOR';
+ }
+
if (in_array('ALL PRIVILEGES', $privileges))
- $sql = "{$mode} ALL PRIVILEGES ON";
+ $sql .= " ALL PRIVILEGES ON";
else
- $sql = "{$mode} " . join(', ', $privileges) . " ON";
+ $sql .= " " . join(', ', $privileges) . " ON";
switch ($type) {
case 'table':
case 'view':
// Grant option
if ($this->hasGrantOption() && $mode == 'GRANT' && $grantoption) {
$sql .= ' WITH GRANT OPTION';
- }
+ }
+
+ // Cascade revoke
+ if ($this->hasGrantOption() && $mode == 'REVOKE' && $cascade) {
+ $sql .= ' CASCADE';
+ }
return $this->execute($sql);
}
/**
* Manage privileges in a database
*
- * $Id: privileges.php,v 1.17 2003/07/28 07:50:31 chriskl Exp $
+ * $Id: privileges.php,v 1.18 2003/08/11 09:15:32 chriskl Exp $
*/
// Include application functions
echo "<td class=\"data1\">\n";
echo "<input type=\"checkbox\" name=\"grantoption\"",
isset($_REQUEST['grantoption']) ? ' selected="selected"' : '', ">GRANT OPTION<br />\n";
+ echo "<input type=\"checkbox\" name=\"cascade\"",
+ isset($_REQUEST['cascade']) ? ' selected="selected"' : '', ">CASCADE ({$lang['strrevoke']})<br />\n";
echo "</td></tr>\n";
}
echo "</table>\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['grantoption']) && isset($_REQUEST['grant']));
+ isset($_REQUEST['grantoption']), isset($_REQUEST['cascade']));
if ($status == 0)
doDefault($lang['strgranted']);
elseif ($status == -3 || $status == -4)