This repository has been archived by the owner on Aug 21, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
/
group_groupoffice.php
87 lines (63 loc) · 1.89 KB
/
group_groupoffice.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<?php
/**
* Copyright (c) 2014 Intermesh BV
*
* This file is licensed under the Affero General Public License version 3 or
* later
*
* If you have questions write an e-mail to [email protected]
*/
namespace OCA\groupoffice;
class Group extends \OC_Group_Backend {
public function getGroups($search = '', $limit = -1, $offset = 0) {
$returnArray = array();
$fp = \GO\Base\Db\FindParams::newInstance()
->start($offset)
->searchQuery($search);
if($limit>0)
$fp->limit($limit);
$stmt = \GO\Base\Model\Group::model()->find($fp);
foreach($stmt as $group){
$returnArray[]=$group->name;
}
return $returnArray;
}
public function getUserGroups($uid) {
$groups = array();
$user = \GO\Base\Model\User::model()->findSingleByAttribute('username', $uid);
if($user){
$stmt = $user->groups();
foreach($stmt as $group){
$groups[]=$group->name;
}
}
return $groups;
}
public function groupExists($gid) {
$group = \GO\Base\Model\Group::model()->findSingleByAttribute('name', $gid);
return $group!=false;
}
public function inGroup($uid, $gid) {
$user = \GO\Base\Model\User::model()->findSingleByAttribute('username', $uid);
if(!$user)
return false;
$group = \GO\Base\Model\Group::model()->findSingleByAttribute('name', $gid);
if(!$group)
return false;
$ug = \GO\Base\Model\UserGroup::model()->findByPk(array('user_id'=>$user->id, 'group_id'=>$group->id));
return $ug!=false;
}
public function usersInGroup($gid, $search = '', $limit = -1, $offset = 0) {
$users = array();
$group = \GO\Base\Model\Group::model()->findSingleByAttribute('name', $gid);
$findParams = \GO\Base\Db\FindParams::newInstance()
->start($offset)
->limit($limit)
->searchQuery($search);
$stmt = $group->users($findParams);
foreach($stmt as $user){
$users[]=$user->username;
}
return $users;
}
}