diff --git a/inc/ui/principal-edit.php b/inc/ui/principal-edit.php
index f90c9f63..e2cc0e58 100644
--- a/inc/ui/principal-edit.php
+++ b/inc/ui/principal-edit.php
@@ -7,6 +7,7 @@ $editor->SetLookup( 'date_format_type', "SELECT 'E', 'European' UNION SELECT 'U'
$editor->SetLookup( 'type_id', 'SELECT principal_type_id, principal_type_desc FROM principal_type ORDER BY principal_type_id' );
$editor->SetLookup( 'locale', 'SELECT \'\', \''.translate("*** Default Locale ***").'\' UNION SELECT locale, locale_name_locale FROM supported_locales ORDER BY 1 ASC' );
$editor->AddAttribute( 'locale', 'title', translate("The preferred language for this person.") );
+$editor->AddAttribute( 'fullname', 'title', translate("The full name for this person, group or other type of principal.") );
param_to_global('id', 'int', 'old_id', 'principal_id' );
$editor->SetWhere( 'principal_id='.$id );
@@ -85,10 +86,30 @@ if ( isset($_GET['subaction']) ) {
$can_write_principal = ($session->AllowedTo('Admin') || $session->principal_id == $id );
+$post_values = false;
+
+if ( isset($_POST['xxxxusername']) ) {
+ $_POST['xxxxusername'] = trim(str_replace('/', '', $_POST['xxxxusername']));
+ if ( $_POST['xxxxusername'] == '' ) {
+ $c->messages[] = i18n("The username must not be blank, and may not contain a slash");
+ $can_write_principal = false;
+ }
+};
+if ( isset($_POST['fullname']) && trim($_POST['fullname']) == '' ) {
+ $c->messages[] = i18n("The full name must not be blank.");
+ $can_write_principal = false;
+};
+if ( isset($_POST['email']) && trim($_POST['email']) == '' ) {
+ $c->messages[] = i18n("The email address really should not be blank.");
+}
+
$pwstars = '@@@@@@@@@@';
if ( $can_write_principal && $editor->IsSubmit() ) {
$editor->WhereNewRecord( "principal_id=(SELECT CURRVAL('dav_id_seq'))" );
- if ( ! $session->AllowedTo('Admin') ) unset($_POST['admin_role']);
+ if ( ! $session->AllowedTo('Admin') ) {
+ unset($_POST['admin_role']);
+ unset($_POST['user_active']);
+ }
unset($_POST['password']);
if ( $_POST['newpass1'] != '' && $_POST['newpass1'] != $pwstars ) {
if ( $_POST['newpass1'] == $_POST['newpass2'] ) {
@@ -98,6 +119,9 @@ if ( $can_write_principal && $editor->IsSubmit() ) {
$c->messages[] = "Password not updated. The supplied passwords do not match.";
}
}
+ if ( isset($_POST['fullname']) && !isset($_POST['displayname']) ) {
+ $_POST['displayname'] = $_POST['fullname'];
+ }
if ( isset($_POST['default_privileges']) ) {
$privilege_bitpos = array_flip($privilege_names);
$priv_names = array_keys($_POST['default_privileges']);
@@ -133,6 +157,9 @@ if ( $can_write_principal && $editor->IsSubmit() ) {
}
else {
$editor->GetRecord();
+ if ( $editor->IsSubmit() ) {
+ $post_values = true;
+ }
}
if ( $editor->Available() ) {
$c->page_title = $editor->Title(translate('Principal').': '.$editor->Value('fullname'));
@@ -142,9 +169,23 @@ else {
$privs = decbin(privilege_to_bits($c->default_privileges));
$editor->Assign('default_privileges', $privs);
$editor->Assign('user_active', 't');
+ foreach( $c->template_usr AS $k => $v ) {
+ $editor->Assign($k, $v);
+ }
+}
+if ( $post_values ) {
+ $editor->PostToValues();
+ if ( isset($_POST['default_privileges']) ) {
+ $privilege_bitpos = array_flip($privilege_names);
+ $priv_names = array_keys($_POST['default_privileges']);
+ $privs = privilege_to_bits($priv_names);
+ $_POST['default_privileges'] = sprintf('%024s',decbin($privs));
+ $editor->Assign('default_privileges', $_POST['default_privileges']);
+ }
}
$privilege_xlate = array(
+ 'all' => translate('All privileges'),
'read' => translate('Read'),
'write-properties' => translate('Write Metadata'),
'write-content' => translate('Write Data'),
@@ -199,10 +240,12 @@ for( $i=0; $iAvailable() ? '##principal_id.hidden####principal_id.value##' : translate('New Principal'));
$prompt_username = translate('Username');
$prompt_password_1 = translate('Change Password');
$prompt_password_1 = translate('Confirm Password');
$prompt_fullname = translate('Fullname');
+$prompt_displayname = translate('Display Name');
$prompt_email = translate('Email Address');
$prompt_date_format = translate('Date Format Style');
$prompt_admin = translate('Administrator');
@@ -274,23 +317,24 @@ label.privilege {
margin:0.2em 1em 0.2em 0.1em;
padding:0 0.2em;
line-height:1.6em;
+ font-size:87%;
}
$prompt_principal_id:
-
##principal_id.value##
+
$value_id
$delete_principal_button
-
$prompt_username:
##xxxxusername.input.50##
-
$prompt_password_1:
##newpass1.password.$pwstars##
+
$prompt_username:
##xxxxusername.input.50##
+
$prompt_password_1:
##newpass1.password.$pwstars##
$prompt_password_1:
##newpass2.password.$pwstars##
-
$prompt_fullname:
##fullname.input.50##
-
$prompt_email:
##email.input.50##
-
$prompt_locale:
##locale.select##
-
$prompt_date_format:
##date_format_type.select##
-
$prompt_type:
##type_id.select##
+
$prompt_fullname:
##fullname.input.50##
+
$prompt_email:
##email.input.50##
+
$prompt_locale:
##locale.select##
+
$prompt_date_format:
##date_format_type.select##
+
$prompt_type:
##type_id.select##
$admin_row_entry
$prompt_privileges:
@@ -356,7 +400,7 @@ if ( isset($id) ) {
if ( $editor->Value('type_id') == 3 ) {
$grouprow = new Editor("Group Members", "group_member");
- $grouprow->SetLookup( 'member_id', 'SELECT principal_id, displayname FROM dav_principal WHERE principal_id NOT IN (SELECT member_id FROM group_member WHERE group_id = '.$id.')');
+ $grouprow->SetLookup( 'member_id', 'SELECT principal_id, coalesce(displayname,fullname,username) FROM dav_principal WHERE principal_id NOT IN (SELECT member_id FROM group_member WHERE group_id = '.$id.')');
$grouprow->SetSubmitName( 'savegrouprow' );
if ( $can_write_principal ) {
@@ -446,7 +490,7 @@ EOTEMPLATE;
if ( isset($_GET['edit_grant']) ) {
$edit_grant_clause = ' AND to_principal != '.intval($_GET['edit_grant']);
}
- $grantrow->SetLookup( 'to_principal', 'SELECT principal_id, displayname FROM dav_principal WHERE principal_id NOT IN (SELECT to_principal FROM grants WHERE by_principal = '.$id.$edit_grant_clause.')' );
+ $grantrow->SetLookup( 'to_principal', 'SELECT principal_id, displayname FROM dav_principal WHERE principal_id NOT IN (SELECT to_principal FROM grants WHERE by_principal = '.$id.$edit_grant_clause.') ORDER BY fullname' );
if ( $can_write_principal ) {
if ( $grantrow->IsSubmit() ) {
if ( $grantrow->IsUpdate() )