[Tickets #8734] Re: Synchronization of multiple calendars with SyncML
bugs at horde.org
bugs at horde.org
Thu Aug 25 14:39:39 UTC 2011
BITTE NICHT AUF DIESE NACHRICHT ANTWORTEN. NACHRICHTEN AN DIESE
E-MAIL-ADRESSE WERDEN NICHT GELESEN.
Ticket-URL: http://bugs.horde.org/ticket/8734
------------------------------------------------------------------------------
Ticket | 8734
Aktualisiert Von | olli at gabosh.net
Zusammenfassung | Synchronization of multiple calendars with SyncML
Warteschlange | Kronolith
Version | Git master
Typ | Enhancement
Status | Resolved
Priorität | 2. Medium
Milestone | 3.0.5
Patch | 1
Zuständige | Michael Rubinsky
------------------------------------------------------------------------------
olli at gabosh.net (2011-08-25 14:39) hat geschrieben:
>> It seems multiple calendarsynchronizations are only working for
>> owner-owned calendars. We have some group calendars and most of our
>> users wants to be able to sync the calendars they have read-access to.
>> So is it possible to add synchronaization for "not" owned calendars?
>
> No. There are a number of issues with this. For your case,the most
> important is that there is no way to mark calendar entries readonly
> in activesync. Editing an event in a read only calendar would appear
> to work on the client,would fail to update server side which would
> cause the client to continuously attempt to sync this change. There
> is a thread on the dev list with more detailed discussion about this
> owner-only limitation.
OK, i solved this issue for me with his script... Maybe this will help
someone else:
#!/usr/bin/perl
use DBD::mysql;
use strict;
# CONFIGURE
my $user="$ARGV[0]";
my $database="$ARGV[1]";
my $host="localhost";
my $dbuser="root";
my $password=`gtc-crypt -a mysqlroot -p`;
chomp($password);
# Connect to the DB
my $dbh =
DBI->connect("DBI:mysql:database=$database;host=$host","$dbuser",
"$password", {'RaiseError' => 1}) || die "No connection to DB
$database: $? $!";
$password="";
# Create synccalendar if not exists
# Get primary calendar of the user
my $sth = $dbh->prepare("SELECT share_name FROM kronolith_sharesng
WHERE share_owner='$user'");
$sth->execute();
my $synccal;
my $nosynccal=1;
my $first=1;
while (my $cal = $sth->fetchrow_array()) {
if ($first) {
$synccal=$cal;
$synccal=~s/^...../SYNC-/;
$first=0;
}
else {
if ($cal eq $synccal) {
$nosynccal=0;
last;
}
}
}
if (($nosynccal) && ($synccal)) {
my $insert="INSERT INTO kronolith_sharesng (share_name, share_owner,
share_flags, perm_creator_2, perm_creator_4, perm_creator_8,
perm_creator_16, perm_creator_1024, perm_default_2, perm_default_4,
perm_default_8, perm_default_16, perm_default_1024, perm_guest_2,
perm_guest_4, perm_guest_8, perm_guest_16, perm_guest_1024,
attribute_name, attribute_desc, attribute_color, share_parents) VALUES
('$synccal', '$user', '0', '0', '0', '0', '0', '0', '0', '0', '0',
'0', '0', '0', '0', '0', '0', '0', 'Sync', 'Only for syncing',
'#ffffff', 'NULL')";
$dbh->do($insert) || die "Error: $! $?";
}
exit 1 unless ($synccal);
# Get displayed calendars of user
my @cals;
my $sth = $dbh->prepare("SELECT pref_value FROM horde_prefs WHERE
pref_scope='kronolith' AND pref_name='display_cals' AND
pref_uid='$user'");
$sth->execute();
while (my $ref = $sth->fetchrow_hashref()) {
my $cals= $ref->{'pref_value'};
$cals=~s/^a:.+:{//;
$cals=~s/i:.;s:23://g;
$cals=~s/\"//g;
$cals=~s/;}$//;
@cals=split(/;/, $cals);
}
exit 1 unless ($cals[0]);
# Set Sync-Calendar in Horde-Prefs
$dbh->do("DELETE FROM horde_prefs WHERE pref_uid='$user' AND
pref_name='sync_calendars' AND pref_scope='kronolith'");
$dbh->do("INSERT INTO horde_prefs (pref_uid, pref_scope, pref_name,
pref_value) VALUES ('$user', 'kronolith', 'sync_calendars',
'a:1:{i:0;s:23:\"$synccal\";}')");
# Clear the sync-calendar
$dbh->do("DELETE FROM kronolith_events WHERE calendar_id='$synccal'");
# Copy Calendars to sync-Calendar
foreach my $cal (@cals) {
if ($cal eq $synccal) { next }
my $sth = $dbh->prepare("SELECT * FROM kronolith_events WHERE
calendar_id='$cal'");
$sth->execute();
while (my $ref = $sth->fetchrow_hashref()) {
$ref->{'event_id'}=~s/^...../SYNC-/;
my $insert="INSERT INTO kronolith_events (event_keywords,
event_exceptions, event_recurinterval, event_recurdays,
event_recurenddate, event_recurcount, event_baseid,
event_exceptionoriginaldate, event_id, event_uid, event_creator_id,
event_title, event_description, event_location, event_url,
event_private, event_status, event_attendees, event_resources,
event_modified, event_start, event_end, event_allday, event_alarm,
event_alarm_methods, event_recurtype, calendar_id) VALUES
('$ref->{'event_keywords'}', '$ref->{'event_exceptions'}',
'$ref->{'event_recurinterval'}', '$ref->{'event_recurdays'}',
'$ref->{'event_recurenddate'}', '$ref->{'event_recurcount'}',
'$ref->{'event_baseid'}', '$ref->{'event_exceptionoriginaldate'}',
'$ref->{'event_id'}', '$ref->{'event_uid'}',
'$ref->{'event_creator_id'}', '$ref->{'event_title'}',
'$ref->{'event_description'}', '$ref->{'event_location'}',
'$ref->{'event_url'}', '$ref->{'event_private'}',
'$ref->{'event_status'}', '$ref->{'event_attendees'}',
'$ref->{'event_resources'}', '$ref->{'event_modified'}',
'$ref->{'event_start'}', '$ref->{'event_end'}',
'$ref->{'event_allday'}', '$ref->{'event_alarm'}',
'$ref->{'event_alarm_methods'}', '$ref->{'event_recurtype'}',
'$synccal')";
$dbh->do($insert) || die "Error: $! $?";
}
$sth->finish();
# Copy Horde-Histories-Settings for synchronization
$sth = $dbh->prepare("SELECT * FROM horde_histories");
$sth->execute();
while (my $ref = $sth->fetchrow_hashref()) {
if ($ref->{'object_uid'} =~ /^kronolith\:$cal/) {
$ref->{'object_uid'}=~s/^kronolith\:$cal/kronolith\:$synccal/;
my $insert="INSERT INTO horde_histories (object_uid,
history_action, history_ts, history_desc, history_who, history_extra)
VALUES ('$ref->{'object_uid'}', '$ref->{'history_action'}',
'$ref->{'history_ts'}', '$ref->{'history_desc'}',
'$ref->{'history_who'}', '$ref->{'history_extra'}')";
$dbh->do($insert) || die "Error: $! $?";
next;
}
if ($ref->{'object_uid'} =~ /^kronolith\:$synccal/) {
$dbh->do("DELETE FROM horde_histories WHERE
history_id='$ref->{'history_id'}'");
}
}
$sth->finish();
}
More information about the bugs
mailing list