add delete-slice action that is used by the interface.
[plewww.git] / planetlab / common / actions.php
1 <?php
2
3 // Require login
4 require_once 'plc_login.php';
5
6 // Get session and API handles
7 require_once 'plc_session.php';
8 global $plc, $api;
9
10 //print header
11 require_once 'plc_drupal.php';
12
13 // Common functions
14 require_once 'plc_functions.php';
15
16 $known_actions=array();
17 ////////////////////////////////////////////////////////////
18 // interface :
19 // (*) use POST 
20 // (*) set 'action' to one of the following
21 //////////////////////////////////////// persons
22 $known_actions []= "add-person-to-site";
23 //      expects:        person_id & site_id
24 $known_actions []= "remove-person-from-sites";
25 //      expects:        person_id & site_ids
26 $known_actions []= "remove-roles-from-person";
27 //      expects:        person_id & role_ids
28 $known_actions []= "add-role-to-person";
29 //      expects:        role_person_id & id
30 $known_actions []= "enable-person";
31 //      expects:        person_id
32 $known_actions []= "disable-person";
33 //      expects:        person_id
34 $known_actions []= "become-person";
35 //      expects:        person_id
36 $known_actions []= "delete-person";
37 //      expects:        person_id
38 $known_actions []= "delete-keys";
39 //      expects:        key_ids & person_id (for redirecting to the person's page)
40 $known_actions []= "upload-key";
41 //      expects:        person_id & $_FILES['key']
42 $known_actions []= "update-person";
43 //      expects:        person_id & first_name last_name title email phone url bio + [password1 password2]
44
45 //////////////////////////////////////// nodes
46 $known_actions []= "node-boot-state";   
47 //      expects:        node_id boot_state
48 $known_actions []= "delete-node";       
49 //      expects:        node_id
50 $known_actions []= "update-node";       
51 //      expects:        node_id, hostname, model
52
53 //////////////////////////////////////// interfaces
54 $known_actions []= "delete-interfaces"; 
55 //      expects:        interface_ids
56 $known_actions []="add-interface";
57 //      expects:        node_id & interface details
58 $known_actions []="update-interface";
59 //      expects:        interface_id & interface details
60
61 //////////////////////////////////////// sites
62 $known_actions []= "delete-site";       
63 //      expects:        site_id
64 $known_actions []= "expire-all-slices-in-site";
65 //      expects:        slice_ids
66 $known_actions []= "update-site";
67 //      expects:        site_id & name abbreviated_name url latitude longitude [login_base max_slices]
68
69 //////////////////////////////////////// slices
70 $known_actions []= "delete-slice";
71 //      expects:        slice_id
72 $known_actions []= "update-slice";      
73 //      expects:        slice_id, name, description, url
74 $known_actions []= "renew-slice";
75 //      expects:        slice_id & expires
76 $known_actions []= 'remove-persons-from-slice';
77 //      expects:        slice_id & person_ids
78 $known_actions []= 'add-persons-in-slice';
79 //      expects:        slice_id & person_ids
80 $known_actions []= 'remove-nodes-from-slice';
81 //      expects:        slice_id & node_ids
82 $known_actions []= 'add-nodes-in-slice';
83 //      expects:        slice_id & node_ids
84
85 //////////////////////////////////////// tag types
86 $known_actions []= "update-tag-type";
87 //      expects:        tag_type_id & name & description & category & min_role_id  
88 $known_actions []= "add-tag-type";
89 //      expects:        tag_type_id & tagname & description & category & min_role_id  
90 $known_actions []= "delete-tag-types";
91 //      expects:        tag_type_ids
92
93 //////////////////////////////////////// tags
94 $known_actions []= "set-tag-on-node";
95 //      expects:        node_id tagname value
96 $known_actions []= "set-tag-on-interface";
97 //      expects:        interface_id tagname value
98 $known_actions []= "delete-node-tags";
99 //      expects:        node_id & node_tag_ids
100 $known_actions []= "delete-interface-tags";
101 //      expects:        interface_id & interface_tag_ids
102
103 ////////////////////////////////////////////////////////////
104 $interface_details= array ('method','type', 'ip', 'gateway', 'network', 
105                            'broadcast', 'netmask', 'dns1', 'dns2', 
106                            'hostname', 'mac', 'bwlimit' );
107
108 //////////////////////////////
109 // sometimes we don't set 'action', but use the submit button name instead
110 // so if 'action' not set, see if $_POST has one of the actions as a key
111 if ($_POST['action']) 
112   $action=$_POST['action'];
113 else 
114   foreach ($known_actions as $known_action) 
115     if ($_POST[$known_action]) {
116       $action=$known_action;
117       break;
118     }
119
120 //uncomment for debugging incoming data
121 //$action='debug';
122
123 $person_id = $_POST['person_id'];       // usually needed
124
125 if ( ! $action ) {
126   drupal_set_message ("actions.php: action not set or not in known_actions");
127   plc_debug('POST',$_POST);
128   return;
129  }
130
131 switch ($action) {
132
133  case 'add-person-to-site': {
134    $site_id = $_POST['site_id'];
135    $api->AddPersonToSite( intval( $person_id ), intval( $site_id ) );
136    plc_redirect (l_person($person_id));
137  }
138
139  case 'remove-person-from-sites': {
140    $site_ids = $_POST['site_ids'];
141    if ( ! $site_ids) {
142      drupal_set_message("action=$action - No site selected");
143      return;
144    }
145    foreach ( $site_ids as $site_id ) {
146      $api->DeletePersonFromSite( intval( $person_id ), intval( $site_id ) );
147    }
148    plc_redirect (l_person($person_id));
149  }
150
151  case 'remove-roles-from-person' : {
152    $role_ids=$_POST['role_ids'];
153    if ( ! $role_ids) {
154      drupal_set_message("action=$action - No role selected");
155      return;
156    }
157    foreach( $role_ids as $role_id)  {
158      $api->DeleteRoleFromPerson( intval( $role_id ), intval( $person_id ) );
159    }
160    plc_redirect (l_person($person_id));
161  }
162      
163  case 'add-role-to-person' : {
164    $role_id=$_POST['role_id'];
165    $api->AddRoleToPerson( intval( $role_id ), intval( $person_id ) );
166    plc_redirect (l_person($person_id));
167  }
168
169  case 'enable-person' : {
170    $fields = array( "enabled"=>true );
171    $api->UpdatePerson( intval( $person_id ), $fields );
172    plc_redirect (l_person($person_id));
173  }
174
175  case 'disable-person' : {
176    $fields = array( "enabled"=>false );
177    $api->UpdatePerson( intval( $person_id ), $fields );
178    plc_redirect (l_person($person_id));
179  }
180
181  case 'become-person' : {
182    $plc->BecomePerson (intval($person_id));
183    plc_redirect (l_persons());
184  }
185
186  case 'delete-person' : {
187   $api->DeletePerson( intval( $person_id ) );
188    plc_redirect (l_persons());
189  }
190
191  case 'delete-keys' : {
192    $key_ids=$_POST['key_ids'];
193    if ( ! $key_ids) {
194      drupal_set_message("action=$action - No key selected");
195      return;
196    }
197    $success=true;
198    $counter=0;
199    foreach( $key_ids as $key_id ) {
200      if ($api->DeleteKey( intval( $key_id )) != 1) 
201        $success=false;
202      else
203        $counter++;
204    }
205    if ($success) 
206      drupal_set_message ("Deleted $counter key(s)");
207    else
208      drupal_set_error ("Could not delete all selected keys, only $counter were removed");
209    plc_redirect(l_person($person_id));
210  }
211
212
213  case 'upload-key' : {
214    if ( ! isset( $_FILES['key'] ) ) {
215      drupal_set_message ("action=$action, no key file set");
216      return;
217    }
218    
219    $key_file= $_FILES['key']['tmp_name'];
220    if ( ! $key_file ) {
221      plc_error("Please select a valid SSH key file to upload");
222      return;
223    } 
224    $fp = fopen( $key_file, "r" );
225    $key = "";
226    if( ! $fp ) {
227      plc_error("Unable to open key file $key_file");
228      return;
229    }
230    // opened the key file, read the one line of contents
231    // The POST operation always creates a file even if the filename
232    // the user specified was garbage.  If there was some problem
233    // with the source file, we'll get a zero length read here.
234    $key = fread($fp, filesize($key_file));
235    fclose($fp);
236    
237    $key_id = $api->AddPersonKey( intval( $person_id ), array( "key_type"=> 'ssh', "key"=> $key ) );
238    
239    if ( $key_id == 1) 
240      drupal_set_message ("New key added");
241    else
242      drupal_set_error("Could not add key, please verify your SSH file content\n" . $api->error());
243    
244    plc_redirect(l_person($person_id));
245  }
246
247  case 'update-person': {
248    $person_id=$_POST['person_id'];
249    // attempt to update this person
250    $first_name= $_POST['first_name'];
251    $last_name= $_POST['last_name'];
252    $title= $_POST['title'];
253    $email= $_POST['email'];
254    $phone= $_POST['phone'];
255    $url= $_POST['url'];
256    $bio= str_replace("\r", "", $_POST['bio']);
257    $password1= $_POST['password1'];
258    $password2= $_POST['password2'];
259
260    if( $password1 != $password2 ) {
261      drupal_set_error ("The passwords do not match");
262      plc_redirect(l_person($person_id));
263   }
264
265    $fields= array();
266    $fields['first_name']= $first_name;
267    $fields['last_name']= $last_name;
268    $fields['title']= $title;
269    $fields['email']= $email;
270    $fields['phone']= $phone;
271    $fields['url']= $url;
272    $fields['bio']= $bio;
273                 
274    if ( $password1 != "" )
275      $fields['password']= $password1;
276     
277     if ( $api->UpdatePerson( intval( $person_id ), $fields) == 1 )
278       drupal_set_message("$first_name $last_name updated");
279     else 
280       drupal_set_error ("Could not update person $person_id" . $api->error());
281
282     plc_redirect(l_person($person_id));
283     break;
284   }
285
286 //////////////////////////////////////////////////////////// nodes
287  case 'node-boot-state': {
288    $node_id=intval($_POST['node_id']);
289    $boot_state=$_POST['boot_state'];
290    $result=$api->UpdateNode( $node_id, array( "boot_state" => $boot_state ) );
291    if ($result==1) {
292      drupal_set_message("boot state updated");
293      plc_redirect (l_node($node_id));
294    } else {
295      drupal_set_error("Could not set boot_state '$boot_state'");
296    }
297    break;
298  }
299
300  case 'delete-node': {
301    $node_id=intval($_POST['node_id']);
302    $result=$api->DeleteNode( intval( $node_id ) );
303    if ($api==1) {
304      drupal_set_message("Node $node_id deleted");
305      plc_redirect (l_nodes());
306    } else {
307      drupal_set_error ("Could not delete node $node_id");
308    }
309    break;
310  }
311
312  case 'update-node': {
313    $hostname= $_POST['hostname'];
314    $model= $_POST['model'];
315
316    $fields= array( "hostname"=>$hostname, "model"=>$model );
317    $api->UpdateNode( intval( $node_id ), $fields );
318    $error= $api->error();
319
320    if( empty( $error ) ) {
321      drupal_set_message("Update node $hostname");
322      plc_redirect(l_node($node_id));
323    } else {
324      drupal_set_error($error);
325    }
326    break;
327  }
328
329 //////////////////////////////////////////////////////////// interfaces
330  case 'delete-interfaces' : {
331    $interface_ids=$_POST['interface_ids'];
332    if ( ! $interface_ids) {
333      drupal_set_message("action=$action - No interface selected");
334      return;
335    }
336    $success=true;
337    $counter=0;
338    foreach( $interface_ids as $interface_id ) {
339      if ($api->DeleteInterface( intval( $interface_id )) != 1) 
340        $success=false;
341      else
342        $counter++;
343    }
344    if ($success) 
345      drupal_set_message ("Deleted $counter interface(s)");
346    else
347      drupal_set_error ("Could not delete all selected interfaces, only $counter were removed");
348    plc_redirect(l_node($_POST['node_id']));
349  }
350
351  case 'add-interface': {
352    $node_id=$_POST['node_id'];
353    foreach ($interface_details as $field) {
354      $interface[$field]= $_POST[$field];
355      if( in_array( $field, array( 'bwlimit', 'node_id' ) ) ) {
356        $interface[$field]= intval( $interface[$field] );
357      }
358    }
359    $result=$api->AddInterface( intval( $node_id ), $interface );
360    if ($result >0 ) 
361      drupal_set_message ("Interface $result added into node $node_id");
362    else
363      drupal_set_error ("Could not create interface");
364    plc_redirect (l_node($node_id));
365  }
366    
367  case 'update-interface': {
368    $interface_id=$_POST['interface_id'];
369    foreach ($interface_details as $field) {
370      $interface[$field]= $_POST[$field];
371      if( in_array( $field, array( 'bwlimit', 'node_id' ) ) ) {
372        $interface[$field]= intval( $interface[$field] );
373      }
374    }
375    $result=$api->UpdateInterface( intval( $interface_id ), $interface );
376    if ($result == 1 ) 
377      drupal_set_message ("Interface $interface_id updated");
378    else
379      drupal_set_error ("Could not update interface");
380    plc_redirect (l_interface($interface_id));
381  }
382    
383 //////////////////////////////////////////////////////////// sites
384  case 'delete-site': {
385    $site_id = intval($_POST['site_id']);
386    if ($api->DeleteSite($site_id) ==1) 
387      drupal_set_message ("Site $site_id deleted");
388    else
389      drupal_set_error("Failed to delete site $site_id");
390    plc_redirect (l_sites());
391    break;
392  }
393
394  case 'expire-all-slices-in-site': {
395    // xxx todo
396    drupal_set_message("action $action not implemented in actions.php -- need tweaks and test");
397    return;
398
399    //// old code from sites/expire.php
400    $sites = $api->GetSites( array( intval( $site_id )));
401    $site=$sites[0];
402    // xxx why not 'now?'
403    $expiration= strtotime( $_POST['expires'] );
404    // loop through all slices for site
405    foreach ($site['slice_ids'] as $slice_id) {
406      $api->UpdateSlice( $slice_id, array( "expires" => $expiration ) );
407    }
408    // update site to not allow slice creation or renewal
409    $api->UpdateSite( $site_id, array( "max_slices" => 0 )) ;
410    plc_redirect (l_site($site_id));
411    break;
412  }
413
414  case 'update-site': {
415    $site_id=intval($_POST['site_id']);
416    $name= $_POST['name'];
417    $abbreviated_name= $_POST['abbreviated_name'];
418    $url= $_POST['url'];
419    $latitude= floatval($_POST['latitude']);
420    $longitude= floatval($_POST['longitude']);
421    //$max_slivers= $_POST['max_slivers'];
422    
423    $fields= array( "name" => $name, 
424                    "abbreviated_name" => $abbreviated_name, 
425                    "url" => $url, 
426                    "latitude" => floatval( $latitude ), 
427                    "longitude" => floatval( $longitude ));
428
429    if ($_POST['login_base']) 
430      $fields['login_base'] = $_POST['login_base'];
431    if ($_POST['max_slices']) 
432      $fields['max_slices'] = intval($_POST['max_slices']);
433    
434    $retcod=$api->UpdateSite( intval( $site_id ), $fields );
435    if ($retcod == 1) 
436      drupal_set_message("Site $name updated");
437    else 
438      drupal_set_error ("Could not update site $site_id");
439      
440    plc_redirect(l_site($site_id));
441    break;
442  }
443
444 //////////////////////////////////////////////////////////// slices
445  case 'delete-slice': {
446    $slice_id = $_POST['slice_id'];
447    $api->DeleteSlice( intval( $slice_id ) );
448    $error= $api->error();
449    if( empty( $error ) ) {
450        drupal_set_message("Deleted slice $slice_id");
451    } else {
452        drupal_set_error($error);
453    }
454    break;
455  }
456      
457  case 'update-slice': {
458    $slice_id = $_POST['slice_id'];
459    $name = $_POST['name'];
460    $description= $_POST['description'];
461    $url= $_POST['url'];
462
463    $fields= array( "description"=>$description, "url"=>$url );
464    $api->UpdateSlice( intval( $slice_id ), $fields );
465    $error= $api->error();
466
467    if( empty( $error ) ) {
468      drupal_set_message("Update slice $name");
469      plc_redirect(l_slice($slice_id));
470    } else {
471      drupal_set_error($error);
472    }
473    break;
474  }
475
476  case 'renew-slice': {
477    $slice_id = intval ($_POST['slice_id']);     
478    $expires = intval ($_POST['expires']);
479    // 8 weeks from now
480    // xxx
481    $now=mktime();
482    $WEEK=7*24*3600;
483    $WEEKS=8;
484    $MAX_FUTURE=$WEEKS*$WEEK;
485    if ( ($expires-$now) > $MAX_FUTURE) {
486      drupal_set_error("Cannot renew slice that far in the future, max is $WEEKS weeks from now");
487      plc_redirect(l_slice($slice_id));
488    }
489    plc_debug('slice_id',$slice_id);
490    plc_debug('expires',$expires);
491    if ($api->UpdateSlice ($slice_id, array('expires'=>$expires)) == 1)
492      drupal_set_message("Slice renewed");
493    else
494      drupal_set_error("Could not update slice $slice_id");
495    plc_redirect(l_slice($slice_id));
496    break;
497  }
498
499  case 'remove-persons-from-slice': {
500    $slice_id = intval ($_POST['slice_id']);     
501    $person_ids = $_POST['person_ids'];
502    
503    $success=true;
504    $counter=0;
505    foreach( $person_ids as $person_id ) {
506      if ($api->DeletePersonFromSlice(intval($person_id),$slice_id) != 1) 
507        $success=false;
508      else
509        $counter++;
510    }
511    if ($success) 
512      drupal_set_message ("Deleted $counter person(s)");
513    else
514      drupal_set_error ("Could not delete all selected persons, only $counter were removed");
515    plc_redirect(l_slice($slice_id) . " &show_persons=true");
516    break;
517  }
518
519  case 'add-persons-in-slice': {
520    $slice_id = intval ($_POST['slice_id']);     
521    $person_ids = $_POST['person_ids'];
522    
523    $success=true;
524    $counter=0;
525    foreach ($person_ids as $person_id) {
526      if ($api->AddPersonToSlice(intval($person_id),$slice_id) != 1) 
527        $success=false;
528      else
529        $counter++;
530    }
531    if ($success) 
532      drupal_set_message ("Added $counter person(s)");
533    else
534      drupal_set_error ("Could not add all selected persons, only $counter were added");
535    plc_redirect(l_slice($slice_id) . "&show_persons=true" );
536    break;
537  }
538
539  case 'remove-nodes-from-slice': {
540    $slice_id = intval ($_POST['slice_id']);     
541    $node_ids = array_map("intval",$_POST['node_ids']);
542    $count=count($node_ids);
543    
544    if ($api->DeleteSliceFromNodes($slice_id,$node_ids) == 1) 
545      drupal_set_message ("Removed $count node(s)");
546    else
547      drupal_set_error ("Could not remove selected nodes");
548    plc_redirect(l_slice($slice_id) . " &show_nodes=true");
549    break;
550  }
551
552  case 'add-nodes-in-slice': {
553    $slice_id = intval ($_POST['slice_id']);     
554    $node_ids = array_map("intval",$_POST['node_ids']);
555    $count=count($node_ids);
556    if ($api->AddSliceToNodes($slice_id,$node_ids) == 1) 
557      drupal_set_message ("Added $count node(s)");
558    else
559      drupal_set_error ("Could not add all selected nodes");
560    plc_redirect(l_slice($slice_id) . "&show_nodes=true" );
561    break;
562  }
563
564 //////////////////////////////////////////////////////////// tag types
565
566  case 'update-tag-type': {
567   // get post vars 
568    $tag_type_id= intval( $_POST['tag_type_id'] );
569    $tagname = $_POST['tagname'];
570    $min_role_id= intval( $_POST['min_role_id'] );
571    $description= $_POST['description'];  
572    $category= $_POST['category'];  
573   
574    // make tag_type_fields dict
575    $tag_type_fields= array( "min_role_id" => $min_role_id, 
576                             "tagname" => $tagname, 
577                             "description" => $description,
578                             "category" => $category,
579                             );
580
581    if ($api->UpdateTagType( $tag_type_id, $tag_type_fields ) == 1) 
582      drupal_set_message ("Tag type $tagname updated");
583    else 
584      drupal_set_error ("Could not update tag type $tag_type_id\n".$api->error());
585    plc_redirect(l_tag($tag_type_id));
586  }
587
588  case 'add-tag-type': {
589   // get post vars 
590    $tagname = $_POST['tagname'];
591    $min_role_id= intval( $_POST['min_role_id'] );
592    $description= $_POST['description'];  
593    $category= $_POST['category'];  
594   
595    // make tag_type_fields dict
596    $tag_type_fields= array( "min_role_id" => $min_role_id, 
597                             "tagname" => $tagname, 
598                             "description" => $description,
599                             "category" => $category,
600                             );
601
602   // Add it!
603    $tag_type_id=$api->AddTagType( $tag_type_fields );
604    if ($tag_type_id > 0) 
605      drupal_set_message ("tag type $tag_type_id created");
606    else
607      drupal_set_error ("Could not create tag type $tagname");
608    plc_redirect( l_tags());
609  }
610
611  case 'delete-tag-types': {
612    $tag_type_ids = $_POST['tag_type_ids'];
613    if ( ! $tag_type_ids) {
614      drupal_set_message("action=$action - No tag selected");
615      return;
616    }
617    $success=true;
618    $counter=0;
619    foreach ($tag_type_ids as $tag_type_id) 
620      if ($api->DeleteTagType(intval($tag_type_id)) != 1) 
621        $success=false;
622      else
623        $counter++;
624    if ($success) 
625      drupal_set_message ("Deleted $counter tag(s)");
626    else
627      drupal_set_error ("Could not delete all selected tags, only $counter were removed");
628    plc_redirect (l_tags());
629    break;
630  }
631
632 //////////////////////////////////////// tags   
633  case 'set-tag-on-node': 
634  case 'set-tag-on-interface': {
635    
636    $node_mode = false;
637    if ($action == 'set-tag-on-node') $node_mode=true;
638
639    if ($node_mode)
640      $node_id = intval($_POST['node_id']);
641    else 
642      $interface_id=intval($_POST['interface_id']);
643    $tag_type_id = intval($_POST['tag_type_id']);
644    $value = $_POST['value'];
645
646    $tag_types=$api->GetTagTypes(array($tag_type_id));
647    if (count ($tag_types) != 1) {
648      drupal_set_error ("Could not locate tag_type_id $tag_type_id </br> Tag not set.");
649    } else {
650      if ($node_mode) 
651        $tags = $api->GetNodeTags (array('node_id'=>$node_id, 'tag_type_id'=> $tag_type_id));
652      else
653        $tags = $api->GetInterfaceTags (array('interface_id'=>$interface_id, 'tag_type_id'=> $tag_type_id));
654      if ( count ($tags) == 1) {
655        $tag=$tags[0];
656        if ($node_mode) {
657          $tag_id=$tag['node_tag_id'];
658          $result=$api->UpdateNodeTag($tag_id,$value);
659        } else {
660          $tag_id=$tag['interface_tag_id'];
661          $result=$api->UpdateInterfaceTag($tag_id,$value);
662        }
663        if ($result == 1) 
664          drupal_set_message ("Updated tag, new value = $value");
665        else
666          drupal_set_error ("Could not update tag");
667      } else {
668        if ($node_mode)
669          $tag_id = $api->AddNodeTag($node_id,$tag_type_id,$value);
670        else
671          $tag_id = $api->AddInterfaceTag($interface_id,$tag_type_id,$value);
672        if ($tag_id) 
673          drupal_set_message ("Created tag, new value = $value");
674        else
675          drupal_set_error ("Could not create tag");
676      }
677    }
678    
679    if ($node_mode)
680      plc_redirect (l_node($node_id));
681    else
682      plc_redirect (l_interface($interface_id));
683  }
684
685  case 'delete-node-tags' : 
686  case 'delete-interface-tags' : {
687
688    $node_mode = false;
689    if ($action == 'delete-node-tags') $node_mode=true;
690
691    if ($node_mode)
692      $tag_ids=$_POST['node_tag_ids'];
693    else
694      $tag_ids=$_POST['interface_tag_ids'];
695
696    if ( ! $tag_ids) {
697      drupal_set_message("action=$action - No tag selected");
698      return;
699    }
700    $success=true;
701    $counter=0;
702    foreach( $tag_ids as $tag_id ) {
703      if ($node_mode)
704        $retcod = $api->DeleteNodeTag( intval( $tag_id ));
705      else
706        $retcod = $api->DeleteInterfaceTag( intval( $tag_id ));
707      if ($retcod != 1) 
708        $success=false;
709      else
710        $counter++;
711    }
712    if ($success) 
713      drupal_set_message ("Deleted $counter tag(s)");
714    else
715      drupal_set_error ("Could not delete all selected tags, only $counter were removed");
716    if ($node_mode)
717      plc_redirect(l_node($_POST['node_id']));
718    else
719      plc_redirect(l_interface($_POST['interface_id']));
720  }
721
722
723 ////////////////////////////////////////
724
725  case 'debug': {
726    plc_debug('GET',$_GET);
727    plc_debug('POST',$_POST);
728    plc_debug('FILES',$_FILES);
729    return;
730  }
731
732  default: {
733    plc_error ("Unknown action $action in actions.php");
734    return;
735  }
736
737  }
738
739 ?>