MailSuite Pro documentation

Calendar

API reference on CApiCalendarManager class

Calendar manager provides all the methods required for manipulating calendars and events. The approach for invoking API manager for calendar is a common point for any methods listed here:

include_once '/var/www/webmail/libraries/afterlogic/api.php';
if (class_exists('CApi') && CApi::IsValid()) {
    $oApiCalendarManager = CApi::Manager('calendar');
    ...
} else {
    echo 'AfterLogic API isn\'t available';
}

The following sample code will import an event represented as .ICS file into default calendar of the account.

include_once '/var/www/webmail/libraries/afterlogic/api.php';
if (class_exists('CApi') && CApi::IsValid()) {
    $oApiUsersManager = CApi::Manager('users');
    $oAccount = $oApiUsersManager->getAccountByEmail("user@domain.com");
    $oApiCalendarManager = CApi::Manager('calendar');
    $oCalendar = $oApiCalendarManager->getDefaultCalendar($oAccount);
    if ($oCalendar)
    {
        $sCalendarId = $oCalendar['Id'];
        $oApiCalendarManager->importToCalendarFromIcs($oAccount, $sCalendarId, "path/to/event.ics");
    } else {
        echo 'Default calendar not found';
    }    
} else {
    echo 'AfterLogic API isn\'t available';
}

NOTE: many methods of this API manager return boolean values. If not stated otherwise, bool value true/false stands for success or failure respectively.

Another example of using this manager is found on Accessing calendars and events documentation page.

API reference on CApiCalendarManager class