fix missing "save configuration" submit button and add a block listed recent trackbacks

shunz - May 16, 2005 - 07:06
Project:TrackBack
Version:4.6.x-1.x-dev
Component:Other
Category:feature request
Priority:normal
Assigned:shunz
Status:closed
Description

1. modify the function trackback_configure() to

function trackback_configure() {
  if ($_POST) {
    system_settings_save();
  }
  $numbers = drupal_map_assoc(array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 25, 30));
  $formitems = form_radios(t('Auto-detection'), 'trackback_auto_detection_enabled', variable_get('trackback_auto_detection_enabled', 1), array(0 => t('Disable auto-detection.'), 1 => t('Enable auto-detection.'), 2 => t('Run auto-detection on cron')), t('If auto-detection is enabled, each URL in any posted content (whether in textile, link, or plain-text form) will be checked for a trackback URL upon submission.  For each URL in the body of the posted content, trackback will check to see if that URL accepts trackbacks from other sites. If a URL accepts trackbacks, trackback will ping the trackback URL found on that page if one has been posted at that URL.<br>*note: This has the potential to take a very long time depending on the amount of links you have in your posts. Using the \'Run auto-detection on cron\' option delays the most time consuming part of the process to when cron is run on the site. This speeds perfomance when editing and creating content, but delays trackbacks until cron is run.'));
  $formitems .= form_radios(t('Trackback moderation'), 'trackback_moderation', variable_get('trackback_moderation', 0), array(0 => t('Disable moderation for trackbacks sent to this site.'), 1 => t('Enable moderation for trackbacks sent to this site.')), t('Enabling moderation forces every received trackback to be approved before it will appear on your site.  The moderation queue can then be viewed on the %linked_page.', array('%linked_page' => l(t('trackback administration page'), 'admin/trackback/list/approval'))));
  $formitems .= form_select(t('Number of trackbacks to display'),'trackbacks_display_number',variable_get('trackbacks_display_number', 10), $numbers,t('How many trackbacks are displayed in the recent trackbacks block'));
  $output = form_group(t('Trackback configuration'), $formitems);
 
  print theme('page', system_settings_form($output));
}

2. add a function trackback_block()

function trackback_block($op = 'list', $delta = 0) {

  $num = variable_get('trackbacks_display_number', 10);
  if ($op == 'list') {
    $blocks[0]['info'] = t('Recent trackbacks received');
  }
  else {
        $result = db_query_range('SELECT * FROM {trackback_received} WHERE status=1 ORDER BY created DESC', 0, $num);
      $items = array();
      while ($trackbacks = db_fetch_object($result)) {
      $items[] = l(truncate_utf8(strip_tags($trackbacks->subject),27), 'node/'. $trackbacks->nid, NULL, NULL, 'trackback-'. $trackbacks->trid) .'<br />'. t('%time ago', array('%time' => format_interval(time() - $trackbacks->created)));
    }
    $blocks['subject'] = t('Recent trackbacks');
    $blocks['content'] = theme('item_list', $items);
  }
  return $blocks;
}

more infomation please visit(chinese utf-8):
http://www.shunz.net/node/203

#1

ankur - May 17, 2005 - 04:13
Category:support request» feature request

Committed to CVS HEAD, DRUPAL-4-6

The issue of the missing "Save Configuration" button was resolved a few commits ago. However, the version of trackback_configure() submitted above was more cleanly coded than what I originally had in there and also added a "Reset defaults" button as well as a setting for how many trackbacks to list in the "Recent trackbacks" block, also added in this "patch".

For a diff to the previous revision, please see
http://cvs.drupal.org/viewcvs/drupal/contributions/modules/trackback/tra...

A few notes to 'shunz' for future reference:

1. The convention on drupal.org is to submit patch files created by the use of "diff". In the future, please follow the guidelines described in http://drupal.org/node/22568 for creating and submitting patch files.

2. Please make sure to set the most appropriate category and component in the future, when submitting an issue.

3. Finally, if not mentioned in the references listed in (1) above, please make sure that each modification is submitted as a seperate issue, in a seperate patch file. In the above case, the addition of the trackback_block() function and the settings for the trackback block in trackback_configure() should've been submitted as a seperate patch in a seperate issue, while your code clean-ups to trackback_configure() shoudl've been submitted to its own issue with its own patch file.

I go to the trouble of saying this because your changes were good ones and failing to follow the above conventions may make it harder for you to contribute your goodness to other Drupal projects on this site, as the maintainers for other projects may be less accomodating when it comes to testing and committing your suggested changes...

Thanks for the "patch" though.

-Ankur

#2

shunz - May 18, 2005 - 12:42

sorry,I did not follow the conventions because my poor English.

#3

Anonymous - June 1, 2005 - 12:58
 
 

Drupal is a registered trademark of Dries Buytaert.