app.php 3.5 KB

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