// expects: node_id
$known_actions []= "update-node";
// expects: node_id, hostname, model
+
+//////////////////////////////////////// interfaces
+$known_actions []= "delete-interfaces";
+// expects: interface_ids
+
//////////////////////////////////////// sites
$known_actions []= "delete-site";
// expects: site_id
$known_actions []= "expire-all-slices-in-site";
// expects: slice_ids
+$known_actions []= "update-site";
+// expects: site_id & name abbreviated_name url latitude longitude [login_base max_slices]
//////////////////////////////////////// tags
$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
+// expects: tag_type_id & tagname & description & category & min_role_id
$known_actions []= "set-tag-on-node";
// expects: node_id tagname value
+$known_actions []= "delete-tag-types";
+// expects: tag_type_ids
+
+//////////////////////////////////////// nodetags
+$known_actions []= "delete-node-tags";
+// expects: node_id & node_tag_ids
//////////////////////////////
// sometimes we don't set 'action', but use the submit button name instead
break;
}
-//debug
+//uncomment for debugging incoming data
//$action='debug';
$person_id = $_POST['person_id']; // usually needed
if ( ! $action ) {
- drupal_set_message ("actions.php: action not set");
+ drupal_set_message ("actions.php: action not set or not in known_actions");
plc_debug('POST',$_POST);
return;
}
drupal_set_message("action=$action - No key selected");
return;
}
+ $success=true;
+ $counter=0;
foreach( $key_ids as $key_id ) {
- $api->DeleteKey( intval( $key_id ) );
+ if ($api->DeleteKey( intval( $key_id )) != 1)
+ $success=false;
+ else
+ $counter++;
}
+ if ($success)
+ drupal_set_message ("Deleted $counter key(s)");
+ else
+ drupal_set_error ("Could not delete all selected keys, only $counter were removed");
plc_redirect(l_person($person_id));
}
$key = fread($fp, filesize($key_file));
fclose($fp);
- $key_id= $api->AddPersonKey( intval( $person_id ), array( "key_type"=> 'ssh', "key"=> $key ) );
+ $key_id = $api->AddPersonKey( intval( $person_id ), array( "key_type"=> 'ssh', "key"=> $key ) );
+
+ if ( $key_id == 1)
+ drupal_set_message ("New key added");
+ else
+ drupal_set_error("Could not add key, please verify your SSH file content\n" . $api->error());
- if ( ! $key_id ) {
- $error= $api->error();
- plc_error("$error");
- plc_error("Please verify your SSH file content");
- return;
- }
plc_redirect(l_person($person_id));
}
$update_vals['url']= $url;
$update_vals['bio']= $bio;
- if( $password1 != "" )
+ if ( $password1 != "" )
$update_vals['password']= $password1;
- $rc= $api->UpdatePerson( intval( $person_id ), $update_vals);
-
- if ( $rc == 1 ) {
+ if ( $api->UpdatePerson( intval( $person_id ), $update_vals) == 1 )
drupal_set_message("$first_name $last_name updated");
- } else {
+ else
drupal_set_error ("Could not update person $person_id" . $api->error());
- }
+
plc_redirect(l_person($person_id));
break;
}
break;
}
+//////////////////////////////////////////////////////////// interfaces
+ case 'delete-interfaces' : {
+ $interface_ids=$_POST['interface_ids'];
+ if ( ! $interface_ids) {
+ drupal_set_message("action=$action - No interface selected");
+ return;
+ }
+ $success=true;
+ $counter=0;
+ foreach( $interface_ids as $interface_id ) {
+ if ($api->DeleteInterface( intval( $interface_id )) != 1)
+ $success=false;
+ else
+ $counter++;
+ }
+ if ($success)
+ drupal_set_message ("Deleted $counter interface(s)");
+ else
+ drupal_set_error ("Could not delete all selected interfaces, only $counter were removed");
+ plc_redirect(l_node($_POST['node_id']));
+ }
+
+
+
//////////////////////////////////////////////////////////// sites
case 'delete-site': {
$site_id = intval($_POST['site_id']);
else
drupal_set_error("Failed to delete site $site_id");
plc_redirect (l_sites());
+ break;
}
case 'expire-all-slices-in-site': {
// update site to not allow slice creation or renewal
$api->UpdateSite( $site_id, array( "max_slices" => 0 )) ;
plc_redirect (l_site($site_id));
+ break;
+ }
+
+ case 'update-site': {
+ $site_id=intval($_POST['site_id']);
+ $name= $_POST['name'];
+ $abbreviated_name= $_POST['abbreviated_name'];
+ $url= $_POST['url'];
+ $latitude= floatval($_POST['latitude']);
+ $longitude= floatval($_POST['longitude']);
+ //$max_slivers= $_POST['max_slivers'];
+
+ $fields= array( "name" => $name,
+ "abbreviated_name" => $abbreviated_name,
+ "url" => $url,
+ "latitude" => floatval( $latitude ),
+ "longitude" => floatval( $longitude ));
+
+ if ($_POST['login_base'])
+ $fields['login_base'] = $_POST['login_base'];
+ if ($_POST['max_slices'])
+ $fields['max_slices'] = intval($_POST['max_slices']);
+
+ $retcod=$api->UpdateSite( intval( $site_id ), $fields );
+ if ($retcod == 1)
+ drupal_set_message("Site $name updated");
+ else
+ drupal_set_error ("Could not update site $site_id");
+
+ plc_redirect(l_site($site_id));
+ break;
}
//////////////////////////////////////////////////////////// tags
case 'update-tag-type': {
// get post vars
$tag_type_id= intval( $_POST['tag_type_id'] );
- $name = $_POST['name'];
+ $tagname = $_POST['tagname'];
$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,
+ "tagname" => $tagname,
"description" => $description,
"category" => $category,
);
- // Update it!
- $api->UpdateTagType( $tag_type_id, $tag_type_fields );
-
+ if ($api->UpdateTagType( $tag_type_id, $tag_type_fields ) == 1)
+ drupal_set_message ("Tag type $tagname updated");
+ else
+ drupal_set_error ("Could not update tag type $tag_type_id\n".$api->error());
plc_redirect(l_tag($tag_type_id));
}
case 'add-tag-type': {
// get post vars
- $name = $_POST['name'];
+ $tagname = $_POST['tagname'];
$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,
+ "tagname" => $tagname,
"description" => $description,
"category" => $category,
);
// Add it!
- $id=$api->AddTagType( $tag_type_fields );
- drupal_set_message ("tag type $id created");
-
- plc_redirect( l_tag($id));
+ $tag_type_id=$api->AddTagType( $tag_type_fields );
+ if ($tag_type_id > 0)
+ drupal_set_message ("tag type $tag_type_id created");
+ else
+ drupal_set_error ("Could not create tag type $tagname");
+ plc_redirect( l_tags());
}
case 'set-tag-on-node': {
plc_redirect (l_node($node_id));
}
+ case 'delete-tag-types': {
+ $tag_type_ids = $_POST['tag_type_ids'];
+ if ( ! $tag_type_ids) {
+ drupal_set_message("action=$action - No tag selected");
+ return;
+ }
+ $success=true;
+ $counter=0;
+ foreach ($tag_type_ids as $tag_type_id)
+ if ($api->DeleteTagType(intval($tag_type_id)) != 1)
+ $success=false;
+ else
+ $counter++;
+ if ($success)
+ drupal_set_message ("Deleted $counter tag(s)");
+ else
+ drupal_set_error ("Could not delete all selected tags, only $counter were removed");
+ plc_redirect (l_tags());
+ break;
+ }
+
+//////////////////////////////////////// node tags
+ case 'delete-node-tags' : {
+ $node_tag_ids=$_POST['node_tag_ids'];
+ if ( ! $node_tag_ids) {
+ drupal_set_message("action=$action - No node tag selected");
+ return;
+ }
+ $success=true;
+ $counter=0;
+ foreach( $node_tag_ids as $node_tag_id ) {
+ if ($api->DeleteNodeTag( intval( $node_tag_id )) != 1)
+ $success=false;
+ else
+ $counter++;
+ }
+ if ($success)
+ drupal_set_message ("Deleted $counter node tag(s)");
+ else
+ drupal_set_error ("Could not delete all selected node tags, only $counter were removed");
+ plc_redirect(l_node($_POST['node_id']));
+ }
+
+
////////////////////////////////////////
case 'debug': {
margin: 0 auto 1.5em auto;
border-collapse:collapse;
}
+
+table.plc_details>tbody>tr>th {
+ text-align: right;
+ font: bold 14px "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif;
+}
background: #CAE8EA url(/planetlab/icons/tablesort_header.jpg) no-repeat;
vertical-align:middle;
}
-table.plc_table>tbody>tr>td {
+table.plc_table>tbody>tr>td, table.plc_table textarea, table.plc_table input [type="text"] {
font: normal 11px "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif;
border-right: 1px solid #C1DAD7;
border-bottom: 1px solid #C1DAD7;
+}
+table.plc_table>tbody>tr>td {
padding: 6px 12px 6px 12px;
color: #4f6b72;
}
$this->field_height="2";
}
+ function form() { return $this->form; }
+
// start the details area, with an optional caption
function start ($caption="") { print $this->start_html("$caption");}
function start_html ($caption="") {
} else {
$html="";
$html .= "<tr><th><label for=$form_varname>$title</label></th>";
- $html .= "<td><input type='$this->input_type' name='$form_varname' value='$value'";
- if ($this->input_type == "textarea") {
- if ($this->field_width) $html .= " cols=$this->field_width/";
- if ($this->field_height) $html .= " rows=$this->field_height/";
+ $html .= "<td>";
+ // hack: if input_type is select : user provides the input field verbatim
+ if ( $this->input_type == "select" ) {
+ $html .= $value;
+ } else if ($this->input_type == "textarea") {
+ $html .= "<textarea name='$form_varname'";
+ if ($this->field_width) $html .= " cols=$this->field_width";
+ if ($this->field_height) $html .= " rows=$this->field_height";
+ $html .= ">$value</textarea>";
} else {
- if ($this->field_width) $html .= " size=$this->field_width/";
+ $html .= "<input type='$this->input_type' name='$form_varname' value='$value'";
+ if ($this->field_width) $html .= " size=$this->field_width";
+ $html .= "/>";
}
- $html .= "></td></tr>";
+ $html .= "</td></tr>";
return $html;
}
}
$html .= "</select>";
return $html;
}
+
+ // helper function to handle role-oriented selectors
+ // because GetRoles does not correctly support filters, it's really painful to do this
+ static public function role_selectors($api,$role_ids=NULL,$current=NULL) {
+ function role_selector ($role) { return array('display'=>$role['name'],"value"=>$role['role_id']); }
+ function role_id ($role) { return $role['role_id']; }
+
+ $all_roles=$api->GetRoles();
+ if ( ! $role_ids)
+ $role_ids=array_map("role_id",$all_roles);
+
+ $selectors=array();
+ // preserve input order
+ foreach ($role_ids as $role_id) {
+ foreach ($all_roles as $all_role) {
+ if ($all_role['role_id'] == $role_id) {
+ $selector=role_selector($all_role);
+ if ($role_id == $current)
+ $selector['selected']=true;
+ $selectors []= $selector;
+ }
+ }
+ }
+ return $selectors;
+ }
+
+ static public function role_selectors_excluding ($api,$exclude_role_ids=NULL,$current=NULL) {
+ if ( ! $exclude_role_ids ) $exclude_role_ids = array();
+ $all_roles=$api->GetRoles();
+ $role_ids = array();
+ foreach ($all_roles as $role) {
+ if ( ! in_array ($role['role_id'],$exclude_role_ids)) {
+ $role_ids [] = $role['role_id'];
+ }
+ }
+ return PlcForm::role_selectors($api,$role_ids,$current);
+ }
}
// a form with a single button
// $Id$
// will trash this eventually
-require_once 'plc_functions_trash.php';
+ //require_once 'plc_functions_trash.php';
// utility
function my_is_int ($x) {
function l_nodes_peer ($peer_id) { return "/db/nodes/index.php?peerscope=$peer_id"; }
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_obj($node) { return href(l_node($node['node_id']),$node['hostname']); }
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_interface ($interface_id) { return "/db/nodes/interfaces.php?id=$interface_id"; }
+function l_interface ($interface_id) { return "/db/nodes/interface.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/interface.php?node_id=$node_id"; }
function l_sites () { return "/db/sites/index.php"; }
function l_sites_peer ($peer_id) { return "/db/sites/index.php?peerscope=$peer_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_site_update($site_id) { return "/db/sites/site_update.php?site_id=$site_id"; }
function l_slices () { return "/db/slices/index.php"; }
function l_slices_peer ($peer_id) { return "/db/slices/index.php?peerscope=$peer_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_slice_add () { return "/db/slices/slice_add.php"; }
function l_slices_site($site_id) { return "/db/slices/index.php?site_id=$site_id"; }
// from an object
function l_slice_obj ($slice) { return l_slice_t ($slice['slice_id'],$slice['name']); }
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_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_tag ($tag_type_id) { return "/db/tags/index.php?id=$tag_type_id"; }
+function l_tag_obj ($tag) { return href(l_tag($tag['tag-type_id']),$tag['tagname']); }
function l_nodegroups () { return "/db/tags/nodegroups.php"; }
function l_nodegroup ($nodegroup_id) { return "/db/tags/nodegroup.php?id=$nodegroup_id"; }
// builds a table from an array of strings, with the given class
// attempt to normalize the delete buttons and confirmations
function plc_delete_icon($width=15) {
- return '<span title="Delete this entry"><img width=' . $width . ' alt="Delete this entry" src="/planetlab/icons/delete.png"></span>';
+ return "<img width='$width' src='/planetlab/icons/delete.png'>";
}
-function plc_js_confirm($message) {
- return "onclick=\"javascript:return confirm('Are you sure you want to delete " . $message . " ?')\"";
+function plc_bubble($text,$bubble) {
+ return "<span title='$bubble'>$text</span>";
}
-
-function plc_delete_link($url,$delete_message,$visible) {
- return "<a href='" . $url . "' " . plc_js_confirm($delete_message) . ">" . $visible . "</a>";
-}
-
-function plc_delete_link_button($url,$delete_message,$width=15) {
- return "<a href='" . $url . "' " . plc_js_confirm($delete_message) . ">" . plc_delete_icon($width) . "</a>";
+function plc_delete_icon_bubble ($bubble,$width=15) {
+ return plc_bubble(plc_delete_icon($width),$bubble);
}
function plc_event_button($type,$param,$id) {
return $diff;
}
+// obsolete ?
+function plc_js_confirm($message) {
+ return "onclick=\"javascript:return confirm('Are you sure you want to delete " . $message . " ?')\"";
+}
+
+function plc_delete_link($url,$delete_message,$visible) {
+ return "<a href='" . $url . "' " . plc_js_confirm($delete_message) . ">" . $visible . "</a>";
+}
+
+function plc_delete_link_button($url,$delete_message,$width=15) {
+ return "<a href='" . $url . "' " . plc_js_confirm($delete_message) . ">" .
+ plc_delete_icon_bubble($width,"Delete this entry") .
+ "</a>";
+}
+
?>
public function start () {
$paginator=$this->table_id."_paginator";
$classname="paginationcallback-".$paginator;
- $classname.=" max-pages-" . $max_pages;
- $classname.=" paginate-" . $pagesize;
+ $classname.=" max-pages-" . $this->max_pages;
+ $classname.=" paginate-" . $this->pagesize;
// instantiate paginator callback
print <<< EOF
<script type="text/javascript">
$result= <<< EOF
<tr class=pagesize_area><td class=pagesize_area colspan=$width><form class='pagesize'>
<input class='pagesize_input' type='text' id="$pagesize_text_id" value=$this->pagesize
- onkeyup='plc_pagesize_set("$this->table_id","$this->pagesize_text_id", $this->pagesize);'
+ onkeyup='plc_pagesize_set("$this->table_id","$pagesize_text_id", $this->pagesize);'
size=3 maxlength=3 />
<label class='pagesize_label'> items/page </label>
<img class='table_reset' src="/planetlab/icons/clear.png"
include 'plc_header.php';
// Start form
-$action= "interfaces.php";
+$action= "interface.php";
if( isset( $id ) ) {
$action.= "?id=" . $interface['interface_id'];
}
require_once 'plc_tables.php';
require_once 'plc_details.php';
require_once 'plc_forms.php';
+require_once 'plc_objects.php';
// --------------------
// recognized URL arguments
$details->space();
}
-$details->form_start(l_actions(),array("action"=>"update-node",
- "node_id"=>$node_id));
+$details->form_start(l_actions(),array("action"=>"update-node", "node_id"=>$node_id));
$details->line("Hostname",$hostname,"hostname");
$details->line("Model",$model,"model");
$details->line("",$details->submit_html("submit","Update Node"));
$details->form_end();
+
$details->line("Type",$node_type);
$details->line("Version",$version);
+// let's use plc_objects
+$Node = new Node($node);
+$details->line("Date created",$Node->dateCreated());
+$details->line("Last contact",$Node->lastContact());
+$details->line("Last update",$Node->lastUpdated());
// boot area
$details->space ();
$headers=array("Name"=>"string",
"Value"=>"string",
"Nodegroup"=>"string",
- "Remove"=>"string",
);
+ if (plc_is_admin()) $headers[plc_delete_icon()]="none";
$table_options=array("notes_area"=>false,"pagesize_area"=>false,"search_width"=>10);
$table=new PlcTable("node_tags",$headers,0,$table_options);
$nodegroup=$nodegroups_hash[$nodegroup_key];
if ($nodegroup) $nodegroup_name=l_nodegroup_t($nodegroup['nodegroup_id'],$nodegroup['groupname']);
$table->row_start();
- $table->cell($tag['tagname']);
+ $table->cell(l_tag_obj($tag));
$table->cell($tag['value']);
$table->cell($nodegroup_name);
// the remove checkbox
- $table->cell ($form->checkbox_html('node_tag_ids[]',$tag['node_tag_id']));
+ if (plc_is_admin()) $table->cell ($form->checkbox_html('node_tag_ids[]',$tag['node_tag_id']));
$table->row_end();
}
// remove tag
$table->row_start();
- $table->cell($form->submit_html("remove-node-tags","Remove Tags"),
+ $table->cell($form->submit_html("delete-node-tags","Remove Tags"),
// use the whole columns and right adjust
$table->columns(), "right");
$table->row_end();
echo "Please add an interface to make this a usable PLC node.</p>\n";
} else {
$headers=array();
- if ( $privileges ) {
- // a single symbol, marking 'p' for primary and a delete button for non-primary
- $headers[' ']='string';
- }
-
+
$headers["IP"]="IPAddress";
$headers["Method"]="string";
$headers["Type"]="string";
$headers["MAC"]="string";
$headers["bw limit"]="FileSize";
+ // a single symbol, marking 'p' for primary and a delete button for non-primary
+ if ( $privileges ) $headers[plc_delete_icon()]='string';
$table_options=array('search_area'=>false,"pagesize_area"=>false,'notes_area'=>false);
$table=new PlcTable("node_interfaces",$headers,2,$table_options);
$interface_method= $interface['method'];
$table->row_start();
- if ( $privileges ) {
- if (!$interface_primary) {
- // xxx
- $table->cell (plc_delete_link_button ('interfaces.php?id=' . $interface_id . '&delete=1&submitted=1',
- '\\nInterface ' . $interface_ip));
- } else {
- $table->cell('p');
- }
- }
$table->cell(l_interface_t($interface_id,$interface_ip));
$table->cell($interface_method);
$table->cell($interface_type);
$table->cell($interface_mac);
$table->cell($interface_bwlimit);
+ if ( $privileges ) {
+ if ($interface_primary) {
+ $table->cell(plc_bubble("p","Cannot delete a primary interface"));
+ } else {
+ $table->cell ($form->checkbox_html('interface_ids[]',$interface_id));
+ }
+ }
$table->row_end();
}
if ($privileges) {
$table->tfoot_start();
$table->row_start();
- $button=new PlcFormButton (l_interface_add($node_id),"add_interface","Add interface","GET");
- $table->cell($button->html(), $table->columns(),"right");
+ $add_button=new PlcFormButton (l_interface_add($node_id),"add_interface","Add interface");
+ // we should have 6 cols, use 3 for the left (new) and the rest for the right (remove)
+ $table->cell($add_button->html(), 3,"left");
+ $table->cell($form->submit_html("delete-interfaces","Remove Interfaces"), $table->columns()-3,"right");
$table->row_end();
}
$table->end();
print( "<td>" . $node_detail['hostname'] . "</td></tr>\n" );
$nn_id = $interface_detail['interface_id'];
- print( "<tr><th colspan=2><a href='interfaces.php?id=$nn_id'>Interface Details</a></th></tr>" );
+ print( "<tr><th colspan=2><a href='interface.php?id=$nn_id'>Interface Details</a></th></tr>" );
print( "<tr><th>Method:</th>" );
print( "<td>" . $interface_detail['method'] . "</td></tr>\n" );
}
}
- print ("<tr><th colspan=2><a href='interfaces.php?id=$nn_id'>Additional Settings</a></th></tr>\n");
+ print ("<tr><th colspan=2><a href='interface.php?id=$nn_id'>Additional Settings</a></th></tr>\n");
$nn_id = $interface_detail['interface_id'];
$settings=$api->GetInterfaceTags(array("interface_id" => array($nn_id)));
foreach ($settings as $setting) {
$tabs=array();
-// update
-//if ($privileges || $is_my_account)
-// $tabs['Update'] = array('url'=>'/db/persons/update.php',
-// 'values'=>array('id'=>$person_id),
-// 'bubble'=>"Update $first_name $last_name");
-//
// enable / disable
if ($local_peer && $privileges)
if ($enabled)
if ($local_peer && $privileges && ! $enabled )
drupal_set_message ("$first_name $last_name is not enabled yet, you can enable her/him with the 'Enable' button below");
-$enabled_label="Enabled";
+$enabled_label="Yes";
if ( ! $enabled ) $enabled_label = plc_warning_html("Disabled");
$can_update = $is_my_account || plc_is_admin();
$details = new PlcDetails($can_update);
+
+$details->form_start(l_actions(),array("action"=>"update-person",
+ "person_id"=>$person_id));
$details->start();
$details->line("Enabled",$enabled_label);
+$details->line("Peer",$peers->peer_link($peer_id));
$details->space();
-$details->form_start(l_actions(),array("action"=>"update-person",
- "person_id"=>$person_id));
+// xxx this needs some more work on the PlcDetails class
+$details->set_field_width(5);
$details->line("Title",$title,"title");
+$details->set_field_width("");
$details->line("First Name",$first_name,"first_name");
$details->line("Last Name",$last_name,"last_name");
$details->line(href("mailto:$email","Email"),$email,"email");
-$details->line("URL",$url,"url");
$details->line("Phone",$phone,"phone");
-$details->line("Bio",wordwrap($bio,50,"<br/>"),"bio");
+$save_w=$details->set_field_width(40);
+$details->line("URL",$url,"url");
+$details->set_field_height(4);
+$details->set_input_type("textarea");
+$details->line("Bio",$bio,"bio");
+$details->set_input_type("text");
+$details->set_field_width($save_w);
+
// xxx need to check that this is working
if ($can_update) {
- $save=$details->set_input_type("password");
+ $save_i=$details->set_input_type("password");
$details->line("Password","","password1");
$details->line("Repeat","","password2");
- $details->set_input_type($save);
+ $details->set_input_type($save_i);
}
// xxx need fields to reset password ?
$details->line("",$details->submit_html("submit","Update Account"));
-$details->form_end();
-$details->line("Peer",$peers->peer_link($peer_id));
$details->end();
+$details->form_end();
//////////////////// slices
plc_section('Slices');
plc_warning("This user has no known key");
}
-// headers
$headers=array("Type"=>"string",
"Key"=>"string");
-if ($can_manage_keys) $headers['Remove']="none";
+if ($can_manage_keys) $headers[plc_delete_icon()]="none";
// table overall options
$table_options=array('search_area'=>false,'pagesize_area'=>false,'notes_area'=>false);
$table=new PlcTable("person_keys",$headers,"1",$table_options);
$table->row_end();
}
$table->row_start();
- $table->cell($form->label_html("key","Upload new key") . $form->file_html("key",60),
- $table->columns()-1,"right");
- $table->cell($form->submit_html("upload-key","Upload key"));
+ $table->cell($form->label_html("key","Upload new key")
+ . $form->file_html("key",60)
+ . $form->submit_html("upload-key","Upload key"),
+ $table->columns(),"right");
$table->row_end();
}
//////////////////// sites
plc_section('Sites');
-// sites
if (empty( $sites ) ) {
plc_warning('This user is not affiliated with a site !!');
}
$headers=array();
$headers['Login_base']="string";
$headers['Name']="string";
-if ($can_manage_sites)
- $headers['Remove']="string";
+if ($can_manage_sites) $headers[plc_delete_icon()]="none";
$table_options = array('notes_area'=>false,'search_area'=>false, 'pagesize_area'=>false);
$table=new PlcTable ("person_sites",$headers,0,$table_options);
$table->start();
$person_site_ids=array_map("get_site_id",$sites);
$relevant_sites= $api->GetSites( array("peer_id"=>NULL,"~site_id"=>$person_site_ids), $site_columns);
// xxx cannot use onchange=submit() - would need to somehow pass action name
- function select_arguments($site) { return array('display'=>$site['name'],"value"=>$site['site_id']); }
- $selectors = array_map ("select_arguments",$relevant_sites);
+ function site_selector($site) { return array('display'=>$site['name'],"value"=>$site['site_id']); }
+ $selectors = array_map ("site_selector",$relevant_sites);
$table->cell ($form->select_html("site_id",$selectors,"Choose a site to add").
$form->submit_html("add-person-to-site","Add in site"),
$table->columns(),"right");
$can_manage_roles= ($local_peer && plc_is_admin());
$table_options=array("search_area"=>false,"notes_area"=>false);
-$headers=array("Role"=>"none");
-if ($can_manage_roles) $headers ["Remove"]="none";
+$headers=array("Role"=>"string");
+if ($can_manage_roles) $headers [plc_delete_icon()]="none";
$table_options=array('search_area'=>false,'pagesize_area'=>false,'notes_area'=>false);
$table=new PlcTable("person_roles",$headers,0,$table_options);
}
$table->row_start();
- // get list of local roles that the person has not yet
- // xxx this does not work because GetRoles does not support filters
- $relevant_roles = $api->GetRoles( array("~role_id"=>$role_ids));
- function selector_argument ($role) { return array('display'=>$role['name'],"value"=>$role['role_id']); }
- $selectors=array_map("selector_argument",$relevant_roles);
- $add_role_left_area=$form->select_html("role_id",$selectors,"Choose a role to add");
+ $selectors=$form->role_selectors_excluding($api,$role_ids);
+ $add_role_left_area=$form->select_html("role_id",$selectors,"Choose role");
// add a role : the button
$add_role_right_area=$form->submit_html("add-role-to-person","Add role");
$table->cell ($add_role_left_area . $add_role_right_area,
$site=$sites[0];
// var names to api return
$sitename= htmlentities($site['name']);
-$abbrev_name= htmlentities($site['abbreviated_name']);
+$abbreviated_name= htmlentities($site['abbreviated_name']);
$site_url= $site['url'];
$login_base= $site['login_base'];
$site_lat= $site['latitude'];
$techs = array();
$pis = array();
+$disabled_persons = array();
foreach( $persons as $person ) {
$role_ids= $person['role_ids'];
- if( in_array( '40', $role_ids ))
- $techs[] = $person;
-
- if( in_array( '20', $role_ids ))
- $pis[] = $person;
+
+ if ( in_array( '20', $role_ids )) $pis[] = $person;
+ if ( in_array( '40', $role_ids )) $techs[] = $person;
+ if ( ! $person['enabled'] ) $disabled_persons[] = $person;
}
// available actions
if ( $local_peer && $privileges ) {
- $tabs['Update']=array('url'=>l_site_update($site_id),
- 'bubble'=>"Update details of $sitename");
- // not avail to PI
$tabs['Expire slices'] = array('url'=>l_actions(),
'method'=>'POST',
'values'=>array('site_id'=>$site_id,
$can_update=plc_is_admin () || ( plc_in_site($site_id) && plc_is_pi());
$details = new PlcDetails($can_update);
-// XXX make this updatable
+
+if ( ! $site['is_public'])
+ plc_warning("This site is not public!");
+
$details->start();
-$details->line("Full name",$sitename);
-$details->line("Login base",$login_base);
-$details->line("Abbreviated name",$abbrev_name);
-$details->line("URL",$site_url);
-$details->line("Latitude",$site_lat);
-$details->line("Longitude",$site_long);
$details->line("Peer",$peers->peer_link($peer_id));
+$details->space();
+
+$details->form_start(l_actions(),array('action'=>'update-site','site_id'=>$site_id));
+$save_w=$details->set_field_width(30);
+$details->line("Full name",$sitename,'name');
+$details->set_field_width($save_w);
+$details->line("Abbreviated name",$abbreviated_name,'abbreviated_name');
+$details->line("URL",$site_url,'url');
+$details->line("Latitude",$site_lat,'latitude');
+$details->line("Longitude",$site_long,'longitude');
+if (plc_is_admin())
+ $details->line("Login base",$login_base,'login_base');
+else
+ $details->line("Login base",$login_base);
+if (plc_is_admin())
+ $details->line("Max slices",$max_slices,'max_slices');
+else
+ $details->line("Max slices",$max_slices);
+$details->line("",$details->submit_html("submit","Update Site"));
+$details->form_end();
if ( $local_peer ) {
$details->line("# Nodes", href(l_nodes_site($site_id),$node_label));
function n_link ($n) { return l_node_t($n['node_id'],$n['hostname'] . " (" . $n['boot_state'] . ")");}
$nodes_label= plc_vertical_table(array_map ("n_link",$nodes));
- $details->line ("hostnames",$nodes_label);
-
+ $details->line ("Hostnames",$nodes_label);
+ $button=new PlcFormButton (l_node_add(),"add_node","Add node","POST");
+ $details->line("",$button->html());
// Users
$details->space();
- $user_label = count($person_ids) . " total / " .
+ $user_label = count($person_ids) . " Total / " .
count ($pis) . " PIs / " .
- count ($techs) . " techs";
+ count ($techs) . " Techs";
if ( (count ($pis) == 0) || (count ($techs) == 0) || (count($person_ids) >=50))
$user_label = plc_warning_html ($user_label);
$details->line ("# Users",href(l_persons_site($site_id),$user_label));
// PIs
$details->line("PI's",plc_vertical_table (array_map ("p_link",$pis)));
// techs
- $details->line("techs's",plc_vertical_table (array_map ("p_link",$techs)));
-
+ $details->line("Techs's",plc_vertical_table (array_map ("p_link",$techs)));
+ if (count ($disabled_persons))
+ $details->line("Disabled",plc_vertical_table (array_map ("p_link",$disabled_persons)));
// Slices
$details->space();
$details->line("# Slices", href(l_slices_site($site_id),$slice_label));
if ($slices) foreach ($slices as $slice)
$details->line($slice['instantiation'],l_slice_obj($slice));
+ $button=new PlcFormButton (l_slice_add(),"slice_add","Add slice","POST");
+ $details->line("",$button->html());
// Addresses
if ($addresses) {
+++ /dev/null
-<?php
-
-// Require login
-require_once 'plc_login.php';
-
-// Get session and API handles
-require_once 'plc_session.php';
-global $plc, $api;
-
-// Common functions
-require_once 'plc_functions.php';
-require_once 'plc_sorts.php';
-
-// find person roles
-$_person= $plc->person;
-$_roles= $_person['role_ids'];
-
-// redirect if no site id is set add instead
-if( $_GET['site_id'] ) {
- $site_id= $_GET['site_id'];
- $do= 'Update';
- } else {
- $do= 'Add';
- }
-
-// if form not submitted get data from API
-if( $_POST['submitted'] ) {
-
- $name= $_POST['name'];
- $abbrev_name= $_POST['abbrev_name'];
- $url= $_POST['url'];
- $login_base= $_POST['login_base'];
- $latitude= $_POST['latitude'];
- $longitude= $_POST['longitude'];
- //$max_slivers= $_POST['max_slivers'];
- $max_slices= $_POST['max_slices'];
-
-
- if( $name == "" )
- $error['name']= "<font color=red>Name can not be blank.</font>";
-
- if( $abbrev_name == "" )
- $error['abbrev_name']= "<font color=red>Abbreviated Name can not be blank.</font>";
-
- if( $login_base == "" )
- $error['login_base']= "<font color=red>Login Base can not be blank.</font>";
-
- if( $url == "" || $url == "http://" )
- $error['url']= "<font color=red>URL can not be blank.</font>";
-
- if( !is_numeric( $latitude ) )
- $error['latitude']= "<font color=red>Latitude must be a number.</font>";
-
- if( !is_numeric( $longitude ) )
- $error['longitude']= "<font color=red>Longitude must be a number.</font>";
-
- if( !is_numeric( $max_slices ) )
- $error['max_slices']= "<font color=red>Max Slices must be a number.</font>";
-
-
- // if no errors add/update site
- if ( $do == 'Add' ) {
- $fields= array( "name" => $name,
- "abbreviated_name" => $abbrev_name,
- "url" => $url,
- "login_base" => $login_base,
- "latitude" => floatval( $latitude ),
- "longitude" => floatval( $longitude ),
- "max_slices" => 0,
- "is_public" => true);
- $site_id=$api->AddSite( $fields );
- plc_redirect(l_site($site_id));
- }
-
- if ( $do == 'Update' ) {
- $fields= array( "name" => $name,
- "abbreviated_name" => $abbrev_name,
- "url" => $url,
- "login_base" => $login_base,
- "latitude" => floatval( $latitude ),
- "longitude" => floatval( $longitude ),
- "max_slices" => intval( $max_slices ),
- "is_public" => true);
- $api->UpdateSite( intval( $site_id ), $fields );
- // Thierry aug 31 07 - redirect to the site's details page
- plc_redirect(l_site($site_id));
- }
-
-}
-
-// if its an update get site info$max_slices &&
-if( $do == 'Update' && empty( $error ) ) {
- // Get site api call
- $site_info= $api->GetSites( array( intval( $site_id ) ), array( "name", "url", "longitude", "latitude", "login_base", "max_slices", "abbreviated_name" ) );
-
- // var names to api return
- $name= $site_info[0]['name'];
- $abbrev_name= $site_info[0]['abbreviated_name'];
- $url= $site_info[0]['url'];
- $login_base= $site_info[0]['login_base'];
- $latitude= $site_info[0]['latitude'];
- $longitude= $site_info[0]['longitude'];
- //$max_slivers= $site_info[0]['max_slivers'];
- $max_slices= $site_info[0]['max_slices'];
-
-}
-
-// Print header
-require_once 'plc_drupal.php';
-drupal_set_title('Sites');
-include 'plc_header.php';
-
-// set error styles
-if( $error['name'] )
- $name_err= " style='border: 1px solid red;'";
-
-if( $error['abbrev_name'] )
- $abbrev_err= " style='border: 1px solid red;'";
-
-if( $error['login_base'] )
- $base_err= " style='border: 1px solid red;'";
-
-if( $error['url'] )
- $url_err= " style='border: 1px solid red;'";
-
-if( $error['latitude'] )
- $lat_err= " style='border: 1px solid red;'";
-
-if( $error['longitude'] )
- $long_err= " style='border: 1px solid red;'";
-
-if( $error['max_slices'] )
- $max_err= " style='border: 1px solid red;'";
-
-// start form
-
-echo "<form action='site_update.php?id=$site_id' method='post'>\n";
-echo "<h2>$do $name</h2>\n";
-
-echo "<table><tbody>\n";
-// Thierry - displays name under double quotes - some site names have single quotes, none have double quotes as of now
-echo "<tr><th>Name: </th><td> <input type=text $name_err name='name' value=\"$name\" size=40></td><td>". $error['name'] ."</td></tr>\n";
-echo "<tr><th>Abbreviated Name: </th><td> <input type=text $abbrev_err name='abbrev_name' value='$abbrev_name' size=40></td><td>". $error['abbrev_name'] ."</td></tr>\n";
-echo "<tr><th>Login Base: </th><td> <input type=text $base_err name='login_base' value='$login_base' size=40></td><td>". $error['login_base'] ."</td></tr>\n";
-echo "<tr><th>URL: </th><td> <input type=text $url_err name='url' value='$url' size=40></td><td>". $error['url'] ."</td></tr>\n";
-echo "<tr><th>Latitude/Longitude: </th><td> <input type=text $lat_err name='latitude' value='$latitude' size=10> / <input type=text $long_err name='longitude' value='$longitude' size=10></td><td>". $error['latitude'] ." ". $error['longitude'] ."</td></tr>\n";
-
-if( in_array( 10, $_roles ) ) {
- echo "<tr><th>Max Slices: </th><td> <input type=text $max_err name='max_slices' value='$max_slices'"; if( !in_array( '10', $_roles ) ) echo " disabled"; echo " size=10></td><td>". $error['max_slices'] ."</td></tr>\n";
-}
-else
- echo "<tr><td colspan=3><input type=hidden name='max_slices' value='$max_slices'></td></tr>\n";
-
-echo "<tr><td></td><td colspan=2><input type=submit name='submitted' value='$do Site'></td></tr>\n";
-echo "</tbody></table><br />\n";
-echo "</form>\n";
-
-if ($do == "Update")
- print href(l_site($site_id),"Back to site");
- else
- print href(l_sites(),"Back to sites");
-
-
-// Print footer
-include 'plc_footer.php';
-
-?>
if ($nb_pis == 0) $messages [] = "No PI";
if ($nb_techs == 0) $messages [] = "No Tech";
+ if (! $site['is_public']) $messages []= "Not public";
+
// check number of slices
if ( $site['max_slices'] == 0) {
$messages [] = "No slice allowed";
// start form
-echo "<form action='add_slice.php' method=post>\n";
+echo "<form action='slice_add.php' method=post>\n";
if( $error['api'] )
echo "<font class='plc-warning'>". $error['api'] ."</font>\n";
// Print header
require_once 'plc_drupal.php';
-#drupal_set_title('Login');
+require_once 'plc_functions.php';
+
include 'plc_header.php';
// Invalidate session
<?php
+// $Id: index.php 11603 2009-01-19 16:44:53Z thierry $
+
// Require login
require_once 'plc_login.php';
-// Get session and API handles
-require_once 'plc_session.php';
-global $plc, $api;
-
-// Print header
-require_once 'plc_drupal.php';
-include 'plc_header.php';
-
-// Common functions
-require_once 'plc_functions.php';
-
-// add or update
-if ( $_GET['action'] ) {
- include 'tag_form.php';
-// list all
- } else if ( ! $_GET['add'] ) {
- include 'tags.php';
-// actually set a tag on an object
- } else {
- include 'tag_set.php';
- }
-
-// Print footer
-include 'plc_footer.php';
+if ($_GET['id']) require ('tag.php') ;
+else require ('tags.php');
?>
--- /dev/null
+<?php
+
+// $Id$
+
+// Require login
+require_once 'plc_login.php';
+
+// Get session and API handles
+require_once 'plc_session.php';
+global $plc, $api;
+
+// Print header
+require_once 'plc_drupal.php';
+include 'plc_header.php';
+
+// Common functions
+require_once 'plc_functions.php';
+require_once 'plc_minitabs.php';
+require_once 'plc_details.php';
+require_once 'plc_tables.php';
+require_once 'plc_forms.php';
+
+// --------------------
+// recognized URL arguments
+$tag_type_id=intval($_GET['id']);
+if ( ! $tag_type_id ) {
+ plc_error('Malformed URL - id not set');
+ return;
+ }
+
+// --- decoration
+$title="Tag Type";
+$tabs=array();
+$tabs['All Types']=array('url'=>l_tags(),'bubble'=>"All Tag Types");
+
+// --------------------
+$tag_types= $api->GetTagTypes( array( $tag_type_id ) );
+$tag_type=$tag_types[0];
+
+$tagname=$tag_type['tagname'];
+$min_role_id= $tag_type['min_role_id'];
+$description= $tag_type['description'];
+$category=$tag_type['category'];
+
+// where is it used
+$filter=array('tag_type_id'=>$tag_type_id);
+$node_tags=$api->GetNodeTags($filter);
+$interface_tags=$api->GetInterfaceTags($filter);
+$slice_tags=$api->GetSliceTags(array_merge($filter,array("node_id"=>array())));
+$sliver_tags=$api->GetSliceTags(array_merge($filter,array("~node_id"=>array())));
+
+drupal_set_title("Details for tag type $tagname");
+plc_tabs($tabs);
+
+// ----------
+$can_update=plc_is_admin();
+$details=new PlcDetails ($can_update);
+
+$details->form_start(l_actions(),array("action"=>"update-tag-type",
+ "tag_type_id"=>$tag_type_id));
+$details->start();
+$details->line("Name",$tagname,"tagname");
+$details->line("Category",$category,"category");
+$details->line("Description",$description,"description");
+
+// xxx misses in PlcDetails
+if ($can_update) {
+//tmp
+// select the option corresponding with min_role_id
+ $selectors = $details->form()->role_selectors($api,"",$min_role_id);
+ $select_field = $details->form()->select_html("min_role_id",$selectors);
+ $save_i=$details->set_input_type("select");
+ $details->line("Min role",$select_field,"min_role_id");
+ $details->set_input_type($save_i);
+ } else {
+ $details->line("Min role",$min_role_id);
+ }
+if ($can_update)
+ $details->single($details->form()->submit_html('update-tag-type',"Update tag type"),"right");
+
+$details->space();
+$details->line("Used in nodes",count($node_tags));
+$details->line("Used in interfaces",count($interface_tags));
+$details->line("Used in slices",count($slice_tags));
+$details->line("Used in slivers",count($sliver_tags));
+
+$details->end();
+$details->form_end();
+
+// common options for tables below
+$table_options=array('notes_area'=>false, 'pagesize_area'=>false, 'search_width'=>10);
+
+// xxx could outline values corresponding to a nodegroup
+if (count ($node_tags)) {
+ plc_section("Nodes");
+ $table=new PlcTable ("tag_nodes",array("Hostname"=>"string","value"=>"string"),0,$table_options);
+ $table->start();
+ foreach ($node_tags as $node_tag) {
+ $table->row_start();
+ $table->cell(href(l_node($node_tag['node_id']),$node_tag['hostname']));
+ $table->cell($node_tag['value']);
+ $table->row_end();
+ }
+ $table->end();
+ }
+
+if (count ($interface_tags)) {
+ plc_section("Interfaces");
+ $table=new PlcTable ("tag_interfaces",array("IP"=>"IPAddress","value"=>"string"),0,$table_options);
+ $table->start();
+ foreach ($interface_tags as $interface_tag) {
+ $table->row_start();
+ $table->cell(href(l_interface($interface_tag['interface_id']),$interface_tag['ip']));
+ $table->cell($interface_tag['value']);
+ $table->row_end();
+ }
+ $table->end();
+ }
+
+// grouping both kinds of slice tags
+// xxx don't show hostnames yet
+$slice_tags = array_merge ($slice_tags,$sliver_tags);
+if (count ($slice_tags)) {
+ plc_section("Slice and sliver tags");
+ $table=new PlcTable ("tag_slices",array("Slice"=>"string","value"=>"string","Node id"=>"int"),0,$table_options);
+ $table->start();
+ foreach ($slice_tags as $slice_tag) {
+ $table->row_start();
+ $table->cell(href(l_slice($slice_tag['slice_id']),$slice_tag['name']));
+ $table->cell($slice_tag['value']);
+ $node_text="all";
+ // sliver tag
+ if ($slice_tag['node_id'])
+ $node_text=l_node($slice_tag['node_id'],$slice_tag['node_id']);
+ $table->cell($node_text);
+ $table->row_end();
+ }
+ $table->end();
+ }
+
+// Print footer
+include 'plc_footer.php';
+
+?>
}
-// delete tag types
-if( $_GET['del_type'] ) {
- // get vars
- $type_id= intval( $_GET['del_type'] );
-
- // delete it!
- $api->DeleteTagType( $type_id );
-
- plc_redirect( "tags.php?type=slice" );
-}
-
-
-
/*
// Print footer
include 'plc_footer.php';
+++ /dev/null
-<?php
-
-// $Id$
-
-// Require login
-require_once 'plc_login.php';
-
-// Get session and API handles
-require_once 'plc_session.php';
-global $plc, $api;
-
-// Print header
-require_once 'plc_drupal.php';
-include 'plc_header.php';
-
-// Common functions
-require_once 'plc_functions.php';
-require_once 'plc_minitabs.php';
-require_once 'plc_tables.php';
-require_once 'plc_details.php';
-require_once 'plc_forms.php';
-
-// to create a new (action=='add-tag-type')
-// or to update an existing (action='update-tag-type','tag_type_id'=<id>)
-
-// --------------------
-// 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_section($label,false);
-
-$form = new PlcForm (l_actions(),array());
-$form->start();
-// XXX make this updatable ?
-$details = new PlcDetails(false);
-$details->start();
-$details->line("Name", $form->text_html("name",$tagname,20));
-$details->line("Category", $form->text_html("category",$category,30));
-$details->line("Description",$form->textarea_html("description",$description,40,5));
-//tmp
-// select the option corresponding with min_role_id
-$selector = "<select name='min_role_id'>".
- "<option value='10'>Admin</option>".
- "<option value='20'>PI</option>".
- "<option value='30'>User</option>" .
- "<option value='40'>Tech</option>" . "</select>\n";
-$details->line("Min Role",$selector);
-if ($update_mode) {
- $submit=$form->hidden_html ('tag_type_id',$tag_type_id) .
- $form->submit_html('update-tag-type',"Update tag type");
- } else {
- $submit=$form->submit_html('add-tag-type',"Add tag type");
- }
-$details->single ($submit,"right");
-
-$details->end();
-$form->end();
-
-// Print footer
-include 'plc_footer.php';
-
-?>
// --- decoration
$title="Tag Types";
$tabs=array();
-$tabs['New Tag Type']=array('url'=>l_tag_add(),'bubble'=>"Create a new tag type");
+$tabs['Tag Types']=array('url'=>l_tags(),'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();
$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";
+$headers['Min role']="string";
+$headers["Id"]="int";
+if (plc_is_admin()) $headers[plc_delete_icon()]="none";
-$table = new PlcTable("tags",$headers,1);
+$form=new PlcForm(l_actions(),NULL);
+$form->start();
+
+$table = new PlcTable("tags",$headers,0);
$table->start();
$roles_hash=plc_role_global_hash($api);
+$description_width=40;
+
foreach( $tag_types as $tag_type ) {
$role_name=$roles_hash[$tag_type['min_role_id']];
$table->row_start();
- $id=$tag_type['tag_type_id'];
- if (plc_is_admin())
- // xxx this is deprecated
- $table->cell(plc_delete_link_button ('tag_action.php?del_type='. $id,
- $tag_type['tagname']));
- $table->cell($id);
- $table->cell(href(l_tag_update($id),$tag_type['tagname']));
- $table->cell(wordwrap($tag_type['description'],40,"<br/>"));
- $table->cell($role_name);
+ $tag_type_id=$tag_type['tag_type_id'];
+ $table->cell(href(l_tag($tag_type_id),$tag_type['tagname']));
+ $table->cell(wordwrap($tag_type['description'],$description_width,"<br/>"));
$table->cell($tag_type['category']);
+ $table->cell($role_name);
+ $table->cell($tag_type_id);
+ if (plc_is_admin())
+ $table->cell ($form->checkbox_html('tag_type_ids[]',$tag_type_id));
$table->row_end();
}
+
if (plc_is_admin()) {
$table->tfoot_start();
+
$table->row_start();
- $button=new PlcFormButton(l_tag_add(),"add_type_id","Add a Tag Type","GET");
- $table->cell ($button->html(), $table->columns(),"right");
+ $table->cell($form->submit_html ("delete-tag-types","Remove tags"),
+ $table->columns(),"right");
+ $table->row_end();
+
+ // an inline area to add a tag type
+ $table->row_start();
+
+ // build the role selector
+ $relevant_roles = $api->GetRoles( array("~role_id"=>$role_ids));
+ function selector_argument ($role) { return array('display'=>$role['name'],"value"=>$role['role_id']); }
+ $selectors=array_map("selector_argument",$relevant_roles);
+ $role_input=$form->select_html("min_role_id",$selectors,"Role");
+
+ $table->cell($form->text_html('tagname','',''));
+ $table->cell($form->textarea_html('description','',$description_width,2));
+ $table->cell($form->text_html('category','',''));
+ $table->cell($role_input);
+ $table->cell($form->submit_html("add-tag-type","Add Type"),2);
$table->row_end();
}
$table->end();
+$form->end();
// Print footer
include 'plc_footer.php';