* Generelle Updates
This commit is contained in:
Daniel Spitzer
2024-11-10 20:47:09 +01:00
parent 72442248f9
commit de7330e331
6 changed files with 305 additions and 51 deletions

View File

@@ -176,6 +176,7 @@ class CalendarApicontroller extends mfBaseApicontroller
$message[0]['attachment'] = $Calendarevent['data'][0]['attachment']['attachment'];
$message[0]['attachments'] = $Calendarevent['data'][0]['attachments']['attachments'];
$message[0]['calendar_name'] = $Calendarevent['data'][0]['calendar_name']['calendar_name'];
$message[0]['isorganizer'] = $Calendarevent['data'][0]['isorganizer']['isorganizer'];
$message[0]['mtime'] = $Calendarevent['data'][0]['mtime']['mtime'];
$message[0]['mname'] = $Calendarevent['data'][0]['mname']['mname'];
$message[0]['ctime'] = $Calendarevent['data'][0]['ctime']['ctime'];

View File

@@ -77,6 +77,11 @@ class CalendarController extends mfBaseController
}
}
die();
case "updateCalendarEventState" :
$r = $this->request;
$calendarEvents = CalendarModel::updateCalendarEventState($r, $this->me);
die();
case "getAddress":
$r = $this->request;
$this->getAddress($r);

View File

