4 require_once 'plc_login.php';
6 // Get session and API handles
7 require_once 'plc_session.php';
11 require_once 'plc_drupal.php';
14 require_once 'plc_functions.php';
16 $known_actions=array();
17 ////////////////////////////////////////////////////////////
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";
32 $known_actions []= "disable-person";
34 $known_actions []= "become-person";
36 $known_actions []= "delete-person";
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]
45 //////////////////////////////////////// nodes
46 $known_actions []= "node-boot-state";
47 // expects: node_id boot_state
48 $known_actions []= "delete-node";
50 $known_actions []= "update-node";
51 // expects: node_id, hostname, model
52 $known_actions []= "attach-pcu";
53 // expects: node_id, pcu_id, port (pcu_id <0 means detach)
55 //////////////////////////////////////// interfaces
56 $known_actions []= "delete-interfaces";
57 // expects: interface_ids
58 $known_actions []="add-interface";
59 // expects: node_id & interface details
60 $known_actions []="new-interface";
62 $known_actions []="update-interface";
63 // expects: interface_id & interface details
65 //////////////////////////////////////// sites
66 $known_actions []= "delete-site";
68 $known_actions []= "expire-all-slices-in-site";
70 $known_actions []= "update-site";
71 // expects: site_id & name abbreviated_name url latitude longitude [login_base max_slices]
73 //////////////////////////////////////// slices
74 $known_actions []= "delete-slice";
76 $known_actions []= "update-slice";
77 // expects: slice_id, name, description, url
78 $known_actions []= "renew-slice";
79 // expects: slice_id & expires
80 $known_actions []= 'remove-persons-from-slice';
81 // expects: slice_id & person_ids
82 $known_actions []= 'add-persons-in-slice';
83 // expects: slice_id & person_ids
84 $known_actions []= 'remove-nodes-from-slice';
85 // expects: slice_id & node_ids
86 $known_actions []= 'add-nodes-in-slice';
87 // expects: slice_id & node_ids
88 $known_actions []= 'delete-slice-tags';
89 // expects: slice_tag_id
90 $known_actions []= 'add-slice-tag';
91 // expects: slice_id & tag_type_id & node_id & nodegroup_id
93 //////////////////////////////////////// tag types
94 $known_actions []= "update-tag-type";
95 // expects: tag_type_id & name & description & category & min_role_id
96 $known_actions []= "add-tag-type";
97 // expects: tag_type_id & tagname & description & category & min_role_id
98 $known_actions []= "delete-tag-types";
99 // expects: tag_type_ids
101 //////////////////////////////////////// tags
102 $known_actions []= "set-tag-on-node";
103 // expects: node_id tagname value
104 $known_actions []= "set-tag-on-interface";
105 // expects: interface_id tagname value
106 $known_actions []= "delete-node-tags";
107 // expects: node_id & node_tag_ids
108 $known_actions []= "delete-interface-tags";
109 // expects: interface_id & interface_tag_ids
111 ////////////////////////////////////////////////////////////
112 $interface_details= array ('method','type', 'ip', 'gateway', 'network',
113 'broadcast', 'netmask', 'dns1', 'dns2',
114 'hostname', 'mac', 'bwlimit' );
116 //////////////////////////////
117 // sometimes we don't set 'action', but use the submit button name instead
118 // so if 'action' not set, see if $_POST has one of the actions as a key
119 if ($_POST['action'])
120 $action=$_POST['action'];
122 foreach ($known_actions as $known_action)
123 if ($_POST[$known_action]) {
124 $action=$known_action;
128 //uncomment for debugging incoming data
131 $person_id = $_POST['person_id']; // usually needed
134 drupal_set_message ("actions.php: action not set or not in known_actions");
135 plc_debug('POST',$_POST);
141 case 'add-person-to-site': {
142 $site_id = $_POST['site_id'];
143 $api->AddPersonToSite( intval( $person_id ), intval( $site_id ) );
144 plc_redirect (l_person($person_id));
147 case 'remove-person-from-sites': {
148 $site_ids = $_POST['site_ids'];
150 drupal_set_message("action=$action - No site selected");
153 foreach ( $site_ids as $site_id ) {
154 $api->DeletePersonFromSite( intval( $person_id ), intval( $site_id ) );
156 plc_redirect (l_person($person_id));
159 case 'remove-roles-from-person' : {
160 $role_ids=$_POST['role_ids'];
162 drupal_set_message("action=$action - No role selected");
165 foreach( $role_ids as $role_id) {
166 $api->DeleteRoleFromPerson( intval( $role_id ), intval( $person_id ) );
168 plc_redirect (l_person($person_id));
171 case 'add-role-to-person' : {
172 $role_id=$_POST['role_id'];
173 $api->AddRoleToPerson( intval( $role_id ), intval( $person_id ) );
174 plc_redirect (l_person($person_id));
177 case 'enable-person' : {
178 $fields = array( "enabled"=>true );
179 $api->UpdatePerson( intval( $person_id ), $fields );
180 plc_redirect (l_person($person_id));
183 case 'disable-person' : {
184 $fields = array( "enabled"=>false );
185 $api->UpdatePerson( intval( $person_id ), $fields );
186 plc_redirect (l_person($person_id));
189 case 'become-person' : {
190 $plc->BecomePerson (intval($person_id));
191 plc_redirect (l_person(intval($person_id)));
194 case 'delete-person' : {
195 $api->DeletePerson( intval( $person_id ) );
196 plc_redirect (l_persons());
199 case 'delete-keys' : {
200 $key_ids=$_POST['key_ids'];
202 drupal_set_message("action=$action - No key selected");
207 foreach( $key_ids as $key_id ) {
208 if ($api->DeleteKey( intval( $key_id )) != 1)
214 drupal_set_message ("Deleted $counter key(s)");
216 drupal_set_error ("Could not delete all selected keys, only $counter were removed");
217 plc_redirect(l_person($person_id));
221 case 'upload-key' : {
222 if ( ! isset( $_FILES['key'] ) ) {
223 drupal_set_message ("action=$action, no key file set");
227 $key_file= $_FILES['key']['tmp_name'];
229 plc_error("Please select a valid SSH key file to upload");
232 $fp = fopen( $key_file, "r" );
235 plc_error("Unable to open key file $key_file");
238 // opened the key file, read the one line of contents
239 // The POST operation always creates a file even if the filename
240 // the user specified was garbage. If there was some problem
241 // with the source file, we'll get a zero length read here.
242 $key = fread($fp, filesize($key_file));
245 $key_id = $api->AddPersonKey( intval( $person_id ), array( "key_type"=> 'ssh', "key"=> $key ) );
248 drupal_set_message ("New key added");
250 drupal_set_error("Could not add key, please verify your SSH file content\n" . $api->error());
252 plc_redirect(l_person($person_id));
255 case 'update-person': {
256 $person_id=$_POST['person_id'];
257 // attempt to update this person
258 $first_name= $_POST['first_name'];
259 $last_name= $_POST['last_name'];
260 $title= $_POST['title'];
261 $email= $_POST['email'];
262 $phone= $_POST['phone'];
264 $bio= str_replace("\r", "", $_POST['bio']);
265 $password1= $_POST['password1'];
266 $password2= $_POST['password2'];
268 if( $password1 != $password2 ) {
269 drupal_set_error ("The passwords do not match");
270 plc_redirect(l_person($person_id));
274 $fields['first_name']= $first_name;
275 $fields['last_name']= $last_name;
276 $fields['title']= $title;
277 $fields['email']= $email;
278 $fields['phone']= $phone;
279 $fields['url']= $url;
280 $fields['bio']= $bio;
282 if ( $password1 != "" )
283 $fields['password']= $password1;
285 if ( $api->UpdatePerson( intval( $person_id ), $fields) == 1 )
286 drupal_set_message("$first_name $last_name updated");
288 drupal_set_error ("Could not update person $person_id" . $api->error());
290 plc_redirect(l_person($person_id));
294 //////////////////////////////////////////////////////////// nodes
295 case 'node-boot-state': {
296 $node_id=intval($_POST['node_id']);
297 $boot_state=$_POST['boot_state'];
298 $result=$api->UpdateNode( $node_id, array( "boot_state" => $boot_state ) );
300 drupal_set_message("boot state updated");
301 plc_redirect (l_node($node_id));
303 drupal_set_error("Could not set boot_state '$boot_state'");
308 case 'delete-node': {
309 $node_id=intval($_POST['node_id']);
310 $result=$api->DeleteNode( intval( $node_id ) );
312 drupal_set_message("Node $node_id deleted");
313 plc_redirect (l_nodes());
315 drupal_set_error ("Could not delete node $node_id");
320 case 'update-node': {
321 $node_id=intval($_POST['node_id']);
322 $hostname= $_POST['hostname'];
323 $model= $_POST['model'];
325 $fields= array( "hostname"=>$hostname, "model"=>$model );
326 $api->UpdateNode( $node_id, $fields );
327 $error= $api->error();
329 if( empty( $error ) ) {
330 drupal_set_message("Update node $hostname");
331 plc_redirect(l_node($node_id));
333 drupal_set_error($error);
338 // this code will ensure that at most one PCU gets attached to the node
340 $node_id=intval($_POST['node_id']);
341 $pcu_id=intval($_POST['pcu_id']);
342 $port=intval($_POST['port']);
343 // always start with deleting former PCUs
344 $nodes = $api->GetNodes(array($node_id),array('pcu_ids'));
345 $former_pcu_ids = $nodes[0]['pcu_ids'];
346 if ($former_pcu_ids) foreach ($former_pcu_ids as $former_pcu_id) {
347 if ($api->DeleteNodeFromPCU($node_id,$former_pcu_id) == 1)
348 drupal_set_message ('Detached node ' . $node_id . ' from PCU ' . $pcu_id);
350 drupal_set_error ('Could not detach node ' . $node_id . ' from PCU ' . $pcu_id);
352 // re-attach only if provided pcu_id >=0
354 if ($api->AddNodeToPCU($node_id,$pcu_id,$port) == 1)
355 drupal_set_message ('Attached node ' . $node_id . ' to PCU ' . $pcu_id . ' on port ' . $port);
357 drupal_set_error ('Failed to attach node ' . $node_id . ' to PCU ' . $pcu_id . ' on port ' . $port);
359 drupal_set_message ('Detached node from all PCUs');
362 plc_redirect(l_node($node_id));
367 //////////////////////////////////////////////////////////// interfaces
368 case 'delete-interfaces' : {
369 $interface_ids=$_POST['interface_ids'];
370 if ( ! $interface_ids) {
371 drupal_set_message("action=$action - No interface selected");
376 foreach( $interface_ids as $interface_id ) {
377 if ($api->DeleteInterface( intval( $interface_id )) != 1)
383 drupal_set_message ("Deleted $counter interface(s)");
385 drupal_set_error ("Could not delete all selected interfaces, only $counter were removed");
386 plc_redirect(l_node($_POST['node_id']));
388 case 'new-interface': {
389 plc_redirect(l_interface_add($_POST['node_id']));
391 case 'add-interface': {
392 $node_id=$_POST['node_id'];
393 foreach ($interface_details as $field) {
394 $interface[$field]= $_POST[$field];
395 if( in_array( $field, array( 'bwlimit', 'node_id' ) ) ) {
396 $interface[$field]= intval( $interface[$field] );
399 $interface_id =$api->AddInterface( intval( $node_id ), $interface );
400 if ($interface_id >0 ) {
402 $api->AddInterfaceTag($interface_id,"alias",strval($interface_id));
403 $api->AddInterfaceTag($interface_id,"ifname","eth0");
404 list($id1, $id2) = $api->commit();
405 if ( $id1 > 0 && $id2 > 0 ) {
406 drupal_set_message ("Interface $interface_id added into node $node_id");
408 drupal_set_error ("Could not add interface tags to interface $interface_id");
411 drupal_set_error ("Could not create interface");
413 plc_redirect (l_node($node_id));
416 case 'update-interface': {
417 $interface_id=$_POST['interface_id'];
418 foreach ($interface_details as $field) {
419 $interface[$field]= $_POST[$field];
420 if( in_array( $field, array( 'bwlimit', 'node_id' ) ) ) {
421 if ( intval($interface[$field]) != 0 ) {
422 $interface[$field]= intval( $interface[$field]);
423 } elseif ($field=='bwlimit' ) {
424 $interface[$field] = NULL;
428 $result=$api->UpdateInterface( intval( $interface_id ), $interface );
430 drupal_set_message ("Interface $interface_id updated");
432 drupal_set_error ("Could not update interface");
433 plc_redirect (l_interface($interface_id));
436 //////////////////////////////////////////////////////////// sites
437 case 'delete-site': {
438 $site_id = intval($_POST['site_id']);
439 if ($api->DeleteSite($site_id) ==1)
440 drupal_set_message ("Site $site_id deleted");
442 drupal_set_error("Failed to delete site $site_id");
443 plc_redirect (l_sites());
447 case 'expire-all-slices-in-site': {
449 drupal_set_message("action $action not implemented in actions.php -- need tweaks and test");
452 //// old code from sites/expire.php
453 $sites = $api->GetSites( array( intval( $site_id )));
455 // xxx why not 'now?'
456 $expiration= strtotime( $_POST['expires'] );
457 // loop through all slices for site
458 foreach ($site['slice_ids'] as $slice_id) {
459 $api->UpdateSlice( $slice_id, array( "expires" => $expiration ) );
461 // update site to not allow slice creation or renewal
462 $api->UpdateSite( $site_id, array( "max_slices" => 0 )) ;
463 plc_redirect (l_site($site_id));
467 case 'update-site': {
468 $site_id=intval($_POST['site_id']);
469 $name= $_POST['name'];
470 $abbreviated_name= $_POST['abbreviated_name'];
472 $latitude= floatval($_POST['latitude']);
473 $longitude= floatval($_POST['longitude']);
474 //$max_slivers= $_POST['max_slivers'];
476 $fields= array( "name" => $name,
477 "abbreviated_name" => $abbreviated_name,
479 "latitude" => floatval( $latitude ),
480 "longitude" => floatval( $longitude ));
482 if ($_POST['login_base'])
483 $fields['login_base'] = $_POST['login_base'];
484 if (isset($_POST['max_slices']))
485 $fields['max_slices'] = intval($_POST['max_slices']);
486 if (isset($_POST['enabled'])) {
487 $fields['enabled'] = (bool)$_POST['enabled'];
490 $retcod=$api->UpdateSite( intval( $site_id ), $fields );
492 drupal_set_message("Site $name updated");
494 drupal_set_error ("Could not update site $site_id");
496 plc_redirect(l_site($site_id));
500 //////////////////////////////////////////////////////////// slices
501 case 'delete-slice': {
502 $slice_id = $_POST['slice_id'];
503 if ($api->DeleteSlice( intval( $slice_id )) == 1 ) {
504 drupal_set_message("Slice $slice_id deleted");
505 plc_redirect(l_slices());
507 drupal_set_error("Could not delete slice $slice_id " . $api->error());
512 case 'update-slice': {
513 $slice_id = $_POST['slice_id'];
514 $name = $_POST['name'];
515 $description= $_POST['description'];
518 $fields= array( "description"=>$description, "url"=>$url );
519 $api->UpdateSlice( intval( $slice_id ), $fields );
520 $error= $api->error();
522 if( empty( $error ) ) {
523 drupal_set_message("Update slice $name");
524 plc_redirect(l_slice($slice_id));
526 drupal_set_error($error);
531 case 'renew-slice': {
532 $slice_id = intval ($_POST['slice_id']);
533 $expires = intval ($_POST['expires']);
539 $MAX_FUTURE=$WEEKS*$WEEK;
540 if ( ($expires-$now) > $MAX_FUTURE) {
541 drupal_set_error("Cannot renew slice that far in the future, max is $WEEKS weeks from now");
542 plc_redirect(l_slice($slice_id));
544 plc_debug('slice_id',$slice_id);
545 plc_debug('expires',$expires);
546 if ($api->UpdateSlice ($slice_id, array('expires'=>$expires)) == 1)
547 drupal_set_message("Slice renewed");
549 drupal_set_error("Could not update slice $slice_id");
550 plc_redirect(l_slice($slice_id));
554 case 'remove-persons-from-slice': {
555 $slice_id = intval ($_POST['slice_id']);
556 $person_ids = $_POST['person_ids'];
559 $tmp_slices = $api->GetSlices($slice_id, array("name"));
560 if (count($tmp_slices) > 0) {
561 $tmp_slice = $tmp_slices[0];
562 $slice_name = $tmp_slice["name"];
564 $notify_subject = "Removed from slice: " . $slice_name;
565 $notify_body = sprintf("You have been removed from the slice %s.
567 Our support team will be glad to answer any question that you might have.
569 $notify_person_ids = array();
573 foreach( $person_ids as $person_id ) {
574 if ($api->DeletePersonFromSlice(intval($person_id),$slice_id) != 1)
577 array_push($notify_person_ids, intval($person_id));
582 $api->NotifyPersons($notify_person_ids,$notify_subject,$notify_body);
583 drupal_set_message ("Deleted $counter person(s)");
586 drupal_set_error ("Could not delete all selected persons, only $counter were removed");
587 plc_redirect(l_slice($slice_id) . " &show_persons=true");
591 case 'add-persons-in-slice': {
592 $slice_id = intval ($_POST['slice_id']);
593 $person_ids = $_POST['person_ids'];
596 $tmp_slices = $api->GetSlices($slice_id, array("name"));
597 if (count($tmp_slices) > 0) {
598 $tmp_slice = $tmp_slices[0];
599 $slice_name = $tmp_slice["name"];
601 $notify_subject = "Added to slice: " . $slice_name;
602 $notify_body = sprintf("You have been added to the slice %s as a user.
604 You can go to your slice page following the link below:
605 https://%s:%d/db/slices/index.php?id=%d
607 Our support team will be glad to answer any question that you might have.
608 ",$slice_name,PLC_WWW_HOST,PLC_WWW_SSL_PORT,$slice_id);
609 $notify_person_ids = array();
613 foreach ($person_ids as $person_id) {
614 if ($api->AddPersonToSlice(intval($person_id),$slice_id) != 1)
617 array_push($notify_person_ids, intval($person_id));
622 $api->NotifyPersons($notify_person_ids,$notify_subject,$notify_body);
623 drupal_set_message ("Added $counter person(s)");
626 drupal_set_error ("Could not add all selected persons, only $counter were added");
627 plc_redirect(l_slice($slice_id) . "&show_persons=true" );
631 case 'remove-nodes-from-slice': {
632 $slice_id = intval ($_POST['slice_id']);
633 $node_ids = array_map("intval",$_POST['node_ids']);
634 $count=count($node_ids);
636 if ($api->DeleteSliceFromNodes($slice_id,$node_ids) == 1)
637 drupal_set_message ("Removed $count node(s)");
639 drupal_set_error ("Could not remove selected nodes");
640 plc_redirect(l_slice($slice_id) . " &show_nodes=true");
644 case 'add-nodes-in-slice': {
645 $slice_id = intval ($_POST['slice_id']);
646 $node_ids = array_map("intval",$_POST['node_ids']);
647 $count=count($node_ids);
648 if ($api->AddSliceToNodes($slice_id,$node_ids) == 1)
649 drupal_set_message ("Added $count node(s)");
651 drupal_set_error ("Could not add all selected nodes");
652 plc_redirect(l_slice($slice_id) . "&show_nodes=true" );
656 case 'delete-slice-tags': {
657 $slice_id = intval($_POST['slice_id']);
658 $slice_tag_ids = array_map("intval", $_POST['slice_tag_ids']);
661 foreach($slice_tag_ids as $slice_tag_id) {
662 if ($api->DeleteSliceTag($slice_tag_id)) $count += 1;
664 drupal_set_error("Could not delete slice tag: slice_tag_id = $slice_tag_id");
669 drupal_set_message ("Deleted $count slice tag(s)");
670 plc_redirect(l_slice($slice_id) . "&show_tags=true" );
674 case 'add-slice-tag': {
675 $slice_id = intval($_POST['slice_id']);
676 $tag_type_id = intval($_POST['tag_type_id']);
677 $value = $_POST['value'];
678 $node_id = intval($_POST['node_id']);
679 $nodegroup_id = intval($_POST['nodegroup_id']);
683 $result = $api->AddSliceTag($slice_id, $tag_type_id, $value, $node_id);
684 } elseif ($nodegroup_id) {
685 $result = $api->AddSliceTag($slice_id, $tag_type_id, $value, null, $nodegroup_id);
687 $result = $api->AddSliceTag($slice_id, $tag_type_id, $value);
690 drupal_set_message ("Added slice tag.");
692 drupal_set_error("Could not add slice tag");
693 if ($_POST['sliver_action'])
694 plc_redirect(l_sliver($node_id,$slice_id));
696 plc_redirect(l_slice($slice_id) . "&show_tags=true" );
700 //////////////////////////////////////////////////////////// tag types
702 case 'update-tag-type': {
704 $tag_type_id= intval( $_POST['tag_type_id'] );
705 $tagname = $_POST['tagname'];
706 $min_role_id= intval( $_POST['min_role_id'] );
707 $description= $_POST['description'];
708 $category= $_POST['category'];
710 // make tag_type_fields dict
711 $tag_type_fields= array( "min_role_id" => $min_role_id,
712 "tagname" => $tagname,
713 "description" => $description,
714 "category" => $category,
717 if ($api->UpdateTagType( $tag_type_id, $tag_type_fields ) == 1)
718 drupal_set_message ("Tag type $tagname updated");
720 drupal_set_error ("Could not update tag type $tag_type_id\n".$api->error());
721 plc_redirect(l_tag($tag_type_id));
724 case 'add-tag-type': {
726 $tagname = $_POST['tagname'];
727 $min_role_id= intval( $_POST['min_role_id'] );
728 $description= $_POST['description'];
729 $category= $_POST['category'];
731 // make tag_type_fields dict
732 $tag_type_fields= array( "min_role_id" => $min_role_id,
733 "tagname" => $tagname,
734 "description" => $description,
735 "category" => $category,
739 $tag_type_id=$api->AddTagType( $tag_type_fields );
740 if ($tag_type_id > 0)
741 drupal_set_message ("tag type $tag_type_id created");
743 drupal_set_error ("Could not create tag type $tagname");
744 plc_redirect( l_tags());
747 case 'delete-tag-types': {
748 $tag_type_ids = $_POST['tag_type_ids'];
749 if ( ! $tag_type_ids) {
750 drupal_set_message("action=$action - No tag selected");
755 foreach ($tag_type_ids as $tag_type_id)
756 if ($api->DeleteTagType(intval($tag_type_id)) != 1)
761 drupal_set_message ("Deleted $counter tag(s)");
763 drupal_set_error ("Could not delete all selected tags, only $counter were removed");
764 plc_redirect (l_tags());
768 //////////////////////////////////////// tags
769 case 'set-tag-on-node':
770 case 'set-tag-on-interface': {
773 if ($action == 'set-tag-on-node') $node_mode=true;
776 $node_id = intval($_POST['node_id']);
778 $interface_id=intval($_POST['interface_id']);
779 $tag_type_id = intval($_POST['tag_type_id']);
780 $value = $_POST['value'];
782 $tag_types=$api->GetTagTypes(array($tag_type_id));
783 if (count ($tag_types) != 1) {
784 drupal_set_error ("Could not locate tag_type_id $tag_type_id </br> Tag not set.");
787 $tags = $api->GetNodeTags (array('node_id'=>$node_id, 'tag_type_id'=> $tag_type_id));
789 $tags = $api->GetInterfaceTags (array('interface_id'=>$interface_id, 'tag_type_id'=> $tag_type_id));
790 if ( count ($tags) == 1) {
793 $tag_id=$tag['node_tag_id'];
794 $result=$api->UpdateNodeTag($tag_id,$value);
796 $tag_id=$tag['interface_tag_id'];
797 $result=$api->UpdateInterfaceTag($tag_id,$value);
800 drupal_set_message ("Updated tag, new value = $value");
802 drupal_set_error ("Could not update tag");
805 $tag_id = $api->AddNodeTag($node_id,$tag_type_id,$value);
807 $tag_id = $api->AddInterfaceTag($interface_id,$tag_type_id,$value);
809 drupal_set_message ("Created tag, new value = $value");
811 drupal_set_error ("Could not create tag");
816 plc_redirect (l_node($node_id));
818 plc_redirect (l_interface($interface_id));
821 case 'delete-node-tags' :
822 case 'delete-interface-tags' : {
825 if ($action == 'delete-node-tags') $node_mode=true;
828 $tag_ids=$_POST['node_tag_ids'];
830 $tag_ids=$_POST['interface_tag_ids'];
833 drupal_set_message("action=$action - No tag selected");
838 foreach( $tag_ids as $tag_id ) {
840 $retcod = $api->DeleteNodeTag( intval( $tag_id ));
842 $retcod = $api->DeleteInterfaceTag( intval( $tag_id ));
849 drupal_set_message ("Deleted $counter tag(s)");
851 drupal_set_error ("Could not delete all selected tags, only $counter were removed");
853 plc_redirect(l_node($_POST['node_id']));
855 plc_redirect(l_interface($_POST['interface_id']));
859 ////////////////////////////////////////
862 plc_debug('GET',$_GET);
863 plc_debug('POST',$_POST);
864 plc_debug('FILES',$_FILES);
869 plc_error ("Unknown action $action in actions.php");