Commit 2f465771 authored by Sebastian Kummer's avatar Sebastian Kummer

Merge pull request #291 in ZP/z-push from...

Merge pull request #291 in ZP/z-push from feature/ZP-969-implement-webservice-api-calls-to to develop

* commit '53288c05':
  ZP-969 Update copyright year, unset several variables together.
  ZP-969 Announce WebserviceInfo command, add command to mappings, remove include in WebserviceDevice, implement StripData() in SyncObject, run parent mapping twice in GetHierarchy() to fetch missing parent mappings.
parents e5c5e3ac 53288c05
...@@ -358,6 +358,14 @@ class BackendKopano implements IBackend, ISearchProvider { ...@@ -358,6 +358,14 @@ class BackendKopano implements IBackend, ISearchProvider {
} }
} }
// reloop the folders to make sure all parentids are mapped correctly
$dm = ZPush::GetDeviceManager();
foreach ($folders as $folder) {
if ($folder->parentid !== "0") {
$folder->parentid = $dm->GetFolderIdForBackendId($folder->parentid);
}
}
return $folders; return $folders;
} }
......
...@@ -97,6 +97,7 @@ class ZPush { ...@@ -97,6 +97,7 @@ class ZPush {
// Webservice commands // Webservice commands
const COMMAND_WEBSERVICE_DEVICE = -100; const COMMAND_WEBSERVICE_DEVICE = -100;
const COMMAND_WEBSERVICE_USERS = -101; const COMMAND_WEBSERVICE_USERS = -101;
const COMMAND_WEBSERVICE_INFO = -102;
// Latest supported State version // Latest supported State version
const STATE_VERSION = IStateMachine::STATEVERSION_02; const STATE_VERSION = IStateMachine::STATEVERSION_02;
...@@ -145,6 +146,7 @@ class ZPush { ...@@ -145,6 +146,7 @@ class ZPush {
self::COMMAND_WEBSERVICE_DEVICE => array(self::REQUESTHANDLER => "Webservice", self::PLAININPUT, self::NOACTIVESYNCCOMMAND, self::WEBSERVICECOMMAND), self::COMMAND_WEBSERVICE_DEVICE => array(self::REQUESTHANDLER => "Webservice", self::PLAININPUT, self::NOACTIVESYNCCOMMAND, self::WEBSERVICECOMMAND),
self::COMMAND_WEBSERVICE_USERS => array(self::REQUESTHANDLER => "Webservice", self::PLAININPUT, self::NOACTIVESYNCCOMMAND, self::WEBSERVICECOMMAND), self::COMMAND_WEBSERVICE_USERS => array(self::REQUESTHANDLER => "Webservice", self::PLAININPUT, self::NOACTIVESYNCCOMMAND, self::WEBSERVICECOMMAND),
self::COMMAND_WEBSERVICE_INFO => array(self::REQUESTHANDLER => "Webservice", self::PLAININPUT, self::NOACTIVESYNCCOMMAND, self::WEBSERVICECOMMAND),
); );
......
...@@ -381,6 +381,19 @@ abstract class SyncObject extends Streamer { ...@@ -381,6 +381,19 @@ abstract class SyncObject extends Streamer {
return $this->unsetVars; return $this->unsetVars;
} }
/**
* Removes not necessary data from the object
*
* @access public
* @return boolean
*/
public function StripData() {
if (isset($this->unsetVars)) {
unset($this->unsetVars);
}
return parent::StripData();
}
/** /**
* Method checks if the object has the minimum of required parameters * Method checks if the object has the minimum of required parameters
* and fullfills semantic dependencies * and fullfills semantic dependencies
......
...@@ -659,7 +659,8 @@ class Utils { ...@@ -659,7 +659,8 @@ class Utils {
// Webservice commands // Webservice commands
case ZPush::COMMAND_WEBSERVICE_DEVICE: return 'WebserviceDevice'; case ZPush::COMMAND_WEBSERVICE_DEVICE: return 'WebserviceDevice';
case ZPush::COMMAND_WEBSERVICE_USERS: return 'WebserviceUsers'; case ZPush::COMMAND_WEBSERVICE_USERS: return 'WebserviceUsers';
case ZPush::COMMAND_WEBSERVICE_INFO: return 'WebserviceInfo';
} }
return false; return false;
} }
...@@ -704,6 +705,7 @@ class Utils { ...@@ -704,6 +705,7 @@ class Utils {
// Webservice commands // Webservice commands
case 'WebserviceDevice': return ZPush::COMMAND_WEBSERVICE_DEVICE; case 'WebserviceDevice': return ZPush::COMMAND_WEBSERVICE_DEVICE;
case 'WebserviceUsers': return ZPush::COMMAND_WEBSERVICE_USERS; case 'WebserviceUsers': return ZPush::COMMAND_WEBSERVICE_USERS;
case 'WebserviceInfo': return ZPush::COMMAND_WEBSERVICE_INFO;
} }
return false; return false;
} }
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* Created : 29.12.2011 * Created : 29.12.2011
* *
* Copyright 2007 - 2013 Zarafa Deutschland GmbH * Copyright 2007 - 2016 Zarafa Deutschland GmbH
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3, * it under the terms of the GNU Affero General Public License, version 3,
...@@ -69,9 +69,13 @@ class Webservice { ...@@ -69,9 +69,13 @@ class Webservice {
ZLog::Write(LOGLEVEL_DEBUG, sprintf("Webservice::HandleWebservice('%s'): executing WebserviceDevice service", $commandCode)); ZLog::Write(LOGLEVEL_DEBUG, sprintf("Webservice::HandleWebservice('%s'): executing WebserviceDevice service", $commandCode));
$this->server->setClass("WebserviceDevice"); $this->server->setClass("WebserviceDevice");
} }
// the webservice command is handled by its class // the webservice command is handled by its class
if ($commandCode == ZPush::COMMAND_WEBSERVICE_USERS) { else if ($commandCode == ZPush::COMMAND_WEBSERVICE_INFO) {
ZLog::Write(LOGLEVEL_DEBUG, sprintf("Webservice::HandleWebservice('%s'): executing WebserviceInfo service", $commandCode));
$this->server->setClass("WebserviceInfo");
}
// the webservice command is handled by its class
else if ($commandCode == ZPush::COMMAND_WEBSERVICE_USERS) {
if (!defined("ALLOW_WEBSERVICE_USERS_ACCESS") || ALLOW_WEBSERVICE_USERS_ACCESS !== true) if (!defined("ALLOW_WEBSERVICE_USERS_ACCESS") || ALLOW_WEBSERVICE_USERS_ACCESS !== true)
throw new HTTPReturnCodeException("Access to the WebserviceUsers service is disabled in configuration. Enable setting ALLOW_WEBSERVICE_USERS_ACCESS", 403); throw new HTTPReturnCodeException("Access to the WebserviceUsers service is disabled in configuration. Enable setting ALLOW_WEBSERVICE_USERS_ACCESS", 403);
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* Created : 23.12.2011 * Created : 23.12.2011
* *
* Copyright 2007 - 2015 Zarafa Deutschland GmbH * Copyright 2007 - 2016 Zarafa Deutschland GmbH
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3, * it under the terms of the GNU Affero General Public License, version 3,
...@@ -42,7 +42,6 @@ ...@@ -42,7 +42,6 @@
* *
* Consult LICENSE file for details * Consult LICENSE file for details
************************************************/ ************************************************/
include ('lib/utils/zpushadmin.php');
class WebserviceDevice { class WebserviceDevice {
......
<?php
/***********************************************
* File : webserviceinfo.php
* Project : Z-Push
* Descr : Provides general information for an authenticated
* user.
*
* Created : 17.06.2016
*
* Copyright 2016 Zarafa Deutschland GmbH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation with the following additional
* term according to sec. 7:
*
* According to sec. 7 of the GNU Affero General Public License, version 3,
* the terms of the AGPL are supplemented with the following terms:
*
* "Zarafa" is a registered trademark of Zarafa B.V.
* "Z-Push" is a registered trademark of Zarafa Deutschland GmbH
* The licensing of the Program under the AGPL does not imply a trademark license.
* Therefore any rights, title and interest in our trademarks remain entirely with us.
*
* However, if you propagate an unmodified version of the Program you are
* allowed to use the term "Z-Push" to indicate that you distribute the Program.
* Furthermore you may use our trademarks where it is necessary to indicate
* the intended purpose of a product or service provided you use it in accordance
* with honest practices in industrial or commercial matters.
* If you want to propagate modified versions of the Program under the name "Z-Push",
* you may only do so if you have a written permission by Zarafa Deutschland GmbH
* (to acquire a permission please contact Zarafa at trademark@zarafa.com).
*
* This program 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Consult LICENSE file for details
************************************************/
class WebserviceInfo {
/**
* Returns a list of folders of the Request::GetGETUser().
* If the user has not enough permissions an empty result is returned.
*
* @access public
* @return array
*/
public function ListUserFolders() {
$user = Request::GetGETUser();
$output = array();
$hasRights = ZPush::GetBackend()->Setup($user);
ZLog::Write(LOGLEVEL_INFO, sprintf("WebserviceInfo::ListUserFolders(): permissions to open store '%s': %s", $user, Utils::PrintAsString($hasRights)));
$folders = ZPush::GetBackend()->GetHierarchy();
ZPush::GetTopCollector()->AnnounceInformation(sprintf("Retrieved details of %d folders", count($folders)), true);
foreach ($folders as $folder) {
$folder->StripData();
unset($folder->Store, $folder->flags, $folder->content, $folder->NoBackendFolder, $folder->ReadOnly);
$output[] = $folder;
}
return $output;
}
}
...@@ -176,6 +176,7 @@ return array( ...@@ -176,6 +176,7 @@ return array(
'WBXMLException' => $baseDir . '/lib/exceptions/wbxmlexception.php', 'WBXMLException' => $baseDir . '/lib/exceptions/wbxmlexception.php',
'Webservice' => $baseDir . '/lib/webservice/webservice.php', 'Webservice' => $baseDir . '/lib/webservice/webservice.php',
'WebserviceDevice' => $baseDir . '/lib/webservice/webservicedevice.php', 'WebserviceDevice' => $baseDir . '/lib/webservice/webservicedevice.php',
'WebserviceInfo' => $baseDir . '/lib/webservice/webserviceinfo.php',
'WebserviceUsers' => $baseDir . '/lib/webservice/webserviceusers.php', 'WebserviceUsers' => $baseDir . '/lib/webservice/webserviceusers.php',
'ZLog' => $baseDir . '/lib/core/zlog.php', 'ZLog' => $baseDir . '/lib/core/zlog.php',
'ZPush' => $baseDir . '/lib/core/zpush.php', 'ZPush' => $baseDir . '/lib/core/zpush.php',
......
...@@ -183,6 +183,7 @@ class ComposerStaticInitd6749fc2fb9944bbe86b2b7d79a7852f ...@@ -183,6 +183,7 @@ class ComposerStaticInitd6749fc2fb9944bbe86b2b7d79a7852f
'WBXMLException' => __DIR__ . '/../..' . '/lib/exceptions/wbxmlexception.php', 'WBXMLException' => __DIR__ . '/../..' . '/lib/exceptions/wbxmlexception.php',
'Webservice' => __DIR__ . '/../..' . '/lib/webservice/webservice.php', 'Webservice' => __DIR__ . '/../..' . '/lib/webservice/webservice.php',
'WebserviceDevice' => __DIR__ . '/../..' . '/lib/webservice/webservicedevice.php', 'WebserviceDevice' => __DIR__ . '/../..' . '/lib/webservice/webservicedevice.php',
'WebserviceInfo' => __DIR__ . '/../..' . '/lib/webservice/webserviceinfo.php',
'WebserviceUsers' => __DIR__ . '/../..' . '/lib/webservice/webserviceusers.php', 'WebserviceUsers' => __DIR__ . '/../..' . '/lib/webservice/webserviceusers.php',
'ZLog' => __DIR__ . '/../..' . '/lib/core/zlog.php', 'ZLog' => __DIR__ . '/../..' . '/lib/core/zlog.php',
'ZPush' => __DIR__ . '/../..' . '/lib/core/zpush.php', 'ZPush' => __DIR__ . '/../..' . '/lib/core/zpush.php',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment