10 defined(
'JPATH_PLATFORM') or die;
32 public function login($lgname, $lgpassword, $lgdomain = null)
35 $path =
'?action=login&lgname=' . $lgname .
'&lgpassword=' . $lgpassword;
39 $path .=
'&lgdomain=' . $lgdomain;
43 $response = $this->client->post($this->fetchUrl($path), null);
46 $path =
'?action=login&lgname=' . $lgname .
'&lgpassword=' . $lgpassword .
'&lgtoken=' . $this->validateResponse($response)->login[
'token'];
50 $path .=
'&lgdomain=' . $lgdomain;
54 $headers = (array) $this->options->get(
'headers');
55 $headers[
'Cookie'] = !empty($headers[
'Cookie']) ? empty($headers[
'Cookie']) :
'';
56 $headers[
'Cookie'] = $headers[
'Cookie'] . $response->headers[
'Set-Cookie'];
57 $this->options->set(
'headers', $headers);
60 $response = $this->client->post($this->fetchUrl($path), null);
61 $response_body = $this->validateResponse($response);
63 $headers = (array) $this->options->get(
'headers');
64 $cookie_prefix = $response_body->login[
'cookieprefix'];
65 $cookie = $cookie_prefix .
'UserID=' . $response_body->login[
'lguserid'] .
'; ' . $cookie_prefix
66 .
'UserName=' . $response_body->login[
'lgusername'];
67 $headers[
'Cookie'] = $headers[
'Cookie'] .
'; ' . $response->headers[
'Set-Cookie'] .
'; ' . $cookie;
68 $this->options->set(
'headers', $headers);
70 return $this->validateResponse($response);
80 public function logout()
83 $path =
'?action=login';
88 $response = $this->client->get($this->fetchUrl($path));
90 return $this->validateResponse($response);
103 public function getUserInfo(array $ususers, array $usprop = null)
106 $path =
'?action=query&list=users';
109 $path .=
'&ususers=' . $this->buildParameter($ususers);
113 $path .=
'&usprop' . $this->buildParameter($usprop);
117 $response = $this->client->get($this->fetchUrl($path));
119 return $this->validateResponse($response);
131 public function getCurrentUserInfo(array $uiprop = null)
134 $path =
'?action=query&meta=userinfo';
138 $path .=
'&uiprop' . $this->buildParameter($uiprop);
142 $response = $this->client->get($this->fetchUrl($path));
144 return $this->validateResponse($response);
167 public function getUserContribs($ucuser = null, $ucuserprefix = null, $uclimit = null, $ucstart = null, $ucend = null, $uccontinue = null,
168 $ucdir = null, array $ucnamespace = null, array $ucprop = null, array $ucshow = null, $uctag = null, $uctoponly = null)
171 $path =
'?action=query&list=usercontribs';
175 $path .=
'&ucuser=' . $ucuser;
178 if (isset($ucuserprefix))
180 $path .=
'&ucuserprefix=' . $ucuserprefix;
185 $path .=
'&uclimit=' . $uclimit;
190 $path .=
'&ucstart=' . $ucstart;
195 $path .=
'&ucend=' . $ucend;
200 $path .=
'&uccontinue=';
205 $path .=
'&ucdir=' . $ucdir;
208 if (isset($ucnamespace))
210 $path .=
'&ucnamespace=' . $this->buildParameter($ucnamespace);
215 $path .=
'&ucprop=' . $this->buildParameter($ucprop);
220 $path .=
'&ucshow=' . $this->buildParameter($ucshow);
225 $path .=
'&uctag=' . $uctag;
228 if (isset($uctoponly))
230 $path .=
'&uctoponly=' . $uctoponly;
234 $response = $this->client->get($this->fetchUrl($path));
236 return $this->validateResponse($response);
258 public function blockUser($user, $expiry = null, $reason = null, $anononly = null, $nocreate = null, $autoblock = null, $noemail = null,
259 $hidename = null, $allowusertalk = null, $reblock = null, $watchuser = null)
262 $token = $this->getToken($user,
'block');
265 $path =
'?action=unblock';
273 'anononly' => $anononly,
274 'nocreate' => $nocreate,
275 'autoblock' => $autoblock,
276 'noemail' => $noemail,
277 'hidename' => $hidename,
278 'allowusetalk' => $allowusertalk,
279 'reblock' => $reblock,
280 'watchuser' => $watchuser
284 $response = $this->client->post($this->fetchUrl($path), $data);
286 return $this->validateResponse($response);
299 public function unBlockUserByName($user, $reason = null)
302 $token = $this->getToken($user,
'unblock');
305 $path =
'?action=unblock';
315 $response = $this->client->post($this->fetchUrl($path), $data);
317 return $this->validateResponse($response);
330 public function unBlockUserByID($id, $reason = null)
333 $token = $this->getToken($id,
'unblock');
336 $path =
'?action=unblock';
347 $response = $this->client->get($this->fetchUrl($path));
349 return $this->validateResponse($response);
364 public function assignGroup($username, $add = null, $remove = null, $reason = null)
367 $token = $this->getToken($username,
'unblock');
370 $path =
'?action=userrights';
374 'username' => $username,
382 $response = $this->client->post($this->fetchUrl($path), $data);
384 return $this->validateResponse($response);
399 public function emailUser($target, $subject = null, $text = null, $ccme = null)
402 $token = $this->getToken($target,
'emailuser');
405 $path =
'?action=emailuser';
411 'subject' => $subject,
417 $response = $this->client->post($this->fetchUrl($path), $data);
419 return $this->validateResponse($response);
432 public function getToken($user, $intoken)
435 $path =
'?action=query&prop=info&intoken=' . $intoken .
'&titles=User:' . $user;
438 $response = $this->client->post($this->fetchUrl($path), null);
440 return (
string) $this->validateResponse($response)->query->pages->page[$intoken .
'token'];