Commit 3338c424 authored by Fjen Undso's avatar Fjen Undso
Browse files

group: use new interface

parent 2c761cce
...@@ -16,32 +16,36 @@ namespace OCA\user_wcf; ...@@ -16,32 +16,36 @@ namespace OCA\user_wcf;
* $wcfPath parameter. * $wcfPath parameter.
*/ */
class Group_WCF extends \OC_Group_Backend { class Group_WCF implements \OCP\GroupInterface {
protected $db; protected $db;
public function __construct() { public function __construct() {
require(\OC_App::getAppPath('user_wcf').'/config/config.php'); 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.'"'); 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 = lib\WCF_DB::getInstance($wcfPath);
$this->db->setAuthorizedGroups($authorizedGroups); $this->db->setAuthorizedGroups($authorizedGroups);
} }
/** /**
* @brief Check if backend implements actions * Check if backend implements actions
* @param int $actions bitwise-or'ed actions * @param int $actions bitwise-or'ed actions
* @return boolean * @return boolean
* * @since 4.5.0
* Returns the supported actions as int to be *
* compared with OC_GROUP_BACKEND_CREATE_GROUP etc. * 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; 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 $uid uid of the user
* @param string $gid gid of the group * @param string $gid gid of the group
* @return bool * @return bool
* @since 4.5.0
* *
* Checks whether the user is member of a group or not. * Checks whether the user is member of a group or not.
*/ */
...@@ -59,9 +63,10 @@ class Group_WCF extends \OC_Group_Backend { ...@@ -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 * @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 * This function fetches all groups a user belongs to. It does not check
* if the user exists at all. * if the user exists at all.
...@@ -80,15 +85,16 @@ class Group_WCF extends \OC_Group_Backend { ...@@ -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 string $search
* @param int $limit * @param int $limit
* @param int $offset * @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 * Returns a list with all groups
*/ */
public function getGroups($search = '', $limit=null, $offset=null) { public function getGroups($search = '', $limit = -1, $offset = 0) {
$groups = array(); $groups = array();
$params = array(); $params = array();
$where = NULL; $where = NULL;
...@@ -100,7 +106,7 @@ class Group_WCF extends \OC_Group_Backend { ...@@ -100,7 +106,7 @@ class Group_WCF extends \OC_Group_Backend {
$params[] = '%'.$search.'%'; $params[] = '%'.$search.'%';
} }
if (!($limit === -1 or is_null($limit))) { if (!($limit === -1 or is_null($limit))) {
$append .= ' LIMIT '.intval($liumit); $append .= ' LIMIT '.intval($limit);
} }
if (!($offset === 0 or is_null($offset))) { if (!($offset === 0 or is_null($offset))) {
$append .= ' OFFSET '.intval($offset); $append .= ' OFFSET '.intval($offset);
...@@ -122,11 +128,12 @@ class Group_WCF extends \OC_Group_Backend { ...@@ -122,11 +128,12 @@ class Group_WCF extends \OC_Group_Backend {
} }
return $groups; return $groups;
} }
/** /**
* check if a group exists * check if a group exists
* @param string $gid * @param string $gid
* @return bool * @return bool
* @since 4.5.0
*/ */
public function groupExists($gid) { public function groupExists($gid) {
$exists = FALSE; $exists = FALSE;
...@@ -140,12 +147,13 @@ class Group_WCF extends \OC_Group_Backend { ...@@ -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 $gid
* @param string $search * @param string $search
* @param int $limit * @param int $limit
* @param int $offset * @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) { public function usersInGroup($gid, $search = '', $limit = -1, $offset = 0) {
$users = array(); $users = array();
...@@ -175,3 +183,4 @@ class Group_WCF extends \OC_Group_Backend { ...@@ -175,3 +183,4 @@ class Group_WCF extends \OC_Group_Backend {
return $users; return $users;
} }
} }
Supports Markdown
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