summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2014-12-19 13:15:50 +0100
committerThomas Müller <thomas.mueller@tmit.eu>2014-12-19 13:15:50 +0100
commit2d647973202151c12a3bd5f0396657212b1f7b7f (patch)
treee8c775f5b0ece150818a78540edd7abbd6d87274
parent678642a6a274610dc62f627d43be9ca42286858a (diff)
parent6da33e1ea7bb340e22330941d2a980a1414210b0 (diff)
downloadnextcloud-server-2d647973202151c12a3bd5f0396657212b1f7b7f.tar.gz
nextcloud-server-2d647973202151c12a3bd5f0396657212b1f7b7f.zip
Merge pull request #12956 from owncloud/jenkins-user-backend-names
[jenkins only] introduce names for user backends - IUserBackend
-rw-r--r--apps/user_ldap/user_ldap.php11
-rw-r--r--apps/user_ldap/user_proxy.php10
-rw-r--r--apps/user_webdavauth/user_webdavauth.php10
-rw-r--r--lib/private/user/database.php10
-rw-r--r--lib/private/user/dummy.php10
-rw-r--r--lib/private/user/http.php10
-rw-r--r--lib/private/user/manager.php11
-rw-r--r--lib/private/user/user.php3
-rw-r--r--lib/public/iuserbackend.php27
-rw-r--r--tests/lib/user/manager.php10
-rw-r--r--tests/lib/user/user.php4
11 files changed, 105 insertions, 11 deletions
diff --git a/apps/user_ldap/user_ldap.php b/apps/user_ldap/user_ldap.php
index 6c7db662ffb..482715b3686 100644
--- a/apps/user_ldap/user_ldap.php
+++ b/apps/user_ldap/user_ldap.php
@@ -27,7 +27,7 @@ namespace OCA\user_ldap;
use OCA\user_ldap\lib\BackendUtility;
-class USER_LDAP extends BackendUtility implements \OCP\UserInterface {
+class USER_LDAP extends BackendUtility implements \OCP\IUserBackend, \OCP\UserInterface {
/**
* checks whether the user is allowed to change his avatar in ownCloud
* @param string $uid the ownCloud user name
@@ -299,4 +299,13 @@ class USER_LDAP extends BackendUtility implements \OCP\UserInterface {
$this->access->connection->writeToCache($cacheKey, $entries);
return $entries;
}
+
+ /**
+ * Backend name to be shown in user management
+ * @return string the name of the backend to be shown
+ */
+ public function getBackendName(){
+ return 'LDAP';
+ }
+
}
diff --git a/apps/user_ldap/user_proxy.php b/apps/user_ldap/user_proxy.php
index fa4d6939303..6414a048071 100644
--- a/apps/user_ldap/user_proxy.php
+++ b/apps/user_ldap/user_proxy.php
@@ -25,7 +25,7 @@ namespace OCA\user_ldap;
use OCA\user_ldap\lib\ILDAPWrapper;
-class User_Proxy extends lib\Proxy implements \OCP\UserInterface {
+class User_Proxy extends lib\Proxy implements \OCP\IUserBackend, \OCP\UserInterface {
private $backends = array();
private $refBackend = null;
@@ -118,6 +118,14 @@ class User_Proxy extends lib\Proxy implements \OCP\UserInterface {
}
/**
+ * Backend name to be shown in user management
+ * @return string the name of the backend to be shown
+ */
+ public function getBackendName() {
+ return $this->refBackend->getBackendName();
+ }
+
+ /**
* Get a list of all users
* @return string[] with all uids
*
diff --git a/apps/user_webdavauth/user_webdavauth.php b/apps/user_webdavauth/user_webdavauth.php
index 86e5b916f3d..1154a7865be 100644
--- a/apps/user_webdavauth/user_webdavauth.php
+++ b/apps/user_webdavauth/user_webdavauth.php
@@ -21,7 +21,7 @@
*
*/
-class OC_USER_WEBDAVAUTH extends OC_User_Backend {
+class OC_USER_WEBDAVAUTH extends OC_User_Backend implements \OCP\IUserBackend {
protected $webdavauth_url;
public function __construct() {
@@ -86,4 +86,12 @@ class OC_USER_WEBDAVAUTH extends OC_User_Backend {
return $returnArray;
}
+
+ /**
+ * Backend name to be shown in user management
+ * @return string the name of the backend to be shown
+ */
+ public function getBackendName(){
+ return 'WebDAV';
+ }
}
diff --git a/lib/private/user/database.php b/lib/private/user/database.php
index a6289066f05..de6c72e4745 100644
--- a/lib/private/user/database.php
+++ b/lib/private/user/database.php
@@ -36,7 +36,7 @@
/**
* Class for user management in a SQL Database (e.g. MySQL, SQLite)
*/
-class OC_User_Database extends OC_User_Backend {
+class OC_User_Database extends OC_User_Backend implements \OCP\IUserBackend {
private $cache = array();
/**
@@ -260,4 +260,12 @@ class OC_User_Database extends OC_User_Backend {
return $result->fetchOne();
}
+ /**
+ * Backend name to be shown in user management
+ * @return string the name of the backend to be shown
+ */
+ public function getBackendName(){
+ return 'Database';
+ }
+
}
diff --git a/lib/private/user/dummy.php b/lib/private/user/dummy.php
index fd0201734fa..322a4562ee6 100644
--- a/lib/private/user/dummy.php
+++ b/lib/private/user/dummy.php
@@ -24,7 +24,7 @@
/**
* dummy user backend, does not keep state, only for testing use
*/
-class OC_User_Dummy extends OC_User_Backend {
+class OC_User_Dummy extends OC_User_Backend implements \OCP\IUserBackend {
private $users = array();
private $displayNames = array();
@@ -156,4 +156,12 @@ class OC_User_Dummy extends OC_User_Backend {
public function getDisplayName($uid) {
return isset($this->displayNames[$uid])? $this->displayNames[$uid]: $uid;
}
+
+ /**
+ * Backend name to be shown in user management
+ * @return string the name of the backend to be shown
+ */
+ public function getBackendName(){
+ return 'Dummy';
+ }
}
diff --git a/lib/private/user/http.php b/lib/private/user/http.php
index 617e8adb3f2..8375c4e1e22 100644
--- a/lib/private/user/http.php
+++ b/lib/private/user/http.php
@@ -24,7 +24,7 @@
/**
* user backend using http auth requests
*/
-class OC_User_HTTP extends OC_User_Backend {
+class OC_User_HTTP extends OC_User_Backend implements \OCP\IUserBackend {
/**
* split http://user@host/path into a user and url part
* @param string $url
@@ -109,4 +109,12 @@ class OC_User_HTTP extends OC_User_Backend {
return false;
}
}
+
+ /**
+ * Backend name to be shown in user management
+ * @return string the name of the backend to be shown
+ */
+ public function getBackendName(){
+ return 'HTTP';
+ }
}
diff --git a/lib/private/user/manager.php b/lib/private/user/manager.php
index 2c56ea261d6..1fc89f8c2c2 100644
--- a/lib/private/user/manager.php
+++ b/lib/private/user/manager.php
@@ -279,10 +279,15 @@ class Manager extends PublicEmitter implements IUserManager {
if ($backend->implementsActions(\OC_User_Backend::COUNT_USERS)) {
$backendusers = $backend->countUsers();
if($backendusers !== false) {
- if(isset($userCountStatistics[get_class($backend)])) {
- $userCountStatistics[get_class($backend)] += $backendusers;
+ if($backend instanceof \OCP\IUserBackend) {
+ $name = $backend->getBackendName();
} else {
- $userCountStatistics[get_class($backend)] = $backendusers;
+ $name = get_class($backend);
+ }
+ if(isset($userCountStatistics[$name])) {
+ $userCountStatistics[$name] += $backendusers;
+ } else {
+ $userCountStatistics[$name] = $backendusers;
}
}
}
diff --git a/lib/private/user/user.php b/lib/private/user/user.php
index 062081d51d4..0b4f9a24276 100644
--- a/lib/private/user/user.php
+++ b/lib/private/user/user.php
@@ -225,6 +225,9 @@ class User implements IUser {
* @return string
*/
public function getBackendClassName() {
+ if($this->backend instanceof \OCP\IUserBackend) {
+ return $this->backend->getBackendName();
+ }
return get_class($this->backend);
}
diff --git a/lib/public/iuserbackend.php b/lib/public/iuserbackend.php
new file mode 100644
index 00000000000..79b5740ee93
--- /dev/null
+++ b/lib/public/iuserbackend.php
@@ -0,0 +1,27 @@
+<?php
+/**
+ * Copyright (c) 2014 Morris Jobke <hey@morrisjobke.de>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+
+/**
+ * Public interface of ownCloud for apps to use.
+ * User Interface version 2
+ *
+ */
+
+// use OCP namespace for all classes that are considered public.
+// This means that they should be used by apps instead of the internal ownCloud classes
+namespace OCP;
+
+interface IUserBackend {
+
+ /**
+ * Backend name to be shown in user management
+ * @return string the name of the backend to be shown
+ */
+ public function getBackendName();
+
+}
diff --git a/tests/lib/user/manager.php b/tests/lib/user/manager.php
index 9cb9374d89f..cc8bcd65896 100644
--- a/tests/lib/user/manager.php
+++ b/tests/lib/user/manager.php
@@ -380,6 +380,10 @@ class Manager extends \Test\TestCase {
->with(\OC_USER_BACKEND_COUNT_USERS)
->will($this->returnValue(true));
+ $backend->expects($this->once())
+ ->method('getBackendName')
+ ->will($this->returnValue('Mock_OC_User_Dummy'));
+
$manager = new \OC\User\Manager();
$manager->registerBackend($backend);
@@ -404,6 +408,9 @@ class Manager extends \Test\TestCase {
->method('implementsActions')
->with(\OC_USER_BACKEND_COUNT_USERS)
->will($this->returnValue(true));
+ $backend1->expects($this->once())
+ ->method('getBackendName')
+ ->will($this->returnValue('Mock_OC_User_Dummy'));
$backend2 = $this->getMock('\OC_User_Dummy');
$backend2->expects($this->once())
@@ -414,6 +421,9 @@ class Manager extends \Test\TestCase {
->method('implementsActions')
->with(\OC_USER_BACKEND_COUNT_USERS)
->will($this->returnValue(true));
+ $backend2->expects($this->once())
+ ->method('getBackendName')
+ ->will($this->returnValue('Mock_OC_User_Dummy'));
$manager = new \OC\User\Manager();
$manager->registerBackend($backend1);
diff --git a/tests/lib/user/user.php b/tests/lib/user/user.php
index e7085182fd6..b1df975b60f 100644
--- a/tests/lib/user/user.php
+++ b/tests/lib/user/user.php
@@ -217,9 +217,9 @@ class User extends \Test\TestCase {
public function testGetBackendClassName() {
$user = new \OC\User\User('foo', new \OC_User_Dummy());
- $this->assertEquals('OC_User_Dummy', $user->getBackendClassName());
+ $this->assertEquals('Dummy', $user->getBackendClassName());
$user = new \OC\User\User('foo', new \OC_User_Database());
- $this->assertEquals('OC_User_Database', $user->getBackendClassName());
+ $this->assertEquals('Database', $user->getBackendClassName());
}
public function testGetHomeNotSupported() {