PageRenderTime 70ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/wp-content/plugins/simple-forum/forum/sf-topic-components.php

https://bitbucket.org/crypticrod/sr_wp_code
PHP | 1007 lines | 821 code | 137 blank | 49 comment | 263 complexity | 00bb1a18c853d2943417ecdfb148318f 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. Topic Rendering Routines (Posts)
  5. $LastChangedDate: 2011-04-28 20:08:44 -0700 (Thu, 28 Apr 2011) $
  6. $Rev: 5994 $
  7. */
  8. if(preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'])) {
  9. die('Access Denied');
  10. }
  11. # = CONSTRUCT PAGED POST NAVIGATION TABLE =====
  12. if(!function_exists('sf_compile_paged_posts')):
  13. function sf_compile_paged_posts($forumslug, $topicslug, $topicid, $currentpage, $postcount)
  14. {
  15. global $sfglobals;
  16. if(!isset($currentpage)) $currentpage = 1;
  17. $ppaged=$sfglobals['display']['posts']['perpage'];
  18. if(!$ppaged) $ppaged=20;
  19. $totalpages = ($postcount / $ppaged);
  20. if(!is_int($totalpages)) $totalpages = (intval($totalpages)+1);
  21. if((isset($_GET['xtp'])) && (sf_esc_int($_GET['xtp']) <> 1))
  22. {
  23. $xtp = '&amp;xtp='.sf_esc_int($_GET['xtp']);
  24. } else {
  25. $xtp = '';
  26. }
  27. $out= __("Page:", "sforum").' ';
  28. $baseurl = '<a href="'.sf_build_url($forumslug, $topicslug, 1, 0);
  29. $out.= sf_pn_next($currentpage, '', $totalpages, $baseurl, $sfglobals['display']['posts']['numpagelinks']);
  30. if ($currentpage > 1)
  31. {
  32. $out.= '&nbsp;&nbsp;' . trailingslashit($baseurl. 'page-'.$currentpage) . '" class="current">'.$currentpage.'</a>'. '&nbsp;&nbsp;'."\n";
  33. } else {
  34. $out.= '&nbsp;&nbsp;' . $baseurl. '" class="current">'.$currentpage.'</a>'. '&nbsp;&nbsp;'."\n"; }
  35. $out.= sf_pn_previous($currentpage, '', $totalpages, $baseurl, $sfglobals['display']['posts']['numpagelinks']);
  36. return $out;
  37. }
  38. endif;
  39. # = TOPIC POSTS PAGE NAV STRIP ================
  40. if(!function_exists('sf_render_post_pagelinks')):
  41. function sf_render_post_pagelinks($thispagelinks, $bottom, $topiclock, $subs, $tpage, $tpagecount)
  42. {
  43. global $current_user, $sfglobals, $sfvars;
  44. $out = '';
  45. if ((!$bottom && $sfglobals['display']['pagelinks']['ptop']) || ($bottom && $sfglobals['display']['pagelinks']['pbottom']))
  46. {
  47. $out.= '<table class="sffooter"><tr>'."\n";
  48. $out.= '<td class="sfpagelinks">'.$thispagelinks."\n";
  49. if($bottom)
  50. {
  51. if($tpage < $tpagecount)
  52. {
  53. $out.= '<img src="'.SFRESOURCES.'separator.png" alt="" />';
  54. $out.= '<a href="'.sf_build_url($sfvars['forumslug'], $sfvars['topicslug'], $tpage+1, 0).'"><img src="'.SFRESOURCES.'next.png" alt="" title="'.esc_attr(__("Next Page", "sforum")).'" /></a>'."\n";
  55. }
  56. $out.= '</td>'."\n";
  57. }
  58. if(!$bottom)
  59. {
  60. if($tpage > 1)
  61. {
  62. $out.= '<img src="'.SFRESOURCES.'separator.png" alt="" />';
  63. $out.= '&nbsp;&nbsp;<a href="'.sf_build_url($sfvars['forumslug'], $sfvars['topicslug'], $tpage-1, 0).'"><img src="'.SFRESOURCES.'previous.png" alt="" title="'.esc_attr(__("Previous Page", "sforum")).'" /></a>'."\n";
  64. }
  65. $out.= '</td>'."\n";
  66. $out.= '<td class="sfadditemcell" style="padding-top:4px;">';
  67. if((!$topiclock) || ($current_user->forumadmin))
  68. {
  69. if (!$sfglobals['lockdown'])
  70. {
  71. if($current_user->offmember)
  72. {
  73. $sflogin = sf_get_option('sflogin');
  74. $out.= '<a class="sficon" href="'.esc_url($sflogin['sfloginurl'].'&amp;redirect_to='.urlencode($_SERVER['REQUEST_URI'])).'"><img class="sfalignright" src="'.SFRESOURCES.'login.png" alt="" title="'.esc_attr(__("Login", "sforum")).'" />'.sf_render_icons("Login").'</a>'."\n";
  75. } else {
  76. if ($current_user->sfreply && $sfvars['displaymode'] == 'posts')
  77. {
  78. $out.= '<a class="sficon" onclick="sfjOpenEditor(\'sfpostform\','.$sfglobals['editor']['sfeditor'].',\'post\');"><img src="'.SFRESOURCES.'addpost.png" alt="" title="'.esc_attr(__("Reply to Post", "sforum")).'" />'.sf_render_icons("Reply to Post").'</a>'."\n"; }
  79. if($current_user->sfaddnew)
  80. {
  81. $url = sf_build_url($sfvars['forumslug'], '', 1, 0).sf_add_get().'new=topic';
  82. $out.= '<a class="sficon" href="'.$url.'"><img src="'.SFRESOURCES.'addtopic.png" alt="" title="'.esc_attr(__("Add a New Topic", "sforum")).'" />'.sf_render_icons("Add a New Topic").'</a>'."\n";
  83. }
  84. }
  85. }
  86. }
  87. $out.= '</td>'."\n";
  88. }
  89. if($bottom)
  90. {
  91. $out.='<td class="sfadditemcell">'."\n";
  92. $out.= sf_render_add_post($bottom, $topiclock);
  93. $out.= '</td>';
  94. }
  95. $out.= '</tr></table>'."\n";
  96. if(!$bottom)
  97. {
  98. $out.= sf_render_topic_icon_legend($subs, $sfvars['topicid'])."\n";
  99. }
  100. } else {
  101. # if bottom with no pagelinks but show add button then...
  102. if($bottom && $sfglobals['display']['pagelinks']['pbottom']==false)
  103. {
  104. if ($current_user->sfreply && $sfvars['displaymode'] == 'posts')
  105. {
  106. $out.= '<table class="sffooter"><tr>'."\n";
  107. $out.= sf_render_add_post($bottom, $topiclock);
  108. $out.= '</tr></table>'."\n";
  109. }
  110. }
  111. }
  112. if ($bottom)
  113. {
  114. $out.= sf_process_hook('sf_hook_post_topic_bottom_pagelinks', array($sfvars['forumid'], $sfvars['topicid']));
  115. } else {
  116. $out.= sf_process_hook('sf_hook_post_topic_top_pagelinks', array($sfvars['forumid'], $sfvars['topicid']));
  117. }
  118. return $out;
  119. }
  120. endif;
  121. # = TOPICS POST PAGE ADD BUTTON ===============
  122. if(!function_exists('sf_render_add_post')):
  123. function sf_render_add_post($bottom, $topiclock)
  124. {
  125. global $current_user, $sfglobals, $sfvars;
  126. $out = '';
  127. # Display Reply to Post if allowed
  128. if((!$topiclock) || ($current_user->forumadmin))
  129. {
  130. if (!$sfglobals['lockdown'])
  131. {
  132. if($current_user->offmember)
  133. {
  134. $sflogin = sf_get_option('sflogin');
  135. $out.= '<a class="sficon sfalignright" href="'.esc_url($sflogin['sfloginurl'].'&amp;redirect_to='.urlencode($_SERVER['REQUEST_URI'])).'"><img src="'.SFRESOURCES.'login.png" alt="" title="'.esc_attr(__("Login", "sforum")).'" />'.sf_render_icons("Login").'</a>'."\n";
  136. } else {
  137. if ($current_user->sfreply && $sfvars['displaymode'] == 'posts')
  138. {
  139. $out.= '<a class="sficon sfalignright" onclick="sfjOpenEditor(\'sfpostform\','.$sfglobals['editor']['sfeditor'].',\'post\');"><img src="'.SFRESOURCES.'addpost.png" alt="" title="'.esc_attr(__("Reply to Post", "sforum")).'" />'.sf_render_icons("Reply to Post").'</a>'."\n";
  140. }
  141. }
  142. }
  143. }
  144. return $out;
  145. }
  146. endif;
  147. # = TOPIC: SUBSCRIBED/WATCHING LEGEND ==========
  148. if(!function_exists('sf_render_topic_icon_legend')):
  149. function sf_render_topic_icon_legend($subs, $topicid)
  150. {
  151. global $wpdb, $current_user;
  152. # Subscriptions
  153. if ($current_user->guest) return;
  154. $out = '';
  155. $subtext = '';
  156. if (!empty($subs))
  157. {
  158. $out.='<span class="sficonkey"><small>';
  159. $sublist = unserialize($subs);
  160. foreach( $sublist as $i)
  161. {
  162. if($i == $current_user->ID) $subtext = '<img src="'. SFRESOURCES .'small-subscribe.png" alt="" />&nbsp;&nbsp;'.esc_attr(__("You are subscribed to this topic", "sforum"));
  163. }
  164. if (empty($subtext))
  165. {
  166. if ($current_user->forumadmin) $subtext= '&nbsp;&nbsp;<img src="'. SFRESOURCES .'small-subscribe.png" alt="" />&nbsp;&nbsp;'.esc_attr(__("This topic has User Subscriptions", "sforum"));
  167. }
  168. $out.= $subtext.'</small></span>';
  169. }
  170. # Watching
  171. $watchtext = '';
  172. $list = $wpdb->get_var("SELECT topic_watches FROM ".SFTOPICS." WHERE topic_id=".$topicid);
  173. if (!empty($list))
  174. {
  175. $out.='<span class="sficonkey"><small>';
  176. $watchlist = unserialize($list);
  177. foreach ($watchlist as $watch)
  178. {
  179. if ($watch == $current_user->ID) $watchtext = '<img src="'. SFRESOURCES .'small-watch.png" alt="" />&nbsp;&nbsp;'.esc_attr(__("You are watching this topic", "sforum"));
  180. }
  181. if (empty($watchtext))
  182. {
  183. if ($current_user->forumadmin) $watchtext = '&nbsp;&nbsp;<img src="'. SFRESOURCES .'small-watch.png" alt="" />&nbsp;&nbsp;'.esc_attr(__("This topic has User Watches", "sforum"));
  184. }
  185. $out.= $watchtext.'</small></span>';
  186. }
  187. return $out;
  188. }
  189. endif;
  190. # = COLUMN HEADER ROW =========================
  191. if(!function_exists('sf_render_topic_column_header_row')):
  192. function sf_render_topic_column_header_row()
  193. {
  194. global $sfglobals;
  195. $out = '<tr>'."\n";
  196. if ($sfglobals['display']['posts']['userabove'])
  197. {
  198. $out .= '<th>'.__("Post", "sforum").'</th>'."\n";
  199. } else {
  200. $out .= '<th>'.__("User", "sforum").'</th><th>'.__("Post", "sforum").'</th>'."\n";
  201. }
  202. $out.= '</tr>'."\n";
  203. return $out;
  204. }
  205. endif;
  206. # = RENDER USER DETAILS CELL ABOVE ============
  207. if(!function_exists('sf_render_poster_details_above')):
  208. function sf_render_poster_details_above($post, $posterstatus, $poster, $rank, $postcount, $alt, $cacheid)
  209. {
  210. global $sfglobals, $sfavatarcache, $sfidentitycache, $current_user;
  211. $rank_class = apply_filters('sanitize_title', $rank);
  212. $sfavatars = sf_get_option('sfavatars');
  213. $size = $sfavatars['sfavatarsize'] + 25;
  214. # Inner poster details table
  215. $out = '<table class="sfinnerusertable" cellpadding="5"><tr align="center">';
  216. $out.= '<td class="'.$alt.'" width="'.$size.'">';
  217. # get avatar from cache if created already
  218. if(array_key_exists($cacheid, $sfavatarcache))
  219. {
  220. $out.= $sfavatarcache[$cacheid];
  221. } else {
  222. $outcache = sf_render_avatar($posterstatus, $post['user_id'], sf_filter_email_display($post['user_email']), sf_filter_email_display($post['guest_email']));
  223. $sfavatarcache[$cacheid] = $outcache;
  224. $out.= $outcache;
  225. }
  226. $out.= '</td>'."\n";
  227. if($sfglobals['display']['posts']['usertype'])
  228. {
  229. $out.= '<td class="'.$alt.'" width="1">';
  230. $out.= '<div class="sfuserrank rank-'.esc_attr($rank_class).' sftype-'.$posterstatus.'">'.$rank.'</div>';
  231. $out.= '</td>';
  232. }
  233. $pid = 'guest';
  234. if ($post['user_id'])
  235. {
  236. $pid = $post['user_id'];
  237. }
  238. $out.= '<td class="sfusername sfuser-'.$pid.' rank-'.esc_attr($rank_class).' sftype-'.$posterstatus.' '.$alt.'"><p><strong>'.$poster.'</strong></p>';
  239. if($sfglobals['display']['posts']['location'])
  240. {
  241. $loc = get_user_meta($post['user_id'], 'location', true);
  242. if (!empty($loc)) $out.= '<p>'.$loc.'</p>';
  243. }
  244. if($sfglobals['display']['posts']['postcount'])
  245. {
  246. $out.= '<p>'.$postcount.'</p>';
  247. }
  248. if($sfglobals['display']['posts']['time'] || $sfglobals['display']['posts']['date'])
  249. {
  250. $out.= '<p>';
  251. if($current_user->member && $current_user->lastvisit > 0 && $current_user->lastvisit < $post['udate'])
  252. {
  253. $out.= '<img src="'.SFRESOURCES.'announcenew.png" alt="" />'."\n";
  254. }
  255. if($sfglobals['display']['posts']['time'])
  256. {
  257. $out.= sf_date('t', $post['post_date']).' ';
  258. }
  259. if($sfglobals['display']['posts']['date'])
  260. {
  261. $out.= sf_date('d', $post['post_date']);
  262. }
  263. $out.= '</p>'."\n";
  264. }
  265. $out.= '</td>';
  266. # get online identities from cache if created already
  267. $out.= '<td class="'.$alt.' sfalignright">';
  268. if (!array_key_exists($cacheid, $sfidentitycache))
  269. {
  270. $sfidentitycache[$cacheid] = '';
  271. $start = false;
  272. $sftwitter = array();
  273. $sftwitter = sf_get_option('sftwitter');
  274. $twitter = get_user_meta($post['user_id'], 'twitter', true);
  275. if ($sftwitter['sftwitterfollow'] && $twitter)
  276. {
  277. if (!$start)
  278. {
  279. $sfidentitycache[$cacheid] .= '<p class="sfuseridentity">';
  280. $start = true;
  281. }
  282. $sfidentitycache[$cacheid] .= '<a href="http://twitter.com/'.$twitter.'"><img src="'.SFRESOURCES.'followme.png" alt="" title="'.__("Follow Me", "sforum").'" /></a>';
  283. }
  284. $sfdisplay = array();
  285. $sfdisplay = sf_get_option('sfdisplay');
  286. $facebook = get_user_meta($post['user_id'], 'facebook', true);
  287. if ($sfdisplay['posts']['sffbconnect'] && $facebook)
  288. {
  289. if (!$start)
  290. {
  291. $sfidentitycache[$cacheid] .= '<p class="sfuseridentity">';
  292. $start = true;
  293. }
  294. $sfidentitycache[$cacheid] .= '<a href="http://facebook.com/'.$facebook.'"><img src="'.SFRESOURCES.'fbconnect.png" alt="" title="'.__("Connect With Me", "sforum").'" /></a>';
  295. }
  296. $mysapce = get_user_meta($post['user_id'], 'myspace', true);
  297. if ($sfdisplay['posts']['sfmyspace'] && $mysapce)
  298. {
  299. if (!$start)
  300. {
  301. $sfidentitycache[$cacheid] .= '<p class="sfuseridentity">';
  302. $start = true;
  303. }
  304. $sfidentitycache[$cacheid] .= '<a href="http://myspace.com/'.$mysapce.'"><img src="'.SFRESOURCES.'myspace.png" alt="" title="'.__("MySpace Page", "sforum").'" /></a>';
  305. }
  306. $linkedin = get_user_meta($post['user_id'], 'linkedin', true);
  307. if ($sfdisplay['posts']['sflinkedin'] && $linkedin)
  308. {
  309. if (!$start)
  310. {
  311. $sfidentitycache[$cacheid] .= '<p class="sfuseridentity">';
  312. $start = true;
  313. }
  314. $sfidentitycache[$cacheid] .= '<a href="http://linkedin.com/in/'.$linkedin.'"><img src="'.SFRESOURCES.'linkedin.png" alt="" title="'.__("LinkedIn Page", "sforum").'" /></a>';
  315. }
  316. if ($start) $sfidentitycache[$cacheid] .= '</p>';
  317. }
  318. $out.= $sfidentitycache[$cacheid];
  319. $out.= '</td>';
  320. $out.= '</tr></table>';
  321. # check if we need nofollow or target on the identity icons
  322. $sffilters = sf_get_option('sffilters');
  323. if ($sffilters['sfnofollow']) {
  324. $out = sf_filter_save_nofollow($out);
  325. }
  326. if ($sffilters['sftarget']) {
  327. $out = sf_filter_save_target($out);
  328. }
  329. return $out;
  330. }
  331. endif;
  332. # = RENDER USER DETAILS CELL SIDE =============
  333. if(!function_exists('sf_render_poster_details_side')):
  334. function sf_render_poster_details_side($post, $posterstatus, $poster, $rank, $postcount, $alt, $cacheid)
  335. {
  336. global $sfglobals, $sfavatarcache, $sfidentitycache, $current_user;
  337. $rank_class = apply_filters('sanitize_title', $rank);
  338. # Inner poster details table
  339. $out = '<table class="sfinnerusertable" cellpadding="0" cellspacing="0" border="0"><tr align="center">';
  340. $out.= '<td class="sfposticonstrip '.$alt.'">'."\n";
  341. if($sfglobals['display']['posts']['time'] || $sfglobals['display']['posts']['date'])
  342. {
  343. $out.= '<p>';
  344. if($current_user->member && $current_user->lastvisit > 0 && $current_user->lastvisit < $post['udate'])
  345. {
  346. $out.= '<img src="'.SFRESOURCES.'announcenew.png" alt="" />'."\n";
  347. }
  348. if($sfglobals['display']['posts']['time'])
  349. {
  350. $out.= sf_date('t', $post['post_date']).'<br />';
  351. }
  352. if($sfglobals['display']['posts']['date'])
  353. {
  354. $out.= sf_date('d', $post['post_date']);
  355. }
  356. $out.= '</p>'."\n";
  357. }
  358. $out.= '</td></tr><tr>';
  359. $pid = 'guest';
  360. if ($post['user_id'])
  361. {
  362. $pid = $post['user_id'];
  363. }
  364. $out.= '<td class="sfusername sfuser-'.$pid.' rank-'.esc_attr($rank_class).' sftype-'.$posterstatus.' '.$alt.'"><p><br /><strong>'.$poster.'</strong></p>';
  365. $out.= '</td></tr>';
  366. $out.= '<tr><td class="'.$alt.'"></td></tr>';
  367. if($sfglobals['display']['posts']['location'])
  368. {
  369. $loc = get_user_meta($post['user_id'], 'location', true);
  370. if (!empty($loc)) $out.= '<tr align="center"><td class="'.$alt.'"><p>'.$loc.'</p></td></tr>';
  371. }
  372. $out.= '<tr align="center"><td class="'.$alt.'">';
  373. # get avatar from cache if created already
  374. if (!array_key_exists($cacheid, $sfavatarcache))
  375. {
  376. $sfavatarcache[$cacheid] = sf_render_avatar($posterstatus, $post['user_id'], sf_filter_email_display($post['user_email']), sf_filter_email_display($post['guest_email']));
  377. }
  378. $out.= $sfavatarcache[$cacheid];
  379. $out.= '</td></tr>'."\n";
  380. $out.= '<tr><td class="'.$alt.'"></td></tr>';
  381. if($sfglobals['display']['posts']['usertype'])
  382. {
  383. $out.= '<tr align="center"><td class="'.$alt.'">';
  384. $out.= '<div class="sfuserrank rank-'.esc_attr($rank_class).' sftype-'.$posterstatus.'">'.$rank.'</div>';
  385. $out.= '</td></tr>';
  386. }
  387. if($sfglobals['display']['posts']['postcount'])
  388. {
  389. $out.= '<tr align="center"><td class="'.$alt.'"><p>'.$postcount.'</p></td></tr>';
  390. }
  391. # get online identities from cache if created already
  392. $out.= '<tr align="center"><td class="'.$alt.'">';
  393. if (!array_key_exists($cacheid, $sfidentitycache))
  394. {
  395. $sfidentitycache[$cacheid] = '';
  396. $start = false;
  397. $sftwitter = array();
  398. $sftwitter = sf_get_option('sftwitter');
  399. $twitter = get_user_meta($post['user_id'], 'twitter', true);
  400. if ($sftwitter['sftwitterfollow'] && $twitter)
  401. {
  402. if (!$start)
  403. {
  404. $sfidentitycache[$cacheid] .= '<p class="sfuseridentity">';
  405. $start = true;
  406. }
  407. $sfidentitycache[$cacheid] .= '<a href="http://twitter.com/'.$twitter.'"><img src="'.SFRESOURCES.'followme.png" alt="" title="'.__("Follow Me", "sforum").'" /></a>';
  408. }
  409. $sfdisplay = array();
  410. $sfdisplay = sf_get_option('sfdisplay');
  411. $facebook = get_user_meta($post['user_id'], 'facebook', true);
  412. if ($sfdisplay['posts']['sffbconnect'] && $facebook)
  413. {
  414. if (!$start)
  415. {
  416. $sfidentitycache[$cacheid] .= '<p class="sfuseridentity">';
  417. $start = true;
  418. }
  419. $sfidentitycache[$cacheid] .= '<a href="http://facebook.com/'.$facebook.'"><img src="'.SFRESOURCES.'fbconnect.png" alt="" title="'.__("Connect With Me", "sforum").'" /></a>';
  420. }
  421. $mysapce = get_user_meta($post['user_id'], 'myspace', true);
  422. if ($sfdisplay['posts']['sfmyspace'] && $mysapce)
  423. {
  424. if (!$start)
  425. {
  426. $sfidentitycache[$cacheid] .= '<p class="sfuseridentity">';
  427. $start = true;
  428. }
  429. $sfidentitycache[$cacheid] .= '<a href="http://myspace.com/'.$mysapce.'"><img src="'.SFRESOURCES.'myspace.png" alt="" title="'.__("MySpace Page", "sforum").'" /></a>';
  430. }
  431. $linkedin = get_user_meta($post['user_id'], 'linkedin', true);
  432. if ($sfdisplay['posts']['sflinkedin'] && $linkedin)
  433. {
  434. if (!$start)
  435. {
  436. $sfidentitycache[$cacheid] .= '<p class="sfuseridentity">';
  437. $start = true;
  438. }
  439. $sfidentitycache[$cacheid] .= '<a href="http://linkedin.com/in/'.$linkedin.'"><img src="'.SFRESOURCES.'linkedin.png" alt="" title="'.__("LinkedIn Page", "sforum").'" /></a>';
  440. }
  441. if ($start) $sfidentitycache[$cacheid] .= '</p>';
  442. }
  443. $out.= $sfidentitycache[$cacheid];
  444. $out.= '</td></tr>';
  445. $out.= '</table>';
  446. # check if we need nofollow or target on the identity icons
  447. $sffilters = sf_get_option('sffilters');
  448. if ($sffilters['sfnofollow']) $out = sf_filter_save_nofollow($out);
  449. if ($sffilters['sftarget']) $out = sf_filter_save_target($out);
  450. return $out;
  451. }
  452. endif;
  453. # = GET ONLINE STATUS =========================
  454. if(!function_exists('sf_render_online_status')):
  455. function sf_render_online_status($userid)
  456. {
  457. global $wpdb, $current_user, $sfglobals;
  458. if(empty($userid)) return '';
  459. $status = sf_is_online($userid);
  460. $opts = sf_get_member_item($userid, 'user_options');
  461. $sfmemberopts = sf_get_option('sfmemberopts');
  462. $hide = !$current_user->forumadmin && ((isset($sfmemberopts['sfhidestatus']) && $sfmemberopts['sfhidestatus']==true) && (isset($opts['hidestatus']) && $opts['hidestatus']==true));
  463. if ($status && !$hide)
  464. {
  465. return '<img class="sficon sfonlinestatus" src="'.SFRESOURCES.'online.png" alt="" title="'.esc_attr(__("Member is On-Line", "sforum")).'" />';
  466. } else {
  467. return '<img class="sficon sfonlinestatus" src="'.SFRESOURCES.'offline.png" alt="" title="'.esc_attr(__("Member is Off-Line", "sforum")).'" />';
  468. }
  469. }
  470. endif;
  471. # = RENDER POST ICON STRIP ====================
  472. if(!function_exists('sf_render_post_icon_strip')):
  473. function sf_render_post_icon_strip($post, $posterstatus, $userid, $username, $currentguest, $currentmember, $displaypost, $topiclock, $lastpost, $alt, $admintools, $postratings)
  474. {
  475. global $sfvars, $sfglobals, $current_user;
  476. $out = '';
  477. $out.= '<td class="sfposticonstrip '.$alt.'">';
  478. $out.= '<div class="sfposticoncontainer">';
  479. # Admin Post Tools
  480. if($sfglobals['admin']['sftools'] && $current_user->sftopicicons && !$sfglobals['lockdown'])
  481. {
  482. $out.= sf_render_post_tools_icon($sfvars['forumid'], $post['post_id'], $sfvars['page'], $post['post_index'], $username);
  483. }
  484. # profile and web link if setup and alowed
  485. if($current_user->sfprofiles && $posterstatus != 'guest')
  486. {
  487. $sfprofile=sf_get_option('sfprofile');
  488. # profile icon
  489. if($sfprofile['profilelink'] == 3)
  490. {
  491. $link = '<img class="sficon" src="'.SFRESOURCES.'user.png" alt="" title="'.esc_attr(__("view user profile", "sforum")).'" />';
  492. $out.= '<div class="sfposticon sfprofileicon">'.sf_attach_user_profilelink($post['user_id'], $link).'</div>'."\n";
  493. }
  494. # weblink icon
  495. if($sfprofile['weblink'] == 3)
  496. {
  497. $link = '<img class="sficon" src="'.SFRESOURCES.'weblink.png" alt="" title="'.esc_attr(__("visit users website", "sforum")).'" />';
  498. $out.= '<div class="sfposticon sfwebicon">'.sf_attach_user_weblink($post['user_id'], $link, false).'</div>'."\n";
  499. }
  500. }
  501. if($sfglobals['display']['posts']['online'])
  502. {
  503. $out.= '<div class="sfposticon sfonlineicon">'.sf_render_online_status($post['user_id']).'</div>';
  504. }
  505. # Do we show Quote and/or Edit icons?
  506. if((($currentmember) || ($currentguest)) || ($displaypost))
  507. {
  508. # Quote Icon
  509. if ($displaypost && !$sfglobals['lockdown'])
  510. {
  511. if($current_user->sfreply)
  512. {
  513. if(!$topiclock) $out.= '<div class="sfposticon sfquoteicon">'.sf_render_post_user_quoteicon($post['post_id'], $username, $post['user_id']).'</div>';
  514. }
  515. # Report Post
  516. if($current_user->sfreport)
  517. {
  518. $out.= '<div class="sfposticon sfreporticon">'.sf_render_report_post_icon($post['post_id'], $username, $post['user_id']).'</div>';
  519. }
  520. }
  521. # Edit Icon
  522. if (($currentmember || $currentguest) && !$sfglobals['lockdown'])
  523. {
  524. if((($current_user->sfstopedit) && ($lastpost)) || ($current_user->sfeditall))
  525. {
  526. $out.= '<div class="sfposticon sfediticon">'.sf_render_post_user_editicon($sfvars['forumslug'], $sfvars['topicslug'], $sfvars['page'], $post['post_id'], $post['post_index']).'</div>';
  527. }
  528. }
  529. # Send PM Icon
  530. if(($posterstatus != 'guest') && ($current_user->sfusepm))
  531. {
  532. if($userid != $post['user_id'] && $post['pm'])
  533. {
  534. $out.= '<div class="sfposticon sfpmicon">'.sf_render_post_user_sendpmicon($userid, $post['user_id'], $username, $post['post_id']).'</div>';
  535. }
  536. }
  537. }
  538. # Is this post pinned?
  539. if($post['post_pinned'] == 1)
  540. {
  541. $out.= '<div class="sfposticon sfpostpinicon"><img class="sficon" src="'.SFRESOURCES.'pin.png" alt="" title="'.esc_attr(__("post pinned", "sforum")).'" /></div>'."\n";
  542. }
  543. if($sfglobals['display']['posts']['permalink'])
  544. {
  545. $pptitle = esc_js(__("Post Permalink", "sforum"));
  546. $purl = sf_build_url($sfvars['forumslug'], $sfvars['topicslug'], $sfvars['page'], $post['post_id'], $post['post_index']);
  547. $out.='<div class="sfposticon sfpermalinkicon"><a href="'.$purl.'" id="sfshowlink'.$post['post_id'].'" onclick="sfjshowPostLink(\''.$pptitle.'\',\''.addslashes($purl).'\',\''.$post['post_id'].'\');return false;"><img src="'.SFRESOURCES.'link.png" alt="" title="'.esc_attr(__("permalink to this post", "sforum")).'" /></a></div>'."\n";
  548. $out.='<div class="highslide-html-content" id="link-content'.$post['post_id'].'" style="width: 300px">';
  549. $out.='<div class="inline-edit" id="sfpostlink'.$post['post_id'].'"></div>';
  550. $out.='<input type="button" class="sfcontrol" id="sfclosevalid'.$post['post_index'].'" onclick="return hs.close(this)" value="'.esc_attr(__("Close", "sforum")).'" />';
  551. $out.='</div>';
  552. }
  553. if($sfglobals['display']['posts']['print'])
  554. {
  555. $out.= '<div class="sfposticon sfprinticon">'.sf_render_post_printicon($post['post_id']).'</div>';
  556. }
  557. $out.= '<div class="sftoplink">';
  558. $out.= '<a href="#forumtop"><img src="'.SFRESOURCES.'top.png" alt="" title="'.esc_attr(__("go to top", "sforum")).'" /></a></div>'."\n";
  559. $out.= '<div class="sfposticon sfpostNumberOnPage">'.$post['post_index'].'</div>';
  560. if ($postratings)
  561. {
  562. $out.= sf_render_post_ratings($post);
  563. }
  564. $out.= '</div>';
  565. # Close the inner table cell
  566. $out.= '</td>';
  567. return $out;
  568. }
  569. endif;
  570. # = RENDER POST CONTENT =======================
  571. if(!function_exists('sf_render_post_content')):
  572. function sf_render_post_content($post, $editmode, $displaypost, $approve_text, $currentguest, $currentmember, $bloglink)
  573. {
  574. global $sfvars, $sfglobals, $current_user;
  575. $out = '';
  576. if($editmode)
  577. {
  578. $postcontent = sf_filter_content_edit($post['post_content']);
  579. $linked=false;
  580. if($bloglink && $post['post_index']==1) $linked=true;
  581. $out.= sf_edit_post($post['post_id'], $postcontent, $sfvars['forumid'], $sfvars['topicid'], $sfvars['page'], $post['post_edit'], $linked, $bloglink);
  582. } else {
  583. $out.= '<div id="post'.$post['post_id'].'"';
  584. if($post['post_pinned'] == 1)
  585. {
  586. $out.=' class="sfpinned">'."\n";
  587. } else {
  588. $out.='>'."\n";
  589. }
  590. # display any post edit data
  591. if(!empty($post['post_edit']) && $sfglobals['display']['posts']['showedits'])
  592. {
  593. $postedit = unserialize($post['post_edit']);
  594. $out.= '<p><small><i>';
  595. $x = 0;
  596. $showlast = $sfglobals['display']['posts']['showlastedit'];
  597. $lastedit = (count($postedit)-1);
  598. $zone = $current_user->timezone;
  599. foreach($postedit as $edit)
  600. {
  601. if (($showlast && ($x==$lastedit)) || ($showlast == false))
  602. {
  603. $ts = $edit['at'];
  604. if($zone < 0) $ts = ($ts-(abs($zone)*3600));
  605. if($zone > 0) $ts = ($ts+(abs($zone)*3600));
  606. $out.= sprintf(__("Post edited %s by %s", "sforum"), date_i18n(SFTIMES, $ts).' - '.date_i18n(SFDATES, $ts), $edit['by']).'<br />';
  607. }
  608. $x++;
  609. }
  610. $out.= '</i></small></p><hr />';
  611. }
  612. if (!sf_is_forum_admin($post['user_id']) || $current_user->sfadminview)
  613. {
  614. if($displaypost)
  615. {
  616. $out.= $approve_text.sf_filter_content_display($post['post_content']);
  617. } else {
  618. $out.= sf_filter_content_display($approve_text)."\n";
  619. if(($currentguest) || ($currentmember))
  620. {
  621. $out.= sf_filter_content_display($post['post_content']);
  622. }
  623. }
  624. } else {
  625. $adminview = sf_get_sfmeta('adminview', 'message');
  626. if ($adminview)
  627. {
  628. $out.= '<div class="sfmessagestrip">';
  629. $out.= sf_filter_text_display($adminview[0]['meta_value']);
  630. $out.= '</div>'."\n";
  631. }
  632. }
  633. if(function_exists('sf_forum_show_blog_link'))
  634. {
  635. if($bloglink > 0)
  636. {
  637. $out.= '<br /><p>'.sf_forum_show_blog_link($bloglink).'</p>';
  638. }
  639. }
  640. $out.= '</div>';
  641. }
  642. return $out;
  643. }
  644. endif;
  645. # = RENDER SIGNATURE STRIP ====================
  646. if(!function_exists('sf_render_signature_strip')):
  647. function sf_render_signature_strip($sig)
  648. {
  649. # force sig to have no follow in links
  650. $sig = sf_filter_save_nofollow($sig);
  651. # force sig images to be limited in size
  652. $sig = sf_filter_signature_display($sig);
  653. $out = '<div class="sfsignaturestrip">'."\n";
  654. $out.= $sig;
  655. $out.= '</div>'."\n";
  656. return $out;
  657. }
  658. endif;
  659. # = RENDER TOPIC STATUS UPDATER ===============
  660. if(!function_exists('sf_render_topic_status_updater')):
  661. function sf_render_topic_status_updater($statusset, $statusflag, $userid)
  662. {
  663. global $current_user;
  664. $out='';
  665. if($current_user->moderator || $current_user->sftopicstatus || $current_user->ID == $userid)
  666. {
  667. $out.= sf_render_topic_statusflag($statusset, $statusflag, 'ts-topic', 'ts-upinline', 'right');
  668. if($statusflag != 0)
  669. {
  670. $out.= '<div class="sfts-status sfalignright"><label><small>'.__("Change Topic Status", "sforum").': '.sf_topic_status_select($statusset, $statusflag, true).'</small></label></div>';
  671. } else {
  672. $out.= '<div class="sfts-status sfalignright"><label><small>'.__("Assign Topic Status", "sforum").': '.sf_topic_status_select($statusset, $statusflag, true).'</small></label></div>';
  673. }
  674. $out.= '<div class="sfclear"></div>';
  675. }
  676. return $out;
  677. }
  678. endif;
  679. # = RENDER QUOTE ICON =========================
  680. if(!function_exists('sf_render_post_user_quoteicon')):
  681. function sf_render_post_user_quoteicon($postid, $username, $userid)
  682. {
  683. global $current_user, $sfglobals, $sfvars;
  684. $out = '';
  685. if (sf_is_forum_admin($userid) && $current_user->sfadminview == false) return $out;
  686. if($current_user->sfreply && $current_user->offmember == false)
  687. {
  688. $quoteUrl = SFHOMEURL."index.php?sf_ahah=quote";
  689. $intro = $username.' '.__("said:", "sforum").' ';
  690. $out = '<a rel="nofollow" class="sficon" onclick="sfjquotePost('.$postid.', \''.esc_js($intro).'\', '.$sfglobals['editor']['sfeditor'].', '.$sfvars['forumid'].',\''.$quoteUrl.'\');"><img src="'.SFRESOURCES.'quote.png" alt="" title="'.esc_attr(__("Quote and Reply", "sforum")).'" />&nbsp;'.sf_render_icons("Quote and Reply").'</a>'."\n";
  691. }
  692. return $out;
  693. }
  694. endif;
  695. # = RENDER REPORT POST ICON ===================
  696. if(!function_exists('sf_render_report_post_icon')):
  697. function sf_render_report_post_icon($postid, $author, $userid)
  698. {
  699. global $current_user;
  700. $out = '';
  701. if (sf_is_forum_admin($userid) && $current_user->sfadminview == false) return $out;
  702. $returnurl=SFURL;
  703. $out.= '<form class="sfhiddenform" action="'.SFURL.'" method="post" name="report'.$postid.'">'."\n";
  704. $out.= '<input type="hidden" class="sfhiddeninput" name="rpaction" value="report" />'."\n";
  705. $out.= '<input type="hidden" class="sfhiddeninput" name="rpurl" value="'.esc_attr($returnurl).'" />'."\n";
  706. $out.= '<input type="hidden" class="sfhiddeninput" name="rpuser" value="'.$current_user->ID.'" />'."\n";
  707. $out.= '<input type="hidden" class="sfhiddeninput" name="rppost" value="'.$postid.'" />'."\n";
  708. $out.= '<input type="hidden" class="sfhiddeninput" name="rpposter" value="'.esc_attr($author).'" />'."\n";
  709. $out.= '<a rel="nofollow" class="sficon" href="javascript:document.report'.$postid.'.submit();"><img src="'.SFRESOURCES.'reportpost.png" alt="" title="'.esc_attr(__("Report Post", "sforum")).'" />&nbsp;'.sf_render_icons("Report Post").'</a>'."\n";
  710. $out.= '</form>'."\n";
  711. return $out;
  712. }
  713. endif;
  714. # = RENDER SEND PM ICON =======================
  715. if(!function_exists('sf_render_post_user_sendpmicon')):
  716. function sf_render_post_user_sendpmicon($from_user, $to_user, $recipient, $postid)
  717. {
  718. global $current_user, $wpdb;
  719. $returnurl=SFURL;
  720. update_sfsetting($current_user->ID.'@pmurl', $returnurl);
  721. $user = $wpdb->get_var("SELECT user_login FROM ".SFUSERS." WHERE ID=".$to_user);
  722. $url = SFURL.'private-messaging/send/'.urlencode($user).'/';
  723. $out = '<a class="sficon" href="'.$url.'"><img src="'.SFRESOURCES.'sendpm.png" alt="" title="'.esc_attr(__("Send PM", "sforum")).'" />&nbsp;'.sf_render_icons("Send PM").'</a>'."\n";
  724. return $out;
  725. }
  726. endif;
  727. # = RENDER EDIT ICON ==========================
  728. if(!function_exists('sf_render_post_user_editicon')):
  729. function sf_render_post_user_editicon($forumslug, $topicslug, $pageid, $postid, $postindex)
  730. {
  731. $out='';
  732. $out.= '<form class="sfhiddenform" action="'.sf_build_url($forumslug, $topicslug, $pageid, $postid, $postindex).'" method="post" name="usereditpost'.$postid.'">'."\n";
  733. $out.= '<input type="hidden" class="sfhiddeninput" name="useredit" value="'.$postid.'" />'."\n";
  734. $out.= '<a class="sficon" href="javascript:document.usereditpost'.$postid.'.submit();"><img src="'.SFRESOURCES.'useredit.png" alt="" title="'.esc_attr(__("Edit Your Post", "sforum")).'" />&nbsp;'.sf_render_icons("Edit Your Post").'</a>'."\n";
  735. $out.= '</form>'."\n";
  736. return $out;
  737. }
  738. endif;
  739. # = RENDER POST RATINGS =======================
  740. if(!function_exists('sf_render_post_ratings')):
  741. function sf_render_post_ratings($post)
  742. {
  743. global $current_user, $sfvars;
  744. $out = '';
  745. $postid = $post['post_id'];
  746. $postratings = sf_get_option('sfpostratings');
  747. if ($postratings['sfpostratings'])
  748. {
  749. $out.= '<div id="sfpostrating-'.$postid.'">';
  750. if (!isset($post['rating_id']))
  751. {
  752. $ratings = 0;
  753. $votes = 0;
  754. $voted = false;
  755. } else {
  756. $ratings = $post['ratings_sum'];
  757. $votes = $post['vote_count'];
  758. if ($current_user->member)
  759. {
  760. $members = unserialize($post['members']);
  761. if ($members)
  762. {
  763. $voted = array_search($current_user->ID, $members);
  764. } else {
  765. $voted = -1;
  766. }
  767. } else {
  768. $ips = unserialize($post['ips']);
  769. if ($ips)
  770. {
  771. $voted = array_search(getenv("REMOTE_ADDR"), $ips);
  772. } else {
  773. $voted = -1;
  774. }
  775. }
  776. }
  777. if ($postratings['sfratingsstyle'] == 1) # thumb up/down
  778. {
  779. $out.= '<div class="sfpostratingscontainer sfthumbs">';
  780. $site = SFHOMEURL."index.php?sf_ahah=postrating&fid=".$sfvars['forumid']."&amp;pid=".$postid."&amp;rate=down";
  781. $downlink = 'style="cursor: pointer;" onclick="javascript:sfjRatePost(\''.$postid.'\', \''.$site.'\');" ';
  782. $site = SFHOMEURL."index.php?sf_ahah=postrating&fid=".$sfvars['forumid']."&amp;pid=".$postid."&amp;rate=up";
  783. $uplink = 'style="cursor: pointer;" onclick="javascript:sfjRatePost(\''.$postid.'\', \''.$site.'\');" ';
  784. $downimg = SFRESOURCES.'ratings/ratedown.png';
  785. $upimg = SFRESOURCES.'ratings/rateup.png';
  786. $uptext = __("Rate Post Up", "sforum");
  787. $downtext = __("Rate Post Down", "sforum");
  788. if (is_numeric($voted) || !$current_user->sfrateposts)
  789. {
  790. $downlink = '';
  791. $uplink = '';
  792. $downimg = SFRESOURCES.'ratings/ratedowngrey.png';
  793. $upimg = SFRESOURCES.'ratings/rateupgrey.png';
  794. $uptext = __("Post Rating: ", "sforum").$ratings;
  795. $downtext = $uptext;
  796. }
  797. if ($ratings > 0) $ratings = '+'.$ratings;
  798. $out.= '<div class="sfposticon sfpostrating">'.$ratings.'</div>';
  799. $out.= '<div class="sfposticon sfpostratedown"><img src="'.$downimg.'" alt="" title="'.esc_attr($downtext).'" '.$downlink.'/></div>';
  800. $out.= '<div class="sfposticon sfpostrateup"><img src="'.$upimg.'" alt="" title="'.esc_attr($uptext).'" '.$uplink.'/></div>';
  801. } else {
  802. $out.= '<div class="sfpostratingscontainer sfstars">';
  803. $offimg = SFRESOURCES.'ratings/ratestaroff.png';
  804. $onimg = SFRESOURCES.'ratings/ratestaron.png';
  805. $overimg = SFRESOURCES.'ratings/ratestarover.png';
  806. if ($votes)
  807. {
  808. $star_rating = round($ratings / $votes, 1);
  809. } else {
  810. $star_rating = 0;
  811. }
  812. $intrating = floor($star_rating);
  813. $out.= '<div class="sfposticon sfpostrating">'.$star_rating.'</div>';
  814. $out.= '<div class="sfposticon sfpoststars">';
  815. for ($x = 1; $x <= $intrating; $x++)
  816. {
  817. $name = ' id="star-'.$postid.'-'.$x.'"';
  818. if (is_numeric($voted) || !$current_user->sfrateposts)
  819. {
  820. $link = '';
  821. $text = __("Post Rating: ", "sforum").$star_rating;
  822. } else {
  823. if ($x == 1) $text = __("Rate Post 1 Star", "sforum");
  824. if ($x == 2) $text = __("Rate Post 2 Stars", "sforum");
  825. if ($x == 3) $text = __("Rate Post 3 Stars", "sforum");
  826. if ($x == 4) $text = __("Rate Post 4 Stars", "sforum");
  827. if ($x == 5) $text = __("Rate Post 5 Stars", "sforum");
  828. $site = SFHOMEURL."index.php?sf_ahah=postrating&fid=".$sfvars['forumid']."&amp;pid=".$postid."&amp;rate=".$x;
  829. $link = 'style="cursor: pointer;" onclick="javascript:sfjRatePost(\''.$postid.'\', \''.$site.'\');" onmouseover="sfjstarhover(\''.$postid.'\', \''.$x.'\', \''.$overimg.'\')" onmouseout="sfjstarunhover(\''.$postid.'\', \''.$intrating.'\', \''.$onimg.'\', \''.$offimg.'\')" ';
  830. }
  831. $out.= '<img'.$name.' src="'.$onimg.'" alt="" title="'.esc_attr($text).'" '.$link.'/>';
  832. }
  833. for ($x = ($intrating+1); $x <= 5; $x++)
  834. {
  835. $name = ' id="star-'.$postid.'-'.$x.'"';
  836. if (is_numeric($voted) || !$current_user->sfrateposts)
  837. {
  838. $link = '';
  839. $text = __("Post Rating: ", "sforum").$star_rating;
  840. } else {
  841. if ($x == 1) $text = __("Rate Post 1 Star", "sforum");
  842. if ($x == 2) $text = __("Rate Post 2 Stars", "sforum");
  843. if ($x == 3) $text = __("Rate Post 3 Stars", "sforum");
  844. if ($x == 4) $text = __("Rate Post 4 Stars", "sforum");
  845. if ($x == 5) $text = __("Rate Post 5 Stars", "sforum");
  846. $site = SFHOMEURL."index.php?sf_ahah=postrating&fid=".$sfvars['forumid']."&amp;pid=".$postid."&amp;rate=".$x;
  847. $link = 'style="cursor: pointer;" onclick="javascript:sfjRatePost(\''.$postid.'\', \''.$site.'\');" onmouseover="sfjstarhover(\''.$postid.'\', \''.$x.'\', \''.$overimg.'\')" onmouseout="sfjstarunhover(\''.$postid.'\', \''.$intrating.'\', \''.$onimg.'\', \''.$offimg.'\')" ';
  848. }
  849. $out.= '<img'.$name.' src="'.$offimg.'" alt="" title="'.esc_attr($text).'" '.$link.'/>';
  850. }
  851. $out.= '</div>';
  852. }
  853. $out.= '</div>';
  854. $out.= '</div>';
  855. }
  856. return $out;
  857. }
  858. endif;
  859. function sf_render_post_printicon($postid)
  860. {
  861. $out = '<a class="sficon" href="javascript:void(0);" onclick="javscript:jQuery(\'#post'.$postid.'\').jqprint({debug:true}); return false;"><img src="'.SFRESOURCES.'print.png" alt="" title="'.esc_attr(__("Print This Post", "sforum")).'"/>'.sf_render_icons("Print this Post").'</a>';
  862. return $out;
  863. }
  864. function sf_render_post_tools_icon($forumid, $postid, $page, $postnum, $displayname)
  865. {
  866. $site = SFHOMEURL."index.php?sf_ahah=adminlinks&action=posttools&post=".$postid."&page=".$page."&postnum=".$postnum."&name=".urlencode($displayname)."&forum=".$forumid;
  867. $out ='<div class="sfposticon sfalignleft sfposttoolsicon" style="padding-top:2px"><a href="'.esc_attr($site).'" onclick="return hs.htmlExpand(this, { objectType: \'ajax\', preserveContent: true, width: 280, height: 350, anchor: \'top left\'} )"><img src="'.SFRESOURCES.'small-tools.png" alt="" title="'.esc_attr(__("Show Edit Tools", "sforum")).'" /></a></div>';
  868. return $out;
  869. }
  870. ?>