Back to index

d-push  2.0
webservice.php
Go to the documentation of this file.
00001 <?php
00002 /***********************************************
00003 * File      :   webservice.php
00004 * Project   :   Z-Push
00005 * Descr     :   Provides an interface for administration
00006 *               tasks over a webservice
00007 *
00008 * Created   :   29.12.2011
00009 *
00010 * Copyright 2007 - 2011 Zarafa Deutschland GmbH
00011 *
00012 * This program is free software: you can redistribute it and/or modify
00013 * it under the terms of the GNU Affero General Public License, version 3,
00014 * as published by the Free Software Foundation with the following additional
00015 * term according to sec. 7:
00016 *
00017 * According to sec. 7 of the GNU Affero General Public License, version 3,
00018 * the terms of the AGPL are supplemented with the following terms:
00019 *
00020 * "Zarafa" is a registered trademark of Zarafa B.V.
00021 * "Z-Push" is a registered trademark of Zarafa Deutschland GmbH
00022 * The licensing of the Program under the AGPL does not imply a trademark license.
00023 * Therefore any rights, title and interest in our trademarks remain entirely with us.
00024 *
00025 * However, if you propagate an unmodified version of the Program you are
00026 * allowed to use the term "Z-Push" to indicate that you distribute the Program.
00027 * Furthermore you may use our trademarks where it is necessary to indicate
00028 * the intended purpose of a product or service provided you use it in accordance
00029 * with honest practices in industrial or commercial matters.
00030 * If you want to propagate modified versions of the Program under the name "Z-Push",
00031 * you may only do so if you have a written permission by Zarafa Deutschland GmbH
00032 * (to acquire a permission please contact Zarafa at trademark@zarafa.com).
00033 *
00034 * This program is distributed in the hope that it will be useful,
00035 * but WITHOUT ANY WARRANTY; without even the implied warranty of
00036 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00037 * GNU Affero General Public License for more details.
00038 *
00039 * You should have received a copy of the GNU Affero General Public License
00040 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00041 *
00042 * Consult LICENSE file for details
00043 ************************************************/
00044 
00045 class Webservice {
00046     private $server;
00047 
00057     public function Handle($commandCode) {
00058         if (Request::GetDeviceType() !== "webservice" || Request::GetDeviceID() !== "webservice")
00059             throw new FatalException("Invalid device id and type for webservice execution");
00060 
00061         if (Request::GetGETUser() != Request::GetAuthUser())
00062             ZLog::Write(LOGLEVEL_INFO, sprintf("Webservice::HandleWebservice('%s'): user '%s' executing action for user '%s'", $commandCode, Request::GetAuthUser(), Request::GetGETUser()));
00063 
00064         // initialize non-wsdl soap server
00065         $this->server = new SoapServer(null, array('uri' => "http://z-push.sf.net/webservice"));
00066 
00067         // the webservice command is handled by its class
00068         if ($commandCode == ZPush::COMMAND_WEBSERVICE_DEVICE) {
00069             ZLog::Write(LOGLEVEL_DEBUG, sprintf("Webservice::HandleWebservice('%s'): executing WebserviceDevice service", $commandCode));
00070 
00071             include_once('webservicedevice.php');
00072             $this->server->setClass("WebserviceDevice");
00073         }
00074         $this->server->handle();
00075 
00076         ZLog::Write(LOGLEVEL_DEBUG, sprintf("Webservice::HandleWebservice('%s'): sucessfully sent %d bytes", $commandCode, ob_get_length()));
00077         return true;
00078     }
00079 }
00080 ?>