Fix for The admin panel isn't showing despite clearing the cache a few times.

  1. <?php
  2. // $Id$
  3.  
  4. /**
  5. * Display help and module information
  6. * @param path which path of the site we're displaying help
  7. * @param arg array that holds the current path as would be returned from arg() function
  8. * @return help text for the path
  9. */
  10. function onthisdate_help($path, $arg) {
  11.   $output = '';
  12.  
  13.   switch ($path) {
  14.     case "admin/help#onthisdate":
  15.       $output = '<p>'.  t("Displays links to nodes created on this date") .'</p>';
  16.       break;
  17.   }
  18.  
  19.   return $output;
  20. } // function onthisdate_help
  21.  
  22. /**
  23. * Valid permissions for this module
  24. * @return array An array of valid permissions for the onthisdate module
  25. */
  26.  
  27. function onthisdate_perm() {
  28.   return array('access onthisdate content');
  29. } // function onthisdate_perm()
  30.  
  31. /**
  32. * Generate HTML for the onthisdate block
  33. * @param op the operation from the URL
  34. * @param delta offset
  35. * @returns block HTML
  36. */
  37. function onthisdate_block($op='list', $delta=0) {
  38.  
  39.   // listing of blocks, such as on the admin/block page
  40.   if ($op == "list") {
  41.     $block[0]["info"] = t('On This Date');
  42.     return $block;
  43.   } else if ($op == 'view') {
  44.  
  45.     // our block content
  46.     // Get today's date
  47.     $today = getdate();
  48.  
  49.     // calculate midnight one week ago
  50.     $start_time = mktime(0, 0, 0,
  51.                          $today['mon'], ($today['mday'] - 7), $today['year']);
  52.  
  53.     // we want items that occur only on the day in question, so  
  54.     // calculate 1 day
  55.     $end_time = $start_time + 86400;  
  56.     // 60 * 60 * 24 = 86400 seconds in a day
  57.  
  58.     $limitnum = variable_get("onthisdate_maxdisp", 3);
  59.     $query = "SELECT nid, title, created FROM "."{node} WHERE created >= %d "."AND created <= %d";
  60.  
  61.     $result = db_query_range($query, $start_time, $end_time, 0, $limitnum);
  62.     // content variable that will be returned for display    
  63.     $block_content = '';
  64.  
  65.     while ($links = db_fetch_object($result)) {
  66.       $block_content .=  l($links->title, 'node/'. $links->nid) .'<br />';
  67.     }
  68.  
  69.     // check to see if there was any content before setting up
  70.     //  the block  
  71.     if ($block_content == '') {    
  72.       /* No content from a week ago.  If we return nothing, the block  
  73.        * doesn't show, which is what we want. */
  74.       return;
  75.     }
  76.  
  77.     // set up the block  
  78.     $block['subject'] = 'On This Date';  
  79.     $block['content'] = $block_content;
  80.     return $block;
  81.  
  82.   }
  83.  
  84.   function onthisdate_admin() {
  85.  
  86.     $form['onthisdate_maxdisp'] = array(
  87.       '#type' => 'textfield',
  88.       '#title' => t('Maximum number of links'),
  89.       '#default_value' => variable_get('onthisdate_maxdisp', 3),
  90.       '#size' => 2,
  91.       '#maxlength' => 2,
  92.       '#description' => t("The maximum number of links to display in the block."),
  93.       '#required' => TRUE,
  94.     );
  95.  
  96.     return system_settings_form($form);
  97.   }
  98.  
  99.   function onthisdate_menu() {
  100.  
  101.     $items = array();
  102.  
  103.     $items['admin/settings/onthisdate'] = array(
  104.       'title' => 'On this date module settings',
  105.       'description' => 'Description of your On this date settings control',
  106.       'page callback' => 'drupal_get_form',
  107.       'page arguments' => array('onthisdate_admin'),
  108.       'access arguments' => array('access administration pages'),
  109.       'type' => MENU_NORMAL_ITEM,
  110.      );
  111.  
  112.     return $items;
  113.   }
  114.  
  115. } // end onthisdate_block

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.