|
@@ -7,16 +7,16 @@ function apple_bash_variables_set_to_exec(){
|
|
|
//
|
|
//
|
|
|
return "export PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/local/bin:/Applications/Server.app/Contents/ServerRoot/usr/bin:/Applications/Server.app/Contents/ServerRoot/usr/sbin
|
|
return "export PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/local/bin:/Applications/Server.app/Contents/ServerRoot/usr/bin:/Applications/Server.app/Contents/ServerRoot/usr/sbin
|
|
|
";
|
|
";
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
function APPLE_ICAL_SE_SYNC() {
|
|
function APPLE_ICAL_SE_SYNC() {
|
|
|
|
|
|
|
|
-//function to share events from SE/Procesy5 to Apple CalDavServer
|
|
|
|
|
|
|
+//function to share events from SE/Procesy5 to Apple CalDavServer
|
|
|
// creating resources: locations/resources
|
|
// creating resources: locations/resources
|
|
|
// sharing them to correct groups/owners according to source record policy
|
|
// sharing them to correct groups/owners according to source record policy
|
|
|
- //
|
|
|
|
|
|
|
+ //
|
|
|
// at the moment @2014-01-15 working only one way
|
|
// at the moment @2014-01-15 working only one way
|
|
|
// -TODO update added events 2 way
|
|
// -TODO update added events 2 way
|
|
|
// -TODO verify perms for shared calendar
|
|
// -TODO verify perms for shared calendar
|
|
@@ -56,7 +56,7 @@ DEBUG_S(-3,'events',$events);
|
|
|
while($t=DB::fetch_array($rt)) {
|
|
while($t=DB::fetch_array($rt)) {
|
|
|
if(!strstr($t[0],'_HIST'))
|
|
if(!strstr($t[0],'_HIST'))
|
|
|
$tbls[]=$t[0];
|
|
$tbls[]=$t[0];
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -64,37 +64,37 @@ DEBUG_S(-3,'events',$events);
|
|
|
|
|
|
|
|
|
|
|
|
|
echo "APPLE_ICAL_SE_SYNC";
|
|
echo "APPLE_ICAL_SE_SYNC";
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
/*
|
|
/*
|
|
|
//! szukamy ostatniej daty zsynchronizwanego wydarzenia lokalnie
|
|
//! szukamy ostatniej daty zsynchronizwanego wydarzenia lokalnie
|
|
|
$sql="select unix_timestamp(max(TIMESTAMP))+".$GMT_OFFSET." as MAX_LEFT from CRM_APPLE_ICAL_SYNC_PGSQL";
|
|
$sql="select unix_timestamp(max(TIMESTAMP))+".$GMT_OFFSET." as MAX_LEFT from CRM_APPLE_ICAL_SYNC_PGSQL";
|
|
|
- $res_max_left=DB::query($sql);
|
|
|
|
|
|
|
+ $res_max_left=DB::query($sql);
|
|
|
while($h=DB::fetch($res_max_left)) { $max_ts_left=$h->MAX_LEFT;}
|
|
while($h=DB::fetch($res_max_left)) { $max_ts_left=$h->MAX_LEFT;}
|
|
|
DEBUG_S(-3,'maxymalna data synchr z lewej MAX_LEFT = '.$max_ts_left,null,__FILE__,__FUNCTION__,__LINE__);
|
|
DEBUG_S(-3,'maxymalna data synchr z lewej MAX_LEFT = '.$max_ts_left,null,__FILE__,__FUNCTION__,__LINE__);
|
|
|
- //! szukamy ostatniej daty dodanego/zsynchronizowanego wydarzenia zdalnie
|
|
|
|
|
|
|
+ //! szukamy ostatniej daty dodanego/zsynchronizowanego wydarzenia zdalnie
|
|
|
//(calendar_metadata resource_id , created,modified - 2013-05-17 11:09:16.409332 )
|
|
//(calendar_metadata resource_id , created,modified - 2013-05-17 11:09:16.409332 )
|
|
|
$dbconn = pg_connect("host='/Library/Server/PostgreSQL For Server Services/Socket' port=5432 user=caldav dbname=caldav");
|
|
$dbconn = pg_connect("host='/Library/Server/PostgreSQL For Server Services/Socket' port=5432 user=caldav dbname=caldav");
|
|
|
$psql="select extract( epoch from max(cm.modified)) from calendar_metadata as cm
|
|
$psql="select extract( epoch from max(cm.modified)) from calendar_metadata as cm
|
|
|
- left join calendar_object_revisions as cor on cor.calendar_resource_id=cm.resource_id
|
|
|
|
|
- where cor.resource_name like '%-ical-sqix-sync%'
|
|
|
|
|
-
|
|
|
|
|
|
|
+ left join calendar_object_revisions as cor on cor.calendar_resource_id=cm.resource_id
|
|
|
|
|
+ where cor.resource_name like '%-ical-sqix-sync%'
|
|
|
|
|
+
|
|
|
" ;
|
|
" ;
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
$qry=pg_query($dbconn,$psql);
|
|
$qry=pg_query($dbconn,$psql);
|
|
|
- $fch = pg_fetch_row($qry); list($max_ts_right)=explode(".",$fch[0]);
|
|
|
|
|
|
|
+ $fch = pg_fetch_row($qry); list($max_ts_right)=explode(".",$fch[0]);
|
|
|
|
|
|
|
|
|
|
|
|
|
- DEBUG_S(-3,'maxymalna data synchr z prawej MAX_RIGHT = '.$max_ts_right,$psql,__FILE__,__FUNCTION__,__LINE__);
|
|
|
|
|
|
|
+ DEBUG_S(-3,'maxymalna data synchr z prawej MAX_RIGHT = '.$max_ts_right,$psql,__FILE__,__FUNCTION__,__LINE__);
|
|
|
// sync_events_from_mac($max_ts_left,$max_ts_right);
|
|
// sync_events_from_mac($max_ts_left,$max_ts_right);
|
|
|
-
|
|
|
|
|
-*/
|
|
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
|
|
+*/
|
|
|
|
|
+
|
|
|
$uid='4720124D-5F20-4EAB-B501-4872E33F9A5C'; //is a.binder
|
|
$uid='4720124D-5F20-4EAB-B501-4872E33F9A5C'; //is a.binder
|
|
|
$calendar_type='tasks';
|
|
$calendar_type='tasks';
|
|
|
// $events_in_server_cal=mac_ical_get_events_etag('4720124D-5F20-4EAB-B501-4872E33F9A5C','calendar');
|
|
// $events_in_server_cal=mac_ical_get_events_etag('4720124D-5F20-4EAB-B501-4872E33F9A5C','calendar');
|
|
|
$events_in_server=mac_ical_get_events_etag($uid,$calendar_type);
|
|
$events_in_server=mac_ical_get_events_etag($uid,$calendar_type);
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
//$events_in_server = (object)array_merge((array)$events_in_server_cal, (array)$events_in_server_task);
|
|
//$events_in_server = (object)array_merge((array)$events_in_server_cal, (array)$events_in_server_task);
|
|
|
DEBUG_S(-3,'All Events in server ',$events_in_server,__FILE__,__FUNCTION__,__LINE__);
|
|
DEBUG_S(-3,'All Events in server ',$events_in_server,__FILE__,__FUNCTION__,__LINE__);
|
|
|
mac_ical_parse_events_detect_what_to_sync($events_in_server,$uid,$calendar_type);
|
|
mac_ical_parse_events_detect_what_to_sync($events_in_server,$uid,$calendar_type);
|
|
@@ -113,25 +113,25 @@ DEBUG_S(-3,'events',$events);
|
|
|
//! 2 sprawdzenie czy sa pola do synchronizacji
|
|
//! 2 sprawdzenie czy sa pola do synchronizacji
|
|
|
|
|
|
|
|
//odczytujemy wszystkie eventy z serwera dla potrzeb synchronizacji
|
|
//odczytujemy wszystkie eventy z serwera dla potrzeb synchronizacji
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
while($h=DB::fetch_array($res)) {
|
|
while($h=DB::fetch_array($res)) {
|
|
|
if($h[0]=='ID') $found_ID=true;
|
|
if($h[0]=='ID') $found_ID=true;
|
|
|
if($h[0]=='L_APPOITMENT_DATE') $found_L_APPOITMENT_DATE=true;
|
|
if($h[0]=='L_APPOITMENT_DATE') $found_L_APPOITMENT_DATE=true;
|
|
|
if($h[0]=='L_APPOITMENT_USER') $found_L_APPOITMENT_USER=true;
|
|
if($h[0]=='L_APPOITMENT_USER') $found_L_APPOITMENT_USER=true;
|
|
|
if($h[0]=='L_APPOITMENT_PERIOD') $found_L_APPOITMENT_PERIOD=true;
|
|
if($h[0]=='L_APPOITMENT_PERIOD') $found_L_APPOITMENT_PERIOD=true;
|
|
|
- if($h[0]=='L_APPOITMENT_INFO') $found_L_APPOITMENT_INFO=true;
|
|
|
|
|
- if($h[0]=='A_RECORD_UPDATE_DATE') $found_A_RECORD_UPDATE_DATE=true;
|
|
|
|
|
|
|
+ if($h[0]=='L_APPOITMENT_INFO') $found_L_APPOITMENT_INFO=true;
|
|
|
|
|
+ if($h[0]=='A_RECORD_UPDATE_DATE') $found_A_RECORD_UPDATE_DATE=true;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
if(($found_ID)&&($found_L_APPOITMENT_PERIOD)&&($found_L_APPOITMENT_USER)&&($found_L_APPOITMENT_PERIOD)&&($found_L_APPOITMENT_INFO)&&($found_A_RECORD_UPDATE_DATE)) {
|
|
if(($found_ID)&&($found_L_APPOITMENT_PERIOD)&&($found_L_APPOITMENT_USER)&&($found_L_APPOITMENT_PERIOD)&&($found_L_APPOITMENT_INFO)&&($found_A_RECORD_UPDATE_DATE)) {
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
echo "<br>Bede synchronizowac ".$table;
|
|
echo "<br>Bede synchronizowac ".$table;
|
|
|
$sql="select t1.*
|
|
$sql="select t1.*
|
|
|
from `".$table."` as t1
|
|
from `".$table."` as t1
|
|
|
- left join CRM_APPLE_ICAL_SYNC_PGSQL as cs
|
|
|
|
|
|
|
+ left join CRM_APPLE_ICAL_SYNC_PGSQL as cs
|
|
|
on ( cs.LOCAL_TABLE='".$table."' and cs.LOCAL_ID=t1.ID )
|
|
on ( cs.LOCAL_TABLE='".$table."' and cs.LOCAL_ID=t1.ID )
|
|
|
where cs.ID is null and
|
|
where cs.ID is null and
|
|
|
- t1.L_APPOITMENT_DATE>0 and ( t1.L_APPOITMENT_USER like '%a.binder%' or t1.L_APPOITMENT_USER like 'xx%crash%' or t1.L_APPOITMENT_USER like 'xx%bzyk%' or t1.L_APPOITMENT_USER like 'xx%moksik%')
|
|
|
|
|
|
|
+ t1.L_APPOITMENT_DATE>0 and ( t1.L_APPOITMENT_USER like '%a.binder%' or t1.L_APPOITMENT_USER like 'xx%crash%' or t1.L_APPOITMENT_USER like 'xx%bzyk%' or t1.L_APPOITMENT_USER like 'xx%moksik%')
|
|
|
limit 2;
|
|
limit 2;
|
|
|
";
|
|
";
|
|
|
DEBUG_S(-3,'SQL',$sql,__FILE__,__FUNCTION__,__LINE__);
|
|
DEBUG_S(-3,'SQL',$sql,__FILE__,__FUNCTION__,__LINE__);
|
|
@@ -140,7 +140,7 @@ DEBUG_S(-3,'events',$events);
|
|
|
while($ROW_WITH_L_APP=DB::fetch($res_rigt)) {
|
|
while($ROW_WITH_L_APP=DB::fetch($res_rigt)) {
|
|
|
insert_new_event_to_mac_ical($ROW_WITH_L_APP,$table);
|
|
insert_new_event_to_mac_ical($ROW_WITH_L_APP,$table);
|
|
|
}
|
|
}
|
|
|
- //! 4 dodajemy nowe resource do kalendarzy -
|
|
|
|
|
|
|
+ //! 4 dodajemy nowe resource do kalendarzy -
|
|
|
//patrzymy jakie sa pola w danej tabeli - szukajac specjalnej kolumny L_CALENDAR
|
|
//patrzymy jakie sa pola w danej tabeli - szukajac specjalnej kolumny L_CALENDAR
|
|
|
$sql="describe ".$table;
|
|
$sql="describe ".$table;
|
|
|
$res_rigt=DB::query($sql);
|
|
$res_rigt=DB::query($sql);
|
|
@@ -151,7 +151,7 @@ DEBUG_S(-3,'events',$events);
|
|
|
if($has_L_CALENDAR) {
|
|
if($has_L_CALENDAR) {
|
|
|
$sql="select t1.*
|
|
$sql="select t1.*
|
|
|
from `".$table."` as t1
|
|
from `".$table."` as t1
|
|
|
- left join _SYNC_ICAL_RESOURCES as cs
|
|
|
|
|
|
|
+ left join _SYNC_ICAL_RESOURCES as cs
|
|
|
on ( cs.LOCAL_TABLE='".$table."' and cs.LOCAL_ID=t1.ID )
|
|
on ( cs.LOCAL_TABLE='".$table."' and cs.LOCAL_ID=t1.ID )
|
|
|
where cs.GUID is null and
|
|
where cs.GUID is null and
|
|
|
t1.L_CALENDAR='YES'
|
|
t1.L_CALENDAR='YES'
|
|
@@ -164,17 +164,17 @@ DEBUG_S(-3,'events',$events);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
//! todo szukamy ostatniej daty aktualizacji rekordu ze wszystkich tabel dla danego usera
|
|
//! todo szukamy ostatniej daty aktualizacji rekordu ze wszystkich tabel dla danego usera
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
//! todo szukamy date ostatniej aktualizacji eventu u uzytkownika
|
|
//! todo szukamy date ostatniej aktualizacji eventu u uzytkownika
|
|
|
-
|
|
|
|
|
- //! todo szukamy daty ostatniej synchronizacji
|
|
|
|
|
|
|
+
|
|
|
|
|
+ //! todo szukamy daty ostatniej synchronizacji
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@@ -195,13 +195,13 @@ function mac_ical_try_create_calendar($ROW_WITH_L_APP,$table) {
|
|
|
// jezeli nie jest puste CALENDAR_RESOURCE_ID to system probuje je stworzyc i zaktualiozwac informacje o numerze resource ID
|
|
// jezeli nie jest puste CALENDAR_RESOURCE_ID to system probuje je stworzyc i zaktualiozwac informacje o numerze resource ID
|
|
|
// to ma byc jednorazowa akcja
|
|
// to ma byc jednorazowa akcja
|
|
|
if(isset($ROW_WITH_L_APP->L_CALENDAR) ) {
|
|
if(isset($ROW_WITH_L_APP->L_CALENDAR) ) {
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
if(($ROW_WITH_L_APP->L_CALENDAR=='YES')) {
|
|
if(($ROW_WITH_L_APP->L_CALENDAR=='YES')) {
|
|
|
//bedziemy tworzyc nowy resource
|
|
//bedziemy tworzyc nowy resource
|
|
|
mac_ical_create_resource_bash($ROW_WITH_L_APP,$table);
|
|
mac_ical_create_resource_bash($ROW_WITH_L_APP,$table);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@@ -213,17 +213,17 @@ function mac_ical_get_long_name($ROW_WITH_L_APP,$table) {
|
|
|
if(!empty($ROW_WITH_L_APP->T_DEVICE_TYPE)) $name.="_".substr($ROW_WITH_L_APP->T_DEVICE_TYPE, 0,50);
|
|
if(!empty($ROW_WITH_L_APP->T_DEVICE_TYPE)) $name.="_".substr($ROW_WITH_L_APP->T_DEVICE_TYPE, 0,50);
|
|
|
if(!empty($ROW_WITH_L_APP->T_DEVICE_INFO)) $name.="_".substr($ROW_WITH_L_APP->T_DEVICE_INFO, 0,50);
|
|
if(!empty($ROW_WITH_L_APP->T_DEVICE_INFO)) $name.="_".substr($ROW_WITH_L_APP->T_DEVICE_INFO, 0,50);
|
|
|
if(!empty($ROW_WITH_L_APP->T_DEVICE_SERIAL)) $name.="_".substr($ROW_WITH_L_APP->T_DEVICE_SERIAL, 0,50);
|
|
if(!empty($ROW_WITH_L_APP->T_DEVICE_SERIAL)) $name.="_".substr($ROW_WITH_L_APP->T_DEVICE_SERIAL, 0,50);
|
|
|
- if(!empty($ROW_WITH_L_APP->T_PRODUCER)) $name.="_".substr($ROW_WITH_L_APP->T_PRODUCER, 0,50);
|
|
|
|
|
- if(!empty($ROW_WITH_L_APP->T_TELBOX_NAME)) $name.="_".substr($ROW_WITH_L_APP->T_TELBOX_NAME, 0,50);
|
|
|
|
|
- if(!empty($ROW_WITH_L_APP->S_ADDRESS_STREET)) $name.="_".substr($ROW_WITH_L_APP->S_ADDRESS_STREET, 0,50);
|
|
|
|
|
- if(!empty($ROW_WITH_L_APP->S_OTHER_INFO)) $name.="_".substr($ROW_WITH_L_APP->S_OTHER_INFO, 0,50);
|
|
|
|
|
|
|
+ if(!empty($ROW_WITH_L_APP->T_PRODUCER)) $name.="_".substr($ROW_WITH_L_APP->T_PRODUCER, 0,50);
|
|
|
|
|
+ if(!empty($ROW_WITH_L_APP->T_TELBOX_NAME)) $name.="_".substr($ROW_WITH_L_APP->T_TELBOX_NAME, 0,50);
|
|
|
|
|
+ if(!empty($ROW_WITH_L_APP->S_ADDRESS_STREET)) $name.="_".substr($ROW_WITH_L_APP->S_ADDRESS_STREET, 0,50);
|
|
|
|
|
+ if(!empty($ROW_WITH_L_APP->S_OTHER_INFO)) $name.="_".substr($ROW_WITH_L_APP->S_OTHER_INFO, 0,50);
|
|
|
$name=preg_replace('((?![a-z]|[A-Z]|[0-9]|[\ ]|[_]|[-]).)', '', $name);
|
|
$name=preg_replace('((?![a-z]|[A-Z]|[0-9]|[\ ]|[_]|[-]).)', '', $name);
|
|
|
return $name;
|
|
return $name;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function mac_ical_get_short_name($ROW_WITH_L_APP,$table) {
|
|
function mac_ical_get_short_name($ROW_WITH_L_APP,$table) {
|
|
|
$name=$ROW_WITH_L_APP->ID."_".$table;
|
|
$name=$ROW_WITH_L_APP->ID."_".$table;
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
return $name;
|
|
return $name;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -250,8 +250,8 @@ function mac_ical_create_resource_bash($ROW_WITH_L_APP,$table) {
|
|
|
if($table=='IN7_MK_BAZA_DYSTRYBUCJI') $resource_type='resources';
|
|
if($table=='IN7_MK_BAZA_DYSTRYBUCJI') $resource_type='resources';
|
|
|
else if($table=='TELBOXES') $resource_type='locations';
|
|
else if($table=='TELBOXES') $resource_type='locations';
|
|
|
else $resource_type='resources';
|
|
else $resource_type='resources';
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
$cmd_share=apple_bash_variables_set_to_exec()." sudo /Applications/Server.app/Contents/ServerRoot/usr/sbin/calendarserver_manage_principals --add ".$resource_type." '".$resource_name."' ".$resource_short_name; $out="";$exit="";
|
|
$cmd_share=apple_bash_variables_set_to_exec()." sudo /Applications/Server.app/Contents/ServerRoot/usr/sbin/calendarserver_manage_principals --add ".$resource_type." '".$resource_name."' ".$resource_short_name; $out="";$exit="";
|
|
|
//$cmd_share='declare';
|
|
//$cmd_share='declare';
|
|
|
// $cmd_share=apple_bash_variables_set_to_exec().' sudo /Applications/Server.app/Contents/ServerRoot/usr/sbin/calendarserver_manage_principals --list-principals resources';
|
|
// $cmd_share=apple_bash_variables_set_to_exec().' sudo /Applications/Server.app/Contents/ServerRoot/usr/sbin/calendarserver_manage_principals --list-principals resources';
|
|
@@ -260,13 +260,13 @@ function mac_ical_create_resource_bash($ROW_WITH_L_APP,$table) {
|
|
|
DEBUG_S(-3,'share calendar cmd/out/exit',array($cmd_share,$out,$exit),__FILE__,__FUNCTION__,__LINE__);
|
|
DEBUG_S(-3,'share calendar cmd/out/exit',array($cmd_share,$out,$exit),__FILE__,__FUNCTION__,__LINE__);
|
|
|
mac_ical_parse_exit_if_added($out);
|
|
mac_ical_parse_exit_if_added($out);
|
|
|
$created_resource_UUID=mac_ical_find_resource_id_by_shortname($resource_short_name,$resource_type);
|
|
$created_resource_UUID=mac_ical_find_resource_id_by_shortname($resource_short_name,$resource_type);
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
mac_ical_notify_created_obj_db($created_resource_UUID,$resource_type,$table,$ROW_WITH_L_APP);
|
|
mac_ical_notify_created_obj_db($created_resource_UUID,$resource_type,$table,$ROW_WITH_L_APP);
|
|
|
mac_ical_share_resource_bash($created_resource_UUID,$ROW_WITH_L_APP->A_CLASSIFIED,$ROW_WITH_L_APP->A_ADM_COMPANY,$ROW_WITH_L_APP->L_APPOITMENT_USER);
|
|
mac_ical_share_resource_bash($created_resource_UUID,$ROW_WITH_L_APP->A_CLASSIFIED,$ROW_WITH_L_APP->A_ADM_COMPANY,$ROW_WITH_L_APP->L_APPOITMENT_USER);
|
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@@ -284,7 +284,7 @@ function mac_ical_find_resource_id_by_shortname($shortname,$resource_type) {
|
|
|
}
|
|
}
|
|
|
DEBUG_S(-3,'error finding resource',array($shortname,$resource_type),__FILE__,__FUNCTION__,__FILE__);
|
|
DEBUG_S(-3,'error finding resource',array($shortname,$resource_type),__FILE__,__FUNCTION__,__FILE__);
|
|
|
die();
|
|
die();
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@@ -307,11 +307,11 @@ function mac_ical_share_resource_bash($resource_id,$group_read,$group_write,$own
|
|
|
// [2] => --------- ----------- ----
|
|
// [2] => --------- ----------- ----
|
|
|
// [3] => Arkadiusz Binder a.binder 4720124D-5F20-4EAB-B501-4872E33F9A5C
|
|
// [3] => Arkadiusz Binder a.binder 4720124D-5F20-4EAB-B501-4872E33F9A5C
|
|
|
// [4] => Workgroup workgroup AEE3F607-1F5B-4E3A-A3D2-785BC23DA17D
|
|
// [4] => Workgroup workgroup AEE3F607-1F5B-4E3A-A3D2-785BC23DA17D
|
|
|
- // [5] =>
|
|
|
|
|
|
|
+ // [5] =>
|
|
|
//
|
|
//
|
|
|
foreach($out as $i=>$test) {
|
|
foreach($out as $i=>$test) {
|
|
|
if(($i>=3)&&(!empty($test))) {
|
|
if(($i>=3)&&(!empty($test))) {
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
if(!(in_array($test, array($admin_uid,$owner_uid,$group_write_uid)))) {
|
|
if(!(in_array($test, array($admin_uid,$owner_uid,$group_write_uid)))) {
|
|
|
//! We remove write proxy which is not correct
|
|
//! We remove write proxy which is not correct
|
|
|
$cmd_share=apple_bash_variables_set_to_exec()." sudo /Applications/Server.app/Contents/ServerRoot/usr/sbin/calendarserver_manage_principals --remove-proxy ".$test." ".$resource_id ; $out="";$exit="";
|
|
$cmd_share=apple_bash_variables_set_to_exec()." sudo /Applications/Server.app/Contents/ServerRoot/usr/sbin/calendarserver_manage_principals --remove-proxy ".$test." ".$resource_id ; $out="";$exit="";
|
|
@@ -320,15 +320,15 @@ function mac_ical_share_resource_bash($resource_id,$group_read,$group_write,$own
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// similar code from upper lines
|
|
// similar code from upper lines
|
|
|
$cmd_share=apple_bash_variables_set_to_exec()." sudo /Applications/Server.app/Contents/ServerRoot/usr/sbin/calendarserver_manage_principals --list-read-proxies ".$resource_id." |awk '{ print \$NF }'" ; $out="";$exit="";
|
|
$cmd_share=apple_bash_variables_set_to_exec()." sudo /Applications/Server.app/Contents/ServerRoot/usr/sbin/calendarserver_manage_principals --list-read-proxies ".$resource_id." |awk '{ print \$NF }'" ; $out="";$exit="";
|
|
|
exec($cmd_share, $out,$exit);
|
|
exec($cmd_share, $out,$exit);
|
|
|
DEBUG_S(-3,'look for read proxies to correct (except admin:'.$admin_uid.', owner:'.$owner_uid.', group_read:'.$group_read_uid.', group_write_uid:'.$group_write_uid.')',array($cmd_share,$out,$exit),__FILE__,__FUNCTION__,__LINE__);
|
|
DEBUG_S(-3,'look for read proxies to correct (except admin:'.$admin_uid.', owner:'.$owner_uid.', group_read:'.$group_read_uid.', group_write_uid:'.$group_write_uid.')',array($cmd_share,$out,$exit),__FILE__,__FUNCTION__,__LINE__);
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
foreach($out as $i=>$test) {
|
|
foreach($out as $i=>$test) {
|
|
|
if(($i>=3)&&(!empty($test))) {
|
|
if(($i>=3)&&(!empty($test))) {
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
if(!(in_array($test, array($group_read_uid)))) {
|
|
if(!(in_array($test, array($group_read_uid)))) {
|
|
|
//! We remove read proxy which is not correct
|
|
//! We remove read proxy which is not correct
|
|
|
$cmd_share=apple_bash_variables_set_to_exec()." sudo /Applications/Server.app/Contents/ServerRoot/usr/sbin/calendarserver_manage_principals --remove-proxy ".$test." ".$resource_id ; $out="";$exit="";
|
|
$cmd_share=apple_bash_variables_set_to_exec()." sudo /Applications/Server.app/Contents/ServerRoot/usr/sbin/calendarserver_manage_principals --remove-proxy ".$test." ".$resource_id ; $out="";$exit="";
|
|
@@ -337,8 +337,8 @@ function mac_ical_share_resource_bash($resource_id,$group_read,$group_write,$own
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
//! we make sharing for read / write ... owner
|
|
//! we make sharing for read / write ... owner
|
|
|
if((!empty($group_read))&&($group_read<>$group_write)) {
|
|
if((!empty($group_read))&&($group_read<>$group_write)) {
|
|
|
$cmd_share=apple_bash_variables_set_to_exec()." sudo /Applications/Server.app/Contents/ServerRoot/usr/sbin/calendarserver_manage_principals --add-read-proxy groups:".$group_read." ".$resource_id; $out="";$exit="";
|
|
$cmd_share=apple_bash_variables_set_to_exec()." sudo /Applications/Server.app/Contents/ServerRoot/usr/sbin/calendarserver_manage_principals --add-read-proxy groups:".$group_read." ".$resource_id; $out="";$exit="";
|
|
@@ -356,8 +356,8 @@ function mac_ical_share_resource_bash($resource_id,$group_read,$group_write,$own
|
|
|
DEBUG_S(-3,'share calendar for owner',array($cmd_share,$out,$exit),__FILE__,__FUNCTION__,__LINE__);
|
|
DEBUG_S(-3,'share calendar for owner',array($cmd_share,$out,$exit),__FILE__,__FUNCTION__,__LINE__);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@@ -366,7 +366,7 @@ function get_apple_uid($resource_type,$resource_name) {
|
|
|
// $cmd=apple_bash_variables_set_to_exec()." sudo calendarserver_manage_principals --list-principals ".$resource_type." |awk -F ' ' '{ print \$(NF-1)\" \"\$NF }' |grep ".$resource_name." |awk '{ print \$2 }'";
|
|
// $cmd=apple_bash_variables_set_to_exec()." sudo calendarserver_manage_principals --list-principals ".$resource_type." |awk -F ' ' '{ print \$(NF-1)\" \"\$NF }' |grep ".$resource_name." |awk '{ print \$2 }'";
|
|
|
$cmd='dscl -q /LDAPv3/127.0.0.1 -read /'.$resource_type.'/'.$resource_name.' GeneratedUID';
|
|
$cmd='dscl -q /LDAPv3/127.0.0.1 -read /'.$resource_type.'/'.$resource_name.' GeneratedUID';
|
|
|
$uid=exec($cmd, $out);
|
|
$uid=exec($cmd, $out);
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
if(empty($uid)) {
|
|
if(empty($uid)) {
|
|
|
$cmd='dscl -q /Local/Default/ -read /'.$resource_type.'/'.$resource_name.' GeneratedUID';
|
|
$cmd='dscl -q /Local/Default/ -read /'.$resource_type.'/'.$resource_name.' GeneratedUID';
|
|
|
$uid=exec($cmd, $out);
|
|
$uid=exec($cmd, $out);
|
|
@@ -387,7 +387,7 @@ function mac_ical_parse_test_return_added_obj($ret) {
|
|
|
if(strstr($ret, 'Invalid') || strstr($ret,'Failed')) {
|
|
if(strstr($ret, 'Invalid') || strstr($ret,'Failed')) {
|
|
|
DEBUG_S(-3,'Error adding object',$ret,__FILE__,__FUNCTION__,__LINE__);
|
|
DEBUG_S(-3,'Error adding object',$ret,__FILE__,__FUNCTION__,__LINE__);
|
|
|
die();
|
|
die();
|
|
|
- }
|
|
|
|
|
|
|
+ }
|
|
|
DEBUG_S(-3,'Returnet info from server (OK?) ',$ret,__FILE__,__FUNCTION__,__LINE__);
|
|
DEBUG_S(-3,'Returnet info from server (OK?) ',$ret,__FILE__,__FUNCTION__,__LINE__);
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
@@ -415,8 +415,8 @@ function INIT_TABLE() {
|
|
|
$sql="CREATE TABLE IF NOT EXISTS `_APPLE_ICAL_SE_SYNC_TIMESTAMP` (
|
|
$sql="CREATE TABLE IF NOT EXISTS `_APPLE_ICAL_SE_SYNC_TIMESTAMP` (
|
|
|
`TIMESTAMP` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'data do kiedy byly zsynchronizowane eventy'
|
|
`TIMESTAMP` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'data do kiedy byly zsynchronizowane eventy'
|
|
|
)";
|
|
)";
|
|
|
- DB::query($sql);
|
|
|
|
|
-
|
|
|
|
|
|
|
+ DB::query($sql);
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@@ -434,7 +434,7 @@ DEBUG_S(-3,'options',$options);
|
|
|
$last_sync_ts=0;
|
|
$last_sync_ts=0;
|
|
|
while($h=DB::fetch($res)) {
|
|
while($h=DB::fetch($res)) {
|
|
|
$last_sync_ts=$h->last_sync_ts;
|
|
$last_sync_ts=$h->last_sync_ts;
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// <C:getctag />
|
|
// <C:getctag />
|
|
@@ -468,7 +468,7 @@ PROPP;
|
|
|
*/
|
|
*/
|
|
|
DEBUG_S(-3,'folder_xml',$folder_xml,__FILE__,__FUNCTION__,__LINE__);
|
|
DEBUG_S(-3,'folder_xml',$folder_xml,__FILE__,__FUNCTION__,__LINE__);
|
|
|
return simplexml_load_string($folder_xml);
|
|
return simplexml_load_string($folder_xml);
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@@ -487,7 +487,7 @@ function mac_ical_parse_events_detect_what_to_sync($events_in_server,$uid,$calen
|
|
|
while ($h=DB::fetch($res)) {
|
|
while ($h=DB::fetch($res)) {
|
|
|
$modifed_time=strtotime($getlastmodified);
|
|
$modifed_time=strtotime($getlastmodified);
|
|
|
DEBUG_S(-3,"Znalazlem event zsynchronizowany do weryfikacji czy nie nalezy go zsynchronizowac - etag z serwera ({$getetag}) (getlastmodified={$getlastmodified})rem_modified({$modifed_time}!=loc_mod{$h->modified})",$h,__FILE__,__FUNCTION__,__LINE__);
|
|
DEBUG_S(-3,"Znalazlem event zsynchronizowany do weryfikacji czy nie nalezy go zsynchronizowac - etag z serwera ({$getetag}) (getlastmodified={$getlastmodified})rem_modified({$modifed_time}!=loc_mod{$h->modified})",$h,__FILE__,__FUNCTION__,__LINE__);
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
//print_r($modifed_time);
|
|
//print_r($modifed_time);
|
|
|
$sql_="select unix_timestamp(A_RECORD_UPDATE_DATE) as modified from `{$h->LOCAL_TABLE}` where ID={$h->LOCAL_ID}";
|
|
$sql_="select unix_timestamp(A_RECORD_UPDATE_DATE) as modified from `{$h->LOCAL_TABLE}` where ID={$h->LOCAL_ID}";
|
|
|
$res_=DB::query($sql_);
|
|
$res_=DB::query($sql_);
|
|
@@ -495,7 +495,7 @@ function mac_ical_parse_events_detect_what_to_sync($events_in_server,$uid,$calen
|
|
|
echo "<br>Modifieds: ".$modifed_time." (".$getlastmodified."=".date(strtotime($getlastmodified)).") h ".$h->modified." h_:".$h_->modified;
|
|
echo "<br>Modifieds: ".$modifed_time." (".$getlastmodified."=".date(strtotime($getlastmodified)).") h ".$h->modified." h_:".$h_->modified;
|
|
|
if($h_->modified>$h->modified) $h->modified=$h_->modified;
|
|
if($h_->modified>$h->modified) $h->modified=$h_->modified;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
//@2014-02-11 cos tu jest zjebane z timestampami z kalendarza - jakby zawyzal
|
|
//@2014-02-11 cos tu jest zjebane z timestampami z kalendarza - jakby zawyzal
|
|
|
//if($h->etag<>$getetag) mac_ical_parse_event_to_sync($displayname,$uid,$calendar_type,$modifed_time,$getetag);
|
|
//if($h->etag<>$getetag) mac_ical_parse_event_to_sync($displayname,$uid,$calendar_type,$modifed_time,$getetag);
|
|
|
if($h->modified<>$modifed_time) mac_ical_parse_event_to_sync($displayname,$uid,$calendar_type,$modifed_time,$getetag);
|
|
if($h->modified<>$modifed_time) mac_ical_parse_event_to_sync($displayname,$uid,$calendar_type,$modifed_time,$getetag);
|
|
@@ -503,7 +503,7 @@ function mac_ical_parse_events_detect_what_to_sync($events_in_server,$uid,$calen
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function mac_ical_parse_event_to_sync($event,$uid,$calendar_type,$modifed_time,$getetag){
|
|
function mac_ical_parse_event_to_sync($event,$uid,$calendar_type,$modifed_time,$getetag){
|
|
@@ -521,8 +521,8 @@ function mac_ical_parse_event_to_sync($event,$uid,$calendar_type,$modifed_time,$
|
|
|
if($calendar_type=='tasks') $vevent=$vcalendar->getComponent( "vtodo" );
|
|
if($calendar_type=='tasks') $vevent=$vcalendar->getComponent( "vtodo" );
|
|
|
else if($calendar_type=='calendar') $vevent=$vcalendar->getComponent( "vevent" );
|
|
else if($calendar_type=='calendar') $vevent=$vcalendar->getComponent( "vevent" );
|
|
|
DEBUG_S(-3,"vevent getcomponent",$vevent);
|
|
DEBUG_S(-3,"vevent getcomponent",$vevent);
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
//get event from database
|
|
//get event from database
|
|
|
$sql="select ID,LOCAL_ID, LOCAL_TABLE , unix_timestamp(TIMESTAMP) as TIMESTAMP , RESOURCE_TYPE, etag, L_APPOITMENT_USER , user_uid from CRM_APPLE_ICAL_SYNC_PGSQL where resource_name='{$event}' limit 1 ";
|
|
$sql="select ID,LOCAL_ID, LOCAL_TABLE , unix_timestamp(TIMESTAMP) as TIMESTAMP , RESOURCE_TYPE, etag, L_APPOITMENT_USER , user_uid from CRM_APPLE_ICAL_SYNC_PGSQL where resource_name='{$event}' limit 1 ";
|
|
|
$res_caisp=DB::query($sql);
|
|
$res_caisp=DB::query($sql);
|
|
@@ -545,23 +545,23 @@ function mac_ical_parse_event_to_sync($event,$uid,$calendar_type,$modifed_time,$
|
|
|
$hist_L_APPOITMENT_INFO=mysql_real_escape_string($vevent->description[0][value]);
|
|
$hist_L_APPOITMENT_INFO=mysql_real_escape_string($vevent->description[0][value]);
|
|
|
//todo ? czy to wszystko - moze completed trzeba tez zsynchronizowac w inny sposob?!
|
|
//todo ? czy to wszystko - moze completed trzeba tez zsynchronizowac w inny sposob?!
|
|
|
} else DEBUG_S(-3,'538 do stworzenia sposob synchronizacji z Caldav VEVENT',null,__FILE__,__FUNCTION__,__LINE__);
|
|
} else DEBUG_S(-3,'538 do stworzenia sposob synchronizacji z Caldav VEVENT',null,__FILE__,__FUNCTION__,__LINE__);
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
//todo do historycznych tabel trzba zapisac funkcja PIOTR
|
|
//todo do historycznych tabel trzba zapisac funkcja PIOTR
|
|
|
$sql_local_upd="update `{$local_syn->LOCAL_TABLE}` set `L_APPOITMENT_DATE`='{$new_L_APPOITMENT_DATE}' , `L_APPOITMENT_INFO`='{$new_L_APPOITMENT_INFO}' , A_RECORD_UPDATE_DATE=now() where ID={$local_syn->LOCAL_ID}";
|
|
$sql_local_upd="update `{$local_syn->LOCAL_TABLE}` set `L_APPOITMENT_DATE`='{$new_L_APPOITMENT_DATE}' , `L_APPOITMENT_INFO`='{$new_L_APPOITMENT_INFO}' , A_RECORD_UPDATE_DATE=now() where ID={$local_syn->LOCAL_ID}";
|
|
|
$sql_local_etag="update CRM_APPLE_ICAL_SYNC_PGSQL set `TIMESTAMP`=from_unixtime({$modifed_time}) where ID={$local_syn->ID} ";
|
|
$sql_local_etag="update CRM_APPLE_ICAL_SYNC_PGSQL set `TIMESTAMP`=from_unixtime({$modifed_time}) where ID={$local_syn->ID} ";
|
|
|
|
|
|
|
|
DEBUG_S(-3,'Lokalnie updatuje dane z serwera CalDav :sql_local_upd/new_L_APPOITMENT_DATE/new_L_APPOITMENT_INFO/hist_L_APPOITMENT_INFO',array($sql_local_upd,$sql_local_etag,$new_L_APPOITMENT_DATE,$new_L_APPOITMENT_INFO,$hist_L_APPOITMENT_INFO),__FILE__,__FUNCTION__,__LINE__);
|
|
DEBUG_S(-3,'Lokalnie updatuje dane z serwera CalDav :sql_local_upd/new_L_APPOITMENT_DATE/new_L_APPOITMENT_INFO/hist_L_APPOITMENT_INFO',array($sql_local_upd,$sql_local_etag,$new_L_APPOITMENT_DATE,$new_L_APPOITMENT_INFO,$hist_L_APPOITMENT_INFO),__FILE__,__FUNCTION__,__LINE__);
|
|
|
DB::query($sql_local_upd);
|
|
DB::query($sql_local_upd);
|
|
|
- DB::query($sql_local_etag);
|
|
|
|
|
|
|
+ DB::query($sql_local_etag);
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
function insert_new_event_to_mac_ical($ROW_WITH_L_APP,$table) {
|
|
function insert_new_event_to_mac_ical($ROW_WITH_L_APP,$table) {
|
|
|
DEBUG_S(-3,'f. insert_new_event_to_mac_ical dla tabeli '.$table,$ROW_WITH_L_APP,__FILE__,__FUNCTION__,__LINE__);
|
|
DEBUG_S(-3,'f. insert_new_event_to_mac_ical dla tabeli '.$table,$ROW_WITH_L_APP,__FILE__,__FUNCTION__,__LINE__);
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
$GMT_OFFSET=3600; //jaka roznica czasu do wprowadzania wydarzen w sekundach TODO w konfigu;
|
|
$GMT_OFFSET=3600; //jaka roznica czasu do wprowadzania wydarzen w sekundach TODO w konfigu;
|
|
|
$user_uid=exec('dscl -q /LDAPv3/127.0.0.1 -read /Users/'.$ROW_WITH_L_APP->L_APPOITMENT_USER.' GeneratedUID', $out);
|
|
$user_uid=exec('dscl -q /LDAPv3/127.0.0.1 -read /Users/'.$ROW_WITH_L_APP->L_APPOITMENT_USER.' GeneratedUID', $out);
|
|
|
//$uniqid=uniqid();
|
|
//$uniqid=uniqid();
|
|
@@ -569,14 +569,14 @@ function insert_new_event_to_mac_ical($ROW_WITH_L_APP,$table) {
|
|
|
$user_uid=str_replace('GeneratedUID: ', '', $user_uid);
|
|
$user_uid=str_replace('GeneratedUID: ', '', $user_uid);
|
|
|
echo "tutaj".$user_uid;
|
|
echo "tutaj".$user_uid;
|
|
|
if(!empty($user_uid)) {
|
|
if(!empty($user_uid)) {
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
require_once "stuff/iCalcreator.class.php";
|
|
require_once "stuff/iCalcreator.class.php";
|
|
|
$config = array( "unique_id" => "ical-sqix-sync",
|
|
$config = array( "unique_id" => "ical-sqix-sync",
|
|
|
"TZID" => "Europe/Warsaw"
|
|
"TZID" => "Europe/Warsaw"
|
|
|
);
|
|
);
|
|
|
-// , "TZNAME" => "CEST"
|
|
|
|
|
|
|
+// , "TZNAME" => "CEST"
|
|
|
|
|
|
|
|
$vcalendar = new vcalendar( $config );
|
|
$vcalendar = new vcalendar( $config );
|
|
|
$config = $vcalendar->getConfig();
|
|
$config = $vcalendar->getConfig();
|
|
@@ -587,7 +587,7 @@ iCalUtilityFunctions::createTimezone( $vcalendar, $tz, $xprops );
|
|
|
|
|
|
|
|
|
|
|
|
|
$attachments_mode=0;
|
|
$attachments_mode=0;
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
$organizer="''";
|
|
$organizer="''";
|
|
|
$organizer_object='null';
|
|
$organizer_object='null';
|
|
|
$recurrance_min='null';
|
|
$recurrance_min='null';
|
|
@@ -602,7 +602,7 @@ iCalUtilityFunctions::createTimezone( $vcalendar, $tz, $xprops );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
echo "<br>".$ROW_WITH_L_APP->L_APPOITMENT_DATE." - to <br>";
|
|
echo "<br>".$ROW_WITH_L_APP->L_APPOITMENT_DATE." - to <br>";
|
|
|
$date_parse=str_replace(array('_',':',' '),'-',$ROW_WITH_L_APP->L_APPOITMENT_DATE);
|
|
$date_parse=str_replace(array('_',':',' '),'-',$ROW_WITH_L_APP->L_APPOITMENT_DATE);
|
|
|
$date_parse=explode('-',$ROW_WITH_L_APP->L_APPOITMENT_DATE);
|
|
$date_parse=explode('-',$ROW_WITH_L_APP->L_APPOITMENT_DATE);
|
|
@@ -635,7 +635,7 @@ $start_date="'".date('Y-m-d H:i:s',strtotime($date_YEAR."-".$date_MONTH."-".$dat
|
|
|
$url=mac_ical_create_url_for_edit_obj($ROW_WITH_APP,$table);
|
|
$url=mac_ical_create_url_for_edit_obj($ROW_WITH_APP,$table);
|
|
|
if(!empty($url)) $description.="\n ".$url ;
|
|
if(!empty($url)) $description.="\n ".$url ;
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
//unset($date_HOUR);unset($date_MIN);
|
|
//unset($date_HOUR);unset($date_MIN);
|
|
|
if(!empty($date_HOUR)) {
|
|
if(!empty($date_HOUR)) {
|
|
@@ -678,31 +678,31 @@ $start_date="'".date('Y-m-d H:i:s',strtotime($date_YEAR."-".$date_MONTH."-".$dat
|
|
|
|
|
|
|
|
if(!empty($url)) $vevent->setProperty( "url", $_SERVER['SCRIPT_URI']."/index.php?MENU_INIT=VIEWTABLE_AJAX&ZASOB_ID=".$dt->ID."#EDIT/".$ROW_WITH_L_APP->ID );
|
|
if(!empty($url)) $vevent->setProperty( "url", $_SERVER['SCRIPT_URI']."/index.php?MENU_INIT=VIEWTABLE_AJAX&ZASOB_ID=".$dt->ID."#EDIT/".$ROW_WITH_L_APP->ID );
|
|
|
|
|
|
|
|
- if(empty($date_YEAR)) return ;
|
|
|
|
|
|
|
+ if(empty($date_YEAR)) return ;
|
|
|
//echo "*".$date_MONTH."*";
|
|
//echo "*".$date_MONTH."*";
|
|
|
//var_dump($date_MONTH);
|
|
//var_dump($date_MONTH);
|
|
|
|
|
|
|
|
var_dump($date_MONTH);
|
|
var_dump($date_MONTH);
|
|
|
-
|
|
|
|
|
- $uniqid_ind=$vcalendar->getProperty( 'uid' );
|
|
|
|
|
|
|
+
|
|
|
|
|
+ $uniqid_ind=$vcalendar->getProperty( 'uid' );
|
|
|
$uniqid=key($uniqid_ind);
|
|
$uniqid=key($uniqid_ind);
|
|
|
$vcalendar->parse();
|
|
$vcalendar->parse();
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
DEBUG_S(-3,'uniqid',$uniqid);
|
|
DEBUG_S(-3,'uniqid',$uniqid);
|
|
|
- // var_dump($uniqid);
|
|
|
|
|
|
|
+ // var_dump($uniqid);
|
|
|
$dropbox_id="'".$uniqid.".dropbox'";
|
|
$dropbox_id="'".$uniqid.".dropbox'";
|
|
|
$resource_name="'".$uniqid.".ics'";
|
|
$resource_name="'".$uniqid.".ics'";
|
|
|
- $icalendar_uid="'".$uniqid."'";
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
|
|
+ $icalendar_uid="'".$uniqid."'";
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
// $vevent->setProperty( "LOCATION", "Central Plaza" );
|
|
// $vevent->setProperty( "LOCATION", "Central Plaza" );
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
//$v=4;
|
|
//$v=4;
|
|
|
//var_dump($v);
|
|
//var_dump($v);
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -743,42 +743,42 @@ END:VCALENDAR";
|
|
|
Plan taki do synchronizacji kalendarzy
|
|
Plan taki do synchronizacji kalendarzy
|
|
|
|
|
|
|
|
|
|
|
|
|
- [ baza translate ]
|
|
|
|
|
|
|
+ [ baza translate ]
|
|
|
[ LOCAL_ID ]
|
|
[ LOCAL_ID ]
|
|
|
- [ LOCAL_TABLE ]
|
|
|
|
|
- [ TIMESTAMP ]
|
|
|
|
|
- [ REMOTE_ID ]
|
|
|
|
|
- [ REMOTE_TABLE ]
|
|
|
|
|
|
|
+ [ LOCAL_TABLE ]
|
|
|
|
|
+ [ TIMESTAMP ]
|
|
|
|
|
+ [ REMOTE_ID ]
|
|
|
|
|
+ [ REMOTE_TABLE ]
|
|
|
|
|
|
|
|
|
|
|
|
|
-1) lokalnie ( dodaje nowe wydarzenie USERS2_MARKETING (
|
|
|
|
|
- id,
|
|
|
|
|
- data+czas,
|
|
|
|
|
|
|
+1) lokalnie ( dodaje nowe wydarzenie USERS2_MARKETING (
|
|
|
|
|
+ id,
|
|
|
|
|
+ data+czas,
|
|
|
L_APP_INFO ,
|
|
L_APP_INFO ,
|
|
|
L_APP_USER)
|
|
L_APP_USER)
|
|
|
|
|
|
|
|
2) foreach table, ktore maja cos w L_APP_DATE szukam w translate
|
|
2) foreach table, ktore maja cos w L_APP_DATE szukam w translate
|
|
|
- a) jak pusto, to
|
|
|
|
|
- - dodaje do ICALÄËĂÂĂÂa ( REMOTE_TABLE, REMOTE_ID )
|
|
|
|
|
|
|
+ a) jak pusto, to
|
|
|
|
|
+ - dodaje do ICALÄËĂÂĂÂa ( REMOTE_TABLE, REMOTE_ID )
|
|
|
- dodaje do [TRANSLATE] [REMOTE_ID,REMOTE_TABLE,LOCAL_ID,LOCAL_TABLE,TIMESTAMP]
|
|
- dodaje do [TRANSLATE] [REMOTE_ID,REMOTE_TABLE,LOCAL_ID,LOCAL_TABLE,TIMESTAMP]
|
|
|
|
|
|
|
|
- c) trzeba wykryc resource_id -> calendar_home_resource_id w calendar_home ( po owner_uid )
|
|
|
|
|
|
|
+ c) trzeba wykryc resource_id -> calendar_home_resource_id w calendar_home ( po owner_uid )
|
|
|
b) trzeba wykryc calendar_home_resource_id w calendar_bind
|
|
b) trzeba wykryc calendar_home_resource_id w calendar_bind
|
|
|
- c) trzeba wykryc w calendar_bind calendar_resource_id (zawsze calendar),
|
|
|
|
|
|
|
+ c) trzeba wykryc w calendar_bind calendar_resource_id (zawsze calendar),
|
|
|
(itd...)
|
|
(itd...)
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
4) synchronizacja od strony lokalnej - jezeli rekord LOCAL i A_UPD_DAT jest > CRM_APPLE_ICAL_SYNC_PGSQL.Timestamp, to jedziemy
|
|
4) synchronizacja od strony lokalnej - jezeli rekord LOCAL i A_UPD_DAT jest > CRM_APPLE_ICAL_SYNC_PGSQL.Timestamp, to jedziemy
|
|
|
a) zaktualizuj rekord w caldavie
|
|
a) zaktualizuj rekord w caldavie
|
|
|
aa)- zmiana terminow -> edytuj
|
|
aa)- zmiana terminow -> edytuj
|
|
|
bb)- zmiana wlasciciela -> kopiuj nowy obiekt, stary zaznacz skasowano
|
|
bb)- zmiana wlasciciela -> kopiuj nowy obiekt, stary zaznacz skasowano
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
5) synchronizacja od strony caldav'a
|
|
5) synchronizacja od strony caldav'a
|
|
|
a) - przesun spotkanie
|
|
a) - przesun spotkanie
|
|
|
- b) - skasuj spotkanie - wyrzuc siebie z osoby odpowiedzialnej
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
|
|
+ b) - skasuj spotkanie - wyrzuc siebie z osoby odpowiedzialnej
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -814,31 +814,31 @@ mac_ical_parse_test_return_added_obj($ret);
|
|
|
/*
|
|
/*
|
|
|
|
|
|
|
|
$dbconn = pg_connect("host='/Library/Server/PostgreSQL For Server Services/Socket' port=5432 user=caldav dbname=caldav");
|
|
$dbconn = pg_connect("host='/Library/Server/PostgreSQL For Server Services/Socket' port=5432 user=caldav dbname=caldav");
|
|
|
- $sql_insert_pgsql="insert into calendar_object ( resource_id , calendar_resource_id , resource_name , icalendar_text, icalendar_uid ,
|
|
|
|
|
|
|
+ $sql_insert_pgsql="insert into calendar_object ( resource_id , calendar_resource_id , resource_name , icalendar_text, icalendar_uid ,
|
|
|
icalendar_type , attachments_mode, dropbox_id, organizer, organizer_object, recurrance_min, recurrance_max, access, schedule_object,
|
|
icalendar_type , attachments_mode, dropbox_id, organizer, organizer_object, recurrance_min, recurrance_max, access, schedule_object,
|
|
|
- schedule_tag , schedule_etags , private_comments , md5, created, modified )
|
|
|
|
|
-
|
|
|
|
|
- select
|
|
|
|
|
|
|
+ schedule_tag , schedule_etags , private_comments , md5, created, modified )
|
|
|
|
|
+
|
|
|
|
|
+ select
|
|
|
(
|
|
(
|
|
|
select max(resource_id) as max from calendar_object
|
|
select max(resource_id) as max from calendar_object
|
|
|
union select max(resource_id) as max from calendar_metadata
|
|
union select max(resource_id) as max from calendar_metadata
|
|
|
order by max desc
|
|
order by max desc
|
|
|
limit 1
|
|
limit 1
|
|
|
)+1 as resource_id
|
|
)+1 as resource_id
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
, t2.calendar_resource_id , ".$resource_name." , ".$icalendar_text." , ".$icalendar_uid."
|
|
, t2.calendar_resource_id , ".$resource_name." , ".$icalendar_text." , ".$icalendar_uid."
|
|
|
- , ".$icalendar_type." , ".$attachments_mode." , ".$dropbox_id." , ".$organizer." , ".$organizer_object."
|
|
|
|
|
- , ".$recurrance_min." , ".$recurrance_max." , ".$access." , ".$schedule_object."
|
|
|
|
|
|
|
+ , ".$icalendar_type." , ".$attachments_mode." , ".$dropbox_id." , ".$organizer." , ".$organizer_object."
|
|
|
|
|
+ , ".$recurrance_min." , ".$recurrance_max." , ".$access." , ".$schedule_object."
|
|
|
, ".$schedule_tag." , ".$schedule_etags." , ".$private_comments." , ".$md5." , ".$created." , ".$modified."
|
|
, ".$schedule_tag." , ".$schedule_etags." , ".$private_comments." , ".$md5." , ".$created." , ".$modified."
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
from calendar_home as t1
|
|
from calendar_home as t1
|
|
|
- join calendar_bind as t2 on ( t1.resource_id=t2.calendar_home_resource_id and t2.calendar_resource_name=".$calendar_resource_name." )
|
|
|
|
|
- where
|
|
|
|
|
|
|
+ join calendar_bind as t2 on ( t1.resource_id=t2.calendar_home_resource_id and t2.calendar_resource_name=".$calendar_resource_name." )
|
|
|
|
|
+ where
|
|
|
t1.owner_uid='".$user_uid."'
|
|
t1.owner_uid='".$user_uid."'
|
|
|
;
|
|
;
|
|
|
SELECT resource_id from calendar_object where resource_name=".$resource_name." LIMIT 1;
|
|
SELECT resource_id from calendar_object where resource_name=".$resource_name." LIMIT 1;
|
|
|
";
|
|
";
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
echo "<br>".$sql_insert_pgsql;
|
|
echo "<br>".$sql_insert_pgsql;
|
|
|
$qry=pg_query($dbconn,$sql_insert_pgsql);
|
|
$qry=pg_query($dbconn,$sql_insert_pgsql);
|
|
|
|
|
|
|
@@ -846,52 +846,47 @@ mac_ical_parse_test_return_added_obj($ret);
|
|
|
echo "<br>\n Inserted id resource id:";
|
|
echo "<br>\n Inserted id resource id:";
|
|
|
print_r($fch);
|
|
print_r($fch);
|
|
|
|
|
|
|
|
- $sql_insert_pgsql="insert into calendar_object_revisions
|
|
|
|
|
|
|
+ $sql_insert_pgsql="insert into calendar_object_revisions
|
|
|
( calendar_home_resource_id, calendar_resource_id, calendar_name, resource_name, revision, deleted )
|
|
( calendar_home_resource_id, calendar_resource_id, calendar_name, resource_name, revision, deleted )
|
|
|
-
|
|
|
|
|
- select
|
|
|
|
|
- t2.calendar_home_resource_id , t2.calendar_resource_id
|
|
|
|
|
- , NULL
|
|
|
|
|
- , ".$resource_name."
|
|
|
|
|
|
|
+
|
|
|
|
|
+ select
|
|
|
|
|
+ t2.calendar_home_resource_id , t2.calendar_resource_id
|
|
|
|
|
+ , NULL
|
|
|
|
|
+ , ".$resource_name."
|
|
|
, ( select max(revision) as max from calendar_object_revisions )+1 as revision
|
|
, ( select max(revision) as max from calendar_object_revisions )+1 as revision
|
|
|
, FALSE
|
|
, FALSE
|
|
|
- from calendar_home as t1
|
|
|
|
|
- join calendar_bind as t2 on ( t1.resource_id=t2.calendar_home_resource_id and t2.calendar_resource_name=".$calendar_resource_name." )
|
|
|
|
|
- where
|
|
|
|
|
|
|
+ from calendar_home as t1
|
|
|
|
|
+ join calendar_bind as t2 on ( t1.resource_id=t2.calendar_home_resource_id and t2.calendar_resource_name=".$calendar_resource_name." )
|
|
|
|
|
+ where
|
|
|
t1.owner_uid='".$user_uid."' ";
|
|
t1.owner_uid='".$user_uid."' ";
|
|
|
echo "<br>".$sql_insert_pgsql;
|
|
echo "<br>".$sql_insert_pgsql;
|
|
|
pg_query($dbconn,$sql_insert_pgsql);
|
|
pg_query($dbconn,$sql_insert_pgsql);
|
|
|
|
|
|
|
|
- $sql_insert_pgsql="insert into time_range ( calendar_resource_id , calendar_object_resource_id, floating , start_date, end_date , fbtype , transparent )
|
|
|
|
|
|
|
+ $sql_insert_pgsql="insert into time_range ( calendar_resource_id , calendar_object_resource_id, floating , start_date, end_date , fbtype , transparent )
|
|
|
select t2.calendar_resource_id , ".$fch[0]." , FALSE , ".$start_date.",".$end_date." , ".$fbtype." , FALSE
|
|
select t2.calendar_resource_id , ".$fch[0]." , FALSE , ".$start_date.",".$end_date." , ".$fbtype." , FALSE
|
|
|
from calendar_home as t1
|
|
from calendar_home as t1
|
|
|
- join calendar_bind as t2 on ( t1.resource_id=t2.calendar_home_resource_id and t2.calendar_resource_name=".$calendar_resource_name." )
|
|
|
|
|
- where
|
|
|
|
|
|
|
+ join calendar_bind as t2 on ( t1.resource_id=t2.calendar_home_resource_id and t2.calendar_resource_name=".$calendar_resource_name." )
|
|
|
|
|
+ where
|
|
|
t1.owner_uid='".$user_uid."' ";
|
|
t1.owner_uid='".$user_uid."' ";
|
|
|
echo "<br>".$sql_insert_pgsql;
|
|
echo "<br>".$sql_insert_pgsql;
|
|
|
pg_query($dbconn,$sql_insert_pgsql);
|
|
pg_query($dbconn,$sql_insert_pgsql);
|
|
|
//aktualizacja info, ze cos zostalo dodane itp
|
|
//aktualizacja info, ze cos zostalo dodane itp
|
|
|
$sql_insert_pgsql="update calendar_metadata set modified=LOCALTIMESTAMP where
|
|
$sql_insert_pgsql="update calendar_metadata set modified=LOCALTIMESTAMP where
|
|
|
- resource_id=(select t2.calendar_resource_id from calendar_home as t1
|
|
|
|
|
- join calendar_bind as t2 on ( t1.resource_id=t2.calendar_home_resource_id and t2.calendar_resource_name=".$calendar_resource_name." )
|
|
|
|
|
|
|
+ resource_id=(select t2.calendar_resource_id from calendar_home as t1
|
|
|
|
|
+ join calendar_bind as t2 on ( t1.resource_id=t2.calendar_home_resource_id and t2.calendar_resource_name=".$calendar_resource_name." )
|
|
|
where t1.owner_uid='".$user_uid."' ) , supported_components=".$icalendar_type." ";
|
|
where t1.owner_uid='".$user_uid."' ) , supported_components=".$icalendar_type." ";
|
|
|
|
|
|
|
|
echo "<br>".$sql_insert_pgsql;
|
|
echo "<br>".$sql_insert_pgsql;
|
|
|
pg_query($dbconn,$sql_insert_pgsql);
|
|
pg_query($dbconn,$sql_insert_pgsql);
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
*/
|
|
*/
|
|
|
|
|
|
|
|
//teraz confirm , ze jest zaimportowane
|
|
//teraz confirm , ze jest zaimportowane
|
|
|
mac_ical_notify_added_event_to_db($ROW_WITH_L_APP,$table,$resource_name,$icalendar_type,md5($v),$user_uid);
|
|
mac_ical_notify_added_event_to_db($ROW_WITH_L_APP,$table,$resource_name,$icalendar_type,md5($v),$user_uid);
|
|
|
//pg_last_oid($res2);
|
|
//pg_last_oid($res2);
|
|
|
-
|
|
|
|
|
- } //not empty
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
|
|
|
|
|
|
|
+ } //not empty
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+}
|