3
3
namespace Jira \Api \Account ;
4
4
5
5
use \Jira \Api \Account \Group ;
6
+ use \Jira \Api \Account \GroupList ;
6
7
7
8
class AccountService extends \Jira \Api \Client
8
9
{
@@ -85,6 +86,38 @@ public function getGroup($name)
85
86
return $ group ;
86
87
}
87
88
89
+ public function findGroups ($ query = '' )
90
+ {
91
+ if (self ::$ isJIRAUtf8 )
92
+ $ ret = $ this ->exec ($ this ->uri .'s/picker?maxResults=1& ' .($ query ?('query= ' . str_replace (' ' , '+ ' , urlencode ($ query )).'&useUnicode=true&characterEncoding=unicode ' ):'' ));
93
+ else
94
+ $ ret = $ this ->exec ($ this ->uri .'s/picker?maxResults=1& ' .($ query ?('query= ' . str_replace (' ' , '+ ' , urlencode ($ query ))):'' ));// .'&useUnicode=false&characterEncoding=unicode');
95
+ // $ret = $this->exec($this->uri.'?groupname=' . ($this->filterName($name,'+')) .'&useUnicode=true&characterEncoding=UTF8');
96
+ // $ret = $this->exec($this->uri, $json, 'POST');
97
+ // $ret = $this->exec($this->uri.'/member?groupname=' . $name);
98
+ //var_dump($ret);
99
+
100
+ $ groups = $ this ->json_mapper ->map (
101
+ json_decode ($ ret ), new GroupList ()
102
+ );
103
+
104
+ if (self ::$ isJIRAUtf8 )
105
+ $ ret = $ this ->exec ($ this ->uri .'s/picker?maxResults= ' .$ groups ->total .'& ' .($ query ?('query= ' . str_replace (' ' , '+ ' , urlencode ($ query )).'&useUnicode=true&characterEncoding=unicode ' ):'' ));
106
+ else
107
+ $ ret = $ this ->exec ($ this ->uri .'s/picker?maxResults= ' .$ groups ->total .'& ' .($ query ?('query= ' . str_replace (' ' , '+ ' , urlencode ($ query ))):'' ));// .'&useUnicode=false&characterEncoding=unicode');
108
+ // $ret = $this->exec($this->uri.'?groupname=' . ($this->filterName($name,'+')) .'&useUnicode=true&characterEncoding=UTF8');
109
+ // $ret = $this->exec($this->uri, $json, 'POST');
110
+ // $ret = $this->exec($this->uri.'/member?groupname=' . $name);
111
+ //var_dump($ret);
112
+
113
+ $ groups = $ this ->json_mapper ->map (
114
+ json_decode ($ ret ), new GroupList ()
115
+ );
116
+
117
+
118
+ return $ groups ;
119
+ }
120
+
88
121
/**
89
122
* @return \Jira\Api\Account\Group[]
90
123
*/
@@ -135,7 +168,7 @@ public function createGroup($name)
135
168
$ json = json_encode ([
136
169
'name ' => $ this ->filterName ($ name ),
137
170
]);
138
- var_dump ($ json );
171
+ // var_dump($json);
139
172
try {
140
173
$ ret = $ this ->exec ($ this ->uri , $ json , 'POST ' );
141
174
} catch (\Exception $ e ) {
@@ -151,4 +184,22 @@ public function createGroup($name)
151
184
152
185
return $ group ;
153
186
}
187
+
188
+ public function removeGroup ($ name )
189
+ {
190
+ $ json = json_encode ([
191
+ 'groupname ' => $ this ->filterName ($ name ),
192
+ 'name ' => $ this ->filterName ($ name ),
193
+ 'group ' => $ this ->filterName ($ name ),
194
+ ]);
195
+ $ ret = false ;
196
+ try {
197
+ $ ret = $ this ->exec ($ this ->uri . '?groupname= ' .str_replace (' ' , '+ ' , urlencode ($ name )).'&useUnicode=true&characterEncoding=unicode ' , null , 'DELETE ' );
198
+ } catch (\Exception $ e ) {
199
+ return false ;
200
+ // var_dump($e->getMessage());
201
+ }
202
+
203
+ return $ ret ;
204
+ }
154
205
}
0 commit comments