Commit 6c375d9e4ab99b0ac2b52e4aee32a5c09f4a51d8

Authored by conradverm
1 parent 2cc34b6a

WSA-113

"Implement returning of basic permissions returned by get_listing() and document detail."
Fixed.

Committed By: Conrad Vermeulen
Reviewed By: Megan Watson

git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@8233 c91229c3-7414-0410-bfa2-8a42b809f60b
ktapi/KTAPIDocument.inc.php
@@ -1443,6 +1443,16 @@ class KTAPI_Document extends KTAPI_FolderItem @@ -1443,6 +1443,16 @@ class KTAPI_Document extends KTAPI_FolderItem
1443 1443
1444 } 1444 }
1445 1445
  1446 + function get_permissions($document)
  1447 + {
  1448 + $perms = 'R';
  1449 + if (Permission::userHasDocumentWritePermission($document))
  1450 + {
  1451 + $perms .= 'W';
  1452 + }
  1453 + return $perms;
  1454 + }
  1455 +
1446 /** 1456 /**
1447 * This returns detailed information on the document. 1457 * This returns detailed information on the document.
1448 * 1458 *
@@ -1587,7 +1597,7 @@ class KTAPI_Document extends KTAPI_FolderItem @@ -1587,7 +1597,7 @@ class KTAPI_Document extends KTAPI_FolderItem
1587 $detail['is_immutable'] = (bool) $document->getImmutable(); 1597 $detail['is_immutable'] = (bool) $document->getImmutable();
1588 1598
1589 // check permissions 1599 // check permissions
1590 - $detail['permissions'] = 'n/a'; 1600 + $detail['permissions'] = KTWSAPI_Document::get_permissions($document);
1591 1601
1592 // get workflow name 1602 // get workflow name
1593 $workflowid = $document->getWorkflowId(); 1603 $workflowid = $document->getWorkflowId();
ktapi/KTAPIFolder.inc.php
@@ -321,6 +321,16 @@ class KTAPI_Folder extends KTAPI_FolderItem @@ -321,6 +321,16 @@ class KTAPI_Folder extends KTAPI_FolderItem
321 return $user; 321 return $user;
322 } 322 }
323 323
  324 + function get_permissions($folder)
  325 + {
  326 + $perms = 'R';
  327 + if (Permission::userHasFolderWritePermission($folder))
  328 + {
  329 + $perms .= 'W';
  330 + }
  331 + return $perms;
  332 + }
  333 +
324 function get_listing($depth=1, $what='DF') 334 function get_listing($depth=1, $what='DF')
325 { 335 {
326 if ($depth < 1) 336 if ($depth < 1)
@@ -389,7 +399,7 @@ class KTAPI_Folder extends KTAPI_FolderItem @@ -389,7 +399,7 @@ class KTAPI_Folder extends KTAPI_FolderItem
389 'version' => 'n/a', 399 'version' => 'n/a',
390 400
391 'is_immutable'=> 'n/a', 401 'is_immutable'=> 'n/a',
392 - 'permissions' => 'n/a', 402 + 'permissions' => KTWSAPI_Folder::get_permissions($folder),
393 403
394 'workflow'=>'n/a', 404 'workflow'=>'n/a',
395 'workflow_state'=>'n/a', 405 'workflow_state'=>'n/a',
@@ -523,7 +533,7 @@ class KTAPI_Folder extends KTAPI_FolderItem @@ -523,7 +533,7 @@ class KTAPI_Folder extends KTAPI_FolderItem
523 'version' => $document->getMajorVersionNumber() . '.' . $document->getMinorVersionNumber(), 533 'version' => $document->getMajorVersionNumber() . '.' . $document->getMinorVersionNumber(),
524 534
525 'is_immutable'=> $document->getImmutable()?'true':'false', 535 'is_immutable'=> $document->getImmutable()?'true':'false',
526 - 'permissions' => 'n/a', 536 + 'permissions' => KTWSAPI_Document::get_permissions($document),
527 537
528 'workflow'=> $workflow, 538 'workflow'=> $workflow,
529 'workflow_state'=> $state, 539 'workflow_state'=> $state,