@@ -192,6 +192,7 @@ class CalendarModel
'cname' => array('cname' => $data['cname']),
'mtime' => array('mtime' => date("d.m.Y H:i", $data['mtime'])),
'mname' => array('mname' => $data['mname']),
'isorganizer' => array('isorganizer' => $data['is_organizer']),
'busy' => array('busy' => $data['busy']),
);
}
@@ -243,9 +244,12 @@ class CalendarModel
$calendar = self::search(array("user_id" => $me));
$dbcal = self::dbKalender();
$res = $dbcal->select("cal_events", "id, uuid, calendar_id, user_id, start_time, end_time, timezone, all_day_event, name, description, location, repeat_end_time, reminder, ctime, mtime, muser_id, busy, status, resource_event_id, private, rrule, background, files_folder_id, read_only, category_id, exception_for_event_id, recurrence_id, is_organizer,event_type,customer,customer_info,customer_info_send,customer_info_reminder,busy,attendees,is_organizer", "1=1 AND id='" . $id . "' ORDER BY id");
$Calendars = self::getAll();
foreach ($Calendars as $key => $value) {
$Allcalendar[$value->user->name] = $key;
}
$Allcalendar['Daniel Whoknows'] = 2;
$res = $dbcal->select("cal_events", "id, uuid, calendar_id, user_id, start_time, end_time, timezone, all_day_event, name, description, location, repeat_end_time, reminder, ctime, mtime, muser_id, busy, status, resource_event_id, private, rrule, background, files_folder_id, read_only, category_id, exception_for_event_id, recurrence_id, is_organizer,event_type,customer,customer_info,customer_info_send,customer_info_reminder,busy,attendees,organizer,is_organizer,accepted", "1=1 AND id='" . $id . "' ORDER BY id");
if ($dbcal->num_rows($res)) {
$data = $dbcal->fetch_array($res);
@@ -298,6 +302,24 @@ class CalendarModel
}
$counter++;
}
$attendees = json_decode($data['attendees'], true);
$organizer = json_decode($data['organizer'], true);
foreach ($attendees as $key => $value) {
foreach ($value as $attendeekey => $attendee) {
// echo $attendee['name'];
if ($attendee['email'] == $organizer['email']) {
} elseif ($Allcalendar[$attendee['name']] && $Allcalendar[$attendee['name']] == $data['calendar_id']) {
} else if ($Allcalendar[$attendee['name']]) {
$AttendeeArray[] = $Allcalendar[$attendee['name']];
} else {
$AttendeeArray[] = $attendee['email'];
}
}
}
$rows = array(
'id' => array('id' => $data['id'], 'order' => $data['id']),
'cstart' => array('cstart' => $starttime, 'order' => $data['ctime']),
@@ -315,7 +337,9 @@ class CalendarModel
'customer_info_send' => array('customer_info_send' => $data['customer_info_send']),
'customer_info_reminder' => array('customer_info_reminder' => $data['customer_info_reminder']),
'isorganizer' => array('isorganizer' => $data['is_organizer']),
'attendees' => array('attendees' => $data['attendees']),
'attendees' => array('attendees' => json_encode($AttendeeArray)),
'organizer' => array('organizer' => $data['organizer']),
'accepted' => array('accepted' => $data['accepted']),
'attachment' => array('attachment' => $attachment, 'order' => $attachment),
'attachments' => array('attachments' => $attachments, 'order' => $attachments)
);
@@ -336,6 +360,7 @@ class CalendarModel
{
$db = self::dbKalender();
$json_data = json_decode($request, true);
$data = [];
$data['ms_event_id'] = $json_data['value'][0]['resourceData']['id'];
@@ -508,6 +533,57 @@ class CalendarModel
}
public static function updateCalendarEventState($r, $me)
{
$id = ($r->id);
$users = ($r->users);
$eventAction = $r->eventAction;
if ($eventAction == "accept") {
$process = 'ae';
$updateArray['busy'] = 1;
} else if ($eventAction == "decline") {
$process = "ce";
} else {
}
foreach ($users as $key => $value) {
$user_id = $value;
}
$db = self::dbKalender();
$sql = "SELECT `cal_events`.id,microsoft_id,uuid,ms_user_id FROM `cal_events` INNER JOIN `cal_calendars` ON (`cal_calendars`.`id`=`cal_events`.`calendar_id`) WHERE `cal_events`.id = '" . $id . "' LIMIT 1";
$res = $db->query($sql);
if ($db->num_rows($res)) {
$result = $db->fetch_object($res);
$microsoft_id = $result->microsoft_id;
$cal_events_id = $result->uuid;
$microsoft_user_id = $result->ms_user_id;
}
$acceptJson = array('time' => time(), 'user' => $me->name);
$updateArray['accepted'] = json_encode($acceptJson);
$db->update("cal_events", $updateArray, "id = '" . $id . "'");
$json_data = json_encode($updateArray);
$data = [];
$data['ms_user_id'] = $microsoft_user_id;
$data['ms_event_id'] = $microsoft_id;
$data['data'] = $json_data;
$data['type'] = $process;
$data['status'] = 'p';
$data['edit'] = time();
$data['create'] = time();
$data['edit_by'] = 89;
$data['create_by'] = 89;
$db->insert("TheTool_CalendarQueue", $data);
}
public static function insertCalendarEvent($r, $me)
{
$description = ($r->description);
@@ -523,6 +599,7 @@ class CalendarModel
$busy = ($r->busy);
$users = ($r->users);
$customer_info_reminder_check = 0;
$attendees = ($r->attendees);
date_default_timezone_set('Europe/Berlin');
header('Content-Type: application/json');
foreach ($users as $key => $value) {
@@ -561,10 +638,10 @@ class CalendarModel
$customer_info_send = NULL;
}
$data = array("start_time" => $start, 'end_time' => $end, 'name' => $title, 'description' => $description, 'location' => $location, 'calendar_id' => $user_id, 'uuid' => "a5eb79b3-fca7-5378-a09e-" . rand(100000000000, 999999999999), 'user_id' => 1, 'timezone' => 'Europe/Amsterdam', 'all_day_event' => 0, 'repeat_end_time' => 0, 'reminder' => $reminder, 'ctime' => time(), 'cname' => $me->name, 'mtime' => time(), 'mname' => $me->name, 'user_id' => 1, 'busy' => $busy, 'status' => 'CONFIRMED', 'resource_event_id' => 0, 'private' => 0, 'rrule' => '', 'background' => 'EBF1E2', 'files_folder_id' => 0, 'read_only' => 0, 'exception_for_event_id' => 0, 'recurrence_id' => 0, 'is_organizer' => 1, 'event_type' => $type, 'customer' => $customer, 'customer_info' => $customer_info, 'customer_info_send' => $customer_info_send, 'customer_info_reminder' => $customer_info_reminder_check);
$dataarray = array("start_time" => $start, 'end_time' => $end, 'name' => $title, 'description' => $description, 'location' => $location, 'calendar_id' => $user_id, 'uuid' => "a5eb79b3-fca7-5378-a09e-" . rand(100000000000, 999999999999), 'user_id' => 1, 'timezone' => 'Europe/Amsterdam', 'all_day_event' => 0, 'repeat_end_time' => 0, 'reminder' => $reminder, 'ctime' => time(), 'cname' => $me->name, 'mtime' => time(), 'mname' => $me->name, 'user_id' => 1, 'busy' => $busy, 'status' => 'CONFIRMED', 'resource_event_id' => 0, 'private' => 0, 'rrule' => '', 'background' => 'EBF1E2', 'files_folder_id' => 0, 'read_only' => 0, 'exception_for_event_id' => 0, 'recurrence_id' => 0, 'is_organizer' => 1, 'event_type' => $type, 'customer' => $customer, 'customer_info' => $customer_info, 'customer_info_send' => $customer_info_send, 'customer_info_reminder' => $customer_info_reminder_check);
$db->insert("cal_events", $data);
$event_id = $data['uuid'];
$db->insert("cal_events", $dataarray);
$event_id = $dataarray['uuid'];
if ($newkey) {
$res = $db->select("tmp_cal_events_attachments", "id,name,contentType,content,size,create_timestamp,edit_timestamp", "1=1 AND newkey='" . $newkey . "' ORDER BY id");
if ($db->num_rows($res)) {
@@ -579,8 +656,10 @@ class CalendarModel
}
$data['attachments'] = $attachments;
$json_data = json_encode($data);
if ($attendees)
$dataarray['attendees'] = $attendees;
$dataarray['attachments'] = $attachments;
$json_data = json_encode($dataarray);
$data = [];
$data['ms_user_id'] = $microsoft_user_id;
@@ -701,7 +780,7 @@ class CalendarModel
return $item;
}
public static function getAll()
public static function getAll($key = 'go_calendar_id')
{
$items = [];
@@ -710,7 +789,7 @@ class CalendarModel
$res = $db->select("Calendar", "*", "1=1");
if ($db->num_rows($res)) {
while ($data = $db->fetch_object($res)) {
$items[$data->go_calendar_id] = new Calendar($data);
$items[$data->{$key}] = new Calendar($data);
}
}
return $items;