You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

users.php 4.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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 Robin McCorkell <robin@mccorkell.me.uk>
  15. * @author Roeland Jago Douma <rullzer@owncloud.com>
  16. * @author Stephan Peijnik <speijnik@anexia-it.com>
  17. * @author Thomas Müller <thomas.mueller@tmit.eu>
  18. *
  19. * @copyright Copyright (c) 2016, ownCloud, Inc.
  20. * @license AGPL-3.0
  21. *
  22. * This code is free software: you can redistribute it and/or modify
  23. * it under the terms of the GNU Affero General Public License, version 3,
  24. * as published by the Free Software Foundation.
  25. *
  26. * This program is distributed in the hope that it will be useful,
  27. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  28. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  29. * GNU Affero General Public License for more details.
  30. *
  31. * You should have received a copy of the GNU Affero General Public License, version 3,
  32. * along with this program. If not, see <http://www.gnu.org/licenses/>
  33. *
  34. */
  35. OC_Util::checkSubAdminUser();
  36. \OC::$server->getNavigationManager()->setActiveEntry('core_users');
  37. $userManager = \OC::$server->getUserManager();
  38. $groupManager = \OC_Group::getManager();
  39. // Set the sort option: SORT_USERCOUNT or SORT_GROUPNAME
  40. $sortGroupsBy = \OC\Group\MetaData::SORT_USERCOUNT;
  41. if (\OC_App::isEnabled('user_ldap')) {
  42. $isLDAPUsed =
  43. $groupManager->isBackendUsed('\OCA\user_ldap\GROUP_LDAP')
  44. || $groupManager->isBackendUsed('\OCA\user_ldap\Group_Proxy');
  45. if ($isLDAPUsed) {
  46. // LDAP user count can be slow, so we sort by group name here
  47. $sortGroupsBy = \OC\Group\MetaData::SORT_GROUPNAME;
  48. }
  49. }
  50. $config = \OC::$server->getConfig();
  51. $isAdmin = OC_User::isAdminUser(OC_User::getUser());
  52. $groupsInfo = new \OC\Group\MetaData(
  53. OC_User::getUser(),
  54. $isAdmin,
  55. $groupManager,
  56. \OC::$server->getUserSession()
  57. );
  58. $groupsInfo->setSorting($sortGroupsBy);
  59. list($adminGroup, $groups) = $groupsInfo->get();
  60. $recoveryAdminEnabled = OC_App::isEnabled('encryption') &&
  61. $config->getAppValue( 'encryption', 'recoveryAdminEnabled', null );
  62. if($isAdmin) {
  63. $subAdmins = \OC::$server->getGroupManager()->getSubAdmin()->getAllSubAdmins();
  64. // New class returns IUser[] so convert back
  65. $result = [];
  66. foreach ($subAdmins as $subAdmin) {
  67. $result[] = [
  68. 'gid' => $subAdmin['group']->getGID(),
  69. 'uid' => $subAdmin['user']->getUID(),
  70. ];
  71. }
  72. $subAdmins = $result;
  73. }else{
  74. /* Retrieve group IDs from $groups array, so we can pass that information into OC_Group::displayNamesInGroups() */
  75. $gids = array();
  76. foreach($groups as $group) {
  77. if (isset($group['id'])) {
  78. $gids[] = $group['id'];
  79. }
  80. }
  81. $subAdmins = false;
  82. }
  83. // load preset quotas
  84. $quotaPreset=$config->getAppValue('files', 'quota_preset', '1 GB, 5 GB, 10 GB');
  85. $quotaPreset=explode(',', $quotaPreset);
  86. foreach($quotaPreset as &$preset) {
  87. $preset=trim($preset);
  88. }
  89. $quotaPreset=array_diff($quotaPreset, array('default', 'none'));
  90. $defaultQuota=$config->getAppValue('files', 'default_quota', 'none');
  91. $defaultQuotaIsUserDefined=array_search($defaultQuota, $quotaPreset)===false
  92. && array_search($defaultQuota, array('none', 'default'))===false;
  93. $tmpl = new OC_Template("settings", "users/main", "user");
  94. $tmpl->assign('groups', $groups);
  95. $tmpl->assign('sortGroups', $sortGroupsBy);
  96. $tmpl->assign('adminGroup', $adminGroup);
  97. $tmpl->assign('isAdmin', (int)$isAdmin);
  98. $tmpl->assign('subadmins', $subAdmins);
  99. $tmpl->assign('numofgroups', count($groups) + count($adminGroup));
  100. $tmpl->assign('quota_preset', $quotaPreset);
  101. $tmpl->assign('default_quota', $defaultQuota);
  102. $tmpl->assign('defaultQuotaIsUserDefined', $defaultQuotaIsUserDefined);
  103. $tmpl->assign('recoveryAdminEnabled', $recoveryAdminEnabled);
  104. $tmpl->assign('enableAvatars', \OC::$server->getConfig()->getSystemValue('enable_avatars', true));
  105. $tmpl->assign('show_storage_location', $config->getAppValue('core', 'umgmt_show_storage_location', 'false'));
  106. $tmpl->assign('show_last_login', $config->getAppValue('core', 'umgmt_show_last_login', 'false'));
  107. $tmpl->assign('show_email', $config->getAppValue('core', 'umgmt_show_email', 'false'));
  108. $tmpl->assign('show_backend', $config->getAppValue('core', 'umgmt_show_backend', 'false'));
  109. $tmpl->assign('send_email', $config->getAppValue('core', 'umgmt_send_email', 'false'));
  110. $tmpl->printPage();