]> source.dussan.org Git - nextcloud-server.git/commitdiff
Implement default functions in OC_User backend
authorBart Visscher <bartv@thisnet.nl>
Tue, 8 May 2012 07:07:11 +0000 (09:07 +0200)
committerBart Visscher <bartv@thisnet.nl>
Thu, 10 May 2012 07:14:26 +0000 (09:14 +0200)
Simplifies calling these functions, and makes code simpler

functions:
deleteUser
getUsers
userExists

apps/user_openid/user_openid.php
lib/user.php
lib/user/backend.php
lib/user/example.php

index 8deb42f68c8637acc23bc5612c94a243bb708ffb..710d400aa57c4642c89336f215605da1a402954c 100755 (executable)
@@ -24,7 +24,7 @@
 require_once('class.openid.v3.php');
 
 /**
- * Class for user management in a SQL Database (e.g. MySQL, SQLite)
+ * Class for user OpenId backend
  */
 class OC_USER_OPENID extends OC_User_Backend {
        /**
index 816caff8dd8de2f0db2cb1117ee0f7f054758476..ad5198d03741162872548b982f4dd368ef673af1 100644 (file)
@@ -161,9 +161,7 @@ class OC_User {
                if( $run ){
                        //delete the user from all backends
                        foreach(self::$_usedBackends as $backend){
-                               if($backend->implementsActions(OC_USER_BACKEND_DELETE_USER)){
-                                       $backend->deleteUser($uid);
-                               }
+                               $backend->deleteUser($uid);
                        }
                        // We have to delete the user from all groups
                        foreach( OC_Group::getUserGroups( $uid ) as $i ){
@@ -323,11 +321,9 @@ class OC_User {
        public static function getUsers(){
                $users=array();
                foreach(self::$_usedBackends as $backend){
-                       if($backend->implementsActions(OC_USER_BACKEND_GET_USERS)){
-                               $backendUsers=$backend->getUsers();
-                               if(is_array($backendUsers)){
-                                       $users=array_merge($users,$backendUsers);
-                               }
+                       $backendUsers=$backend->getUsers();
+                       if(is_array($backendUsers)){
+                               $users=array_merge($users,$backendUsers);
                        }
                }
                return $users;
@@ -340,11 +336,9 @@ class OC_User {
         */
        public static function userExists($uid){
                foreach(self::$_usedBackends as $backend){
-                       if($backend->implementsActions(OC_USER_BACKEND_USER_EXISTS)){
-                               $result=$backend->userExists($uid);
-                               if($result===true){
-                                       return true;
-                               }
+                       $result=$backend->userExists($uid);
+                       if($result===true){
+                               return true;
                        }
                }
                return false;
index 4afdf152150f2015af6b135d7651c177f2a492cb..8c954338fb14ebcaebb3545d7aee8f0dfb036a67 100644 (file)
@@ -32,11 +32,8 @@ define('OC_USER_BACKEND_NOT_IMPLEMENTED',   -501);
  * actions that user backends can define
  */
 define('OC_USER_BACKEND_CREATE_USER',       0x000001);
-define('OC_USER_BACKEND_DELETE_USER',       0x000010);
-define('OC_USER_BACKEND_SET_PASSWORD',      0x000100);
-define('OC_USER_BACKEND_CHECK_PASSWORD',    0x001000);
-define('OC_USER_BACKEND_GET_USERS',         0x010000);
-define('OC_USER_BACKEND_USER_EXISTS',       0x100000);
+define('OC_USER_BACKEND_SET_PASSWORD',      0x000010);
+define('OC_USER_BACKEND_CHECK_PASSWORD',    0x000100);
 
 
 /**
@@ -47,11 +44,8 @@ abstract class OC_User_Backend {
 
        protected $possibleActions = array(
                OC_USER_BACKEND_CREATE_USER => 'createUser',
-               OC_USER_BACKEND_DELETE_USER => 'deleteUser',
                OC_USER_BACKEND_SET_PASSWORD => 'setPassword',
                OC_USER_BACKEND_CHECK_PASSWORD => 'checkPassword',
-               OC_USER_BACKEND_GET_USERS => 'getUsers',
-               OC_USER_BACKEND_USER_EXISTS => 'userExists'
        );
 
        /**
@@ -83,4 +77,34 @@ abstract class OC_User_Backend {
        public function implementsActions($actions){
                return (bool)($this->getSupportedActions() & $actions);
        }
+
+       /**
+       * @brief delete a user
+       * @param $uid The username of the user to delete
+       * @returns true/false
+       *
+       * Deletes a user
+       */
+       public function deleteUser( $uid ){
+               return false;
+       }
+
+       /**
+       * @brief Get a list of all users
+       * @returns array with all uids
+       *
+       * Get a list of all users.
+       */
+       public function getUsers(){
+               return array();
+       }
+
+       /**
+       * @brief check if a user exists
+       * @param string $uid the username
+       * @return boolean
+       */
+       public function userExists($uid){
+               return false;
+       }
 }
index 7481014de77c5fb54ff8183abfdd529886e10573..270b72e389baa806b9751fc7379f910798230c8c 100644 (file)
@@ -39,17 +39,6 @@ abstract class OC_User_Example extends OC_User_Backend {
                return OC_USER_BACKEND_NOT_IMPLEMENTED;
        }
 
-       /**
-               * @brief delete a user
-               * @param $uid The username of the user to delete
-               * @returns true/false
-               *
-               * Deletes a user
-               */
-       public function deleteUser( $uid ){
-               return OC_USER_BACKEND_NOT_IMPLEMENTED;
-       }
-
        /**
                * @brief Set password
                * @param $uid The username
@@ -73,23 +62,4 @@ abstract class OC_User_Example extends OC_User_Backend {
        public function checkPassword($uid, $password){
                return OC_USER_BACKEND_NOT_IMPLEMENTED;
        }
-
-       /**
-               * @brief Get a list of all users
-               * @returns array with all uids
-               *
-               * Get a list of all users.
-               */
-       public function getUsers(){
-               return OC_USER_BACKEND_NOT_IMPLEMENTED;
-       }
-
-       /**
-               * @brief check if a user exists
-               * @param string $uid the username
-               * @return boolean
-               */
-       public function userExists($uid){
-               return OC_USER_BACKEND_NOT_IMPLEMENTED;
-       }
 }