Commit 24511c6f authored by Joas Schilling's avatar Joas Schilling
Browse files

Move OC_GROUP_BACKEND_* constants to OC_Group_Backend class

parent a7482227
......@@ -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',
);
/**
......
......@@ -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);
}
......
......@@ -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);
......
......@@ -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));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment