X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=modules%2Fplanetlab.module;h=06aa2592a3980532eed75d05545b6dd50058b9be;hb=31f2c290aac50eac519f4d2c428b6f76c5cb67c9;hp=378d1f9341460ef1fe147aff53b26a796a5c5c90;hpb=3aca091c5ef5315b2f8ab1b11b65ddf8f42cc370;p=plewww.git diff --git a/modules/planetlab.module b/modules/planetlab.module index 378d1f9..06aa259 100644 --- a/modules/planetlab.module +++ b/modules/planetlab.module @@ -54,12 +54,36 @@ function planetlab_menu($may_cache) { return $items; } -// formatting helpers +//////////////////// formatting helpers - specific to module presentation function ul_start () { return ''; } function leaf($text) { return '
  • ' . $text . '
  • '; } function expanded($text) { return '
  • ' . $text . '
  • '; } function p($text) { return '

    ' . $text . '

    '; } + +# this should get embedded into a ul_start()/ul_end() pair +function plc_my_site_links() { + $html = ''; + $sites = plc_my_sites(); + if (count($sites)>1) foreach ($sites as $site) { + $html .= leaf( href(l_site($site['site_id']),$site['abbreviated_name'])); + } else { + $html .= leaf( href(l_site(plc_my_site_id()),"My Site")); + } + return $html; +} + +// ditto +function plc_my_node_links () { + $html = ''; + if (count (plc_my_site_ids()) == 1) { + $html .= leaf( href (l_nodes_my_site() ,"My Site Nodes")); + } else { + $html .= leaf( href (l_nodes_all_my_site(),"All My Sites Nodes")); + } + return $html; +} + // fake theme to look like menu function menu_theme ($menu) { $result = ''; @@ -80,7 +104,10 @@ function planetlab_block($op = 'list', $delta = 0, $edit = array()) { } else if ($op == 'view') { $block = array(); - if (!$plc->person) { + if ($plc->hide_planetlab_block) { + // do nothing + // this is a private hook from the Vicci module to hide the planetlab module + } else if (!$plc->person) { // Force login via HTTPS unset($_GET['time']); $form['#action'] = "https://" . $_SERVER['HTTP_HOST'] . url($_GET['q'], drupal_get_destination()); @@ -134,10 +161,10 @@ function planetlab_block($op = 'list', $delta = 0, $edit = array()) { $bullet_item .= l_person_t(plc_my_person_id(),"My Account"); $bullet_item .= ul_start(); if (plc_is_admin() || plc_is_pi()) - $bullet_item .= leaf( href( l_persons_site(plc_my_site_id()), "My Users")); + $bullet_item .= leaf( href( l_persons_site(plc_my_site_id()), "My Site Accounts")); if (plc_is_admin()) { - $bullet_item .= leaf(href(l_persons_peer('local'),'Local users (looong)')); - $bullet_item .= leaf(href(l_persons(),'All users (looong)')); + $bullet_item .= leaf(href(l_persons_peer('local'),'Local Accounts (slow)')); + $bullet_item .= leaf(href(l_persons(),'All Accounts (slow)')); } $bullet_item .= ul_end(); @@ -147,7 +174,7 @@ function planetlab_block($op = 'list', $delta = 0, $edit = array()) { $bullet_item = ''; $bullet_item .= href(l_sites(),"Sites"); $bullet_item .= ul_start(); - $bullet_item .= leaf( href(l_site(plc_my_site_id()),"My Site")); + $bullet_item .= plc_my_site_links(); if ( plc_is_admin() ) $bullet_item .= leaf( href(l_sites_pending(),"Pending Requests")); $bullet_item .= ul_end(); @@ -157,19 +184,23 @@ function planetlab_block($op = 'list', $delta = 0, $edit = array()) { $bullet_item = ''; $bullet_item .= href(l_nodes(),"Nodes"); $bullet_item .= ul_start(); - $bullet_item .= leaf( href (l_nodes_site (plc_my_site_id()),"My Site Nodes")); - $bullet_item .= leaf( href (l_node_add(),"Add Node")); - $bullet_item .= leaf( href (l_register_node(),"Register Node")); + $bullet_item .= plc_my_node_links(); + if (plc_is_admin() || plc_is_pi() || plc_is_tech()) + $bullet_item .= leaf( href (l_register_node(),"Register Node")); $bullet_item .= ul_end(); $items [] = expanded($bullet_item); //////////////////// Slices $bullet_item = ''; //if( !( plc_is_tech() && ! plc_is_user() && ! plc_is_pi() && ! plc_is_admin() ) ) - $bullet_item .= href(l_slices(),"Slices"); + if (plc_is_admin()) { + $bullet_item .= href(l_slices(),"Slices"); + } else { + $bullet_item .= href(l_slices(),"My Slices"); + } $bullet_item .= ul_start(); if (plc_is_admin()) - $bullet_item .= leaf ( href(l_slices_site(plc_my_site_id()), 'My Site Slices')); + $bullet_item .= leaf ( href(l_slices_my_site(), 'My Site Slices')); if( plc_is_admin() || plc_is_pi() ) { $bullet_item .= leaf(href(l_slice_add(),"Create Slice")); } @@ -183,7 +214,8 @@ function planetlab_block($op = 'list', $delta = 0, $edit = array()) { $bullet_item = ''; $bullet_item .= href(l_admin(),"Admin search"); $bullet_item .= ul_start(); - $bullet_item .= leaf( href (l_node_add(),"Add Node")); + if ( plc_is_admin() ) + $bullet_item .= leaf( href (l_node_add(),"Add Node")); $bullet_item .= leaf( href( l_tags(),"Tags")); $bullet_item .= leaf( href( l_nodegroups(),"Node groups")); $bullet_item .= leaf (href(l_peers(),'Peers'));