From: Thierry Parmentelat Date: Thu, 29 Jan 2009 16:41:07 +0000 (+0000) Subject: ckp X-Git-Tag: PLEWWW-4.3-1~77 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=47599d12927b555b6f104e387112edee3656f157;p=plewww.git ckp --- diff --git a/planetlab/persons/person_actions.php b/planetlab/actions.php similarity index 71% rename from planetlab/persons/person_actions.php rename to planetlab/actions.php index 1a2c82e..7e18dfd 100644 --- a/planetlab/persons/person_actions.php +++ b/planetlab/actions.php @@ -19,25 +19,29 @@ $known_actions=array(); // (*) use POST // (*) set 'action' to one of the following $known_actions []= "add-person-to-site"; -// expects: person_id & site_id +// expects: person_id & site_id $known_actions []= "remove-person-from-sites"; -// expects: person_id & site_ids +// expects: person_id & site_ids $known_actions []= "remove-roles-from-person"; -// expects: person_id & role_ids +// expects: person_id & role_ids $known_actions []= "add-role-to-person"; -// expects: role_person_id & id +// expects: role_person_id & id $known_actions []= "enable-person"; -// expects: person_id +// expects: person_id $known_actions []= "disable-person"; -// expects: person_id +// expects: person_id $known_actions []= "become-person"; -// expects: person_id +// expects: person_id $known_actions []= "delete-person"; -// expects: person_id +// expects: person_id $known_actions []= "delete-keys"; -// expects: key_ids & person_id (for redirecting to the person's page) +// expects: key_ids & person_id (for redirecting to the person's page) $known_actions []= "upload-key"; -// expects: person_id & $_FILES['key'] +// expects: person_id & $_FILES['key'] +$known_actions []= "update-tag-type"; +// expects: tag_type_id & name & description & category & min_role_id +$known_actions []= "add-tag-type"; +// expects: tag_type_id & name & description & category & min_role_id ////////////////////////////// // sometimes we don't set 'action', but use the submit button name instead @@ -55,7 +59,7 @@ else $person_id = $_POST['person_id']; // usually needed if ( ! $action ) { - drupal_set_message ("person_actions.php: action not set"); + drupal_set_message ("actions.php: action not set"); plc_debug('POST',$_POST); return; } @@ -177,6 +181,50 @@ switch ($action) { exit(); } + case 'update-tag-type': { + // get post vars + $tag_type_id= intval( $_POST['tag_type_id'] ); + $name = $_POST['name']; + $min_role_id= intval( $_POST['min_role_id'] ); + $description= $_POST['description']; + $category= $_POST['category']; + + // make tag_type_fields dict + $tag_type_fields= array( "min_role_id" => $min_role_id, + "tagname" => $name, + "description" => $description, + "category" => $category, + ); + + // Update it! + $api->UpdateTagType( $tag_type_id, $tag_type_fields ); + + header( "location: " . l_tag($tag_type_id)); + exit(); + } + + case 'add-tag-type': { + // get post vars + $name = $_POST['name']; + $min_role_id= intval( $_POST['min_role_id'] ); + $description= $_POST['description']; + $category= $_POST['category']; + + // make tag_type_fields dict + $tag_type_fields= array( "min_role_id" => $min_role_id, + "tagname" => $name, + "description" => $description, + "category" => $category, + ); + + // Add it! + $id=$api->AddTagType( $tag_type_fields ); + drupal_set_message ("tag type $id created"); + + header( "location: " . l_tag($id)); + exit(); + } + case 'debug': { plc_debug('GET',$_GET); plc_debug('POST',$_POST); @@ -185,7 +233,7 @@ switch ($action) { } default: { - plc_error ("Unknown action $action in person_actions.php"); + plc_error ("Unknown action $action in actions.php"); return; } diff --git a/planetlab/includes/plc_details.php b/planetlab/includes/plc_details.php index 5244e27..d28d1c7 100644 --- a/planetlab/includes/plc_details.php +++ b/planetlab/includes/plc_details.php @@ -30,6 +30,15 @@ function plc_details_line_list($title,$list) { plc_details_line($title,plc_vertical_table($list,"foo")); } +// same but the values are multiple and displayed in an embedded vertical table +function plc_details_line1_text($title,$align=NULL) { + $result=" \n"; diff --git a/planetlab/includes/plc_forms.php b/planetlab/includes/plc_forms.php index 2197e13..15480dc 100644 --- a/planetlab/includes/plc_forms.php +++ b/planetlab/includes/plc_forms.php @@ -1,6 +1,6 @@ "; +} +function plc_form_hidden ($key,$value) { print plc_form_hidden_text($key,$value); } + +// options unused so far function plc_form_start ($url, $values, $options=array()) { $method = array_key_exists('method',$options) ? $options['method'] : 'POST'; print "
"; foreach ($values as $key=>$value) { - print ""; + print plc_form_hidden_text($ke,$value); } } @@ -22,20 +28,28 @@ function plc_form_end($options=array()) { function plc_form_checkbox_text ($name,$value,$selected=false) { if ($selected) $xtra=" selected=selected"; - return ""; + return ""; } function plc_form_submit_text ($name,$display) { - return ""; + return ""; } +function plc_form_submit ($name, $display) { print plc_form_submit_text($name,$display); } function plc_form_file_text ($name,$size) { - return ""; + return ""; } function plc_form_label_text ($name,$display) { return ""; } + +function plc_form_text_text ($name,$value,$size) { + return ""; +} +function plc_form_textarea_text ($name,$value,$cols,$rows) { + return ""; +} function plc_form_select_text ($name,$values,$label="") { $selector=""; @@ -45,10 +59,17 @@ function plc_form_select_text ($name,$values,$label="") { foreach ($values as $chunk) { $display=$chunk['display']; $value=$chunk['value']; - $selector .= "\n"; + $selector .= "
"; +} + ?> diff --git a/planetlab/includes/plc_functions.php b/planetlab/includes/plc_functions.php index 7a8ac86..a25f747 100644 --- a/planetlab/includes/plc_functions.php +++ b/planetlab/includes/plc_functions.php @@ -42,55 +42,55 @@ function href ($url,$text) { return "" . $text . ""; // l_object_t($object_id,text) -> an tag that shows text and links to the above // l_object_add () -> the url to that object-afding page +function l_actions () { return "/db/actions.php"; } + function l_nodes () { return "/db/nodes/index.php"; } -function l_node ($node_id) { return "/db/nodes/node.php?id=" . $node_id; } +function l_nodes_local () { return "/db/nodes/index.php?peerscope=local"; } +function l_node ($node_id) { return "/db/nodes/node.php?id=$node_id"; } function l_node_t ($node_id,$text) { return href (l_node($node_id),$text); } 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_site ($site_id) { return "/db/nodes/index.php?site_id=$site_id"; } -function l_interface ($interface_id) { return "/db/nodes/interfaces.php?id=" . $interface_id; } +function l_interface ($interface_id) { return "/db/nodes/interfaces.php?id=$interface_id"; } function l_interface_t ($interface_id,$text) { return href (l_interface($interface_id),$text); } -function l_interface_add($node_id) { return "/db/nodes/interfaces.php?node_id=" . $node_id; } +function l_interface_add($node_id) { return "/db/nodes/interfaces.php?node_id=$node_id"; } function l_sites () { return "/db/sites/index.php"; } -function l_site ($site_id) { return "/db/sites/index.php?id=" . $site_id; } +function l_site ($site_id) { return "/db/sites/index.php?id=$site_id"; } function l_site_t ($site_id,$text) { return href (l_site($site_id),$text); } function l_slices () { return "/db/slices/index.php"; } -function l_slice ($slice_id) { return "/db/slices/index.php?id=" . $slice_id; } +function l_slice ($slice_id) { return "/db/slices/index.php?id=$slice_id"; } function l_slice_t ($slice_id,$text) { return href (l_slice($slice_id),$text); } function l_slice_add () { return "/db/slices/add_slice.php"; } -function l_sliver ($node_id,$slice_id) { return "/db/nodes/slivers.php?node_id=" . $node_id. "&slice_id=" . $slice_id; } +function l_sliver ($node_id,$slice_id) { return "/db/nodes/slivers.php?node_id=$node_id&slice_id=$slice_id"; } function l_sliver_t ($node_id,$slice_id,$text) { return href (l_sliver($node_id,$slice_id),$text) ; } function l_persons () { return "/db/persons/index.php"; } -function l_person ($person_id) { return "/db/persons/index.php?id=" . $person_id; } +function l_person ($person_id) { return "/db/persons/index.php?id=$person_id"; } function l_person_t ($person_id,$text) { return href (l_person($person_id),$text); } -function l_persons_site ($site_id) { return "/db/persons/index.php?site_id=" . $site_id; } -function l_person_actions() { return "/db/persons/person_actions.php"; } +function l_persons_site ($site_id) { return "/db/persons/index.php?site_id=$site_id"; } function l_tags () { return "/db/tags/index.php"; } -function l_tags_node () { return "/db/tags/index.php?type=node"; } -# xxx cleanup duplicate pages -#function l_tags_interface () { return "/db/tags/index.php?type=interface"; } -function l_tags_interface () { return "/db/nodes/settings.php"; } -function l_tags_slice () { return "/db/tags/index.php?type=slice"; } +function l_tag ($tag_type_id) { return "/db/tags/index.php"; } +function l_tag_add() { return "/db/tags/tag_form.php"; } +function l_tag_update($id) { return "/db/tags/tag_form.php&action=update-tag-type&id=$id"; } function l_nodegroups () { return "/db/tags/node_groups.php"; } -function l_nodegroup ($nodegroup_id) { return "/db/tags/node_groups.php?id=" . $nodegroup_id; } +function l_nodegroup ($nodegroup_id) { return "/db/tags/node_groups.php?id=$nodegroup_id"; } function l_nodegroup_t ($nodegroup_id,$text) { return href(l_nodegroup($nodegroup_id),$text); } -function l_events () { return '/db/events/index.php'; } -function l_event ($type,$param,$id) { return '/db/events/index.php?type=' . $type . '&' . $param . '=' . $id; } +function l_events () { return "/db/events/index.php"; } +function l_event ($type,$param,$id) { return "/db/events/index.php?type=$type&$param=$id"; } function l_peers() { return "/db/peers/index.php"; } -function l_peer($peer_id) { return "/db/peers/index.php?id=" . $peer_id; } +function l_peer($peer_id) { return "/db/peers/index.php?id=$peer_id"; } -function l_comon($id_name,$id_value) { return '/db/nodes/comon.php?' . $id_name . "=" . $id_value; } +function l_comon($id_name,$id_value) { return "/db/nodes/comon.php?$id_name=$id_value"; } function l_sirius() { return "/db/sirius/index.php"; } function l_about() { return "/db/about.php"; } function l_doc_plcapi() { return "/db/doc/PLCAPI.php"; } @@ -185,6 +185,16 @@ function is_reserved_network_addr($network_addr) { return false; } +//////////////////////////////////////////////////////////// peer & peerscopes +function plc_role_global_hash ($api) { + $hash=array(); + $roles=$api->GetRoles(); + foreach ($roles as $role) { + $hash[$role['role_id']]=$role['name']; + } + return $hash; +} + //////////////////////////////////////////////////////////// peer & peerscopes // when shortnames are needed on peers function plc_peer_global_hash ($api) { diff --git a/planetlab/includes/plc_tables.php b/planetlab/includes/plc_tables.php index 5b13810..ee3a5d2 100644 --- a/planetlab/includes/plc_tables.php +++ b/planetlab/includes/plc_tables.php @@ -176,5 +176,14 @@ function plc_table_row_end () { print "\n"; } +function plc_table_td_text ($text,$colspan=0,$align=NULL) { + $result=""; + $result .= " diff --git a/planetlab/nodes/interfaces.php b/planetlab/nodes/interfaces.php index ab5e60e..9cbdca0 100644 --- a/planetlab/nodes/interfaces.php +++ b/planetlab/nodes/interfaces.php @@ -195,6 +195,7 @@ print "
"; if (empty ($interface['interface_tag_ids'])) { print "

