@@ 472-483 (lines=12) @@ | ||
469 | * |
|
470 | * @return int 0 if operation was successful |
|
471 | */ |
|
472 | public function grantRole($role, $rolename, $admin = 0) |
|
473 | { |
|
474 | $this->fieldClean($role); |
|
475 | $this->fieldClean($rolename); |
|
476 | ||
477 | $sql = "GRANT \"{$role}\" TO \"{$rolename}\""; |
|
478 | if ($admin == 1) { |
|
479 | $sql .= ' WITH ADMIN OPTION'; |
|
480 | } |
|
481 | ||
482 | return $this->execute($sql); |
|
483 | } |
|
484 | ||
485 | /** |
|
486 | * Revokes membership in a role. |
|
@@ 495-508 (lines=14) @@ | ||
492 | * |
|
493 | * @return int 0 if operation was successful |
|
494 | */ |
|
495 | public function revokeRole($role, $rolename, $admin = 0, $type = 'RESTRICT') |
|
496 | { |
|
497 | $this->fieldClean($role); |
|
498 | $this->fieldClean($rolename); |
|
499 | ||
500 | $sql = 'REVOKE '; |
|
501 | if ($admin == 1) { |
|
502 | $sql .= 'ADMIN OPTION FOR '; |
|
503 | } |
|
504 | ||
505 | $sql .= "\"{$role}\" FROM \"{$rolename}\" {$type}"; |
|
506 | ||
507 | return $this->execute($sql); |
|
508 | } |
|
509 | ||
510 | /** |
|
511 | * Removes a role. |