apps.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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. require_once('../lib/base.php');
  23. OC_Util::checkAdminUser();
  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. $registeredApps=OC_App::getAllApps();
  29. $apps=array();
  30. $blacklist=array('files','files_imageviewer','files_textviewer');//we dont want to show configuration for these
  31. foreach($registeredApps as $app){
  32. if(array_search($app,$blacklist)===false){
  33. $info=OC_App::getAppInfo($app);
  34. $active=(OC_Appconfig::getValue($app,'enabled','no')=='yes')?true:false;
  35. $info['active']=$active;
  36. if(isset($info['shipped']) and ($info['shipped']=='true')) {
  37. $info['internal']=true;
  38. $info['internallabel']='Internal App';
  39. }else{
  40. $info['internal']=false;
  41. $info['internallabel']='3rd Party App';
  42. }
  43. $info['preview']='trans.png';
  44. $apps[]=$info;
  45. }
  46. }
  47. function app_sort($a, $b){
  48. if ($a['active'] != $b['active']){
  49. return $b['active'] - $a['active'];
  50. }
  51. return strcmp($a['name'], $b['name']);
  52. }
  53. usort($apps, 'app_sort');
  54. // apps from external repo via OCS
  55. $catagoryNames=OC_OCSClient::getCategories();
  56. if(is_array($catagoryNames)){
  57. $categories=array_keys($catagoryNames);
  58. $page=0;
  59. $externalApps=OC_OCSClient::getApplications($categories,$page);
  60. foreach($externalApps as $app){
  61. // show only external apps that are not exist yet
  62. $local=false;
  63. foreach($apps as $a){
  64. if($a['name']==$app['name']) $local=true;
  65. }
  66. if(!$local) {
  67. if($app['preview']=='') $pre='trans.png'; else $pre=$app['preview'];
  68. $apps[]=array(
  69. 'name'=>$app['name'],
  70. 'id'=>$app['id'],
  71. 'active'=>false,
  72. 'description'=>$app['description'],
  73. 'author'=>$app['personid'],
  74. 'license'=>$app['license'],
  75. 'preview'=>$pre,
  76. 'internal'=>false,
  77. 'internallabel'=>'3rd Party App',
  78. );
  79. }
  80. }
  81. }
  82. $tmpl = new OC_Template( "settings", "apps", "user" );
  83. $tmpl->assign('apps',$apps, false);
  84. $tmpl->printPage();
  85. ?>