// Build a tree from the tag list and return it.
function getTagTree ()
{
- $tagtree = array();
- $taglist = getTagList();
- while (count ($taglist) > 0)
+ global $taglist;
+ $mytaglist = $taglist;
+ $ret = array();
+ while (count ($mytaglist) > 0)
{
$picked = FALSE;
- foreach ($taglist as $tagid => $taginfo)
+ foreach ($mytaglist as $tagid => $taginfo)
{
$taginfo['kids'] = array();
if ($taginfo['parent_id'] == NULL)
{
- $tagtree[$tagid] = $taginfo;
+ $ret[$tagid] = $taginfo;
$picked = TRUE;
- unset ($taglist[$tagid]);
+ unset ($mytaglist[$tagid]);
}
- elseif (attachChildTag ($tagtree, $taginfo['parent_id'], $tagid, $taginfo))
+ elseif (attachChildTag ($ret, $taginfo['parent_id'], $tagid, $taginfo))
{
$picked = TRUE;
- unset ($taglist[$tagid]);
+ unset ($mytaglist[$tagid]);
}
}
if (!$picked) // Only orphaned items on the list.
break;
}
- return $tagtree;
+ return $ret;
}
function serializeTags ($trail)
// except user's tags on the trail.
function getTrailExpansion ($trail)
{
- $tree = getTagTree();
- return traceTrail ($tree, $trail);
+ global $tagtree;
+ return traceTrail ($tagtree, $trail);
}
// Return the list of missing implicit tags.
// Minimize the trail: exclude all implicit tags and return the resulting trail.
function getExplicitTagsOnly ($trail, $tree = NULL)
{
+ global $tagtree;
if ($tree === NULL)
- $tree = getTagTree();
+ $tree = $tagtree;
$ret = array();
foreach ($tree as $taginfo)
{
// a list of tag structures.
function complementByKids ($idlist, $tree = NULL, $getall = FALSE)
{
+ global $tagtree;
if ($tree === NULL)
- $tree = getTagTree();
+ $tree = $tagtree;
$getallkids = $getall;
$ret = array();
foreach ($tree as $taginfo)
// Build a tag trail from supplied tag id list and return it.
function buildTrailFromIds ($tagidlist)
{
- $taglist = getTagList();
+ global $taglist;
$ret = array();
foreach ($tagidlist as $tag_id)
if (isset ($taglist[$tag_id]))
function renderObjectGroupSummary ()
{
global $root;
+ $tagfilter = isset ($_REQUEST['tagfilter']) ? $_REQUEST['tagfilter'] : array();
+ $tagfilter = complementByKids ($tagfilter);
$summary = getObjectGroupInfo();
if ($summary === NULL)
{
startPortlet ('Summary');
foreach ($summary as $gi)
- {
echo "<a href='${root}?page=objgroup&group_id=${gi['id']}'><b>${gi['name']}</b></a> <i>(${gi['count']})</i><br>";
- }
finishPortlet();
echo '</td><td class=pcright>';
renderUnmountedObjectsPortlet();
echo '</td><td class=pcright>';
renderProblematicObjectsPortlet();
+ echo '</td><td class=pcright>';
+ renderTagFilterPortlet ($tagfilter, 'object');
echo "</td></tr></table>\n";
}
}
else
printImageHREF ('nodelete', 'There are IP addresses allocated or reserved');
- echo "</td>\n<td><a href='${root}?page=iprange&id=${iprange['id']}'>${iprange['ip']}/${iprange['mask']}</a></td><td>${iprange['name']}</td><td class=tdleft>";
+ echo "</td>\n<td class=tdleft><a href='${root}?page=iprange&id=${iprange['id']}'>";
+ echo "${iprange['ip']}/${iprange['mask']}</a></td><td class=tdleft>${iprange['name']}";
+ echo "</td><td class=tdleft>";
renderProgressBar ($usedips / $totalips);
echo " ${usedips}/${totalips}";
echo "</td></tr>";
function renderAddMultipleObjectsForm ()
{
- global $pageno, $tabno, $nextorder;
+ global $root, $pageno, $tabno, $nextorder;
$type_id = array();
$global_type_id = 0;
$typelist[0] = 'select type...';
startPortlet ('Fast way');
- echo '<form>';
- echo "<input type=hidden name=page value=${pageno}>";
- echo "<input type=hidden name=tab value=${tabno}>";
+ echo "<form name=fastform method=post action='${root}?page=${pageno}&tab=${tabno}'>";
echo '<table border=0 align=center>';
echo "<tr><th>Object type</th><th>Common name</th><th>Visible label</th><th>Asset tag</th><th>Barcode</th></tr>\n";
// If a user forgot to select object type on input, we keep his
finishPortlet();
startPortlet ('Very fast way');
- echo '<form>';
- echo "<input type=hidden name=page value=${pageno}>";
- echo "<input type=hidden name=tab value=${tabno}>";
+ echo "<form name=veryfastform method=post action='${root}?page=${pageno}&tab=${tabno}'>";
echo 'For each line shown below create an object of type ';
printSelect ($typelist, "global_type_id", getConfigVar ('DEFAULT_OBJECT_TYPE'));
echo " <input type=submit name=got_very_fast_data value='Go!'><br>\n";
$order = 'odd';
foreach ($accounts as $user)
{
- echo "<tr class=row_${order}><td class=tdleft>${user['user_name']}</td><td class=tdleft>${user['user_realname']}</td></li>";
+ echo "<tr class=row_${order}><td class=tdleft><div title='\$userid_${user['user_id']}'>";
+ echo "${user['user_name']}</div></td>";
+ echo "<td class=tdleft>${user['user_realname']}</td></li>";
$order = $nextorder[$order];
}
echo '</table>';
function renderTagTree ()
{
+ global $tagtree;
echo '<table>';
- foreach (getTagTree() as $taginfo)
+ foreach ($tagtree as $taginfo)
{
echo '<tr>';
renderTagRowForViewer ($taginfo);
function renderTagTreeEditor ()
{
- global $root, $pageno, $tabno;
+ global $root, $pageno, $tabno, $taglist, $tagtree;
showMessageOrError();
echo "<table cellspacing=0 cellpadding=5 align=center class=widetable>\n";
echo "<tr><th> </th><th>tag</th><th> </th></tr>\n";
- foreach (getTagTree() as $taginfo)
+ foreach ($tagtree as $taginfo)
{
renderTagRowForEditor ($taginfo, TRUE);
}
printImageHREF ('grant', 'Create tag', TRUE);
echo '</td><td><input type=text name=tagname> under <select name=parent_id>';
echo "<option value=0>-- NONE --</option>\n";
- foreach (getTagList() as $taginfo)
+ foreach ($taglist as $taginfo)
echo "<option value=${taginfo['id']}>${taginfo['tag']}</option>";
echo "</select></td><td> </td></tr>";
echo "</form>\n";
function renderEntityTags ($entity_realm = '', $bypass_name, $entity_id = 0)
{
+ global $tagtree;
if ($entity_realm == '' or $entity_id <= 0)
{
showError ('Invalid or missing arguments', __FUNCTION__);
}
global $root, $pageno, $tabno;
showMessageOrError();
- $tree = getTagTree();
startPortlet ('Tag list');
echo "<form method=post action='${root}process.php'>\n";
echo "<input type=hidden name=page value=${pageno}>\n";
echo "<input type=hidden name=${bypass_name} value=${entity_id}>\n";
echo "<input type=hidden name=op value=save>\n";
echo '<select name=taglist[] multiple size=' . getConfigVar ('MAXSELSIZE') . '>';
- foreach ($tree as $taginfo)
+ foreach ($tagtree as $taginfo)
renderTagOption ($taginfo);
echo '</select><br>';
echo "<input type=submit value='Save'></form>\n";
function renderTagFilterPortlet ($tagfilter, $realm)
{
- global $pageno, $tabno;
+ global $pageno, $tabno, $taglist, $tagtree;
startPortlet ('Tag filter');
- if (!count (($tagTree = getTagTree())))
+ if (!count ($taglist))
{
echo "No tags defined";
return;
echo "<input type=hidden name=page value=${pageno}>\n";
echo "<input type=hidden name=tab value=${tabno}>\n";
echo '<select name=tagfilter[] multiple>';
- foreach ($tagTree as $taginfo)
+ foreach ($tagtree as $taginfo)
renderTagOptionForFilter ($taginfo, $tagfilter, $realm);
echo '</select><br>';
echo "<input type=submit value='Apply'></form>\n";
function renderTagSelect ()
{
- if (!count (($tagTree = getTagTree())))
+ global $taglist, $tagtree;
+ if (!count ($taglist))
{
echo "No tags defined";
return;
}
echo '<select name=taglist[] multiple>';
- foreach ($tagTree as $taginfo)
+ foreach ($tagtree as $taginfo)
renderTagOption ($taginfo);
echo '</select><br>';
}