modification.xml 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684
  1. <?xml version="1.0"?>
  2. <!DOCTYPE modification SYSTEM "http://www.simplemachines.org/xml/modification">
  3. <modification xmlns="http://www.simplemachines.org/xml/modification" xmlns:smf="http://www.simplemachines.org/">
  4. <id>cooliojazz:RecentPosts</id>
  5. <version>0.1</version>
  6. <file name="$sourcedir/../index.php">
  7. <operation>
  8. <search position="replace"><![CDATA[array('Recent.php', 'RecentPosts')]]></search>
  9. <add><![CDATA[array('Recent.php', 'RecentPosts2')]]></add>
  10. </operation>
  11. </file>
  12. <file name="$sourcedir/Recent.php">
  13. <operation>
  14. <search position="end" />
  15. <add><![CDATA[
  16. // Find unread topics and replies.
  17. function RecentPosts2() {
  18. global $board, $txt, $scripturl, $sourcedir, $user_info, $context, $settings, $modSettings, $smcFunc, $options;
  19. $context['showing_all_topics'] = false;
  20. // Prefetching + lots of MySQL work = bad mojo.
  21. if (isset($_SERVER['HTTP_X_MOZ']) && $_SERVER['HTTP_X_MOZ'] == 'prefetch') {
  22. ob_end_clean();
  23. header('HTTP/1.1 403 Forbidden');
  24. die;
  25. }
  26. $context['start'] = (int)$_REQUEST['start'];
  27. $context['topics_per_page'] = empty($modSettings['disableCustomPerPage']) && !empty($options['topics_per_page']) && !WIRELESS ? $options['topics_per_page'] : $modSettings['defaultMaxTopics'];
  28. $context['page_title'] = $txt['recent_posts'];
  29. // if ($context['showing_all_topics'] && !empty($context['load_average']) && !empty($modSettings['loadavg_allunread']) && $context['load_average'] >= $modSettings['loadavg_allunread'])
  30. // fatal_lang_error('loadavg_allunread_disabled', false);
  31. // elseif ($_REQUEST['action'] != 'unread' && !empty($context['load_average']) && !empty($modSettings['loadavg_unreadreplies']) && $context['load_average'] >= $modSettings['loadavg_unreadreplies'])
  32. // fatal_lang_error('loadavg_unreadreplies_disabled', false);
  33. // elseif (!$context['showing_all_topics'] && $_REQUEST['action'] == 'unread' && !empty($context['load_average']) && !empty($modSettings['loadavg_unread']) && $context['load_average'] >= $modSettings['loadavg_unread'])
  34. // fatal_lang_error('loadavg_unread_disabled', false);
  35. // Parameters for the main query.
  36. $query_parameters = array();
  37. // Are we specifying any specific board?
  38. if (isset($_REQUEST['children']) && (!empty($board) || !empty($_REQUEST['boards']))) {
  39. $boards = array();
  40. if (!empty($_REQUEST['boards'])) {
  41. $_REQUEST['boards'] = explode(',', $_REQUEST['boards']);
  42. foreach ($_REQUEST['boards'] as $b) $boards[] = (int)$b;
  43. }
  44. if (!empty($board)) $boards[] = (int)$board;
  45. // The easiest thing is to just get all the boards they can see, but since we've specified the top of tree we ignore some of them
  46. $request = $smcFunc['db_query']('', '
  47. SELECT b.id_board, b.id_parent
  48. FROM {db_prefix}boards AS b
  49. WHERE {query_wanna_see_board}
  50. AND b.child_level > {int:no_child}
  51. AND b.id_board NOT IN ({array_int:boards})
  52. ORDER BY child_level ASC
  53. ',
  54. array(
  55. 'no_child' => 0,
  56. 'boards' => $boards,
  57. )
  58. );
  59. while ($row = $smcFunc['db_fetch_assoc']($request)) {
  60. if (in_array($row['id_parent'], $boards)) $boards[] = $row['id_board'];
  61. }
  62. $smcFunc['db_free_result']($request);
  63. if (empty($boards)) fatal_lang_error('error_no_boards_selected');
  64. $query_this_board = 'id_board IN ({array_int:boards})';
  65. $query_parameters['boards'] = $boards;
  66. $context['querystring_board_limits'] = ';boards=' . implode(',', $boards) . ';start=%d';
  67. } elseif (!empty($board)) {
  68. $query_this_board = 'id_board = {int:board}';
  69. $query_parameters['board'] = $board;
  70. $context['querystring_board_limits'] = ';board=' . $board . '.%1$d';
  71. } elseif (!empty($_REQUEST['boards'])) {
  72. $_REQUEST['boards'] = explode(',', $_REQUEST['boards']);
  73. foreach ($_REQUEST['boards'] as $i => $b) $_REQUEST['boards'][$i] = (int) $b;
  74. $request = $smcFunc['db_query']('', '
  75. SELECT b.id_board
  76. FROM {db_prefix}boards AS b
  77. WHERE {query_see_board}
  78. AND b.id_board IN ({array_int:board_list})',
  79. array(
  80. 'board_list' => $_REQUEST['boards'],
  81. )
  82. );
  83. $boards = array();
  84. while ($row = $smcFunc['db_fetch_assoc']($request)) $boards[] = $row['id_board'];
  85. $smcFunc['db_free_result']($request);
  86. if (empty($boards)) fatal_lang_error('error_no_boards_selected');
  87. $query_this_board = 'id_board IN ({array_int:boards})';
  88. $query_parameters['boards'] = $boards;
  89. $context['querystring_board_limits'] = ';boards=' . implode(',', $boards) . ';start=%1$d';
  90. } elseif (!empty($_REQUEST['c'])) {
  91. $_REQUEST['c'] = explode(',', $_REQUEST['c']);
  92. foreach ($_REQUEST['c'] as $i => $c)
  93. $_REQUEST['c'][$i] = (int) $c;
  94. $see_board = isset($_REQUEST['action']) && $_REQUEST['action'] == 'unreadreplies' ? 'query_see_board' : 'query_wanna_see_board';
  95. $request = $smcFunc['db_query']('', '
  96. SELECT b.id_board
  97. FROM {db_prefix}boards AS b
  98. WHERE ' . $user_info[$see_board] . '
  99. AND b.id_cat IN ({array_int:id_cat})',
  100. array(
  101. 'id_cat' => $_REQUEST['c'],
  102. )
  103. );
  104. $boards = array();
  105. while ($row = $smcFunc['db_fetch_assoc']($request))
  106. $boards[] = $row['id_board'];
  107. $smcFunc['db_free_result']($request);
  108. if (empty($boards))
  109. fatal_lang_error('error_no_boards_selected');
  110. $query_this_board = 'id_board IN ({array_int:boards})';
  111. $query_parameters['boards'] = $boards;
  112. $context['querystring_board_limits'] = ';c=' . implode(',', $_REQUEST['c']) . ';start=%1$d';
  113. } else {
  114. $see_board = isset($_REQUEST['action']) && $_REQUEST['action'] == 'unreadreplies' ? 'query_see_board' : 'query_wanna_see_board';
  115. // Don't bother to show deleted posts!
  116. $request = $smcFunc['db_query']('', '
  117. SELECT b.id_board
  118. FROM {db_prefix}boards AS b
  119. WHERE ' . $user_info[$see_board] . (!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0 ? '
  120. AND b.id_board != {int:recycle_board}' : ''),
  121. array(
  122. 'recycle_board' => (int) $modSettings['recycle_board'],
  123. )
  124. );
  125. $boards = array();
  126. while ($row = $smcFunc['db_fetch_assoc']($request)) $boards[] = $row['id_board'];
  127. $smcFunc['db_free_result']($request);
  128. if (empty($boards)) fatal_lang_error('error_no_boards_selected');
  129. $query_this_board = 'id_board IN ({array_int:boards})';
  130. $query_parameters['boards'] = $boards;
  131. $context['querystring_board_limits'] = ';start=%1$d';
  132. $context['no_board_limits'] = true;
  133. }
  134. $sort_methods = array(
  135. 'subject' => 'ms.subject',
  136. 'starter' => 'IFNULL(mems.real_name, ms.poster_name)',
  137. 'replies' => 't.num_replies',
  138. 'views' => 't.num_views',
  139. 'first_post' => 't.id_topic',
  140. 'last_post' => 't.id_last_msg'
  141. );
  142. // The default is the most logical: newest first.
  143. if (!isset($_REQUEST['sort']) || !isset($sort_methods[$_REQUEST['sort']])) {
  144. $context['sort_by'] = 'last_post';
  145. $_REQUEST['sort'] = 't.id_last_msg';
  146. $ascending = isset($_REQUEST['asc']);
  147. $context['querystring_sort_limits'] = $ascending ? ';asc' : '';
  148. } else {
  149. // But, for other methods the default sort is ascending.
  150. $context['sort_by'] = $_REQUEST['sort'];
  151. $_REQUEST['sort'] = $sort_methods[$_REQUEST['sort']];
  152. $ascending = !isset($_REQUEST['desc']);
  153. $context['querystring_sort_limits'] = ';sort=' . $context['sort_by'] . ($ascending ? '' : ';desc');
  154. }
  155. $context['sort_direction'] = $ascending ? 'up' : 'down';
  156. if (!empty($_REQUEST['c']) && is_array($_REQUEST['c']) && count($_REQUEST['c']) == 1) {
  157. $request = $smcFunc['db_query']('', '
  158. SELECT name
  159. FROM {db_prefix}categories
  160. WHERE id_cat = {int:id_cat}
  161. LIMIT 1',
  162. array(
  163. 'id_cat' => (int) $_REQUEST['c'][0],
  164. )
  165. );
  166. list ($name) = $smcFunc['db_fetch_row']($request);
  167. $smcFunc['db_free_result']($request);
  168. $context['linktree'][] = array(
  169. 'url' => $scripturl . '#c' . (int) $_REQUEST['c'][0],
  170. 'name' => $name
  171. );
  172. }
  173. $context['linktree'][] = array(
  174. 'url' => $scripturl . '?action=' . $_REQUEST['action'] . sprintf($context['querystring_board_limits'], 0) . $context['querystring_sort_limits'],
  175. 'name' => $_REQUEST['action'] == 'recent' ? $txt['unread_topics_visit'] : $txt['unread_replies']
  176. );
  177. // if ($context['showing_all_topics'])
  178. // $context['linktree'][] = array(
  179. // 'url' => $scripturl . '?action=' . $_REQUEST['action'] . ';all' . sprintf($context['querystring_board_limits'], 0) . $context['querystring_sort_limits'],
  180. // 'name' => $txt['unread_topics_all']
  181. // );
  182. // else
  183. $txt['unread_topics_visit_none'] = strtr($txt['unread_topics_visit_none'], array('?action=unread;all' => '?action=unread;all' . sprintf($context['querystring_board_limits'], 0) . $context['querystring_sort_limits']));
  184. if (WIRELESS)
  185. $context['sub_template'] = WIRELESS_PROTOCOL . '_recent';
  186. else {
  187. loadTemplate('Recent');
  188. $context['sub_template'] = 'recent';
  189. }
  190. // Setup the default topic icons... for checking they exist and the like ;)
  191. $stable_icons = array('xx', 'thumbup', 'thumbdown', 'exclamation', 'question', 'lamp', 'smiley', 'angry', 'cheesy', 'grin', 'sad', 'wink', 'moved', 'recycled', 'wireless', 'clip');
  192. $context['icon_sources'] = array();
  193. foreach ($stable_icons as $icon) $context['icon_sources'][$icon] = 'images_url';
  194. // This part is the same for each query.
  195. $select_clause = '
  196. ms.subject AS first_subject, ms.poster_time AS first_poster_time, ms.id_topic, t.id_board, b.name AS bname,
  197. t.num_replies, t.num_views, ms.id_member AS id_first_member, ml.id_member AS id_last_member,
  198. ml.poster_time AS last_poster_time, IFNULL(mems.real_name, ms.poster_name) AS first_poster_name,
  199. IFNULL(meml.real_name, ml.poster_name) AS last_poster_name, ml.subject AS last_subject,
  200. ml.icon AS last_icon, ms.icon AS first_icon, t.id_poll, t.is_sticky, t.locked, ml.modified_time AS last_modified_time,
  201. IFNULL(lt.id_msg, IFNULL(lmr.id_msg, -1)) + 1 AS new_from, SUBSTRING(ml.body, 1, 385) AS last_body,
  202. SUBSTRING(ms.body, 1, ' . (!empty($modSettings['NiceTooltips_lenght']) ? $modSettings['NiceTooltips_lenght'] : 385) . ') AS first_body, ml.smileys_enabled AS last_smileys, ms.smileys_enabled AS first_smileys, t.id_first_msg, t.id_last_msg';
  203. // !!! Add modified_time in for log_time check?
  204. if ($modSettings['totalMessages'] > 100000) {
  205. $smcFunc['db_query']('', '
  206. DROP TABLE IF EXISTS {db_prefix}log_topics_unread',
  207. array(
  208. )
  209. );
  210. // Let's copy things out of the log_topics table, to reduce searching.
  211. $have_temp_table = $smcFunc['db_query']('', '
  212. CREATE TEMPORARY TABLE {db_prefix}log_topics_unread (PRIMARY KEY (id_topic))
  213. SELECT lt.id_topic, lt.id_msg
  214. FROM {db_prefix}topics AS t
  215. INNER JOIN {db_prefix}log_topics AS lt ON (lt.id_topic = t.id_topic)
  216. WHERE lt.id_member = {int:current_member}
  217. AND t.' . $query_this_board . ($modSettings['postmod_active'] ? '
  218. AND t.approved = {int:is_approved}' : ''),
  219. array_merge($query_parameters, array(
  220. 'current_member' => $user_info['id'],
  221. 'is_approved' => 1,
  222. 'db_error_skip' => true,
  223. ))
  224. ) !== false;
  225. } else {
  226. $have_temp_table = false;
  227. }
  228. $request = $smcFunc['db_query']('', '
  229. SELECT COUNT(*), MIN(t.id_last_msg)
  230. FROM {db_prefix}topics AS t' . (!empty($have_temp_table) ? '
  231. LEFT JOIN {db_prefix}log_topics_unread AS lt ON (lt.id_topic = t.id_topic)' : '
  232. LEFT JOIN {db_prefix}log_topics AS lt ON (lt.id_topic = t.id_topic AND lt.id_member = {int:current_member})') . '
  233. LEFT JOIN {db_prefix}log_mark_read AS lmr ON (lmr.id_board = t.id_board AND lmr.id_member = {int:current_member})
  234. WHERE t.' . $query_this_board . ($modSettings['postmod_active'] ? '
  235. AND t.approved = {int:is_approved}' : ''),
  236. array_merge($query_parameters, array(
  237. 'current_member' => $user_info['id'],
  238. 'is_approved' => 1,
  239. ))
  240. );
  241. list($num_topics, $min_message) = $smcFunc['db_fetch_row']($request);
  242. $smcFunc['db_free_result']($request);
  243. // Make sure the starting place makes sense and construct the page index.
  244. $context['page_index'] = constructPageIndex($scripturl . '?action=' . $_REQUEST['action'] . ($context['showing_all_topics'] ? ';all' : '') . $context['querystring_board_limits'] . $context['querystring_sort_limits'], $_REQUEST['start'], $num_topics, $context['topics_per_page'], true);
  245. $context['current_page'] = (int) $_REQUEST['start'] / $context['topics_per_page'];
  246. $context['links'] = array(
  247. 'first' => $_REQUEST['start'] >= $context['topics_per_page'] ? $scripturl . '?action=' . $_REQUEST['action'] . ($context['showing_all_topics'] ? ';all' : '') . sprintf($context['querystring_board_limits'], 0) . $context['querystring_sort_limits'] : '',
  248. 'prev' => $_REQUEST['start'] >= $context['topics_per_page'] ? $scripturl . '?action=' . $_REQUEST['action'] . ($context['showing_all_topics'] ? ';all' : '') . sprintf($context['querystring_board_limits'], $_REQUEST['start'] - $context['topics_per_page']) . $context['querystring_sort_limits'] : '',
  249. 'next' => $_REQUEST['start'] + $context['topics_per_page'] < $num_topics ? $scripturl . '?action=' . $_REQUEST['action'] . ($context['showing_all_topics'] ? ';all' : '') . sprintf($context['querystring_board_limits'], $_REQUEST['start'] + $context['topics_per_page']) . $context['querystring_sort_limits'] : '',
  250. 'last' => $_REQUEST['start'] + $context['topics_per_page'] < $num_topics ? $scripturl . '?action=' . $_REQUEST['action'] . ($context['showing_all_topics'] ? ';all' : '') . sprintf($context['querystring_board_limits'], floor(($num_topics - 1) / $context['topics_per_page']) * $context['topics_per_page']) . $context['querystring_sort_limits'] : '',
  251. 'up' => $scripturl,
  252. );
  253. $context['page_info'] = array(
  254. 'current_page' => $_REQUEST['start'] / $context['topics_per_page'] + 1,
  255. 'num_pages' => floor(($num_topics - 1) / $context['topics_per_page']) + 1
  256. );
  257. $request = $smcFunc['db_query']('substring', '
  258. SELECT ' . $select_clause . '
  259. FROM {db_prefix}messages AS ms
  260. INNER JOIN {db_prefix}topics AS t ON (t.id_topic = ms.id_topic AND t.id_first_msg = ms.id_msg)
  261. INNER JOIN {db_prefix}messages AS ml ON (ml.id_msg = t.id_last_msg)
  262. LEFT JOIN {db_prefix}boards AS b ON (b.id_board = t.id_board)
  263. LEFT JOIN {db_prefix}members AS mems ON (mems.id_member = ms.id_member)
  264. LEFT JOIN {db_prefix}members AS meml ON (meml.id_member = ml.id_member)' . (!empty($have_temp_table) ? '
  265. LEFT JOIN {db_prefix}log_topics_unread AS lt ON (lt.id_topic = t.id_topic)' : '
  266. LEFT JOIN {db_prefix}log_topics AS lt ON (lt.id_topic = t.id_topic AND lt.id_member = {int:current_member})') . '
  267. LEFT JOIN {db_prefix}log_mark_read AS lmr ON (lmr.id_board = t.id_board AND lmr.id_member = {int:current_member})
  268. WHERE t.' . $query_this_board . ($modSettings['postmod_active'] ? '
  269. AND ms.approved = {int:is_approved}' : '') . '
  270. ORDER BY {raw:order}
  271. LIMIT {int:offset}, {int:limit}',
  272. array_merge($query_parameters, array(
  273. 'current_member' => $user_info['id'],
  274. 'is_approved' => 1,
  275. 'order' => $_REQUEST['sort'] . ($ascending ? '' : ' DESC'),
  276. 'offset' => $_REQUEST['start'],
  277. 'limit' => $context['topics_per_page'],
  278. ))
  279. );
  280. $context['topics'] = array();
  281. $topic_ids = array();
  282. while ($row = $smcFunc['db_fetch_assoc']($request)) {
  283. if ($row['id_poll'] > 0 && $modSettings['pollMode'] == '0') continue;
  284. $topic_ids[] = $row['id_topic'];
  285. if (!empty($settings['message_index_preview'])) {
  286. // Limit them to 128 characters - do this FIRST because it's a lot of wasted censoring otherwise.
  287. $row['first_body'] = strip_tags(strtr(parse_bbc($row['first_body'], $row['first_smileys'], $row['id_first_msg']), array('<br />' => '&#10;')));
  288. if ($smcFunc['strlen']($row['first_body']) > 128)
  289. $row['first_body'] = $smcFunc['substr']($row['first_body'], 0, 128) . '...';
  290. $row['last_body'] = strip_tags(strtr(parse_bbc($row['last_body'], $row['last_smileys'], $row['id_last_msg']), array('<br />' => '&#10;')));
  291. if ($smcFunc['strlen']($row['last_body']) > 128)
  292. $row['last_body'] = $smcFunc['substr']($row['last_body'], 0, 128) . '...';
  293. // Censor the subject and message preview.
  294. censorText($row['first_subject']);
  295. censorText($row['first_body']);
  296. // Don't censor them twice!
  297. if ($row['id_first_msg'] == $row['id_last_msg']) {
  298. $row['last_subject'] = $row['first_subject'];
  299. $row['last_body'] = $row['first_body'];
  300. } else {
  301. censorText($row['last_subject']);
  302. censorText($row['last_body']);
  303. }
  304. } else {
  305. $row['first_body'] = '';
  306. $row['last_body'] = '';
  307. censorText($row['first_subject']);
  308. if ($row['id_first_msg'] == $row['id_last_msg'])
  309. $row['last_subject'] = $row['first_subject'];
  310. else
  311. censorText($row['last_subject']);
  312. }
  313. // Decide how many pages the topic should have.
  314. $topic_length = $row['num_replies'] + 1;
  315. $messages_per_page = empty($modSettings['disableCustomPerPage']) && !empty($options['messages_per_page']) && !WIRELESS ? $options['messages_per_page'] : $modSettings['defaultMaxMessages'];
  316. if ($topic_length > $messages_per_page)
  317. {
  318. $tmppages = array();
  319. $tmpa = 1;
  320. for ($tmpb = 0; $tmpb < $topic_length; $tmpb += $messages_per_page)
  321. {
  322. $tmppages[] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.' . $tmpb . ';topicseen">' . $tmpa . '</a>';
  323. $tmpa++;
  324. }
  325. // Show links to all the pages?
  326. if (count($tmppages) <= 5)
  327. $pages = '&#171; ' . implode(' ', $tmppages);
  328. // Or skip a few?
  329. else
  330. $pages = '&#171; ' . $tmppages[0] . ' ' . $tmppages[1] . ' ... ' . $tmppages[count($tmppages) - 2] . ' ' . $tmppages[count($tmppages) - 1];
  331. if (!empty($modSettings['enableAllMessages']) && $topic_length < $modSettings['enableAllMessages'])
  332. $pages .= ' &nbsp;<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0;all">' . $txt['all'] . '</a>';
  333. $pages .= ' &#187;';
  334. } else {
  335. $pages = '';
  336. }
  337. // We need to check the topic icons exist... you can never be too sure!
  338. if (empty($modSettings['messageIconChecks_disable'])) {
  339. // First icon first... as you'd expect.
  340. if (!isset($context['icon_sources'][$row['first_icon']]))
  341. $context['icon_sources'][$row['first_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['first_icon'] . '.gif') ? 'images_url' : 'default_images_url';
  342. // Last icon... last... duh.
  343. if (!isset($context['icon_sources'][$row['last_icon']]))
  344. $context['icon_sources'][$row['last_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['last_icon'] . '.gif') ? 'images_url' : 'default_images_url';
  345. }
  346. // * NiceTooltips mod
  347. $row['nice_tooltip_first_msg'] = NiceTooltip($row['first_body'], $row['first_subject'], $row['first_smileys'], $row['id_first_msg']);
  348. // And build the array.
  349. $context['topics'][$row['id_topic']] = array(
  350. 'id' => $row['id_topic'],
  351. 'first_post' => array(
  352. 'id' => $row['id_first_msg'],
  353. 'member' => array(
  354. 'name' => $row['first_poster_name'],
  355. 'id' => $row['id_first_member'],
  356. 'href' => $scripturl . '?action=profile;u=' . $row['id_first_member'],
  357. 'link' => !empty($row['id_first_member']) ? '<a href="' . $scripturl . '?action=profile;u=' . $row['id_first_member'] . '" title="' . $txt['profile_of'] . ' ' . $row['first_poster_name'] . '">' . $row['first_poster_name'] . '</a>' : $row['first_poster_name']
  358. ),
  359. 'time' => timeformat($row['first_poster_time']),
  360. 'timestamp' => forum_time(true, $row['first_poster_time']),
  361. 'subject' => $row['first_subject'],
  362. 'preview' => $row['first_body'],
  363. 'icon' => $row['first_icon'],
  364. 'icon_url' => $settings[$context['icon_sources'][$row['first_icon']]] . '/post/' . $row['first_icon'] . '.gif',
  365. 'href' => $scripturl . '?topic=' . $row['id_topic'] . '.0;topicseen',
  366. // * NiceTooltips mod
  367. 'link' => '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0;topscreen"' . $row['nice_tooltip_first_msg'] . ' >' . $row['first_subject'] . '</a>'
  368. ),
  369. 'last_post' => array(
  370. 'id' => $row['id_last_msg'],
  371. 'member' => array(
  372. 'name' => $row['last_poster_name'],
  373. 'id' => $row['id_last_member'],
  374. 'href' => $scripturl . '?action=profile;u=' . $row['id_last_member'],
  375. 'link' => !empty($row['id_last_member']) ? '<a href="' . $scripturl . '?action=profile;u=' . $row['id_last_member'] . '">' . $row['last_poster_name'] . '</a>' : $row['last_poster_name']
  376. ),
  377. 'time' => timeformat($row['last_poster_time']),
  378. 'timestamp' => forum_time(true, $row['last_poster_time']),
  379. 'subject' => $row['last_subject'],
  380. 'preview' => $row['last_body'],
  381. 'icon' => $row['last_icon'],
  382. 'icon_url' => $settings[$context['icon_sources'][$row['last_icon']]] . '/post/' . $row['last_icon'] . '.gif',
  383. 'href' => $scripturl . '?topic=' . $row['id_topic'] . ($row['num_replies'] == 0 ? '.0' : '.msg' . $row['id_last_msg']) . ';topicseen#msg' . $row['id_last_msg'],
  384. 'link' => '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . ($row['num_replies'] == 0 ? '.0' : '.msg' . $row['id_last_msg']) . ';topicseen#msg' . $row['id_last_msg'] . '" rel="nofollow">' . $row['last_subject'] . '</a>'
  385. ),
  386. 'new_from' => $row['new_from'],
  387. 'new_href' => $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['new_from'] . ';topicseen#new',
  388. 'href' => $scripturl . '?topic=' . $row['id_topic'] . ($row['num_replies'] == 0 ? '.0' : '.msg' . $row['new_from']) . ';topicseen' . ($row['num_replies'] == 0 ? '' : 'new'),
  389. 'link' => '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . ($row['num_replies'] == 0 ? '.0' : '.msg' . $row['new_from']) . ';topicseen#msg' . $row['new_from'] . '" rel="nofollow">' . $row['first_subject'] . '</a>',
  390. 'is_sticky' => !empty($modSettings['enableStickyTopics']) && !empty($row['is_sticky']),
  391. 'is_locked' => !empty($row['locked']),
  392. 'is_poll' => $modSettings['pollMode'] == '1' && $row['id_poll'] > 0,
  393. 'is_hot' => $row['num_replies'] >= $modSettings['hotTopicPosts'],
  394. 'is_very_hot' => $row['num_replies'] >= $modSettings['hotTopicVeryPosts'],
  395. 'is_posted_in' => false,
  396. 'icon' => $row['first_icon'],
  397. 'icon_url' => $settings[$context['icon_sources'][$row['first_icon']]] . '/post/' . $row['first_icon'] . '.gif',
  398. 'subject' => $row['first_subject'],
  399. 'pages' => $pages,
  400. 'replies' => comma_format($row['num_replies']),
  401. 'views' => comma_format($row['num_views']),
  402. 'board' => array(
  403. 'id' => $row['id_board'],
  404. 'name' => $row['bname'],
  405. 'href' => $scripturl . '?board=' . $row['id_board'] . '.0',
  406. 'link' => '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['bname'] . '</a>'
  407. )
  408. );
  409. determineTopicClass($context['topics'][$row['id_topic']]);
  410. }
  411. $smcFunc['db_free_result']($request);
  412. $is_topics = false;
  413. if ($is_topics && !empty($modSettings['enableParticipation']) && !empty($topic_ids)) {
  414. $result = $smcFunc['db_query']('', '
  415. SELECT id_topic
  416. FROM {db_prefix}messages
  417. WHERE id_topic IN ({array_int:topic_list})
  418. AND id_member = {int:current_member}
  419. GROUP BY id_topic
  420. LIMIT {int:limit}',
  421. array(
  422. 'current_member' => $user_info['id'],
  423. 'topic_list' => $topic_ids,
  424. 'limit' => count($topic_ids),
  425. )
  426. );
  427. while ($row = $smcFunc['db_fetch_assoc']($result)) {
  428. if (empty($context['topics'][$row['id_topic']]['is_posted_in'])) {
  429. $context['topics'][$row['id_topic']]['is_posted_in'] = true;
  430. $context['topics'][$row['id_topic']]['class'] = 'my_' . $context['topics'][$row['id_topic']]['class'];
  431. }
  432. }
  433. $smcFunc['db_free_result']($result);
  434. }
  435. $context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']);
  436. $context['topics_to_mark'] = implode('-', $topic_ids);
  437. }
  438. ]]></add>
  439. </operation>
  440. </file>
  441. <file name="$themedir/Recent.template.php">
  442. <operation>
  443. <search position="end" />
  444. <add><![CDATA[
  445. function template_recent() {
  446. global $context, $settings, $options, $txt, $scripturl, $modSettings;
  447. echo '
  448. <div id="recent" class="main_content">';
  449. $showCheckboxes = !empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && $settings['show_mark_read'];
  450. if ($showCheckboxes)
  451. echo '
  452. <form action="', $scripturl, '?action=quickmod" method="post" accept-charset="', $context['character_set'], '" name="quickModForm" id="quickModForm" style="margin: 0;">
  453. <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
  454. <input type="hidden" name="qaction" value="markread" />
  455. <input type="hidden" name="redirect_url" value="action=unread', (!empty($context['showing_all_topics']) ? ';all' : ''), $context['querystring_board_limits'], '" />';
  456. if ($settings['show_mark_read'])
  457. {
  458. // Generate the button strip.
  459. $mark_read = array(
  460. 'markread' => array('text' => !empty($context['no_board_limits']) ? 'mark_as_read' : 'mark_read_short', 'image' => 'markread.gif', 'lang' => true, 'url' => $scripturl . '?action=markasread;sa=' . (!empty($context['no_board_limits']) ? 'all' : 'board' . $context['querystring_board_limits']) . ';' . $context['session_var'] . '=' . $context['session_id']),
  461. );
  462. if ($showCheckboxes)
  463. $mark_read['markselectread'] = array(
  464. 'text' => 'quick_mod_markread',
  465. 'image' => 'markselectedread.gif',
  466. 'lang' => true,
  467. 'url' => 'javascript:document.quickModForm.submit();',
  468. );
  469. }
  470. if (!empty($context['topics']))
  471. {
  472. echo '
  473. <div class="pagesection">';
  474. if (!empty($mark_read) && !empty($settings['use_tabs']))
  475. template_button_strip($mark_read, 'right');
  476. echo '
  477. <span>', $txt['pages'], ': ', $context['page_index'], '</span>
  478. </div>';
  479. echo '
  480. <div class="tborder topic_table" id="unread">
  481. <table class="table_grid" cellspacing="0">
  482. <thead>
  483. <tr class="catbg">
  484. <th scope="col" class="first_th" width="8%" colspan="2">&nbsp;</th>
  485. <th scope="col">
  486. <a href="', $scripturl, '?action=recent', $context['showing_all_topics'] ? ';all' : '', $context['querystring_board_limits'], ';sort=subject', $context['sort_by'] == 'subject' && $context['sort_direction'] == 'up' ? ';desc' : '', '">', $txt['subject'], $context['sort_by'] == 'subject' ? ' <img src="' . $settings['images_url'] . '/sort_' . $context['sort_direction'] . '.gif" alt="" />' : '', '</a>
  487. </th>
  488. <th scope="col" width="14%" align="center">
  489. <a href="', $scripturl, '?action=recent', $context['showing_all_topics'] ? ';all' : '', $context['querystring_board_limits'], ';sort=replies', $context['sort_by'] == 'replies' && $context['sort_direction'] == 'up' ? ';desc' : '', '">', $txt['replies'], $context['sort_by'] == 'replies' ? ' <img src="' . $settings['images_url'] . '/sort_' . $context['sort_direction'] . '.gif" alt="" />' : '', '</a>
  490. </th>';
  491. // Show a "select all" box for quick moderation?
  492. if ($showCheckboxes)
  493. echo '
  494. <th scope="col" width="22%">
  495. <a href="', $scripturl, '?action=recent', $context['showing_all_topics'] ? ';all' : '', $context['querystring_board_limits'], ';sort=last_post', $context['sort_by'] == 'last_post' && $context['sort_direction'] == 'up' ? ';desc' : '', '">', $txt['last_post'], $context['sort_by'] == 'last_post' ? ' <img src="' . $settings['images_url'] . '/sort_' . $context['sort_direction'] . '.gif" alt="" />' : '', '</a>
  496. </th>
  497. <th class="last_th">
  498. <input type="checkbox" onclick="invertAll(this, this.form, \'topics[]\');" class="input_check" />
  499. </th>';
  500. else
  501. echo '
  502. <th scope="col" class="smalltext last_th" width="22%">
  503. <a href="', $scripturl, '?action=recent', $context['showing_all_topics'] ? ';all' : '', $context['querystring_board_limits'], ';sort=last_post', $context['sort_by'] == 'last_post' && $context['sort_direction'] == 'up' ? ';desc' : '', '">', $txt['last_post'], $context['sort_by'] == 'last_post' ? ' <img src="' . $settings['images_url'] . '/sort_' . $context['sort_direction'] . '.gif" alt="" />' : '', '</a>
  504. </th>';
  505. echo '
  506. </tr>
  507. </thead>
  508. <tbody>';
  509. foreach ($context['topics'] as $topic)
  510. {
  511. // Calculate the color class of the topic.
  512. $color_class = '';
  513. if (strpos($topic['class'], 'sticky') !== false)
  514. $color_class = 'stickybg';
  515. if (strpos($topic['class'], 'locked') !== false)
  516. $color_class .= 'lockedbg';
  517. $color_class2 = !empty($color_class) ? $color_class . '2' : '';
  518. echo '
  519. <tr>
  520. <td class="', $color_class, ' icon1 windowbg">
  521. <img src="', $settings['images_url'], '/topic/', $topic['class'], '.gif" alt="" />
  522. </td>
  523. <td class="', $color_class, ' icon2 windowbg">
  524. <img src="', $topic['first_post']['icon_url'], '" alt="" />
  525. </td>
  526. <td class="subject ', $color_class2, ' windowbg2">
  527. <div>
  528. ', $topic['is_sticky'] ? '<strong>' : '', '<span id="msg_' . $topic['first_post']['id'] . '">', $topic['first_post']['link'], '</span>', $topic['is_sticky'] ? '</strong>' : '', '
  529. ', ($topic['new_from'] <= $topic['last_post']['id'] ? '
  530. <a href="' . $topic['new_href'] . '" id="newicon' . $topic['first_post']['id'] . '"><img src="' . $settings['lang_images_url'] . '/new.gif" alt="' . $txt['new'] . '" /></a>
  531. ' : ''), '
  532. <p>
  533. ', $txt['started_by'], ' <strong>', $topic['first_post']['member']['link'], '</strong>
  534. ', $txt['in'], ' <em>', $topic['board']['link'], '</em>
  535. <small id="pages', $topic['first_post']['id'], '">', $topic['pages'], '</small>
  536. </p>
  537. </div>
  538. </td>
  539. <td class="', $color_class, ' stats windowbg">
  540. ', $topic['replies'], ' ', $txt['replies'], '
  541. <br />
  542. ', $topic['views'], ' ', $txt['views'], '
  543. </td>
  544. <td class="', $color_class2, ' lastpost windowbg2">
  545. <a href="', $topic['last_post']['href'], '"><img src="', $settings['images_url'], '/icons/last_post.gif" alt="', $txt['last_post'], '" title="', $txt['last_post'], '" style="float: right;" /></a>
  546. ', $topic['last_post']['time'], '<br />
  547. ', $txt['by'], ' ', $topic['last_post']['member']['link'], '
  548. </td>';
  549. if ($showCheckboxes)
  550. echo '
  551. <td class="windowbg2" valign="middle" align="center">
  552. <input type="checkbox" name="topics[]" value="', $topic['id'], '" class="input_check" />
  553. </td>';
  554. echo '
  555. </tr>';
  556. }
  557. if (!empty($context['topics']) && !$context['showing_all_topics'])
  558. $mark_read['readall'] = array('text' => 'unread_topics_all', 'image' => 'markreadall.gif', 'lang' => true, 'url' => $scripturl . '?action=unread;all' . $context['querystring_board_limits'], 'active' => true);
  559. if (empty($settings['use_tabs']) && !empty($mark_read))
  560. echo '
  561. <tr class="catbg">
  562. <td colspan="', $showCheckboxes ? '6' : '5', '" align="right">
  563. ', template_button_strip($mark_read, 'top'), '
  564. </td>
  565. </tr>';
  566. if (empty($context['topics']))
  567. echo '
  568. <tr style="display: none;"><td></td></tr>';
  569. echo '
  570. </tbody>
  571. </table>
  572. </div>
  573. <div class="pagesection" id="readbuttons">';
  574. if (!empty($settings['use_tabs']) && !empty($mark_read))
  575. template_button_strip($mark_read, 'right');
  576. echo '
  577. <span>', $txt['pages'], ': ', $context['page_index'], '</span>
  578. </div>';
  579. } else {
  580. echo '
  581. <div class="cat_bar">
  582. <h3 class="catbg centertext">
  583. ', $context['showing_all_topics'] ? $txt['msg_alert_none'] : $txt['unread_topics_visit_none'], '
  584. </h3>
  585. </div>';
  586. }
  587. if ($showCheckboxes)
  588. echo '
  589. </form>';
  590. echo '
  591. <div class="description " id="topic_icons">
  592. <p class="smalltext floatleft">
  593. ', !empty($modSettings['enableParticipation']) ? '
  594. <img src="' . $settings['images_url'] . '/topic/my_normal_post.gif" alt="" align="middle" /> ' . $txt['participation_caption'] . '<br />' : '', '
  595. <img src="', $settings['images_url'], '/topic/normal_post.gif" alt="" align="middle" /> ', $txt['normal_topic'], '<br />
  596. <img src="', $settings['images_url'], '/topic/hot_post.gif" alt="" align="middle" /> ', sprintf($txt['hot_topics'], $modSettings['hotTopicPosts']), '<br />
  597. <img src="', $settings['images_url'], '/topic/veryhot_post.gif" alt="" align="middle" /> ', sprintf($txt['very_hot_topics'], $modSettings['hotTopicVeryPosts']), '
  598. </p>
  599. <p class="smalltext para2">
  600. <img src="', $settings['images_url'], '/icons/quick_lock.gif" alt="" align="middle" /> ', $txt['locked_topic'], '<br />', ($modSettings['enableStickyTopics'] == '1' ? '
  601. <img src="' . $settings['images_url'] . '/icons/quick_sticky.gif" alt="" align="middle" /> ' . $txt['sticky_topic'] . '<br />' : ''), ($modSettings['pollMode'] == '1' ? '
  602. <img src="' . $settings['images_url'] . '/topic/normal_poll.gif" alt="" align="middle" /> ' . $txt['poll'] : ''), '
  603. </p>
  604. </div>
  605. </div>';
  606. }
  607. ]]></add>
  608. </operation>
  609. </file>
  610. </modification>