personal.php 4.0 KB

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