personal.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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_Util::addScript('files', 'jquery.fileupload');
  16. if (\OC_Config::getValue('enable_avatars', true) === true) {
  17. \OC_Util::addScript('3rdparty/Jcrop', 'jquery.Jcrop.min');
  18. \OC_Util::addStyle('3rdparty/Jcrop', 'jquery.Jcrop.min');
  19. }
  20. OC_App::setActiveNavigationEntry( 'personal' );
  21. $storageInfo=OC_Helper::getStorageInfo('/');
  22. $email=OC_Preferences::getValue(OC_User::getUser(), 'settings', 'email', '');
  23. $userLang=OC_Preferences::getValue( OC_User::getUser(), 'core', 'lang', OC_L10N::findLanguage() );
  24. $languageCodes=OC_L10N::findAvailableLanguages();
  25. //check if encryption was enabled in the past
  26. $enableDecryptAll = OC_Util::encryptedFiles();
  27. // array of common languages
  28. $commonlangcodes = array(
  29. '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'
  30. );
  31. $languageNames=include 'languageCodes.php';
  32. $languages=array();
  33. $commonlanguages = array();
  34. foreach($languageCodes as $lang) {
  35. $l=OC_L10N::get('settings', $lang);
  36. if(substr($l->t('__language_name__'), 0, 1) !== '_') {//first check if the language name is in the translation file
  37. $ln=array('code'=>$lang, 'name'=> (string)$l->t('__language_name__'));
  38. }elseif(isset($languageNames[$lang])) {
  39. $ln=array('code'=>$lang, 'name'=>$languageNames[$lang]);
  40. }else{//fallback to language code
  41. $ln=array('code'=>$lang, 'name'=>$lang);
  42. }
  43. // put apropriate languages into apropriate arrays, to print them sorted
  44. // used language -> common languages -> divider -> other languages
  45. if ($lang === $userLang) {
  46. $userLang = $ln;
  47. } elseif (in_array($lang, $commonlangcodes)) {
  48. $commonlanguages[array_search($lang, $commonlangcodes)]=$ln;
  49. } else {
  50. $languages[]=$ln;
  51. }
  52. }
  53. ksort($commonlanguages);
  54. // sort now by displayed language not the iso-code
  55. usort( $languages, function ($a, $b) {
  56. return strcmp($a['name'], $b['name']);
  57. });
  58. //links to clients
  59. $clients = array(
  60. 'desktop' => OC_Config::getValue('customclient_desktop', $defaults->getSyncClientUrl()),
  61. 'android' => OC_Config::getValue('customclient_android', 'https://play.google.com/store/apps/details?id=com.owncloud.android'),
  62. 'ios' => OC_Config::getValue('customclient_ios', 'https://itunes.apple.com/us/app/owncloud/id543672169?mt=8')
  63. );
  64. // Return template
  65. $tmpl = new OC_Template( 'settings', 'personal', 'user');
  66. $tmpl->assign('usage', OC_Helper::humanFileSize($storageInfo['used']));
  67. $tmpl->assign('total_space', OC_Helper::humanFileSize($storageInfo['total']));
  68. $tmpl->assign('usage_relative', $storageInfo['relative']);
  69. $tmpl->assign('clients', $clients);
  70. $tmpl->assign('email', $email);
  71. $tmpl->assign('languages', $languages);
  72. $tmpl->assign('commonlanguages', $commonlanguages);
  73. $tmpl->assign('activelanguage', $userLang);
  74. $tmpl->assign('passwordChangeSupported', OC_User::canUserChangePassword(OC_User::getUser()));
  75. $tmpl->assign('displayNameChangeSupported', OC_User::canUserChangeDisplayName(OC_User::getUser()));
  76. $tmpl->assign('displayName', OC_User::getDisplayName());
  77. $tmpl->assign('enableDecryptAll' , $enableDecryptAll);
  78. $tmpl->assign('enableAvatars', \OC_Config::getValue('enable_avatars', true));
  79. $forms=OC_App::getForms('personal');
  80. $tmpl->assign('forms', array());
  81. foreach($forms as $form) {
  82. $tmpl->append('forms', $form);
  83. }
  84. $tmpl->printPage();