3 // $Id: index.php 11750 2009-01-29 10:11:53Z thierry $
6 require_once 'plc_login.php';
8 // Get session and API handles
9 require_once 'plc_session.php';
13 require_once 'plc_drupal.php';
14 include 'plc_header.php';
17 require_once 'plc_functions.php';
18 require_once 'plc_peers.php';
19 require_once 'plc_minitabs.php';
20 require_once 'plc_tables.php';
21 require_once 'plc_details.php';
22 require_once 'plc_forms.php';
24 // --------------------
25 // recognized URL arguments
26 $site_id=intval($_GET['id']);
27 if ( ! $site_id ) { plc_error('Malformed URL - id not set'); return; }
30 // Get all columns as we focus on only one entry
31 $sites= $api->GetSites( array($site_id));
34 drupal_set_message ("Site " . $site_id . " not found");
39 // var names to api return
40 $sitename= htmlentities($site['name']);
41 $abbreviated_name= htmlentities($site['abbreviated_name']);
42 $site_url= $site['url'];
43 $login_base= $site['login_base'];
44 $site_lat= $site['latitude'];
45 $site_long= $site['longitude'];
46 $max_slivers= $site['max_slivers'];
47 $max_slices= $site['max_slices'];
49 $enabled = $site['enabled'];
51 // extra privileges to admins, and (pi||tech) on this site
52 $privileges = plc_is_admin () || ( plc_in_site($site_id) && ( plc_is_pi() || plc_is_tech()));
55 $peer_id= $site['peer_id'];
56 $peers = new Peers ($api);
58 $adress_ids= $site['address_ids'];
59 $pcu_ids= $site['pcu_ids'];
60 $node_ids= $site['node_ids'];
61 $person_ids= $site['person_ids'];
62 $slice_ids= $site['slice_ids'];
66 $api->GetAddresses( $adress_ids );
69 // GetPCUs is not accessible to the 'user' role
70 //$api->GetPCUs( $pcu_ids );
73 $api->GetNodes( $node_ids, array( "node_id", "hostname", "boot_state" ) );
76 $api->GetPersons( $person_ids, array( "role_ids", "person_id", "first_name", "last_name", "email", "enabled" ) );
78 $api->GetSlices ( $slice_ids, array ("slice_id", "name", "instantiation" ) );
80 //list( $addresses, $pcus, $nodes, $persons, $slices )= $api->commit();
81 list( $addresses, $nodes, $persons, $slices )= $api->commit();
85 $disabled_persons = array();
86 foreach( $persons as $person ) {
87 $role_ids= $person['role_ids'];
89 if ( in_array( '20', $role_ids )) $pis[] = $person;
90 if ( in_array( '40', $role_ids )) $techs[] = $person;
91 if ( ! $person['enabled'] ) $disabled_persons[] = $person;
95 drupal_set_title("Details for site " . $sitename);
96 $local_peer = ! $peer_id;
98 // extra privileges to admins, and pi on this site
99 $privileges = plc_is_admin () || ( plc_in_site($site_id) && plc_is_pi());
103 if ( $local_peer && $privileges ) {
105 $tabs['Expire slices'] = array('url'=>l_actions(),
107 'values'=>array('site_id'=>$site_id,
108 'action'=>'expire-all-slices-in-site'),
109 'bubble'=>"Expire all slices and prevent creation of new slices",
110 'confirm'=>"Suspend all slices in $login_base");
112 $tabs['Delete']=array('url'=>l_actions(),
114 'values'=>array('site_id'=>$site_id,
115 'action'=>'delete-site'),
116 'bubble'=>"Delete site $sitename",
117 'confirm'=>"Are you sure you want to delete site $login_base");
118 $tabs["Events"]=array_merge (tabs_events(),
119 array('url'=>l_event("Site","site",$site_id),
120 'bubble'=>"Events for site $sitename"));
121 $tabs["Comon"]=array_merge(tabs_comon(),
122 array('url'=>l_comon("site_id",$site_id),
123 'bubble'=>"Comon page for $sitename"));
126 $tabs['Pending'] = array ('url'=>l_sites_pending(),
127 'bubble'=>'Review pending join requests');
130 $tabs["All sites"]=l_sites();
134 // show gray background on foreign objects : start a <div> with proper class
135 $peers->block_start ($peer_id);
138 plc_warning ("This site is not enabled - Please visit " .
139 href (l_sites_pending(),"this page") .
140 " to review pending applications.");
142 $can_update=plc_is_admin () || ( plc_in_site($site_id) && plc_is_pi());
143 $details = new PlcDetails($can_update);
145 if ( ! $site['is_public'])
146 plc_warning("This site is not public!");
149 $details->line("Peer",$peers->peer_link($peer_id));
152 $details->form_start(l_actions(),array('action'=>'update-site','site_id'=>$site_id));
153 $save_w=$details->set_field_width(30);
154 $details->line("Full name",$sitename,'name');
155 $details->set_field_width($save_w);
156 $details->line("Abbreviated name",$abbreviated_name,'abbreviated_name');
157 $details->line("URL",$site_url,'url');
158 $details->line("Latitude",$site_lat,'latitude');
159 $details->line("Longitude",$site_long,'longitude');
161 $details->line("Login base",$login_base,'login_base');
163 $details->line("Login base",$login_base);
165 $details->line("Max slices",$max_slices,'max_slices');
167 $details->line("Max slices",$max_slices);
168 $details->line("",$details->submit_html("submit","Update Site"));
169 $details->form_end();
176 if ($nodes) foreach ($nodes as $node) if ($node['boot_state'] == 'boot') $nb_boot ++;
177 $node_label = $nb_boot . " boot / " . count($nodes) . " total";
178 $details->line("# Nodes", href(l_nodes_site($site_id),$node_label));
179 function n_link ($n) { return l_node_t($n['node_id'],$n['hostname'] . " (" . $n['boot_state'] . ")");}
180 $nodes_label= plc_vertical_table(array_map ("n_link",$nodes));
181 $details->line ("Hostnames",$nodes_label);
182 $button=new PlcFormButton (l_node_add(),"add_node","Add node","POST");
183 $details->line("",$button->html());
187 $user_label = count($person_ids) . " Total / " .
188 count ($pis) . " PIs / " .
189 count ($techs) . " Techs";
190 if ( (count ($pis) == 0) || (count ($techs) == 0) || (count($person_ids) >=50))
191 $user_label = plc_warning_html ($user_label);
192 $details->line ("# Users",href(l_persons_site($site_id),$user_label));
193 function p_link ($p) { return l_person_t($p['person_id'],$p['email']); }
195 $details->line("PI's",plc_vertical_table (array_map ("p_link",$pis)));
197 $details->line("Techs's",plc_vertical_table (array_map ("p_link",$techs)));
198 if (count ($disabled_persons))
199 $details->line("Disabled",plc_vertical_table (array_map ("p_link",$disabled_persons)));
204 $slice_label = count($slice_ids) . " running / " . $max_slices . " max";
205 if (count($slice_ids) >= $max_slices)
206 $slice_label = plc_warning_html ($slice_label);
207 $details->line("# Slices", href(l_slices_site($site_id),$slice_label));
208 if ($slices) foreach ($slices as $slice)
209 $details->line($slice['instantiation'],l_slice_obj($slice));
210 $button=new PlcFormButton (l_slice_add(),"slice_add","Add slice","POST");
211 $details->line("",$button->html());
216 $details->line("Addresses","");
217 foreach ($addresses as $address) {
218 $details->line(plc_vertical_table($address['address_types']),
219 plc_vertical_table(array($address['line1'],
224 $address['postalcode'],
225 $address['country'])));
233 ////////////////////////////////////////
234 $peers->block_end($peer_id);
237 include 'plc_footer.php';