This network interface has no additional setting

"; if( $is_admin || $is_pi ) + // xxx check the destination page echo "

Add an Interface Setting

\n"; } else { $interface_tags = $api->GetInterfaceTags($interface['interface_tag_ids']); @@ -214,6 +215,7 @@ if (empty ($interface['interface_tag_ids'])) { echo(""); } if ($is_admin || $is_pi) + // xxx check the destination page printf (" %s ",$setting['interface_tag_id'],$setting['tagname']); else printf (" %s ",$setting['tagname']); @@ -223,6 +225,7 @@ if (empty ($interface['interface_tag_ids'])) { $setting['value']); } if( $is_admin || $is_pi ) + // xxx check the destination page echo "Add a Network Setting\n"; print ""; diff --git a/planetlab/nodes/setting_action.php b/planetlab/nodes/setting_action.php index 498068d..8576a96 100644 --- a/planetlab/nodes/setting_action.php +++ b/planetlab/nodes/setting_action.php @@ -9,13 +9,6 @@ require_once 'plc_login.php'; require_once 'plc_session.php'; global $plc, $api; -/* -// Print header -require_once 'plc_drupal.php'; -drupal_set_title('Slices'); -include 'plc_header.php'; -*/ - // Common functions require_once 'plc_functions.php'; require_once 'plc_sorts.php'; @@ -42,6 +35,7 @@ if( $_POST['edit_type'] ) { print "
" . $api_error . "
"; } + // xxx check the destination page header( "location: settings.php" ); exit(); } @@ -55,6 +49,7 @@ if( $_POST['add_type'] ) { // add it!! $api->AddTagType( $setting_type ); + // xxx check the destination page header( "location: settings.php" ); exit(); } @@ -116,6 +111,7 @@ if( $_GET['del_type'] ) { // delete it! $api->DeleteTagType( $type_id ); + // xxx check the destination page header( "location: settings.php" ); exit(); } diff --git a/planetlab/nodes/settings.php b/planetlab/nodes/settings.php deleted file mode 100644 index cf1d21a..0000000 --- a/planetlab/nodes/settings.php +++ /dev/null @@ -1,234 +0,0 @@ -person; -$_roles= $_person['role_ids']; - -//plc_debug("person", $_person ); - -$tag_columns=array( "tag_type_id", "category", "tagname", "description", "min_role_id" ); - -// prepare dict role_id => role_name -global $roles; -$roles= $api->GetRoles(); -global $roles_id_to_name; -$roles_id_to_name=array(); -foreach ($roles as $role) { - $roles_id_to_name[$role['role_id']] = $role['name']; -} - -// compute person's smallest role -global $person_role; -$person_role=50; -foreach ($_person['role_ids'] as $role_id) { - if ($role_id < $person_role) { - $person_role=$role_id; - } -} -//plc_debug("person_role",$person_role); - -// post-process results from GetTagTypes -// with planetlab 4.2, we've moved to php-5.2 -// with the former 5.0 reelase, I could invoke array_map -// with a function that took a reference and could do side-effects -// Now I have to return the copy... -// this new way of doing things might require more memory -// on the other hand we should move to a schema where -// pagination is done in the API, so it's no big deal hopefully -function layout_setting_type ($setting_type) { - // replace role_id with name - global $roles_id_to_name; - $setting_type['min_role']=$roles_id_to_name[$setting_type['min_role_id']]; - return $setting_type; -} - -// if no id, display list of tag types -if( !$_GET['id'] && !$_GET['add'] && !$_GET['add_type'] && !$_GET['edit_type'] ) { - // get types - global $person_role; - $filter = array (']min_role_id'=>$person_role,'category'=>'interface*'); - $setting_types= $api->GetTagTypes( $filter, $tag_columns ); - $setting_types = array_map(layout_setting_type,$setting_types); - sort_interface_tags ($setting_types); - - // list them - - echo ""; - echo ""; - // if admin we need one more cells for delete links - if( in_array( "10", $_person['role_ids'] ) ) - echo ""; - $role_header="
min
Role
"; - echo "Name"; - echo "Category"; - echo "" . $role_header . ""; - echo "Id"; - echo "Description"; - echo ""; - echo ""; - - foreach( $setting_types as $type ) { - echo ""; - // if admin display delete links - if( in_array( "10", $_person['role_ids'] ) ) { - echo ""; - echo plc_delete_link_button('setting_action.php?del_type='. $type['tag_type_id'], - $type['tagname']); - echo ""; - } - // if admin, the name is a link to edition - if (in_array( "10", $_person['role_ids'])) { - echo "
" . $type['tagname'] . ""; - } else { - echo "" . $type['tagname'] . ""; - } - echo "" . $type['category'] . ""; - echo "" . $type['min_role'] . "" . $type['min_role_id'] . "" . $type['description'] . ""; - echo "\n"; - } - - if( in_array( "10", $_person['role_ids'] ) ) - echo "Add a Setting Type"; - - echo "\n"; - - - // back link o nodes - echo "

