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.

cloud.php 3.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <?php
  2. /**
  3. * @author Bart Visscher <bartv@thisnet.nl>
  4. * @author Morris Jobke <hey@morrisjobke.de>
  5. * @author Robin McCorkell <rmccorkell@karoshi.org.uk>
  6. * @author Roeland Jago Douma <roeland@famdouma.nl>
  7. * @author Thomas Müller <thomas.mueller@tmit.eu>
  8. * @author Tom Needham <tom@owncloud.com>
  9. *
  10. * @copyright Copyright (c) 2015, ownCloud, Inc.
  11. * @license AGPL-3.0
  12. *
  13. * This code is free software: you can redistribute it and/or modify
  14. * it under the terms of the GNU Affero General Public License, version 3,
  15. * as published by the Free Software Foundation.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU Affero General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU Affero General Public License, version 3,
  23. * along with this program. If not, see <http://www.gnu.org/licenses/>
  24. *
  25. */
  26. class OC_OCS_Cloud {
  27. public static function getCapabilities() {
  28. $result = array();
  29. list($major, $minor, $micro) = OC_Util::getVersion();
  30. $result['version'] = array(
  31. 'major' => $major,
  32. 'minor' => $minor,
  33. 'micro' => $micro,
  34. 'string' => OC_Util::getVersionString(),
  35. 'edition' => OC_Util::getEditionString(),
  36. );
  37. $result['capabilities'] = \OC::$server->getCapabilitiesManager()->getCapabilities();
  38. return new OC_OCS_Result($result);
  39. }
  40. /**
  41. * gets user info
  42. *
  43. * exposes the quota of an user:
  44. * <data>
  45. * <quota>
  46. * <free>1234</free>
  47. * <used>4321</used>
  48. * <total>5555</total>
  49. * <ralative>0.78</ralative>
  50. * </quota>
  51. * </data>
  52. *
  53. * @param array $parameters should contain parameter 'userid' which identifies
  54. * the user from whom the information will be returned
  55. */
  56. public static function getUser($parameters) {
  57. $return = array();
  58. // Check if they are viewing information on themselves
  59. if($parameters['userid'] === OC_User::getUser()) {
  60. // Self lookup
  61. $storage = OC_Helper::getStorageInfo('/');
  62. $return['quota'] = array(
  63. 'free' => $storage['free'],
  64. 'used' => $storage['used'],
  65. 'total' => $storage['total'],
  66. 'relative' => $storage['relative'],
  67. );
  68. }
  69. if(OC_User::isAdminUser(OC_User::getUser())
  70. || OC_Subadmin::isUserAccessible(OC_User::getUser(), $parameters['userid'])) {
  71. if(OC_User::userExists($parameters['userid'])) {
  72. // Is an admin/subadmin so can see display name
  73. $return['displayname'] = OC_User::getDisplayName($parameters['userid']);
  74. } else {
  75. return new OC_OCS_Result(null, 101);
  76. }
  77. }
  78. if(count($return)) {
  79. return new OC_OCS_Result($return);
  80. } else {
  81. // No permission to view this user data
  82. return new OC_OCS_Result(null, 997);
  83. }
  84. }
  85. public static function getCurrentUser() {
  86. $email=\OC::$server->getConfig()->getUserValue(OC_User::getUser(), 'settings', 'email', '');
  87. $data = array(
  88. 'id' => OC_User::getUser(),
  89. 'display-name' => OC_User::getDisplayName(),
  90. 'email' => $email,
  91. );
  92. return new OC_OCS_Result($data);
  93. }
  94. }