|
@@ 273-319 (lines=47) @@
|
| 270 |
|
* @param array $permissions permissions |
| 271 |
|
* @return boolean success |
| 272 |
|
*/ |
| 273 |
|
function channelAddPerm($cid, $permissions) { |
| 274 |
|
if(!$this->runtime['selected']) { return $this->checkSelected(); } |
| 275 |
|
|
| 276 |
|
if(count($permissions) > 0) { |
| 277 |
|
//Permissions given |
| 278 |
|
|
| 279 |
|
//Errorcollector |
| 280 |
|
$errors = array(); |
| 281 |
|
|
| 282 |
|
//Split Permissions to prevent query from overload |
| 283 |
|
$permissions = array_chunk($permissions, 50, true); |
| 284 |
|
|
| 285 |
|
//Action for each splitted part of permission |
| 286 |
|
foreach($permissions as $permission_part) |
| 287 |
|
{ |
| 288 |
|
//Create command_string for each command that we could use implode later |
| 289 |
|
$command_string = array(); |
| 290 |
|
|
| 291 |
|
foreach($permission_part as $key => $value) |
| 292 |
|
{ |
| 293 |
|
$command_string[] = (is_numeric($key) ? "permid=" : "permsid=").$this->escapeText($key).' permvalue='.$value; |
| 294 |
|
} |
| 295 |
|
|
| 296 |
|
$result = $this->getData('boolean', 'channeladdperm cid='.$cid.' '.implode('|', $command_string)); |
| 297 |
|
|
| 298 |
|
if(!$result['success']) |
| 299 |
|
{ |
| 300 |
|
foreach($result['errors'] as $error) |
| 301 |
|
{ |
| 302 |
|
$errors[] = $error; |
| 303 |
|
} |
| 304 |
|
} |
| 305 |
|
} |
| 306 |
|
|
| 307 |
|
if(count($errors) == 0) |
| 308 |
|
{ |
| 309 |
|
return $this->generateOutput(true, array(), true); |
| 310 |
|
}else{ |
| 311 |
|
return $this->generateOutput(false, $errors, false); |
| 312 |
|
} |
| 313 |
|
|
| 314 |
|
}else{ |
| 315 |
|
// No permissions given |
| 316 |
|
$this->addDebugLog('no permissions given'); |
| 317 |
|
return $this->generateOutput(false, array('Error: no permissions given'), false); |
| 318 |
|
} |
| 319 |
|
} |
| 320 |
|
|
| 321 |
|
/** |
| 322 |
|
* channelClientAddPerm |
|
@@ 340-386 (lines=47) @@
|
| 337 |
|
* @param array $permissions permissions |
| 338 |
|
* @return boolean success |
| 339 |
|
*/ |
| 340 |
|
function channelClientAddPerm($cid, $cldbid, $permissions) { |
| 341 |
|
if(!$this->runtime['selected']) { return $this->checkSelected(); } |
| 342 |
|
|
| 343 |
|
if(count($permissions) > 0) { |
| 344 |
|
//Permissions given |
| 345 |
|
|
| 346 |
|
//Errorcollector |
| 347 |
|
$errors = array(); |
| 348 |
|
|
| 349 |
|
//Split Permissions to prevent query from overload |
| 350 |
|
$permissions = array_chunk($permissions, 50, true); |
| 351 |
|
|
| 352 |
|
//Action for each splitted part of permission |
| 353 |
|
foreach($permissions as $permission_part) |
| 354 |
|
{ |
| 355 |
|
//Create command_string for each command that we could use implode later |
| 356 |
|
$command_string = array(); |
| 357 |
|
|
| 358 |
|
foreach($permission_part as $key => $value) |
| 359 |
|
{ |
| 360 |
|
$command_string[] = (is_numeric($key) ? "permid=" : "permsid=").$this->escapeText($key).' permvalue='.$value; |
| 361 |
|
} |
| 362 |
|
|
| 363 |
|
$result = $this->getData('boolean', 'channelclientaddperm cid='.$cid.' cldbid='.$cldbid.' '.implode('|', $command_string)); |
| 364 |
|
|
| 365 |
|
if(!$result['success']) |
| 366 |
|
{ |
| 367 |
|
foreach($result['errors'] as $error) |
| 368 |
|
{ |
| 369 |
|
$errors[] = $error; |
| 370 |
|
} |
| 371 |
|
} |
| 372 |
|
} |
| 373 |
|
|
| 374 |
|
if(count($errors) == 0) |
| 375 |
|
{ |
| 376 |
|
return $this->generateOutput(true, array(), true); |
| 377 |
|
}else{ |
| 378 |
|
return $this->generateOutput(false, $errors, false); |
| 379 |
|
} |
| 380 |
|
|
| 381 |
|
}else{ |
| 382 |
|
// No permissions given |
| 383 |
|
$this->addDebugLog('no permissions given'); |
| 384 |
|
return $this->generateOutput(false, array('Error: no permissions given'), false); |
| 385 |
|
} |
| 386 |
|
} |
| 387 |
|
|
| 388 |
|
/** |
| 389 |
|
* channelClientDelPerm |
|
@@ 643-688 (lines=46) @@
|
| 640 |
|
* @param array $permissions permissions |
| 641 |
|
* @return boolean success |
| 642 |
|
*/ |
| 643 |
|
function channelGroupAddPerm($cgid, $permissions) { |
| 644 |
|
if(!$this->runtime['selected']) { return $this->checkSelected(); } |
| 645 |
|
|
| 646 |
|
if(count($permissions) > 0) { |
| 647 |
|
//Permissions given |
| 648 |
|
|
| 649 |
|
//Errorcollector |
| 650 |
|
$errors = array(); |
| 651 |
|
|
| 652 |
|
//Split Permissions to prevent query from overload |
| 653 |
|
$permissions = array_chunk($permissions, 50, true); |
| 654 |
|
|
| 655 |
|
//Action for each splitted part of permission |
| 656 |
|
foreach($permissions as $permission_part) |
| 657 |
|
{ |
| 658 |
|
//Create command_string for each command that we could use implode later |
| 659 |
|
$command_string = array(); |
| 660 |
|
|
| 661 |
|
foreach($permission_part as $key => $value) |
| 662 |
|
{ |
| 663 |
|
$command_string[] = (is_numeric($key) ? "permid=" : "permsid=").$this->escapeText($key).' permvalue='.$value; |
| 664 |
|
} |
| 665 |
|
|
| 666 |
|
$result = $this->getData('boolean', 'channelgroupaddperm cgid='.$cgid.' '.implode('|', $command_string)); |
| 667 |
|
|
| 668 |
|
if(!$result['success']) |
| 669 |
|
{ |
| 670 |
|
foreach($result['errors'] as $error) |
| 671 |
|
{ |
| 672 |
|
$errors[] = $error; |
| 673 |
|
} |
| 674 |
|
} |
| 675 |
|
} |
| 676 |
|
|
| 677 |
|
if(count($errors) == 0) { |
| 678 |
|
return $this->generateOutput(true, array(), true); |
| 679 |
|
}else{ |
| 680 |
|
return $this->generateOutput(false, $errors, false); |
| 681 |
|
} |
| 682 |
|
|
| 683 |
|
}else{ |
| 684 |
|
// No permissions given |
| 685 |
|
$this->addDebugLog('no permissions given'); |
| 686 |
|
return $this->generateOutput(false, array('Error: no permissions given'), false); |
| 687 |
|
} |
| 688 |
|
} |
| 689 |
|
|
| 690 |
|
/** |
| 691 |
|
* channelGroupClientList |