ckp
[plewww.git] / planetlab / tags / tag_form.php
1 <?php
2
3 // $Id$
4
5 // Require login
6 require_once 'plc_login.php';
7
8 // Get session and API handles
9 require_once 'plc_session.php';
10 global $plc, $api;
11
12 // Print header
13 require_once 'plc_drupal.php';
14 include 'plc_header.php';
15
16 // Common functions
17 require_once 'plc_functions.php';
18 require_once 'plc_minitabs.php';
19 require_once 'plc_tables.php';
20 require_once 'plc_details.php';
21 require_once 'plc_forms.php';
22
23 // to create a new (action=='add-tag-type') 
24 // or to update an existing (action='update-tag-type','tag_type_id'=<id>)
25
26 // -------------------- 
27 // recognized URL arguments
28 $pattern=$_GET['pattern'];
29
30 // --- decoration
31 $title="Tag Types";
32 $tabs=array();
33 $tabs['All Types']=array('url'=>l_tags(),'bubble'=>"All Tag Types");
34
35 // -------------------- 
36 drupal_set_title($title);
37 plc_tabs($tabs);
38
39 // if its edit get the tag info
40 $update_mode = ( $_GET['action'] == 'update-tag-type' ) ;
41
42 if ($update_mode) {
43   $tag_type_id= intval( $_GET['id'] );
44   $type_info= $api->GetTagTypes( array( $tag_type_id ) );
45   
46   $tagname=$type_info[0]['tagname'];
47   $min_role_id= $type_info[0]['min_role_id'];
48   $description= $type_info[0]['description'];
49   $category=$type_info[0]['category'];
50  }  
51
52 // display form for tag types
53 plc_section($label,false);
54
55 plc_form_start (l_actions(),array());
56 plc_details_start();
57 plc_details_line("Name", plc_form_text_text("name",$tagname,20));
58 plc_details_line("Category", plc_form_text_text("category",$category,30));
59 plc_details_line("Description",plc_form_textarea_text("description",$description,40,5));
60 //tmp
61 // select the option corresponding with min_role_id
62 $selector = "<select name='min_role_id'>".
63   "<option value='10'>Admin</option>".
64   "<option value='20'>PI</option>".
65   "<option value='30'>User</option>" .
66   "<option value='40'>Tech</option>" . "</select>\n";
67 plc_details_line("Min Role",$selector);
68 if ($update_mode) {
69   $submit=plc_form_hidden_text ('tag_type_id',$tag_type_id) . 
70     plc_form_submit_text('update-tag-type',"Update tag type");
71  } else {
72   $submit=plc_form_submit_text('add-tag-type',"Add tag type");
73  }
74 plc_details_line1 ($submit,"right");
75
76 plc_details_end();
77 plc_form_end();
78
79 // Print footer
80 include 'plc_footer.php';
81
82 ?>