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 3.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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::checkSubAdminUser();
  8. // We have some javascript foo!
  9. OC_Util::addScript('settings', 'users/deleteHandler');
  10. OC_Util::addScript('settings', 'users/filter');
  11. OC_Util::addScript( 'settings', 'users/users' );
  12. OC_Util::addScript( 'settings', 'users/groups' );
  13. OC_Util::addScript( 'core', 'multiselect' );
  14. OC_Util::addScript( 'core', 'singleselect' );
  15. OC_Util::addStyle( 'settings', 'settings' );
  16. OC_App::setActiveNavigationEntry( 'core_users' );
  17. $users = array();
  18. $userManager = \OC_User::getManager();
  19. $groupManager = \OC_Group::getManager();
  20. $config = \OC::$server->getConfig();
  21. $isAdmin = OC_User::isAdminUser(OC_User::getUser());
  22. $groupsInfo = new \OC\Group\MetaData(OC_User::getUser(), $isAdmin, $groupManager);
  23. $groupsInfo->setSorting($groupsInfo::SORT_USERCOUNT);
  24. list($adminGroup, $groups) = $groupsInfo->get();
  25. $recoveryAdminEnabled = OC_App::isEnabled('files_encryption') &&
  26. $config->getAppValue( 'files_encryption', 'recoveryAdminEnabled', null );
  27. if($isAdmin) {
  28. $accessibleUsers = OC_User::getDisplayNames('', 30);
  29. $subadmins = OC_SubAdmin::getAllSubAdmins();
  30. }else{
  31. /* Retrieve group IDs from $groups array, so we can pass that information into OC_Group::displayNamesInGroups() */
  32. $gids = array();
  33. foreach($groups as $group) {
  34. if (isset($group['id'])) {
  35. $gids[] = $group['id'];
  36. }
  37. }
  38. $accessibleUsers = OC_Group::displayNamesInGroups($gids, '', 30);
  39. $subadmins = false;
  40. }
  41. // load preset quotas
  42. $quotaPreset=OC_Appconfig::getValue('files', 'quota_preset', '1 GB, 5 GB, 10 GB');
  43. $quotaPreset=explode(',', $quotaPreset);
  44. foreach($quotaPreset as &$preset) {
  45. $preset=trim($preset);
  46. }
  47. $quotaPreset=array_diff($quotaPreset, array('default', 'none'));
  48. $defaultQuota=OC_Appconfig::getValue('files', 'default_quota', 'none');
  49. $defaultQuotaIsUserDefined=array_search($defaultQuota, $quotaPreset)===false
  50. && array_search($defaultQuota, array('none', 'default'))===false;
  51. // load users and quota
  52. foreach($accessibleUsers as $uid => $displayName) {
  53. $quota = $config->getUserValue($uid, 'files', 'quota', 'default');
  54. $isQuotaUserDefined = array_search($quota, $quotaPreset) === false
  55. && array_search($quota, array('none', 'default')) === false;
  56. $name = $displayName;
  57. if ($displayName !== $uid) {
  58. $name = $name . ' (' . $uid . ')';
  59. }
  60. $user = $userManager->get($uid);
  61. $users[] = array(
  62. "name" => $uid,
  63. "displayName" => $displayName,
  64. "groups" => OC_Group::getUserGroups($uid),
  65. 'quota' => $quota,
  66. 'isQuotaUserDefined' => $isQuotaUserDefined,
  67. 'subadmin' => OC_SubAdmin::getSubAdminsGroups($uid),
  68. 'storageLocation' => $user->getHome(),
  69. 'lastLogin' => $user->getLastLogin(),
  70. );
  71. }
  72. $tmpl = new OC_Template("settings", "users/main", "user");
  73. $tmpl->assign('users', $users);
  74. $tmpl->assign('groups', $groups);
  75. $tmpl->assign('adminGroup', $adminGroup);
  76. $tmpl->assign('isAdmin', (int)$isAdmin);
  77. $tmpl->assign('subadmins', $subadmins);
  78. $tmpl->assign('numofgroups', count($groups) + count($adminGroup));
  79. $tmpl->assign('quota_preset', $quotaPreset);
  80. $tmpl->assign('default_quota', $defaultQuota);
  81. $tmpl->assign('defaultQuotaIsUserDefined', $defaultQuotaIsUserDefined);
  82. $tmpl->assign('recoveryAdminEnabled', $recoveryAdminEnabled);
  83. $tmpl->assign('enableAvatars', \OC::$server->getConfig()->getSystemValue('enable_avatars', true));
  84. $tmpl->printPage();