function GoogleCallsUsers(&$bean, $event, $arguments) { global $sugar_config, $dbconfig, $beanList, $beanFiles, $app_strings, $app_list_strings, $current_user, $db; if (isset($_REQUEST['entryPoint'])) { if ($_REQUEST['entryPoint'] == "acceptDecline") { if ($_REQUEST['user_id'] != "") { if ($_REQUEST['accept_status'] == "accept" or $_REQUEST['accept_status'] == "tentative") { //decline if (!isset($_REQUEST['allready_retrieved_user_acceptDecline'])) { $_REQUEST['allready_retrieved_user_acceptDecline'] = true; if (!file_exists("google_calendar_tc.php")) { $sq = "CREATE TABLE `google_calendar_rel` (\n `id` VARCHAR(36),\n `obj_id` VARCHAR(36),\n `obj_type` VARCHAR(36),\n `user_id` VARCHAR(36),\n `old_id_c` VARCHAR(255),\n `old_link_edit_c` VARCHAR(255),\n `deleted` INTEGER UNSIGNED DEFAULT 0,\n PRIMARY KEY (`id`)\n)\nENGINE = MyISAM;"; $db->query($sq); $f = fopen("google_calendar_tc.php", "w+"); fclose($f); } $sq = "select * from google_calendar_rel where obj_id='" . $_REQUEST['record'] . "' and obj_type='" . $_REQUEST['module'] . "' and user_id='" . $bean->id . "' and deleted=0"; $res = $db->query($sq); $row_oldsaved = $db->fetchByAssoc($res); $current_user = $bean; require_once "custom/include/Calls/google_calendar_plg.php"; # $us=new User(); # $us->retrieve($_REQUEST['user_id']); # print_R($bean); #exit; $bean = $beanList[clean_string($_REQUEST['module'])]; require_once $beanFiles[$bean]; $focus = new $bean(); $focus->disable_row_level_security = true; $result = $focus->retrieve($_REQUEST['record']); if ($row_oldsaved['old_id_c'] == "") { $result->old_id_c = ""; } else { $result->old_id_c = $row_oldsaved['old_id_c']; $result->old_link_edit_c = $row_oldsaved['old_link_edit_c']; } if ($_REQUEST['accept_status'] == "tentative") { $result->name = $result->name . " (tentative)"; } $su = new GoogleCalls($result, "", ""); # print_r($row_oldsaved); #echo "\n<br>old record link ".$row_oldsaved['old_id_c']." a<br>\n"; if (!empty($row_oldsaved['old_id_c'])) { $sq = "update google_calendar_rel set old_id_c='" . $result->old_id_c . "',old_link_edit_c='" . $result->old_link_edit_c . "' where id='" . $row_oldsaved['id'] . "' and deleted=0"; # echo $sq; # exit; } else { $gid = create_guid(); $sq = "insert into google_calendar_rel values ('{$gid}','{$result->id}','" . $_REQUEST['module'] . "','" . $_REQUEST['user_id'] . "','{$result->old_id_c}','{$result->old_link_edit_c}',0)"; # echo $sq; # exit; } $db->query($sq); # echo "\n <br>aaaaaaaaaaaaaaaaaaaaaa".$result->old_id_c; # echo "<br>\n".print_r($bean->id)."\n"; } } else { if (!isset($_REQUEST['allready_retrieved_user_acceptDecline'])) { $_REQUEST['allready_retrieved_user_acceptDecline'] = true; require_once "custom/include/Calls/google_calendar_plg.php"; $bean = $beanList[clean_string($_REQUEST['module'])]; require_once $beanFiles[$bean]; $focus = new $bean(); $focus->disable_row_level_security = true; $result = $focus->retrieve($_REQUEST['record']); $sq = "select * from google_calendar_rel where obj_id='" . $_REQUEST['record'] . "' and obj_type='" . $_REQUEST['module'] . "' and user_id='" . $_REQUEST['user_id'] . "' and deleted=0"; $res = $db->query($sq); $row_oldsaved = $db->fetchByAssoc($res); if ($row_oldsaved['old_link_edit_c'] != "") { # $user_data=get_user_email_pass1($_REQUEST['user_id']); $user = new User(); # echo "a"; #exit; $user->retrieve($_REQUEST['user_id']); $current_user = $user; $user_data = array($user->google_mmail_c, $user->google_mpass_c); $assigned_link = ""; if ($user->google_mmail_c != "" and $user->google_mpass_c != "") { # echo "<br>".$user_data[0]; $_REQUEST['delete_invite_user_id'] = $row_oldsaved['user_id']; $_REQUEST['delete_invite_url'] = $row_oldsaved['old_link_edit_c']; $gc = new GoogleCalendarWrapper($user_data[0], $user_data[1], "", $assigned_link); $gc->delete_event($s, $_REQUEST['record'], $result->table_name, $user_data, $focus, $add_notifications); $sq = "delete from google_calendar_rel where id='" . $row_oldsaved['id'] . "'"; $db->query($sq); } } } } } } } }
function sync_events($one_user = false, $sel_user = "") { global $beanList, $beanFiles, $path; $use_offset_time = true; $td = new TimeDate(); $arr_modules[] = "Meetings"; $arr_modules[] = "Calls"; $arr_modules[] = "Tasks"; global $timedate; global $beanList, $beanFiles, $path, $current_user; for ($tn = 0; $tn < count($arr_modules); $tn++) { ob_start(); $module_name = $arr_modules[$tn]; $class_name = $beanList[$module_name]; require_once $beanFiles[$class_name]; $seed = new $class_name(); $tbn = $seed->table_name; $tablename = $tbn; $cstmtbname2 = $tablename . "_cstm"; if ($one_user == true) { if ($_SESSION['authenticated_user_id'] == "" and 1 == 2) { } else { if ($sel_user != "") { $cu = $sel_user; } else { $cu = $_SESSION['authenticated_user_id']; } $tdus = new TimeDate(); $cus = new User(); $cus->retrieve($cu); ############## global $current_user; $current_user = $cus; ############## $calendar_priv_add = $cus->google_mcalendar_c; $crdatefilt = $cus->google_mafterdate_c; $crdatefilt = $tdus->swap_formats($crdatefilt, $td->get_date_format(true, $cus), "Y-m-d"); unset($cus); $sql_user = "******"; if ($crdatefilt != '') { $sql_user .= " and {$tbn}.date_entered>='{$crdatefilt}' "; } $query = $sql_user; } } $d1d = array(); $s = array(); $ch = array(); $fd = array(); $forexp = ""; $fort1d = ""; $t1d = ""; $nt = ""; $nt1 = ""; $cm = date("m"); $cy = date("Y"); unset($response); global $max_events_upload_google; $response = $seed->get_list($order_by, $query, $offset, 10000, $max_events_upload_google, false); if ($tablename == "calls") { } $newdoc = $response['list'][$tn1]; if (1 == 1) { $tablename = $tbn; echo "<br>****** Get events from {$tablename}"; require_once 'modules/Calendar/DateTimeUtil.php'; $cm = date("m"); $cy = date("Y"); for ($tn1 = 0; $tn1 < count($response['list']); $tn1++) { unset($a); unset($a1); unset($a2); unset($s); unset($current_user); unset($user); unset($td); $a1 = $response['list'][$tn1]; $current_user = new User(); $current_user->retrieve($a1->assigned_user_id); debugg("<br> current user for event " . $a1->assigned_user_id . " " . $current_user->name); $user = $current_user; $td = new TimeDate(); $user_google_mafterdate_c = $td->swap_formats($current_user->google_mafterdate_c, $td->get_date_format(true, $current_user), "Y-m-d"); $add_notifications = $current_user->google_mnotifications_c; unset($a2); if ($tablename == 'meetings') { $a2 = new Meeting(); } if ($tablename == 'calls') { $a2 = new Call(); } if ($tablename == 'tasks') { $a2 = new Task(); } unset($a); $a = $a2->retrieve($a1->id); if ($a->old_id_c == "" or 1 == 1) { global $calls_prefix; global $meetings_prefix; global $tasks_prefix; $s = array(); $s["title"] = $a->name; if ($tablename == 'meetings') { $s["title"] = $meetings_prefix . $s["title"]; } if ($tablename == 'calls') { $s["title"] = $calls_prefix . $s["title"]; } if ($tablename == 'tasks') { $s["title"] = $tasks_prefix . $s["title"]; } debugg("<br><br><br>**********Event ******* id={$a->id} ***** name={$a->name}" . " number " . $tn1 . " date " . $a->date_start); if ($a->name == "gmt+1 start 23:30 end 00:15" or $a->name == "gmt+3 + dst start 23:30 end 00:15") { } $sq = "select * from {$tablename} where id='" . $a2->id . "' and deleted='0'"; $result = $a2->db->query($sq); while ($row = $a2->db->fetchByAssoc($result)) { $ro = $row; } $start = $ro['date_start']; $end = $ro['date_due']; #260608 $start_offset = $td->handle_offset($start, "Y-m-d H:i:s", true,$current_user); #260608 $end_offset = $td->handle_offset($end, "Y-m-d H:i:s", true,$current_user); $start_offset = $start; $end_offset = $end; if ($tablename == 'tasks') { $a->date_start = $start; $a->date_due = $end; } $s["content"] = $a->description; $s["where"] = $a->location; $s["startDay"] = $start_offset; $s["startTime"] = $a->time_start; $s["endDay"] = $end_offset; $s["reminder_time"] = $a->reminder_time / 60; if ($s["reminder_time"] == '' or $s["reminder_time"] == 0) { $s["reminder_time"] = 10; } if ($tablename == 'tasks') { $s["startTime"] = ""; $a->time_start = ""; } if ($a->date_start == '' and $a->date_due != "") { $a->date_start = $end_offset; #### for tsaks if no start date } else { $a->date_start = $start_offset; } $date_start_in_db_fmt = $start_offset; $date_start_array = split(" ", trim($date_start_in_db_fmt)); $date_due_in_db_fmt = $end_offset; $arr_ds = explode(" ", $start_offset); $arr_de = explode(" ", $end_offset); debugg("<br>current user " . $current_user->name); $a->time_start = $arr_ds[1]; $a->time_due = $arr_de[1]; $s["startDay"] = $arr_ds[0]; $s["startTime"] = $a->time_start; $s["endDay"] = $arr_de[0]; $s["endTime"] = $arr_de[1]; if ($tablename == "tasks" and $s["startDay"] == "" and $s["endDay"] !== "") { $s["startDay"] = $s["endDay"]; $s["startTime"] = $s["endTime"]; $a->time_start = $s["endTime"]; } debugg("<br>dst00 " . $date_start_in_db_fmt . " a time start " . $a->time_start); $fd = explode("/", $s["startDay"]); if ($fd[2] == "") { $fd = explode("-", $s["startDay"]); } $plugin_date_start = $fd[2] . "/" . $fd[1] . "/" . $fd[0] . " " . $s["startTime"]; if ($tablename != 'tasks') { $plugin_date_due = $plugin_date_start; } else { $fd = explode("/", $s["endDay"]); if ($fd[2] == "") { $fd = explode("-", $s["endDay"]); } if ($fd[2] != "") { $plugin_date_due = $fd[2] . "/" . $fd[1] . "/" . $fd[0] . " " . $s["dueTime"]; } else { $plugin_date_due = $plugin_date_start; } } $plugin_format = "d/m/Y H:i"; ###################################### $d1 = explode("/", $plugin_date_start); global $current_user; $d1[2] = explode(" ", $d1[2]); $d1[2] = $d1[2][0]; $fort1 = explode(" ", $plugin_date_start); $fort1 = $fort1[1]; $t1 = explode(":", $fort1); $t1[1] = round($t1[1]); $untill = mktime($t1[0] + $a->duration_hours, $t1[1] + $a->duration_minutes, $t1[2], $d1[1], $d1[0], $d1[2]); if ($tablename == 'tasks') { if ($plugin_date_due == "" or $a->date_due == "") { $forexp = $plugin_date_start; } else { $forexp = $plugin_date_due; } } else { $forexp = $plugin_date_start; } $d1d = explode("/", $forexp); if ($d1d[2] == "") { $d1d = explode("-", $forexp); } $d1d[2] = explode(" ", $d1d[2]); $d1d[2] = $d1d[2][0]; $fort1d = explode(" ", $forexp); $fort1d = $fort1d[1]; $t1d = explode(":", $fort1d); $untill = mktime($t1d[0] + $a->duration_hours, $t1d[1] + $a->duration_minutes, $t1d[2], $d1d[1], $d1d[0], $d1d[2]); if ($tablename == 'tasks' and $a->date_due != "") { $nt = explode(" ", $a->date_due); $nt1 = explode(":", $nt[1]); if ($nt[1] == "") { $nt1 = explode(".", $nt[1]); } print_r($nt); $untill = mktime($nt1[0], $nt1[1], 0, $d1d[1], $d1d[0], $d1d[2]); } $date_due = date("Y-m-d", $untill); $time_due = date("H:i:s", $untill); $s["endTime"] = $time_due; $s["endDay"] = $date_due; if ($a->date_start == '') { $s["startTime"] = $s["endTime"]; $s["startDay"] = $s["endDay"]; } if ($a->assigned_user_id == '') { $user = $a->created_by; } else { $user = $a->assigned_user_id; } $user_data = get_user_email_pass1($user); if ($user_data[0] != '' and $user_data[1] != '') { debugg("<br>**Got user " . $user_data[0]); $gc = new GoogleCalendarWrapper($user_data[0], $user_data[1], $current_user->google_mcalendar_c); $_SESSION["called_from_sync"] = true; $settings["reminder_checked"] = $a->reminder_checked; if ($sel_user != "" and $calendar_priv_add != "" and $calendar_priv_add != "1") { $gc->feed_url = $calendar_priv_add; } if ($s["startDay"] >= $user_google_mafterdate_c) { $gc->add_event($s, $a->id, $tablename, $user_data, $add_notifications); } else { } $_SESSION["called_from_sync"] = false; } } } } } }
function GoogleCalls(&$bean, $event, $arguments) { $okev = true; $_SESSION["mass_upd_assigned"] = false; if (isset($_REQUEST["massupdate"])) { if ($_REQUEST["massupdate"] == true) { $okev = false; if ($_REQUEST['assigned_user_id'] != "" or $_REQUEST['date_start'] != "") { $okev = true; } if ($_REQUEST['assigned_user_id'] != "") { $_SESSION["mass_upd_assigned"] = true; } } } if ($okev == true) { if ($_SESSION["called_from_sync"] == false or $_SESSION["called_from_sync"] == "") { ### skip if called from sync.php logic hook global $timedate; $offset_val = ".000+02:00"; $td = new TimeDate(); $tablename = $bean->table_name; $a = $response['list'][$tn1]; $s = array(); # echo "<br>**********Event ******* id=$a[id] ***** name=$a[name]"; $s["title"] = $bean->name; if ($tablename == 'meetings') { $s["title"] = "Meeting: " . $s["title"]; } if ($tablename == 'calls') { $s["title"] = "Call: " . $s["title"]; } if ($tablename == 'tasks') { $s["title"] = "Task: " . $s["title"]; } $s["content"] = $bean->description; $s["where"] = $bean->location; $s["startDay"] = $bean->date_start; $s["startTime"] = $bean->time_start; $s["endDay"] = $bean->date_end; $s["reminder_time"] = $bean->reminder_time / 60; if ($s["reminder_time"] == '' or $s["reminder_time"] == 0) { $s["reminder_time"] = 10; } if ($bean->date_start == '' and $bean->date_due != "") { $s["startDay"] = $bean->date_due; #### for tasks if no start date } else { $s["startDay"] = $bean->date_start; } # print_r($s); global $current_user; $pd = $s["startDay"]; ####260608 #$pd= $td->handle_offset($td->get_date_time_format(true, $current_user), $td->get_date_time_format(true, $current_user), false,$current_user); $date_start_in_db_fmt = $td->swap_formats($s["startDay"], $td->get_date_time_format(true, $current_user), $td->get_db_date_time_format()); $date_end_in_db_fmt1 = $td->swap_formats($bean->date_due, $td->get_date_time_format(true, $current_user), $td->get_db_date_time_format()); $date_start_array = split(" ", trim($date_start_in_db_fmt)); $date_time_start = DateTimeUtil::get_time_start($date_start_array[0], $date_start_array[1]); $tt1 = $td->to_display_date_time($bean->date_start, true, true, false); $user = $current_user; $s["startTime"] = $td->handle_offset($date_start_in_db_fmt, "H:i:s", false, $current_user); $date_end_in_db_fmt1 = $td->handle_offset($date_end_in_db_fmt1, "Y-m-d H:i:s", false, $current_user); ###### problem with offset ... if record is at 23.15 gmt +2 .. date problem $ch = explode(" ", $s["startDay"]); if ($ch['1'] == "00:00" or $ch['1'] == "00.00") { #### 120608 bogdan if task and 12:00 goes to next day $s["startDay"] = $td->handle_offset($date_start_in_db_fmt, "Y-m-d", false,$current_user); $s["startDay"] = $td->handle_offset($date_start_in_db_fmt, "Y-m-d", false, $current_user); $s["startDay1"] = $td->handle_offset($date_start_in_db_fmt, "Y-m-d H:i:s", false, $current_user); } else { $s["startDay"] = $td->handle_offset($date_start_in_db_fmt, "Y-m-d", false, $current_user); $s["startDay1"] = $td->handle_offset($date_start_in_db_fmt, "Y-m-d H:i:s", false, $current_user); } $plugin_format = "d/m/Y H:i"; if ($td->get_date_time_format(true, $current_user) != $plugin_format) { ##260608 $plugin_date_start=$td->swap_formats($pd, $td->get_date_time_format(true, $current_user), $plugin_format); $plugin_date_due = $td->swap_formats($bean->date_due, $td->get_date_time_format(true, $current_user), $plugin_format); } else { ##260608 $plugin_date_start=$pd; $plugin_date_due = $bean->date_due; } $plugin_date_start = $td->swap_formats($s["startDay1"], "Y-m-d H:i:s", $plugin_format); $plugin_date_due1 = $td->swap_formats($date_end_in_db_fmt1, "Y-m-d H:i:s", $plugin_format); ################################################# $d1 = explode("/", $plugin_date_start); global $current_user; $d1[2] = explode(" ", $d1[2]); $d1[2] = $d1[2][0]; if ($bean->time_start != '' and 1 == 2) { $t1 = explode(":", $bean->time_start); } else { $fort1 = explode(" ", $plugin_date_start); $fort1 = $fort1[1]; $t1 = explode(":", $fort1); } $t1[1] = round($t1[1]); $untill = mktime($t1[0] + $bean->duration_hours, $t1[1] + $bean->duration_minutes, $t1[2], $d1[1], $d1[0], $d1[2]); if ($tablename == 'tasks') { if ($plugin_date_due == "" or $bean->date_due == "") { $forexp = $plugin_date_start; } else { $forexp = $plugin_date_due; $forexp = $plugin_date_due1; } $d1d = explode("/", $forexp); $d1d[2] = explode(" ", $d1d[2]); $d1d[2] = $d1d[2][0]; $fort1d = explode(" ", $forexp); $fort1d = $fort1d[1]; $t1d = explode(":", $fort1d); $untill = mktime($t1d[0], $t1d[1], $t1d[2], $d1d[1], $d1d[0], $d1d[2]); } $date_due = date("Y-m-d", $untill); $time_due = date("H:i:s", $untill); $s["endTime"] = $time_due; $s["endDay"] = $date_due; if ($bean->assigned_user_id == '') { $userid = $bean->created_by; } else { $userid = $bean->assigned_user_id; } ////////// dmc290609 if (isset($_REQUEST['allready_retrieved_user_acceptDecline'])) { $userid = $current_user->id; } ////////// dmc290609 $user = new User(); $user->retrieve($userid); $user_data = get_user_email_pass1($user->id); if ($user_data[0] != '' and $user_data[1] != '') { } else { } if ($user_data[0] != '' and $user_data[1] != '') { $assigned_link = $user->google_mcalendar_c; if ($assigned_link == "" or $assigned_link == "1") { $assigned_link = "nolinkfromhook"; $assigned_link = "http://www.google.com/calendar/feeds/default/private/full"; } $gc = new GoogleCalendarWrapper($user_data[0], $user_data[1], "", $assigned_link); global $current_user; $doevent = false; if ($tablename == "calls" and $user->google_mcalls_c == "on") { $doevent = true; if ($user->google_mplannedcalls_c == "on" and $bean->status != "Planned") { $doevent = false; } } if ($tablename == "meetings" and $user->google_mmeetings_c == "on") { $doevent = true; } if ($tablename == "tasks" and $user->google_mtasks_c == "on") { $doevent = true; } if ($doevent == true) { $add_notifications = $user->google_mnotifications_c; $gc->add_event_onl($s, $bean->id, $tablename, $user_data, $bean, $add_notifications); } $_SESSION["mass_upd_assigned"] = false; } } } }
function GoogleCalls(&$bean, $event, $arguments) { echo "<br>aa " . $bean->id; echo "<br>aa " . $bean->name; echo "<br>sess delete " . $_SESSION["mass_upd_assigned"]; echo "<br>sess delete" . $_REQUEST["massupdate"]; echo "<br>"; $okev = true; $_SESSION["mass_upd_assigned"] = false; if (isset($_REQUEST["massupdate"])) { if ($_REQUEST["massupdate"] == true) { $okev = false; if ($_REQUEST['assigned_user_id'] != "" or $_REQUEST['date_start'] != "") { $okev = true; } if ($_REQUEST['assigned_user_id'] != "") { $_SESSION["mass_upd_assigned"] = true; } } } if ($okev == true) { if ($_SESSION["called_from_sync"] == false or $_SESSION["called_from_sync"] == "") { ### skip if called from sync.php logic hook echo "<br>delete from sugar logic hook "; global $timedate; $offset_val = ".000+02:00"; $td = new TimeDate(); echo "<br>old bean id " . $bean->id; echo "<br>old bean name " . $bean->name; echo "<br>tablename "; $tablename = $bean->table_name; $a = $response['list'][$tn1]; $s = array(); $s["title"] = $bean->name; if ($tablename == 'meetings') { $s["title"] = "Meeting: " . $s["title"]; } if ($tablename == 'calls') { $s["title"] = "Call: " . $s["title"]; } if ($tablename == 'tasks') { $s["title"] = "Task: " . $s["title"]; } echo "<br>bean date start " . $bean->date_start; $s["content"] = $bean->description; $s["where"] = $bean->location; $s["startDay"] = $bean->date_start; $s["startTime"] = $bean->time_start; $s["endDay"] = $bean->date_end; $s["reminder_time"] = $bean->reminder_time / 60; if ($s["reminder_time"] == '' or $s["reminder_time"] == 0) { $s["reminder_time"] = 10; } if ($bean->date_start == '' and $bean->date_due != "") { $s["startDay"] = $bean->date_due; #### for tasks if no start date } else { $s["startDay"] = $bean->date_start; } # print_r($s); global $current_user; $pd = $s["startDay"]; ####260608 #$pd= $td->handle_offset($td->get_date_time_format(true, $current_user), $td->get_date_time_format(true, $current_user), false,$current_user); $date_start_in_db_fmt = $td->swap_formats($s["startDay"], $td->get_date_time_format(true, $current_user), $td->get_db_date_time_format()); $date_end_in_db_fmt1 = $td->swap_formats($bean->date_due, $td->get_date_time_format(true, $current_user), $td->get_db_date_time_format()); $date_start_array = split(" ", trim($date_start_in_db_fmt)); $date_time_start = DateTimeUtil::get_time_start($date_start_array[0], $date_start_array[1]); $tt1 = $td->to_display_date_time($bean->date_start, true, true, false); $user = $current_user; $s["startTime"] = $td->handle_offset($date_start_in_db_fmt, "H:i:s", false, $current_user); $date_end_in_db_fmt1 = $td->handle_offset($date_end_in_db_fmt1, "Y-m-d H:i:s", false, $current_user); echo "<br>bean date start1 " . $s["startTime"]; ##260806 $s["startTime"]=$date_start_array[1]; echo "<br>bean date start2 " . $s["startTime"]; $ch = explode(" ", $s["startDay"]); if ($ch['1'] == "00:00" or $ch['1'] == "00.00") { #### 120608 bogdan if task and 12:00 goes to next day $s["startDay"] = $td->handle_offset($date_start_in_db_fmt, "Y-m-d", false,$current_user); $s["startDay"] = $td->handle_offset($date_start_in_db_fmt, "Y-m-d", false, $current_user); $s["startDay1"] = $td->handle_offset($date_start_in_db_fmt, "Y-m-d H:i:s", false, $current_user); } else { $s["startDay"] = $td->handle_offset($date_start_in_db_fmt, "Y-m-d", false, $current_user); $s["startDay1"] = $td->handle_offset($date_start_in_db_fmt, "Y-m-d H:i:s", false, $current_user); } $plugin_format = "d/m/Y H:i"; if ($td->get_date_time_format(true, $current_user) != $plugin_format) { ##260608 $plugin_date_start=$td->swap_formats($pd, $td->get_date_time_format(true, $current_user), $plugin_format); $plugin_date_due = $td->swap_formats($bean->date_due, $td->get_date_time_format(true, $current_user), $plugin_format); } else { ##260608 $plugin_date_start=$pd; $plugin_date_due = $bean->date_due; } $plugin_date_start = $td->swap_formats($s["startDay1"], "Y-m-d H:i:s", $plugin_format); $plugin_date_due1 = $td->swap_formats($date_end_in_db_fmt1, "Y-m-d H:i:s", $plugin_format); echo "<br>plg date start " . $plugin_date_start; ################################################# $d1 = explode("/", $plugin_date_start); global $current_user; $d1[2] = explode(" ", $d1[2]); $d1[2] = $d1[2][0]; if ($bean->time_start != '' and 1 == 2) { $t1 = explode(":", $bean->time_start); } else { $fort1 = explode(" ", $plugin_date_start); $fort1 = $fort1[1]; $t1 = explode(":", $fort1); } $t1[1] = round($t1[1]); print_r($t1); $untill = mktime($t1[0] + $bean->duration_hours, $t1[1] + $bean->duration_minutes, $t1[2], $d1[1], $d1[0], $d1[2]); if ($tablename == 'tasks') { if ($plugin_date_due == "" or $bean->date_due == "") { $forexp = $plugin_date_start; echo "<br>date due " . $plugin_date_due . " " . $bean->date_due; } else { $forexp = $plugin_date_due; $forexp = $plugin_date_due1; } $d1d = explode("/", $forexp); $d1d[2] = explode(" ", $d1d[2]); $d1d[2] = $d1d[2][0]; $fort1d = explode(" ", $forexp); $fort1d = $fort1d[1]; $t1d = explode(":", $fort1d); $untill = mktime($t1d[0], $t1d[1], $t1d[2], $d1d[1], $d1d[0], $d1d[2]); } $date_due = date("Y-m-d", $untill); $time_due = date("H:i:s", $untill); $s["endTime"] = $time_due; $s["endDay"] = $date_due; echo "<br>start day " . $s["startDay"] . " " . $s["startTime"] . " " . $plugin_date_start; echo "<br>end day " . $s["endDay"] . " " . $s["endTime"] . " " . $plugin_date_due; if ($bean->assigned_user_id == '') { $userid = $bean->created_by; } else { $userid = $bean->assigned_user_id; } $user = new User(); $user->retrieve($userid); $user_data = get_user_email_pass1($user->id); if ($user_data[0] != '' and $user_data[1] != '') { echo "<br>**Got user " . $user_data[0]; $assigned_link = $user->google_mcalendar_c; if ($assigned_link == "" or $assigned_link == "1") { $assigned_link = "nolinkfromhook"; $assigned_link = "http://www.google.com/calendar/feeds/default/private/full"; } $gc = new GoogleCalendarWrapper($user_data[0], $user_data[1], "", $assigned_link); global $current_user; $add_notifications = $user->google_mnotifications_c; $gc->delete_event($s, $bean->id, $tablename, $user_data, $bean, $add_notifications); echo "<br>do event" . $doevent . " tb name " . $tablename; $_SESSION["mass_upd_assigned"] = false; ////////// dmc290609 #echo print_r($bean); # exit; if ($bean->table_name == "calls") { $mdname = "Calls"; } if ($bean->table_name == "meetings") { $mdname = "Meetings"; } if ($bean->table_name == "tasks") { $mdname = "Tasks"; } global $db; $_REQUEST['allready_retrieved_user_acceptDecline'] = true; $sq = "select * from google_calendar_rel where obj_id='" . $bean->id . "' and obj_type='" . $mdname . "' and deleted=0"; $res = $db->query($sq); while ($row_oldsaved = $db->fetchByAssoc($res)) { $user_data = get_user_email_pass1($row_oldsaved['user_id']); $_REQUEST['delete_invite_user_id'] = $row_oldsaved['user_id']; $_REQUEST['delete_invite_url'] = $row_oldsaved['old_link_edit_c']; if ($user_data[0] != '' and $user_data[1] != '') { $assigned_link = ""; $gc = new GoogleCalendarWrapper($user_data[0], $user_data[1], "", $assigned_link); $gc->delete_event($s, $bean->id, $tablename, $user_data, $bean, $add_notifications); #echo "<br>url ".$_REQUEST['delete_invite_url']; } } ////////// dmc290609 } } } }
73730 Esslingen, Germany info@mycrm.de (we do not answer technical support questions) ************************************************************************************************************************************************/ ob_start(); ini_set('max_execution_time', '36000'); define('sugarEntry', 'index.php'); require_once 'include/entryPoint.php'; require_once 'include/utils/file_utils.php'; ob_start(); require_once 'include/MVC/SugarApplication.php'; require_once 'config.php'; require_once 'include/database/PearDatabase.php'; require_once 'include/nusoap/nusoap.php'; include_once "googlecal/clsParseXML.php"; include_once "include/TimeDate.php"; include_once "googlecal/GoogleCalendarWrapper.php"; require_once "modules/Users/User.php"; require_once "modules/Tasks/Task.php"; require_once "modules/Administration/Administration.php"; require_once "google_calendar_conf.php"; global $server, $sugar_config, $system_config; $gc = new GoogleCalendarWrapper($_REQUEST['uss'], $_REQUEST['pass'], ""); $resp = $gc->Login(); echo "<table width=100% height=100% align=center valign=middle><tr><td align=center>"; if ($gc->fAuth == "") { echo "LOGIN CONNECTION TO GOOGLE: FAILED "; } else { echo "LOGIN CONNECTION TO GOOGLE: SCUCCESSFUL "; } echo "<tr><td align=center><a href=# onClick=\"window.close()\">Close window</a>";