4 * This file is a library of tab triggers for RackTables.
8 // Triggers may be optionally referred by some tabs of a page.
9 // In case they are defined, the given tab is only displayed if
10 // the trigger returned true. In certain cases, a key is necessary
11 // to decide (the 'bypass' hint of a page), and in some cases,
12 // other data can be used.
14 // This trigger filters out everything except switches with known-good
16 // FIXME: That's a bit of hardcoding at the moment, but
17 // let's thinks about fixing it later.
18 function trigger_switchvlans ()
20 assertUIntArg ('object_id', __FUNCTION__
);
21 $object_id = $_REQUEST['object_id'];
22 $object = getObjectInfo ($object_id);
23 if ($object['objtype_id'] != 8)
25 $values = getAttrValues ($object_id);
26 foreach ($values as $record)
28 if ($record['id'] != 4) // SW type
33 if (in_array ($record['key'], array (244, 251, 252)))
41 // SNMP port finder tab trigger. At the moment we decide on showing it
42 // for pristine switches only. Once a user has begun
43 // filling the data in, we stop showing the tab.
44 function trigger_snmpportfinder ()
46 assertUIntArg ('object_id', __FUNCTION__
);
47 $object_id = $_REQUEST['object_id'];
48 $object = getObjectInfo ($object_id);
49 if ($object['objtype_id'] != 8)
51 $tails = getObjectPortsAndLinks ($object_id);
57 // Output "click me" in an empty rackspace.
58 function trigger_emptyRackspace ()
60 return (count (readChapter ('RackRow')) == 0);
63 function trigger_lvsconfig ()
65 assertUIntArg ('object_id', __FUNCTION__
);
66 return count (getRSPoolsForObject ($_REQUEST['object_id'])) > 0;
69 function trigger_ipv4 ()
71 assertUIntArg ('object_id', __FUNCTION__
);
72 $info = getObjectInfo ($_REQUEST['object_id']);
73 return in_array ($info['objtype_id'], explode (',', getConfigVar ('IPV4_PERFORMERS')));
76 function trigger_natv4 ()
78 assertUIntArg ('object_id', __FUNCTION__
);
79 $info = getObjectInfo ($_REQUEST['object_id']);
80 return in_array ($info['objtype_id'], explode (',', getConfigVar ('NATV4_PERFORMERS')));
83 function trigger_poolrscount ()
85 assertUIntArg ('pool_id', __FUNCTION__
);
86 $poolInfo = getRSPoolInfo ($_REQUEST['pool_id']);
87 return count ($poolInfo['rslist']) > 0;
90 function trigger_autoports ()
92 assertUIntArg ('object_id', __FUNCTION__
);
93 if (count (getObjectPortsAndLinks ($_REQUEST['object_id'])) != 0)
95 $info = getObjectInfo ($_REQUEST['object_id']);
96 return count (getAutoPorts ($info['objtype_id'])) != 0;
99 function trigger_tags ()
102 return count ($taglist) > 0;