use ext_consortium_id for pending sites
[plewww.git] / planetlab / sites / join_request.php
index ce602b4..0540bf1 100644 (file)
@@ -11,18 +11,20 @@ require_once 'plc_login.php';
 require_once 'plc_session.php';
 global $plc, $api;
 
-// Common functions
-require_once 'plc_functions.php';
-
 // Print header
 require_once 'plc_drupal.php';
 include 'plc_header.php';
 
+// Common functions
+require_once 'plc_functions.php';
+require_once 'details.php';
+require_once 'nifty.php';
+
 include 'site_form.php';
 
 ////////////////////////////////////////
 function render_all_join_requests($api) {
-  $sites = $api->GetSites( array("enabled" => False, "peer_id" => NULL));
+  $sites = $api->GetSites( array("enabled" => False, "peer_id" => NULL, "ext_consortium_id" => $PENDING_CONSORTIUM_ID));
   if (!empty($sites)) {
     print("<table width=100%>");
     print("<tr><th>Site Name</th><th>site_id</th><th>Submitted</th></tr>");
@@ -44,7 +46,7 @@ function render_join_request_review($api, $site_id) {
       return;
   }
   $site = $sites[0];
-  if ($site['enabled']) {
+  if ($site['enabled'] && $site['ext_consortium_id'] == $PENDING_CONSORTIUM_ID) {
     print("<p class='plc-warning'> This site is already enabled </p>");
     return;
   }
@@ -60,7 +62,7 @@ function render_join_request_review($api, $site_id) {
     $persons=array();
   } else {
     $person_ids = $site['person_ids'];
-    $persons = $api->GetPersons( $person_ids, array( "person_id", "role_ids", "first_name", "last_name", "email" , "phone") );
+    $persons = $api->GetPersons( $person_ids, array( "person_id", "role_ids", "first_name", "last_name", "title", "email" , "phone") );
   }
   $tech = Null;
   $pi = Null;
@@ -74,7 +76,7 @@ function render_join_request_review($api, $site_id) {
   }
   $pi_id = $pi['person_id'];
   $tech_id = $tech['person_id'];
-    
+
   print <<< EOF
 <p> Please review the join request below.</p>
     <p> <b> Warning:</b> the PI email address that was provided in this form will <b> not be checked</b> automatically. We expect that as part of the handshake with the site, the support team has had an opportunity to use this address so it can be considered safe. Please check it manually if this is not the case.</p>
@@ -83,41 +85,36 @@ function render_join_request_review($api, $site_id) {
 <input type="hidden" name="address_id" value="$address_id">
 <input type="hidden" name="tech_id" value="$tech_id">
 <input type="hidden" name="site_id" value="$site_id">
-
-<table border="0" width="100%" cellspacing="0" cellpadding="3">
 EOF;
 
   $site_form = build_site_form(FALSE);
   $input = array ('site' => $site, 'address'=> $address, 'pi' => $pi, 'tech' => $tech);
   
+  $nifty=new PlekitNifty ('pending','site-pending','medium');
+
+  $nifty->start();
+  $details = new PlekitDetails(TRUE);
+  $details->start();
+
   // display the buttons 
-  print <<< EOF
-    <tr>
-    <td colspan='2'>
+  $buttons_row =<<<EOF
     <table width="100%" border=0 cellspacing="0" cellpadding="5"> <tr> 
     <td align=center><input type="submit" name="submitted" value="Delete"></td>
     <td align=center><input type="submit" name="submitted" value="Update"></td>
     <td align=center><input type="submit" name="submitted" value="Approve"></td>
     </tr> </table>
-    </tr>
 EOF;
 
+  $details->tr($buttons_row,'center');
   // render the form - not supposed to be empty
-  form_render_table2 ($site_form, $input, TRUE);
+  form_render_details ($details,$site_form, $input, TRUE);
 
-  // display the buttons 
-  print <<< EOF
-    <tr>
-    <td colspan='2'>
-    <table width="100%" border=0 cellspacing="0" cellpadding="5"> <tr> 
-    <td align=center><input type="submit" name="submitted" value="Delete"></td>
-    <td align=center><input type="submit" name="submitted" value="Update"></td>
-    <td align=center><input type="submit" name="submitted" value="Approve"></td>
-    </tr> </table>
-    </tr>
-EOF;
+  // display the buttons again
+  $details->tr($buttons_row,'center');
+
+  $details->end();
+  $nifty->end();
 
-  print "</table></form>";
 }
 
 function notify_enabled_pi ($api, $pi_id, $pi, $site_id, $site) {
@@ -237,6 +234,7 @@ else if ($_POST['submitted'] )
       // the PI's email address, which makes the whole thing *a lot* simpler
       // enable the site, enable the PI, and VerifyPerson the thec if different from the PI
       $site['enabled'] = True;
+      $site['ext_consortium_id'] = $APPROVED_CONSORTIUM_ID;
       $api->UpdateSite ($site_id,$site);
       $api_error=$api->error();
       if (!empty($api_error)) {