Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Fachrat Informatik
user_wcf
Commits
a33671a3
Commit
a33671a3
authored
Jul 09, 2017
by
Sven Greiner
Browse files
Just copy & paste without testing
parent
2c761cce
Changes
2
Hide whitespace changes
Inline
Side-by-side
group_wcf.php
View file @
a33671a3
...
...
@@ -16,32 +16,36 @@ namespace OCA\user_wcf;
* $wcfPath parameter.
*/
class
Group_WCF
ext
en
d
s
\
OC
_
Group
_Backend
{
class
Group_WCF
implem
en
t
s
\
OC
P\
Group
Interface
{
protected
$db
;
public
function
__construct
()
{
require
(
\
OC_App
::
getAppPath
(
'user_wcf'
)
.
'/config/config.php'
);
if
(
!
file_exists
(
$wcfPath
)
||
!
is_dir
(
$wcfPath
))
throw
new
\
Exception
(
'Not a valid WCF path: "'
.
$wcfPath
.
'"'
);
$this
->
db
=
lib\WCF_DB
::
getInstance
(
$wcfPath
);
$this
->
db
->
setAuthorizedGroups
(
$authorizedGroups
);
}
/**
* @brief Check if backend implements actions
* @param int $actions bitwise-or'ed actions
* @return boolean
*
* Returns the supported actions as int to be
* compared with OC_GROUP_BACKEND_CREATE_GROUP etc.
*/
public
function
getSupportedActions
()
{
return
OC_GROUP_BACKEND_GET_DISPLAYNAME
;
* Check if backend implements actions
* @param int $actions bitwise-or'ed actions
* @return boolean
* @since 4.5.0
*
* Returns the supported actions as int to be
* compared with \OC_Group_Backend::CREATE_GROUP etc.
*/
public
function
implementsActions
(
$actions
)
{
return
(
bool
)(
GROUP_DETAILS
&
$actions
);
}
/**
*
@brief
is user in group?
* is user in group?
* @param string $uid uid of the user
* @param string $gid gid of the group
* @return bool
* @since 4.5.0
*
* Checks whether the user is member of a group or not.
*/
...
...
@@ -59,9 +63,10 @@ class Group_WCF extends \OC_Group_Backend {
}
/**
*
@brief
Get all groups a user belongs to
* Get all groups a user belongs to
* @param string $uid Name of the user
* @return array with group names
* @return array an array of group names
* @since 4.5.0
*
* This function fetches all groups a user belongs to. It does not check
* if the user exists at all.
...
...
@@ -80,15 +85,16 @@ class Group_WCF extends \OC_Group_Backend {
}
/**
*
@brief
get a list of all groups
* get a list of all groups
* @param string $search
* @param int $limit
* @param int $offset
* @return array with group names
* @return array an array of group names
* @since 4.5.0
*
* Returns a list with all groups
*/
public
function
getGroups
(
$search
=
''
,
$limit
=
null
,
$offset
=
null
)
{
public
function
getGroups
(
$search
=
''
,
$limit
=
-
1
,
$offset
=
0
)
{
$groups
=
array
();
$params
=
array
();
$where
=
NULL
;
...
...
@@ -122,11 +128,12 @@ class Group_WCF extends \OC_Group_Backend {
}
return
$groups
;
}
/**
* check if a group exists
* @param string $gid
* @return bool
* @since 4.5.0
*/
public
function
groupExists
(
$gid
)
{
$exists
=
FALSE
;
...
...
@@ -140,12 +147,13 @@ class Group_WCF extends \OC_Group_Backend {
}
/**
*
@brief
get a list of all users in a group
* get a list of all users in a group
* @param string $gid
* @param string $search
* @param int $limit
* @param int $offset
* @return array with user ids
* @return array an array of user ids
* @since 4.5.0
*/
public
function
usersInGroup
(
$gid
,
$search
=
''
,
$limit
=
-
1
,
$offset
=
0
)
{
$users
=
array
();
...
...
user_wcf.php
View file @
a33671a3
...
...
@@ -8,6 +8,7 @@
namespace
OCA\user_wcf
;
use
OC\User\Backend
;
/**
* This class authenticates users against a WCF database if they belong to
...
...
@@ -15,7 +16,7 @@ namespace OCA\user_wcf;
* database configuration is imported from the WCF configuration file of
* the WCF installation given in the $wcfPath paramter.
*/
class
User_WCF
ext
en
d
s
\
OC
_
User
_
Backend
{
class
User_WCF
implem
en
t
s
\
OC
P\I
UserBackend
,
\
OCP\UserInterface
{
protected
$authorizedGroups
;
protected
$groupsCondition
;
protected
$db
=
NULL
;
...
...
@@ -28,8 +29,127 @@ class User_WCF extends \OC_User_Backend {
$this
->
db
->
setAuthorizedGroups
(
$authorizedGroups
);
}
public
function
getSupportedActions
()
{
return
OC_USER_BACKEND_CHECK_PASSWORD
|
OC_USER_BACKEND_GET_DISPLAYNAME
;
/**
* Backend name to be shown in user management
* @return string the name of the backend to be shown
* @since 8.0.0
*/
public
function
getBackendName
()
{
return
"WCF"
;
}
/**
* Check if backend implements actions
* @param int $actions bitwise-or'ed actions
* @return boolean
*
* Returns the supported actions as int to be
* compared with \OC_User_Backend::CREATE_USER etc.
* @since 4.5.0
*/
public
function
implementsActions
(
$actions
)
{
return
(
bool
)((
Backend
::
CHECK_PASSWORD
|
Backend
::
GET_DISPLAYNAME
)
&
$actions
);
}
/**
* delete a user
* @param string $uid The username of the user to delete
* @return bool
* @since 4.5.0
* @todo
*/
public
function
deleteUser
(
$uid
);
/**
* Get a list of all users
*
* @param string $search
* @param null|int $limit
* @param null|int $offset
* @return string[] an array of all uids
* @since 4.5.0
*/
public
function
getUsers
(
$search
=
''
,
$limit
=
null
,
$offset
=
null
)
{
$users
=
array
();
$params
=
array
();
$where
=
NULL
;
$append
=
'ORDER BY username'
;
if
(
$search
!==
''
)
{
$where
=
'username LIKE ?'
;
$params
[]
=
'%'
.
$search
.
'%'
;
}
if
(
$limit
!==
NULL
)
{
$append
.
=
' LIMIT '
.
intval
(
$limit
);
}
if
(
$offset
!==
NULL
)
{
$append
.
=
' OFFSET '
.
intval
(
$offset
);;
}
$result
=
$this
->
db
->
prepare
(
'username'
,
$where
,
$append
);
if
(
$result
!==
FALSE
and
$result
->
execute
(
$params
))
{
if
(
$result
->
rowCount
()
<=
0
)
{
$this
->
warn
(
'No users returned from database.'
);
}
foreach
(
$result
as
$row
)
{
$users
[]
=
$row
[
'username'
];
}
$result
->
closeCursor
();
}
else
{
$this
->
warn
(
'Error executing statement to get user list.'
);
}
return
$users
;
}
/**
* check if a user exists
* @param string $uid the username
* @return boolean
* @since 4.5.0
*/
public
function
userExists
(
$uid
)
{
$exists
=
FALSE
;
$result
=
$this
->
db
->
prepare
(
'1'
,
'username=?'
);
if
(
$result
!==
FALSE
and
$result
->
execute
(
array
(
$uid
)))
{
$exists
=
(
$result
->
fetch
()
!==
FALSE
);
$result
->
closeCursor
();
}
return
$exists
;
}
/**
* get display name of the user
* @param string $uid user ID of the user
* @return string display name
* @since 4.5.0
* @todo
*/
public
function
getDisplayName
(
$uid
);
/**
* Get a list of all display names and user ids.
*
* @param string $search
* @param string|null $limit
* @param string|null $offset
* @return array an array of all displayNames (value) and the corresponding uids (key)
* @since 4.5.0
* @todo
*/
public
function
getDisplayNames
(
$search
=
''
,
$limit
=
null
,
$offset
=
null
);
/**
* Check if a user list is available or not
* @return boolean if users can be listed or not
* @since 4.5.0
*/
public
function
hasUserListings
()
{
return
true
;
}
/**
...
...
@@ -73,51 +193,6 @@ class User_WCF extends \OC_User_Backend {
return
$authenticatedAs
;
}
public
function
userExists
(
$uid
)
{
$exists
=
FALSE
;
$result
=
$this
->
db
->
prepare
(
'1'
,
'username=?'
);
if
(
$result
!==
FALSE
and
$result
->
execute
(
array
(
$uid
)))
{
$exists
=
(
$result
->
fetch
()
!==
FALSE
);
$result
->
closeCursor
();
}
return
$exists
;
}
public
function
getUsers
(
$search
=
''
,
$limit
=
null
,
$offset
=
null
)
{
$users
=
array
();
$params
=
array
();
$where
=
NULL
;
$append
=
'ORDER BY username'
;
if
(
$search
!==
''
)
{
$where
=
'username LIKE ?'
;
$params
[]
=
'%'
.
$search
.
'%'
;
}
if
(
$limit
!==
NULL
)
{
$append
.
=
' LIMIT '
.
intval
(
$limit
);
}
if
(
$offset
!==
NULL
)
{
$append
.
=
' OFFSET '
.
intval
(
$offset
);;
}
$result
=
$this
->
db
->
prepare
(
'username'
,
$where
,
$append
);
if
(
$result
!==
FALSE
and
$result
->
execute
(
$params
))
{
if
(
$result
->
rowCount
()
<=
0
)
{
$this
->
warn
(
'No users returned from database.'
);
}
foreach
(
$result
as
$row
)
{
$users
[]
=
$row
[
'username'
];
}
$result
->
closeCursor
();
}
else
{
$this
->
warn
(
'Error executing statement to get user list.'
);
}
return
$users
;
}
public
static
function
info
(
$text
)
{
\
OCP\Util
::
writeLog
(
'user_wcf'
,
$text
,
\
OCP\Util
::
INFO
);
}
...
...
@@ -129,21 +204,4 @@ class User_WCF extends \OC_User_Backend {
public
static
function
debug
(
$text
)
{
\
OCP\Util
::
writeLog
(
'user_wcf'
,
$text
,
\
OCP\Util
::
DEBUG
);
}
/**
* Backend name to be shown in user management
* @return string the name of the backend to be shown
*/
public
function
getBackendName
(){
return
'WCF'
;
}
/**
* Check if a user list is available or not
* @return boolean if users can be listed or not
*/
public
function
hasUserListings
()
{
return
true
;
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment