Commit fea6d7f8 authored by Sebastian Kummer's avatar Sebastian Kummer

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

Merge pull request #304 in ZP/z-push from bugfix/ZP-989-warning-that-readonly-flag-is-undefined to develop

* commit '881fc1f3':
  ZP-989 Output current permission flags on all additional folders in AdditionalFolderList(), criteria to add a shared folder in the ChangesMemoryWrapper should always be on the read only flag, refixed typo in Kopano backend.
  ZP-989 Reverted: "Remove readonly parameter from backends' Setup() function. Check"
  ZP-989 Backward compatibility fixes for old style folder ids.
  ZP-989 Remove readonly parameter from $additionalFolders in config.php and where it was used in the code.
  ZP-989 Remove readonly parameter when adding an additional folder via webservice.
  ZP-989 Remove readonly parameter from backends' Setup() function. Check for only read permission in Kopano backend Setup().
parents f6051d9c 881fc1f3
......@@ -238,7 +238,7 @@ class BackendKopano implements IBackend, ISearchProvider {
if ($user === false)
$user = $this->mainUser;
// This is a special case. A user will get it's entire folder structure by the foldersync by default.
// This is a special case. A user will get his entire folder structure by the foldersync by default.
// The ACL check is executed when an additional folder is going to be sent to the mobile.
// Configured that way the user could receive the same folderid twice, with two different names.
if ($this->mainUser == $user && $checkACLonly && $folderid) {
......
......@@ -453,16 +453,15 @@ class ReplyBackImExporter implements IImportChanges, IExportChanges {
$sourcekey = hex2bin($sk);
$parentsourcekey = hex2bin(ZPush::GetDeviceManager()->GetBackendIdForFolderId($fsk));
// Backwards compatibility for old style folder ids
if (empty($parentsourcekey)) {
$parentsourcekey = $this->folderid;
}
$entryid = mapi_msgstore_entryidfromsourcekey($this->store, $parentsourcekey, $sourcekey);
if(!$entryid) {
ZLog::Write(LOGLEVEL_INFO, sprintf("ReplyBackImExporter->getMessage(): Couldn't retrieve message from MAPIProvider, sourcekey: '%s', parentsourcekey: '%s'", bin2hex($sourcekey), bin2hex($parentsourcekey), bin2hex($entryid)));
if ($announceErrors) {
return $status;
}
else {
return false;
}
return false;
}
$mapimessage = mapi_msgstore_openentry($this->store, $entryid);
......@@ -484,8 +483,7 @@ class ReplyBackImExporter implements IImportChanges, IExportChanges {
}
ZPush::GetDeviceManager()->AnnounceIgnoredMessage(false, $brokenSO->id, $brokenSO);
}
// tell MAPI to ignore the message
return $status;
return false;
}
}
return $message;
......
......@@ -345,8 +345,6 @@
* SYNC_FOLDER_TYPE_USER_TASK
* SYNC_FOLDER_TYPE_USER_MAIL
* SYNC_FOLDER_TYPE_USER_NOTE
* readonly: indicates if the folder should be opened read-only.
* If set to false, full writing permissions are required.
*
* Additional notes:
* - on Kopano systems use backend/kopano/listfolders.php script to get a list
......@@ -379,7 +377,6 @@
'folderid' => "",
'name' => "Public Contacts",
'type' => SYNC_FOLDER_TYPE_USER_CONTACT,
'readonly' => false,
),
*/
);
......@@ -854,12 +854,11 @@ class ASDevice extends StateObject {
* @param string $folderid the folder id of the additional folder.
* @param string $name the name of the additional folder (has to be unique for all folders on the device).
* @param string $type AS foldertype of SYNC_FOLDER_TYPE_USER_*
* @param boolean $readonly Indicates if the folder should be synched if the user has at least read-only permissions.
*
* @access public
* @return boolean
*/
public function AddAdditionalFolder($store, $folderid, $name, $type, $readonly) {
public function AddAdditionalFolder($store, $folderid, $name, $type) {
// check if type is of a additional user type
if (!in_array($type, array(SYNC_FOLDER_TYPE_USER_CONTACT, SYNC_FOLDER_TYPE_USER_APPOINTMENT, SYNC_FOLDER_TYPE_USER_TASK, SYNC_FOLDER_TYPE_USER_MAIL, SYNC_FOLDER_TYPE_USER_NOTE, SYNC_FOLDER_TYPE_USER_JOURNAL))) {
ZLog::Write(LOGLEVEL_ERROR, sprintf("ASDevice->AddAdditionalFolder(): folder can not be added because the specified type '%s' is not a permitted user type.", $type));
......@@ -901,7 +900,6 @@ class ASDevice extends StateObject {
'folderid' => $folderid,
'name' => $name,
'type' => $type,
'readonly' => $readonly,
);
$this->additionalfolders = $af;
......
......@@ -78,7 +78,8 @@ class ChangesMemoryWrapper extends HierarchyCache implements IImportChanges, IEx
foreach($state as $addKey => $addFolder) {
ZLog::Write(LOGLEVEL_DEBUG, sprintf("ChangesMemoryWrapper->Config(AdditionalFolders) : process folder '%s'", $addFolder->displayname));
if (isset($addFolder->NoBackendFolder) && $addFolder->NoBackendFolder == true) {
$hasRights = ZPush::GetBackend()->Setup($addFolder->Store, true, $addFolder->BackendId, $addFolder->ReadOnly);
// check rights for readonly access only
$hasRights = ZPush::GetBackend()->Setup($addFolder->Store, true, $addFolder->BackendId, true);
// delete the folder on the device
if (! $hasRights) {
// delete the folder only if it was an additional folder before, else ignore it
......
......@@ -493,7 +493,7 @@ class DeviceManager {
public function GetAdditionalUserSyncFolders() {
$folders = array();
foreach($this->device->GetAdditionalFolders() as $df) {
$folder = $this->getAdditionalSyncFolder($df['store'], $df['folderid'], $df['name'], $df['type'], $df['readonly'], DeviceManager::FLD_ORIGIN_SHARED);
$folder = $this->getAdditionalSyncFolder($df['store'], $df['folderid'], $df['name'], $df['type'], DeviceManager::FLD_ORIGIN_SHARED);
$folders[$folder->BackendId] = $folder;
}
......@@ -501,7 +501,7 @@ class DeviceManager {
if (KOE_CAPABILITY_GAB && $this->IsKoe() && KOE_GAB_STORE != "" && KOE_GAB_NAME != "") {
// if KOE_GAB_FOLDERID is set, use it
if (KOE_GAB_FOLDERID != "") {
$folder = $this->getAdditionalSyncFolder(KOE_GAB_STORE, KOE_GAB_FOLDERID, KOE_GAB_NAME, SYNC_FOLDER_TYPE_USER_APPOINTMENT, true, DeviceManager::FLD_ORIGIN_GAB);
$folder = $this->getAdditionalSyncFolder(KOE_GAB_STORE, KOE_GAB_FOLDERID, KOE_GAB_NAME, SYNC_FOLDER_TYPE_USER_APPOINTMENT, DeviceManager::FLD_ORIGIN_GAB);
$folders[$folder->BackendId] = $folder;
}
else {
......@@ -518,7 +518,7 @@ class DeviceManager {
}
if ($backendGabId) {
$folders[$backendGabId] = $this->getAdditionalSyncFolder(KOE_GAB_STORE, $backendGabId, KOE_GAB_NAME, SYNC_FOLDER_TYPE_USER_APPOINTMENT, true, DeviceManager::FLD_ORIGIN_GAB);
$folders[$backendGabId] = $this->getAdditionalSyncFolder(KOE_GAB_STORE, $backendGabId, KOE_GAB_NAME, SYNC_FOLDER_TYPE_USER_APPOINTMENT, DeviceManager::FLD_ORIGIN_GAB);
}
}
}
......@@ -1141,13 +1141,12 @@ class DeviceManager {
* @param string $folderid
* @param string $name
* @param int $type
* @param boolean $readonly
* @param string $folderOrigin
*
* @access private
* @returns SyncFolder
*/
private function getAdditionalSyncFolder($store, $folderid, $name, $type, $readonly, $folderOrigin) {
private function getAdditionalSyncFolder($store, $folderid, $name, $type, $folderOrigin) {
$folder = new SyncFolder();
$folder->BackendId = $folderid;
$folder->serverid = $this->GetFolderIdForBackendId($folder->BackendId, true, $folderOrigin, $name);
......@@ -1157,7 +1156,6 @@ class DeviceManager {
// save store as custom property which is not streamed directly to the device
$folder->NoBackendFolder = true;
$folder->Store = $store;
$folder->ReadOnly = $readonly;
return $folder;
}
......
......@@ -415,7 +415,6 @@ class ZPush {
// save store as custom property which is not streamed directly to the device
$folder->NoBackendFolder = true;
$folder->Store = $af['store'];
$folder->ReadOnly = $af['readonly'];
self::$addSyncFolders[$folder->BackendId] = $folder;
}
......
......@@ -326,7 +326,6 @@ define("SYNC_FOLDERHIERARCHY_VERSION","FolderHierarchy:Version");
define("SYNC_FOLDERHIERARCHY_IGNORE_STORE","FolderHierarchy:IgnoreStore");
define("SYNC_FOLDERHIERARCHY_IGNORE_NOBCKENDFLD","FolderHierarchy:IgnoreNoBackendFolder");
define("SYNC_FOLDERHIERARCHY_IGNORE_BACKENDID","FolderHierarchy:IgnoreBackendId");
define("SYNC_FOLDERHIERARCHY_IGNORE_READONLY","FolderHierarchy:IgnoreReadOnly");
// MeetingResponse
define("SYNC_MEETINGRESPONSE_CALENDARID","MeetingResponse:CalendarId");
......
......@@ -54,7 +54,6 @@ class SyncFolder extends SyncObject {
public $Store;
public $NoBackendFolder;
public $BackendId;
public $ReadOnly;
function SyncFolder() {
$mapping = array (
......@@ -80,10 +79,6 @@ class SyncFolder extends SyncObject {
SYNC_FOLDERHIERARCHY_IGNORE_BACKENDID => array ( self::STREAMER_VAR => "BackendId",
self::STREAMER_TYPE => self::STREAMER_TYPE_IGNORE),
SYNC_FOLDERHIERARCHY_IGNORE_READONLY => array ( self::STREAMER_VAR => "ReadOnly",
self::STREAMER_TYPE => self::STREAMER_TYPE_IGNORE),
);
parent::SyncObject($mapping);
......
......@@ -505,7 +505,6 @@ class ZPushAdmin {
'syncfolderid' => $syncfolderid,
'name' => $so->displayname,
'type' => $so->type,
'readonly' => $so->ReadOnly,
'origin' => Utils::GetFolderOriginFromId($syncfolderid),
);
}
......@@ -529,12 +528,11 @@ class ZPushAdmin {
* @param string $add_folderid the folder id of the additional folder.
* @param string $add_name the name of the additional folder (has to be unique for all folders on the device).
* @param string $add_type AS foldertype of SYNC_FOLDER_TYPE_USER_*
* @param boolean $add_readonly Indicates if the folder should be synched if the user has at least read-only permissions.
*
* @access public
* @return boolean
*/
static public function AdditionalFolderAdd($user, $devid, $add_store, $add_folderid, $add_name, $add_type, $add_readonly) {
static public function AdditionalFolderAdd($user, $devid, $add_store, $add_folderid, $add_name, $add_type) {
// load device data
$device = new ASDevice($devid, ASDevice::UNDEFINED, $user, ASDevice::UNDEFINED);
try {
......@@ -551,7 +549,7 @@ class ZPushAdmin {
return false;
}
$status = $device->AddAdditionalFolder($add_store, $add_folderid, $add_name, $add_type, $add_readonly);
$status = $device->AddAdditionalFolder($add_store, $add_folderid, $add_name, $add_type);
if ($status)
ZPush::GetStateMachine()->SetState($device->GetData(), $devid, IStateMachine::DEVICEDATA);
......
......@@ -168,6 +168,15 @@ class WebserviceDevice {
$deviceId = preg_replace("/[^A-Za-z0-9]/", "", $deviceId);
$folders = ZPushAdmin::AdditionalFolderList($user, $deviceId);
ZLog::Write(LOGLEVEL_INFO, sprintf("WebserviceDevice::AdditionalFolderList(): found %d folders for device '%s' of user '%s'", count($folders), $deviceId, $user));
// retrieve the permission flags from the backend
$backend = ZPush::GetBackend();
foreach($folders as &$folder) {
$folder['readable'] = $backend->Setup($folder['store'], true, $folder['folderid'], true);
$folder['writeable'] = $backend->Setup($folder['store'], true, $folder['folderid']);
}
// make sure folder is not pointing to our last folder anymore
unset($folder);
ZPush::GetTopCollector()->AnnounceInformation(sprintf("Retrieved details of %d folders", count($folders)), true);
return $folders;
......@@ -181,19 +190,17 @@ class WebserviceDevice {
* @param string $add_folderid the folder id of the additional folder.
* @param string $add_name the name of the additional folder (has to be unique for all folders on the device).
* @param string $add_type AS foldertype of SYNC_FOLDER_TYPE_USER_*
* @param boolean $add_readonly Indicates if the folder should be synched if the user has at least read-only permissions.
*
* @access public
* @return boolean
*/
public function AdditionalFolderAdd($deviceId, $add_store, $add_folderid, $add_name, $add_type, $add_readonly) {
public function AdditionalFolderAdd($deviceId, $add_store, $add_folderid, $add_name, $add_type) {
$user = Request::GetGETUser();
$deviceId = preg_replace("/[^A-Za-z0-9]/", "", $deviceId);
$add_folderid = preg_replace("/[^A-Za-z0-9]/", "", $add_folderid);
$add_type = preg_replace("/[^0-9]/", "", $add_type);
$add_readonly = !! $add_readonly;
$status = ZPushAdmin::AdditionalFolderAdd($user, $deviceId, $add_store, $add_folderid, $add_name, $add_type, $add_readonly);
$status = ZPushAdmin::AdditionalFolderAdd($user, $deviceId, $add_store, $add_folderid, $add_name, $add_type);
if (!$status) {
ZPush::GetTopCollector()->AnnounceInformation(ZLog::GetLastMessage(LOGLEVEL_ERROR), true);
throw new SoapFault("ERROR", ZLog::GetLastMessage(LOGLEVEL_ERROR));
......
......@@ -62,7 +62,7 @@ class WebserviceInfo {
foreach ($folders as $folder) {
$folder->StripData();
unset($folder->Store, $folder->flags, $folder->content, $folder->NoBackendFolder, $folder->ReadOnly);
unset($folder->Store, $folder->flags, $folder->content, $folder->NoBackendFolder);
$output[] = $folder;
}
......
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