backend.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. <?php
  2. /**
  3. * ownCloud
  4. *
  5. * @author Frank Karlitschek
  6. * @author Dominik Schmidt
  7. * @copyright 2012 Frank Karlitschek frank@owncloud.org
  8. * @copyright 2011 Dominik Schmidt dev@dominik-schmidt.de
  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. /**
  25. * error code for functions not provided by the user backend
  26. */
  27. define('OC_USER_BACKEND_NOT_IMPLEMENTED', -501);
  28. /**
  29. * actions that user backends can define
  30. */
  31. define('OC_USER_BACKEND_CREATE_USER', 0x000001);
  32. define('OC_USER_BACKEND_SET_PASSWORD', 0x000010);
  33. define('OC_USER_BACKEND_CHECK_PASSWORD', 0x000100);
  34. define('OC_USER_BACKEND_GET_HOME', 0x001000);
  35. /**
  36. * Abstract base class for user management. Provides methods for querying backend
  37. * capabilities.
  38. *
  39. * Subclass this for your own backends, and see OC_User_Example for descriptions
  40. */
  41. abstract class OC_User_Backend implements OC_User_Interface {
  42. protected $possibleActions = array(
  43. OC_USER_BACKEND_CREATE_USER => 'createUser',
  44. OC_USER_BACKEND_SET_PASSWORD => 'setPassword',
  45. OC_USER_BACKEND_CHECK_PASSWORD => 'checkPassword',
  46. OC_USER_BACKEND_GET_HOME => 'getHome',
  47. );
  48. /**
  49. * @brief Get all supported actions
  50. * @returns bitwise-or'ed actions
  51. *
  52. * Returns the supported actions as int to be
  53. * compared with OC_USER_BACKEND_CREATE_USER etc.
  54. */
  55. public function getSupportedActions(){
  56. $actions = 0;
  57. foreach($this->possibleActions AS $action => $methodName){
  58. if(method_exists($this, $methodName)) {
  59. $actions |= $action;
  60. }
  61. }
  62. return $actions;
  63. }
  64. /**
  65. * @brief Check if backend implements actions
  66. * @param $actions bitwise-or'ed actions
  67. * @returns boolean
  68. *
  69. * Returns the supported actions as int to be
  70. * compared with OC_USER_BACKEND_CREATE_USER etc.
  71. */
  72. public function implementsActions($actions){
  73. return (bool)($this->getSupportedActions() & $actions);
  74. }
  75. /**
  76. * @brief delete a user
  77. * @param $uid The username of the user to delete
  78. * @returns true/false
  79. *
  80. * Deletes a user
  81. */
  82. public function deleteUser( $uid ){
  83. return false;
  84. }
  85. /**
  86. * @brief Get a list of all users
  87. * @returns array with all uids
  88. *
  89. * Get a list of all users.
  90. */
  91. public function getUsers($search = '', $limit = null, $offset = null) {
  92. return array();
  93. }
  94. /**
  95. * @brief check if a user exists
  96. * @param string $uid the username
  97. * @return boolean
  98. */
  99. public function userExists($uid){
  100. return false;
  101. }
  102. /**
  103. * @brief get the user's home directory
  104. * @param string $uid the username
  105. * @return boolean
  106. */
  107. public function getHome($uid){
  108. return false;
  109. }
  110. }