@@ -21,16 +21,16 @@ discard block |
||
21 | 21 | * This file contains examples of utilization of this library |
22 | 22 | */ |
23 | 23 | |
24 | -ini_set( 'display_errors', 1); |
|
25 | -ini_set( 'track_errors', 1); |
|
26 | -ini_set( 'html_errors', 1); |
|
27 | -error_reporting( E_ALL ); |
|
24 | +ini_set('display_errors', 1); |
|
25 | +ini_set('track_errors', 1); |
|
26 | +ini_set('html_errors', 1); |
|
27 | +error_reporting(E_ALL); |
|
28 | 28 | |
29 | -require_once( 'functions_utils.php' ); |
|
29 | +require_once('functions_utils.php'); |
|
30 | 30 | |
31 | 31 | $host = 'ipa.demo1.freeipa.org'; |
32 | 32 | // The certificate can be obtained in https://$host/ipa/config/ca.crt |
33 | -$certificate = __DIR__ . "/../certs/ipa.demo1.freeipa.org_ca.crt"; |
|
33 | +$certificate = __DIR__."/../certs/ipa.demo1.freeipa.org_ca.crt"; |
|
34 | 34 | $user = 'admin'; |
35 | 35 | $password = 'Secret123'; |
36 | 36 | $search = 'test'; |
@@ -109,8 +109,8 @@ discard block |
||
109 | 109 | if ($ret_search_users) { |
110 | 110 | $t = count($ret_search_users); |
111 | 111 | print "Found $t usuários. Names: "; |
112 | - for ($i = 0; $i < $t; $i++) { |
|
113 | - print $ret_search_users[$i]->uid[0] . " | "; |
|
112 | + for ($i = 0; $i<$t; $i++) { |
|
113 | + print $ret_search_users[$i]->uid[0]." | "; |
|
114 | 114 | } |
115 | 115 | _print(); |
116 | 116 | } else { |
@@ -240,8 +240,8 @@ discard block |
||
240 | 240 | if ($ret_search_groups) { |
241 | 241 | $t = count($ret_search_groups); |
242 | 242 | print "Found $t groups. Names: "; |
243 | - for ($i = 0; $i < $t; $i++) { |
|
244 | - print $ret_search_groups[$i]->cn[0] . " | "; |
|
243 | + for ($i = 0; $i<$t; $i++) { |
|
244 | + print $ret_search_groups[$i]->cn[0]." | "; |
|
245 | 245 | } |
246 | 246 | _print(); |
247 | 247 | } else { |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | // Modify group |
256 | 256 | _print("Modify group \"group$random\""); |
257 | 257 | try { |
258 | - $mod_group = $ipa->group()->modify("group$random", [ 'description' => "group$random description updated"]); |
|
258 | + $mod_group = $ipa->group()->modify("group$random", ['description' => "group$random description updated"]); |
|
259 | 259 | if ($mod_group) { |
260 | 260 | _print('Group modified'); |
261 | 261 | } else { |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | */ |
55 | 55 | public function add($name = null, $data = array()) |
56 | 56 | { |
57 | - if (!$name || !$data) { |
|
57 | + if ( ! $name || ! $data) { |
|
58 | 58 | return false; |
59 | 59 | } |
60 | 60 | |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | |
78 | 78 | // The buildRequest() method already checks the field 'error', which is the only relevant to this API method |
79 | 79 | $response = $this->getConnection()->buildRequest('group_add', $args, $final_options); //returns json and http code of response |
80 | - if (!$response) { |
|
80 | + if ( ! $response) { |
|
81 | 81 | return false; |
82 | 82 | } |
83 | 83 | |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | */ |
95 | 95 | public function del($name = null, $data = array()) |
96 | 96 | { |
97 | - if (!$name || !$data) { |
|
97 | + if ( ! $name || ! $data) { |
|
98 | 98 | return false; |
99 | 99 | } |
100 | 100 | |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | |
112 | 112 | // The buildRequest() method already checks the field 'error', which is the only relevant to this API method |
113 | 113 | $response = $this->getConnection()->buildRequest('group_del', $args, $final_options); //returns json and http code of response |
114 | - if (!$response) { |
|
114 | + if ( ! $response) { |
|
115 | 115 | return false; |
116 | 116 | } |
117 | 117 | |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | */ |
137 | 137 | public function addMember($group_name = null, $data = array()) |
138 | 138 | { |
139 | - if (!$group_name || !$data) { |
|
139 | + if ( ! $group_name || ! $data) { |
|
140 | 140 | return false; |
141 | 141 | } |
142 | 142 | |
@@ -156,22 +156,22 @@ discard block |
||
156 | 156 | } |
157 | 157 | |
158 | 158 | $response = $this->getConnection()->buildRequest('group_add_member', $args, $final_options); //returns json and http code of response |
159 | - if (!$response) { |
|
159 | + if ( ! $response) { |
|
160 | 160 | return false; |
161 | 161 | } |
162 | 162 | $returned_json = $response[0]; |
163 | - if (!$returned_json->result->completed) { |
|
163 | + if ( ! $returned_json->result->completed) { |
|
164 | 164 | $message = "Error while inserting members in group \"$group_name\"."; |
165 | - if (!empty($returned_json->result->failed->member->group) || |
|
166 | - !empty($returned_json->result->failed->member->user)) { |
|
165 | + if ( ! empty($returned_json->result->failed->member->group) || |
|
166 | + ! empty($returned_json->result->failed->member->user)) { |
|
167 | 167 | $message .= 'Details: '; |
168 | 168 | } |
169 | 169 | |
170 | - if (!empty($returned_json->result->failed->member->group)) { |
|
170 | + if ( ! empty($returned_json->result->failed->member->group)) { |
|
171 | 171 | $message .= implode(' ', $returned_json->result->failed->member->group[0]); |
172 | 172 | } |
173 | 173 | |
174 | - if (!empty($returned_json->result->failed->member->user)) { |
|
174 | + if ( ! empty($returned_json->result->failed->member->user)) { |
|
175 | 175 | $message .= implode(' ', $returned_json->result->failed->member->user[0]); |
176 | 176 | } |
177 | 177 | |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | */ |
199 | 199 | public function removeMember($group_name = null, $data = array()) |
200 | 200 | { |
201 | - if (!$group_name || !$data) { |
|
201 | + if ( ! $group_name || ! $data) { |
|
202 | 202 | return false; |
203 | 203 | } |
204 | 204 | |
@@ -218,22 +218,22 @@ discard block |
||
218 | 218 | } |
219 | 219 | |
220 | 220 | $response = $this->getConnection()->buildRequest('group_remove_member', $args, $final_options); //returns json and http code of response |
221 | - if (!$response) { |
|
221 | + if ( ! $response) { |
|
222 | 222 | return false; |
223 | 223 | } |
224 | 224 | $returned_json = $response[0]; |
225 | - if (!$returned_json->result->completed) { |
|
225 | + if ( ! $returned_json->result->completed) { |
|
226 | 226 | $message = "Error while removing members in group \"$group_name\"."; |
227 | - if (!empty($returned_json->result->failed->member->group) || |
|
228 | - !empty($returned_json->result->failed->member->user)) { |
|
227 | + if ( ! empty($returned_json->result->failed->member->group) || |
|
228 | + ! empty($returned_json->result->failed->member->user)) { |
|
229 | 229 | $message .= 'Details: '; |
230 | 230 | } |
231 | 231 | |
232 | - if (!empty($returned_json->result->failed->member->group)) { |
|
232 | + if ( ! empty($returned_json->result->failed->member->group)) { |
|
233 | 233 | $message .= implode(' ', $returned_json->result->failed->member->group[0]); |
234 | 234 | } |
235 | 235 | |
236 | - if (!empty($returned_json->result->failed->member->user)) { |
|
236 | + if ( ! empty($returned_json->result->failed->member->user)) { |
|
237 | 237 | $message .= implode(' ', $returned_json->result->failed->member->user[0]); |
238 | 238 | } |
239 | 239 | |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | */ |
257 | 257 | public function find($args = array(), $options = array()) |
258 | 258 | { |
259 | - if (!is_array($args) || !is_array($options)) { |
|
259 | + if ( ! is_array($args) || ! is_array($options)) { |
|
260 | 260 | return false; |
261 | 261 | } |
262 | 262 | |
@@ -275,11 +275,11 @@ discard block |
||
275 | 275 | $return_request = $this->getConnection()->buildRequest('group_find', $args, $final_options); //returns json and http code of response |
276 | 276 | $json = $return_request[0]; |
277 | 277 | |
278 | - if (empty($json->result) || !isset($json->result->count)) { |
|
278 | + if (empty($json->result) || ! isset($json->result->count)) { |
|
279 | 279 | throw new \Exception('Malformed json'); |
280 | 280 | } |
281 | 281 | |
282 | - if ($json->result->count < 1) { |
|
282 | + if ($json->result->count<1) { |
|
283 | 283 | return false; |
284 | 284 | } |
285 | 285 | |
@@ -296,7 +296,7 @@ discard block |
||
296 | 296 | */ |
297 | 297 | public function findBy($field = null, $value = null) |
298 | 298 | { |
299 | - if (!$field || !$value) { |
|
299 | + if ( ! $field || ! $value) { |
|
300 | 300 | return false; |
301 | 301 | } |
302 | 302 | |
@@ -315,7 +315,7 @@ discard block |
||
315 | 315 | */ |
316 | 316 | public function get($params = null, $options = array()) |
317 | 317 | { |
318 | - if (!is_array($options)) { |
|
318 | + if ( ! is_array($options)) { |
|
319 | 319 | return false; |
320 | 320 | } |
321 | 321 | |
@@ -340,7 +340,7 @@ discard block |
||
340 | 340 | $return_request = $this->getConnection()->buildRequest('group_show', $final_params, $final_options, false); |
341 | 341 | $json = $return_request[0]; |
342 | 342 | |
343 | - if (!empty($json->error) && strtolower($json->error->name) == 'notfound') { |
|
343 | + if ( ! empty($json->error) && strtolower($json->error->name) == 'notfound') { |
|
344 | 344 | // group not found |
345 | 345 | return false; |
346 | 346 | } |
@@ -350,7 +350,7 @@ discard block |
||
350 | 350 | } |
351 | 351 | |
352 | 352 | // #TODO erase this code? |
353 | - if (!isset($json->result->result)) { |
|
353 | + if ( ! isset($json->result->result)) { |
|
354 | 354 | return false; |
355 | 355 | } |
356 | 356 | |
@@ -369,7 +369,7 @@ discard block |
||
369 | 369 | */ |
370 | 370 | public function modify($cn = null, $data = array()) |
371 | 371 | { |
372 | - if (!$cn || !$data) { |
|
372 | + if ( ! $cn || ! $data) { |
|
373 | 373 | return false; |
374 | 374 | } |
375 | 375 | |
@@ -387,7 +387,7 @@ discard block |
||
387 | 387 | |
388 | 388 | // The buildRequest() method already checks the field 'error', which is the only relevant to this API method |
389 | 389 | $return_request = $this->getConnection()->buildRequest('group_mod', $args, $final_options); //returns json and http code of response |
390 | - if (!$return_request) { |
|
390 | + if ( ! $return_request) { |
|
391 | 391 | return false; |
392 | 392 | } |
393 | 393 |