Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/inc/User
diff options
context:
space:
mode:
authorAldo "xoen" Giambelluca <xoen@xoen.org>2010-07-19 23:33:29 +0400
committerAldo "xoen" Giambelluca <xoen@xoen.org>2010-07-19 23:33:29 +0400
commit9fe46ef0937d91c50f8cb2578437bfd740e8c49c (patch)
treeb7bee7e300a3d7021f259513b07b5de87c2802d1 /inc/User
parent9c124a8dbf7c63c8353d3ef6148a618620a3ee3c (diff)
OC_USER now is an abstract class (OC_USER_ABSTRACT)
At start the choosen user manager is created (e.g. OC_USER_DATABASE, OC_USER_LDAP) and put into the global variable `$userManager`. This is the variable to use instead of `OC_USER` class. TODO: A better name than $userManager?
Diffstat (limited to 'inc/User')
-rwxr-xr-xinc/User/database.php26
-rwxr-xr-xinc/User/ldap.php3
-rwxr-xr-xinc/User/mod_auth.php4
3 files changed, 19 insertions, 14 deletions
diff --git a/inc/User/database.php b/inc/User/database.php
index d0bcf56fa96..c4239eb07cd 100755
--- a/inc/User/database.php
+++ b/inc/User/database.php
@@ -21,13 +21,15 @@
*
*/
+require_once $SERVERROOT . '/inc/lib_user.php';
+
/**
* Class for usermanagement in a SQL Database (e.g. MySQL, SQLite)
*
*/
-class OC_USER_Database extends OC_USER {
+class OC_USER_DATABASE extends OC_USER_ABSTRACT {
/**
* Check if the login button is pressed and logg the user in
@@ -35,7 +37,7 @@ class OC_USER_Database extends OC_USER {
*/
public static function loginLisener() {
if ( isset($_POST['loginbutton']) AND isset($_POST['password']) AND isset($_POST['login']) ) {
- if ( OC_USER::login($_POST['login'], $_POST['password']) ) {
+ if ( self::login($_POST['login'], $_POST['password']) ) {
echo 1;
OC_LOG::event($_SESSION['username'], 1, '');
echo 2;
@@ -62,7 +64,7 @@ class OC_USER_Database extends OC_USER {
public static function createUser($username, $password) {
global $CONFIG_DBTABLEPREFIX;
- if ( 0 !== OC_USER::getUserId($username, true) ) {
+ if ( 0 !== self::getUserId($username, true) ) {
return false;
} else {
$usernameClean = strtolower($username);
@@ -132,7 +134,7 @@ class OC_USER_Database extends OC_USER {
public static function createGroup($groupName) {
global $CONFIG_DBTABLEPREFIX;
- if ( 0 === OC_USER::getGroupId($groupName, true) ) {
+ if ( 0 === self::getGroupId($groupName, true) ) {
$groupName = OC_DB::escape($groupName);
$query = "INSERT INTO `{$CONFIG_DBTABLEPREFIX}groups` (`group_name`) VALUES ('$groupName')";
$result = OC_DB::query($query);
@@ -223,8 +225,8 @@ class OC_USER_Database extends OC_USER {
public static function inGroup($username, $groupName) {
global $CONFIG_DBTABLEPREFIX;
- $userId = OC_USER::getUserId($username);
- $groupId = OC_USER::getGroupId($groupName);
+ $userId = self::getUserId($username);
+ $groupId = self::getGroupId($groupName);
if ( ($groupId > 0) AND ($userId > 0) ) {
$query = "SELECT * FROM {$CONFIG_DBTABLEPREFIX}user_group WHERE group_id = '$groupId' AND user_id = '$userId';";
$result = OC_DB::select($query);
@@ -245,9 +247,9 @@ class OC_USER_Database extends OC_USER {
public static function addToGroup($username, $groupName) {
global $CONFIG_DBTABLEPREFIX;
- if ( !OC_USER::inGroup($username, $groupName) ) {
- $userId = OC_USER::getuserid($username);
- $groupId = OC_USER::getgroupid($groupName);
+ if ( !self::inGroup($username, $groupName) ) {
+ $userId = self::getuserid($username);
+ $groupId = self::getgroupid($groupName);
if ( (0 !== $groupId) AND (0 !== $userId) ) {
$query = "INSERT INTO `{$CONFIG_DBTABLEPREFIX}user_group` (`user_id` ,`group_id`) VALUES ('$userId', '$groupId');";
$result = OC_DB::query($query);
@@ -275,14 +277,14 @@ class OC_USER_Database extends OC_USER {
public static function getUserGroups($username) {
global $CONFIG_DBTABLEPREFIX;
- $userId = OC_USER::getUserId($username);
+ $userId = self::getUserId($username);
$query = "SELECT group_id FROM {$CONFIG_DBTABLEPREFIX}user_group WHERE user_id = '$userId'";
$result = OC_DB::select($query);
$groups = array();
if ( is_array($result) ) {
foreach ( $result as $group ) {
$groupId = $group['group_id'];
- $groups[] = OC_USER::getGroupName($groupId);
+ $groups[] = self::getGroupName($groupId);
}
}
@@ -297,7 +299,7 @@ class OC_USER_Database extends OC_USER {
global $CONFIG_DBTABLEPREFIX;
$password = sha1($password);
- $userId = OC_USER::getUserId($username);
+ $userId = self::getUserId($username);
$query = "UPDATE {$CONFIG_DBTABLEPREFIX}users SET user_password = '$password' WHERE user_id ='$userId'";
$result = OC_DB::query($query);
diff --git a/inc/User/ldap.php b/inc/User/ldap.php
index 37ca441fc07..9ce36975bd3 100755
--- a/inc/User/ldap.php
+++ b/inc/User/ldap.php
@@ -21,7 +21,8 @@
*
*/
-require_once 'mod_auth.php';
+require_once $SERVERROOT . '/inc/lib_user.php';
+require_once $SERVERROOT . '/inc/User/mod_auth.php';
diff --git a/inc/User/mod_auth.php b/inc/User/mod_auth.php
index 059bb7b5aaa..8bab4394a5d 100755
--- a/inc/User/mod_auth.php
+++ b/inc/User/mod_auth.php
@@ -21,13 +21,15 @@
*
*/
+require_once $SERVERROOT . '/inc/lib_user.php';
+
/**
* Class for usermanagement in a SQL Database (e.g. MySQL, SQLite)
*
*/
-class OC_USER_MOD_AUTH extends OC_USER {
+class OC_USER_MOD_AUTH extends OC_USER_ABSTRACT {
/**
* Check if the login button is pressed and logg the user in