Back to Nodes\n"; - -} -elseif( $_GET['add_type'] || $_GET['edit_type'] ) { - // if its edit get the tag info - if( $_GET['edit_type'] ) { - $type_id= intval( $_GET['edit_type'] ); - $type= $api->GetTagTypes( array( $type_id ) ); - - $category=$type[0]['category']; - $name= $type[0]['tagname']; - $min_role_id= $type[0]['min_role_id']; - $description= $type[0]['description']; - - } - - // display form for setting types - echo "

\n"; - if ($_GET['edit_type']) { - drupal_set_title("Edit Setting Type"); - } else { - drupal_set_title("Add Setting Type"); - } - echo ""; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo ""; - echo "
Category:
Name:
Min Role:
Description:"; - echo "\n"; - echo "
"; - if( $_GET['edit_type'] ) { - echo "\n"; - echo "\n"; - } else { - echo "\n"; - } - echo "
"; - - echo "
\n"; - - echo "

Back to Setting Types\n"; -} -elseif( $_GET['add'] ) { - - // get interface id from GET - $interface_id= intval( $_GET['add'] ); - - // get all setting types - global $person_role; - $filter = array (']min_role_id'=>$person_role,'category'=>'interface*'); - $setting_types= $api->GetTagTypes( $filter, array( "tag_type_id", "tagname" , "category") ); - sort_interface_tags($setting_types); - - // get interface's settings - $interface = $api->GetInterfaces( array( $interface_id ), array( "interface_tag_ids","ip" ) ); - - drupal_set_title("Add a setting to ". $interface[0]['ip']); - - // start form - echo "

