Back to index

d-push  2.0
meetingresponse.php
Go to the documentation of this file.
00001 <?php
00002 /***********************************************
00003 * File      :   meetingresponse.php
00004 * Project   :   Z-Push
00005 * Descr     :   Provides the MEETINGRESPONSE command
00006 *
00007 * Created   :   16.02.2012
00008 *
00009 * Copyright 2007 - 2012 Zarafa Deutschland GmbH
00010 *
00011 * This program is free software: you can redistribute it and/or modify
00012 * it under the terms of the GNU Affero General Public License, version 3,
00013 * as published by the Free Software Foundation with the following additional
00014 * term according to sec. 7:
00015 *
00016 * According to sec. 7 of the GNU Affero General Public License, version 3,
00017 * the terms of the AGPL are supplemented with the following terms:
00018 *
00019 * "Zarafa" is a registered trademark of Zarafa B.V.
00020 * "Z-Push" is a registered trademark of Zarafa Deutschland GmbH
00021 * The licensing of the Program under the AGPL does not imply a trademark license.
00022 * Therefore any rights, title and interest in our trademarks remain entirely with us.
00023 *
00024 * However, if you propagate an unmodified version of the Program you are
00025 * allowed to use the term "Z-Push" to indicate that you distribute the Program.
00026 * Furthermore you may use our trademarks where it is necessary to indicate
00027 * the intended purpose of a product or service provided you use it in accordance
00028 * with honest practices in industrial or commercial matters.
00029 * If you want to propagate modified versions of the Program under the name "Z-Push",
00030 * you may only do so if you have a written permission by Zarafa Deutschland GmbH
00031 * (to acquire a permission please contact Zarafa at trademark@zarafa.com).
00032 *
00033 * This program is distributed in the hope that it will be useful,
00034 * but WITHOUT ANY WARRANTY; without even the implied warranty of
00035 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00036 * GNU Affero General Public License for more details.
00037 *
00038 * You should have received a copy of the GNU Affero General Public License
00039 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00040 *
00041 * Consult LICENSE file for details
00042 ************************************************/
00043 
00044 class MeetingResponse extends RequestProcessor {
00045 
00054     public function Handle($commandCode) {
00055         $requests = Array();
00056 
00057         if(!self::$decoder->getElementStartTag(SYNC_MEETINGRESPONSE_MEETINGRESPONSE))
00058             return false;
00059 
00060         while(self::$decoder->getElementStartTag(SYNC_MEETINGRESPONSE_REQUEST)) {
00061             $req = Array();
00062 
00063             if(self::$decoder->getElementStartTag(SYNC_MEETINGRESPONSE_USERRESPONSE)) {
00064                 $req["response"] = self::$decoder->getElementContent();
00065                 if(!self::$decoder->getElementEndTag())
00066                     return false;
00067             }
00068 
00069             if(self::$decoder->getElementStartTag(SYNC_MEETINGRESPONSE_FOLDERID)) {
00070                 $req["folderid"] = self::$decoder->getElementContent();
00071                 if(!self::$decoder->getElementEndTag())
00072                     return false;
00073             }
00074 
00075             if(self::$decoder->getElementStartTag(SYNC_MEETINGRESPONSE_REQUESTID)) {
00076                 $req["requestid"] = self::$decoder->getElementContent();
00077                 if(!self::$decoder->getElementEndTag())
00078                     return false;
00079             }
00080 
00081             if(!self::$decoder->getElementEndTag())
00082                 return false;
00083 
00084             array_push($requests, $req);
00085         }
00086 
00087         if(!self::$decoder->getElementEndTag())
00088             return false;
00089 
00090         // output the error code, plus the ID of the calendar item that was generated by the
00091         // accept of the meeting response
00092         self::$encoder->StartWBXML();
00093         self::$encoder->startTag(SYNC_MEETINGRESPONSE_MEETINGRESPONSE);
00094 
00095         foreach($requests as $req) {
00096             $status = SYNC_MEETRESPSTATUS_SUCCESS;
00097 
00098             try {
00099                 $calendarid = self::$backend->MeetingResponse($req["requestid"], $req["folderid"], $req["response"]);
00100                 if ($calendarid === false)
00101                     throw new StatusException("HandleMeetingResponse() not possible", SYNC_MEETRESPSTATUS_SERVERERROR);
00102             }
00103             catch (StatusException $stex) {
00104                 $status = $stex->getCode();
00105             }
00106 
00107             self::$encoder->startTag(SYNC_MEETINGRESPONSE_RESULT);
00108                 self::$encoder->startTag(SYNC_MEETINGRESPONSE_REQUESTID);
00109                     self::$encoder->content($req["requestid"]);
00110                 self::$encoder->endTag();
00111 
00112                 self::$encoder->startTag(SYNC_MEETINGRESPONSE_STATUS);
00113                     self::$encoder->content($status);
00114                 self::$encoder->endTag();
00115 
00116                 if($status == SYNC_MEETRESPSTATUS_SUCCESS) {
00117                     self::$encoder->startTag(SYNC_MEETINGRESPONSE_CALENDARID);
00118                         self::$encoder->content($calendarid);
00119                     self::$encoder->endTag();
00120                 }
00121             self::$encoder->endTag();
00122             self::$topCollector->AnnounceInformation(sprintf("Operation status %d", $status), true);
00123         }
00124         self::$encoder->endTag();
00125 
00126         return true;
00127     }
00128 }
00129 ?>