users.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <?php
  2. /**
  3. * @author Arthur Schiwon <blizzz@owncloud.com>
  4. * @author Bart Visscher <bartv@thisnet.nl>
  5. * @author Björn Schießle <schiessle@owncloud.com>
  6. * @author Clark Tomlinson <fallen013@gmail.com>
  7. * @author Daniel Molkentin <daniel@molkentin.de>
  8. * @author Georg Ehrke <georg@owncloud.com>
  9. * @author Jakob Sack <mail@jakobsack.de>
  10. * @author Joas Schilling <nickvergessen@owncloud.com>
  11. * @author Lukas Reschke <lukas@owncloud.com>
  12. * @author Morris Jobke <hey@morrisjobke.de>
  13. * @author Robin Appelman <icewind@owncloud.com>
  14. * @author Stephan Peijnik <speijnik@anexia-it.com>
  15. * @author Thomas Müller <thomas.mueller@tmit.eu>
  16. *
  17. * @copyright Copyright (c) 2015, ownCloud, Inc.
  18. * @license AGPL-3.0
  19. *
  20. * This code is free software: you can redistribute it and/or modify
  21. * it under the terms of the GNU Affero General Public License, version 3,
  22. * as published by the Free Software Foundation.
  23. *
  24. * This program is distributed in the hope that it will be useful,
  25. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  26. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  27. * GNU Affero General Public License for more details.
  28. *
  29. * You should have received a copy of the GNU Affero General Public License, version 3,
  30. * along with this program. If not, see <http://www.gnu.org/licenses/>
  31. *
  32. */
  33. OC_Util::checkSubAdminUser();
  34. OC_App::setActiveNavigationEntry( 'core_users' );
  35. $userManager = \OC_User::getManager();
  36. $groupManager = \OC_Group::getManager();
  37. // Set the sort option: SORT_USERCOUNT or SORT_GROUPNAME
  38. $sortGroupsBy = \OC\Group\MetaData::SORT_USERCOUNT;
  39. if (class_exists('\OCA\user_ldap\GROUP_LDAP')) {
  40. $isLDAPUsed = $groupManager->isBackendUsed('\OCA\user_ldap\GROUP_LDAP');
  41. if ($isLDAPUsed) {
  42. // LDAP user count can be slow, so we sort by group name here
  43. $sortGroupsBy = \OC\Group\MetaData::SORT_GROUPNAME;
  44. }
  45. }
  46. $config = \OC::$server->getConfig();
  47. $isAdmin = OC_User::isAdminUser(OC_User::getUser());
  48. $groupsInfo = new \OC\Group\MetaData(OC_User::getUser(), $isAdmin, $groupManager);
  49. $groupsInfo->setSorting($sortGroupsBy);
  50. list($adminGroup, $groups) = $groupsInfo->get();
  51. $recoveryAdminEnabled = OC_App::isEnabled('encryption') &&
  52. $config->getAppValue( 'encryption', 'recoveryAdminEnabled', null );
  53. if($isAdmin) {
  54. $subadmins = OC_SubAdmin::getAllSubAdmins();
  55. }else{
  56. /* Retrieve group IDs from $groups array, so we can pass that information into OC_Group::displayNamesInGroups() */
  57. $gids = array();
  58. foreach($groups as $group) {
  59. if (isset($group['id'])) {
  60. $gids[] = $group['id'];
  61. }
  62. }
  63. $subadmins = false;
  64. }
  65. // load preset quotas
  66. $quotaPreset=$config->getAppValue('files', 'quota_preset', '1 GB, 5 GB, 10 GB');
  67. $quotaPreset=explode(',', $quotaPreset);
  68. foreach($quotaPreset as &$preset) {
  69. $preset=trim($preset);
  70. }
  71. $quotaPreset=array_diff($quotaPreset, array('default', 'none'));
  72. $defaultQuota=$config->getAppValue('files', 'default_quota', 'none');
  73. $defaultQuotaIsUserDefined=array_search($defaultQuota, $quotaPreset)===false
  74. && array_search($defaultQuota, array('none', 'default'))===false;
  75. $tmpl = new OC_Template("settings", "users/main", "user");
  76. $tmpl->assign('groups', $groups);
  77. $tmpl->assign('sortGroups', $sortGroupsBy);
  78. $tmpl->assign('adminGroup', $adminGroup);
  79. $tmpl->assign('isAdmin', (int)$isAdmin);
  80. $tmpl->assign('subadmins', $subadmins);
  81. $tmpl->assign('numofgroups', count($groups) + count($adminGroup));
  82. $tmpl->assign('quota_preset', $quotaPreset);
  83. $tmpl->assign('default_quota', $defaultQuota);
  84. $tmpl->assign('defaultQuotaIsUserDefined', $defaultQuotaIsUserDefined);
  85. $tmpl->assign('recoveryAdminEnabled', $recoveryAdminEnabled);
  86. $tmpl->assign('enableAvatars', \OC::$server->getConfig()->getSystemValue('enable_avatars', true));
  87. $tmpl->printPage();