mirror of
https://gitlab.com/davical-project/davical.git
synced 2026-06-03 04:00:16 +00:00
Allow a user delegated write access to the principal to maintain it.
This commit is contained in:
parent
395d14d85d
commit
d1c2179bbb
@ -755,7 +755,7 @@ EOQRY;
|
||||
|
||||
|
||||
/**
|
||||
* Is the user has the privileges to do what is requested.
|
||||
* Does the user have the privileges to do what is requested.
|
||||
* @param $do_what mixed The request privilege name, or array of privilege names, to be checked.
|
||||
* @param $any boolean Whether we accept any of the privileges. The default is true, unless the requested privilege is 'all', when it is false.
|
||||
* @return boolean Whether they do have one of those privileges against this resource.
|
||||
|
||||
@ -35,6 +35,7 @@ EOSQL;
|
||||
* We extend the AWL Session class.
|
||||
*/
|
||||
require('Session.php');
|
||||
include_once('DAVResource.php');
|
||||
|
||||
|
||||
@Session::_CheckLogout();
|
||||
@ -48,6 +49,7 @@ class DAViCalSession extends Session
|
||||
{
|
||||
|
||||
public $principal_id;
|
||||
private $privilege_resources = array();
|
||||
|
||||
/**
|
||||
* Create a new DAViCalSession object.
|
||||
@ -99,6 +101,27 @@ class DAViCalSession extends Session
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Does the user have the privileges to do what is requested.
|
||||
* @param $do_what mixed The request privilege name, or array of privilege names, to be checked.
|
||||
* @param $path string The path we want that permission for
|
||||
* @param $any boolean Whether we accept any of the privileges. The default is true, unless the requested privilege is 'all', when it is false.
|
||||
* @return boolean Whether they do have one of those privileges against the specified path.
|
||||
*/
|
||||
function HavePrivilegeTo( $do_what, $path, $any = null ) {
|
||||
if ( $this->AllowedTo('Admin') ) return true;
|
||||
if ( !isset($this->privilege_resources[$path]) ) {
|
||||
$this->privilege_resources[$path] = new DAVResource($path);
|
||||
}
|
||||
$resource = $this->privilege_resources[$path];
|
||||
if ( isset($resource) && $resource->Exists() ) {
|
||||
return $resource->HavePrivilegeTo($do_what,$any);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Checks that this user is logged in, and presents a login screen if they aren't.
|
||||
*
|
||||
|
||||
@ -940,12 +940,13 @@ if ( isset($_GET['subaction']) ) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$can_write_principal = ($session->AllowedTo('Admin') || $session->principal_id == $id );
|
||||
|
||||
$editor = principal_editor();
|
||||
$page_elements[] = $editor;
|
||||
|
||||
$principal_path = '/'.$editor->Value('username').'/';
|
||||
$can_write_principal = ($session->AllowedTo('Admin') || $session->principal_id == $id
|
||||
|| $session->HavePrivilegeTo('DAV::write', $principal_path) );
|
||||
|
||||
if ( isset($id) && $id > 0 ) {
|
||||
$c->stylesheets[] = 'css/browse.css';
|
||||
$c->scripts[] = 'js/browse.js';
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user