zimbra-api / soap-api

Zimbra SOAP client in PHP language
BSD 3-Clause "New" or "Revised" License
62 stars 48 forks source link

Need documentation for the method "modifyAppointment" #14

Closed idev2020 closed 7 years ago

idev2020 commented 7 years ago

Hi nguyennv,

Thank you for this api.

Can you give me an example to use the method "modifyAppointment" ?

Thank you.

nguyennv commented 7 years ago

Hi idev2020 You can use example in https://github.com/zimbra-api/zimbra-api/issues/11 by replacing createAppointment with modifyAppointment and then pass appointment id to modifyAppointment

$api->modifyAppointment($msg, $appointmentId);
idev2020 commented 7 years ago

Hi nguyennv,

Thanks a lot for your help :+1:

vmaury commented 6 years ago

Hello szn256, When you call the method modifyAppointment (), appointmentId (2nd arg) is NOT the apptId :-$, it's the invId something like '1142-1141' when the appointment is created, the response is something like

(
    [invId] => 1142-1141
    [calItemId] => 1142
    [rev] => 4995
    [ms] => 4995
    [apptId] => 1142
)

And you've to put the compNum on 5th arg so here's my complete code

// $i is the appointment number, 1142 for ex.
$apt = $api->getAppointment(true, true, true, null, $i);
        $msgor = $apt->appt;

        if (!isset($info['folderId'])) $info['folderId'] = '10'; // folder par défaut pour les évènements

        $inv = new InvitationInfo();
        $comp = new InviteComponent();
        $comp->setName($info['name'])
            ->setLocation($info['location'])
            ->setFreeBusy(FreeBusyStatus::FREE())
            ->setStatus(InviteStatus::CONFIRMED())
            ->setCalClass(InviteClass::PUB())
            ->setTransparency(Transparency::OPAQUE())
            ->setIsAllDay(false)
            ->setIsDraft(false)
            ->addAttendee(new CalendarAttendee($info['calDestMail'], null, $info['calDestDisplayName'])) 
    //        ->addAttendee(new CalendarAttendee('nguyennv1981@yahoo.com', null, 'Van Nguyen'))
            ->setOrganizer(new CalOrganizer(userAuth, null, userDisplayName)) // <= !! il ne peut être différent du user connecté
            ->setDtStart(new DtTimeInfo($info['dtStart']))
            ->setDtEnd(new DtTimeInfo($info['dtEnd']))
            // SPECIFIQUE A LA MODIF !!
            ->setProperty('compNum',$apt->appt->inv->comp->compNum) // <= INDISPENSABLE
            ->setProperty('uid',$apt->appt->inv->comp->uid) 
            ->setProperty('calItemId',$apt->appt->inv->comp->calItemId)     
                ;

    //  $trigger = new AlarmTriggerInfo();
    //    $trigger->setRelative(new DurationInfo(true, null, null, null, 5, null, 'START'));
    //    $alarm = new AlarmInfo(AlarmAction::DISPLAY(), $trigger);
    //        ->addAlarm($alarm);

        $inv->setInviteComponent($comp);
        $inv->setProperty("id", $apt->appt->inv->id);

        $msg = new Msg();
        $msg->setSubject($info['mailSubject'])
            ->setFolderId($info['folderId'])
            // envoie un mail au gars sur qui on crée le rdv
            // Obligatoire si celui qui est connecté crée un évènement pour un autre; sinon non
            //->addEmail(new EmailAddrInfo($info['calDestMail'], AddressType::TO(), $info['calDestDisplayName'])) 
            //->addEmail(new EmailAddrInfo('nguyennv1981@yahoo.com', AddressType::TO(), 'Van Nguyen'))  
            ->setInvite($inv)
            //->setOrigId($apt->appt->uid)
                ;

        if (isset($info['mimePart'])) {
            $mp = new MimePartInfo(null, 'multipart/alternative');
            $mp->addMimePart(new MimePartInfo(null, 'text/plain', $info['mimePart']));
            $msg->setMimePart($mp);
        }
        return($api->modifyAppointment($msg, $i.'-'. $apt->appt->inv->id));

And it's the same thing for cancelAppointment method, the id to be indicated is like '1142-1141'