mirror of
https://gitlab.com/davical-project/davical.git
synced 2026-07-22 12:09:25 +00:00
Add NeedPrivilege() method to DAVResource and simplify request method.
This commit is contained in:
parent
e0e5887762
commit
ebbec96269
@ -1098,12 +1098,18 @@ EOSQL;
|
||||
|
||||
|
||||
/**
|
||||
* Send a need-privileges error response. This function will never return.
|
||||
* Send a need-privileges error response. This function will only return
|
||||
* if the $href is not supplied and the current user has the specified
|
||||
* permission for the request path.
|
||||
*
|
||||
* @param string $href The unconstructed URI where we needed the privilege.
|
||||
* @param string $privilege The name of the needed privilege.
|
||||
* @param string $href The unconstructed URI where we needed the privilege.
|
||||
*/
|
||||
function NeedPrivilege( $href, $privilege ) {
|
||||
function NeedPrivilege( $privilege, $href=null ) {
|
||||
if ( !isset($href) ) {
|
||||
if ( $request->AllowedTo($privilege) ) return;
|
||||
}
|
||||
|
||||
$reply = new XMLDocument();
|
||||
$xml = new XMLElement( 'need-privileges',
|
||||
new XMLElement( 'resource', array(
|
||||
|
||||
@ -509,6 +509,21 @@ EOQRY;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if we have the needed privilege or send an error response.
|
||||
*
|
||||
* @param string $privilege The name of the needed privilege.
|
||||
*/
|
||||
function NeedPrivilege( $privilege ) {
|
||||
global $request;
|
||||
|
||||
if ( $this->HavePrivilegeTo($privilege) ) return;
|
||||
|
||||
$request->NeedPrivilege( $privilege, $this->dav_name );
|
||||
exit(0); // Unecessary, but might clarify things
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the array of privilege names converted into XMLElements
|
||||
*/
|
||||
|
||||
@ -12,9 +12,7 @@ dbg_error_log("ACL", "method handler");
|
||||
|
||||
require_once('DAVResource.php');
|
||||
|
||||
if ( ! ( $request->AllowedTo('read-acl') || $request->AllowedTo('read-current-user-privilege-set') || $request->AllowedTo('write-acl') ) ) {
|
||||
$request->DoResponse(403);
|
||||
}
|
||||
$request->NeedPrivilege('DAV::write-acl');
|
||||
|
||||
if ( ! ini_get('open_basedir') && (isset($c->dbg['ALL']) || (isset($c->dbg['put']) && $c->dbg['put'])) ) {
|
||||
$fh = fopen('/tmp/MOVE.txt','w');
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user