apps.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. <?php
  2. /**
  3. * ownCloud
  4. *
  5. * @author Frank Karlitschek
  6. * @copyright 2012 Frank Karlitschek frank@owncloud.org
  7. *
  8. * This library is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
  10. * License as published by the Free Software Foundation; either
  11. * version 3 of the License, or any later version.
  12. *
  13. * This library is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
  17. *
  18. * You should have received a copy of the GNU Affero General Public
  19. * License along with this library. If not, see <http://www.gnu.org/licenses/>.
  20. *
  21. */
  22. OC_Util::checkAdminUser();
  23. OC_App::loadApps();
  24. // Load the files we need
  25. OC_Util::addStyle( "settings", "settings" );
  26. OC_Util::addScript( "settings", "apps" );
  27. OC_App::setActiveNavigationEntry( "core_apps" );
  28. $installedApps = OC_App::getAllApps();
  29. //TODO which apps do we want to blacklist and how do we integrate blacklisting with the multi apps folder feature?
  30. $blacklist = array('files');//we dont want to show configuration for these
  31. $appList = array();
  32. foreach ( $installedApps as $app ) {
  33. if ( array_search( $app, $blacklist ) === false ) {
  34. $info=OC_App::getAppInfo($app);
  35. if (!isset($info['name'])) {
  36. OC_Log::write('core', 'App id "'.$app.'" has no name in appinfo', OC_Log::ERROR);
  37. continue;
  38. }
  39. if ( OC_Appconfig::getValue( $app, 'enabled', 'no') == 'yes' ) {
  40. $active = true;
  41. } else {
  42. $active = false;
  43. }
  44. $info['active'] = $active;
  45. if(isset($info['shipped']) and ($info['shipped']=='true')) {
  46. $info['internal']=true;
  47. $info['internallabel']='Internal App';
  48. }else{
  49. $info['internal']=false;
  50. $info['internallabel']='3rd Party App';
  51. }
  52. $info['preview'] = OC_Helper::imagePath('settings', 'trans.png');
  53. $info['version'] = OC_App::getAppVersion($app);
  54. $appList[] = $info;
  55. }
  56. }
  57. $remoteApps = OC_App::getAppstoreApps();
  58. if ( $remoteApps ) {
  59. // Remove duplicates
  60. foreach ( $appList as $app ) {
  61. foreach ( $remoteApps AS $key => $remote ) {
  62. if (
  63. $app['name'] == $remote['name']
  64. // To set duplicate detection to use OCS ID instead of string name,
  65. // enable this code, remove the line of code above,
  66. // and add <ocs_id>[ID]</ocs_id> to info.xml of each 3rd party app:
  67. // OR $app['ocs_id'] == $remote['ocs_id']
  68. ) {
  69. unset( $remoteApps[$key]);
  70. }
  71. }
  72. }
  73. $combinedApps = array_merge( $appList, $remoteApps );
  74. } else {
  75. $combinedApps = $appList;
  76. }
  77. function app_sort( $a, $b ) {
  78. if ($a['active'] != $b['active']) {
  79. return $b['active'] - $a['active'];
  80. }
  81. return strcmp($a['name'], $b['name']);
  82. }
  83. usort( $combinedApps, 'app_sort' );
  84. $tmpl = new OC_Template( "settings", "apps", "user" );
  85. $tmpl->assign('apps', $combinedApps, false);
  86. $appid = (isset($_GET['appid'])?strip_tags($_GET['appid']):'');
  87. $tmpl->assign('appid', $appid);
  88. $tmpl->printPage();