elfinder.drupalfs.acl.inc 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. <?php
  2. /**
  3. * elFinder Integration
  4. *
  5. * Copyright (c) 2010-2018, Alexey Sukhotin. All rights reserved.
  6. */
  7. /**
  8. * @file
  9. * elfinder ACL class
  10. */
  11. class elFinderDrupalACL {
  12. public function fsAccessPublic($attr, $path, $data, $volume) {
  13. if (strpos(basename($path), '.') === 0 && $attr == 'hidden') {
  14. return TRUE;
  15. }
  16. /* Hiding thumbnail folder */
  17. if (strstr($path, DIRECTORY_SEPARATOR . variable_get('elfinder_settings_thumbnail_dirname', 'tmb')) && $attr == 'hidden') {
  18. return TRUE;
  19. }
  20. // Hide folders hidden by config settings.
  21. $f = drupal_realpath("public://") . "/";
  22. $folder = str_replace($f, "", $path);
  23. $hidden_folder = preg_split("/[\s,]+/", variable_get('elfinder_settings_misc_hidden_folders', ''));
  24. if (in_array($folder, $hidden_folder) && $attr == 'hidden') {
  25. return TRUE;
  26. }
  27. if (strstr($path, DIRECTORY_SEPARATOR . '.quarantine') && $attr == 'hidden') {
  28. return TRUE;
  29. }
  30. if ($attr == 'read') {
  31. return TRUE;
  32. }
  33. if ($attr == 'write') {
  34. return TRUE;
  35. }
  36. /* if ($attr == 'write' && user_access('write public files')) {
  37. return TRUE;
  38. }
  39. if ($attr == 'locked' && !user_access('write public files')) {
  40. return TRUE;
  41. } */
  42. return FALSE;
  43. }
  44. public function fsAccessPrivate($attr, $path, $data, $volume) {
  45. if (strpos(basename($path), '.') === 0 && $attr == 'hidden') {
  46. return TRUE;
  47. }
  48. /* Hiding thumbnail folder */
  49. if (strstr($path, DIRECTORY_SEPARATOR . variable_get('elfinder_settings_thumbnail_dirname', 'tmb')) && $attr == 'hidden') {
  50. return TRUE;
  51. }
  52. if (strstr($path, DIRECTORY_SEPARATOR . '.quarantine') && $attr == 'hidden') {
  53. return TRUE;
  54. }
  55. if ($attr == 'read') {
  56. return TRUE;
  57. }
  58. if ($attr == 'write') {
  59. return TRUE;
  60. }
  61. /* if ($attr == 'write' && user_access('write public files')) {
  62. return TRUE;
  63. }
  64. if ($attr == 'locked' && !user_access('write public files')) {
  65. return TRUE;
  66. } */
  67. return FALSE;
  68. }
  69. public function fsAccessUnmanaged($attr, $path, $data, $volume) {
  70. if (strpos(basename($path), '.') === 0 && $attr == 'hidden') {
  71. return TRUE;
  72. }
  73. /* Hiding thumbnail folder */
  74. if (strstr($path, DIRECTORY_SEPARATOR . variable_get('elfinder_settings_thumbnail_dirname', 'tmb')) && $attr == 'hidden') {
  75. return TRUE;
  76. }
  77. if (strstr($path, DIRECTORY_SEPARATOR . '.quarantine') && $attr == 'hidden') {
  78. return TRUE;
  79. }
  80. if ($attr == 'read') {
  81. return TRUE;
  82. }
  83. return FALSE;
  84. }
  85. }