diff --git a/appinfo/routes.php b/appinfo/routes.php
index 2862e75..b1ee012 100644
--- a/appinfo/routes.php
+++ b/appinfo/routes.php
@@ -8,6 +8,7 @@ return [
# AGENCY
['name' => 'agency#show', 'url' => '/getagencydata', 'verb' => 'GET'],
['name' => 'agency#updateagencydata', 'url' => '/updateagencydata', 'verb' => 'PUT'],
+ ['name' => 'agency#getagencycontributors', 'url' => '/getagencycontributors', 'verb' => 'GET'],
# GROUPS
['name' => 'group#getagencygroups', 'url' => '/getagencygroups', 'verb' => 'GET'],
['name' => 'group#addagencygroup', 'url' => '/addagencygroup', 'verb' => 'PUT'],
diff --git a/lib/Agency/AgencyManager.php b/lib/Agency/AgencyManager.php
index 03951b7..02eef74 100644
--- a/lib/Agency/AgencyManager.php
+++ b/lib/Agency/AgencyManager.php
@@ -37,7 +37,7 @@ class AgencyManager {
/**
* getAgencyByUser
*
- * Return the Agency-ID by filtering the id from default agency-group, ex: agency_1 -> 1 (int)
+ * Return the complete Agency-Data by filtering the id from default agency-group, ex: agency_1 -> 1 (int)
*
*/
public function getAgencyByUser(){
@@ -52,6 +52,20 @@ class AgencyManager {
return $this->agencyMapper->getAgencyByGId($agency_group_id);
#return $agency_group_id;
}
+ /**
+ * Return only the AgencyGroupId
+ */
+ public function getAgencyGIdByUser(){
+ $groups = $this->groupManager->getUserGroups($this->userSession->getUser());
+ $agency_group_id = "";
+ foreach($groups as $group){
+ if(str_contains($group->getGId(), 'agencymaingroupid_')){
+ $agency_group_id_array = explode("_", strval($group->getGId()));
+ $agency_group_id = $agency_group_id_array[0]."_".$agency_group_id_array[1];
+ }
+ }
+ return $agency_group_id;
+ }
// Return an random Id-Ele for generating single IDs
public function generateRandomId($length = 6) {
@@ -63,4 +77,22 @@ class AgencyManager {
}
return $randomString;
}
+
+ /**
+ * Returns all users of an Agency by filtering the Main Agency Group Id out
+ *
+ * Returns an Array of IUser-Objects. Filtering is by logged User
+ */
+ public function getagencycontributors(){
+ $group = $this->groupManager->get($this->getAgencyGIdByUser());
+ $users = $group->getUsers();
+
+ $return_users = array();
+ // Creating a nice User-JSON-Array
+ foreach($users as $user){
+ #array_push($return_users, array("displayName" => $user->getDisplayName(), "uid" => $user->getUID(), "lastLogin" => $user->getLastLogin()));
+ array_push($return_users, $user->getDisplayName());
+ }
+ return $return_users;
+ }
}
\ No newline at end of file
diff --git a/lib/Controller/AgencyController.php b/lib/Controller/AgencyController.php
index 15751f3..2f4edc6 100644
--- a/lib/Controller/AgencyController.php
+++ b/lib/Controller/AgencyController.php
@@ -94,4 +94,11 @@ class AgencyController extends Controller {
});
}
+ /**
+ * @NoAdminRequired
+ */
+ public function getagencycontributors(){
+ return $this->agencyManager->getagencycontributors();
+ }
+
}
\ No newline at end of file
diff --git a/lib/Controller/GroupController.php b/lib/Controller/GroupController.php
index ed3d441..eb636bc 100644
--- a/lib/Controller/GroupController.php
+++ b/lib/Controller/GroupController.php
@@ -3,6 +3,8 @@ declare(strict_types=1);
namespace OCA\Agency\Controller;
+use Exception;
+
use OCP\IRequest;
use OCP\IGroupManager;
use OCP\AppFramework\Http\DataResponse;
@@ -106,12 +108,11 @@ class GroupController extends Controller {
$searchGroupId = $this->agencymanager->getAgencyByUser()->getAgencygid();
$result = false;
- # If user is in the same Agency, then delete
+ # If user is in the same Agency, then delete is possible - check permissions!
# TODO: Hier noch einbauen, dass die Rechte geprüft werden!
if(str_contains($todel->getGID(), $searchGroupId)) {
- # TODO: Hier das löschen der GroupPermission mit verwalten, wenn eine Gruppe gelöscht wird!
- // $todel->delete();
- $result = true;
+ $this->grouppermissionservice->remove($todel->getGID());
+ $todel->delete();
}
return $result;
}
diff --git a/lib/Db/GroupPermissionMapper.php b/lib/Db/GroupPermissionMapper.php
index e69a9ca..e004e4c 100644
--- a/lib/Db/GroupPermissionMapper.php
+++ b/lib/Db/GroupPermissionMapper.php
@@ -34,11 +34,10 @@ class GroupPermissionMapper extends QBMapper {
return $this->findEntity($qb);
}
- public function remove(int $id) {
- $db = $this->db->getQueryBuilder();
- $db->delete($this->getTableName())
- ->where($db->expr()->eq('id', $query->createNamedParameter($id)));
-
- return $this->findEntity($qb);
+ public function remove(string $gid) {
+ $qb = $this->db->getQueryBuilder();
+ $qb->delete($this->getTableName())
+ ->where($qb->expr()->eq('gid', $qb->createNamedParameter($gid)));
+ return $qb->execute();
}
}
\ No newline at end of file
diff --git a/lib/Service/GroupPermissionService.php b/lib/Service/GroupPermissionService.php
index 5a44261..7bddff7 100644
--- a/lib/Service/GroupPermissionService.php
+++ b/lib/Service/GroupPermissionService.php
@@ -51,9 +51,9 @@ class GroupPermissionService {
}
}
- public function remove(int $id){
+ public function remove(string $gid){
try {
- return $this->mapper->remove($id);
+ return $this->mapper->remove($gid);
} catch(Exception $e) {
$this->handleException($e);
}
diff --git a/src/components/Group.vue b/src/components/Group.vue
index e8a081d..4d07718 100644
--- a/src/components/Group.vue
+++ b/src/components/Group.vue
@@ -24,19 +24,27 @@
The GroupId is {{ group.gid }}
Ist default
Nicht default
+