users.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. // TODO Move script to core
  13. OC_Util::addScript('contacts', 'jquery.inview');
  14. OC_Util::addStyle( 'settings', 'settings' );
  15. OC_App::setActiveNavigationEntry( 'core_users' );
  16. $users = array();
  17. $groups = array();
  18. $isadmin = OC_Group::inGroup(OC_User::getUser(),'admin')?true:false;
  19. if($isadmin){
  20. $accessiblegroups = OC_Group::getGroups();
  21. $accessibleusers = OC_User::getUsers('', 30);
  22. $subadmins = OC_SubAdmin::getAllSubAdmins();
  23. }else{
  24. $accessiblegroups = OC_SubAdmin::getSubAdminsGroups(OC_User::getUser());
  25. $accessibleusers = OC_Group::usersInGroups($accessiblegroups, '', 30);
  26. $subadmins = false;
  27. }
  28. foreach($accessibleusers as $i){
  29. $users[] = array( "name" => $i, "groups" => join( ", ", /*array_intersect(*/OC_Group::getUserGroups($i)/*, OC_SubAdmin::getSubAdminsGroups(OC_User::getUser()))*/),'quota'=>OC_Preferences::getValue($i,'files','quota','default'),'subadmin'=>implode(', ',OC_SubAdmin::getSubAdminsGroups($i)));
  30. }
  31. foreach( $accessiblegroups as $i ){
  32. // Do some more work here soon
  33. $groups[] = array( "name" => $i );
  34. }
  35. $quotaPreset=OC_Appconfig::getValue('files','quota_preset','default,none,1 GB, 5 GB, 10 GB');
  36. $quotaPreset=explode(',',$quotaPreset);
  37. foreach($quotaPreset as &$preset){
  38. $preset=trim($preset);
  39. }
  40. $defaultQuota=OC_Appconfig::getValue('files','default_quota','none');
  41. $shareNotice = '';
  42. if (\OC_App::isEnabled( "files_sharing" ) ) {
  43. $shareNotice = 'Note: users may only share to groups that they belong to, and their members';
  44. }
  45. $tmpl = new OC_Template( "settings", "users", "user" );
  46. $tmpl->assign( "users", $users );
  47. $tmpl->assign( "groups", $groups );
  48. $tmpl->assign( 'isadmin', (int) $isadmin);
  49. $tmpl->assign( 'subadmins', $subadmins);
  50. $tmpl->assign( 'numofgroups', count($accessiblegroups));
  51. $tmpl->assign( 'quota_preset', $quotaPreset);
  52. $tmpl->assign( 'default_quota', $defaultQuota);
  53. $tmpl->assign( 'share_notice', $shareNotice);
  54. $tmpl->printPage();