cleanup for plc_sorts.php removal.
[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 sort_sites( $site_info );
49
50 // start form
51 echo "<from method=post action='switch_site.php?id=$site_id'>\n";
52 echo "<h2>Switch Site</h2>\n";
53 echo "Change active site to: \n";
54 echo "<p><select name='new_site'>\n";
55
56 // out puts site names and ids
57 foreach( $site_info as $site ) {
58   echo "<option value='". $site['site_id'] ."'>". $site['name'] ."</option>\n";
59
60 }
61
62 echo "</select>\n";
63 echo "<p>This will change your Primary Site.\n";
64 echo "<p><input type=submit name='submitted' value='Switch Site'>\n";
65
66 echo "<p><a href='index.php?id=$site_id'>Back to Site</a>\n";
67
68 echo "</form>\n";
69
70
71
72 // Print footer
73 include 'plc_footer.php';
74
75 ?>