Index: trackback.admin.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/trackback/trackback.admin.inc,v retrieving revision 1.1.2.1 diff -u -r1.1.2.1 trackback.admin.inc --- trackback.admin.inc 8 Apr 2008 15:24:14 -0000 1.1.2.1 +++ trackback.admin.inc 23 Oct 2008 14:53:42 -0000 @@ -16,6 +16,16 @@ * Menu callback; present an administrative trackback listing. */ function trackback_admin_overview(&$form_state, $type = 'new') { + + // Disable Approval Queue if moderation isn't enabled + if(variable_get('trackback_moderation', 0) == 0 && $type == 'approval') { + $form = array(); + $form['trackback_message'] = array( + '#value' => t('Approval queue is disabled, enable in !url', array('!url' => l('Trackback settings', 'admin/content/trackback/settings'))), + ); + return $form; + } + $operations = array(); if ($type == 'new') { $operations['unpublish'] = t('Unpublish the selected trackbacks'); @@ -23,6 +33,7 @@ else { $operations['publish'] = t('Publish the selected trackbacks'); } + if (TRACKBACK_WITH_SPAM) { $operations['_trackback_as_spam'] = t('Mark the selected trackbacks as spam'); $operations['_trackback_as_notspam'] = t('Mark the selected trackbacks as not spam'); @@ -145,40 +156,125 @@ return theme('table', $header, $rows); } -function trackback_configure() { - $form['trackback_auto_detection_enabled'] = array( +function trackback_configure() { + + $form['trackback_auto_detection'] = array( + '#type' => 'fieldset', + '#title' => t('Auto-detection'), + '#collapsible' => TRUE, + '#collapsed' => TRUE, + '#description' => t('Auto-detection for pings to other sites.'), + ); + + $form['trackback_auto_detection']['trackback_auto_detection_enabled'] = array( '#type' => 'radios', - '#title' => t('Auto-detection'), '#default_value' => variable_get('trackback_auto_detection_enabled', 0), - '#options' => array(t('Disabled'), t('Enabled'), t('Run auto-detection on cron')), - '#description' => 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.
*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.') + '#options' => array( + t('Disabled'), + t('Enabled'), + t('Run auto-detection on cron') + ), + '#description' => 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.
*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.'), ); - $form['trackback_link_only'] = array( + + $form['trackback_auto_detection']['trackback_link_only'] = array( '#type' => 'checkbox', '#title' => t('Link only'), '#default_value' => variable_get('trackback_link_only', 0), '#description' => t('If checked, auto-detection will check link only.') ); - $form['trackback_moderation'] = array( + + $form['trackback_retention_settings'] = array( + '#type' => 'fieldset', + '#title' => t('Trackback retention settings'), + '#description' => t(''), + '#collapsible' => TRUE, + '#collapsed' => TRUE, + ); + + $form['trackback_retention_settings']['trackback_moderation'] = array( '#type' => 'radios', '#title' => t('Trackback moderation'), '#default_value' => variable_get('trackback_moderation', 0), '#options' => array(t('Disabled'), t('Enabled')), '#description' => 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/content/trackback/list/approval'))) ); - $form['trackback_reject_oneway'] = array( + + $form['trackback_retention_settings']['trackback_reject_oneway'] = array( '#type' => 'radios', '#title' => t('Reject one-way trackbacks'), '#default_value' => variable_get('trackback_reject_oneway', 0), '#options' => array(t('Disabled'), t('Enabled')), '#description' => t('If enabled, trackbacks that the sender page does not refer to your site will be rejected.') ); - $form['trackback_view'] = array( + + /** + * Setting for Trackback display (trackbacks and Trackback-URL) + */ + $form['trackback_display'] = array( + '#type' => 'fieldset', + '#title' => t('Trackback display'), + '#description' => t('Settings to configure Trackback displaing modes'), + '#collapsible' => TRUE, + '#collapsed' => TRUE, + ); + + // Setting to hide/show trackback counts in links + $form['trackback_display']['trackback_links_count_display'] = array( + '#type' => 'checkbox', + '#title' => t('Display Trackback count in links'), + '#default_value' => variable_get('trackback_links_count_display', 1), + ); + + // Location to display Trackbacks + $form['trackback_display']['trackback_view'] = array( '#type' => 'radios', '#title' => t('Location of received trackbacks'), '#default_value' => variable_get('trackback_view', 0), - '#options' => array(t('Display below post'), t('Display on separate page'), t('Display in block')) + '#options' => array( + t('Display below post'), + t('Display on separate page'), + t('Display in block') + ), ); + + // Setting to place Trackback URL + $form['trackback_display']['trackback_url_display'] = array( + '#type' => 'radios', + '#title' => t('Trackback URL display position'), + '#description' => t('Setting for displayed trackback URL in node view. RDF tags will always be added in HTML code.'), + '#default_value' => variable_get('trackback_url_display', 'default'), + '#options' => array( + 'default' => t('Below post'), + 'hide' => t('Hide from post'), + 'links' => t('Display in links'), + 'links-teaser' => t ('Display in links (only in teaser view)'), + 'links-full' => t ('Display in links (only in full-node view)') + ), + ); + + + /** + * Mass edit for node-type setting + */ + $form['trackback_nodetypes'] = array( + '#type' => 'fieldset', + '#title' => t('Node types'), + '#description' => t('Mass-Edit of node type trackback settings'), + '#collapsible' => TRUE, + '#collapsed' => TRUE, + ); + $node_types = node_get_types(); + foreach($node_types as $key => $type) { + $form['trackback_nodetypes']['trackback_' . $key] = array( + '#type' => 'checkbox', + '#default_value' => _trackback_node_type($key), + '#title' => $type->name, + ); + } + + $form['#tree'] = FALSE; + return system_settings_form($form); } Index: trackback.info =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/trackback/trackback.info,v retrieving revision 1.2 diff -u -r1.2 trackback.info --- trackback.info 12 Jul 2007 17:25:08 -0000 1.2 +++ trackback.info 6 Sep 2008 13:24:29 -0000 @@ -1,5 +1,4 @@ ; $Id: trackback.info,v 1.2 2007/07/12 17:25:08 zorac Exp $ name = Trackback description = Allow for sending and receiving TrackBacks, which is a way for sites to notify another that they have commented on a post. -version = VERSION core = 6.x Index: trackback.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/trackback/trackback.module,v retrieving revision 1.75.2.3 diff -u -r1.75.2.3 trackback.module --- trackback.module 13 May 2008 19:56:40 -0000 1.75.2.3 +++ trackback.module 23 Oct 2008 15:03:17 -0000 @@ -98,8 +98,12 @@ return theme('trackbacks', $received); } } - +/** + * hook_form_alter() callback + */ function trackback_form_alter(&$form, $form_state, $form_id) { + + // Add settings for node_type edit form if ($form_id == 'node_type_form' && isset($form['identity']['type'])) { $form['workflow']['trackback'] = array( '#type' => 'radios', @@ -109,6 +113,7 @@ '#description' => t('Enable trackbacks for this node type.') ); } + // Add trackback settings on node creation/edit form else if (isset($form['type']) && $form['type']['#value'] .'_node_form' == $form_id) { $node = $form['#node']; if (_trackback_node_type($node->type)) { @@ -117,12 +122,22 @@ '#title' => t('Trackbacks'), '#collapsible' => TRUE ); - $form['trackback']['can_receive'] = array( - '#type' => 'checkbox', - '#title' => t('Allow Trackbacks'), - '#default_value' => isset($node->can_receive) ? $node->can_receive : 1, - '#description' => t('Allow other posts to send trackbacks to this content.') - ); + + if (user_access('change node trackback setting')) { + $form['trackback']['can_receive'] = array( + '#type' => 'checkbox', + '#title' => t('Allow Trackbacks'), + '#default_value' => isset($node->can_receive) ? $node->can_receive : 1, + '#description' => t('Allow other posts to send trackbacks to this content.') + ); + } + else { + $form['trackback']['can_receive'] = array( + '#type' => 'value', + '#value' => isset($node->can_receive) ? $node->can_receive : 1, + ); + } + $form['trackback']['trackback_urls'] = array( '#type' => 'textarea', '#title' => t('Send Trackbacks'), @@ -170,6 +185,10 @@ } } +function _trackback_get_url(&$node) { + return url('trackback/'. $node->nid, array('absolute' => TRUE)); +} + function trackback_nodeapi(&$node, $op, $teaser = NULL, $page = NULL) { switch ($op) { case 'load': @@ -184,15 +203,21 @@ $node->content['trackback'] = array('#weight' => 12); if ($node->can_receive) { $url = url('node/'. $node->nid, array('absolute' => TRUE)); - $tb_url = url('trackback/'. $node->nid, array('absolute' => TRUE)); + $tb_url = _trackback_get_url($node); $autodetect = "\n\n"; - $node->content['trackback']['autodetect'] = array('#value' => $autodetect, '#weight' => -2); - if (!$teaser) { - $node->content['trackback']['url'] = array('#value' => theme('trackback_url', $tb_url), '#weight' => -1); + $node->content['trackback']['autodetect'] = array( + '#value' => $autodetect, + '#weight' => -2 + ); + if (!$teaser && variable_get('trackback_url_display', 'default') == 'default') { + $node->content['trackback']['url'] = array( + '#value' => theme('trackback_url', $tb_url), + '#weight' => -1 + ); } } if (!$teaser && variable_get('trackback_view', 0) == 0) { @@ -241,16 +266,29 @@ $links = array(); switch ($type) { case 'node': - if ($teaser && isset($node->can_receive)) { - $count = db_result(db_query("SELECT count(*) FROM {trackback_received} WHERE nid=%d AND status=1", $node->nid)); - if ($count) { - $links[] = array( - 'title' => format_plural($count, '1 trackback', '@count trackbacks'), - 'href' => _trackback_path($node), - 'fragment' => 'trackbacks' + if (isset($node->can_receive)) { + if (variable_get('trackback_url_display', 'default') == 'links' || + (!$teaser && variable_get('trackback_url_display', 'default') == 'links-full') || + ($teaser && variable_get('trackback_url_display', 'default') == 'links-teaser')) { + $links['trackback-url'] = array( + 'title' => t('Trackback URL'), + 'href' => _trackback_get_url($node), + 'attributes' => array('title' => t('Trackback URL for "%nodetitle"', array('%nodetitle' => $node->title))), ); } - } + if ($teaser && variable_get('trackback_links_count_display', 1) == 1) { + $count = db_result(db_query("SELECT count(*) FROM {trackback_received} WHERE nid=%d AND status=1", $node->nid)); + if ($count) { + $links['trackback_trackbacks'] = array( + 'title' => format_plural($count, '1 trackback', '@count trackbacks'), + 'href' => _trackback_path($node), + ); + // Don't display fragment if trackbacks are displayed on a separate page + if (variable_get('trackback_view', 0) != 1) + $links['trackback_trackbacks']['fragment'] = 'trackbacks'; + } + } + } break; case 'trackback': @@ -272,6 +310,9 @@ return $links; } +/** + * hook_menu() callback + */ function trackback_menu() { $items['admin/content/trackback'] = array( 'title' => 'Trackbacks', @@ -356,8 +397,14 @@ return $items; } +/** + * hook_perm() callback + */ function trackback_perm() { - return array('administer trackbacks'); + return array( + 'administer trackbacks', + 'change node trackback setting', + ); } function _trackback_access($op, $node, $trackback = NULL) { @@ -390,6 +437,9 @@ return trackback_render($node); } +/** + * hook_cron() callback + */ function trackback_cron() { // query for all nodes where $result = db_query('SELECT t.nid, n.status FROM {trackback_node} t INNER JOIN {node} n ON t.nid = n.nid WHERE t.awaiting_cron = 1'); @@ -404,7 +454,9 @@ } } } - +/** + * hook_block() callback + */ function trackback_block($op = 'list', $delta = 0, $edit = array()) { if ($op == 'list') { $blocks[0]['info'] = t('Recent trackbacks'); @@ -415,41 +467,70 @@ return $blocks; } - if ($delta == 0) { - switch ($op) { - case 'configure': - $form['trackback_display_number'] = array( - '#type' => 'select', - '#title' => t('Number of trackbacks to display'), - '#default_value' => variable_get('trackback_display_number', 10), - '#options' => drupal_map_assoc(array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 25, 30)), - '#description' => t('How many trackbacks are displayed in the recent trackbacks block') - ); - return $form; - - case 'save': - variable_set('trackback_display_number', $edit['trackback_display_number']); - break; + switch ($delta) { + case 0: + switch ($op) { + case 'configure': + $form['trackback_display_number'] = array( + '#type' => 'select', + '#title' => t('Number of trackbacks to display'), + '#default_value' => variable_get('trackback_display_number', 10), + '#options' => drupal_map_assoc(array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 25, 30)), + '#description' => t('How many trackbacks are displayed in the recent trackbacks block') + ); + return $form; + break; - case 'view': - $result = db_query_range('SELECT * FROM {trackback_received} WHERE status=1 ORDER BY created DESC', 0, variable_get('trackback_display_number', 10)); - $items = array(); - while ($tb = db_fetch_object($result)) { - $items[] = _trackback_path($tb, truncate_utf8($tb->subject, 128, FALSE, TRUE)) .'
'. t('%time ago', array('%time' => format_interval(time() - $tb->created))); - } - $block['subject'] = t('Recent trackbacks'); - $block['content'] = theme('item_list', $items); - return $block; - } - } - else if ($op == 'view' && variable_get('trackback_view', 0) == 2) { - if (arg(0) == 'node' && is_numeric(arg(1)) && is_null(arg(2))) { - $node = node_load(arg(1)); - if (isset($node->can_receive) and node_access('view', $node) and $block['content'] = trackback_render($node)) { - $block['subject'] = t('Trackbacks'); - return $block; + case 'save': + variable_set('trackback_display_number', $edit['trackback_display_number']); + break; + + case 'view': + $result = db_query_range('SELECT * FROM {trackback_received} WHERE status=1 ORDER BY created DESC', 0, variable_get('trackback_display_number', 10)); + $items = array(); + while ($tb = db_fetch_object($result)) { + $items[] = _trackback_path($tb, truncate_utf8($tb->subject, 128, FALSE, TRUE)) .'
'. t('%time ago', array('%time' => format_interval(time() - $tb->created))); + } + $block['subject'] = t('Recent trackbacks'); + $block['content'] = theme('item_list', $items); + return $block; + break; } - } + break; + case 1: + switch ($op) { + case 'configure': + $form['trackback_block' . $delta . '_display_url'] = array( + '#type' => 'checkbox', + '#title' => t('Display Trackback-URL in block'), + '#default_value' => variable_get('trackback_block' . $delta . '_display_url', 0), + ); + return $form; + break; + + case 'save': + variable_set('trackback_block' . $delta . '_display_url', $edit['trackback_block' . $delta . '_display_url']); + break; + + case 'view': + if (variable_get('trackback_view', 0) == 2 && arg(0) == 'node' && is_numeric(arg(1)) && is_null(arg(2))) { + $node = node_load(arg(1)); + if (isset($node->can_receive) and node_access('view', $node) and $block['content'] = trackback_render($node)) { + if (variable_get('trackback_block' . $delta . '_display_url', 0) == 1) { + $attributes = array( + 'class' => 'trackback-url', + 'title' => t('Trackback URL for "%nodetitle"', array('%nodetitle' => $node->title)) + ); + $block['content'] .= l(t('Trackback URL'), _trackback_get_url($node), array('attributes' => $attributes)); + } + + $block['subject'] = t('Trackbacks'); + return $block; + } + } + break; + } + break; } } @@ -458,7 +539,9 @@ return preg_match('`^(http|https)://'. $uc .'+(#'. $uc .'*)?$`i', $url); } -// Code that adds configurability for trackback features. +/** + * Code that adds configurability for trackback features by node type + */ function _trackback_node_type($type) { static $types = array('story', 'forum', 'blog'); return variable_get('trackback_'. $type, in_array($type, $types) ? 1 : 0);