user in several sites gets 'All My Sites Nodes' instead of 'My Site Nodes'
[plewww.git] / planetlab / includes / plc_functions.php
index a54dd65..aa6cbd5 100644 (file)
@@ -19,6 +19,10 @@ function plc_is_pi () {
   global $plc;
   return in_array( 20, $plc->person['role_ids']);
 }
+function plc_is_user () {
+  global $plc;
+  return in_array( 30, $plc->person['role_ids']);
+}
 function plc_is_tech () {
   global $plc;
   return in_array( 40, $plc->person['role_ids']);
@@ -32,12 +36,20 @@ function plc_my_site_ids () {
   global $plc;
   return $plc->person['site_ids'];
 }
+function plc_my_sites () {
+  global $plc;
+  global $api;
+  return $api->GetSites($plc->person['site_ids'], array('site_id', 'abbreviated_name'));
+}
 
 function plc_my_site_id () {
   global $plc;
   return $plc->person['site_ids'][0];
 }
 
+function plc_my_person () {
+  return $plc->person;
+}
 function plc_my_person_id () {
   global $plc;
   return $plc->person['person_id'];
@@ -55,6 +67,8 @@ function href ($url,$text) { return "<a href='" . $url . "'>" . $text . "</a>";
 function l_actions ()                  { return "/db/common/actions.php"; }
 // some complex node actions are kept separate, e.g. the ones related to getbootmedium
 function l_actions_download ()         { return "/db/nodes/node_downloads.php"; }
+function l_register_node ()            { return "/registerwizard/index.php"; }
+function l_pcu_add ()                  { return "/registerwizard/index.php/register/stage1_addpcu"; }
 
 function l_nodes ()                    { return "/db/nodes/index.php"; }
 function l_nodes_peer ($peer_id)       { return "/db/nodes/index.php?peerscope=$peer_id"; }
@@ -63,6 +77,7 @@ function l_node_t ($node_id,$text)    { return href (l_node($node_id),$text); }
 function l_node_obj($node)             { return href(l_node($node['node_id']),$node['hostname']); }
 function l_node_add ()                 { return "/db/nodes/node_add.php"; }
 function l_nodes_site ($site_id)       { return "/db/nodes/index.php?site_id=$site_id"; }
+function l_nodes_person ($person_id)   { return "/db/nodes/index.php?person_id=$person_id"; }
 function l_nodes_slice ($slice_id)     { return "/db/nodes/index.php?slice_id=$slice_id"; }
 
 function l_interface ($interface_id)   { return "/db/nodes/interface.php?id=$interface_id"; }
@@ -322,10 +337,10 @@ function plc_itemize ($messages, $class="") {
   return $formatted;
 }
 
-function plc_error ($text) {
-  // should use the same channel as the php errors..
-  print "<div class='plc-error'> Error " . $text . "</div>";
-}
+//////////
+// should use the same channel as the php errors..
+function plc_error_html ($text)                { return  "<div class='plc-error'> " . $text . "</div>"; }
+function plc_error ($text)             { print plc_error_html ("Error " . $text); }
 
 function plc_errors ($errors) {
   if ($errors) {
@@ -340,7 +355,8 @@ function plc_errors ($errors) {
 
 function plc_warning_html ($text)      { return "<span class='plc-warning'>" . $text . "</span>";}
 function plc_warning ($text)           { print plc_warning_html("Warning " . $text); }
-function plc_foreign_html($text)       { return "<span class=plc-foreign>$text</span>"; }
+
+function bold_html ($text)             { return "<span class='bold'>$text</span>"; }
 
 // shows a php variable verbatim with a heading message
 function plc_debug ($message,$object) {
@@ -376,6 +392,10 @@ function plc_delete_icon($width=15) {
   return "<img width='$width' src='/planetlab/icons/delete.png'>";
 }
 
+function plc_add_icon($width=15) {
+  return "<img width='$width' src='/planetlab/icons/add.png'>";
+}
+
 function plc_bubble($text,$bubble) {
   return "<span title='$bubble'>$text</span>";
 }