| @@ 60-78 (lines=19) @@ | ||
| 57 | * @param string $username |
|
| 58 | * @return string[] |
|
| 59 | */ |
|
| 60 | public function groups($project, $username) |
|
| 61 | { |
|
| 62 | $this->setUp($project); |
|
| 63 | $params = [ "list"=>"users", "ususers"=>$username, "usprop"=>"groups" ]; |
|
| 64 | $query = new SimpleRequest('query', $params); |
|
| 65 | $result = []; |
|
| 66 | ||
| 67 | try { |
|
| 68 | $res = $this->api->getRequest($query); |
|
| 69 | if (isset($res["batchcomplete"]) |
|
| 70 | && isset($res["query"]["users"][0]["groups"]) |
|
| 71 | ) { |
|
| 72 | $result = $res["query"]["users"][0]["groups"]; |
|
| 73 | } |
|
| 74 | } catch (Exception $e) { |
|
| 75 | // The api returned an error! Ignore |
|
| 76 | } |
|
| 77 | ||
| 78 | return $result; |
|
| 79 | } |
|
| 80 | ||
| 81 | /** |
|
| @@ 88-106 (lines=19) @@ | ||
| 85 | * @param string $username |
|
| 86 | * @return string[] |
|
| 87 | */ |
|
| 88 | public function globalGroups($project, $username) |
|
| 89 | { |
|
| 90 | $this->setUp($project); |
|
| 91 | $params = [ "meta"=>"globaluserinfo", "guiuser"=>$username, "guiprop"=>"groups" ]; |
|
| 92 | $query = new SimpleRequest('query', $params); |
|
| 93 | $result = []; |
|
| 94 | ||
| 95 | try { |
|
| 96 | $res = $this->api->getRequest($query); |
|
| 97 | if (isset($res["batchcomplete"]) && isset($res["query"]["globaluserinfo"]["groups"])) { |
|
| 98 | $result = $res["query"]["globaluserinfo"]["groups"]; |
|
| 99 | } |
|
| 100 | } catch (Exception $e) { |
|
| 101 | // The api returned an error! Ignore |
|
| 102 | } |
|
| 103 | ||
| 104 | return $result; |
|
| 105 | } |
|
| 106 | ||
| 107 | /** |
|
| 108 | * Get HTML display titles of a set of pages (or the normal title if there's no display title). |
|
| 109 | * This will send t/50 API requests where t is the number of titles supplied. |
|