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 { ...@@ -238,7 +238,7 @@ class BackendKopano implements IBackend, ISearchProvider {
if ($user === false) if ($user === false)
$user = $this->mainUser; $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. // 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. // Configured that way the user could receive the same folderid twice, with two different names.
if ($this->mainUser == $user && $checkACLonly && $folderid) { if ($this->mainUser == $user && $checkACLonly && $folderid) {
......
...@@ -453,17 +453,16 @@ class ReplyBackImExporter implements IImportChanges, IExportChanges { ...@@ -453,17 +453,16 @@ class ReplyBackImExporter implements IImportChanges, IExportChanges {
$sourcekey = hex2bin($sk); $sourcekey = hex2bin($sk);
$parentsourcekey = hex2bin(ZPush::GetDeviceManager()->GetBackendIdForFolderId($fsk)); $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); $entryid = mapi_msgstore_entryidfromsourcekey($this->store, $parentsourcekey, $sourcekey);
if(!$entryid) { 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))); 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); $mapimessage = mapi_msgstore_openentry($this->store, $entryid);
try { try {
...@@ -484,8 +483,7 @@ class ReplyBackImExporter implements IImportChanges, IExportChanges { ...@@ -484,8 +483,7 @@ class ReplyBackImExporter implements IImportChanges, IExportChanges {
} }
ZPush::GetDeviceManager()->AnnounceIgnoredMessage(false, $brokenSO->id, $brokenSO); ZPush::GetDeviceManager()->AnnounceIgnoredMessage(false, $brokenSO->id, $brokenSO);
} }
// tell MAPI to ignore the message return false;
return $status;
} }
} }
return $message; return $message;
......
...@@ -345,8 +345,6 @@ ...@@ -345,8 +345,6 @@
* SYNC_FOLDER_TYPE_USER_TASK * SYNC_FOLDER_TYPE_USER_TASK
* SYNC_FOLDER_TYPE_USER_MAIL * SYNC_FOLDER_TYPE_USER_MAIL
* SYNC_FOLDER_TYPE_USER_NOTE * 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: * Additional notes:
* - on Kopano systems use backend/kopano/listfolders.php script to get a list * - on Kopano systems use backend/kopano/listfolders.php script to get a list
...@@ -379,7 +377,6 @@ ...@@ -379,7 +377,6 @@
'folderid' => "", 'folderid' => "",
'name' => "Public Contacts", 'name' => "Public Contacts",
'type' => SYNC_FOLDER_TYPE_USER_CONTACT, 'type' => SYNC_FOLDER_TYPE_USER_CONTACT,
'readonly' => false,
), ),
*/ */
); );
...@@ -854,12 +854,11 @@ class ASDevice extends StateObject { ...@@ -854,12 +854,11 @@ class ASDevice extends StateObject {
* @param string $folderid the folder id of the additional folder. * @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 $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 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 * @access public
* @return boolean * @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 // 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))) { 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)); 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 { ...@@ -901,7 +900,6 @@ class ASDevice extends StateObject {
'folderid' => $folderid, 'folderid' => $folderid,
'name' => $name, 'name' => $name,
'type' => $type, 'type' => $type,
'readonly' => $readonly,
); );
$this->additionalfolders = $af; $this->additionalfolders = $af;
......
...@@ -78,7 +78,8 @@ class ChangesMemoryWrapper extends HierarchyCache implements IImportChanges, IEx ...@@ -78,7 +78,8 @@ class ChangesMemoryWrapper extends HierarchyCache implements IImportChanges, IEx
foreach($state as $addKey => $addFolder) { foreach($state as $addKey => $addFolder) {
ZLog::Write(LOGLEVEL_DEBUG, sprintf("ChangesMemoryWrapper->Config(AdditionalFolders) : process folder '%s'", $addFolder->displayname)); ZLog::Write(LOGLEVEL_DEBUG, sprintf("ChangesMemoryWrapper->Config(AdditionalFolders) : process folder '%s'", $addFolder->displayname));
if (isset($addFolder->NoBackendFolder) && $addFolder->NoBackendFolder == true) { 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 // delete the folder on the device
if (! $hasRights) { if (! $hasRights) {
// delete the folder only if it was an additional folder before, else ignore it // delete the folder only if it was an additional folder before, else ignore it
......
...@@ -493,7 +493,7 @@ class DeviceManager { ...@@ -493,7 +493,7 @@ class DeviceManager {
public function GetAdditionalUserSyncFolders() { public function GetAdditionalUserSyncFolders() {
$folders = array(); $folders = array();
foreach($this->device->GetAdditionalFolders() as $df) { 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; $folders[$folder->BackendId] = $folder;
} }
...@@ -501,7 +501,7 @@ class DeviceManager { ...@@ -501,7 +501,7 @@ class DeviceManager {
if (KOE_CAPABILITY_GAB && $this->IsKoe() && KOE_GAB_STORE != "" && KOE_GAB_NAME != "") { if (KOE_CAPABILITY_GAB && $this->IsKoe() && KOE_GAB_STORE != "" && KOE_GAB_NAME != "") {
// if KOE_GAB_FOLDERID is set, use it // if KOE_GAB_FOLDERID is set, use it
if (KOE_GAB_FOLDERID != "") { 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; $folders[$folder->BackendId] = $folder;
} }
else { else {
...@@ -518,7 +518,7 @@ class DeviceManager { ...@@ -518,7 +518,7 @@ class DeviceManager {
} }
if ($backendGabId) { 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 { ...@@ -1141,13 +1141,12 @@ class DeviceManager {
* @param string $folderid * @param string $folderid
* @param string $name * @param string $name
* @param int $type * @param int $type
* @param boolean $readonly
* @param string $folderOrigin * @param string $folderOrigin
* *
* @access private * @access private
* @returns SyncFolder * @returns SyncFolder
*/ */
private function getAdditionalSyncFolder($store, $folderid, $name, $type, $readonly, $folderOrigin) { private function getAdditionalSyncFolder($store, $folderid, $name, $type, $folderOrigin) {
$folder = new SyncFolder(); $folder = new SyncFolder();
$folder->BackendId = $folderid; $folder->BackendId = $folderid;
$folder->serverid = $this->GetFolderIdForBackendId($folder->BackendId, true, $folderOrigin, $name); $folder->serverid = $this->GetFolderIdForBackendId($folder->BackendId, true, $folderOrigin, $name);
...@@ -1157,7 +1156,6 @@ class DeviceManager { ...@@ -1157,7 +1156,6 @@ class DeviceManager {
// save store as custom property which is not streamed directly to the device // save store as custom property which is not streamed directly to the device
$folder->NoBackendFolder = true; $folder->NoBackendFolder = true;
$folder->Store = $store; $folder->Store = $store;
$folder->ReadOnly = $readonly;
return $folder; return $folder;
} }
......
...@@ -415,7 +415,6 @@ class ZPush { ...@@ -415,7 +415,6 @@ class ZPush {
// save store as custom property which is not streamed directly to the device // save store as custom property which is not streamed directly to the device
$folder->NoBackendFolder = true; $folder->NoBackendFolder = true;
$folder->Store = $af['store']; $folder->Store = $af['store'];
$folder->ReadOnly = $af['readonly'];
self::$addSyncFolders[$folder->BackendId] = $folder; self::$addSyncFolders[$folder->BackendId] = $folder;
} }
......
...@@ -326,7 +326,6 @@ define("SYNC_FOLDERHIERARCHY_VERSION","FolderHierarchy:Version"); ...@@ -326,7 +326,6 @@ define("SYNC_FOLDERHIERARCHY_VERSION","FolderHierarchy:Version");
define("SYNC_FOLDERHIERARCHY_IGNORE_STORE","FolderHierarchy:IgnoreStore"); define("SYNC_FOLDERHIERARCHY_IGNORE_STORE","FolderHierarchy:IgnoreStore");
define("SYNC_FOLDERHIERARCHY_IGNORE_NOBCKENDFLD","FolderHierarchy:IgnoreNoBackendFolder"); define("SYNC_FOLDERHIERARCHY_IGNORE_NOBCKENDFLD","FolderHierarchy:IgnoreNoBackendFolder");
define("SYNC_FOLDERHIERARCHY_IGNORE_BACKENDID","FolderHierarchy:IgnoreBackendId"); define("SYNC_FOLDERHIERARCHY_IGNORE_BACKENDID","FolderHierarchy:IgnoreBackendId");
define("SYNC_FOLDERHIERARCHY_IGNORE_READONLY","FolderHierarchy:IgnoreReadOnly");
// MeetingResponse // MeetingResponse
define("SYNC_MEETINGRESPONSE_CALENDARID","MeetingResponse:CalendarId"); define("SYNC_MEETINGRESPONSE_CALENDARID","MeetingResponse:CalendarId");
......
...@@ -54,7 +54,6 @@ class SyncFolder extends SyncObject { ...@@ -54,7 +54,6 @@ class SyncFolder extends SyncObject {
public $Store; public $Store;
public $NoBackendFolder; public $NoBackendFolder;
public $BackendId; public $BackendId;
public $ReadOnly;
function SyncFolder() { function SyncFolder() {
$mapping = array ( $mapping = array (
...@@ -80,10 +79,6 @@ class SyncFolder extends SyncObject { ...@@ -80,10 +79,6 @@ class SyncFolder extends SyncObject {
SYNC_FOLDERHIERARCHY_IGNORE_BACKENDID => array ( self::STREAMER_VAR => "BackendId", SYNC_FOLDERHIERARCHY_IGNORE_BACKENDID => array ( self::STREAMER_VAR => "BackendId",
self::STREAMER_TYPE => self::STREAMER_TYPE_IGNORE), 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); parent::SyncObject($mapping);
......
...@@ -505,7 +505,6 @@ class ZPushAdmin { ...@@ -505,7 +505,6 @@ class ZPushAdmin {
'syncfolderid' => $syncfolderid, 'syncfolderid' => $syncfolderid,
'name' => $so->displayname, 'name' => $so->displayname,
'type' => $so->type, 'type' => $so->type,
'readonly' => $so->ReadOnly,
'origin' => Utils::GetFolderOriginFromId($syncfolderid), 'origin' => Utils::GetFolderOriginFromId($syncfolderid),
); );
} }
...@@ -529,12 +528,11 @@ class ZPushAdmin { ...@@ -529,12 +528,11 @@ class ZPushAdmin {
* @param string $add_folderid the folder id of the additional folder. * @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_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 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 * @access public
* @return boolean * @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 // load device data
$device = new ASDevice($devid, ASDevice::UNDEFINED, $user, ASDevice::UNDEFINED); $device = new ASDevice($devid, ASDevice::UNDEFINED, $user, ASDevice::UNDEFINED);
try { try {
...@@ -551,7 +549,7 @@ class ZPushAdmin { ...@@ -551,7 +549,7 @@ class ZPushAdmin {
return false; 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) if ($status)
ZPush::GetStateMachine()->SetState($device->GetData(), $devid, IStateMachine::DEVICEDATA); ZPush::GetStateMachine()->SetState($device->GetData(), $devid, IStateMachine::DEVICEDATA);
......
...@@ -168,6 +168,15 @@ class WebserviceDevice { ...@@ -168,6 +168,15 @@ class WebserviceDevice {
$deviceId = preg_replace("/[^A-Za-z0-9]/", "", $deviceId); $deviceId = preg_replace("/[^A-Za-z0-9]/", "", $deviceId);
$folders = ZPushAdmin::AdditionalFolderList($user, $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)); 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); ZPush::GetTopCollector()->AnnounceInformation(sprintf("Retrieved details of %d folders", count($folders)), true);
return $folders; return $folders;
...@@ -181,19 +190,17 @@ class WebserviceDevice { ...@@ -181,19 +190,17 @@ class WebserviceDevice {
* @param string $add_folderid the folder id of the additional folder. * @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_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 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 * @access public
* @return boolean * @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(); $user = Request::GetGETUser();
$deviceId = preg_replace("/[^A-Za-z0-9]/", "", $deviceId); $deviceId = preg_replace("/[^A-Za-z0-9]/", "", $deviceId);
$add_folderid = preg_replace("/[^A-Za-z0-9]/", "", $add_folderid); $add_folderid = preg_replace("/[^A-Za-z0-9]/", "", $add_folderid);
$add_type = preg_replace("/[^0-9]/", "", $add_type); $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) { if (!$status) {
ZPush::GetTopCollector()->AnnounceInformation(ZLog::GetLastMessage(LOGLEVEL_ERROR), true); ZPush::GetTopCollector()->AnnounceInformation(ZLog::GetLastMessage(LOGLEVEL_ERROR), true);
throw new SoapFault("ERROR", ZLog::GetLastMessage(LOGLEVEL_ERROR)); throw new SoapFault("ERROR", ZLog::GetLastMessage(LOGLEVEL_ERROR));
......
...@@ -62,7 +62,7 @@ class WebserviceInfo { ...@@ -62,7 +62,7 @@ class WebserviceInfo {
foreach ($folders as $folder) { foreach ($folders as $folder) {
$folder->StripData(); $folder->StripData();
unset($folder->Store, $folder->flags, $folder->content, $folder->NoBackendFolder, $folder->ReadOnly); unset($folder->Store, $folder->flags, $folder->content, $folder->NoBackendFolder);
$output[] = $folder; $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