details can be updated inline - old forms still to be cleaned up
[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 $form = new PlcForm (l_actions(),array());
56 $form->start();
57 // XXX make this updatable ?
58 $details = new PlcDetails(false);
59 $details->start();
60 $details->line("Name", $form->text_html("name",$tagname,20));
61 $details->line("Category", $form->text_html("category",$category,30));
62 $details->line("Description",$form->textarea_html("description",$description,40,5));
63 //tmp
64 // select the option corresponding with min_role_id
65 $selector = "<select name='min_role_id'>".
66   "<option value='10'>Admin</option>".
67   "<option value='20'>PI</option>".
68   "<option value='30'>User</option>" .
69   "<option value='40'>Tech</option>" . "</select>\n";
70 $details->line("Min Role",$selector);
71 if ($update_mode) {
72   $submit=$form->hidden_html ('tag_type_id',$tag_type_id) . 
73     $form->submit_html('update-tag-type',"Update tag type");
74  } else {
75   $submit=$form->submit_html('add-tag-type',"Add tag type");
76  }
77 $details->single ($submit,"right");
78
79 $details->end();
80 $form->end();
81
82 // Print footer
83 include 'plc_footer.php';
84
85 ?>