app.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Björn Schießle <bjoern@schiessle.org>
  6. * @author Gadzy <dev@gadzy.fr>
  7. * @author Jan-Christoph Borchardt <hey@jancborchardt.net>
  8. * @author Jörn Friedrich Dreyer <jfd@butonic.de>
  9. * @author Morris Jobke <hey@morrisjobke.de>
  10. * @author Robin Appelman <robin@icewind.nl>
  11. * @author Roeland Jago Douma <roeland@famdouma.nl>
  12. * @author Vincent Petry <pvince81@owncloud.com>
  13. *
  14. * @license AGPL-3.0
  15. *
  16. * This code is free software: you can redistribute it and/or modify
  17. * it under the terms of the GNU Affero General Public License, version 3,
  18. * as published by the Free Software Foundation.
  19. *
  20. * This program is distributed in the hope that it will be useful,
  21. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  22. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  23. * GNU Affero General Public License for more details.
  24. *
  25. * You should have received a copy of the GNU Affero General Public License, version 3,
  26. * along with this program. If not, see <http://www.gnu.org/licenses/>
  27. *
  28. */
  29. use OCA\Files_Sharing\ShareBackend\File;
  30. use OCA\Files_Sharing\ShareBackend\Folder;
  31. \OCA\Files_Sharing\Helper::registerHooks();
  32. \OC\Share\Share::registerBackend('file', File::class);
  33. \OC\Share\Share::registerBackend('folder', Folder::class, 'file');
  34. $application = new \OCA\Files_Sharing\AppInfo\Application();
  35. $application->registerMountProviders();
  36. $eventDispatcher = \OC::$server->getEventDispatcher();
  37. $eventDispatcher->addListener(
  38. 'OCA\Files::loadAdditionalScripts',
  39. function() {
  40. \OCP\Util::addScript('files_sharing', 'dist/additionalScripts');
  41. }
  42. );
  43. \OC::$server->getEventDispatcher()->addListener('\OCP\Collaboration\Resources::loadAdditionalScripts', function () {
  44. \OCP\Util::addScript('files_sharing', 'dist/collaboration');
  45. });
  46. $config = \OC::$server->getConfig();
  47. $shareManager = \OC::$server->getShareManager();
  48. $userSession = \OC::$server->getUserSession();
  49. $l = \OC::$server->getL10N('files_sharing');
  50. if ($config->getAppValue('core', 'shareapi_enabled', 'yes') === 'yes') {
  51. $sharingSublistArray = [];
  52. if (\OCP\Util::isSharingDisabledForUser() === false) {
  53. array_push($sharingSublistArray, [
  54. 'id' => 'sharingout',
  55. 'appname' => 'files_sharing',
  56. 'script' => 'list.php',
  57. 'order' => 16,
  58. 'name' => $l->t('Shared with others'),
  59. ]);
  60. }
  61. array_push($sharingSublistArray, [
  62. 'id' => 'sharingin',
  63. 'appname' => 'files_sharing',
  64. 'script' => 'list.php',
  65. 'order' => 15,
  66. 'name' => $l->t('Shared with you'),
  67. ]);
  68. if (\OCP\Util::isSharingDisabledForUser() === false) {
  69. // Check if sharing by link is enabled
  70. if ($config->getAppValue('core', 'shareapi_allow_links', 'yes') === 'yes') {
  71. array_push($sharingSublistArray, [
  72. 'id' => 'sharinglinks',
  73. 'appname' => 'files_sharing',
  74. 'script' => 'list.php',
  75. 'order' => 17,
  76. 'name' => $l->t('Shared by link'),
  77. ]);
  78. }
  79. }
  80. array_push($sharingSublistArray, [
  81. 'id' => 'deletedshares',
  82. 'appname' => 'files_sharing',
  83. 'script' => 'list.php',
  84. 'order' => 19,
  85. 'name' => $l->t('Deleted shares'),
  86. ]);
  87. // show_Quick_Access stored as string
  88. $user = $userSession->getUser();
  89. $defaultExpandedState = true;
  90. if ($user instanceof \OCP\IUser) {
  91. $defaultExpandedState = $config->getUserValue($userSession->getUser()->getUID(), 'files', 'show_sharing_menu', '0') === '1';
  92. }
  93. \OCA\Files\App::getNavigationManager()->add([
  94. 'id' => 'shareoverview',
  95. 'appname' => 'files_sharing',
  96. 'script' => 'list.php',
  97. 'order' => 18,
  98. 'name' => $l->t('Shares'),
  99. 'classes' => 'collapsible',
  100. 'sublist' => $sharingSublistArray,
  101. 'expandedState' => 'show_sharing_menu'
  102. ]);
  103. }