function handle_remote_attendee_reply(vCalendar $ical) { $attendees = $ical->GetAttendees(); // attendee reply have just one attendee if (count($attendees) != 1) { return; } $attendee = $attendees[0]; $uidparam = $ical->GetPropertiesByPath("VCALENDAR/*/UID"); $uid = $uidparam[0]->Value(); $qry = new AwlQuery('UPDATE calendar_attendee SET email_status=:statusTo WHERE attendee=:attendee AND dav_id = (SELECT dav_id FROM calendar_item WHERE uid = :uid)'); // user accepted $qry->Bind(':statusTo', EMAIL_STATUS::NORMAL); $qry->Bind(':attendee', $attendee->Value()); $qry->Bind(':uid', $uid); $qry->Exec('changeStatusTo'); return true; }
function handle_remote_attendee_reply(vCalendar $ical) { $attendees = $ical->GetAttendees(); // attendee reply have just one attendee if (count($attendees) != 1) { return; } $attendee = $attendees[0]; $uidparam = $ical->GetPropertiesByPath("VCALENDAR/*/UID"); $uid = $uidparam[0]->Value(); $parameters = $attendee->Parameters(); $propertyText = ''; foreach ($parameters as $key => $param) { if (!empty($propertyText)) { $propertyText .= ';'; } $propertyText .= $key . '=' . $param; } //$propertyText .= ':' . $attendee->Value(); $qry = new AwlQuery('SELECT dav_id, calendar_item.collection_id AS collection_id, calendar_item.dav_name AS dav_name, caldav_data FROM calendar_item LEFT JOIN caldav_data USING(dav_id) WHERE uid = :uid'); $qry->Bind(':uid', $uid); $qry->Exec('select dav_id, collection_id'); if ($row = $qry->Fetch()) { $qry = new AwlQuery('UPDATE calendar_attendee SET email_status=:statusTo, partstat=:partstat, params=:params WHERE attendee=:attendee AND dav_id = :dav_id'); // user accepted $qry->Bind(':statusTo', EMAIL_STATUS::NORMAL); $qry->Bind(':attendee', $attendee->Value()); $qry->Bind(':dav_id', $row->dav_id); $qry->Bind(':params', $propertyText); $qry->Bind(':partstat', $parameters['PARTSTAT']); $qry->Exec('changeStatusTo'); //'(SELECT dav_id FROM calendar_item WHERE uid = :uid)'; $collection_id = $row->collection_id; $dav_name = $row->dav_name; //$qry->QDo("SELECT write_sync_change( $collection_id, 200, :dav_name)", array(':dav_name' => $dav_name ) ); //$qry->Execute(); $this->update_caldav_data($row->caldav_data, $row->dav_id); } return true; }
$this->email = $principal->email(); $this->dav_name = $principal->dav_name(); $this->principal = $principal; $this->logged_in = true; } function AllowedTo($do_something) { return true; } } $d = new iSchedule(); if ($d->validateRequest()) { $ical = new vCalendar($request->raw_post); $attendee = array(); $addresses = array(); $attendees = $ical->GetAttendees(); foreach ($attendees as $v) { $email = preg_replace('/^mailto:/i', '', $v->Value()); $addresses[] = $email; } $organizer = $ical->GetOrganizer(); $addresses[] = preg_replace('/^mailto:/i', '', $organizer->Value()); $recipients = array(); $attendees_ok = array(); $attendees_fail = array(); if (strpos($_SERVER['HTTP_RECIPIENT'], ',') === false) { // single recipient $recipients[] = $_SERVER['HTTP_RECIPIENT']; } else { $rcpt = explode(',', $_SERVER['HTTP_RECIPIENT']); foreach ($rcpt as $k => $v) {
/** * Parse out the attendee property and write a row to the * calendar_attendee table for each one. * @param int $dav_id The dav_id of the caldav_data we're processing * @param vComponent The VEVENT or VTODO containing the ATTENDEEs * @return null */ function WriteCalendarAttendees($dav_id, vCalendar $vcal) { $qry = new AwlQuery('DELETE FROM calendar_attendee WHERE dav_id = ' . $dav_id); $qry->Exec('PUT', __LINE__, __FILE__); $attendees = $vcal->GetAttendees(); if (count($attendees) < 1) { return; } $qry->SetSql('INSERT INTO calendar_attendee ( dav_id, status, partstat, cn, attendee, role, rsvp, params ) VALUES( ' . $dav_id . ', :status, :partstat, :cn, :attendee, :role, :rsvp, :params )'); $qry->Prepare(); $processed = array(); foreach ($attendees as $v) { $attendee = $v->Value(); if (isset($processed[$attendee])) { dbg_error_log('LOG', 'Duplicate attendee "%s" in resource "%d"', $attendee, $dav_id); dbg_error_log('LOG', 'Original: "%s"', $processed[$attendee]); dbg_error_log('LOG', 'Duplicate: "%s"', $v->Render()); continue; /** @todo work out why we get duplicate ATTENDEE on one VEVENT */ } $qry->Bind(':attendee', $attendee); $qry->Bind(':status', $v->GetParameterValue('STATUS')); $qry->Bind(':partstat', $v->GetParameterValue('PARTSTAT')); $qry->Bind(':cn', $v->GetParameterValue('CN')); $qry->Bind(':role', $v->GetParameterValue('ROLE')); $qry->Bind(':rsvp', $v->GetParameterValue('RSVP')); $qry->Bind(':params', $v->Parameters()); $qry->Exec('PUT', __LINE__, __FILE__); $processed[$attendee] = $v->Render(); } }
/** * Handles sending the iTIP CANCEL messages to each ATTENDEE by the ORGANIZER. * @param vCalendar $vcal What's being cancelled. */ function doItipOrganizerCancel(vCalendar $vcal) { global $request; $attendees = $vcal->GetAttendees(); if (count($attendees) == 0 && count($old_attendees) == 0) { dbg_error_log('schedule', 'Event has no attendees - no scheduling required.', count($attendees)); return true; } dbg_error_log('schedule', 'Writing scheduling resources for %d attendees', count($attendees)); $scheduling_actions = false; $iTIP = GetItip($vcal, 'CANCEL', null); foreach ($attendees as $attendee) { $email = preg_replace('/^mailto:/i', '', $attendee->Value()); if ($email == $request->principal->email()) { dbg_error_log('schedule', "not delivering to owner '%s'", $request->principal->email()); continue; } $agent = $attendee->GetParameterValue('SCHEDULE-AGENT'); if ($agent && $agent != 'SERVER') { dbg_error_log('schedule', "not delivering to %s, schedule agent set to value other than server", $email); continue; } $schedule_target = new Principal('email', $email); if (!$schedule_target->Exists()) { if (doImipMessage('CANCEL', $email, $vcal)) { $response = '1.1'; // Scheduling whoosit 'Sent' } else { $response = '3.7'; } } else { $attendee_inbox = new WritableCollection(array('path' => $schedule_target->internal_url('schedule-inbox'))); if (!$attendee_inbox->HavePrivilegeTo('schedule-deliver-invite')) { dbg_error_log('schedule', "No authority to deliver invite to %s", $schedule_target->internal_url('schedule-inbox')); $response = '3.8'; } else { $attendee_calendar = new WritableCollection(array('path' => $schedule_target->internal_url('schedule-default-calendar'))); $response = processItipCancel($vcal, $attendee, $attendee_calendar, $schedule_target); deliverItipCancel($iTIP, $attendee, $attendee_inbox); } } dbg_error_log('schedule', 'Status for attendee <%s> set to "%s"', $attendee->Value(), $response); $attendee->SetParameterValue('SCHEDULE-STATUS', $response); $scheduling_actions = true; } return true; }