redirects
[plewww.git] / planetlab / slices / update_slice.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 // Common functions
11 require_once 'plc_functions.php';
12 require_once 'plc_sorts.php';
13   
14 // find person roles
15 $_person= $plc->person;
16 $_roles= $_person['role_ids'];
17
18
19 if( !empty( $_GET['id'] ) ) {
20   $slice_id= $_GET['id'];
21   // Fetch slice information
22   $slices= $api->GetSlices( array( intval( $slice_id ) ) );
23   if( !empty( $slices ) ) {
24     $slice= $slices[0];
25   }
26 }
27
28 // Invalid slice name
29 if( !isset( $slice ) ) {
30   plc_redirect( l_slices());
31 }
32
33 // Defaults
34 $url_error = "";
35 $description_error = "";
36
37 if( isset( $_POST['submitted'] ) ) {
38   if( !empty($_POST['url'] ) )
39     $slice['url']= $_POST['url'];
40   else
41     $url_error= "Provide a link to a project website.";
42
43   if( !empty($_POST['desc'] ) )
44     $slice['description'] = $_POST['desc'];
45   else
46     $description_error= "Provide a short description of the slice.";
47
48   if( empty( $url_error ) && empty( $description_error ) ) {
49     // Update the slice URL and description
50     $fields= array( "description"=>$slice['description'], "url"=>$slice['url'] );
51     $api->UpdateSlice( intval( $slice_id ), $fields );
52     plc_redirect(l_slice($slice_id));
53   }
54 }
55
56 // Print header
57 require_once 'plc_drupal.php';
58 drupal_set_title('Slices');
59 include 'plc_header.php';
60
61 $slice_name= $slice['name'];
62
63 print "<h2>Update Slice ". $slice['name'] ."</h2>";
64
65 //echo "<pre>"; print_r( $slice ); echo "</pre>";
66 $url =  $slice['url'] ;
67 $description =  $slice['description'] ;
68
69 echo <<<EOF
70
71 <p>You must provide a short description as well as a
72 link to a project website. Do <b>not</b> provide
73 bogus information; if a complaint is lodged against your slice and
74 PlanetLab Operations is unable to determine what the normal behavior
75 of your slice is, your slice may be deleted to resolve the
76 complaint.</p>
77
78 <form method="post" action="update_slice.php?id=$slice_id">
79
80 <table>
81   <tbody>
82     <tr>
83       <th>Name:</th>
84       <td>$slice_name</td>
85       <td></td>
86     </tr>
87     <tr>
88       <th>URL:</th>
89       <td><input size="50" name="url" value="$url" /></td>
90       <td><font color="red"><strong>$url_error</strong></font></td>
91     </tr>
92     <tr>
93       <th>Description:</th>
94       <td><textarea name="desc" rows="5" cols="40">$description</textarea></td>
95       <td><font color="red"><strong>$description_error</strong></font></td>
96     </tr>
97   </tbody>
98 </table>
99
100 <input type="submit" name="submitted" value="Update" />
101
102 </form>
103
104 EOF;
105
106 // Print footer
107 include 'plc_footer.php';
108
109 ?>