\n"; - echo "\n"; - - echo ""; - - echo "\n"; - - echo "\n"; - echo "
New Setting
Select\n"; - - echo "
Value:
"; - echo "
\n"; - -} -else { - $setting_id= intval( $_GET['id'] ); - - // get setting info - $setting= $api->GetInterfaceTags( array( $setting_id )); - - // interface info - $interface= $api->GetInterfaces( array( $setting[0]['interface_id'] ), array( "ip" ) ); - - drupal_set_title("Edit setting ". $setting[0]['tagname'] ." on ". $interface[0]['ip']); - - // start form and put values in to be edited. - echo "
\n"; - echo "\n"; - echo "\n"; - - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo "
Edit Setting
Category " . $setting[0]['category'] . "
Name " . $setting[0]['tagname'] . "
Value
"; - echo "
\n"; - -} - -// back link is case-dependant - -// Print footer -include 'plc_footer.php'; - -?> diff --git a/planetlab/persons/person.php b/planetlab/persons/person.php index 4156076..83d7ff9 100644 --- a/planetlab/persons/person.php +++ b/planetlab/persons/person.php @@ -82,14 +82,14 @@ if ($privileges || $is_my_account) if ($local_peer && $privileges) if ($enabled) $tabs['Disable'] = array ('method'=>'POST', - 'url'=>l_person_actions(), + 'url'=>l_actions(), 'values'=> array ('person_id'=>$person_id, 'action'=>'disable-person'), 'bubble'=>"Disable $first_name $last_name", 'confirm'=>"Are you sure you want to disable $first_name $last_name"); else $tabs['Enable'] = array ('method'=>'POST', - 'url'=>l_person_actions(), + 'url'=>l_actions(), 'values'=> array ('person_id'=>$person_id, 'action'=>'enable-person'), 'bubble'=>"Enable $first_name $last_name", @@ -97,7 +97,7 @@ if ($local_peer && $privileges) // become if (plc_is_admin() && ! $is_my_account) - $tabs['Become'] = array('url'=>l_person_actions(), + $tabs['Become'] = array('url'=>l_actions(), 'values'=>array('action'=>'become-person', 'person_id'=>$person_id), 'bubble'=>"Become $first_name $last_name", @@ -106,7 +106,7 @@ if (plc_is_admin() && ! $is_my_account) // delete if ($local_peer && $privileges) $tabs['Delete'] = array ('method'=>'POST', - 'url'=>l_person_actions(), + 'url'=>l_actions(), 'values'=> array ('person_id'=>$person_id, 'action'=>'delete-person'), 'bubble'=>"Delete $first_name $last_name", @@ -165,7 +165,7 @@ if( ! $slices) { } // we don't set 'action', but use the submit button name instead -plc_form_start(l_person_actions(), +plc_form_start(l_actions(), array("person_id"=>$person_id, // uncomment this to run the 'debug' action //"action"=>"debug", diff --git a/planetlab/tags/index.php b/planetlab/tags/index.php index b4a0d34..8d27beb 100644 --- a/planetlab/tags/index.php +++ b/planetlab/tags/index.php @@ -7,190 +7,20 @@ require_once 'plc_login.php'; require_once 'plc_session.php'; global $plc, $api; -if (! isset($_GET['type']) || $_GET['type']=='all') { - $title="All tag types"; - $tag_type_filter=array("-SORT"=>"tagname"); - } else { - $title="Tag Types for " . $_GET['type'] . "s"; - $pattern=$_GET['type'] . '*'; - $tag_type_filter=array("category"=>$pattern,"-SORT"=>"tagname"); - } - - // Print header require_once 'plc_drupal.php'; -drupal_set_title($title); include 'plc_header.php'; // Common functions require_once 'plc_functions.php'; -require_once 'plc_sorts.php'; - -// find person roles -$_person= $plc->person; -$_roles= $_person['role_ids']; - -//print_r( $_person ); - -// if no id, display list of tag types -if( !$_GET['id'] && !$_GET['add'] && !$_GET['add_type'] && !$_GET['edit_type'] ) { - // get types - $tag_types= $api->GetTagTypes($tag_type_filter, - array( "tag_type_id", "tagname", "category", "description", "min_role_id" ) ); - - // get role names for the min role_ids - foreach( $tag_types as $tag_type ) { - $roles= $api->GetRoles(); - foreach( $roles as $role ) { - if( $tag_type['min_role_id'] == $role['role_id'] ) - $role_name= $role['name']; - } - - $tag_type_info[]= array( "tag_type_id" => $tag_type['tag_type_id'], - "tagname" => $tag_type['tagname'], - "description" => $tag_type['description'], - "min_role" => $role_name, - "category" => $tag_type['category']); - } - // list them - echo "

