calendarimporter/php/module.calendarexporter.php
2012-12-05 21:31:10 +00:00

95 lines
2.6 KiB
PHP

<?php
/**
* class.calendarexporter.php, zarafa calender to ics exporter
*
* Author: Christoph Haas <christoph.h@sprinternet.at>
* Copyright (C) 2012 Christoph Haas
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
/**
* This module integrates Owncloud into attachment part of emails
* @class OwncloudModule
* @extends Module
*/
class CalendarexporterModule extends Module {
private $DEBUG = true; // enable error_log debugging
/**
* @constructor
* @param $id
* @param $data
*/
public function __construct($id, $data) {
parent::Module($id, $data);
}
/**
* Executes all the actions in the $data variable.
* Exception part is used for authentication errors also
* @return boolean true on success or false on failure.
*/
public function execute() {
$result = false;
foreach($this->data as $actionType => $actionData) {
if(isset($actionType)) {
try {
if($this->DEBUG) {
error_log("exec: " . $actionType);
}
switch($actionType) {
case "export":
$result = $this->exportCalendar($actionType, $actionData);
break;
default:
$this->handleUnknownActionType($actionType);
}
} catch (MAPIException $e) {
if($this->DEBUG) {
error_log("mapi exception: " . $e->getMessage());
}
} catch (Exception $e) {
if($this->DEBUG) {
error_log("exception: " . $e->getMessage());
}
}
}
}
return $result;
}
private function exportCalendar($actionType, $actionData) {
/* look up functionality in class.appointmentlistmodule.php (webapp/server/modules)*/
$response['status'] = true;
$response['entries'] = "1002"; // number of entries that will be exported
$this->addActionData($actionType, $response);
$GLOBALS["bus"]->addData($this->getResponseData());
if($this->DEBUG) {
error_log("export done, bus data written!");
}
}
};
?>