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';
19 $_person= $plc->person;
20 $_roles= $_person['role_ids'];
22 //print_r( $_person );
25 // if add is set, diplay add sliver form
27 $node_id= $_GET['add'];
28 $slice_id= $_GET['slice'];
31 $slice_info= $api->GetSlices( array( intval( $slice_id ) ), array( "name" ) );
34 $node_info= $api->GetNodes( array( intval( $node_id ) ), array( "hostname" ) );
37 $type_info= $api->GetTagTypes( NULL, array( "tag_type_id", "tagname" ) );
39 // get the slivers for this node
40 $sliver_info= $api->GetSliceTags( array( "node_id"=>intval( $node_id ), "slice_id"=>intval( $slice_id ) ), array( "tag_type_id", "name" ) );
42 $types_left= $type_info;
46 echo "<form action='sliver_action.php' method=post>\n
47 <h2>Add a Sliver Tag to ". $slice_info[0]['name'] ." on node ". $node_info[0]['hostname'] ."</h2>\n
48 <table class='list_set' border=0 cellpadding=2><tbody>\n
49 <tr class='list_set'><th class='list_set'>Tag: </th><td class='list_set'><select name='sliver'>\n";
51 foreach( $types_left as $type ) {
52 echo "<option value='". $type['tag_type_id'] ."'>". $type['name'] ."</option>\n";
56 echo "</td><td class='list_set'></td></tr>\n
57 <tr class='list_set'><th class='list_set'>Value: </th><td class='list_set'><input type=text name='value'></td></tr>\n
59 <input type=hidden name='node_id' value='$node_id'><input type=hidden name='slice_id' value='$slice_id'>
60 <p><input type=submit name='add_sub' value='Add Sliver Tag'>\n";
62 echo "<p><a href='index.php?id=$node_id'>Back to Node</a>\n</form>\n";
67 // if slice and node ids are passed display slivers and tags
68 if( $_GET['slice'] && $_GET['node'] ) {
69 $slice_id= $_GET['slice'];
70 $node_id= $_GET['node'];
73 $slice_info= $api->GetSlices( array( intval( $slice_id ) ), array( "name" ) );
76 $node_info= $api->GetNodes( array( intval( $node_id ) ), array( "hostname" ) );
78 // get the slivers for this node
79 $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" ) );
81 // get the attrbibutes for this slice
82 $tag_info= $api->GetSliceTags( array( intval( $slice_id ) ), array( "slice_tag_id", "name", "value", "min_role_id", "description" ) );
86 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";
88 // sliver tags of slice
89 if( empty( $sliver_info ) )
90 // if no sliver exists tell user
91 echo "No sliver tag for this node/slice sliver combination.\n";
93 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>";
94 if ( in_array( 10, $_roles ) || ( in_array( 20, $_roles ) && in_array( $node_info, $_person['site_ids'] ) ) ) echo "<th></th><th></th>";
95 echo "</tr></thead><tbody>\n";
97 foreach( $sliver_info AS $sliver ) {
98 echo "<tr><td>". $sliver['name'] ."</td><td>". $sliver['value'] ."</td><td>". $sliver['min_role_id'] ."</td><td>". $sliver['description'] ."</td>";
99 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>";
105 echo "</tbody></table>\n";
109 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";
113 // regular tags of slice
114 if( empty( $tag_info ) )
115 // if no tags exist tell user
116 echo "No Tags for this slice.\n";
118 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>";
119 if ( in_array( 10, $_roles ) || ( in_array( 20, $_roles ) && in_array( $node_info, $_person['site_ids'] ) ) ) echo "<th></th>";
120 echo "</tr></thead><tbody>\n";
122 foreach( $tag_info AS $tag ) {
123 echo "<tr><td>". $tag['name'] ."</td><td>". $tag['value'] ."</td><td>". $tag['min_role_id'] ."</td><td>". $tag['description'] ."</td>";
124 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>";
130 echo "</tbody></table>\n";
135 echo "<p><a href='index.php?id=$node_id'>Back to Node</a>\n</form>\n";
141 include 'plc_footer.php';