/**
* 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 iCalComponent The VEVENT or VTODO containing the ATTENDEEs
* @return null
*/
function write_attendees($dav_id, $ical)
{
    $qry = new AwlQuery('DELETE FROM calendar_attendee WHERE dav_id = ' . $dav_id);
    $qry->Exec('PUT', __LINE__, __FILE__);
    $attendees = $ical->GetProperties('ATTENDEE');
    if (count($attendees) < 1) {
        return;
    }
    $qry->SetSql('INSERT INTO calendar_attendee ( dav_id, status, partstat, cn, attendee, role, rsvp, property )
          VALUES( ' . $dav_id . ', :status, :partstat, :cn, :attendee, :role, :rsvp, :property )');
    $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(':property', $v->Render());
        $qry->Exec('PUT', __LINE__, __FILE__);
        $processed[$attendee] = $v->Render();
    }
}
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;
}
Beispiel #3
0
 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;
 }