diff --git a/inc/auth-functions.php b/inc/auth-functions.php index 6ec757d3..0ef8cc17 100644 --- a/inc/auth-functions.php +++ b/inc/auth-functions.php @@ -78,7 +78,7 @@ function getPrincipalByID( $principal_id, $use_cache = true ) { * Creates some default home collections for the user. * @param string $username The username of the user we are creating relationships for. */ -function CreateHomeCollections( $username, $defult_timezone = null ) { +function CreateHomeCollections( $username, $default_timezone = null ) { global $session, $c; if ( !isset($c->default_collections) ) @@ -98,8 +98,8 @@ function CreateHomeCollections( $username, $defult_timezone = null ) { $user_fullname = $principal->fullname; // user fullname $user_rfullname = implode(' ', array_reverse(explode(' ', $principal->fullname))); // user fullname in reverse order - $sql = 'INSERT INTO collection (user_no, parent_container, dav_name, dav_etag, dav_displayname, is_calendar, is_addressbook, default_privileges, created, modified, resourcetypes) '; - $sql .= 'VALUES( :user_no, :parent_container, :collection_path, :dav_etag, :displayname, :is_calendar, :is_addressbook, :privileges::BIT(24), current_timestamp, current_timestamp, :resourcetypes );'; + $sql = 'INSERT INTO collection (user_no, parent_container, dav_name, dav_etag, dav_displayname, is_calendar, is_addressbook, default_privileges, created, modified, resourcetypes, timezone ) '; + $sql .= 'VALUES( :user_no, :parent_container, :collection_path, :dav_etag, :displayname, :is_calendar, :is_addressbook, :privileges::BIT(24), current_timestamp, current_timestamp, :resourcetypes, :timezone );'; foreach( $c->default_collections as $v ) { if ( $v['type'] == 'calendar' || $v['type']=='addressbook' ) { @@ -123,6 +123,7 @@ function CreateHomeCollections( $username, $defult_timezone = null ) { $params[':is_calendar'] = ( $v['type']=='calendar' ? true : false ); $params[':is_addressbook'] = ( $v['type']=='addressbook' ? true : false ); $params[':privileges'] = ( !isset($v['privileges']) || $v['privileges']===null ? null : privilege_to_bits($v['privileges']) ); + $params[':timezone'] = ( ( !isset($v['timezone']) || empty($v['timezone']) ) && $v['type']=='calendar' ? $default_timezone : $v['timezone'] ); $qry = new AwlQuery( $sql, $params ); if ( $qry->Exec() ) { @@ -290,7 +291,7 @@ function UpdateUserFromExternal( &$usr ) { $qry = new AwlQuery( 'INSERT INTO principal( type_id, user_no, displayname, default_privileges) SELECT 1, user_no, fullname, :privs::INT::BIT(24) FROM usr WHERE username=(text(:username))', array( ':privs' => privilege_to_bits($c->default_privileges), ':username' => $usr->username) ); $qry->Exec('Login',__LINE__,__FILE__); - CreateHomeCalendar($usr->username); + CreateHomeCollections($usr->username, $c->default_timezone); CreateDefaultRelationships($usr->username); } else if ( $usr->fullname != $old->{'fullname'} ) { diff --git a/inc/drivers_imap_pam.php b/inc/drivers_imap_pam.php index 68ab8c97..bb4a480c 100644 --- a/inc/drivers_imap_pam.php +++ b/inc/drivers_imap_pam.php @@ -107,7 +107,7 @@ function IMAP_PAM_check($username, $password ){ dbg_error_log( "PAM", "Unable to create local principal for '%s'", $username ); return false; } - CreateHomeCollections($username); + CreateHomeCollections($username, $c->default_timezone); CreateDefaultRelationships($username); } return $principal; diff --git a/inc/drivers_ldap.php b/inc/drivers_ldap.php index 4bae21fe..9a51ed47 100644 --- a/inc/drivers_ldap.php +++ b/inc/drivers_ldap.php @@ -312,7 +312,7 @@ function sync_user_from_LDAP( Principal &$principal, $mapping, $ldap_values ) { } else { $principal->Create($fields_to_set); - CreateHomeCollections($principal->username()); + CreateHomeCollections($principal->username(), $c->default_timezone); CreateDefaultRelationships($principal->username()); } } diff --git a/inc/drivers_pwauth_pam.php b/inc/drivers_pwauth_pam.php index d7e13755..a28b86f6 100644 --- a/inc/drivers_pwauth_pam.php +++ b/inc/drivers_pwauth_pam.php @@ -79,7 +79,7 @@ function PWAUTH_PAM_check($username, $password) { dbg_error_log( "PAM", "Unable to create local principal for '%s'", $username ); return false; } - CreateHomeCollections($username); + CreateHomeCollections($username, $c->default_timezone); CreateDefaultRelationships($username); } return $principal; diff --git a/inc/drivers_rimap.php b/inc/drivers_rimap.php index 3b2d3a75..16d29ed7 100644 --- a/inc/drivers_rimap.php +++ b/inc/drivers_rimap.php @@ -99,7 +99,7 @@ function RIMAP_check($username, $password ){ dbg_error_log( "PAM", "Unable to create local principal for '%s'", $username ); return false; } - CreateHomeCollections($username); + CreateHomeCollections($username, $c->default_timezone); CreateDefaultRelationships($username); } return $principal; diff --git a/inc/drivers_squid_pam.php b/inc/drivers_squid_pam.php index d3a23610..8dfaa2f9 100644 --- a/inc/drivers_squid_pam.php +++ b/inc/drivers_squid_pam.php @@ -70,7 +70,7 @@ function SQUID_PAM_check($username, $password ){ dbg_error_log( "PAM", "Unable to create local principal for '%s'", $username ); return false; } - CreateHomeCollections($username); + CreateHomeCollections($username, $c->default_timezone); CreateDefaultRelationships($username); } return $principal; diff --git a/inc/ui/principal-edit.php b/inc/ui/principal-edit.php index 2e37cd59..a575a271 100644 --- a/inc/ui/principal-edit.php +++ b/inc/ui/principal-edit.php @@ -240,7 +240,7 @@ function principal_editor() { if ( $_POST['type_id'] != 3 && $editor->IsCreate() ) { /** We only add the default calendar if it isn't a group, and this is a create action */ require_once('auth-functions.php'); - CreateHomeCollections($editor->Value('username')); + CreateHomeCollections($editor->Value('username'), $c->default_timezone); CreateDefaultRelationships($editor->Value('username')); } if ( $session->AllowedTo('Admin') ) {