update
[plewww.git] / modules / planetlab.module
index e24e933..4df1b15 100644 (file)
@@ -34,7 +34,7 @@ function planetlab_menu($may_cache) {
 
   if ($may_cache) {
     $items[] = array(
-                    'path' => 'planetlab/logout',
+                    'path' => 'planetlab/common/logout',
                     'title' => t('Log out of %s', array('%s' => variable_get('site_name', 'local'))),
                     'callback' => 'planetlab_logout',
                     'access' => TRUE,
@@ -53,10 +53,10 @@ function planetlab_menu($may_cache) {
 }
 
 // formatting helpers
-function ul_start () { return '<ul class=menu>'; }
+function ul_start () { return '<ul class="menu">'; }
 function ul_end () { return '</ul>'; }
-function leaf($text) { return '<li class=leaf>' . $text . '</li>'; }
-function expanded($text) { return '<li class=expanded>' . $text . '</li>'; }
+function leaf($text) { return '<li class="leaf">' . $text . '</li>'; }
+function expanded($text) { return '<li class="expanded">' . $text . '</li>'; }
 function p($text) { return '<p>' . $text . '</p>'; }
 // fake theme to look like menu
 function menu_theme ($menu) {
@@ -105,19 +105,30 @@ function planetlab_block($op = 'list', $delta = 0, $edit = array()) {
       $block['content'] .= p( href(l_person_register(),"Create an account") );
       $block['content'] .= p( href(l_site_register(),"File a site registration") );
     } else {
-      $block['subject'] = $plc->person['email'];
+      $block['subject'] = truncate($plc->person['email'],30);
       $is_admin = in_array(10,$plc->person['role_ids']);
       $is_pi    = in_array(20,$plc->person['role_ids']);
       $is_user  = in_array(30,$plc->person['role_ids']);
       $is_tech  = in_array(40,$plc->person['role_ids']);
 
+      //////////////////// Log out
+      if ($user->uid) {
+       // Drupal logout (destroys the session and cleans up $user)
+       // Thierry unclear when this triggers, I suspect this is obsolete
+       $items[] = leaf (l(t('Log out of %s', 
+                            array('%s' => variable_get('site_name', 'local'))), 'logout'));
+      } else {
+       // PlanetLab logout (just destroy the session)
+       $items[] = leaf ( href (l_logout(),'Log out'));
+      }
+      
       //////////////////// Sites
       $site_item = '';
       $site_item .= href(l_sites(),"Sites");
       $site_item .= ul_start();
       $site_item .= leaf( href(l_site(plc_my_site_id()),"My site"));
       if ( $is_admin ) 
-       $site_item .= leaf( href(l_site_pending(),"Pending Requests"));
+       $site_item .= leaf( href(l_sites_pending(),"Pending Requests"));
       $site_item .= ul_end();
       $items[] = expanded($site_item);
 
@@ -129,7 +140,7 @@ function planetlab_block($op = 'list', $delta = 0, $edit = array()) {
       if (is_pi) 
        $user_item .= leaf( href( l_persons_site(plc_my_site_id()), "My users"));
       if ( $plc->alt_person && $plc->alt_auth) {
-       $email = $plc->person['email']
+       $email = truncate($plc->person['email'],20)
        $user_item .= leaf( href( l_sulogout(),"Log out of $email"));
       }        
       $user_item .= ul_end();
@@ -163,13 +174,10 @@ function planetlab_block($op = 'list', $delta = 0, $edit = array()) {
        $admin_item .= href(l_admin(),"Admin");
        $admin_item .= ul_start();
        $admin_item .= leaf( href( l_tags(),"Tags"));
-       $admin_item .= leaf( href( l_nodegroups(),"Node groups (xxx)"));
-       // xxx need to cleanup
-       //$admin_item .= leaf( href( l_tags_slice(),"Slice Tags"));
-       //$admin_item .= leaf( href( l_tags_interface(),"Interface Tags"));
-       //$admin_item .= leaf( href (l_tags_interface(),"Setting Types (dup xxx)"));
-       //$admin_item .= leaf( href( l_tags_node(),"Node Tags"));
+       $admin_item .= leaf( href( l_nodegroups(),"Node groups"));
        $admin_item .= leaf (href(l_peers(),'Peers'));
+       if ( $is_admin )
+         $admin_item .= leaf (href(l_events(),'Events'));
        $admin_item .= ul_end();
        $items [] = expanded($admin_item);
       }
@@ -179,24 +187,11 @@ function planetlab_block($op = 'list', $delta = 0, $edit = array()) {
       $doc_item .= ul_start();
       $doc_item .= leaf ( href (l_doc_plcapi(),"PLCAPI doc"));
       $doc_item .= leaf ( href (l_doc_nmapi(),"NMAPI doc"));
-      if ( $is_admin )
-       $doc_item .= leaf (href(l_events(),'Events'));
       $doc_item .= ul_end();
       $items[] = expanded($doc_item);
 
-      if ($user->uid) {
-       // Drupal logout (destroys the session and cleans up $user)
-       // Thierry unclear when this triggers, I suspect this is obsolete
-       $items[] = leaf (l(t('Log out of %s', 
-                            array('%s' => variable_get('site_name', 'local'))), 'logout'));
-      } else {
-       // PlanetLab logout (just destroy the session)
-       $items[] = leaf ( href (l_logout(),'Log out'));
-      }
-      
       //$block['content'] = theme('list_item', $items);
       $block['content'] = menu_theme($items);
-      //      plc_debug("content",$block['content']);
     }
 
     /*
@@ -275,7 +270,7 @@ function planetlab_login_submit($form_id, $form_values) {
       if ($url[0] != "/") {
        $url = "/$url";
       }
-      Header("Location: $url");
+      header("Location: $url");
       exit();
     }
   }