PageRenderTime 39ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/wp-content/plugins/simple-forum/linking/sf-links-forum.php

https://bitbucket.org/crypticrod/sr_wp_code
PHP | 82 lines | 47 code | 13 blank | 22 comment | 8 complexity | 6ca6ebc287fba0aa03b2a33e82b07313 MD5 | raw file
Possible License(s): AGPL-1.0, GPL-2.0, LGPL-2.1, GPL-3.0, LGPL-2.0, AGPL-3.0
  1. <?php
  2. /*
  3. Simple:Press
  4. Blog Linking - Forum side support routines
  5. $LastChangedDate: 2011-01-03 14:29:28 -0700 (Mon, 03 Jan 2011) $
  6. $Rev: 5253 $
  7. */
  8. if(preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'])) {
  9. die('Access Denied');
  10. }
  11. # ------------------------------------------------------------------
  12. # sf_forum_show_blog_link()
  13. #
  14. # Displays the link in the forum topic
  15. # $postid ID of the post being deleted
  16. # ------------------------------------------------------------------
  17. function sf_forum_show_blog_link($postid)
  18. {
  19. $sfpostlinking = array();
  20. $sfpostlinking = sf_get_option('sfpostlinking');
  21. $text = $sfpostlinking['sflinkforumtext'];
  22. $icon = '<img src="'.SFRESOURCES.'bloglink.png" alt=""/>';
  23. $href = '<a href="'.get_permalink($postid).'">';
  24. if(strpos($text, '%ICON%') !== false)
  25. {
  26. $text = str_replace('%ICON%', $icon, $text);
  27. }
  28. if(strpos($text, '%BLOGTITLE%') !== false)
  29. {
  30. $text = str_replace('%BLOGTITLE%', sf_get_blog_title_from_id($postid), $text);
  31. }
  32. if(strpos($text, '%LINKSTART%') !== false)
  33. {
  34. $text = str_replace('%LINKSTART%', $href, $text);
  35. } else {
  36. $text = $href.$text;
  37. }
  38. if(strpos($text, '%LINKEND%') !== false)
  39. {
  40. $text = str_replace('%LINKEND%', '</a>', $text);
  41. } else {
  42. $text = $text.'</a>';
  43. }
  44. $out = '<span class="sfbloglink">'.$text.'</span>';
  45. return $out;
  46. }
  47. # ------------------------------------------------------------------
  48. # sf_break_blog_link()
  49. #
  50. # Breaks the link - removes nothing
  51. # $topicid SPF Topic id of the link
  52. # $postid WP Post id of the link
  53. # ------------------------------------------------------------------
  54. function sf_break_blog_link($topicid, $postid)
  55. {
  56. global $wpdb, $sfglobals;
  57. # dont update forum if its locked down
  58. if ($sfglobals['lockdown'])
  59. {
  60. update_sfnotice('sfmessage', __('This Forum is Currently Locked - Access is Read Only - Not Updated', "sforum"));
  61. return;
  62. }
  63. # remove from postmeta
  64. sf_blog_links_control('delete', $postid);
  65. # and set blog_oost_id to zero in topic record
  66. $wpdb->query("UPDATE ".SFTOPICS." SET blog_post_id = 0 WHERE topic_id = ".$topicid.";");
  67. return;
  68. }
  69. ?>