(*) slices list has links towards the slice page with the details area closed and...
[plewww.git] / planetlab / includes / plc_functions.php
index facf215..53600ae 100644 (file)
@@ -5,6 +5,13 @@
 // will trash this eventually
   //require_once 'plc_functions_trash.php';
 
+# note: this needs to be consistent with the value in Monitor/monitor/wrapper/plc.py
+global $PENDING_CONSORTIUM_ID;
+$PENDING_CONSORTIUM_ID = 0;
+# this one does not matter that much, just picking one
+global $APPROVED_CONSORTIUM_ID;
+$APPROVED_CONSORTIUM_ID = 999999;
+
 // utility
 function my_is_int ($x) {
     return (is_numeric($x) ? intval($x) == $x : false);
@@ -98,6 +105,7 @@ function l_site_obj($site)           { return href (l_site($site['site_id']),$site['name'
 function l_slices ()                   { return "/db/slices/index.php"; }
 function l_slices_peer ($peer_id)      { return "/db/slices/index.php?peerscope=$peer_id"; }
 function l_slice ($slice_id)           { return "/db/slices/index.php?id=$slice_id"; }
+function l_slice_nodes ($slice_id)     { return "/db/slices/index.php?id=$slice_id&show_details=0&show_nodes=1&show_nodes_current=1&show_nodes_add=1"; }
 function l_slice_t ($slice_id,$text)   { return href (l_slice($slice_id),$text); }
 function l_slice_add ()                        { return "/db/slices/slice_add.php"; }
 function l_slices_site($site_id)       { return "/db/slices/index.php?site_id=$site_id"; }
@@ -127,6 +135,8 @@ function l_nodegroups ()            { return "/db/tags/nodegroups.php"; }
 function l_nodegroup ($nodegroup_id)   { return "/db/tags/nodegroup.php?id=$nodegroup_id"; }
 function l_nodegroup_t ($nodegroup_id,$text) { 
                                          return href(l_nodegroup($nodegroup_id),$text); }
+function l_nodegroup_obj ($nodegroup) { 
+                                         return href(l_nodegroup($nodegroup['nodegroup_id']),$nodegroup['groupname']); }
 
 function l_events ()                   { return "/db/events/index.php"; }
 function l_event ($type,$param,$id)    { return "/db/events/index.php?type=$type&$param=$id"; }
@@ -149,6 +159,7 @@ function l_reset_password()         { return "/db/persons/reset_password.php"; }
 function l_person_register()           { return "/db/persons/register.php"; }
 function l_site_register()             { return "/db/sites/register.php"; }
 function l_sites_pending()             { return "/db/sites/join_request.php"; }
+function l_site_review_pending($site_id){ return "/db/sites/join_request.php?review=t&site_id=$site_id"; }
 
 
 //////////////////////////////////////////////////////////// nav tabs
@@ -345,11 +356,37 @@ function plc_itemize ($messages, $class="") {
 }
 
 //////////
+function truncate ($text,$numb,$etc = "...") {
+  if (strlen($text) > $numb) {
+    $text = substr($text, 0, $numb);
+    $text = $text.$etc;
+  }
+  return $text;
+}
+// generates <(atom) class=(class)> (text) </(atom)>
+function html_atom ($atom,$text,$class="") {
+  $html="<$atom";
+  if ($class) $html .= " class='$class'";
+  $html .= ">$text</$atom>";
+  return $html;
+}
+function html_div ($text,$class="") { return html_atom ('div',$text,$class); }
+function html_span ($text,$class="") { return html_atom ('span',$text,$class); }
+
 // should use the same channel as the php errors..
-function plc_error_html ($text)                { return  "<div class='plc-error'> " . $text . "</div>"; }
+function plc_error_html ($text)                { return  html_div ($text,'plc-error'); }
 function plc_error ($text)             { print plc_error_html ("Error " . $text); }
 
-function plc_errors ($errors) {
+function errors_init() { return array();}
+function errors_record ($adm, $errors) {
+  if ($adm->error()) {
+    $tmp=$adm->error();
+    $errors []= $tmp;
+  }
+  return $errors;
+}
+
+function errors_display ($errors) {
   if ($errors) {
     print( "<div class='plc-error'>" );
     print( "<p>The following errors occured:</p>" );
@@ -360,10 +397,10 @@ function plc_errors ($errors) {
   }
 }
 
-function plc_warning_html ($text)      { return "<span class='plc-warning'>" . $text . "</span>";}
+function plc_warning_html ($text)      { return html_span($text,'plc-warning'); }
 function plc_warning ($text)           { print plc_warning_html("Warning " . $text); }
 
-function bold_html ($text)             { return "<span class='bold'>$text</span>"; }
+function bold_html ($text)             { return html_span($text,'bold'); }
 
 // shows a php variable verbatim with a heading message
 function plc_debug ($message,$object) {
@@ -372,20 +409,6 @@ function plc_debug ($message,$object) {
   print "</pre>";
 }
 
-function truncate ($text,$numb,$etc = "...") {
-  if (strlen($text) > $numb) {
-    $text = substr($text, 0, $numb);
-    $text = $text.$etc;
-  }
-  return $text;
-}
-function html_div ($text,$class="") {
-  $html="<div";
-  if ($class) $html .= " class='$class'";
-  $html .= ">$text</div>";
-  return $html;
-}
-
 if (! function_exists ("drupal_set_error")) {
   function drupal_set_error ($text) {
     drupal_set_message ("<span class=error>$text</span>");