// Common functions
require_once 'plc_functions.php';
+require_once 'plc_peers.php';
require_once 'plc_minitabs.php';
require_once 'plc_tables.php';
require_once 'plc_details.php';
$site=$sites[0];
// var names to api return
-$sitename= $site['name'];
-$abbrev_name= $site['abbreviated_name'];
+$sitename= htmlentities($site['name']);
+$abbreviated_name= htmlentities($site['abbreviated_name']);
$site_url= $site['url'];
$login_base= $site['login_base'];
$site_lat= $site['latitude'];
$enabled = $site['enabled'];
+// extra privileges to admins, and (pi||tech) on this site
+$privileges = plc_is_admin () || ( plc_in_site($site_id) && ( plc_is_pi() || plc_is_tech()));
+
// get peer details
$peer_id= $site['peer_id'];
-if ($peer_id) {
- $peers=$api->GetPeers(array("peer_id"=>$peer_id));
- $peer=$peers[0];
- }
+$peers = new Peers ($api);
$adress_ids= $site['address_ids'];
$pcu_ids= $site['pcu_ids'];
$api->GetAddresses( $adress_ids );
// gets pcu info
-$api->GetPCUs( $pcu_ids );
+// GetPCUs is not accessible to the 'user' role
+//$api->GetPCUs( $pcu_ids );
// gets node info
$api->GetNodes( $node_ids, array( "node_id", "hostname", "boot_state" ) );
$api->GetSlices ( $slice_ids, array ("slice_id", "name", "instantiation" ) );
-list( $addresses, $pcus, $nodes, $persons, $slices )= $api->commit();
+//list( $addresses, $pcus, $nodes, $persons, $slices )= $api->commit();
+list( $addresses, $nodes, $persons, $slices )= $api->commit();
$techs = array();
$pis = array();
+$disabled_persons = array();
foreach( $persons as $person ) {
$role_ids= $person['role_ids'];
- if( in_array( '40', $role_ids ))
- $techs[] = $person;
-
- if( in_array( '20', $role_ids ))
- $pis[] = $person;
+
+ if ( in_array( '20', $role_ids )) $pis[] = $person;
+ if ( in_array( '40', $role_ids )) $techs[] = $person;
+ if ( ! $person['enabled'] ) $disabled_persons[] = $person;
}
-// fetches peers and initialize hash peer_id->peer
-$peer_hash = plc_peer_global_hash ($api);
-// show gray background on foreign objects : start a <div> with proper class
-plc_peer_block_start ($peer_hash,$peer_id);
-
drupal_set_title("Details for site " . $sitename);
+$local_peer = ! $peer_id;
// extra privileges to admins, and pi on this site
$privileges = plc_is_admin () || ( plc_in_site($site_id) && plc_is_pi());
$tabs=array();
+
+$tabs []= tab_sites();
+$tabs []= tab_sites_local();
+
// available actions
-if ( ! $peer_id && $privileges ) {
+if ( $local_peer && $privileges ) {
- $tabs['Update']=array('url'=>l_site_update($site_id),
- 'bubble'=>"Update details of $sitename");
- // not avail to PI
$tabs['Expire slices'] = array('url'=>l_actions(),
+ 'method'=>'POST',
'values'=>array('site_id'=>$site_id,
'action'=>'expire-all-slices-in-site'),
'bubble'=>"Expire all slices and prevent creation of new slices",
'confirm'=>"Suspend all slices in $login_base");
if (plc_is_admin())
$tabs['Delete']=array('url'=>l_actions(),
+ 'method'=>'POST',
'values'=>array('site_id'=>$site_id,
'action'=>'delete-site'),
'bubble'=>"Delete site $sitename",
'confirm'=>"Are you sure you want to delete site $login_base");
- $tabs["Events"]=array_merge (tabs_events(),
+ $tabs["Events"]=array_merge (tablook_event(),
array('url'=>l_event("Site","site",$site_id),
'bubble'=>"Events for site $sitename"));
- $tabs["Comon"]=array_merge(tabs_comon(),
+ $tabs["Comon"]=array_merge(tablook_comon(),
array('url'=>l_comon("site_id",$site_id),
'bubble'=>"Comon page for $sitename"));
'bubble'=>'Review pending join requests');
}
-$tabs["All sites"]=l_sites();
-
plc_tabs($tabs);
+// show gray background on foreign objects : start a <div> with proper class
+$peers->block_start ($peer_id);
+
if ( ! $enabled )
plc_warning ("This site is not enabled - Please visit " .
href (l_sites_pending(),"this page") .
" to review pending applications.");
-plc_details_start();
-plc_details_line("Full name",$sitename);
-plc_details_line("Login base",$login_base);
-plc_details_line("Abbreviated name",$abbrev_name);
-plc_details_line("URL",$site_url);
-plc_details_line("Latitude",$site_lat);
-plc_details_line("Longitude",$site_long);
-plc_details_line("Peer",plc_peer_label($peer));
+$can_update=(plc_is_admin () && $local_peer) || ( plc_in_site($site_id) && plc_is_pi());
+$details = new PlcDetails($can_update);
+
+if ( ! $site['is_public'])
+ plc_warning("This site is not public!");
+
+$details->start();
+
+$details->form_start(l_actions(),array('action'=>'update-site','site_id'=>$site_id));
+$details->th_td("Full name",$sitename,'name',array('width'=>50));
+$details->th_td("Abbreviated name",$abbreviated_name,'abbreviated_name',array('width'=>15));
+$details->th_td("URL",$site_url,'url',array('width'=>50));
+$details->th_td("Latitude",$site_lat,'latitude');
+$details->th_td("Longitude",$site_long,'longitude');
+
+// modifiable by admins only
+if (plc_is_admin())
+ $details->th_td("Login base",$login_base,'login_base',array('width'=>12));
+else
+ $details->th_td("Login base",$login_base);
+if (plc_is_admin())
+ $details->th_td("Max slices",$max_slices,'max_slices');
+else
+ $details->th_td("Max slices",$max_slices);
+$details->tr_submit("submit","Update Site");
+$details->form_end();
+
+if ( ! $local_peer) {
+ $details->space();
+ $details->th_td("Peer",$peers->peer_link($peer_id));
+ }
-if ( ! $peer_id ) {
-
- // Addresses
- if ($addresses) {
- plc_details_space_line();
- plc_details_line("Addresses","");
- foreach ($addresses as $address) {
- plc_details_line(plc_vertical_table($address['address_types']),
- plc_vertical_table($address['line1'],
- $address['line2'],
- $address['line3'],
- $address['city'],
- $address['state'],
- $address['postalcode'],
- $address['country']));
- }
- }
+if ( $local_peer ) {
// Nodes
- plc_details_space_line();
+ $details->space();
$nb_boot = 0;
if ($nodes) foreach ($nodes as $node) if ($node['boot_state'] == 'boot') $nb_boot ++;
- $node_text = $nb_boot . " boot / " . count($nodes) . " total";
- plc_details_line("# Nodes", href(l_nodes_site($site_id),$node_text));
+ $node_label = $nb_boot . " boot / " . count($nodes) . " total";
+ $details->th_td("# Nodes", href(l_nodes_site($site_id),$node_label));
function n_link ($n) { return l_node_t($n['node_id'],$n['hostname'] . " (" . $n['boot_state'] . ")");}
- $nodes_text= plc_vertical_table(array_map ("n_link",$nodes));
- plc_details_line ("hostnames",$nodes_text);
-
+ $nodes_label= plc_vertical_table(array_map ("n_link",$nodes));
+ $details->th_td ("Hostnames",$nodes_label);
+ $button=new PlcFormButton (l_node_add(),"add_node","Add node","POST");
+ $details->tr($button->html(),"right");
+
// Users
- plc_details_space_line();
- $user_text = count($person_ids) . " total / " .
+ $details->space();
+ $user_label = count($person_ids) . " Total / " .
count ($pis) . " PIs / " .
- count ($techs) . " techs";
+ count ($techs) . " Techs";
if ( (count ($pis) == 0) || (count ($techs) == 0) || (count($person_ids) >=50))
- $user_text = plc_warning_text ($user_text);
- plc_details_line ("# Users",href(l_persons_site($site_id),$user_text));
+ $user_label = plc_warning_html ($user_label);
+ $details->th_td ("# Users",href(l_persons_site($site_id),$user_label));
function p_link ($p) { return l_person_t($p['person_id'],$p['email']); }
// PIs
- $pi_text = plc_vertical_table (array_map ("p_link",$pis));
- plc_details_line("PI's",$pi_text);
- // PIs
- $tech_text = plc_vertical_table (array_map ("p_link",$techs));
- plc_details_line("techs's",$tech_text);
+ $details->th_td("PI's",plc_vertical_table (array_map ("p_link",$pis)));
+ // techs
+ $details->th_td("Techs's",plc_vertical_table (array_map ("p_link",$techs)));
+ if (count ($disabled_persons))
+ $details->th_td("Disabled",plc_vertical_table (array_map ("p_link",$disabled_persons)));
// Slices
- plc_details_space_line();
- // summary on # slices
- $slice_text = count($slice_ids) . " running / " . $max_slices . " max";
- if (count($slice_ids) >= $max_slices) $slice_text = plc_warning_text ($slice_text);
- plc_details_line("# Slices", href(l_slices_site($site_id),$slice_text));
+ $details->space();
+ // summary on slices
+ $slice_label = count($slice_ids) . " running / " . $max_slices . " max";
+ if (count($slice_ids) >= $max_slices)
+ $slice_label = plc_warning_html ($slice_label);
+ $details->th_td("# Slices", href(l_slices_site($site_id),$slice_label));
if ($slices) foreach ($slices as $slice)
- plc_details_line($slice['instantiation'],l_slice_text($slice));
+ $details->th_td($slice['instantiation'],l_slice_obj($slice));
+ $button=new PlcFormButton (l_slice_add(),"slice_add","Add slice","POST");
+ $details->tr($button->html(),"right");
+ // Addresses
+ if ($addresses) {
+ $details->space();
+ $details->th_td("Addresses","");
+ foreach ($addresses as $address) {
+ $details->th_td(plc_vertical_table($address['address_types']),
+ plc_vertical_table(array($address['line1'],
+ $address['line2'],
+ $address['line3'],
+ $address['city'],
+ $address['state'],
+ $address['postalcode'],
+ $address['country'])));
+ }
+ }
}
-plc_details_end();
+$details->end();
////////////////////////////////////////
-plc_peer_block_end();
+$peers->block_end($peer_id);
// Print footer
include 'plc_footer.php';