Delete all flags from flagged content

Public

This module removes all flags from flagged content

</> CopyGet raw version
php
  1. <?php
  2.  
  3. /*
  4.  ** ! for Flag 3.xx
  5.  */
  6.  
  7. function flag_delete_menu() {
  8. $items = array();
  9.  
  10. $items['flags/remove/uid/%user'] = array(
  11. 'page callback' => 'flag_delete_remove_flags',
  12. 'page arguments' => array('uid', 3),
  13. 'access callback' => 'user_access',
  14. 'access arguments' => array('access content'),
  15. 'type' => MENU_CALLBACK,
  16. );
  17.  
  18. $items['flags/remove/sid'] = array(
  19. 'page callback' => 'flag_delete_remove_flags',
  20. 'page arguments' => array('sid'),
  21. 'access callback' => 'user_access',
  22. 'access arguments' => array('access content'),
  23. 'type' => MENU_CALLBACK,
  24. );
  25.  
  26. return $items;
  27. }
  28.  
  29. function flag_delete_remove_flags($type, $id = 0) {
  30. if ($type == 'sid') {
  31. $id = session_api_get_sid();
  32. } else {
  33. $id = $id->uid;
  34. }
  35. $done = flag_delete_reset($id, $type);
  36. $destination = drupal_get_destination();
  37. drupal_goto($destination['destination']);
  38. }
  39.  
  40. function flag_delete_reset($id, $type) {
  41. $query = db_delete('flagging')->condition($type, $id);
  42. return $query->execute();
  43. }
  44.  
  45. function flag_delete_link() {
  46. global $user;
  47. $output = '';
  48. $p = isset($_GET['q']) ? $_GET['q'] : '<front>';
  49. $destination = url($p, array('absolute' => TRUE));
  50. $path = 'flags/remove/';
  51. if ($user->uid > 0) {
  52. $path .= 'uid/' . $user->uid;
  53. } else {
  54. $path .= 'sid';
  55. }
  56. $output = l(t('Clear flags'), $path, array('query' => array('destination' => $destination), 'attributes' => array('class' => 'btn btn-mini btn-danger')));
  57. return $output;
  58. }

Paste in block with your Bookmarks

</> CopyGet raw version
php
  1. <?php print(flag_delete_link()); ?>

Comments

valentine's picture

As an jewelry lover, an individual learn your current value http://www.onlinevalentinesgifts.com/valentines-day-jewelry-gifts.html of an good piece. Not lone does the pair regarding earrings, the necklace, wedding band, or maybe a good bracelet shop brilliant with a good daily basis or even in special occasions, but the idea delivers happiness and also enjoyment for the wearer in the same way well. Regardless of whether you\'ve spent an purchase connected with night out to look for simply just your own correct piece, searching until you could have located your perfect make by merely your own correct jewelry designer, subsequently the piece is usually sure to help bring an individual a good sense associated with enjoyment whilst wearing it proudly.