From ec3996bca7a0df42595c1e5f19d2190a6a970459 Mon Sep 17 00:00:00 2001 From: Andrew McMillan Date: Thu, 14 Jun 2012 21:16:13 +1200 Subject: [PATCH] Decide whether we can write the principal before we refer to it... --- inc/ui/principal-edit.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/inc/ui/principal-edit.php b/inc/ui/principal-edit.php index 2f0bf28e..82bc5480 100644 --- a/inc/ui/principal-edit.php +++ b/inc/ui/principal-edit.php @@ -28,6 +28,12 @@ $privilege_xlate = array( 'schedule-send' => translate('Scheduling: Sending') ); +$can_write_principal = ($session->AllowedTo('Admin') || ($session->principal_id == $id)); +if ( !$can_write_principal && $id > 0 ) { + $target_principal = new Principal('principal_id', $id); + $can_write_principal = $session->HavePrivilegeTo('DAV::write', $target_principal->dav_name()); +} + $delete_collection_confirmation_required = null; $delete_principal_confirmation_required = null; @@ -943,10 +949,6 @@ if ( isset($_GET['subaction']) ) { $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';