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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. if($isadmin) {
  20. $accessiblegroups = OC_Group::getGroups();
  21. $accessibleusers = OC_User::getDisplayNames('', 30);
  22. $subadmins = OC_SubAdmin::getAllSubAdmins();
  23. }else{
  24. $accessiblegroups = OC_SubAdmin::getSubAdminsGroups(OC_User::getUser());
  25. $accessibleusers = OC_Group::displayNamesInGroups($accessiblegroups, '', 30);
  26. $subadmins = false;
  27. }
  28. // load preset quotas
  29. $quotaPreset=OC_Appconfig::getValue('files', 'quota_preset', '1 GB, 5 GB, 10 GB');
  30. $quotaPreset=explode(',', $quotaPreset);
  31. foreach($quotaPreset as &$preset) {
  32. $preset=trim($preset);
  33. }
  34. $quotaPreset=array_diff($quotaPreset, array('default', 'none'));
  35. $defaultQuota=OC_Appconfig::getValue('files', 'default_quota', 'none');
  36. $defaultQuotaIsUserDefined=array_search($defaultQuota, $quotaPreset)===false
  37. && array_search($defaultQuota, array('none', 'default'))===false;
  38. // load users and quota
  39. foreach($accessibleusers as $uid => $displayName) {
  40. $quota=OC_Preferences::getValue($uid, 'files', 'quota', 'default');
  41. $isQuotaUserDefined=array_search($quota, $quotaPreset)===false
  42. && array_search($quota, array('none', 'default'))===false;
  43. $name = $displayName;
  44. if ( $displayName != $uid ) {
  45. $name = $name . ' ('.$uid.')';
  46. }
  47. $users[] = array(
  48. "name" => $uid,
  49. "displayName" => $displayName,
  50. "groups" => join( ", ", /*array_intersect(*/OC_Group::getUserGroups($uid)/*, OC_SubAdmin::getSubAdminsGroups(OC_User::getUser()))*/),
  51. 'quota'=>$quota,
  52. 'isQuotaUserDefined'=>$isQuotaUserDefined,
  53. 'subadmin'=>implode(', ', OC_SubAdmin::getSubAdminsGroups($uid)));
  54. }
  55. foreach( $accessiblegroups as $i ) {
  56. // Do some more work here soon
  57. $groups[] = array( "name" => $i );
  58. }
  59. $tmpl = new OC_Template( "settings", "users", "user" );
  60. $tmpl->assign( 'users', $users );
  61. $tmpl->assign( 'groups', $groups );
  62. $tmpl->assign( 'isadmin', (int) $isadmin);
  63. $tmpl->assign( 'subadmins', $subadmins);
  64. $tmpl->assign( 'numofgroups', count($accessiblegroups));
  65. $tmpl->assign( 'quota_preset', $quotaPreset);
  66. $tmpl->assign( 'default_quota', $defaultQuota);
  67. $tmpl->assign( 'defaultQuotaIsUserDefined', $defaultQuotaIsUserDefined);
  68. $tmpl->printPage();