| @@ 65-83 (lines=19) @@ | ||
| 62 | * @param string $username |
|
| 63 | * @return string[] |
|
| 64 | */ |
|
| 65 | public function groups($project, $username) |
|
| 66 | { |
|
| 67 | $this->setUp($project); |
|
| 68 | $params = [ "list"=>"users", "ususers"=>$username, "usprop"=>"groups" ]; |
|
| 69 | $query = new SimpleRequest('query', $params); |
|
| 70 | $result = []; |
|
| 71 | ||
| 72 | try { |
|
| 73 | $res = $this->api->getRequest($query); |
|
| 74 | if (isset($res["batchcomplete"]) && isset($res["query"]["users"][0]["groups"])) { |
|
| 75 | $result = $res["query"]["users"][0]["groups"]; |
|
| 76 | } |
|
| 77 | } catch (Exception $e) { |
|
| 78 | // The api returned an error! Ignore |
|
| 79 | } |
|
| 80 | ||
| 81 | return $result; |
|
| 82 | } |
|
| 83 | ||
| 84 | /** |
|
| 85 | * Get the given user's globally-applicable groups. |
|
| 86 | * @deprecated Use User::getGlobalGroups() instead. |
|
| @@ 91-109 (lines=19) @@ | ||
| 88 | * @param string $username |
|
| 89 | * @return string[] |
|
| 90 | */ |
|
| 91 | public function globalGroups($project, $username) |
|
| 92 | { |
|
| 93 | $this->setUp($project); |
|
| 94 | $params = [ "meta"=>"globaluserinfo", "guiuser"=>$username, "guiprop"=>"groups" ]; |
|
| 95 | $query = new SimpleRequest('query', $params); |
|
| 96 | $result = []; |
|
| 97 | ||
| 98 | try { |
|
| 99 | $res = $this->api->getRequest($query); |
|
| 100 | if (isset($res["batchcomplete"]) && isset($res["query"]["globaluserinfo"]["groups"])) { |
|
| 101 | $result = $res["query"]["globaluserinfo"]["groups"]; |
|
| 102 | } |
|
| 103 | } catch (Exception $e) { |
|
| 104 | // The api returned an error! Ignore |
|
| 105 | } |
|
| 106 | ||
| 107 | return $result; |
|
| 108 | } |
|
| 109 | ||
| 110 | /** |
|
| 111 | * Get a list of administrators for the given project. |
|
| 112 | * @TODO Move to the Project class? |
|