4 require_once 'plc_login.php';
6 // Get session and API handles
7 require_once 'plc_session.php';
11 require_once 'plc_drupal.php';
12 drupal_set_title('Slivers');
13 include 'plc_header.php';
16 require_once 'plc_functions.php';
17 require_once 'plc_sorts.php';
20 $_person= $plc->person;
21 $_roles= $_person['role_ids'];
23 //print_r( $_person );
26 // if add is set, diplay add sliver form
28 $node_id= $_GET['add'];
29 $slice_id= $_GET['slice'];
32 $slice_info= $api->GetSlices( array( intval( $slice_id ) ), array( "name" ) );
35 $node_info= $api->GetNodes( array( intval( $node_id ) ), array( "hostname" ) );
38 $type_info= $api->GetTagTypes( NULL, array( "tag_type_id", "tagname" ) );
40 // get the slivers for this node
41 $sliver_info= $api->GetSliceTags( array( "node_id"=>intval( $node_id ), "slice_id"=>intval( $slice_id ) ), array( "tag_type_id", "name" ) );
43 $types_left= $type_info;
47 echo "<form action='sliver_action.php' method=post>\n
48 <h2>Add a Sliver Tag to ". $slice_info[0]['name'] ." on node ". $node_info[0]['hostname'] ."</h2>\n
49 <table class='list_set' border=0 cellpadding=2><tbody>\n
50 <tr class='list_set'><th class='list_set'>Tag: </th><td class='list_set'><select name='sliver'>\n";
52 foreach( $types_left as $type ) {
53 echo "<option value='". $type['tag_type_id'] ."'>". $type['name'] ."</option>\n";
57 echo "</td><td class='list_set'></td></tr>\n
58 <tr class='list_set'><th class='list_set'>Value: </th><td class='list_set'><input type=text name='value'></td></tr>\n
60 <input type=hidden name='node_id' value='$node_id'><input type=hidden name='slice_id' value='$slice_id'>
61 <p><input type=submit name='add_sub' value='Add Sliver Tag'>\n";
63 echo "<p><a href='index.php?id=$node_id'>Back to Node</a>\n</form>\n";
68 // if slice and node ids are passed display slivers and tags
69 if( $_GET['slice'] && $_GET['node'] ) {
70 $slice_id= $_GET['slice'];
71 $node_id= $_GET['node'];
74 $slice_info= $api->GetSlices( array( intval( $slice_id ) ), array( "name" ) );
77 $node_info= $api->GetNodes( array( intval( $node_id ) ), array( "hostname" ) );
79 // get the slivers for this node
80 $sliver_info= $api->GetSliceTags( array( "node_id"=>intval( $node_id ), "slice_id"=>intval( $slice_id ) ), array( "slice_tag_id", "name", "value", "min_role_id", "description" ) );
82 // get the attrbibutes for this slice
83 $tag_info= $api->GetSliceTags( array( intval( $slice_id ) ), array( "slice_tag_id", "name", "value", "min_role_id", "description" ) );
87 echo "<form action='slivers.php' method=post>\n<h2>Sliver Details for slice ". $slice_info[0]['name'] ." on node ". $node_info[0]['hostname'] ."</h2>\n";
89 // sliver tags of slice
90 if( empty( $sliver_info ) )
91 // if no sliver exists tell user
92 echo "No sliver tag for this node/slice sliver combination.\n";
94 echo "<p><table class='list_set' border=0 cellpadding=2>\n<caption class='list_set'>Slivers</caption>\n<thead><tr class='list_set'><th class='list_set'>Name</th><th class='list_set'>Value</th><th class='list_set'>Min Roll</th><th class='list_set'>Description</th>";
95 if ( in_array( 10, $_roles ) || ( in_array( 20, $_roles ) && in_array( $node_info, $_person['site_ids'] ) ) ) echo "<th></th><th></th>";
96 echo "</tr></thead><tbody>\n";
98 foreach( $sliver_info AS $sliver ) {
99 echo "<tr><td>". $sliver['name'] ."</td><td>". $sliver['value'] ."</td><td>". $sliver['min_role_id'] ."</td><td>". $sliver['description'] ."</td>";
100 if ( in_array( 10, $_roles ) || ( in_array( 20, $_roles ) && in_array( $node_info, $_person['site_ids'] ) ) ) echo "<td><a href='/db/slices/tags.php?type=slice&id=". $sliver['slice_tag_id'] ."'>Edit</a></td><td><a href='sliver_action.php?rem_id=". $sliver['slice_tag_id'] ."' onclick=\"javascript:return confirm('Are you sure you want to remove ". $sliver['name'] ." from node ". $node_info[0]['hostname'] ."?')\">Remove</a></td>";
106 echo "</tbody></table>\n";
110 if ( in_array( 10, $_roles ) || ( in_array( 20, $_roles ) && in_array( $node_info, $_person['site_ids'] ) ) ) echo "<p><a href='slivers.php?add=$node_id&slice=$slice_id'>Add Sliver Tag</a>\n";
114 // regular tags of slice
115 if( empty( $tag_info ) )
116 // if no tags exist tell user
117 echo "No Tags for this slice.\n";
119 echo "<p><table class='list_set' border=0 cellpadding=2>\n<caption class='list_set'>Tags</caption>\n<thead><tr class='list_set'><th class='list_set'>Name</th><th class='list_set'>Value</th><th class='list_set'>Min Roll</th><th class='list_set'>Description</th>";
120 if ( in_array( 10, $_roles ) || ( in_array( 20, $_roles ) && in_array( $node_info, $_person['site_ids'] ) ) ) echo "<th></th>";
121 echo "</tr></thead><tbody>\n";
123 foreach( $tag_info AS $tag ) {
124 echo "<tr><td>". $tag['name'] ."</td><td>". $tag['value'] ."</td><td>". $tag['min_role_id'] ."</td><td>". $tag['description'] ."</td>";
125 if ( in_array( 10, $_roles ) || ( in_array( 20, $_roles ) && in_array( $node_info, $_person['site_ids'] ) ) ) echo "<td><a href='tags.php?type=slice&id=". $tag['slice_tag_id'] ."'>Edit</a></td>";
131 echo "</tbody></table>\n";
136 echo "<p><a href='index.php?id=$node_id'>Back to Node</a>\n</form>\n";
142 include 'plc_footer.php';