Skip to content
Snippets Groups Projects
Commit 3338c424 authored by Fjen Undso's avatar Fjen Undso
Browse files

group: use new interface

parent 2c761cce
Branches master
No related tags found
No related merge requests found
......@@ -16,32 +16,36 @@ namespace OCA\user_wcf;
* $wcfPath parameter.
*/
class Group_WCF extends \OC_Group_Backend {
class Group_WCF implements \OCP\GroupInterface {
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)(0
& $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;
......@@ -100,7 +106,7 @@ class Group_WCF extends \OC_Group_Backend {
$params[] = '%'.$search.'%';
}
if (!($limit === -1 or is_null($limit))) {
$append .= ' LIMIT '.intval($liumit);
$append .= ' LIMIT '.intval($limit);
}
if (!($offset === 0 or is_null($offset))) {
$append .= ' OFFSET '.intval($offset);
......@@ -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();
......@@ -175,3 +183,4 @@ class Group_WCF extends \OC_Group_Backend {
return $users;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment