app.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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. \OCP\Util::addStyle('files_sharing', 'icons');
  42. }
  43. );
  44. \OC::$server->getEventDispatcher()->addListener('\OCP\Collaboration\Resources::loadAdditionalScripts', function () {
  45. \OCP\Util::addScript('files_sharing', 'dist/collaboration');
  46. });
  47. $config = \OC::$server->getConfig();
  48. $shareManager = \OC::$server->getShareManager();
  49. $userSession = \OC::$server->getUserSession();
  50. $l = \OC::$server->getL10N('files_sharing');
  51. if ($config->getAppValue('core', 'shareapi_enabled', 'yes') === 'yes') {
  52. $sharingSublistArray = [];
  53. if (\OCP\Util::isSharingDisabledForUser() === false) {
  54. array_push($sharingSublistArray, [
  55. 'id' => 'sharingout',
  56. 'appname' => 'files_sharing',
  57. 'script' => 'list.php',
  58. 'order' => 16,
  59. 'name' => $l->t('Shared with others'),
  60. ]);
  61. }
  62. array_push($sharingSublistArray, [
  63. 'id' => 'sharingin',
  64. 'appname' => 'files_sharing',
  65. 'script' => 'list.php',
  66. 'order' => 15,
  67. 'name' => $l->t('Shared with you'),
  68. ]);
  69. if (\OCP\Util::isSharingDisabledForUser() === false) {
  70. // Check if sharing by link is enabled
  71. if ($config->getAppValue('core', 'shareapi_allow_links', 'yes') === 'yes') {
  72. array_push($sharingSublistArray, [
  73. 'id' => 'sharinglinks',
  74. 'appname' => 'files_sharing',
  75. 'script' => 'list.php',
  76. 'order' => 17,
  77. 'name' => $l->t('Shared by link'),
  78. ]);
  79. }
  80. }
  81. array_push($sharingSublistArray, [
  82. 'id' => 'deletedshares',
  83. 'appname' => 'files_sharing',
  84. 'script' => 'list.php',
  85. 'order' => 19,
  86. 'name' => $l->t('Deleted shares'),
  87. ]);
  88. // show_Quick_Access stored as string
  89. $user = $userSession->getUser();
  90. $defaultExpandedState = true;
  91. if ($user instanceof \OCP\IUser) {
  92. $defaultExpandedState = $config->getUserValue($userSession->getUser()->getUID(), 'files', 'show_sharing_menu', '0') === '1';
  93. }
  94. \OCA\Files\App::getNavigationManager()->add([
  95. 'id' => 'shareoverview',
  96. 'appname' => 'files_sharing',
  97. 'script' => 'list.php',
  98. 'order' => 18,
  99. 'name' => $l->t('Shares'),
  100. 'classes' => 'collapsible',
  101. 'sublist' => $sharingSublistArray,
  102. 'expandedState' => 'show_sharing_menu'
  103. ]);
  104. }