personal.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. /**
  3. * Copyright (c) 2011, Robin Appelman <icewind1991@gmail.com>
  4. * This file is licensed under the Affero General Public License version 3 or later.
  5. * See the COPYING-README file.
  6. */
  7. require_once('../lib/base.php');
  8. OC_Util::checkLoggedIn();
  9. // Highlight navigation entry
  10. OC_Util::addScript( 'settings', 'personal' );
  11. OC_Util::addStyle( 'settings', 'settings' );
  12. OC_Util::addScript( '3rdparty', 'chosen/chosen.jquery.min' );
  13. OC_Util::addStyle( '3rdparty', 'chosen' );
  14. OC_App::setActiveNavigationEntry( 'personal' );
  15. // calculate the disc space
  16. $rootInfo=OC_FileCache::get('');
  17. $sharedInfo=OC_FileCache::get('/Shared');
  18. if (!isset($sharedInfo['size'])) {
  19. $sharedSize = 0;
  20. } else {
  21. $sharedSize = $sharedInfo['size'];
  22. }
  23. $used=$rootInfo['size']-$sharedSize;
  24. $free=OC_Filesystem::free_space();
  25. $total=$free+$used;
  26. if($total==0) $total=1; // prevent division by zero
  27. $relative=round(($used/$total)*10000)/100;
  28. $email=OC_Preferences::getValue(OC_User::getUser(), 'settings','email','');
  29. $lang=OC_Preferences::getValue( OC_User::getUser(), 'core', 'lang', OC_L10N::findLanguage() );
  30. $languageCodes=OC_L10N::findAvailableLanguages();
  31. sort ($languageCodes);
  32. //put the current language in the front
  33. unset($languageCodes[array_search($lang,$languageCodes)]);
  34. array_unshift($languageCodes,$lang);
  35. $languageNames=include 'languageCodes.php';
  36. $languages=array();
  37. foreach($languageCodes as $lang){
  38. $l=OC_L10N::get('settings',$lang);
  39. if(substr($l->t('__language_name__'),0,1)!='_'){//first check if the language name is in the translation file
  40. $languages[]=array('code'=>$lang,'name'=>$l->t('__language_name__'));
  41. }elseif(isset($languageNames[$lang])){
  42. $languages[]=array('code'=>$lang,'name'=>$languageNames[$lang]);
  43. }else{//fallback to language code
  44. $languages[]=array('code'=>$lang,'name'=>$lang);
  45. }
  46. }
  47. // Return template
  48. $tmpl = new OC_Template( 'settings', 'personal', 'user');
  49. $tmpl->assign('usage',OC_Helper::humanFileSize($used));
  50. $tmpl->assign('total_space',OC_Helper::humanFileSize($total));
  51. $tmpl->assign('usage_relative',$relative);
  52. $tmpl->assign('email',$email);
  53. $tmpl->assign('languages',$languages);
  54. $forms=OC_App::getForms('personal');
  55. $tmpl->assign('forms',array());
  56. foreach($forms as $form){
  57. $tmpl->append('forms',$form);
  58. }
  59. $tmpl->printPage();