From c0aa374fdfee009b36dd0cf00fc3e1f5c28061c6 Mon Sep 17 00:00:00 2001 From: Thierry Parmentelat Date: Thu, 22 Jan 2009 23:14:32 +0000 Subject: [PATCH] checkpoint --- modules/planetlab.module | 133 +++++++++++-------- planetlab/events/index.php | 189 +++++++++------------------ planetlab/includes/plc_functions.php | 156 +++++++++++++--------- planetlab/includes/plc_tables.php | 20 ++- planetlab/nodes/add_node.php | 9 +- planetlab/nodes/node.php | 52 ++++---- planetlab/peers/index.php | 105 +-------------- planetlab/peers/peer.php | 57 ++++++++ planetlab/peers/peers.php | 56 ++++++++ 9 files changed, 391 insertions(+), 386 deletions(-) create mode 100644 planetlab/peers/peer.php create mode 100644 planetlab/peers/peers.php diff --git a/modules/planetlab.module b/modules/planetlab.module index 870b661..4921cb3 100644 --- a/modules/planetlab.module +++ b/modules/planetlab.module @@ -10,6 +10,7 @@ require_once 'plc_config.php'; require_once 'plc_session.php'; +require_once 'plc_functions.php'; function planetlab_help($section) { switch ($section) { @@ -51,6 +52,21 @@ function planetlab_menu($may_cache) { return $items; } +// formatting helpers +function ul_start () { return ''; } +function leaf($text) { return '
  • ' . $text . '
  • '; } +function expanded($text) { return '
  • ' . $text . '
  • '; } +function p($text) { return '

    ' . $text . '

    '; } +// fake theme to look like menu +function menu_theme ($menu) { + $result = ''; + $result .= ul_start(); + foreach ($menu as $item) $result .= $item; + $result .= ul_end(); + return $result; +} + function planetlab_block($op = 'list', $delta = 0, $edit = array()) { global $user, $plc; @@ -84,9 +100,10 @@ function planetlab_block($op = 'list', $delta = 0, $edit = array()) { $block['subject'] = t('%s login', array('%s' => variable_get('site_name', 'local'))); $block['content'] = drupal_get_form('planetlab_login_block', $form, 'planetlab_login'); - $block['content'] .= '

    Forgot your password?

    '; - $block['content'] .= '

    Create an account

    '; - $block['content'] .= '

    File a site registration

    '; + $block['content'] .= p(''); + $block['content'] .= p( href (l_reset_password(),"Forgot your password?") ); + $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']; $is_admin = in_array(10,$plc->person['role_ids']); @@ -95,83 +112,88 @@ function planetlab_block($op = 'list', $delta = 0, $edit = array()) { $is_tech = in_array(40,$plc->person['role_ids']); $site_item = ''; - $site_item .= 'Sites'; - $site_item .= '"; - $items[] = $site_item; + $site_item .= leaf( href(l_site_status(),"Migration Status")); + $site_item .= ul_end(); + $items[] = expanded($site_item); $user_item = ''; - $user_item .= 'Users'; - $user_item .= ''; - $items [] = $user_item; + $user_item .= ul_end(); + $items [] = expanded($user_item); $node_item = ''; - $node_item .= 'Nodes'; - $node_item .= ''; - $items [] = $node_item; + $node_item .= leaf (href(l_peers(),'Peers')); + $node_item .= ul_end(); + $items [] = expanded($node_item); $slice_item = ''; //if( !( $is_tech && ! $is_user && ! $is_pi && ! $is_admin ) ) - $slice_item .= 'Slices'; - $slice_item .= ''; - $items [] = $slice_item; + $slice_item .= leaf(href(l_sirius(),"Sirius")); + $slice_item .= ul_end(); + $items [] = expanded($slice_item); if( $is_admin || $is_pi ) { $tag_item = ''; - $tag_item .= 'Tags'; - $tag_item .= ''; - $items [] = $tag_item; + $tag_item .= href(l_tags(),"All Tag Types"); + $tag_item .= ul_start(); + $tag_item .= leaf( href( l_tags_slice(),"Slice Tags")); + $tag_item .= leaf( href( l_tags_interface(),"Interface Tags")); + $tag_item .= leaf( href (l_tags_interface(),"Setting Types (dup xxx)")); + $tag_item .= leaf( href( l_tags_node(),"Node Tags")); + $tag_item .= leaf( href( l_nodegroups(),"Node groups (xxx)")); + $tag_item .= ul_end(); + $items [] = expanded($tag_item); } - + + $doc_item = ''; + $doc_item .= href(l_about(),'About MyPLC'); + $doc_item .= ul_start(); + $doc_item .= leaf ( href (l_doc_plcapi(),"PLCAPI doc")); + $doc_item .= leaf ( href (l_doc_nmapi(),"NMAPI doc")); + $doc_item .= ul_end(); + $items[] = expanded($doc_item); if ( $is_admin ) - $items[] = l(t('Peers'),'db/peers/'); - - if ( $is_admin ) - $items[] = l(t('Events'),'db/events/'); + $items[] = leaf (href(l_events(),'Events')); - $items[] = l(t('About'),'db/about.php'); - if ($user->uid) { // Drupal logout (destroys the session and cleans up $user) - $items[] = l(t('Log out of %s', array('%s' => variable_get('site_name', 'local'))), 'logout'); + // 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[] = l(t('Log out'), 'planetlab/logout'); + $items[] = leaf ( href (l_logout(),'Log out')); } - - $block['content'] = theme('item_list', $items); + + //$block['content'] = theme('list_item', $items); + $block['content'] = menu_theme($items); + // plc_debug("content",$block['content']); } /* @@ -272,8 +294,7 @@ function planetlab_logout() { drupal_goto(NULL, 'time='. time()); } -function planetlab_user($type, &$edit, &$user, $category = NULL) -{ +function planetlab_user($type, &$edit, &$user, $category = NULL) { switch ($type) { case 'logout': if ($plc->person) { @@ -284,8 +305,7 @@ function planetlab_user($type, &$edit, &$user, $category = NULL) } } -function planetlab_page() -{ +function planetlab_page() { $path = $_SERVER['DOCUMENT_ROOT'] . preg_replace('/^db\//', '/planetlab/', $_GET['q']); // error_log("Requested " . $_GET['q'] . " -> $path"); @@ -314,8 +334,7 @@ function planetlab_page() drupal_not_found(); } -function theme_planetlab($content) -{ +function theme_planetlab($content) { return $content; } diff --git a/planetlab/events/index.php b/planetlab/events/index.php index 1afe07a..6899f66 100644 --- a/planetlab/events/index.php +++ b/planetlab/events/index.php @@ -1,6 +1,5 @@ person; -$_roles= $_person['role_ids']; +// needs much memory +ini_set("memory_limit","128M"); + +//set default title +drupal_set_title('Events'); // paginate unit $page_size=30; $messages = array (); +//////////////////////////////////////// +// defaults for day ('j'), 3-letter month ('M') or year ('Y') +function the_date ($key,$dateformat) { + if ($_GET[$key]) return $_GET[$key]; + else return date($dateformat); +} + +// fill out dates from now if not specified +$from_d = the_date('from_d','j'); +$from_m = the_date('from_m','M'); +$from_y = the_date('from_y','Y'); +$until_d = the_date('until_d','j'); +$until_m = the_date('until_m','M'); +$until_y = the_date('until_y','Y'); + +// create the options area from a list and the selected entry +function dropdown_options ($array,$selected) { + $result=""; + foreach ($array as $item) { + $result.= "