Tag Types

\n"; - - echo ""; - // if admin we need to more cells - if( in_array( "10", $_person['role_ids'] ) ) - echo ""; - echo ""; - - foreach( $tag_type_info as $type ) { - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - // if admin display edit/delet links - if( in_array( "10", $_person['role_ids'] ) ) { - echo ""; - echo ""; - } - echo "\n"; - - } - - echo "
NameCategory>Min RoleDescription
". $type['tagname'] ."". $type['category'] ."". $type['min_role'] ."". $type['description'] ."Edit"; - echo plc_delete_link_button ('tag_action.php?del_type='. $type['tag_type_id'], - $type['tagname']); - echo "
\n"; - - if( in_array( "10", $_person['role_ids'] ) ) - echo "

Add a Tag Type"; - +if ( $_GET['action'] ) { + include 'tag_edit.php'; + } else if ( ! $_GET['add'] ) { + include 'tags.php'; + } else { + include 'tag_set.php'; } -elseif( $_GET['add_type'] || $_GET['edit_type'] ) { - // if its edit get the tag info - if( $_GET['edit_type'] ) { - $type_id= intval( $_GET['edit_type'] ); - $type_info= $api->GetTagTypes( array( $type_id ) ); - - $tagname= $type_info[0]['tagname']; - $min_role_id= $type_info[0]['min_role_id']; - $description= $type_info[0]['description']; - $category=$type_info[0]['category']; - - } - - // display form for tag types - echo "

