diff --git a/inc/ui/collection-edit.php b/inc/ui/collection-edit.php
index 11947e32..9279223e 100644
--- a/inc/ui/collection-edit.php
+++ b/inc/ui/collection-edit.php
@@ -14,11 +14,16 @@ $editor->AddAttribute('timezone', 'id', 'fld_timezone' );
$editor->AddAttribute('schedule_transp', 'id', 'fld_schedule_transp' );
$editor->AddAttribute('is_calendar', 'id', 'fld_is_calendar');
$editor->AddAttribute('is_addressbook', 'id', 'fld_is_addressbook');
-$editor->AddAttribute('is_calendar', 'onclick', 'toggle_enabled(\'fld_is_calendar\',\'=fld_timezone\',\'=fld_schedule_transp\',\'!fld_is_addressbook\');');
+$editor->AddAttribute('is_calendar', 'onclick', 'toggle_enabled(\'fld_is_calendar\',\'=fld_timezone\',\'=fld_schedule_transp\',\'!fld_is_addressbook\',\'=fld_ics_file\');');
$editor->AddAttribute('is_addressbook', 'onclick', 'toggle_enabled(\'fld_is_addressbook\',\'!fld_is_calendar\');');
-$editor->AddField('specific_privileges','default_privileges IS NULL');
-$editor->AddAttribute('specific_privileges', 'id', 'fld_specific_privileges');
-$editor->AddAttribute('specific_privileges', 'onclick', 'toggle_visible(\'fld_specific_privileges\',\'!privileges_settings\');');
+
+$editor->AddField('use_default_privs','default_privileges IS NULL');
+$editor->AddAttribute('use_default_privs', 'id', 'fld_use_default_privs');
+$editor->AddAttribute('use_default_privs', 'onclick', 'toggle_visible(\'fld_use_default_privs\',\'!privileges_settings\');');
+
+$editor->AddField('ics_file', "''");
+$editor->AddAttribute('ics_file', 'title', translate('Upload a .ics calendar in iCalendar format to initialise or replace this calendar.'));
+$editor->AddAttribute('ics_file', 'id', 'fld_ics_file');
$editor->SetWhere( 'collection_id='.$id );
@@ -33,6 +38,7 @@ $params = array(
$is_update = ( $_POST['_editor_action'][$editor->Id] == 'update' );
if ( !$is_update && isset($collection_name) && isset($user_no) && is_object($usr) ) {
$_POST['dav_name'] = sprintf('/%s/%s/', $usr->username, $collection_name );
+ $_POST['parent_container'] = sprintf('/%s/', $usr->username );
$params['collection_path'] = $_POST['dav_name'];
$privsql = 'SELECT path_privs( :session_principal, :collection_path, :scan_depth) AS priv';
}
@@ -51,7 +57,7 @@ dbg_error_log("ERROR", "Can write collection: %s", ($can_write_collection? 'yes'
$pwstars = '@@@@@@@@@@';
if ( $can_write_collection && $editor->IsSubmit() ) {
$editor->WhereNewRecord( "collection_id=(SELECT CURRVAL('dav_id_seq'))" );
- if ( $_POST['specific_privileges'] == 'on' ) {
+ if ( $_POST['use_default_privs'] == 'on' ) {
$_POST['default_privileges'] = '';
}
else if ( isset($_POST['default_privileges']) ) {
@@ -64,6 +70,30 @@ if ( $can_write_collection && $editor->IsSubmit() ) {
$is_update = ( $_POST['_editor_action'][$editor->Id] == 'update' );
if ( $_POST['timezone'] == '' ) unset($_POST['timezone']);
$editor->Write();
+ if ( isset($_FILES['ics_file']['tmp_name']) && $_FILES['ics_file']['tmp_name'] != '' ) {
+ /**
+ * If the user has uploaded a .ics file as a calendar, we fake this out
+ * as if it were a "PUT" request against a collection. This is something
+ * of a hack. It works though :-)
+ */
+ $ics = trim(file_get_contents($_FILES['ics_file']['tmp_name']));
+ dbg_error_log('User',':Write: Loaded %d bytes from %s', strlen($ics), $_FILES['ics_file']['tmp_name'] );
+ include_once('check_UTF8.php');
+ if ( !check_string($ics) ) $ics = force_utf8($ics);
+
+ if ( check_string($ics) ) {
+ $path = $editor->Value('dav_name');
+ $user_no = $editor->Value('user_no');
+ $username = $editor->Value('username');
+ include_once('caldav-PUT-functions.php');
+ controlRequestContainer( $username, $user_no, $path, false, ($publicly_readable == 'on' ? true : false));
+ import_collection( $ics, $user_no, $path, $session->user_no );
+ $c->messages[] = sprintf(translate('Calendar "%s" was loaded from file.'), $path);
+ }
+ else {
+ $c->messages[] = i18n('The file is not UTF-8 encoded, please check the error for more details.');
+ }
+ }
}
else {
$editor->GetRecord();
@@ -77,6 +107,8 @@ else {
$editor->Assign('default_privileges', $privs);
$editor->Assign('username', $usr->username);
$editor->Assign('user_no', $usr->user_no);
+ $editor->Assign('is_calendar', 't' );
+ $editor->Assign('use_default_privs', 't');
}
$privilege_xlate = array(
@@ -98,7 +130,6 @@ $privilege_xlate = array(
'schedule-send-freebusy' => translate('Scheduling: Send free/busy')
);
-
$default_privileges = bindec($editor->Value('default_privileges'));
$privileges_set = '
';
for( $i=0; $i
Available() ? '##collection_id.hidden####collection_id.value##' : translate('New Collection'));
-$prompt_dav_name = translate('DAV Path');
-$value_dav_name = ( $editor->Available() ? '##dav_name.value##' : '/##user_no.hidden####username.value##/##collection_name.input.20##' );
-$prompt_displayname = translate('Displayname');
-$prompt_public = translate('Publicly Readable');
-$prompt_calendar = translate('Is a Calendar');
-$prompt_addressbook = translate('Is an Addressbook');
-$prompt_specific_privileges = translate('Specific Privileges');
-$prompt_privileges = translate('Default Privileges');
-$prompt_description = translate('Description');
-$prompt_schedule_transp = translate('Schedule Transparency');
-$prompt_timezone = translate('Calendar Timezone');
+$prompt_collection_id = htmlentities(translate('Collection ID'));
+$value_id = ( $editor->Available() ? '##collection_id.hidden####collection_id.value##' : htmlentities(translate('New Collection')));
+$prompt_dav_name = htmlentities(translate('DAV Path'));
+$value_dav_name = ( $editor->Available() ? '##dav_name.value##' : '/##user_no.hidden####username.value##/ ##collection_name.input.30##' );
+$prompt_load_file = htmlentities(translate('Load From File'));
+$prompt_displayname = htmlentities(translate('Displayname'));
+$prompt_public = htmlentities(translate('Publicly Readable'));
+$prompt_calendar = htmlentities(translate('Is a Calendar'));
+$prompt_addressbook = htmlentities(translate('Is an Addressbook'));
+$prompt_use_default_privs = htmlentities(translate('Specific Privileges'));
+$prompt_privileges = htmlentities(translate('Default Privileges'));
+$prompt_description = htmlentities(translate('Description'));
+$prompt_schedule_transp = htmlentities(translate('Schedule Transparency'));
+$prompt_timezone = htmlentities(translate('Calendar Timezone'));
+
+$btn_all = htmlentities(translate('All')); $btn_all_title = htmlentities(translate('Toggle all privileges'));
+$btn_rw = htmlentities(translate('Read/Write')); $btn_rw_title = htmlentities(translate('Set read+write privileges'));
+$btn_read = htmlentities(translate('Read')); $btn_read_title = htmlentities(translate('Set read privileges'));
+$btn_fb = htmlentities(translate('Free/Busy')); $btn_fb_title = htmlentities(translate('Set free/busy privileges'));
+$btn_sd = htmlentities(translate('Schedule Deliver')); $btn_sd_title = htmlentities(translate('Set schedule-deliver privileges'));
+$btn_ss = htmlentities(translate('Schedule Send')); $btn_ss_title = htmlentities(translate('Set schedule-deliver privileges'));
+
$id = $editor->Value('collection_id');
$template = <<
| $prompt_collection_id: | $value_id |
| $prompt_dav_name: | $c->base_name/caldav.php$value_dav_name |
+ | $prompt_load_file: | ##ics_file.file.60## |
| $prompt_displayname: | ##dav_displayname.input.50## |
| $prompt_public: | ##publicly_readable.checkbox## |
| $prompt_calendar: | ##is_calendar.checkbox## |
| $prompt_addressbook: | ##is_addressbook.checkbox## |
- | $prompt_privileges: | ##specific_privileges.checkbox##
+ |
| $prompt_privileges: | ##use_default_privs.checkbox##
-
-
+
-
-
-
-
$privileges_set |
| $prompt_timezone: | ##timezone.select## |
@@ -242,9 +283,9 @@ label.privilege {
EOTEMPLATE;
@@ -288,6 +329,8 @@ if ( $editor->Available() ) {
function edit_grant_row( $row_data ) {
global $grantrow, $id, $privilege_xlate, $privilege_names;
+ global $btn_all, $btn_all_title, $btn_rw, $btn_rw_title, $btn_read, $btn_read_title;
+ global $btn_fb, $btn_fb_title, $btn_sd, $btn_sd_title, $btn_ss, $btn_ss_title;
if ( $row_data->to_principal > -1 ) {
$grantrow->SetRecord( $row_data );
@@ -309,19 +352,19 @@ if ( $editor->Available() ) {
diff --git a/inc/ui/principal-edit.php b/inc/ui/principal-edit.php
index 00966074..023013ff 100644
--- a/inc/ui/principal-edit.php
+++ b/inc/ui/principal-edit.php
@@ -4,6 +4,8 @@
$editor = new Editor(translate('Principal'), 'dav_principal');
$editor->SetLookup( 'date_format_type', "SELECT 'E', 'European' UNION SELECT 'U', 'US Format' UNION SELECT 'I', 'ISO Format'" );
$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.") );
param_to_global('id', 'int', 'old_id', 'principal_id' );
$editor->SetWhere( 'principal_id='.$id );
@@ -168,20 +170,30 @@ for( $i=0; $iAllowedTo('Admin') ) {
$admin_row_entry = ' | '.$prompt_admin.': | ##is_admin.checkbox## |
';
+ $delete_principal_button = '' . translate("Delete Principal") . '';
}
$id = $editor->Value('principal_id');
@@ -234,28 +246,34 @@ label.privilege {
}
- | $prompt_principal_id: | ##principal_id.value## |
+ | $prompt_principal_id: |
+
+ |
| $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## |
$admin_row_entry
| $prompt_privileges: |
-
-
+
-
-
-
-
$privileges_set |
| ##submit## |
@@ -362,8 +380,8 @@ EOTEMPLATE;
$browser->AddColumn( 'members', translate('Has Members'), '', '', 'has_members_list(principal_id)' );
if ( $can_write_principal ) {
- $del_link = 'Delete';
- $browser->AddColumn( 'action', 'Action', 'center', '', "'$edit_link $del_link'" );
+ $del_link = ''.translate('Delete').'';
+ $browser->AddColumn( 'action', translate('Action'), 'center', '', "'$edit_link $del_link'" );
}
$browser->SetOrdering( 'displayname', 'A' );
@@ -427,6 +445,8 @@ EOTEMPLATE;
function edit_grant_row( $row_data ) {
global $grantrow, $id, $c, $privilege_xlate, $privilege_names;
+ global $btn_all, $btn_all_title, $btn_rw, $btn_rw_title, $btn_read, $btn_read_title;
+ global $btn_fb, $btn_fb_title, $btn_sd, $btn_sd_title, $btn_ss, $btn_ss_title;
if ( $row_data->to_principal > -1 ) {
$grantrow->SetRecord( $row_data );
@@ -448,18 +468,18 @@ EOTEMPLATE;