Fix for Triggerblock module which may be nice to create?

  1. <?php
  2. /**
  3.   Triggerblock allows you to trigger when the triggerblock is shown.
  4.  
  5.   It also adds a new action which will publish old posts that are both sticky and promoted.
  6.   The sticky bit will be set to 0;
  7.  
  8.   This allows you to get a node published after the authoring date only by
  9.   setting it promoted, unpublished and sticky.
  10. */
  11.  
  12. function triggerblock_perm() {
  13.   return array('access');
  14. }
  15.  
  16. function triggerblock_block($op='list', $delta=0) {
  17.   if ($op == 'list') {
  18.     $block[0]['info'] = t('Allows you to trigger when the block is shown');
  19.     return $block;
  20.   }
  21.   else if ($op == 'view') {
  22.         module_invoke_all('triggerblock', $op);
  23.     return array('subject' => '', 'content' => '<!-- trigger block -->');
  24.   }
  25. }
  26.  
  27. /**
  28.  * Implementation of hook_hook_info().
  29.  */
  30. function triggerblock_hook_info() {
  31.   return array(
  32.     'triggerblock' => array(
  33.       'triggerblock' => array(
  34.         'view' => array(
  35.           'runs when' => t('The triggerblock is viewed.'),
  36.         ),
  37.       ),
  38.     ),
  39.   );
  40. }
  41.  
  42. /**
  43. * Implementation of hook_action_info().
  44. */
  45. function triggerblock_action_info() {
  46.   return array(
  47.     'triggerblock_publish_old_promoted_sticky_unpublised_clean_action' => array(
  48.       'description' => t('Publish any node that is sticky, promoted and unpublished and unstick it.'),
  49.       'type' => 'system',
  50.       'configurable' => FALSE,
  51.       'hooks' => array(
  52.         'any' => TRUE,
  53.         ),
  54.       ),
  55.     );
  56. }
  57.  
  58.  
  59. /**
  60. * Implementation of a Drupal action.
  61. * Blocks the current user.
  62. */
  63. function triggerblock_publish_old_promoted_sticky_unpublised_clean_action(&$object, $context = array()) {
  64.         db_query('UPDATE {node} SET sticky=0, status=1 WHERE sticky = 1 AND status = 0 AND promote = 1 AND created <= UNIX_TIMESTAMP()');
  65. }

Submit Fix

Any tags you'd like to associate with your code, delimitered by commas (example: Views, CCK, Module, etc).
Select the syntax highlighting mode to use.