app.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  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. */
  39. class App {
  40. /**
  41. * Makes ownCloud aware of this app
  42. * @param array $data with all information
  43. * @return boolean
  44. *
  45. * @deprecated This method is deprecated. Do not call it anymore.
  46. * It'll remain in our public API for compatibility reasons.
  47. *
  48. */
  49. public static function register( $data ) {
  50. return true; // don't do anything
  51. }
  52. /**
  53. * Adds an entry to the navigation
  54. *
  55. * This function adds a new entry to the navigation visible to users. $data
  56. * is an associative array.
  57. * The following keys are required:
  58. * - id: unique id for this entry ('addressbook_index')
  59. * - href: link to the page
  60. * - name: Human readable name ('Addressbook')
  61. *
  62. * The following keys are optional:
  63. * - icon: path to the icon of the app
  64. * - order: integer, that influences the position of your application in
  65. * the navigation. Lower values come first.
  66. *
  67. * @param array $data containing the data
  68. * @return boolean
  69. *
  70. * @deprecated Use \OC::$server->getNavigationManager()->add() instead to
  71. * register a closure, this helps to speed up all requests against ownCloud
  72. */
  73. public static function addNavigationEntry($data) {
  74. \OC::$server->getNavigationManager()->add($data);
  75. return true;
  76. }
  77. /**
  78. * Marks a navigation entry as active
  79. * @param string $id id of the entry
  80. * @return boolean
  81. *
  82. * This function sets a navigation entry as active and removes the 'active'
  83. * property from all other entries. The templates can use this for
  84. * highlighting the current position of the user.
  85. *
  86. * @deprecated Use \OC::$server->getNavigationManager()->setActiveEntry() instead
  87. */
  88. public static function setActiveNavigationEntry( $id ) {
  89. return \OC_App::setActiveNavigationEntry( $id );
  90. }
  91. /**
  92. * Register a Configuration Screen that should appear in the personal settings section.
  93. * @param string $app appid
  94. * @param string $page page to be included
  95. * @return void
  96. */
  97. public static function registerPersonal( $app, $page ) {
  98. \OC_App::registerPersonal( $app, $page );
  99. }
  100. /**
  101. * Register a Configuration Screen that should appear in the Admin section.
  102. * @param string $app string appid
  103. * @param string $page string page to be included
  104. * @return void
  105. */
  106. public static function registerAdmin( $app, $page ) {
  107. \OC_App::registerAdmin( $app, $page );
  108. }
  109. /**
  110. * Read app metadata from the info.xml file
  111. * @param string $app id of the app or the path of the info.xml file
  112. * @param boolean $path (optional)
  113. * @return array
  114. */
  115. public static function getAppInfo( $app, $path=false ) {
  116. return \OC_App::getAppInfo( $app, $path);
  117. }
  118. /**
  119. * checks whether or not an app is enabled
  120. * @param string $app
  121. * @return boolean
  122. *
  123. * This function checks whether or not an app is enabled.
  124. */
  125. public static function isEnabled( $app ) {
  126. return \OC_App::isEnabled( $app );
  127. }
  128. /**
  129. * Check if the app is enabled, redirects to home if not
  130. * @param string $app
  131. * @return void
  132. */
  133. public static function checkAppEnabled( $app ) {
  134. \OC_Util::checkAppEnabled( $app );
  135. }
  136. /**
  137. * Get the last version of the app, either from appinfo/version or from appinfo/info.xml
  138. * @param string $app
  139. * @return string
  140. */
  141. public static function getAppVersion( $app ) {
  142. return \OC_App::getAppVersion( $app );
  143. }
  144. }