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.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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::addScript('core', 'jquery.inview');
  16. OC_Util::addStyle( 'settings', 'settings' );
  17. OC_App::setActiveNavigationEntry( 'core_users' );
  18. $users = array();
  19. $userManager = \OC_User::getManager();
  20. $groupManager = \OC_Group::getManager();
  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. OC_Appconfig::getValue( 'files_encryption', 'recoveryAdminEnabled' );
  27. if($isAdmin) {
  28. $accessibleUsers = OC_User::getDisplayNames('', 30);
  29. $subadmins = OC_SubAdmin::getAllSubAdmins();
  30. }else{
  31. $accessibleUsers = OC_Group::displayNamesInGroups($groups, '', 30);
  32. $subadmins = false;
  33. }
  34. // load preset quotas
  35. $quotaPreset=OC_Appconfig::getValue('files', 'quota_preset', '1 GB, 5 GB, 10 GB');
  36. $quotaPreset=explode(',', $quotaPreset);
  37. foreach($quotaPreset as &$preset) {
  38. $preset=trim($preset);
  39. }
  40. $quotaPreset=array_diff($quotaPreset, array('default', 'none'));
  41. $defaultQuota=OC_Appconfig::getValue('files', 'default_quota', 'none');
  42. $defaultQuotaIsUserDefined=array_search($defaultQuota, $quotaPreset)===false
  43. && array_search($defaultQuota, array('none', 'default'))===false;
  44. // load users and quota
  45. foreach($accessibleUsers as $uid => $displayName) {
  46. $quota=OC_Preferences::getValue($uid, 'files', 'quota', 'default');
  47. $isQuotaUserDefined=array_search($quota, $quotaPreset)===false
  48. && array_search($quota, array('none', 'default'))===false;
  49. $name = $displayName;
  50. if ( $displayName !== $uid ) {
  51. $name = $name . ' ('.$uid.')';
  52. }
  53. $user = $userManager->get($uid);
  54. $users[] = array(
  55. "name" => $uid,
  56. "displayName" => $displayName,
  57. "groups" => OC_Group::getUserGroups($uid),
  58. 'quota' => $quota,
  59. 'isQuotaUserDefined' => $isQuotaUserDefined,
  60. 'subadmin' => OC_SubAdmin::getSubAdminsGroups($uid),
  61. 'storageLocation' => $user->getHome(),
  62. 'lastLogin' => $user->getLastLogin(),
  63. );
  64. }
  65. $tmpl = new OC_Template( "settings", "users/main", "user" );
  66. $tmpl->assign( 'users', $users );
  67. $tmpl->assign( 'groups', $groups );
  68. $tmpl->assign( 'adminGroup', $adminGroup );
  69. $tmpl->assign( 'isAdmin', (int) $isAdmin);
  70. $tmpl->assign( 'subadmins', $subadmins);
  71. $tmpl->assign( 'numofgroups', count($groups) + count($adminGroup));
  72. $tmpl->assign( 'quota_preset', $quotaPreset);
  73. $tmpl->assign( 'default_quota', $defaultQuota);
  74. $tmpl->assign( 'defaultQuotaIsUserDefined', $defaultQuotaIsUserDefined);
  75. $tmpl->assign( 'recoveryAdminEnabled', $recoveryAdminEnabled);
  76. $tmpl->assign( 'enableAvatars', \OC_Config::getValue('enable_avatars', true));
  77. $tmpl->printPage();