reformatted
[plewww.git] / planetlab / sites / register.php
index 56d2f7b..ef332bd 100644 (file)
@@ -1,9 +1,9 @@
 <?php
 //
-// Site registration and verification form. 
+// Site registration and verification form.
 //
-// Thierry Parmentelat -- INRIA 
-// based on persons/register.php 
+// Thierry Parmentelat -- INRIA
+// based on persons/register.php
 //
 
 // Get session and API handles
@@ -59,11 +59,11 @@ if (! $empty_form ) {
     // begin
     // AddSite(..)
     // AddSiteAddress('login_base',...)
-    // because if the first call fails because login_base is already taken, 
+    // because if the first call fails because login_base is already taken,
     // then you're going to add the new address to the wrong site
-    // 
+    //
     // the bottom line is, there's no advantage in using begin/commit at all
-    
+
     // creating the site
     $site['enabled']=FALSE;
     global $PENDING_CONSORTIUM_ID;
@@ -76,14 +76,14 @@ if (! $empty_form ) {
       $error .= $api_error;
     }
   }
-  
+
   if (empty($error)) {
 
     // Thierry on august 22 2007
     // use NotifySupport to send this message, and get rid of the fake account
 
     $subject = "Site registration form : new site " . $site['name'];
-    // should use GetMessages and stuff, but I do not trust the way 
+    // should use GetMessages and stuff, but I do not trust the way
     // templates are created in db-config, for upgrades notably
     $template = <<< EOF
 We received a site registration form for site name %s
@@ -92,7 +92,7 @@ To review, please visit https://%s:%d/db/sites/join_request.php?review=t&site_id
 EOF;
     $body=sprintf($template,$site['name'],PLC_WWW_HOST,PLC_WWW_SSL_PORT,$site_id);
     $adm->NotifySupport($subject,$body);
-      
+
     $messages [] = "Your registration request has been received.";
     $messages [] = "A mail was sent to the operations team, your application should be processed shortly.";
     $messages [] = "Upon approval, the PI will receive an information e-mail";
@@ -103,9 +103,9 @@ EOF;
       $adm->AddSiteAddress($site_id,$address);
       $api_error = $adm->error();
       if (empty($api_error)) {
-       $verboses [] = "Address created";
+             $verboses [] = "Address created";
       } else {
-       $error .= $api_error;
+             $error .= $api_error;
       }
     }
 
@@ -113,7 +113,8 @@ EOF;
     // Thierry 23 august 2007
     // avoid using a pre-existing federated account
     $known_pi = $adm->GetPersons(array("email"=>$pi['email'],
-                                      "peer_id"=>NULL),array("person_id"));
+                                                              "peer_id"=>NULL),
+                                 array("person_id"));
     if ($known_pi) {
       $messages [] = " Note: PI was already known";
       $pi_id=$known_pi[0]['person_id'];
@@ -122,9 +123,9 @@ EOF;
       $pi_id=$adm->AddPerson($pi);
       $api_error = $adm->error();
       if (empty($api_error)) {
-       $verboses [] = "PI created as disabled</p>";
+             $verboses [] = "PI created as disabled</p>";
       } else {
-       $error .= $api_error;
+             $error .= $api_error;
       }
     }
     if ($adm->AddPersonToSite($pi_id,$site_id)) {
@@ -133,46 +134,47 @@ EOF;
     if ($adm->AddRoleToPerson('pi',$pi_id)) {
       $verboses [] = $pi['email'] . " granted PI role</p>";
     }
-    
+
     if ($pi['email'] == $tech['email']) {
       // need to assign tech role so the registration request gets filled properly
       if ($adm->AddRoleToPerson('tech',$pi_id)) {
-       $verboses [] = $pi['email'] . " granted Tech role</p>";
+             $verboses [] = $pi['email'] . " granted Tech role</p>";
       }
     } else {
       // creating TECH
       $known_tech = $adm->GetPersons(array("email"=>$tech['email'],
-                                          "peer_id"=>NULL),array("person_id"));
+                                                                  "peer_id"=>NULL),
+                                     array("person_id"));
       // jan-2013 with improvements in plcapi-5.1-6 about managing persons and tags,
       // AddPerson has gone more picky and we need to remove some fields
       // that no longer are silently ignored by AddPerson
       $user_role_required=$tech['user-role'];
       unset($tech['user-role']);
       if ($known_tech) {
-       $messages [] = " Note: Tech was already known";
-       $tech_id=$known_tech[0]['person_id'];
+             $messages [] = " Note: Tech was already known";
+             $tech_id=$known_tech[0]['person_id'];
       } else {
-       $tech['enabled']=FALSE;
-       $tech_id=$adm->AddPerson($tech);
-       $api_error = $adm->error();
-       if (empty($api_error)) {
-         $verboses [] = "Tech created as disabled</p>";
-       } else {
-         $error .= $api_error;
-       }
+             $tech['enabled']=FALSE;
+        $tech_id=$adm->AddPerson($tech);
+        $api_error = $adm->error();
+        if (empty($api_error)) {
+          $verboses [] = "Tech created as disabled</p>";
+        } else {
+          $error .= $api_error;
+        }
       }
       if ($adm->AddPersonToSite($tech_id,$site_id)) {
-       $verboses [] = "Tech attached to new site";
+        $verboses [] = "Tech attached to new site";
       }
       if ($adm->AddRoleToPerson('tech',$tech_id)) {
-       $verboses [] = $tech['email'] . " granted Tech role";
+        $verboses [] = $tech['email'] . " granted Tech role";
       }
       if ( $user_role_required && $adm->AddRoleToPerson('user',$tech_id) ) {
-       $verboses [] = $tech['email'] . " granted User role";
+        $verboses [] = $tech['email'] . " granted User role";
       }
     }
   }
-    
+
 
   // Show messages
   if (!empty($messages)) {
@@ -182,7 +184,7 @@ EOF;
     }
     print "</ul></div>";
   }
-       
+
   if ($verbose && !empty($verboses)) {
     print '<div class="messages status"><ul>';
     print "<p> Verbose messages</p>";
@@ -191,7 +193,7 @@ EOF;
     }
     print "</ul></div>";
   }
-       
+
   if (!empty($error)) {
     print '<div class="messages error">' . $error . '</div>';
   } else {