Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
die_coolen_jungs
our_own_cloud_project
Commits
24511c6f
Commit
24511c6f
authored
Nov 26, 2014
by
Joas Schilling
Browse files
Move OC_GROUP_BACKEND_* constants to OC_Group_Backend class
parent
a7482227
Changes
4
Hide whitespace changes
Inline
Side-by-side
lib/private/group/backend.php
View file @
24511c6f
...
...
@@ -23,29 +23,51 @@
/**
* error code for functions not provided by the group backend
* @deprecated Use \OC_Group_Backend::NOT_IMPLEMENTED instead
*/
define
(
'OC_GROUP_BACKEND_NOT_IMPLEMENTED'
,
-
501
);
/**
* actions that user backends can define
*/
/** @deprecated Use \OC_Group_Backend::CREATE_GROUP instead */
define
(
'OC_GROUP_BACKEND_CREATE_GROUP'
,
0x00000001
);
/** @deprecated Use \OC_Group_Backend::DELETE_GROUP instead */
define
(
'OC_GROUP_BACKEND_DELETE_GROUP'
,
0x00000010
);
/** @deprecated Use \OC_Group_Backend::ADD_TO_GROUP instead */
define
(
'OC_GROUP_BACKEND_ADD_TO_GROUP'
,
0x00000100
);
/** @deprecated Use \OC_Group_Backend::REMOVE_FROM_GOUP instead */
define
(
'OC_GROUP_BACKEND_REMOVE_FROM_GOUP'
,
0x00001000
);
/** @deprecated Obsolete */
define
(
'OC_GROUP_BACKEND_GET_DISPLAYNAME'
,
0x00010000
);
//OBSOLETE
/** @deprecated Use \OC_Group_Backend::COUNT_USERS instead */
define
(
'OC_GROUP_BACKEND_COUNT_USERS'
,
0x00100000
);
/**
* Abstract base class for user management
*/
abstract
class
OC_Group_Backend
implements
OC_Group_Interface
{
/**
* error code for functions not provided by the group backend
*/
const
NOT_IMPLEMENTED
=
-
501
;
/**
* actions that user backends can define
*/
const
CREATE_GROUP
=
0x00000001
;
const
DELETE_GROUP
=
0x00000010
;
const
ADD_TO_GROUP
=
0x00000100
;
const
REMOVE_FROM_GOUP
=
0x00001000
;
//OBSOLETE const GET_DISPLAYNAME = 0x00010000;
const
COUNT_USERS
=
0x00100000
;
protected
$possibleActions
=
array
(
OC_GROUP_BACKEND_
CREATE_GROUP
=>
'createGroup'
,
OC_GROUP_BACKEND_
DELETE_GROUP
=>
'deleteGroup'
,
OC_GROUP_BACKEND_
ADD_TO_GROUP
=>
'addToGroup'
,
OC_GROUP_BACKEND_
REMOVE_FROM_GOUP
=>
'removeFromGroup'
,
OC_GROUP_BACKEND_
COUNT_USERS
=>
'countUsersInGroup'
,
self
::
CREATE_GROUP
=>
'createGroup'
,
self
::
DELETE_GROUP
=>
'deleteGroup'
,
self
::
ADD_TO_GROUP
=>
'addToGroup'
,
self
::
REMOVE_FROM_GOUP
=>
'removeFromGroup'
,
self
::
COUNT_USERS
=>
'countUsersInGroup'
,
);
/**
...
...
lib/private/group/group.php
View file @
24511c6f
...
...
@@ -118,7 +118,7 @@ class Group implements IGroup {
$this
->
emitter
->
emit
(
'\OC\Group'
,
'preAddUser'
,
array
(
$this
,
$user
));
}
foreach
(
$this
->
backends
as
$backend
)
{
if
(
$backend
->
implementsActions
(
OC_G
ROUP_BACKEND_
ADD_TO_GROUP
))
{
if
(
$backend
->
implementsActions
(
\
OC_G
roup_Backend
::
ADD_TO_GROUP
))
{
$backend
->
addToGroup
(
$user
->
getUID
(),
$this
->
gid
);
if
(
$this
->
users
)
{
$this
->
users
[
$user
->
getUID
()]
=
$user
;
...
...
@@ -142,7 +142,7 @@ class Group implements IGroup {
$this
->
emitter
->
emit
(
'\OC\Group'
,
'preRemoveUser'
,
array
(
$this
,
$user
));
}
foreach
(
$this
->
backends
as
$backend
)
{
if
(
$backend
->
implementsActions
(
OC_G
ROUP_BACKEND_
REMOVE_FROM_GOUP
)
and
$backend
->
inGroup
(
$user
->
getUID
(),
$this
->
gid
))
{
if
(
$backend
->
implementsActions
(
\
OC_G
roup_Backend
::
REMOVE_FROM_GOUP
)
and
$backend
->
inGroup
(
$user
->
getUID
(),
$this
->
gid
))
{
$backend
->
removeFromGroup
(
$user
->
getUID
(),
$this
->
gid
);
$result
=
true
;
}
...
...
@@ -191,7 +191,7 @@ class Group implements IGroup {
public
function
count
(
$search
=
''
)
{
$users
=
false
;
foreach
(
$this
->
backends
as
$backend
)
{
if
(
$backend
->
implementsActions
(
OC_G
ROUP_BACKEND_
COUNT_USERS
))
{
if
(
$backend
->
implementsActions
(
\
OC_G
roup_Backend
::
COUNT_USERS
))
{
if
(
$users
===
false
)
{
//we could directly add to a bool variable, but this would
//be ugly
...
...
@@ -234,7 +234,7 @@ class Group implements IGroup {
$this
->
emitter
->
emit
(
'\OC\Group'
,
'preDelete'
,
array
(
$this
));
}
foreach
(
$this
->
backends
as
$backend
)
{
if
(
$backend
->
implementsActions
(
OC_G
ROUP_BACKEND_
DELETE_GROUP
))
{
if
(
$backend
->
implementsActions
(
\
OC_G
roup_Backend
::
DELETE_GROUP
))
{
$result
=
true
;
$backend
->
deleteGroup
(
$this
->
gid
);
}
...
...
lib/private/group/interface.php
View file @
24511c6f
...
...
@@ -28,7 +28,7 @@ interface OC_Group_Interface {
* @return boolean
*
* Returns the supported actions as int to be
* compared with OC_G
ROUP_BACKEND_
CREATE_GROUP etc.
* compared with
\
OC_G
roup_Backend::
CREATE_GROUP etc.
*/
public
function
implementsActions
(
$actions
);
...
...
lib/private/group/manager.php
View file @
24511c6f
...
...
@@ -134,7 +134,7 @@ class Manager extends PublicEmitter implements IGroupManager {
}
else
{
$this
->
emit
(
'\OC\Group'
,
'preCreate'
,
array
(
$gid
));
foreach
(
$this
->
backends
as
$backend
)
{
if
(
$backend
->
implementsActions
(
OC_G
ROUP_BACKEND_
CREATE_GROUP
))
{
if
(
$backend
->
implementsActions
(
\
OC_G
roup_Backend
::
CREATE_GROUP
))
{
$backend
->
createGroup
(
$gid
);
$group
=
$this
->
getGroupObject
(
$gid
);
$this
->
emit
(
'\OC\Group'
,
'postCreate'
,
array
(
$group
));
...
...
Write
Preview
Markdown
is supported
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