Skip to content

Commit

Permalink
Merge pull request #8854 from Minervis-GmbH/bugfixes/soap/43452
Browse files Browse the repository at this point in the history
#0043452: getTreeChilds & getXMLTree: add checks for empty  types and user_ids
  • Loading branch information
jeph864 authored Jan 27, 2025
2 parents b596fa0 + 8dbd1c1 commit 58352a1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion webservice/soap/classes/class.ilObjectXMLWriter.php
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ private function appendOperations(int $a_ref_id, string $a_type): void
$ops_ids = ilRbacReview::lookupCreateOperationIds(array_keys($objects));
$creation_operations = array();
foreach ($objects as $type => $info) {
$ops_id = $ops_ids[$type];
$ops_id = $ops_ids[$type] ?? null;

if (!$ops_id) {
continue;
Expand Down
13 changes: 9 additions & 4 deletions webservice/soap/classes/class.ilSoapObjectAdministration.php
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ public function searchObjects(string $sid, ?array $types, string $key, string $c
/**
* @return soap_fault|SoapFault|string|null
*/
public function getTreeChilds(string $sid, int $ref_id, ?array $types, ?int $user_id = null)
public function getTreeChilds(string $sid, int $ref_id, ?array $types = null, ?int $user_id = null)
{
$this->initAuth($sid);
$this->initIlias();
Expand Down Expand Up @@ -417,7 +417,7 @@ public function getTreeChilds(string $sid, int $ref_id, ?array $types, ?int $use
);
}

if (!is_array($types)) {
if (!is_array($types) || empty($types)) {
$all = true;
}

Expand Down Expand Up @@ -449,7 +449,7 @@ public function getTreeChilds(string $sid, int $ref_id, ?array $types, ?int $use
/**
* @return soap_fault|SoapFault|string|null
*/
public function getXMLTree(string $sid, int $ref_id, ?array $types, ?int $user_id =null)
public function getXMLTree(string $sid, int $ref_id, ?array $types = null, ?int $user_id = null)
{
$this->initAuth($sid);
$this->initIlias();
Expand All @@ -466,6 +466,11 @@ public function getXMLTree(string $sid, int $ref_id, ?array $types, ?int $user_i
$nodedata = $tree->getNodeData($ref_id);
$nodearray = $tree->getSubTree($nodedata);

$all = false;
if (!is_array($types) || empty($types)) {
$all = true;
}

$filter = $types;

global $DIC;
Expand All @@ -476,7 +481,7 @@ public function getXMLTree(string $sid, int $ref_id, ?array $types, ?int $user_i
if (
!$objDefinition->isAdministrationObject($node['type']) &&
!$objDefinition->isSystemObject($node['type']) &&
!in_array($node['type'], $filter, true) &&
($all || !in_array($node['type'], $filter, true)) &&
$access->checkAccess("read", "", (int) $node['ref_id']) &&
($tmp = ilObjectFactory::getInstanceByRefId($node['ref_id'], false))) {
$nodes[] = $tmp;
Expand Down
4 changes: 2 additions & 2 deletions webservice/soap/include/inc.soap_functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ public static function searchObjects(string $sid, array $types, string $key, str
/**
* @return soap_fault|SoapFault|string|null
*/
public static function getTreeChilds(string $sid, int $ref_id, array $types, int $user_id)
public static function getTreeChilds(string $sid, int $ref_id, ?array $types = null, ?int $user_id = null)
{
include_once './webservice/soap/classes/class.ilSoapObjectAdministration.php';
$soa = new ilSoapObjectAdministration();
Expand All @@ -263,7 +263,7 @@ public static function getTreeChilds(string $sid, int $ref_id, array $types, int
/**
* @return soap_fault|SoapFault|string|null
*/
public static function getXMLTree(string $sid, int $ref_id, array $types, ?int $user_id = null)
public static function getXMLTree(string $sid, int $ref_id, ?array $types = null, ?int $user_id = null)
{
include_once './webservice/soap/classes/class.ilSoapObjectAdministration.php';
$soa = new ilSoapObjectAdministration();
Expand Down

0 comments on commit 58352a1

Please sign in to comment.