static function ApplyMask(MASK $mask = NULL, $list) { if (!$mask || !is_array($mask->ids)) { return $list; } $list_pos = 0; $res = array(); $ids = $mask->ids; sort($ids); if ($ids) { $curid = array_shift($ids); } else { return $res; } foreach ($list as $key => &$gr) { if (is_array($gr['items'])) { $items = $gr['items']; $size = sizeof($items); } else { $req = new GROUPRequest($gr['props']); $rdr = $req->CreateReader(); $size = $rdr->GetGroupSize(); unset($rdr); unset($req); $items = range(0, $size - 1); } $ires = array(); $ireal = array(); while ($list_pos + $size > $curid) { array_push($ires, $items[$curid - $list_pos]); array_push($ireal, $curid - $list_pos); if ($ids) { $curid = array_shift($ids); } else { $curid = -1; break; } } if ($ires) { $props = $gr['props']; $props['db_mask'] = implode(",", $ires); $props['real_mask'] = implode(",", $ireal); $res[$key] = array('props' => $props, 'items' => $ires); } $list_pos += $size; if ($curid < 0) { break; } } return $res; }
<?php require "../../adei.php"; header("Content-type: text/xml"); header("Cache-Control: no-cache, must-revalidate"); header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); $_GET['db_server'] = "test_zeus"; $_GET['db_name'] = "zeus"; $_GET['db_group'] = "0"; try { $req = new GROUPRequest($_GET); $reader = $req->CreateReader(); $list = $reader->GetItemList(NULL, NULL, REQUEST::CONTROL); unset($reader); } catch (ADEIException $ex) { $error = xml_escape($ex->getMessage()); } echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; if ($error) { echo "<result><Error>{$error}</Error></result>"; } else { echo "<result>"; foreach ($list as $value => $info) { $extra = ""; if ($info['uid']) { $extra .= " uid=\"{$info['uid']}\""; } $name = xml_escape($info['name']); echo "<Value name=\"" . $name . "\"{$extra} value=\"" . $value . "\"/>"; } echo "</result>";