users.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. require_once '../lib/base.php';
  8. OC_Util::checkSubAdminUser();
  9. // We have some javascript foo!
  10. OC_Util::addScript( 'settings', 'users' );
  11. OC_Util::addScript( 'core', 'multiselect' );
  12. OC_Util::addScript('core', 'jquery.inview');
  13. OC_Util::addStyle( 'settings', 'settings' );
  14. OC_App::setActiveNavigationEntry( 'core_users' );
  15. $users = array();
  16. $groups = array();
  17. $isadmin = OC_Group::inGroup(OC_User::getUser(), 'admin')?true:false;
  18. if($isadmin) {
  19. $accessiblegroups = OC_Group::getGroups();
  20. $accessibleusers = OC_User::getUsers('', 30);
  21. $subadmins = OC_SubAdmin::getAllSubAdmins();
  22. }else{
  23. $accessiblegroups = OC_SubAdmin::getSubAdminsGroups(OC_User::getUser());
  24. $accessibleusers = OC_Group::usersInGroups($accessiblegroups, '', 30);
  25. $subadmins = false;
  26. }
  27. foreach($accessibleusers as $i){
  28. $users[] = array(
  29. "name" => $i,
  30. "groups" => join( ", ", /*array_intersect(*/OC_Group::getUserGroups($i)/*, OC_SubAdmin::getSubAdminsGroups(OC_User::getUser()))*/),
  31. 'quota'=>OC_Preferences::getValue($i, 'files', 'quota', 'default'),
  32. 'subadmin'=>implode(', ', OC_SubAdmin::getSubAdminsGroups($i)));
  33. }
  34. foreach( $accessiblegroups as $i ){
  35. // Do some more work here soon
  36. $groups[] = array( "name" => $i );
  37. }
  38. $quotaPreset=OC_Appconfig::getValue('files', 'quota_preset', 'default,none,1 GB, 5 GB, 10 GB');
  39. $quotaPreset=explode(',',$quotaPreset);
  40. foreach($quotaPreset as &$preset){
  41. $preset=trim($preset);
  42. }
  43. $defaultQuota=OC_Appconfig::getValue('files', 'default_quota', 'none');
  44. $tmpl = new OC_Template( "settings", "users", "user" );
  45. $tmpl->assign( "users", $users );
  46. $tmpl->assign( "groups", $groups );
  47. $tmpl->assign( 'isadmin', (int) $isadmin);
  48. $tmpl->assign( 'subadmins', $subadmins);
  49. $tmpl->assign( 'numofgroups', count($accessiblegroups));
  50. $tmpl->assign( 'quota_preset', $quotaPreset);
  51. $tmpl->assign( 'default_quota', $defaultQuota);
  52. $tmpl->printPage();