mirror of
https://gitlab.com/davical-project/davical.git
synced 2026-01-27 00:33:34 +00:00
default timezone for collections (fix: #106)
patch contributed by Gitlab user c-schwamborn in #106
This commit is contained in:
parent
7b55b7b1f2
commit
06085aa2e0
@ -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'} ) {
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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') ) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user