personal.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. OC_Util::checkLoggedIn();
  8. OC_App::loadApps();
  9. $defaults = new OC_Defaults(); // initialize themable default strings and urls
  10. // Highlight navigation entry
  11. OC_Util::addScript( 'settings', 'personal' );
  12. OC_Util::addStyle( 'settings', 'settings' );
  13. OC_Util::addScript( '3rdparty', 'chosen/chosen.jquery.min' );
  14. OC_Util::addStyle( '3rdparty', 'chosen' );
  15. OC_App::setActiveNavigationEntry( 'personal' );
  16. $storageInfo=OC_Helper::getStorageInfo();
  17. $email=OC_Preferences::getValue(OC_User::getUser(), 'settings', 'email', '');
  18. $userLang=OC_Preferences::getValue( OC_User::getUser(), 'core', 'lang', OC_L10N::findLanguage() );
  19. $languageCodes=OC_L10N::findAvailableLanguages();
  20. // array of common languages
  21. $commonlangcodes = array(
  22. 'en', 'es', 'fr', 'de', 'de_DE', 'ja_JP', 'ar', 'ru', 'nl', 'it', 'pt_BR', 'pt_PT', 'da', 'fi_FI', 'nb_NO', 'sv', 'zh_CN', 'ko'
  23. );
  24. $languageNames=include 'languageCodes.php';
  25. $languages=array();
  26. $commonlanguages = array();
  27. foreach($languageCodes as $lang) {
  28. $l=OC_L10N::get('settings', $lang);
  29. if(substr($l->t('__language_name__'), 0, 1) !== '_') {//first check if the language name is in the translation file
  30. $ln=array('code'=>$lang, 'name'=> (string)$l->t('__language_name__'));
  31. }elseif(isset($languageNames[$lang])) {
  32. $ln=array('code'=>$lang, 'name'=>$languageNames[$lang]);
  33. }else{//fallback to language code
  34. $ln=array('code'=>$lang, 'name'=>$lang);
  35. }
  36. // put apropriate languages into apropriate arrays, to print them sorted
  37. // used language -> common languages -> divider -> other languages
  38. if ($lang === $userLang) {
  39. $userLang = $ln;
  40. } elseif (in_array($lang, $commonlangcodes)) {
  41. $commonlanguages[array_search($lang, $commonlangcodes)]=$ln;
  42. } else {
  43. $languages[]=$ln;
  44. }
  45. }
  46. ksort($commonlanguages);
  47. // sort now by displayed language not the iso-code
  48. usort( $languages, function ($a, $b) {
  49. return strcmp($a['name'], $b['name']);
  50. });
  51. //links to clients
  52. $clients = array(
  53. 'desktop' => OC_Config::getValue('customclient_desktop', $defaults->getSyncClientUrl()),
  54. 'android' => OC_Config::getValue('customclient_android', 'https://play.google.com/store/apps/details?id=com.owncloud.android'),
  55. 'ios' => OC_Config::getValue('customclient_ios', 'https://itunes.apple.com/us/app/owncloud/id543672169?mt=8')
  56. );
  57. // Return template
  58. $tmpl = new OC_Template( 'settings', 'personal', 'user');
  59. $tmpl->assign('usage', OC_Helper::humanFileSize($storageInfo['used']));
  60. $tmpl->assign('total_space', OC_Helper::humanFileSize($storageInfo['total']));
  61. $tmpl->assign('usage_relative', $storageInfo['relative']);
  62. $tmpl->assign('clients', $clients);
  63. $tmpl->assign('email', $email);
  64. $tmpl->assign('languages', $languages);
  65. $tmpl->assign('commonlanguages', $commonlanguages);
  66. $tmpl->assign('activelanguage', $userLang);
  67. $tmpl->assign('passwordChangeSupported', OC_User::canUserChangePassword(OC_User::getUser()));
  68. $tmpl->assign('displayNameChangeSupported', OC_User::canUserChangeDisplayName(OC_User::getUser()));
  69. $tmpl->assign('displayName', OC_User::getDisplayName());
  70. $forms=OC_App::getForms('personal');
  71. $tmpl->assign('forms', array());
  72. foreach($forms as $form) {
  73. $tmpl->append('forms', $form);
  74. }
  75. $tmpl->printPage();