Antoine Lyset

How to know if we can share a note ?

Recommended Posts

All the notes in the user's account are editable by the owner. It gets more tricky with notebooks that are shared by other users (learn more about sharing here). The list of all other users' notebooks are defined by linked notebooks. A reference of that sharing is stored in the owner's account as a SharedNotebook that contains the permissions given to other users. Here is a portion of code to help you understand how to get the sharednotebook and access the permissions:


$linkedNotebook = current($linkedNotebooks);
$parts = parse_url($linkedNotebook->noteStoreUrl);
if (!isset($parts['port'])) {
if ($parts['scheme'] === 'https') {
$parts['port'] = 443;
} else {
$parts['port'] = 80;
}
}
$sharedNoteStoreHttpClient =
new THttpClient($parts['host'], $parts['port'], $parts['path'], $parts['scheme']);
$sharedNoteStoreProtocol = new TBinaryProtocol($sharedNoteStoreHttpClient);
$sharedNoteStore = new NoteStoreClient($sharedNoteStoreProtocol, $sharedNoteStoreProtocol);
$sharedAuthResult =
$sharedNoteStore->authenticateToSharedNotebook($linkedNotebook->shareKey, $authToken);
$sharedAuthToken = $sharedAuthResult->authenticationToken;
$sharedNotebook = $sharedNoteStore->getSharedNotebookByAuth($sharedAuthToken);
// permissions are stored in $sharedNotebook-> notebookModifiable

Share this post


Link to post

The PrivilegeLevel GROUP is only used in a business context when sharing with the entire company. It is designed to propagate sharing configuration changes for notebooks that are in the Business library. The associated privilege level for those notebook are inherited from the Notebook.businessNotebook field.

Here is an example: if I share a notebook in read only mode with all the users in my business (sharedNotebook.SharedNotebookPrivilegeLevel = 3 and Notebook.businessNotebook = 1) and later decide to make it editable (sharedNotebook.SharedNotebookPrivilegeLevel = 3 and Notebook.businessNotebook = 5) all the users that have the previous permissions get full access as well.

Share this post


Link to post