\n"; - echo "

Add Tag Type

\n"; - echo "

Name: \n"; - echo "

Category: \n"; - echo "

Min Role: \n"; - echo "

Description:
\n"; - echo "\n"; - echo "

\n"; - echo "\n"; - } - else - echo "name='add_type' value='Add Tag Type'>\n"; - - echo "

\n"; - -} -elseif( $_GET['add'] ) { - // get slice id from GET - $slice_id= intval( $_GET['add'] ); - - // get all tag types - $tag_types= $api->GetTagTypes( $tag_type_filter , array( "tag_type_id", "tagname" ) ); - - foreach( $tag_types as $tag_type ) { - $all_tags[$tag_type['tag_type_id']]= $tag_type['tagname']; - } - - // get slice's tag types - $slice_info= $api->GetSlices( array( $slice_id ), array( "slice_tag_ids" ) ); - $tag_info= $api->GetSliceTags( $slice_info[0]['slice_tag_ids'], array( "tag_type_id", "tagname" ) ); - - foreach( $tag_info as $info ) { - $slice_tag_types[$info['tag_type_id']]= $info['tagname']; - } - - - $tag_types= $all_tags; - - // start form - echo "
\n"; - echo "

Edit ". $slice_info[0]['name'] ." tag: ". $tag_type[0]['tagname'] ."

