personal.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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. $certificateManager = \OC::$server->getCertificateManager();
  10. // Highlight navigation entry
  11. OC_Util::addScript( 'settings', 'personal' );
  12. OC_Util::addStyle( 'settings', 'settings' );
  13. OC_Util::addScript( '3rdparty', 'strengthify/jquery.strengthify' );
  14. OC_Util::addStyle( '3rdparty', 'strengthify/strengthify' );
  15. OC_Util::addScript( '3rdparty', 'chosen/chosen.jquery.min' );
  16. OC_Util::addStyle( '3rdparty', 'chosen/chosen' );
  17. \OC_Util::addScript('files', 'jquery.fileupload');
  18. if (\OC_Config::getValue('enable_avatars', true) === true) {
  19. \OC_Util::addScript('3rdparty/Jcrop', 'jquery.Jcrop.min');
  20. \OC_Util::addStyle('3rdparty/Jcrop', 'jquery.Jcrop.min');
  21. }
  22. // Highlight navigation entry
  23. OC_App::setActiveNavigationEntry( 'personal' );
  24. $storageInfo=OC_Helper::getStorageInfo('/');
  25. $email=OC_Preferences::getValue(OC_User::getUser(), 'settings', 'email', '');
  26. $userLang=OC_Preferences::getValue( OC_User::getUser(), 'core', 'lang', OC_L10N::findLanguage() );
  27. $languageCodes=OC_L10N::findAvailableLanguages();
  28. //check if encryption was enabled in the past
  29. $filesStillEncrypted = OC_Util::encryptedFiles();
  30. $backupKeysExists = OC_Util::backupKeysExists();
  31. $enableDecryptAll = $filesStillEncrypted || $backupKeysExists;
  32. // array of common languages
  33. $commonlangcodes = array(
  34. 'en', 'es', 'fr', 'de', 'de_DE', 'ja', 'ar', 'ru', 'nl', 'it', 'pt_BR', 'pt_PT', 'da', 'fi_FI', 'nb_NO', 'sv', 'tr', 'zh_CN', 'ko'
  35. );
  36. $languageNames=include 'languageCodes.php';
  37. $languages=array();
  38. $commonlanguages = array();
  39. foreach($languageCodes as $lang) {
  40. $l = \OC::$server->getL10N('settings', $lang);
  41. if(substr($l->t('__language_name__'), 0, 1) !== '_') {//first check if the language name is in the translation file
  42. $ln=array('code'=>$lang, 'name'=> (string)$l->t('__language_name__'));
  43. }elseif(isset($languageNames[$lang])) {
  44. $ln=array('code'=>$lang, 'name'=>$languageNames[$lang]);
  45. }else{//fallback to language code
  46. $ln=array('code'=>$lang, 'name'=>$lang);
  47. }
  48. // put apropriate languages into apropriate arrays, to print them sorted
  49. // used language -> common languages -> divider -> other languages
  50. if ($lang === $userLang) {
  51. $userLang = $ln;
  52. } elseif (in_array($lang, $commonlangcodes)) {
  53. $commonlanguages[array_search($lang, $commonlangcodes)]=$ln;
  54. } else {
  55. $languages[]=$ln;
  56. }
  57. }
  58. ksort($commonlanguages);
  59. // sort now by displayed language not the iso-code
  60. usort( $languages, function ($a, $b) {
  61. return strcmp($a['name'], $b['name']);
  62. });
  63. //links to clients
  64. $clients = array(
  65. 'desktop' => OC_Config::getValue('customclient_desktop', $defaults->getSyncClientUrl()),
  66. 'android' => OC_Config::getValue('customclient_android', $defaults->getAndroidClientUrl()),
  67. 'ios' => OC_Config::getValue('customclient_ios', $defaults->getiOSClientUrl())
  68. );
  69. // Return template
  70. $tmpl = new OC_Template( 'settings', 'personal', 'user');
  71. $tmpl->assign('usage', OC_Helper::humanFileSize($storageInfo['used']));
  72. $tmpl->assign('total_space', OC_Helper::humanFileSize($storageInfo['total']));
  73. $tmpl->assign('usage_relative', $storageInfo['relative']);
  74. $tmpl->assign('clients', $clients);
  75. $tmpl->assign('email', $email);
  76. $tmpl->assign('languages', $languages);
  77. $tmpl->assign('commonlanguages', $commonlanguages);
  78. $tmpl->assign('activelanguage', $userLang);
  79. $tmpl->assign('passwordChangeSupported', OC_User::canUserChangePassword(OC_User::getUser()));
  80. $tmpl->assign('displayNameChangeSupported', OC_User::canUserChangeDisplayName(OC_User::getUser()));
  81. $tmpl->assign('displayName', OC_User::getDisplayName());
  82. $tmpl->assign('enableDecryptAll' , $enableDecryptAll);
  83. $tmpl->assign('backupKeysExists' , $backupKeysExists);
  84. $tmpl->assign('filesStillEncrypted' , $filesStillEncrypted);
  85. $tmpl->assign('enableAvatars', \OC_Config::getValue('enable_avatars', true));
  86. $tmpl->assign('avatarChangeSupported', OC_User::canUserChangeAvatar(OC_User::getUser()));
  87. $tmpl->assign('certs', $certificateManager->listCertificates());
  88. $forms=OC_App::getForms('personal');
  89. $tmpl->assign('forms', array());
  90. foreach($forms as $form) {
  91. $tmpl->append('forms', $form);
  92. }
  93. $tmpl->printPage();