diff --git a/lib/private/group/backend.php b/lib/private/group/backend.php index ab694268bb..9348463a53 100644 --- a/lib/private/group/backend.php +++ b/lib/private/group/backend.php @@ -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', ); /** diff --git a/lib/private/group/group.php b/lib/private/group/group.php index 6f8b84dff1..6111051ea0 100644 --- a/lib/private/group/group.php +++ b/lib/private/group/group.php @@ -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_GROUP_BACKEND_ADD_TO_GROUP)) { + if ($backend->implementsActions(\OC_Group_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_GROUP_BACKEND_REMOVE_FROM_GOUP) and $backend->inGroup($user->getUID(), $this->gid)) { + if ($backend->implementsActions(\OC_Group_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_GROUP_BACKEND_COUNT_USERS)) { + if($backend->implementsActions(\OC_Group_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_GROUP_BACKEND_DELETE_GROUP)) { + if ($backend->implementsActions(\OC_Group_Backend::DELETE_GROUP)) { $result = true; $backend->deleteGroup($this->gid); } diff --git a/lib/private/group/interface.php b/lib/private/group/interface.php index ee5c2d635d..ee2d718e5d 100644 --- a/lib/private/group/interface.php +++ b/lib/private/group/interface.php @@ -28,7 +28,7 @@ interface OC_Group_Interface { * @return boolean * * Returns the supported actions as int to be - * compared with OC_GROUP_BACKEND_CREATE_GROUP etc. + * compared with \OC_Group_Backend::CREATE_GROUP etc. */ public function implementsActions($actions); diff --git a/lib/private/group/manager.php b/lib/private/group/manager.php index 417be79ab3..be7bf97269 100644 --- a/lib/private/group/manager.php +++ b/lib/private/group/manager.php @@ -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_GROUP_BACKEND_CREATE_GROUP)) { + if ($backend->implementsActions(\OC_Group_Backend::CREATE_GROUP)) { $backend->createGroup($gid); $group = $this->getGroupObject($gid); $this->emit('\OC\Group', 'postCreate', array($group));