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