X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=planetlab%2Fsites%2Fsite.php;h=1a0ffbacec57e58745f06828abb363614f72cb8b;hb=3bdca023594d530cdbfa9c5662aa494c1e06956c;hp=ef5fe1e72d3ccd0f2561af1f2c299cfe534203f4;hpb=e14802949c7a66853594ae9d8c297ce666039fed;p=plewww.git
diff --git a/planetlab/sites/site.php b/planetlab/sites/site.php
index ef5fe1e..1a0ffba 100644
--- a/planetlab/sites/site.php
+++ b/planetlab/sites/site.php
@@ -38,6 +38,9 @@ if (empty($sites)) {
$site=$sites[0];
// var names to api return
+// Thomas Dreibholz suggested that utf8_decode could be non-needed
+// and maybe even harmful on modern systems like f23
+// $sitename= htmlentities(utf8_decode($site['name']));
$sitename= htmlentities($site['name']);
$abbreviated_name= htmlentities($site['abbreviated_name']);
$site_url= $site['url'];
@@ -48,6 +51,7 @@ $max_slivers= $site['max_slivers'];
$max_slices= $site['max_slices'];
$enabled = $site['enabled'];
+$ext_consortium_id = $site ['ext_consortium_id'];
// get peer
$peer_id= $site['peer_id'];
@@ -65,30 +69,44 @@ $node_ids= $site['node_ids'];
$person_ids= $site['person_ids'];
$slice_ids= $site['slice_ids'];
-$api->begin();
+//$api->begin();
// gets address info
-$api->GetAddresses( $address_ids );
+$addresses = $api->GetAddresses( $address_ids );
// gets node info
-$api->GetNodes( $node_ids, array( "node_id", "hostname", "boot_state", "pcu_ids", "ports" ) );
-
+if ($node_ids) {
+ $nodes = $api->GetNodes( $node_ids, array( "node_id", "hostname", "boot_state", "pcu_ids", "ports" ) );
+} else {
+ $nodes = array();
+}
// gets person info
-$api->GetPersons( $person_ids, array( "role_ids", "person_id", "first_name", "last_name", "email", "enabled" , "slice_ids") );
-
-$api->GetSlices ( $slice_ids, array ("slice_id", "name", "instantiation", "node_ids", "person_ids" ) );
+if ($person_ids) {
+ $persons = $api->GetPersons( $person_ids, array( "role_ids", "person_id", "first_name", "last_name", "email", "enabled" , "slice_ids") );
+} else {
+ $persons = array();
+}
+if ($slice_ids) {
+ $slices = $api->GetSlices ( $slice_ids, array ("slice_id", "name", "instantiation", "node_ids", "person_ids" ) );
+} else {
+ $slices = array();
+}
////////////////////
// PCU stuff - not too sure why, but GetPCUs is not exposed to the 'user' role
$display_pcus = (plc_is_admin() || plc_is_pi() || plc_is_tech());
-if ($display_pcus)
- $api->GetPCUs ($pcu_ids, array ('hostname', 'pcu_id' ));
-
+if ($display_pcus) {
+ if ($pcu_ids) {
+ $pcus = $api->GetPCUs ($pcu_ids, array ('hostname', 'pcu_id' ));
+ } else {
+ $pcus = array();
+ }
+}
// get results
-if ($display_pcus)
- list( $addresses, $nodes, $persons, $slices, $pcus )= $api->commit();
-else
- list( $addresses, $nodes, $persons, $slices )= $api->commit();
-
+//if ($display_pcus)
+// list( $addresses, $nodes, $persons, $slices, $pcus )= $api->commit();
+//else
+// list( $addresses, $nodes, $persons, $slices )= $api->commit();
+
$techs = array();
$pis = array();
$disabled_persons = array();
@@ -150,21 +168,28 @@ plekit_linetabs($tabs);
// show gray background on foreign objects : start a
with proper class
$peers->block_start ($peer_id);
-if ( $local_peer && ( ! $enabled ) ) {
- if ($site['ext_consortium_id'] == $PENDING_CONSORTIUM_ID) {
- plc_warning ("This site is not enabled - Please visit " .
- href (l_sites_pending(),"this page") .
- " to review pending applications.");
- } else {
- plc_warning ("This site is disabled.");
- }
+// sanity checks
+if ( $local_peer ) {
+ // pending site
+ global $PENDING_CONSORTIUM_ID;
+ if ( $ext_consortium_id === $PENDING_CONSORTIUM_ID) {
+ if ( ! $enabled )
+ plc_warning ("This site is under pending registration - Please visit " .
+ href (l_sites_pending(),"this page") .
+ " to review pending applications.");
+ else
+ plc_warning ("This site is pending but is also enabled - something is wrong. You should fix the issue with plcsh");
+ } else {
+ if ( ! $enabled)
+ plc_warning ("This site is disabled.");
+ }
}
$can_update=(plc_is_admin () && $local_peer) || ( plc_in_site($site_id) && plc_is_pi());
$toggle = new PlekitToggle ('site',"Details",
- array('visible'=>get_arg('show_details',true),
+ array('visible'=>get_arg('show_details'),
'bubble'=>'Display and modify details for that site'));
$toggle->start();
@@ -229,7 +254,7 @@ if ( $local_peer ) {
$nodes_title .= href(l_nodes_site($site_id)," (See as nodes)");
$toggle=new PlekitToggle ('nodes',$nodes_title,
- array('visible'=>get_arg('show_nodes',true)));
+ array('visible'=>get_arg('show_nodes')));
$toggle->start();
$headers=array();
@@ -256,7 +281,7 @@ if ( $local_peer ) {
if (empty($ports)) return plc_error_html('???');
$port=$ports[0];
$pcu=$pcu_hash[$pcu_id];
- $display= $pcu['hostname'] . ' : ' . $port;
+ $display= l_pcu_href($pcu_id, $pcu['hostname'] . ' : ' . $port);
$pcu_hash[$pcu_id]['displayed']=true;
return $display;
}
@@ -302,7 +327,7 @@ if ( $local_peer ) {
$persons_title .= href(l_persons_site($site_id)," (See as users)");
$toggle=new PlekitToggle ('persons',$persons_title,
- array('visible'=>get_arg('show_persons',false)));
+ array('visible'=>get_arg('show_persons')));
$toggle->start();
$headers = array ();
@@ -340,7 +365,7 @@ if ( $local_peer ) {
$slices_title .= href(l_slices_site($site_id)," (See as slices)");
$toggle=new PlekitToggle ('slices',$slices_title,
- array('visible'=>get_arg('show_slices',false)));
+ array('visible'=>get_arg('show_slices')));
$toggle->start();
$headers = array ();
@@ -374,9 +399,70 @@ if ( $local_peer ) {
$table->end();
$toggle->end();
+ $form=new PlekitForm (l_actions(), array('site_id'=>$site_id));
+ $form->start();
+ //////////////////////////////////////////////////////////// Tags
+ // tags section
+ // already inside a if ( $local_peer )...
+
+ $tags=$api->GetSiteTags (array('site_id'=>$site_id));
+ function get_tagname ($tag) { return $tag['tagname'];}
+ // xxx looks like tech-only see an error here,
+ // might be that GetSiteTags is not accessible or something
+ $tagnames = array_map ("get_tagname",$tags);
+
+ $toggle = new PlekitToggle ('tags',count_english($tags,'tag'),
+ array('bubble'=>'Inspect and set tags on that site',
+ 'visible'=>get_arg('show_tags')));
+ $toggle->start();
+
+ $headers=array("Name"=>"string",
+ "Value"=>"string",
+ );
+ if (plc_is_admin()) $headers[plc_delete_icon()]="none";
+
+ $table_options=array("notes_area"=>false,"pagesize_area"=>false,"search_width"=>10);
+ $table=new PlekitTable("site_tags",$headers,0,$table_options);
+ $table->start();
+ if ($tags) foreach ($tags as $tag) {
+ $table->row_start();
+ $table->cell(l_tag_obj($tag));
+ $table->cell($tag['value']);
+ // the remove checkbox
+ if (plc_is_admin()) $table->cell ($form->checkbox_html('site_tag_ids[]',$tag['site_tag_id']));
+ $table->row_end();
+ }
+
+ if ($is_site_pi || $is_site_admin) {
+ $table->tfoot_start();
+
+ // remove tag
+ $table->row_start();
+ $table->cell($form->submit_html("delete-site-tags","Remove Tags"),
+ // use the whole columns and right adjust
+ array('hfill'=>true,'align'=>'right'));
+ $table->row_end();
+
+ // set tag area
+ $table->row_start();
+ // get list of tag names in the site/* category
+ $all_tags= $api->GetTagTypes( array ("category"=>"site*","-SORT"=>"tagname"), array("tagname","tag_type_id"));
+ // xxx cannot use onchange=submit() - would need to somehow pass action name
+ function tag_selector ($tag) { return array("display"=>$tag['tagname'],"value"=>$tag['tag_type_id']); }
+ $selector=array_map("tag_selector",$all_tags);
+ $table->cell($form->select_html("tag_type_id",$selector,array('label'=>"Choose")));
+ $table->cell($form->text_html("value","",array('width'=>8)));
+ $table->cell($form->submit_html("set-tag-on-site","Set Tag"),array('columns'=>2,'align'=>'left'));
+ $table->row_end();
+ }
+
+ $table->end();
+ $toggle->end();
+ $form->end();
+
//////////////////// Addresses
$toggle=new PlekitToggle ('addresses',"Addresses",
- array('visible'=>get_arg('show_addresses',false)));
+ array('visible'=>get_arg('show_addresses')));
$toggle->start();
if ( ! $addresses) {
print "
No known address for this site
";