users.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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 =
  41. $groupManager->isBackendUsed('\OCA\user_ldap\GROUP_LDAP')
  42. || $groupManager->isBackendUsed('\OCA\user_ldap\Group_Proxy');
  43. if ($isLDAPUsed) {
  44. // LDAP user count can be slow, so we sort by group name here
  45. $sortGroupsBy = \OC\Group\MetaData::SORT_GROUPNAME;
  46. }
  47. }
  48. $config = \OC::$server->getConfig();
  49. $isAdmin = OC_User::isAdminUser(OC_User::getUser());
  50. $groupsInfo = new \OC\Group\MetaData(OC_User::getUser(), $isAdmin, $groupManager);
  51. $groupsInfo->setSorting($sortGroupsBy);
  52. list($adminGroup, $groups) = $groupsInfo->get();
  53. $recoveryAdminEnabled = OC_App::isEnabled('encryption') &&
  54. $config->getAppValue( 'encryption', 'recoveryAdminEnabled', null );
  55. if($isAdmin) {
  56. $subadmins = OC_SubAdmin::getAllSubAdmins();
  57. }else{
  58. /* Retrieve group IDs from $groups array, so we can pass that information into OC_Group::displayNamesInGroups() */
  59. $gids = array();
  60. foreach($groups as $group) {
  61. if (isset($group['id'])) {
  62. $gids[] = $group['id'];
  63. }
  64. }
  65. $subadmins = false;
  66. }
  67. // load preset quotas
  68. $quotaPreset=$config->getAppValue('files', 'quota_preset', '1 GB, 5 GB, 10 GB');
  69. $quotaPreset=explode(',', $quotaPreset);
  70. foreach($quotaPreset as &$preset) {
  71. $preset=trim($preset);
  72. }
  73. $quotaPreset=array_diff($quotaPreset, array('default', 'none'));
  74. $defaultQuota=$config->getAppValue('files', 'default_quota', 'none');
  75. $defaultQuotaIsUserDefined=array_search($defaultQuota, $quotaPreset)===false
  76. && array_search($defaultQuota, array('none', 'default'))===false;
  77. $tmpl = new OC_Template("settings", "users/main", "user");
  78. $tmpl->assign('groups', $groups);
  79. $tmpl->assign('sortGroups', $sortGroupsBy);
  80. $tmpl->assign('adminGroup', $adminGroup);
  81. $tmpl->assign('isAdmin', (int)$isAdmin);
  82. $tmpl->assign('subadmins', $subadmins);
  83. $tmpl->assign('numofgroups', count($groups) + count($adminGroup));
  84. $tmpl->assign('quota_preset', $quotaPreset);
  85. $tmpl->assign('default_quota', $defaultQuota);
  86. $tmpl->assign('defaultQuotaIsUserDefined', $defaultQuotaIsUserDefined);
  87. $tmpl->assign('recoveryAdminEnabled', $recoveryAdminEnabled);
  88. $tmpl->assign('enableAvatars', \OC::$server->getConfig()->getSystemValue('enable_avatars', true));
  89. $tmpl->printPage();