modification.xml 32 KB

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