You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

permissions.php 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <?php
  2. /**
  3. * ownCloud
  4. *
  5. * @author Michael Gapczynski
  6. * @copyright 2012 Michael Gapczynski mtgap@owncloud.com
  7. *
  8. * This library is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
  10. * License as published by the Free Software Foundation; either
  11. * version 3 of the License, or any later version.
  12. *
  13. * This library is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
  17. *
  18. * You should have received a copy of the GNU Affero General Public
  19. * License along with this library. If not, see <http://www.gnu.org/licenses/>.
  20. */
  21. namespace OC\Files\Cache;
  22. class Shared_Permissions extends Permissions {
  23. /**
  24. * get the permissions for a single file
  25. *
  26. * @param int $fileId
  27. * @param string $user
  28. * @return int permissions
  29. */
  30. public function get($fileId, $user) {
  31. $permissions = $this->storage->getPermissions();
  32. return $this->updatePermissions($permissions);
  33. }
  34. /**
  35. * @param integer $fileId
  36. * @param string $user
  37. */
  38. private function getFile($fileId, $user) {
  39. return $this->get($fileId, $user);
  40. }
  41. /**
  42. * set the permissions of a file
  43. *
  44. * @param int $fileId
  45. * @param string $user
  46. * @param int $permissions
  47. */
  48. public function set($fileId, $user, $permissions) {
  49. // Not a valid action for Shared Permissions
  50. }
  51. /**
  52. * get the permissions of multiply files
  53. *
  54. * @param int[] $fileIds
  55. * @param string $user
  56. * @return int[]
  57. */
  58. public function getMultiple($fileIds, $user) {
  59. $filePermissions = array();
  60. foreach ($fileIds as $fileId) {
  61. $filePermissions[$fileId] = $this->get($fileId, $user);
  62. }
  63. return $filePermissions;
  64. }
  65. /**
  66. * get the permissions for all files in a folder
  67. *
  68. * @param int $parentId
  69. * @param string $user
  70. * @return int[]
  71. */
  72. public function getDirectoryPermissions($parentId, $user) {
  73. if ($parentId === -1 && $this->storage->instanceOfStorage('\OC\Files\Storage\Shared')) {
  74. $fileCacheId = $this->storage->getSourceId();
  75. } else {
  76. $fileCacheId = $parentId;
  77. }
  78. $query = \OC_DB::prepare('SELECT `fileid` FROM `*PREFIX*filecache` WHERE `parent` = ?');
  79. $result = $query->execute(array($fileCacheId));
  80. $permissions = $this->get($parentId, $user);
  81. $filePermissions = array();
  82. while ($row = $result->fetchRow()) {
  83. $filePermissions[$row['fileid']] = $permissions;
  84. }
  85. return $filePermissions;
  86. }
  87. /**
  88. * remove the permissions for a file
  89. *
  90. * @param int $fileId
  91. * @param string $user
  92. */
  93. public function remove($fileId, $user = null) {
  94. // Not a valid action for Shared Permissions
  95. }
  96. public function removeMultiple($fileIds, $user) {
  97. // Not a valid action for Shared Permissions
  98. }
  99. }