r2764 - doSNMPmining(): switch from getObjectInfo() to spotEntity()
[racktables] / inc / triggers.php
CommitLineData
b325120a 1<?php
641fe9b0
DO
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
913e0ebf 10// the trigger returned CSS class name. In certain cases, a key is necessary
641fe9b0
DO
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.
46f92ff7 18function trigger_livevlans ()
641fe9b0 19{
2c6c7645 20 assertUIntArg ('object_id', __FUNCTION__);
641fe9b0 21 $object_id = $_REQUEST['object_id'];
6297d584 22 $object = spotEntity ('object', $object_id, FALSE);
641fe9b0 23 if ($object['objtype_id'] != 8)
913e0ebf 24 return '';
641fe9b0
DO
25 $values = getAttrValues ($object_id);
26 foreach ($values as $record)
27 {
dce5a9e7 28 if ($record['id'] != 4) // SW type
641fe9b0 29 continue;
dce5a9e7
DO
30 // Cisco IOS 12.0
31 // Cisco IOS 12.1
32 // Cisco IOS 12.2
33 if (in_array ($record['key'], array (244, 251, 252)))
913e0ebf 34 return 'std';
641fe9b0 35 else
913e0ebf 36 return '';
641fe9b0 37 }
913e0ebf 38 return '';
641fe9b0
DO
39}
40
9c67f713
DO
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.
44function trigger_snmpportfinder ()
45{
2c6c7645 46 assertUIntArg ('object_id', __FUNCTION__);
b179c07c 47 $object = spotEntity ('object', $_REQUEST['object_id']);
9c67f713 48 if ($object['objtype_id'] != 8)
913e0ebf 49 return '';
125b5f39 50 return count (getObjectPortsAndLinks ($_REQUEST['object_id'])) ? '' : 'attn';
9c67f713
DO
51}
52
a0527aef 53function trigger_isloadbalancer ()
3ee1252b 54{
2c6c7645 55 assertUIntArg ('object_id', __FUNCTION__);
212c9d8a 56 return considerConfiguredConstraint (spotEntity ('object', $_REQUEST['object_id']), 'IPV4LB_LISTSRC') ? 'std' : '';
6dbdc7c7
DO
57}
58
59function trigger_ipv4 ()
60{
2c6c7645 61 assertUIntArg ('object_id', __FUNCTION__);
aa90450a 62 if (count (getObjectIPv4Allocations ($_REQUEST['object_id'])))
913e0ebf 63 return 'std';
aa90450a 64 // Only hide the tab, if there are no addresses allocated.
212c9d8a 65 return considerConfiguredConstraint (spotEntity ('object', $_REQUEST['object_id']), 'IPV4OBJ_LISTSRC') ? 'std' : '';
6dbdc7c7
DO
66}
67
68function trigger_natv4 ()
69{
2c6c7645 70 assertUIntArg ('object_id', __FUNCTION__);
212c9d8a 71 return considerConfiguredConstraint (spotEntity ('object', $_REQUEST['object_id']), 'IPV4NAT_LISTSRC') ? 'std' : '';
3ee1252b
DO
72}
73
a785988f
DO
74function trigger_poolrscount ()
75{
2c6c7645 76 assertUIntArg ('pool_id', __FUNCTION__);
a6e91ac2
DO
77 $poolInfo = spotEntity ('ipv4rspool', $_REQUEST['pool_id']);
78 amplifyCell ($poolInfo);
913e0ebf 79 return count ($poolInfo['rslist']) ? 'std' : '';
a785988f
DO
80}
81
118e4c38
DO
82function trigger_autoports ()
83{
2c6c7645 84 assertUIntArg ('object_id', __FUNCTION__);
125b5f39 85 if (count (getObjectPortsAndLinks ($_REQUEST['object_id'])))
913e0ebf 86 return '';
125b5f39 87 $info = spotEntity ('object', $_REQUEST['object_id']);
913e0ebf 88 return count (getAutoPorts ($info['objtype_id'])) ? 'attn' : '';
118e4c38
DO
89}
90
91dbb8a3
DO
91function trigger_tags ()
92{
20c901a7 93 global $taglist;
913e0ebf 94 return count ($taglist) ? 'std' : '';
91dbb8a3
DO
95}
96
0ac7e4b3
DO
97function trigger_passwdchange ()
98{
204284ba 99 global $user_auth_src;
913e0ebf 100 return $user_auth_src == 'database' ? 'std' : '';
0ac7e4b3
DO
101}
102
e5c4506d
DO
103function trigger_localreports ()
104{
105 global $localreports;
913e0ebf 106 return count ($localreports) ? 'std' : '';
e5c4506d
DO
107}
108
8628ae44
DO
109function trigger_file_editText ()
110{
111 assertUIntArg ('file_id', __FUNCTION__);
112 $fileInfo = getFileInfo ($_REQUEST['file_id']);
913e0ebf 113 return ($fileInfo['type'] == 'text/plain') ? 'std' : '';
8628ae44
DO
114}
115
641fe9b0 116?>