r1245 + initial frame coding for the new gateway (SNMP port finder)
[racktables] / inc / triggers.php
1 <?
2 /*
3 *
4 * This file is a library of tab triggers for RackTables.
5 *
6 */
7
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.
13
14 // This trigger filters out everything except switches with known-good
15 // software.
16 // FIXME: That's a bit of hardcoding at the moment, but
17 // let's thinks about fixing it later.
18 function trigger_switchvlans ()
19 {
20 assertUIntArg ('object_id');
21 $object_id = $_REQUEST['object_id'];
22 $object = getObjectInfo ($object_id);
23 if ($object['objtype_id'] != 8)
24 return FALSE;
25 $values = getAttrValues ($object_id);
26 foreach ($values as $record)
27 {
28 if ($record['id'] != 4)
29 continue;
30 if (in_array ($record['key'], array (1, 20, 21)))
31 return TRUE;
32 else
33 return FALSE;
34 }
35 return FALSE;
36 }
37
38 // SNMP port finder tab trigger. At the moment we decide on showing it
39 // for pristine switches only. Once a user has begun
40 // filling the data in, we stop showing the tab.
41 function trigger_snmpportfinder ()
42 {
43 assertUIntArg ('object_id');
44 $object_id = $_REQUEST['object_id'];
45 $object = getObjectInfo ($object_id);
46 if ($object['objtype_id'] != 8)
47 return FALSE;
48 $tails = getObjectPortsAndLinks ($object_id);
49 if (count ($tails))
50 return FALSE;
51 return TRUE;
52 }
53
54 ?>