X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=planetlab%2Fsites%2Findex.php;h=a8719482130786dbffcefb1d9a639266d6909bbe;hb=9fea82d06df5c051a457045595aa682c56cddefd;hp=4b7443f947bf354702f4925d244e485e2684755a;hpb=7772d4ba04b97c8a32f3b9baf680ce4a76da1e25;p=plewww.git diff --git a/planetlab/sites/index.php b/planetlab/sites/index.php index 4b7443f..a871948 100644 --- a/planetlab/sites/index.php +++ b/planetlab/sites/index.php @@ -1,445 +1,11 @@ person; -$_roles= $_person['role_ids']; - -//////////////////// -// The set of columns to fetch -// and the filter applied for fetching sites -if ( !in_array( '10', $_roles ) ) { - $site_columns = array("site_id", "name", "abbreviated_name", "login_base" , "peer_id" ); - $filter = array ("enabled" => TRUE); - } else { - $site_columns = array("site_id", "name", "abbreviated_name", "login_base" , "peer_id" , "enabled", "person_ids", "max_slices", "slice_ids", "node_ids"); - $filter = array (); - } - - -////////////////// -// perform post-processing on site objects as returned by GetSites -// performs sanity check and summarize the result in a single column -// performs in-place replacement, so passes a reference -function layout_site ($site) { - - // we need the 'enabled' field to do this - // so regular users wont run this - if ( ! array_key_exists ('enabled', $site)) - return $site; - - $messages=array(); - - if (empty ($site['node_ids'])) $messages [] = "Site has no node"; - $class='plc-foreign'; - - // do all this stuff on local sites only - if ( ! $site['peer_id'] ) { - - $class='plc-warning'; - - // check that site is enabled - if ( ! $site['enabled']) { - $messages [] = "Not enabled"; - } - - // check that site has at least a PI and a tech - global $api; - $persons=$api->GetPersons(array("person_id"=>$site['person_ids']),array("role_ids")); - $nb_pis=0; - $nb_tech=0; - - if ( ! empty ($persons)) { - foreach ($persons as $person) { - if (in_array( '20', $person['role_ids'])) $nb_pis += 1; - if (in_array( '40', $person['role_ids'])) $nb_techs += 1; - } - } - if ($nb_pis == 0) $messages [] = "Site has no PI"; - if ($nb_techs == 0) $messages [] = "Site has no Tech"; - - // check number of slices - if ( $site['max_slices'] == 0) { - $messages [] = "No slice allowed"; - } else if (count($site["slice_ids"]) >= $site['max_slices']) { - $messages [] = "Site has no slice left"; - } - - // pretty print the cell - } - // but always cleanup $site columns - unset ($site['enabled']); - unset ($site['person_ids']); - unset ($site['max_slices']); - unset ($site['slice_ids']); - unset ($site['node_ids']); - $site['sanity check'] = plc_vertical_table($messages,$class); - - return $site; -} - - -// if sitepattern or peerscope is set : search the sites -// we use GET rather than POST so paginate can display the right contents on subsequent pages -// can be useful for writing bookmarkable URL's as well -if( $_GET['sitepattern'] || $_GET['peerscope']) { - $sitename= $_GET['sitepattern']; - if (empty($sitename)) { - $sitename="*"; - } - $filter = array_merge (array( "name"=>$sitename ), $filter); - switch ($_GET['peerscope']) { - case '': - $peer_label="all peers"; - break; - case 'local': - $filter=array_merge(array("peer_id"=>NULL),$filter); - $peer_label="local peer"; - break; - case 'foreign': - $filter=array_merge(array("~peer_id"=>NULL),$filter); - $peer_label="foreign peers"; - break; - default: - $peer_id=intval($_GET['peerscope']); - $filter=array_merge(array("peer_id"=>$peer_id),$filter); - $peer=$api->GetPeers(array("peer_id"=>$peer_id)); - $peer_label='peer "' . $peer[0]['peername'] . '"'; - break; - } - - $sites= $api->GetSites( $filter , $site_columns); - $sites = array_map(layout_site,$sites); - - $sites_count = count ($sites); - if ( $sites_count == 1) { - header( "location: index.php?id=". $sites[0]['site_id'] ); - exit(); - } else if ( $sites_count == 0) { - echo " No site matching $sitename on " . $peer_label . " "; - } else { - drupal_set_title ("Sites matching $sitename on " . $peer_label); - sort_sites ($sites); - echo paginate( $sites, "site_id", "Sites", 25, "name"); - } -} - - -// if no site id, display list of sites to choose -elseif( !$_GET['id'] ) { - - // GetSites API call - // careful, need to pass NULL and *not* array() if no filter is given - $sites= $api->GetSites( empty($filter) ? NULL : $filter, $site_columns ); - $sites = array_map(layout_site,$sites); - if ( empty ($sites)) { - echo "No site to display"; - } else { - sort_sites( $sites ); - - drupal_set_html_head(' - - '); - - echo "
"; - if( in_array( 10, $_roles ) ) { - echo plc_event_button("Site","site",$site_id); - echo " | \n"; - } - echo plc_comon_button("site_id",$site_id); - // comon link - echo " | "; - - // list to take site action - echo ""; - - echo " |
This site is not enabled - Please visit this page to review pending applications.
"; - } - - // basic site info - echo "Full name: | $sitename |
---|---|
Login base: | $login_base |
Abbreviated Name: | $abbrev_name |
URL: | $site_url |
Latitude: | $site_lat |
Longitude: | $site_long |
Managed at foreign peer: | " . $peer[0]['peername'] . " |
";
- if ( ! $person['enabled'] ) {
- printf(" %s (not enabled yet) \n",$person['person_id'],$person['email']); - } else { - printf("%s \n",$person['person_id'],$person['email']); - } - echo " |
";
- if ( ! $person['enabled'] ) {
- printf(" %s (not enabled yet) \n",$person['person_id'],$person['email']); - } else { - printf("%s \n",$person['person_id'],$person['email']); - } - echo " |
"; - - $comma= count( $address['address_types'] ); - $count= 0; - foreach( $address['address_types'] as $add_type ) { - echo $add_type; - $count++; - if ( $comma > 0 && $count != $comma ) - echo ", "; - } - - echo " |
". $address['line1'] ." | ". $address['line2'] ." | \n
". $address['line3'] ." |
". $address['city'] .", ". $address['state'] ." ". $address['postalcode'] ." |
". $address['country'] ." |
Add an address\n";*/
-
- }
-
- echo "
Back to site list"; - -} - - -// Print footer -include 'plc_footer.php'; +if ($_GET['id']) require ('site.php') ; +else require ('sites.php'); ?>