Create .in and .out calendars on principal creation.

Closes #227
This commit is contained in:
Andrew Ruthven authored and Andrew Ruthven committed 2023-02-05 13:04:09 +00:00
1 parent 0041577fc8
commit 43996a3297
2 files changed
+30 -4

No files matched your search

+28 -4
View File
@@ -86,9 +86,27 @@ function CreateHomeCollections( $username, $default_timezone = null ) {
$c->default_collections = array();
if( !empty($c->home_calendar_name) )
$c->default_collections[] = array( 'type' => 'calendar', 'name' => $c->home_calendar_name );
$c->default_collections[] = array(
'type' => 'calendar',
'name' => $c->home_calendar_name
);
if( !empty($c->home_out_calendar_name) )
$c->default_collections[] = array(
'type' => 'calendar',
'name' => $c->home_out_calendar_name,
'displayname_suffix' => ' Outbox'
);
if( !empty($c->home_in_calendar_name) )
$c->default_collections[] = array(
'type' => 'calendar',
'name' => $c->home_in_calendar_name,
'displayname_suffix' => ' Inbox'
);
if( !empty($c->home_addressbook_name) )
$c->default_collections[] = array( 'type' => 'addressbook', 'name' => $c->home_addressbook_name );
$c->default_collections[] = array(
'type' => 'addressbook',
'name' => $c->home_addressbook_name
);
}
if ( !is_array($c->default_collections) || !count($c->default_collections) ) return true;
@@ -118,7 +136,13 @@ function CreateHomeCollections( $username, $default_timezone = null ) {
$params[':parent_container'] = $principal->dav_name();
$params[':dav_etag'] = '-1';
$params[':collection_path'] = $principal->dav_name().$v['name'].'/';
$params[':displayname'] = ( !isset($v['displayname']) || empty($v['displayname']) ? $user_fullname.( $v['type']=='calendar' ? ' calendar' : ' addressbook' ) : str_replace(array('%fn', '%rfn'), array($user_fullname, $user_rfullname), $v['displayname']) );
if ( isset($v['displayname']) && ! empty($v['displayname']) ) {
$params[':displayname'] = str_replace(array('%fn', '%rfn'), array($user_fullname, $user_rfullname), $v['displayname']);
} elseif ( isset($v['displayname_suffix']) && ! empty($v['displayname_suffix']) ) {
$params[':displayname'] = $user_fullname . $v['displayname_suffix'];
} else {
$params[':displayname'] = $user_fullname . ($v['type']=='calendar' ? ' calendar' : ' addressbook');
}
$params[':resourcetypes'] = ( $v['type']=='calendar' ? '<DAV::collection/><urn:ietf:params:xml:ns:caldav:calendar/>' : '<DAV::collection/><urn:ietf:params:xml:ns:carddav:addressbook/>' );
$params[':is_calendar'] = ( $v['type']=='calendar' ? true : false );
$params[':is_addressbook'] = ( $v['type']=='addressbook' ? true : false );
@@ -126,7 +150,7 @@ function CreateHomeCollections( $username, $default_timezone = null ) {
$qry = new AwlQuery( $sql, $params );
if ( $qry->Exec() ) {
$c->messages[] = i18n('Home '.( $v['type']=='calendar' ? 'calendar' : 'addressbook' ).' added.');
$c->messages[] = i18n('Home '.( $v['type']=='calendar' ? 'calendar' : 'addressbook' ).' added.') . " " . $v['name'];
dbg_error_log("User",":Write: Created user's home ".( $v['type']=='calendar' ? 'calendar' : 'addressbook' )." at '%s'", $params[':collection_path'] );
// create value for urn:ietf:params:xml:ns:caldav:supported-calendar-component-set property