reviewed plcdetails
[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 require_once 'plc_sorts.php';
14
15 // find person roles
16 $_person= $plc->person;
17 $_roles= $_person['role_ids'];
18
19
20 // if no site id redirect
21 if( !$_GET['id'] ) 
22   plc_redirect(l_sites());
23
24 // get site_id
25 $site_id= $_GET['id'];
26
27 // if submitted
28 if( $_POST['submitted'] ) {
29   $new_site= $_POST['new_site'];
30   
31   // no primary site anymore..........
32
33 }
34
35
36 // Print header
37 require_once 'plc_drupal.php';
38 drupal_set_title('Sites');
39 include 'plc_header.php';
40
41
42 // if admin list all sites, else list just persons sites
43 if( in_array( '10', $_roles ) ) 
44   $site_info= $api->GetSites( NULL, array( "site_id", "name" ) );
45 else 
46   $site_info= $api->GetSites( $_person['site_ids'], array( "site_id", "name" ) );
47
48
49 sort_sites( $site_info );
50
51 // start form
52 echo "<from method=post action='switch_site.php?id=$site_id'>\n";
53 echo "<h2>Switch Site</h2>\n";
54 echo "Change active site to: \n";
55 echo "<p><select name='new_site'>\n";
56
57 // out puts site names and ids
58 foreach( $site_info as $site ) {
59   echo "<option value='". $site['site_id'] ."'>". $site['name'] ."</option>\n";
60
61 }
62
63 echo "</select>\n";
64 echo "<p>This will change your Primary Site.\n";
65 echo "<p><input type=submit name='submitted' value='Switch Site'>\n";
66
67 echo "<p><a href='index.php?id=$site_id'>Back to Site</a>\n";
68
69 echo "</form>\n";
70
71
72
73 // Print footer
74 include 'plc_footer.php';
75
76 ?>