users.php 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. OC_App::loadApps();
  9. // We have some javascript foo!
  10. OC_Util::addScript( 'settings', 'users' );
  11. OC_Util::addScript( 'core', 'multiselect' );
  12. OC_Util::addScript( 'core', 'singleselect' );
  13. OC_Util::addScript('core', 'jquery.inview');
  14. OC_Util::addStyle( 'settings', 'settings' );
  15. OC_App::setActiveNavigationEntry( 'core_users' );
  16. $users = array();
  17. $groups = array();
  18. $isadmin = OC_User::isAdminUser(OC_User::getUser());
  19. $recoveryAdminEnabled = OC_App::isEnabled('files_encryption') &&
  20. OC_Appconfig::getValue( 'files_encryption', 'recoveryAdminEnabled' );
  21. if($isadmin) {
  22. $accessiblegroups = OC_Group::getGroups();
  23. $accessibleusers = OC_User::getDisplayNames('', 30);
  24. $subadmins = OC_SubAdmin::getAllSubAdmins();
  25. }else{
  26. $accessiblegroups = OC_SubAdmin::getSubAdminsGroups(OC_User::getUser());
  27. $accessibleusers = OC_Group::displayNamesInGroups($accessiblegroups, '', 30);
  28. $subadmins = false;
  29. }
  30. // load preset quotas
  31. $quotaPreset=OC_Appconfig::getValue('files', 'quota_preset', '1 GB, 5 GB, 10 GB');
  32. $quotaPreset=explode(',', $quotaPreset);
  33. foreach($quotaPreset as &$preset) {
  34. $preset=trim($preset);
  35. }
  36. $quotaPreset=array_diff($quotaPreset, array('default', 'none'));
  37. $defaultQuota=OC_Appconfig::getValue('files', 'default_quota', 'none');
  38. $defaultQuotaIsUserDefined=array_search($defaultQuota, $quotaPreset)===false
  39. && array_search($defaultQuota, array('none', 'default'))===false;
  40. // load users and quota
  41. foreach($accessibleusers as $uid => $displayName) {
  42. $quota=OC_Preferences::getValue($uid, 'files', 'quota', 'default');
  43. $isQuotaUserDefined=array_search($quota, $quotaPreset)===false
  44. && array_search($quota, array('none', 'default'))===false;
  45. $name = $displayName;
  46. if ( $displayName !== $uid ) {
  47. $name = $name . ' ('.$uid.')';
  48. }
  49. $users[] = array(
  50. "name" => $uid,
  51. "displayName" => $displayName,
  52. "groups" => OC_Group::getUserGroups($uid),
  53. 'quota' => $quota,
  54. 'isQuotaUserDefined' => $isQuotaUserDefined,
  55. 'subadmin' => OC_SubAdmin::getSubAdminsGroups($uid),
  56. );
  57. }
  58. foreach( $accessiblegroups as $i ) {
  59. // Do some more work here soon
  60. $groups[] = array( "name" => $i );
  61. }
  62. $tmpl = new OC_Template( "settings", "users", "user" );
  63. $tmpl->assign( 'users', $users );
  64. $tmpl->assign( 'groups', $groups );
  65. $tmpl->assign( 'isadmin', (int) $isadmin);
  66. $tmpl->assign( 'subadmins', $subadmins);
  67. $tmpl->assign( 'numofgroups', count($accessiblegroups));
  68. $tmpl->assign( 'quota_preset', $quotaPreset);
  69. $tmpl->assign( 'default_quota', $defaultQuota);
  70. $tmpl->assign( 'defaultQuotaIsUserDefined', $defaultQuotaIsUserDefined);
  71. $tmpl->assign( 'recoveryAdminEnabled', $recoveryAdminEnabled);
  72. $tmpl->assign('enableAvatars', \OC_Config::getValue('enable_avatars', true));
  73. $tmpl->printPage();