fix typo in sites list, N is the number of nodes not of sites
[plewww.git] / planetlab / sites / switch_site.php
1 <?php
2
3 // Require login
4 require_once 'plc_login.php';
5
6 // Get session and API handles
7 require_once 'plc_session.php';
8 global $plc, $api;
9
10
11 // Common functions
12 require_once 'plc_functions.php';
13
14 // find person roles
15 $_person= $plc->person;
16 $_roles= $_person['role_ids'];
17
18
19 // if no site id redirect
20 if( !$_GET['id'] ) 
21   plc_redirect(l_sites());
22
23 // get site_id
24 $site_id= $_GET['id'];
25
26 // if submitted
27 if( $_POST['submitted'] ) {
28   $new_site= $_POST['new_site'];
29   
30   // no primary site anymore..........
31
32 }
33
34
35 // Print header
36 require_once 'plc_drupal.php';
37 drupal_set_title('Sites');
38 include 'plc_header.php';
39
40
41 // if admin list all sites, else list just persons sites
42 if( in_array( '10', $_roles ) ) 
43   $site_info= $api->GetSites( NULL, array( "site_id", "name" ) );
44 else 
45   $site_info= $api->GetSites( $_person['site_ids'], array( "site_id", "name" ) );
46
47
48 // start form
49 echo "<from method=post action='switch_site.php?id=$site_id'>\n";
50 echo "<h2>Switch Site</h2>\n";
51 echo "Change active site to: \n";
52 echo "<p><select name='new_site'>\n";
53
54 // out puts site names and ids
55 foreach( $site_info as $site ) {
56   echo "<option value='". $site['site_id'] ."'>". $site['name'] ."</option>\n";
57
58 }
59
60 echo "</select>\n";
61 echo "<p>This will change your Primary Site.\n";
62 echo "<p><input type=submit name='submitted' value='Switch Site'>\n";
63
64 echo "<p><a href='index.php?id=$site_id'>Back to Site</a>\n";
65
66 echo "</form>\n";
67
68
69
70 // Print footer
71 include 'plc_footer.php';
72
73 ?>