App.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Bart Visscher <bartv@thisnet.nl>
  6. * @author Frank Karlitschek <frank@karlitschek.de>
  7. * @author Georg Ehrke <georg@owncloud.com>
  8. * @author Joas Schilling <coding@schilljs.com>
  9. * @author Jörn Friedrich Dreyer <jfd@butonic.de>
  10. * @author Morris Jobke <hey@morrisjobke.de>
  11. * @author Robin McCorkell <robin@mccorkell.me.uk>
  12. * @author Thomas Müller <thomas.mueller@tmit.eu>
  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. /**
  30. * Public interface of ownCloud for apps to use.
  31. * App Class
  32. *
  33. */
  34. // use OCP namespace for all classes that are considered public.
  35. // This means that they should be used by apps instead of the internal ownCloud classes
  36. namespace OCP;
  37. /**
  38. * This class provides functions to manage apps in ownCloud
  39. * @since 4.0.0
  40. */
  41. class App {
  42. /**
  43. * Adds an entry to the navigation
  44. *
  45. * This function adds a new entry to the navigation visible to users. $data
  46. * is an associative array.
  47. * The following keys are required:
  48. * - id: unique id for this entry ('addressbook_index')
  49. * - href: link to the page
  50. * - name: Human readable name ('Addressbook')
  51. *
  52. * The following keys are optional:
  53. * - icon: path to the icon of the app
  54. * - order: integer, that influences the position of your application in
  55. * the navigation. Lower values come first.
  56. *
  57. * @param array $data containing the data
  58. * @return boolean
  59. *
  60. * @deprecated 8.1.0 Use \OC::$server->getNavigationManager()->add() instead to
  61. * register a closure, this helps to speed up all requests against ownCloud
  62. * @since 4.0.0
  63. */
  64. public static function addNavigationEntry($data) {
  65. \OC::$server->getNavigationManager()->add($data);
  66. return true;
  67. }
  68. /**
  69. * Marks a navigation entry as active
  70. * @param string $id id of the entry
  71. * @return boolean
  72. *
  73. * This function sets a navigation entry as active and removes the 'active'
  74. * property from all other entries. The templates can use this for
  75. * highlighting the current position of the user.
  76. *
  77. * @deprecated 8.1.0 Use \OC::$server->getNavigationManager()->setActiveEntry() instead
  78. * @since 4.0.0
  79. */
  80. public static function setActiveNavigationEntry( $id ) {
  81. \OC::$server->getNavigationManager()->setActiveEntry($id);
  82. return true;
  83. }
  84. /**
  85. * Register a Configuration Screen that should appear in the personal settings section.
  86. * @param string $app appid
  87. * @param string $page page to be included
  88. * @return void
  89. * @since 4.0.0
  90. */
  91. public static function registerPersonal( $app, $page ) {
  92. \OC_App::registerPersonal( $app, $page );
  93. }
  94. /**
  95. * Register a Configuration Screen that should appear in the Admin section.
  96. * @param string $app string appid
  97. * @param string $page string page to be included
  98. * @return void
  99. * @since 4.0.0
  100. */
  101. public static function registerAdmin( $app, $page ) {
  102. \OC_App::registerAdmin( $app, $page );
  103. }
  104. /**
  105. * Read app metadata from the info.xml file
  106. * @param string $app id of the app or the path of the info.xml file
  107. * @param boolean $path (optional)
  108. * @return array|null
  109. * @since 4.0.0
  110. */
  111. public static function getAppInfo( $app, $path=false ) {
  112. return \OC_App::getAppInfo( $app, $path);
  113. }
  114. /**
  115. * checks whether or not an app is enabled
  116. * @param string $app
  117. * @return boolean
  118. *
  119. * This function checks whether or not an app is enabled.
  120. * @since 4.0.0
  121. */
  122. public static function isEnabled( $app ) {
  123. return \OC_App::isEnabled( $app );
  124. }
  125. /**
  126. * Check if the app is enabled, redirects to home if not
  127. * @param string $app
  128. * @return void
  129. * @since 4.0.0
  130. * @deprecated 9.0.0 ownCloud core will handle disabled apps and redirects to valid URLs
  131. */
  132. public static function checkAppEnabled( $app ) {
  133. }
  134. /**
  135. * Get the last version of the app from appinfo/info.xml
  136. * @param string $app
  137. * @return string
  138. * @since 4.0.0
  139. */
  140. public static function getAppVersion( $app ) {
  141. return \OC_App::getAppVersion( $app );
  142. }
  143. }