You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

app.php 4.4KB

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