Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

cloud.php 2.9KB

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