app.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  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. * @author Vincent Petry <pvince81@owncloud.com>
  14. *
  15. * @license AGPL-3.0
  16. *
  17. * This code is free software: you can redistribute it and/or modify
  18. * it under the terms of the GNU Affero General Public License, version 3,
  19. * as published by the Free Software Foundation.
  20. *
  21. * This program is distributed in the hope that it will be useful,
  22. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  23. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  24. * GNU Affero General Public License for more details.
  25. *
  26. * You should have received a copy of the GNU Affero General Public License, version 3,
  27. * along with this program. If not, see <http://www.gnu.org/licenses/>
  28. *
  29. */
  30. /**
  31. * Public interface of ownCloud for apps to use.
  32. * App Class
  33. *
  34. */
  35. // use OCP namespace for all classes that are considered public.
  36. // This means that they should be used by apps instead of the internal ownCloud classes
  37. namespace OCP;
  38. /**
  39. * This class provides functions to manage apps in ownCloud
  40. * @since 4.0.0
  41. */
  42. class App {
  43. /**
  44. * Adds an entry to the navigation
  45. *
  46. * This function adds a new entry to the navigation visible to users. $data
  47. * is an associative array.
  48. * The following keys are required:
  49. * - id: unique id for this entry ('addressbook_index')
  50. * - href: link to the page
  51. * - name: Human readable name ('Addressbook')
  52. *
  53. * The following keys are optional:
  54. * - icon: path to the icon of the app
  55. * - order: integer, that influences the position of your application in
  56. * the navigation. Lower values come first.
  57. *
  58. * @param array $data containing the data
  59. * @return boolean
  60. *
  61. * @deprecated 8.1.0 Use \OC::$server->getNavigationManager()->add() instead to
  62. * register a closure, this helps to speed up all requests against ownCloud
  63. * @since 4.0.0
  64. */
  65. public static function addNavigationEntry($data) {
  66. \OC::$server->getNavigationManager()->add($data);
  67. return true;
  68. }
  69. /**
  70. * Marks a navigation entry as active
  71. * @param string $id id of the entry
  72. * @return boolean
  73. *
  74. * This function sets a navigation entry as active and removes the 'active'
  75. * property from all other entries. The templates can use this for
  76. * highlighting the current position of the user.
  77. *
  78. * @deprecated 8.1.0 Use \OC::$server->getNavigationManager()->setActiveEntry() instead
  79. * @since 4.0.0
  80. */
  81. public static function setActiveNavigationEntry( $id ) {
  82. \OC::$server->getNavigationManager()->setActiveEntry($id);
  83. return true;
  84. }
  85. /**
  86. * Register a Configuration Screen that should appear in the personal settings section.
  87. * @param string $app appid
  88. * @param string $page page to be included
  89. * @return void
  90. * @since 4.0.0
  91. */
  92. public static function registerPersonal( $app, $page ) {
  93. \OC_App::registerPersonal( $app, $page );
  94. }
  95. /**
  96. * Register a Configuration Screen that should appear in the Admin section.
  97. * @param string $app string appid
  98. * @param string $page string page to be included
  99. * @return void
  100. * @since 4.0.0
  101. */
  102. public static function registerAdmin( $app, $page ) {
  103. \OC_App::registerAdmin( $app, $page );
  104. }
  105. /**
  106. * Read app metadata from the info.xml file
  107. * @param string $app id of the app or the path of the info.xml file
  108. * @param boolean $path (optional)
  109. * @return array|null
  110. * @since 4.0.0
  111. */
  112. public static function getAppInfo( $app, $path=false ) {
  113. return \OC_App::getAppInfo( $app, $path);
  114. }
  115. /**
  116. * checks whether or not an app is enabled
  117. * @param string $app
  118. * @return boolean
  119. *
  120. * This function checks whether or not an app is enabled.
  121. * @since 4.0.0
  122. */
  123. public static function isEnabled( $app ) {
  124. return \OC_App::isEnabled( $app );
  125. }
  126. /**
  127. * Check if the app is enabled, redirects to home if not
  128. * @param string $app
  129. * @return void
  130. * @since 4.0.0
  131. * @deprecated 9.0.0 ownCloud core will handle disabled apps and redirects to valid URLs
  132. */
  133. public static function checkAppEnabled( $app ) {
  134. }
  135. /**
  136. * Get the last version of the app, either from appinfo/version or from appinfo/info.xml
  137. * @param string $app
  138. * @return string
  139. * @since 4.0.0
  140. */
  141. public static function getAppVersion( $app ) {
  142. return \OC_App::getAppVersion( $app );
  143. }
  144. }