\n"; - - echo "\n"; - - echo "

Value: \n"; - - echo "

\n"; - echo "\n"; - echo "

\n"; - -} -else { - $tag_id= intval( $_GET['id'] ); - - // get tag - $slice_tag= $api->GetSliceTags( array( $tag_id ), array( "slice_id", "slice_tag_id", "tag_type_id", "value", "description", "min_role_id" ) ); - - // get type info - $tag_type= $api->GetTagTypes( array( $slice_tag[0]['tag_type_id'] ), array( "tag_type_id", "tagname", "description" ) ); - - // slice info - $slice_info= $api->GetSlices( array( $slice_tag[0]['slice_id'] ), array( "name" ) ); - - // start form and put values in to be edited. - echo "
\n"; - echo "

Edit ". $slice_info[0]['name'] ." tag: ". $tag_type[0]['tagname'] ."

\n"; - - echo $slice_tag[0]['description'] ."
\n"; - echo "Value:

\n"; - - echo "\n"; - echo "\n"; - echo "\n"; - echo "
\n"; - -} - -echo "

Back to Slices\n"; // Print footer include 'plc_footer.php'; diff --git a/planetlab/tags/tag_action.php b/planetlab/tags/tag_action.php index 170db85..abd0781 100644 --- a/planetlab/tags/tag_action.php +++ b/planetlab/tags/tag_action.php @@ -45,7 +45,7 @@ if( $_GET['rem_id'] ) { // tag updates if( $_POST['edit_tag'] ) { - // get the id of the tag to update and teh value from POST + // get the id of the tag to update and the value from POST $tag_id= intval( $_POST['tag_id'] ); $value= $_POST['value']; $slice_id= $_POST['slice_id']; diff --git a/planetlab/tags/tag_form.php b/planetlab/tags/tag_form.php new file mode 100644 index 0000000..2851e82 --- /dev/null +++ b/planetlab/tags/tag_form.php @@ -0,0 +1,82 @@ +) + +// -------------------- +// recognized URL arguments +$pattern=$_GET['pattern']; + +// --- decoration +$title="Tag Types"; +$tabs=array(); +$tabs['All Types']=array('url'=>l_tags(),'bubble'=>"All Tag Types"); + +// -------------------- +drupal_set_title($title); +plc_tabs($tabs); + +// if its edit get the tag info +$update_mode = ( $_GET['action'] == 'update-tag-type' ) ; + +if ($update_mode) { + $tag_type_id= intval( $_GET['id'] ); + $type_info= $api->GetTagTypes( array( $tag_type_id ) ); + + $tagname=$type_info[0]['tagname']; + $min_role_id= $type_info[0]['min_role_id']; + $description= $type_info[0]['description']; + $category=$type_info[0]['category']; + } + +// display form for tag types +plc_table_title($label); + +plc_form_start (l_actions(),array()); +plc_details_start(); +plc_details_line("Name", plc_form_text_text("name",$tagname,20)); +plc_details_line("Category", plc_form_text_text("category",$category,30)); +plc_details_line("Description",plc_form_textarea_text("description",$description,40,5)); +//tmp +// select the option corresponding with min_role_id +$selector = "\n"; +plc_details_line("Min Role",$selector); +if ($update_mode) { + $submit=plc_form_hidden_text ('tag_type_id',$tag_type_id) . + plc_form_submit_text('update-tag-type',"Update tag type"); + } else { + $submit=plc_form_submit_text('add-tag-type',"Add tag type"); + } +plc_details_line1 ($submit,"right"); + +plc_details_end(); +plc_form_end(); + +// Print footer +include 'plc_footer.php'; + +?> diff --git a/planetlab/tags/tag_set.php b/planetlab/tags/tag_set.php new file mode 100644 index 0000000..69b7a0d --- /dev/null +++ b/planetlab/tags/tag_set.php @@ -0,0 +1,90 @@ +GetTagTypes( $tag_type_filter , array( "tag_type_id", "tagname" ) ); + + foreach( $tag_types as $tag_type ) { + $all_tags[$tag_type['tag_type_id']]= $tag_type['tagname']; + } + + // get slice's tag types + $slice_info= $api->GetSlices( array( $slice_id ), array( "slice_tag_ids" ) ); + $tag_info= $api->GetSliceTags( $slice_info[0]['slice_tag_ids'], array( "tag_type_id", "tagname" ) ); + + foreach( $tag_info as $info ) { + $slice_tag_types[$info['tag_type_id']]= $info['tagname']; + } + + + $tag_types= $all_tags; + + // start form + echo "

