return multiple site list for 'my site' link.
[plewww.git] / planetlab / includes / plc_functions.php
index 34f9f3e..4e8928c 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']);
@@ -28,6 +32,32 @@ function plc_in_site ($site_id) {
   return in_array( $site_id, $plc->person['site_ids']);
 }
 
+function plc_my_site_ids () {
+  global $plc;
+  return $plc->person['site_ids'];
+}
+function plc_my_site_names () {
+  global $plc;
+  global $api;
+  $ret = $api->GetSites($plc->person['site_ids'], array('site_id', 'abbreviated_name'));
+  return $ret;
+}
+
+function plc_my_site_links()
+{
+  $site_item = '';
+  if ( sizeof(plc_my_site_ids()) > 1 )
+  {
+    foreach (plc_my_site_names() as $site) 
+    {
+       $site_item .= leaf( href(l_site($site['site_id']),$site['abbreviated_name']));
+    }
+  } else {
+      $site_item .= leaf( href(l_site(plc_my_site_id()),"My Site"));
+  }
+  return $site_item;
+}
+
 function plc_my_site_id () {
   global $plc;
   return $plc->person['site_ids'][0];
@@ -50,6 +80,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"; }
@@ -61,6 +93,7 @@ function l_nodes_site ($site_id)      { return "/db/nodes/index.php?site_id=$site_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"; }
+function l_interface_tags($interface_id){ return "/db/nodes/interface.php?id=$interface_id&show_details=0&show_tags=1"; }
 function l_interface_t ($interface_id,$text) { 
                                          return href (l_interface($interface_id),$text); }
 function l_interface_add($node_id)     { return "/db/nodes/interface.php?node_id=$node_id"; }
@@ -129,7 +162,7 @@ function l_sites_pending()          { return "/db/sites/join_request.php"; }
 function tab_nodes ()          { return array ('label'=>'All nodes','url'=>l_nodes(), 
                                                'bubble'=>'Display nodes from all peers'); }
 function tab_nodes_local ()    { return array ('label'=>'Local nodes', 'url'=>l_nodes_peer('local'), 
-                                               'bubble'=>'Display local nodes only'); }
+                                               'bubble'=>'Display all nodes local to this peer'); }
 function tab_nodes_site($site_id){ return array ('label'=>'Site nodes', 'url'=>l_nodes_site($site_id), 
                                                 'bubble'=>'Display nodes on that site'); }
 function tab_nodes_slice($slice_id){ return array ('label'=>'Slice nodes', 'url'=>l_nodes_slice($slice_id), 
@@ -145,7 +178,7 @@ function tab_mysite()               { return array ('label'=>'My site', 'url'=>l_site(plc_my_
                                                'bubble'=>'Details for site ' . plc_my_site_id()); }
 function tab_sites ()          { return array ('label'=>'All sites' , 'url'=>l_sites(), 'bubble'=> 'Display all sites'); }
 function tab_sites_local ()    { return array ('label'=>'Local sites' , 'url'=>l_sites_peer('local'), 
-                                               'bubble'=> 'Display local sites'); }
+                                               'bubble'=> 'Display all siteslocal to this peer'); }
 //////////
 function tab_slices()          { return array ('label'=>'All slices', 'url'=>l_slices(),
                                                'bubble' => 'Display all slices'); }
@@ -154,14 +187,14 @@ function tab_slices_mysite ()     { return array ('label'=>'My site slices', 'url'=>
 function tab_slices_mine ()    { return array ('label'=>'My site slices', 'url'=>l_slices_site(plc_my_site_id()), 
                                                'bubble'=>'Display all slices on my site'); }
 function tab_slices_local ()   { return array ('label'=>'Local slices', 'url'=>l_slices_local(), 
-                                               'bubble'=>'Display all slices on my site'); }
+                                               'bubble'=>'Display all slices local to this peer'); }
 function tab_slice($slice)     { return array ('label'=>'Slice '.$slice['name'], 'url'=>l_slice($slice['slice_id']),
                                                'bubble' => 'Details for ' . $slice['name']); }
 //////////
 function tab_persons()         { return array ('label'=>'All accounts', 'url'=>l_persons(),
                                                'bubble'=>'Display users from all peers'); }
 function tab_persons_local()   { return array ('label'=>'Local accounts', 'url'=>l_persons_peer('local'),
-                                               'bubble'=>'Display local users'); }
+                                               'bubble'=>'Display all users local to this peer'); }
 function tab_persons_mysite()  { return array ('label'=>'My accounts' , 'url'=>l_persons_site(plc_my_site_id()),
                                                'bubble'=>'Display accounts on site ' . plc_my_site_id()); }
 function tab_person($person)   { return array ('label'=>'Account '.$person['email'], 'url'=>l_person($person['person_id']),
@@ -316,10 +349,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) {
@@ -370,6 +403,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>";
 }