trackback.module

Tracking 6.x-2.x branch
  1. drupal
    1. 5 contributions/trackback/trackback.module
    2. 6 contributions/trackback/trackback.module

Functions & methods

NameDescription
theme_trackback
theme_trackbacks
theme_trackback_url
trackback_blockImplementation of hook_block()
trackback_delete_trackbacksDelete all Trackbacks for the givend NodeID
trackback_delete_trackbacks_nodetypeDelete all trackback for given node-type @TODO: Implement this function!
trackback_doMaster function for Trackback management
trackback_existsCheck if the given trackback exists in the database
trackback_exit
trackback_form_alterImplementation of hook_form_alter()
trackback_get_object_trackbackReturns an empry Trackback Object
trackback_get_RDFConstruct RDF metadata for Trackback url
trackback_get_receivedReturn an array of Trackbacks object received by the given Node
trackback_get_sentReturns an array of sented trackbacks for given Node,
trackback_get_urlReturns the trackback URL for given node
trackback_helpImplementation of hook_help().
trackback_invoke_trackback
trackback_loadLoad gived TrackbackID from database
trackback_load_receivedLoad received trackback with given TrackbackID
trackback_menuhook_menu() callback
trackback_nodeapiImplementation of hook_nodeapi() @TODO: review!!
trackback_nodetypes_enabledCheck if trackback is enabled for given NodeType
trackback_node_enabledReturns if the given Node can receive trackbacks
trackback_node_typeImplementation of hook_node_type()
trackback_node_type_form_submitAdding/removing trackback for nodetypes
trackback_perm
trackback_receivedHandler function called when a trackback have been successfully received
trackback_receive_xmlrpcXML-RPC callback: process pingback.ping() call.
trackback_render_received
trackback_saveSaves the given Trackback object into DB, trackback->trid is updated
trackback_sent
trackback_themeImplementation of hook_theme()
trackback_xmlrpcImplementation of hook_xmlrpc() Required by Pingback 1.0 specs (http://www.hixie.ch/specs/pingback/pingback) Code taken from pingback.module
_trackback_access
_trackback_build_content
_trackback_do_deleteDelete given TrackbackID from database
_trackback_do_updateUpdate the given Trackback to database
_trackback_enqueue@TODO:

Constants

NameDescription
TRACKBACK_STATUS_PUBLISHED
TRACKBACK_STATUS_SPAM
TRACKBACK_STATUS_SPAM_UNSURE
TRACKBACK_STATUS_UNPUBLISHED
TRACKBACK_WITH_SPAM

File

View source
  1. <?php
  2. define('TRACKBACK_WITH_SPAM', FALSE);
  3. define('TRACKBACK_STATUS_UNPUBLISHED', 0);
  4. define('TRACKBACK_STATUS_PUBLISHED', 1);
  5. define('TRACKBACK_STATUS_SPAM_UNSURE', 2);
  6. define('TRACKBACK_STATUS_SPAM', 3);
  7. /**
  8. * Implementation of hook_theme()
  9. */
  10. function trackback_theme() {
  11. return array(
  12. 'trackback' => array(
  13. 'arguments' => array('trackback' => NULL)
  14. ),
  15. 'trackbacks' => array(
  16. 'arguments' => array('trackbacks' => NULL)
  17. ),
  18. 'trackback_url' => array(
  19. 'arguments' => array('url' => NULL, 'node' => NULL, 'inblock' => NULL)
  20. ),
  21. 'trackback_admin_table' => array(
  22. 'arguments' => array('form' => NULL)
  23. )
  24. );
  25. }
  26. function theme_trackback($trackback, $inblock) {
  27. drupal_add_css(drupal_get_path('module', 'trackback') .'/trackback.css');
  28. $output = '';
  29. if ($inblock) {
  30. $options = variable_get('trackback_block_display_options', array('excerpt'));
  31. $output .= '<div class="trackback" id="trackback-'. $trackback->trid .'">'."\n";
  32. $options['attributes'] = array(
  33. 'title' => t('Read post "%postname" from %sitename', array('%sitename' => $trackback->name, '%postname' => $trackback->subject))
  34. );
  35. $output .= '<span class="trackback-title">'. l($trackback->subject, $trackback->url, $options) .'</span>'."\n";
  36. if (!empty($options['created'])) {
  37. $output .= '<span class="trackback-created">'. t('from %sitename on @date', array('%sitename' => $trackback->name, '@date' => format_date($trackback->created))) .'</span>'."\n";
  38. } else {
  39. $output .= '<span class="trackback-created">'. t('from %sitename', array('%sitename' => $trackback->name)) .'</span>'."\n";
  40. }
  41. if (!empty($options['excerpt'])) {
  42. $output .= '<div class="excerpt">'. check_markup($trackback->excerpt .'[..]') .'</div>'."\n";
  43. }
  44. if (!empty($options['site'])) {
  45. $output .= '<span class="trackback-site">'. t('IP Address: %ip', array('%ip' => $trackback->site)) .'</span>'."\n";
  46. }
  47. $output .= '</div>'."\n";
  48. }
  49. else {
  50. $output = '<div class="trackback" id="trackback-'. $trackback->trid .'">'."\n";
  51. $output .= '<h3 class="title">'. l($trackback->subject, $trackback->url) .'</h3>'."\n";
  52. $output .= '<span class="submitted">'. t('from %sitename on @date', array('%sitename' => $trackback->name, '@date' => format_date($trackback->created))) .'</span>'."\n";
  53. $output .= '<div class="content">'. check_markup($trackback->excerpt) .'</div>'."\n";
  54. if ($links) {
  55. $output .= '<div class="links">'. theme('links', $links) .'</div>'."\n";
  56. }
  57. $output .= '</div>'."\n";
  58. }
  59. return $output;
  60. }
  61. function theme_trackbacks($trackbacks, $inblock) {
  62. if (count($trackbacks) == 0)
  63. return;
  64. $output = '';
  65. if ($inblock) {
  66. if (count($trackbacks) == 0) {
  67. $output = t('No Trackbacks received');
  68. }
  69. else {
  70. $output = theme('item_list', $trackbacks, NULL, 'ul', array('class' => 'trackback-block-list'));
  71. }
  72. }
  73. else {
  74. $output = 'aaaa';
  75. }
  76. return $output;
  77. }
  78. function theme_trackback_url($url, &$node, $inblock = FALSE) {
  79. if ($inblock) {
  80. $options['attributes'] = array(
  81. 'class' => 'trackback-url',
  82. 'title' => t('Trackback URL for "%nodetitle"', array('%nodetitle' => $node->title))
  83. );
  84. return l(t('Trackback-URL'), $url, $options);
  85. }
  86. else
  87. return '<div class="trackback-url">'. theme('box', t('Trackback URL for "%nodetitle"', array('%nodetitle' => $node->title)), $url) .'</div>';
  88. }
  89. /**
  90. * Invoke a hook_trackback() operation in all modules.
  91. *
  92. * @param &$trackback
  93. * A trackback object.
  94. * @param $op
  95. * A string containing the name of the trackback operation.
  96. * - received : the trackback have been received, not already stored into DB ($trackback->trid is NULL)
  97. * modules can set "status" and "status_log" to something useful (see TRACKBACK_STATUS_xxxx defines)
  98. * - inserted : the trackback have been saved into DB (modules can use $trackback->trid value)
  99. * - published : the trackback have been published
  100. * - mark-spam : the trackback have been marked as SPAM content
  101. * - unmark-spam: the trackback have been un-marked from beening SPAM
  102. * - unpublished: the trackback have been un-published
  103. * - deleted : the trackback have been deleted (the Trackback Object is only for read)
  104. *
  105. * - sent : a pingback have been sent
  106. *
  107. * - spam-filtering : a module should present himself for SPAM filtering returning a 'modulename' => TRUE
  108. *
  109. * @return
  110. * The returned value of the invoked hooks.
  111. */
  112. function trackback_invoke_trackback($op, &$trackback) {
  113. $return = array();
  114. foreach (module_implements('trackback') as $name) {
  115. $function = $name .'_trackback';
  116. $result = $function($op, $trackback);
  117. //print __function__ . " --- $function($op) : ". var_export($result, TRUE). "\n";
  118. if (isset($result)) {
  119. if (is_array($result)) {
  120. $return = array_merge($return, $result);
  121. }
  122. else {
  123. $return[$name] = $result;
  124. }
  125. }
  126. }
  127. return $return;
  128. }
  129. function trackback_render_received(&$node, $inblock = FALSE) {
  130. $trackbacks = trackback_get_received($node);
  131. // drupal_setdrupal_set_message(__function__ . var_export($trackbacks, TRUE));
  132. $received = array();
  133. foreach ($trackbacks as $trackback) {
  134. $received[] = theme('trackback', $trackback, $inblock);
  135. }
  136. return theme('trackbacks', $received, $inblock);
  137. }
  138. /**
  139. * Implementation of hook_node_type()
  140. */
  141. function trackback_node_type($op, $info) {
  142. switch($op) {
  143. case 'update':
  144. if (!empty($info->old_type) && $info->old_type != $info->type && trackback_nodetypes_enabled($info->old_type)) {
  145. // drupal_set_message(__function__ .'('. $op. ')');
  146. trackback_nodetypes_enabled($info->old_type, 'delete');
  147. trackback_nodetypes_enabled($info->type, 'add');
  148. }
  149. break;
  150. case 'delete':
  151. if (trackback_nodetypes_enabled($info->type)) {
  152. // drupal_set_message(__function__ .'('. $op. ')');
  153. trackback_nodetypes_enabled($info->type, 'delete');
  154. // @TODO: delete all trackbacks for deleted nodetypes!!!
  155. trackback_delete_trackbacks_nodetype($info->type);
  156. }
  157. break;
  158. }
  159. }
  160. /**
  161. * Adding/removing trackback for nodetypes
  162. */
  163. function trackback_node_type_form_submit(&$form, $form_state) {
  164. $type = $form_state['values']['type'];
  165. if (trackback_nodetypes_enabled($type) != $form_state['values']['trackback']) {
  166. trackback_nodetypes_enabled($type, $form_state['values']['trackback'] == 1 ? 'add' : 'delete');
  167. }
  168. return;
  169. }
  170. /**
  171. * Implementation of hook_form_alter()
  172. */
  173. function trackback_form_alter(&$form, $form_state, $form_id) {
  174. // Add settings for node_type edit form
  175. if ($form_id == 'node_type_form') {
  176. $form['workflow']['trackback'] = array(
  177. '#type' => 'checkbox',
  178. '#title' => t('Enable receiving Trackbacks'),
  179. '#default_value' => trackback_nodetypes_enabled($form['#node_type']->type),
  180. '#description' => t('Enable trackbacks for this node type.')
  181. );
  182. $form['#submit'][] = 'trackback_node_type_form_submit';
  183. }
  184. // Add trackback settings on node creation/edit form
  185. else if (isset($form['type']) && $form['type']['#value'] .'_node_form' == $form_id) {
  186. $node = $form['#node'];
  187. if (trackback_nodetypes_enabled($node->type)) {
  188. // drupal_set_message(__function__);
  189. $form['trackback'] = array(
  190. '#type' => 'fieldset',
  191. '#title' => t('Trackbacks'),
  192. '#collapsible' => TRUE,
  193. '#collapsed' => !isset($node->trackback_urls),
  194. );
  195. if (user_access('change node trackback setting')) {
  196. $form['trackback']['trackback_can_receive'] = array(
  197. '#type' => 'checkbox',
  198. '#title' => t('Enable incoming Trackbacks'),
  199. '#default_value' => isset($node->trackback_can_receive) ? $node->trackback_can_receive : 1,
  200. '#description' => t('Allow other posts to send trackbacks to this content.')
  201. );
  202. }
  203. else {
  204. $form['trackback']['trackback_can_receive'] = array(
  205. '#type' => 'value',
  206. '#value' => isset($node->trackback_can_receive) ? $node->trackback_can_receive : 1,
  207. );
  208. }
  209. if (variable_get('trackback_auto_detection', 'auto') == 'user') {
  210. $form['trackback']['trackback_urls'] = array(
  211. '#type' => 'textarea',
  212. '#title' => t('Send Trackbacks'),
  213. '#default_value' => isset($node->trackback_urls) ? $node->trackback_urls : '',
  214. '#cols' => 80,
  215. '#rows' => 4,
  216. '#description' => t('Enter one URL per line for each trackback you wish to send.'),
  217. '#wysiwyg' => FALSE,
  218. );
  219. }
  220. // if there are any past successful trackbacks from this posting, add them to the node editing page.
  221. // if there are any past unsuccessful trackbacks from this posting, add checkmarks to enable resending them
  222. $past_successes_listing = array();
  223. $options = array();
  224. if (isset($node->nid)) {
  225. $sent_ok = trackback_get_sent($node, 'successful');
  226. if (count($sent_ok)) {
  227. $sent = array();
  228. foreach($sent_ok as $s) {
  229. $sent[$s] = $s;
  230. }
  231. // drupal_set_message(var_export($sent, TRUE));
  232. $form['trackback']['trackbacks_urls'] = array(
  233. '#type' => 'checkboxes',
  234. '#title' => t('Successful sent URLs'),
  235. '#disabled' => 'disabled',
  236. '#default_value' => array_keys($sent),
  237. '#options' => $sent,
  238. );
  239. }
  240. if (TRUE || variable_get('trackback_auto_detection', 'auto') == 'user') {
  241. $sent_err = trackback_get_sent($node, 'error');
  242. // add listing of unsuccessfully trackbacked URLs
  243. if (count($sent_err)) {
  244. $sent = array();
  245. foreach($sent_err as $s) {
  246. $sent[$s] = $s;
  247. }
  248. $form['trackback']['trackback_urls_to_retry'] = array(
  249. '#type' => 'checkboxes',
  250. '#title' => t('Unsuccessful URLs'),
  251. '#default_value' => array(),
  252. '#options' => $sent,
  253. '#description' => t('Attempts to ping these URLs with this post have failed. Mark a check next to the trackback URLs you wish to retry for this post.')
  254. );
  255. }
  256. }
  257. }
  258. }
  259. }
  260. }
  261. /*
  262. function trackback_link($type, $node = NULL, $teaser = FALSE) {
  263. $links = array();
  264. switch ($type) {
  265. case 'node':
  266. if (isset($node->can_receive)) {
  267. if (variable_get('trackback_display_url', 'default') == 'links' ||
  268. (!$teaser && variable_get('trackback_display_url', 'default') == 'links-full') ||
  269. ($teaser && variable_get('trackback_display_url', 'default') == 'links-teaser')) {
  270. $links['trackback-url'] = array(
  271. 'title' => t('Trackback URL'),
  272. 'href' => trackback_get_url($node),
  273. 'attributes' => array('title' => t('Trackback URL for "%nodetitle"', array('%nodetitle' => $node->title))),
  274. );
  275. }
  276. if ($teaser && variable_get('trackback_links_count_display', 1) == 1) {
  277. $count = db_result(db_query("SELECT count(*) FROM {trackback_received} WHERE nid=%d AND status=1", $node->nid));
  278. if ($count) {
  279. $links['trackback_trackbacks'] = array(
  280. 'title' => format_plural($count, '1 trackback', '@count trackbacks'),
  281. 'href' => _trackback_path($node),
  282. );
  283. // Don't display fragment if trackbacks are displayed on a separate page
  284. if (variable_get('trackback_view', 0) != 1)
  285. $links['trackback_trackbacks']['fragment'] = 'trackbacks';
  286. }
  287. }
  288. }
  289. break;
  290. case 'trackback':
  291. if (!$teaser) {
  292. $links['trackback_edit'] = array(
  293. 'title' => t('edit'),
  294. 'href' => 'trackback/edit/'. $node->trid
  295. );
  296. }
  297. $links['trackback_delete'] = array(
  298. 'title' => t('delete'),
  299. 'href' => 'trackback/delete/'. $node->trid
  300. );
  301. if (TRACKBACK_WITH_SPAM) {
  302. $links += _trackback_spam_link($node);
  303. }
  304. break;
  305. }
  306. return $links;
  307. }
  308. */
  309. /**
  310. * hook_menu() callback
  311. */
  312. function trackback_menu() {
  313. // drupal_set_message(__function__);
  314. $items['admin/content/trackback'] = array(
  315. 'title' => 'Trackbacks',
  316. 'description' => 'List and edit site trackbacks and the trackback moderation queue.',
  317. 'page callback' => 'drupal_get_form',
  318. 'page arguments' => array('trackback_admin_overview'),
  319. 'access arguments' => array('administer trackbacks'),
  320. 'file' => 'trackback.admin.inc'
  321. );
  322. // Tabs:
  323. $items['admin/content/trackback/list'] = array(
  324. 'title' => 'List',
  325. 'type' => MENU_DEFAULT_LOCAL_TASK,
  326. 'weight' => -10
  327. );
  328. // Subtabs:
  329. $items['admin/content/trackback/list/published'] = array(
  330. 'title' => 'Published trackbacks',
  331. 'access arguments' => array('administer trackbacks'),
  332. 'type' => MENU_DEFAULT_LOCAL_TASK,
  333. 'weight' => -10
  334. );
  335. $items['admin/content/trackback/list/approval'] = array(
  336. 'title' => 'Approval queue',
  337. 'page arguments' => array('trackback_admin_overview', 'approval'),
  338. 'access arguments' => array('administer trackbacks'),
  339. 'type' => MENU_LOCAL_TASK
  340. );
  341. $items['admin/content/trackback/list/spam'] = array(
  342. 'title' => 'Spam',
  343. 'page arguments' => array('trackback_admin_overview', 'spam'),
  344. 'access arguments' => array('administer trackbacks'),
  345. 'weight' => 10,
  346. 'type' => MENU_LOCAL_TASK
  347. );
  348. $items['admin/content/trackback/settings'] = array(
  349. 'title' => 'Settings',
  350. 'page callback' => 'drupal_get_form',
  351. 'page arguments' => array('trackback_config_form'),
  352. 'access arguments' => array('administer trackbacks'),
  353. 'weight' => 10,
  354. 'type' => MENU_LOCAL_TASK,
  355. 'file' => 'trackback.admin.inc'
  356. );
  357. // Other stuff:
  358. $items['trackback/%node'] = array(
  359. 'title' => 'Trackbacks',
  360. 'page callback' => '_trackback_receive_post',
  361. 'page arguments' => array(1),
  362. 'access arguments' => array('access content'),
  363. 'access callback' => '_trackback_access',
  364. 'access arguments' => array('receive', 1),
  365. 'type' => MENU_CALLBACK,
  366. 'file' => 'trackback-receive.inc'
  367. );
  368. $items['trackback/edit/%trackback'] = array(
  369. 'title' => 'Moderate trackback',
  370. 'page callback' => 'drupal_get_form',
  371. 'page arguments' => array('trackback_edit_form', 2),
  372. 'access callback' => '_trackback_access',
  373. 'access arguments' => array('edit', NULL, 2),
  374. 'type' => MENU_CALLBACK,
  375. 'file' => 'trackback.admin.inc'
  376. );
  377. $items['trackback/delete/%trackback'] = array(
  378. 'title' => 'Delete trackback',
  379. 'page callback' => 'drupal_get_form',
  380. 'page arguments' => array('trackback_delete_form', 2),
  381. 'access callback' => '_trackback_access',
  382. 'access arguments' => array('edit', NULL, 2),
  383. 'type' => MENU_CALLBACK,
  384. 'file' => 'trackback.admin.inc'
  385. );
  386. /*
  387. $items['node/%node/trackback'] = array(
  388. 'title' => 'Trackbacks',
  389. 'page callback' => 'trackback_view_page',
  390. 'page arguments' => array(1),
  391. 'access callback' => '_trackback_access',
  392. 'access arguments' => array('page', 1),
  393. 'weight' => 2,
  394. 'type' => MENU_LOCAL_TASK
  395. );
  396. */
  397. return $items;
  398. }
  399. /**
  400. * hook_perm() callback
  401. */
  402. function trackback_perm() {
  403. return array(
  404. 'administer trackbacks',
  405. 'change node trackback setting',
  406. );
  407. }
  408. function _trackback_access($op, $node, $trackback = NULL) {
  409. // drupal_set_message(__function__ .'('.$op.')');
  410. // print __function__ .'('.$op.')';
  411. switch ($op) {
  412. case 'page':
  413. // drupal_set_message(__function__ . var_export($node->trackback_can_receive, TRUE));
  414. return $node->trackback_can_receive && variable_get('trackback_view', 0) == 1 && node_access('view', $node) && db_result(db_query('SELECT count(*) FROM {trackback_received} WHERE nid=%d AND status=1', $node->nid));
  415. case 'edit':
  416. if (user_access('administer trackbacks')) {
  417. return TRUE;
  418. }
  419. if (empty($node) && !empty($trackback->nid)) {
  420. $node = node_load($trackback->nid);
  421. }
  422. return node_access('update', $node);
  423. case 'receive':
  424. if (variable_get('trackback_receive_post', TRUE) == TRUE)
  425. return $node->trackback_can_receive && node_access('view', $node);
  426. else
  427. return FALSE;
  428. }
  429. }
  430. /*
  431. function trackback_view_page($node) {
  432. drupal_set_title(check_plain($node->title));
  433. return trackback_render_received($node);
  434. }
  435. */
  436. /**
  437. * hook_cron() callback
  438. */
  439. /*
  440. function trackback_cron() {
  441. // query for all nodes where
  442. $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');
  443. while ($node = db_fetch_object($result)) {
  444. // First things first, let's unset the 'awaiting_cron' bit in the {trackback_node} table.
  445. db_query('UPDATE {trackback_node} SET awaiting_cron = 0 WHERE nid = %d', $node->nid);
  446. if ($node->status) {
  447. module_load_include('inc', 'trackback', 'trackback.ping');
  448. $node = node_load($node->nid);
  449. _trackback_ping($node, trackback_urls_via_nodebody($node));
  450. }
  451. }
  452. }
  453. */
  454. /*
  455. function _trackback_valid_url($url) {
  456. $uc = '[a-z0-9;/?:@&=+$,_.!~*\'()%-]';
  457. return preg_match('`^(http|https)://'. $uc .'+(#'. $uc .'*)?$`i', $url);
  458. }
  459. */
  460. /*
  461. function _trackback_path($obj, $text = NULL, $opt = array()) {
  462. static $prefix;
  463. if (!isset($prefix)) {
  464. $prefix = variable_get('trackback_view', 0) == 1 ? '/trackback' : '';
  465. }
  466. if (!isset($text)) {
  467. return 'node/'. $obj->nid . $prefix;
  468. }
  469. if ($obj->status) {
  470. $opt += array('fragment' => 'trackback-'. $obj->trid);
  471. return l($text, 'node/'. $obj->nid . $prefix, $opt);
  472. }
  473. return l($text, 'trackback/edit/'. $obj->trid, $opt);
  474. }
  475. */
  476. function _trackback_build_content($node, $teaser = FALSE) {
  477. unset($node->trackback_can_receive);
  478. return node_build_content($node, $teaser);
  479. }
  480. /**
  481. * Master function for Trackback management
  482. * @param <type> $op
  483. * @param <type> $trackback
  484. */
  485. function trackback_do($op, &$trackback, $cacheclear = FALSE) {
  486. $operated = NULL;
  487. $result = FALSE;
  488. if (is_numeric($trackback)) {
  489. $trackback = trackback_load($trackback);
  490. }
  491. if (is_object($trackback)) {
  492. switch ($op) {
  493. case 'publish':
  494. $trackback->status = TRACKBACK_STATUS_PUBLISHED;
  495. $result = _trackback_do_update($trackback);
  496. $operated = 'published';
  497. break;
  498. case 'unpublish':
  499. $trackback->status = TRACKBACK_STATUS_UNPUBLISHED;
  500. $result = _trackback_do_update($trackback);
  501. $operated = 'unpublished';
  502. break;
  503. case 'mark-spam':
  504. $trackback->status = TRACKBACK_STATUS_SPAM;
  505. $result = _trackback_do_save($trackback);
  506. $operated = 'mark-spam';
  507. break;
  508. case 'unmark-spam':
  509. // What are we gonna do here???
  510. $operated = 'unmark-spam';
  511. break;
  512. case 'delete':
  513. $result = _trackback_do_delete($trackback);
  514. $operated = 'deleted';
  515. break;
  516. default:
  517. drupal_set_message(t('Trackback Operation %op not implemented', array('%op' => $op)));
  518. }
  519. trackback_invoke_trackback($operated, $trackback);
  520. if ($clearcache) {
  521. cache_clear_all();
  522. }
  523. return $result;
  524. }
  525. else {
  526. return FALSE;
  527. }
  528. }
  529. /*
  530. function _trackback_operation($action, $trackback, $clear = TRUE) {
  531. if (is_numeric($trackback)) {
  532. $trackback = trackback_load($trackback);
  533. }
  534. if ($trackback) {
  535. switch ($action) {
  536. case 'publish':
  537. db_query('UPDATE {trackback_received} SET status=1 WHERE trid=%d', $trackback->trid);
  538. $trackback->status = 1;
  539. trackback_invoke_trackback($trackback, $action);
  540. watchdog('trackback', 'Published trackback %subject.', array('%subject' => $trackback->subject), WATCHDOG_NOTICE, _trackback_path($trackback, t('view')));
  541. break;
  542. case 'unpublish':
  543. db_query('UPDATE {trackback_received} SET status=0 WHERE trid=%d', $trackback->trid);
  544. $trackback->status = 0;
  545. trackback_invoke_trackback($trackback, $action);
  546. watchdog('trackback', 'Unpublished trackback %subject.', array('%subject' => $trackback->subject), WATCHDOG_NOTICE, _trackback_path($trackback, t('view')));
  547. break;
  548. case 'delete':
  549. db_query('DELETE FROM {trackback_received} WHERE trid=%d', $trackback->trid);
  550. trackback_invoke_trackback($trackback, $action);
  551. watchdog('trackback', 'Deleted trackback %subject. The trackback was posted to !link.', array('%subject' => $trackback->subject, '!link' => l(url('node/'. $trackback->nid, array('absolute' => TRUE)), 'node/'. $trackback->nid)));
  552. break;
  553. default:
  554. $action($trackback);
  555. break;
  556. }
  557. if ($clear) {
  558. cache_clear_all();
  559. }
  560. }
  561. return $trackback;
  562. }
  563. */
  564. // ==========================================================================================================================
  565. /**
  566. * Implementation of hook_help().
  567. */
  568. function trackback_help($path, $arg) {
  569. if ($path == 'admin/help#trackback') {
  570. module_load_include('inc', 'trackback', 'trackback.admin');
  571. return _trackback_help($path, $arg);
  572. }
  573. }
  574. /**
  575. * Returns if the given Node can receive trackbacks
  576. * @param $nid
  577. * @param $action in check, enable, disable, insert
  578. * @return
  579. */
  580. function trackback_node_enabled($nid, $action = 'check') {
  581. // drupal_set_message(__function__ .'() : '. $action . '=>'.$nid);
  582. switch ($action) {
  583. case 'insert':
  584. db_query("INSERT INTO {trackback_node}(nid, awaiting_cron, can_receive) VALUES(%d, %d, %b)", $nid, 0, 1);
  585. return TRUE;
  586. break;
  587. case 'enable':
  588. db_query("UPDATE {trackback_node} SET can_receive = %b, awaiting_cron = %b WHERE nid = %d", 1, 1, $nid);
  589. return TRUE;
  590. break;
  591. case 'disable':
  592. db_query("UPDATE {trackback_node} SET can_receive = %b, awaiting_cron = %b WHERE nid = %d", 0, 0, $nid);
  593. return TRUE;
  594. break;
  595. default:
  596. $sql = "SELECT can_receive FROM {trackback_node} WHERE nid=%d";
  597. return (boolean) db_result(db_query($sql, $nid));
  598. break;
  599. }
  600. }
  601. /**
  602. * Check if trackback is enabled for given NodeType
  603. * @param nodetype nodeType to check
  604. * @param action to do: check, add or delete
  605. * @return TRUE or FALSE
  606. */
  607. function trackback_nodetypes_enabled($nodetype, $action = 'check') {
  608. // drupal_set_message(__function__ .'() : '. $action . '='.$nodetype);
  609. switch($action) {
  610. case 'check':
  611. return in_array($nodetype, variable_get('trackback_nodetypes', array()), TRUE);
  612. break;
  613. case 'delete':
  614. $types = variable_get('trackback_nodetypes', array());
  615. unset($types[$nodetype]);
  616. variable_set('trackback_nodetypes', $types);
  617. break;
  618. case 'add':
  619. $types = variable_get('trackback_nodetypes', array());
  620. $types[] = $nodetype;
  621. variable_set('trackback_nodetypes', $types);
  622. // @TODO: manage i18sync module view README in i18nsync
  623. /* More fields for a specific content type 'nodetype' only.
  624. $conf['i18nsync_fields_node_nodetype'] = array(
  625. 'field3' => t('Field 3 name'),
  626. ...
  627. );
  628. */
  629. break;
  630. default:
  631. return FALSE;
  632. }
  633. return TRUE;
  634. }
  635. /**
  636. * Implementation of hook_xmlrpc()
  637. * Required by Pingback 1.0 specs (http://www.hixie.ch/specs/pingback/pingback)
  638. * Code taken from pingback.module
  639. */
  640. function trackback_xmlrpc() {
  641. return array(array(
  642. 'pingback.ping', // Method-Name (as in Pingback 1.0 specs)
  643. 'trackback_receive_xmlrpc', // Function callback
  644. array( // Method Signature
  645. 'string', // sourceURI
  646. 'string', // targetURI
  647. 'string' // return value
  648. ),
  649. t('Handles Trackbacks pings.'),
  650. ));
  651. }
  652. /**
  653. * XML-RPC callback: process pingback.ping() call.
  654. * @return xmlrpc server errors as for Pingback 1.0 specs (http://www.hixie.ch/specs/pingback/pingback)
  655. */
  656. function trackback_receive_xmlrpc($sourceURI, $targetURI) {
  657. if (variable_get('trackback_receive_xmlrpc', FALSE)) {
  658. module_load_include('inc', 'trackback', 'trackback-receive');
  659. _trackback_receive_xmlrpc($sourceURI, $targetURI);
  660. }
  661. else
  662. return xmlrpc_server_error(33, t("The specified target URL cannot be used as a target. It either doesn't exist, or it is not a pingback-enabled resource."));
  663. }
  664. /**
  665. * Implementation of hook_nodeapi()
  666. * @TODO: review!!
  667. */
  668. function trackback_nodeapi(&$node, $op, $teaser = NULL, $page = NULL) {
  669. // drupal_set_message(__function__ .'() : '.$op);
  670. if (!variable_get('trackback_receive_post', TRUE) && !variable_get('trackback_receive_xmlrpc', FALSE)) {
  671. // Trackback in't enabled!
  672. return;
  673. }
  674. if (!trackback_nodetypes_enabled($node->type)) {
  675. // This nodetype don't have Trackback enabled
  676. // @TODO: manage nodetype changing
  677. // @TODO: manage enable/disable nodetype deleting old trackbacks?
  678. return;
  679. }
  680. switch ($op) {
  681. // "load" : OK!
  682. case 'load':
  683. $can_receive = FALSE;
  684. if ($node->status) {
  685. $can_receive = trackback_node_enabled($node->nid);
  686. }
  687. // drupal_set_message(__function__ . var_export($can_receive, TRUE));
  688. return array('trackback_can_receive' => $can_receive);
  689. break;
  690. // "view": OK!
  691. case 'view':
  692. // If node can receive trackbacks and isn't in preview mode
  693. if (isset($node->trackback_can_receive) && empty($node->in_preview)) {
  694. // XMLRPC
  695. if (variable_get('trackback_receive_xmlrpc', FALSE)) {
  696. // Insert pingback header when a node is being viewed.
  697. if (arg(0) == 'node' && is_numeric(arg(1)) && arg(3) == NULL) {
  698. drupal_set_header('X-Pingback: '. $GLOBALS['base_url'] .'/xmlrpc.php');
  699. // We should only send the HTTP header and not the <Link>?
  700. // drupal_add_link(array('rel' => $GLOBALS['base_url'] .'/xmlrpc.php'));
  701. }
  702. }
  703. // Trackback using POST/GET url
  704. if (variable_get('trackback_receive_post', TRUE)) {
  705. $node->content['trackback'] = array('#weight' => 12);
  706. $node->content['trackback']['rdf'] = array(
  707. '#value' => trackback_get_RDF($node),
  708. '#weight' => -1
  709. );
  710. if (!$teaser && variable_get('trackback_display_url', 'innode') == 'innode') {
  711. $node->content['trackback']['url'] = array(
  712. '#value' => theme('trackback_url', trackback_get_url($node), $node),
  713. '#weight' => 8,
  714. );
  715. }
  716. }
  717. if (!$teaser && variable_get('trackback_display_node', FALSE)) {
  718. $node->content['trackback']['received'] = array(
  719. '#value' => trackback_render_received($node),
  720. '#weight' => 7,
  721. );
  722. }
  723. }
  724. break;
  725. case 'validate':
  726. /*
  727. if (!empty($node->trackback_urls)) {
  728. foreach (explode("\n", $node->trackback_urls) as $url) {
  729. $url = trim($url);
  730. if ($url && !_trackback_valid_url($url)) {
  731. form_set_error('trackback_urls', t('The trackback url %url is not a valid url.', array('%url' => $url)));
  732. }
  733. }
  734. }
  735. */
  736. break;
  737. case 'insert':
  738. if (trackback_nodetypes_enabled($node->type)) {
  739. trackback_node_enabled($node->nid, 'insert');
  740. $set = ($node->trackback_can_receive && $node->status)? 'enable' : 'disable';
  741. if (isset($node->trackback_can_receive)) {
  742. trackback_node_enabled($node->nid, $set);
  743. }
  744. }
  745. break;
  746. case 'update':
  747. $set = ($node->trackback_can_receive && $node->status)? 'enable' : 'disable';
  748. // drupal_set_message(__function__ .'() : SET='. $set);
  749. if (isset($node->trackback_can_receive)) {
  750. trackback_node_enabled($node->nid, $set);
  751. }
  752. if ($set == 'enable' && variable_get('trackback_sending', 'oncron') == 'onupdate') {
  753. // drupal_set_message(__function__ .'() : send?='. variable_get('trackback_sending', 'oncron'));
  754. // Add this node to the list of awaiting for ping..
  755. global $_trackback_ping_nid;
  756. if (variable_get('trackback_merge_within_translations', TRUE)) {
  757. // If we keep only the "original" source, send pingbacks only from original node?
  758. if (isset($node->tnid) && ($node->nid == $node->tnid)) {
  759. $_trackback_ping_nid[] = $node->tnid;
  760. }
  761. }
  762. else {
  763. $_trackback_ping_nid[] = $node->nid;
  764. }
  765. // drupal_set_message(__function__ .'() : GLOBAL='. var_export($_trackback_ping_nid, TRUE));
  766. }
  767. /*
  768. module_load_include('inc', 'trackback', 'trackback.ping');
  769. global $_trackback_ping_node;
  770. $_trackback_ping_node = drupal_clone($node);
  771. $cron = ($node->status && variable_get('trackback_auto_detection_enabled', 0) == 2);
  772. db_query("UPDATE {trackback_node} SET awaiting_cron=%d, can_receive=%d WHERE nid=%d", $cron, $node->can_receive, $node->nid);
  773. if (!db_affected_rows()) {
  774. db_query("INSERT INTO {trackback_node}(nid, awaiting_cron, can_receive) VALUES(%d, %d, %d)", $node->nid, $cron, $node->can_receive);
  775. }
  776. */
  777. break;
  778. case 'delete':
  779. trackback_delete_trackbacks($node->nid);
  780. break;
  781. }
  782. }
  783. /**
  784. *
  785. */
  786. function trackback_exit() {
  787. global $_trackback_ping_nid;
  788. // drupal_set_message(__function__ .'() : GLOBAL='. var_export($_trackback_ping_nid, TRUE));
  789. if (!empty($_trackback_ping_nid)) {
  790. // If more than one, use a FIFO list and let cron ping the others!
  791. $first = array_shift($_trackback_ping_nid);
  792. if (!empty($_trackback_ping_nid)) {
  793. _trackback_enqueue($_trackback_ping_nid);
  794. }
  795. module_load_include('inc', 'trackback', 'trackback-send');
  796. _trackback_send($first);
  797. }
  798. }
  799. /**
  800. * @TODO:
  801. */
  802. function _trackback_enqueue($nids) {
  803. drupal_set_message(__function__ .'() : NIDs='. var_export($nids, TRUE));
  804. return true;
  805. }
  806. /**
  807. * Handler function called when a trackback have been successfully received
  808. */
  809. function trackback_received(&$trackback) {
  810. // print __function__ . "<br>\n";
  811. trackback_invoke_trackback('received', $trackback);
  812. if ($trackback->status == TRACKBACK_STATUS_SPAM && variable_get('trackback_spam_moderation', 'delete') == 'delete') {
  813. // Auto delete!
  814. watchdog('trackback', 'Auto-Deleted trackback %subject: marked as SPAM (%status_log).', array('%subject' => $trackback->subject, '%status_log' => $trackback->status_log));
  815. return;
  816. }
  817. if (empty($trackback->status)) {
  818. $trackback->status = variable_get('trackback_moderation', TRUE) == FALSE ? TRACKBACK_STATUS_PUBLISHED : TRACKBACK_STATUS_UNPUBLISHED;
  819. }
  820. if (trackback_save($trackback)) {
  821. trackback_invoke_trackback('insert', $trackback);
  822. watchdog('trackback', 'Added trackback %subject.', array('%subject' => $trackback->subject), WATCHDOG_NOTICE);//, _trackback_path($trackback, t('view')));
  823. }
  824. else {
  825. watchdog('trackback', 'Error adding %subject from %site(@status_log).', array('%subject' => $trackback->subject, '%site' => $trackback->site, '@status_log' => $trackback->status_log), WATCHDOG_WARNING);
  826. }
  827. }
  828. /**
  829. * Returns the trackback URL for given node
  830. */
  831. function trackback_get_url(&$node) {
  832. $nid = $node->nid;
  833. if (!empty($node->tnid) && variable_get('trackback_merge_within_translations', TRUE)) {
  834. // Track only the original Node
  835. $nid = $node->tnid;
  836. }
  837. return url('trackback/'. $nid, array('absolute' => TRUE));
  838. }
  839. /**
  840. * Construct RDF metadata for Trackback url
  841. */
  842. function trackback_get_RDF(&$node) {
  843. $url = url('node/'. $node->nid, array('absolute' => TRUE));
  844. $result = "\n<!--\n";
  845. $result .= '<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">'."\n";
  846. $result .= '<rdf:Description rdf:about="'. $url .'"'
  847. .' dc:identifier="'. $url .'"'
  848. .' dc:title="'. strtr(check_plain($node->title), array('--' => '&mdash;')) .'"'
  849. .' trackback:ping="'. trackback_get_url($node) .'" />'."\n";
  850. $result .= '</rdf:RDF>';
  851. $result .= "\n-->\n";
  852. return $result;
  853. }
  854. /**
  855. * Returns an empry Trackback Object
  856. */
  857. function trackback_get_object_trackback() {
  858. $trackback = array(
  859. 'trid' => NULL,
  860. 'nid' => NULL,
  861. 'created' => time(),
  862. 'site' => ip_address(),
  863. 'name' => NULL, // The sender site name of this trackback.
  864. 'subject' => NULL,
  865. 'url' => NULL,
  866. 'excerpt' => NULL,
  867. 'status' => NULL,
  868. 'status_log' => NULL,
  869. );
  870. return (object)$trackback;
  871. }
  872. /**
  873. *
  874. */
  875. function trackback_sent($nid, $url, $success, $protocol) {
  876. $sql = 'INSERT INTO {trackback_sent} (nid, url, successful) VALUES (%d, "%s", %d)';
  877. db_query($sql, $nid, $url, $success);
  878. return TRUE;
  879. }
  880. /**
  881. * Check if the given trackback exists in the database
  882. */
  883. function trackback_exists($trid) {
  884. $params = null;
  885. if (is_numeric($trid)) {
  886. $sql = "SELECT trid FROM {trackback_received} WHERE trid = %d";
  887. $params = $trid;
  888. }elseif (is_array($trid)) {
  889. $sql = "SELECT trid FROM {trackback_received} WHERE nid = %d AND url = '%s'";
  890. $params = array($trid['nid'], $trid['url']);
  891. }
  892. $result = db_query($sql, $params);
  893. return db_result($result);
  894. }
  895. /**
  896. * Delete given TrackbackID from database
  897. */
  898. function _trackback_do_delete(&$trackback) {
  899. drupal_set_message(__function__);
  900. db_query('DELETE FROM {trackback_received} WHERE trid=%d', $trid);
  901. watchdog('trackback', 'Deleted trackback %subject. The trackback was posted to !link.', array('%subject' => $trackback->subject, '!link' => l(url('node/'. $trackback->nid, array('absolute' => TRUE)), 'node/'. $trackback->nid)));
  902. $trackback->trid = NULL;
  903. return TRUE;
  904. }
  905. /**
  906. * Update the given Trackback to database
  907. * @param <type> $trackback
  908. */
  909. function _trackback_do_update(&$trackback) {
  910. //drupal_set_message(__function__ .'('.var_export($trackback, TRUE).')');
  911. if (trackback_exists($trackback->trid)) {
  912. $sql = "UPDATE {trackback_received} SET subject = '%s', excerpt = '%s', status = %d WHERE trid = %d";
  913. $result = db_query($sql,
  914. $trackback->subject,
  915. $trackback->excerpt,
  916. $trackback->status,
  917. $trackback->trid);
  918. return $result;
  919. }
  920. return FALSE;
  921. }
  922. /**
  923. * Load gived TrackbackID from database
  924. */
  925. function trackback_load($trid) {
  926. return db_fetch_object(db_query('SELECT * FROM {trackback_received} WHERE trid=%d', $trid));
  927. }
  928. /**
  929. * Saves the given Trackback object into DB, trackback->trid is updated
  930. * @return TRUE on success, FALSE otherwise
  931. */
  932. function trackback_save(&$trackback) {
  933. drupal_set_message(__function__);
  934. if (!is_object($trackback))
  935. return FALSE;
  936. $trid = trackback_exists(array('trid' => $trackback->nid, 'url' => $trackback->url));
  937. if ($trid) {
  938. $trackback->trid = $trid;
  939. $trackback->status_log = t('Trackback already exists');
  940. return FALSE;
  941. }
  942. else {
  943. $sql = "INSERT INTO {trackback_received} (nid, created, site, name, subject, url, excerpt, status) VALUES (%d, %d, '%s', '%s', '%s', '%s', '%s', %d)";
  944. $result = db_query($sql, $trackback->nid,
  945. $trackback->created,
  946. drupal_substr($trackback->site, 0, 16), // IP is xxx.xxx.xxx.xxx 16 char long
  947. $trackback->name,
  948. drupal_substr($trackback->subject, 0 , 64),
  949. drupal_substr($trackback->url, 0, 255),
  950. drupal_substr($trackback->excerpt, 0, 255), // Max 255 chars (used in .install and tracback_edit form)
  951. $trackback->status
  952. );
  953. if ($result) {
  954. $trackback->trid = db_last_insert_id('trackback_received', 'trid');
  955. return TRUE;
  956. }
  957. }
  958. return FAlSE;
  959. }
  960. /**
  961. * Implementation of hook_block()
  962. */
  963. function trackback_block($op = 'list', $delta = 'trackback_recent', $edit = array()) {
  964. //drupal_set_message($op . ' -- '.$delta);
  965. if ($op == 'list') {
  966. // Recent trackbacks
  967. $blocks['trackback_recent'] = array (
  968. 'info' => t('Recent trackbacks'),
  969. );
  970. // Per-node Trackbacks
  971. $blocks['trackback_block'] = array (
  972. 'info' => t('Trackbacks'),
  973. 'cache' => BLOCK_CACHE_PER_PAGE | BLOCK_CACHE_PER_ROLE,
  974. );
  975. return $blocks;
  976. }
  977. switch ($delta) {
  978. case 'trackback_recent':
  979. switch ($op) {
  980. case 'configure':
  981. $form['trackback_block_recent_count'] = array(
  982. '#type' => 'select',
  983. '#title' => t('Number of trackbacks to display'),
  984. '#default_value' => variable_get('trackback_block_recent_count', 10),
  985. '#options' => drupal_map_assoc(array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 25, 30)),
  986. '#description' => t('How many trackbacks are displayed in the Recent Trackbacks block')
  987. );
  988. return $form;
  989. break;
  990. case 'save':
  991. variable_set('trackback_block_recent_count', $edit['trackback_block_recent_count']);
  992. break;
  993. case 'view':
  994. //$result = db_query_range('SELECT * FROM {trackback_received} WHERE status=1 ORDER BY created DESC', 0, variable_get('trackback_display_number', 10));
  995. //$items = array();
  996. //while ($tb = db_fetch_object($result)) {
  997. // $items[] = _trackback_path($tb, truncate_utf8($tb->subject, 128, FALSE, TRUE)) .'<br />'. t('%time ago', array('%time' => format_interval(time() - $tb->created)));
  998. //}
  999. $block['subject'] = t('Recent Trackbacks');
  1000. $block['content'] = __file__ . '::TO IMPLEMENT';//theme('item_list', $items);
  1001. return $block;
  1002. break;
  1003. }
  1004. break;
  1005. // Per-node Setting
  1006. case 'trackback_block':
  1007. switch ($op) {
  1008. case 'configure':
  1009. $form['trackback_block_display_url'] = array(
  1010. '#type' => 'checkbox',
  1011. '#title' => t('Display Trackback-URL in block'),
  1012. '#default_value' => variable_get('trackback_block_display_url', TRUE),
  1013. );
  1014. $form['trackback_block_display_options'] = array(
  1015. '#type' => 'checkboxes',
  1016. '#title' => t('Display Options for trackbacks'),
  1017. '#description' => t(''),
  1018. '#default_value' => variable_get('trackback_block_display_options', array('excerpt')),
  1019. '#options' => array(
  1020. 'created' => t('Received date'),
  1021. 'excerpt' => t('Excerpt text'),
  1022. 'site' => t('IP Address'),
  1023. ),
  1024. );
  1025. return $form;
  1026. break;
  1027. case 'save':
  1028. variable_set('trackback_block_display_url', $edit['trackback_block_display_url']);
  1029. variable_set('trackback_block_display_options', $edit['trackback_block_display_options']);
  1030. break;
  1031. case 'view':
  1032. if (arg(0) == 'node' && is_numeric(arg(1)) && is_null(arg(2))) {
  1033. $node = node_load(arg(1));
  1034. $block['subject'] = t('Trackbacks');
  1035. if (isset($node->trackback_can_receive) && node_access('view', $node)) {
  1036. $block['content'] = trackback_render_received($node, TRUE);
  1037. if (variable_get('trackback_receive_post', TRUE) && variable_get('trackback_block_display_url', TRUE)) {
  1038. $url = trackback_get_url($node);
  1039. $block['content'] .= theme('trackback_url', $url, $node, TRUE);
  1040. }
  1041. }
  1042. return $block;
  1043. }
  1044. break;
  1045. }
  1046. break;
  1047. }
  1048. }
  1049. /**
  1050. * Delete all Trackbacks for the givend NodeID
  1051. * @param $nid
  1052. */
  1053. function trackback_delete_trackbacks($nid) {
  1054. db_query("DELETE FROM {trackback_node} WHERE nid = %d", $nid);
  1055. db_query("DELETE FROM {trackback_sent} WHERE nid = %d", $nid);
  1056. db_query("DELETE FROM {trackback_received} WHERE nid = %d", $nid);
  1057. drupal_set_message(t('All trackbacks deleted.'));
  1058. }
  1059. /**
  1060. * Returns an array of sented trackbacks for given Node,
  1061. */
  1062. function trackback_get_sent(&$node, $status = 'all') {
  1063. // drupal_set_message(__function__ . '() => '. $status);
  1064. $nid = $node->nid;
  1065. $return = array();
  1066. $params = array($node->nid);
  1067. $sql = 'SELECT url FROM {trackback_sent} WHERE nid = %d';
  1068. switch ($status) {
  1069. case 'successful':
  1070. $sql .= ' AND successful = %b';
  1071. $params[] = 1;
  1072. break;
  1073. case 'error':
  1074. $sql .= ' AND successful = %b';
  1075. $params[] = 0;
  1076. break;
  1077. default:
  1078. // Returns ALL sent trackbscks
  1079. break;
  1080. } // End status switch
  1081. $result = db_query($sql, $params);
  1082. while ($send = db_fetch_object($result)) {
  1083. $return[] = $send->url;
  1084. }
  1085. return $return;
  1086. }
  1087. /**
  1088. * Return an array of Trackbacks object received by the given Node
  1089. */
  1090. function trackback_get_received($node) {
  1091. $nid = $node->nid;
  1092. if (!empty($node->tnid) && variable_get('trackback_merge_within_translations', TRUE)) {
  1093. $nid = $node->tnid;
  1094. }
  1095. $return = array();
  1096. $result = db_query('SELECT * FROM {trackback_received} WHERE nid = %d AND status = %d ORDER BY created DESC', $nid, TRACKBACK_STATUS_PUBLISHED);
  1097. while ($trackback = db_fetch_object($result)) {
  1098. $return[] = $trackback;
  1099. }
  1100. return $return;
  1101. }
  1102. /**
  1103. * Delete all trackback for given node-type
  1104. * @TODO: Implement this function!
  1105. */
  1106. function trackback_delete_trackbacks_nodetype($nodetype) {
  1107. return;
  1108. }
  1109. /**
  1110. * Load received trackback with given TrackbackID
  1111. */
  1112. function trackback_load_received($trid) {
  1113. return db_fetch_object(db_query('SELECT * FROM {trackback_received} WHERE trid=%d', $trid));
  1114. }