\n"; + echo "

Edit ". $slice_info[0]['name'] ." tag: ". $tag_type[0]['tagname'] ."

\n"; + + echo "\n"; + + echo "

Value: \n"; + + echo "

\n"; + echo "\n"; + echo "

\n"; + +} +else { + $tag_id= intval( $_GET['id'] ); + + // get tag + $slice_tag= $api->GetSliceTags( array( $tag_id ), array( "slice_id", "slice_tag_id", "tag_type_id", "value", "description", "min_role_id" ) ); + + // get type info + $tag_type= $api->GetTagTypes( array( $slice_tag[0]['tag_type_id'] ), array( "tag_type_id", "tagname", "description" ) ); + + // slice info + $slice_info= $api->GetSlices( array( $slice_tag[0]['slice_id'] ), array( "name" ) ); + + // start form and put values in to be edited. + echo "
\n"; + echo "

Edit ". $slice_info[0]['name'] ." tag: ". $tag_type[0]['tagname'] ."

\n"; + + echo $slice_tag[0]['description'] ."
\n"; + echo "Value:

\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "
\n"; + +} + +// Print footer +include 'plc_footer.php'; + +?> diff --git a/planetlab/tags/tags.php b/planetlab/tags/tags.php new file mode 100644 index 0000000..8b768d7 --- /dev/null +++ b/planetlab/tags/tags.php @@ -0,0 +1,85 @@ +l_tag_add(),'bubble'=>"Create a new tag type"); +$tabs['All Nodes']=array('url'=>l_nodes(),'bubble'=>"Nodes from all peers"); +$tabs['Local Nodes']=array('url'=>l_nodes(),'values'=>array('peerscope'=>'local'),'bubble'=>"All local nodes"); +//$tabs['Interfaces']=l_interfaces(); +$tabs['All Slices']=array('url'=>l_slices(),'bubble'=>"Slices from all peers"); + +// -------------------- +drupal_set_title($title); +plc_tabs($tabs); + +$tag_type_columns = array( "tag_type_id", "tagname", "category", "description", "min_role_id" ); + +$tag_type_filter=NULL; +if ($pattern) + $tag_type_filter['category']=$pattern; + +// get types +$tag_types= $api->GetTagTypes($tag_type_filter, $tag_type_columns); + +$headers=array(); +// delete button +if (plc_is_admin()) $headers[' ']="none"; +$headers["Id"]="int"; +$headers['Name']="string"; +$headers['Description']="string"; +$headers['Min role']="string"; +$headers['Category']="string"; + +plc_table_start("tags",$headers,1); + +$roles_hash=plc_role_global_hash($api); + +foreach( $tag_types as $tag_type ) { + $role_name=$roles_hash[$tag_type['min_role_id']]; + + plc_table_row_start(); + $id=$tag_type['tag_type_id']; + if (plc_is_admin()) + plc_table_cell(plc_delete_link_button ('tag_action.php?del_type='. $id, + $tag_type['tagname'])); + plc_table_cell($id); + plc_table_cell(href(l_tag_update($id),$tag_type['tagname'])); + plc_table_cell(wordwrap($tag_type['description'],40,"
")); + plc_table_cell($role_name); + plc_table_cell($tag_type['category']); + plc_table_row_end(); +} +$footers=array(); +if (plc_is_admin()) + $footers[]=plc_table_td_text(plc_form_simple_button(l_tag_add(),"Add a Tag Type","GET"),6,"right"); + +plc_table_end("tags",array('footers'=>$footers)); + +// Print footer +include 'plc_footer.php'; + +?>