Swampcritter

excuses-module

Mar 26th, 2014
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. /**
  2. * Implements hook_block_info().
  3. */
  4.  
  5. function excuse_block_info() {
  6. //$blocks = array();
  7. $blocks['info'] = array(
  8. 'info' => t('Excuses'),
  9. 'cache' => DRUPAL_NO_CACHE,
  10. 'status' => 1,
  11. );
  12. return $blocks;
  13. }
  14.  
  15. /**
  16. * Implements hook_block_view().
  17. */
  18.  
  19. function excuse_block_view($delta = '') {
  20. $block = array();
  21. switch ($delta) {
  22. case 'info':
  23. $block['subject'] = t('Excuses');
  24. $block['content'] = t($_excuse_block_content());
  25. break;
  26. }
  27. return $block;
  28. }
  29.  
  30. /**
  31. * Implements hook_block_content().
  32. */
  33.  
  34. function _excuse_block_content() {
  35.  
  36. $excusefile = "./excuses.txt"
  37.  
  38. if (!$excuses = @file($excusefile))
  39. return "couldn't read excuse file '$excusefile'";
  40.  
  41. mt_srand((double)microtime()*1000000);
  42. return $excuses[mt_rand(0, count($excuses)-1)];
  43. }
Advertisement
Add Comment
Please, Sign In to add comment