@@ -34,18 +34,18 @@ discard block |
||
| 34 | 34 | |
| 35 | 35 | protected function doRequest($type, $endpoint, $params=array()) |
| 36 | 36 | { |
| 37 | - $base = ($this->useSSL) ? "https" : "http"; |
|
| 38 | - $url = $base . "://" . $this->host . ":" .$this->port.$this->plugin.$endpoint; |
|
| 37 | + $base = ($this->useSSL) ? "https" : "http"; |
|
| 38 | + $url = $base . "://" . $this->host . ":" .$this->port.$this->plugin.$endpoint; |
|
| 39 | 39 | |
| 40 | - if ($this->useBasicAuth) |
|
| 40 | + if ($this->useBasicAuth) |
|
| 41 | 41 | $auth = 'Basic ' . base64_encode($this->basicUser . ':' . $this->basicPwd); |
| 42 | 42 | else |
| 43 | 43 | $auth = $this->secret; |
| 44 | 44 | |
| 45 | - $headers = array( |
|
| 46 | - 'Accept' => 'application/json', |
|
| 47 | - 'Authorization' => $auth |
|
| 48 | - ); |
|
| 45 | + $headers = array( |
|
| 46 | + 'Accept' => 'application/json', |
|
| 47 | + 'Authorization' => $auth |
|
| 48 | + ); |
|
| 49 | 49 | |
| 50 | 50 | $body = json_encode($params); |
| 51 | 51 | |
@@ -85,8 +85,8 @@ discard block |
||
| 85 | 85 | */ |
| 86 | 86 | public function getUsers() |
| 87 | 87 | { |
| 88 | - $endpoint = '/users'; |
|
| 89 | - return $this->doRequest('get',$endpoint); |
|
| 88 | + $endpoint = '/users'; |
|
| 89 | + return $this->doRequest('get',$endpoint); |
|
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | |
@@ -147,12 +147,12 @@ discard block |
||
| 147 | 147 | return $this->doRequest('put', $endpoint, compact('username', 'password','name','email', 'groups')); |
| 148 | 148 | } |
| 149 | 149 | |
| 150 | - /** |
|
| 151 | - * locks/Disables an OpenFire user |
|
| 152 | - * |
|
| 153 | - * @param string $username Username |
|
| 154 | - * @return json|false Json with data or error, or False when something went fully wrong |
|
| 155 | - */ |
|
| 150 | + /** |
|
| 151 | + * locks/Disables an OpenFire user |
|
| 152 | + * |
|
| 153 | + * @param string $username Username |
|
| 154 | + * @return json|false Json with data or error, or False when something went fully wrong |
|
| 155 | + */ |
|
| 156 | 156 | public function lockoutUser($username) |
| 157 | 157 | { |
| 158 | 158 | $endpoint = '/lockouts/'.$username; |
@@ -32,13 +32,13 @@ discard block |
||
| 32 | 32 | * @return array|false Array with data or error, or False when something went fully wrong |
| 33 | 33 | */ |
| 34 | 34 | |
| 35 | - protected function doRequest($type, $endpoint, $params=array()) |
|
| 35 | + protected function doRequest($type, $endpoint, $params = array()) |
|
| 36 | 36 | { |
| 37 | 37 | $base = ($this->useSSL) ? "https" : "http"; |
| 38 | - $url = $base . "://" . $this->host . ":" .$this->port.$this->plugin.$endpoint; |
|
| 38 | + $url = $base."://".$this->host.":".$this->port.$this->plugin.$endpoint; |
|
| 39 | 39 | |
| 40 | 40 | if ($this->useBasicAuth) |
| 41 | - $auth = 'Basic ' . base64_encode($this->basicUser . ':' . $this->basicPwd); |
|
| 41 | + $auth = 'Basic '.base64_encode($this->basicUser.':'.$this->basicPwd); |
|
| 42 | 42 | else |
| 43 | 43 | $auth = $this->secret; |
| 44 | 44 | |
@@ -54,16 +54,16 @@ discard block |
||
| 54 | 54 | $result = $this->client->get($url, compact('headers')); |
| 55 | 55 | break; |
| 56 | 56 | case 'post': |
| 57 | - $headers += ['Content-Type'=>'application/json']; |
|
| 58 | - $result = $this->client->post($url, compact('headers','body')); |
|
| 57 | + $headers += [ 'Content-Type'=>'application/json' ]; |
|
| 58 | + $result = $this->client->post($url, compact('headers', 'body')); |
|
| 59 | 59 | break; |
| 60 | 60 | case 'delete': |
| 61 | - $headers += ['Content-Type'=>'application/json']; |
|
| 62 | - $result = $this->client->delete($url, compact('headers','body')); |
|
| 61 | + $headers += [ 'Content-Type'=>'application/json' ]; |
|
| 62 | + $result = $this->client->delete($url, compact('headers', 'body')); |
|
| 63 | 63 | break; |
| 64 | 64 | case 'put': |
| 65 | - $headers += ['Content-Type'=>'application/json']; |
|
| 66 | - $result = $this->client->put($url, compact('headers','body')); |
|
| 65 | + $headers += [ 'Content-Type'=>'application/json' ]; |
|
| 66 | + $result = $this->client->put($url, compact('headers', 'body')); |
|
| 67 | 67 | break; |
| 68 | 68 | default: |
| 69 | 69 | $result = null; |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | public function getUsers() |
| 87 | 87 | { |
| 88 | 88 | $endpoint = '/users'; |
| 89 | - return $this->doRequest('get',$endpoint); |
|
| 89 | + return $this->doRequest('get', $endpoint); |
|
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | |
@@ -112,10 +112,10 @@ discard block |
||
| 112 | 112 | * @param string[]|false $groups Groups (Optional) |
| 113 | 113 | * @return json|false Json with data or error, or False when something went fully wrong |
| 114 | 114 | */ |
| 115 | - public function addUser($username, $password, $name=false, $email=false, $groups=false) |
|
| 115 | + public function addUser($username, $password, $name = false, $email = false, $groups = false) |
|
| 116 | 116 | { |
| 117 | 117 | $endpoint = '/users'; |
| 118 | - return $this->doRequest('post', $endpoint, compact('username', 'password','name','email', 'groups')); |
|
| 118 | + return $this->doRequest('post', $endpoint, compact('username', 'password', 'name', 'email', 'groups')); |
|
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | |
@@ -141,10 +141,10 @@ discard block |
||
| 141 | 141 | * @param string[]|false $groups Groups (Optional) |
| 142 | 142 | * @return json|false Json with data or error, or False when something went fully wrong |
| 143 | 143 | */ |
| 144 | - public function updateUser($username, $password, $name=false, $email=false, $groups=false) |
|
| 144 | + public function updateUser($username, $password, $name = false, $email = false, $groups = false) |
|
| 145 | 145 | { |
| 146 | 146 | $endpoint = '/users/'.$username; |
| 147 | - return $this->doRequest('put', $endpoint, compact('username', 'password','name','email', 'groups')); |
|
| 147 | + return $this->doRequest('put', $endpoint, compact('username', 'password', 'name', 'email', 'groups')); |
|
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | /** |
@@ -182,10 +182,10 @@ discard block |
||
| 182 | 182 | * @param int|false $subscriptionType Subscription (Optional) |
| 183 | 183 | * @return json|false Json with data or error, or False when something went fully wrong |
| 184 | 184 | */ |
| 185 | - public function addToRoster($username, $jid, $name=false, $subscriptionType=false) |
|
| 185 | + public function addToRoster($username, $jid, $name = false, $subscriptionType = false) |
|
| 186 | 186 | { |
| 187 | 187 | $endpoint = '/users/'.$username.'/roster'; |
| 188 | - return $this->doRequest('post', $endpoint, compact('jid','name','subscriptionType')); |
|
| 188 | + return $this->doRequest('post', $endpoint, compact('jid', 'name', 'subscriptionType')); |
|
| 189 | 189 | } |
| 190 | 190 | |
| 191 | 191 | |
@@ -211,10 +211,10 @@ discard block |
||
| 211 | 211 | * @param int|false $subscriptionType Subscription (Optional) |
| 212 | 212 | * @return json|false Json with data or error, or False when something went fully wrong |
| 213 | 213 | */ |
| 214 | - public function updateRoster($username, $jid, $nickname=false, $subscriptionType=false) |
|
| 214 | + public function updateRoster($username, $jid, $nickname = false, $subscriptionType = false) |
|
| 215 | 215 | { |
| 216 | 216 | $endpoint = '/users/'.$username.'/roster/'.$jid; |
| 217 | - return $this->doRequest('put', $endpoint, $jid, compact('jid','username','subscriptionType')); |
|
| 217 | + return $this->doRequest('put', $endpoint, $jid, compact('jid', 'username', 'subscriptionType')); |
|
| 218 | 218 | } |
| 219 | 219 | |
| 220 | 220 | /** |
@@ -251,7 +251,7 @@ discard block |
||
| 251 | 251 | public function createGroup($name, $description = false) |
| 252 | 252 | { |
| 253 | 253 | $endpoint = '/groups/'; |
| 254 | - return $this->doRequest('post', $endpoint, compact('name','description')); |
|
| 254 | + return $this->doRequest('post', $endpoint, compact('name', 'description')); |
|
| 255 | 255 | } |
| 256 | 256 | |
| 257 | 257 | /** |
@@ -273,10 +273,10 @@ discard block |
||
| 273 | 273 | * @param string $description Some description of the group |
| 274 | 274 | * |
| 275 | 275 | */ |
| 276 | - public function updateGroup($name, $description) |
|
| 276 | + public function updateGroup($name, $description) |
|
| 277 | 277 | { |
| 278 | 278 | $endpoint = '/groups/'.$name; |
| 279 | - return $this->doRequest('put', $endpoint, compact('name','description')); |
|
| 279 | + return $this->doRequest('put', $endpoint, compact('name', 'description')); |
|
| 280 | 280 | } |
| 281 | 281 | |
| 282 | 282 | /** |
@@ -37,10 +37,11 @@ |
||
| 37 | 37 | $base = ($this->useSSL) ? "https" : "http"; |
| 38 | 38 | $url = $base . "://" . $this->host . ":" .$this->port.$this->plugin.$endpoint; |
| 39 | 39 | |
| 40 | - if ($this->useBasicAuth) |
|
| 41 | - $auth = 'Basic ' . base64_encode($this->basicUser . ':' . $this->basicPwd); |
|
| 42 | - else |
|
| 43 | - $auth = $this->secret; |
|
| 40 | + if ($this->useBasicAuth) { |
|
| 41 | + $auth = 'Basic ' . base64_encode($this->basicUser . ':' . $this->basicPwd); |
|
| 42 | + } else { |
|
| 43 | + $auth = $this->secret; |
|
| 44 | + } |
|
| 44 | 45 | |
| 45 | 46 | $headers = array( |
| 46 | 47 | 'Accept' => 'application/json', |