SHARE
TWEET

Untitled

a guest Sep 13th, 2019 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. /* Hooks */
  4.  
  5. $plugins->add_hook("index_end", "recentthread_list_threads");
  6. $plugins->add_hook("global_start", "recentthread_get_templates");
  7. $plugins->add_hook("global_intermediate", "recentthread_global_intermediate");
  8. $plugins->add_hook("xmlhttp", "recentthread_refresh_threads");
  9. $plugins->add_hook("admin_config_plugins_begin", "recentthread_update");
  10.  
  11. function recentthread_info()
  12. {
  13.     $donationlink = "https://www.paypal.me/MarkJanssen";
  14.     $updatelink = "index.php?module=config-plugins&action=update_recentthreads";
  15.     return array(
  16.         "name"      => "Recent Threads",
  17.         "description"       => "A plug-in that shows the most recent threads on the index. <a href='$updatelink'>Run Update Script</a><br /><a href='$donationlink'>Donate to support</a>",
  18.         "author"        => "Mark Janssen",
  19.         "version"       => "12.0",
  20.         "codename"          => "recentthreads",
  21.         "compatibility" => "18*"
  22.     );
  23. }
  24.  
  25. function recentthread_install()
  26. {
  27.     global $db, $mybb;
  28.  
  29.     if($mybb->version_code < 1801)
  30.     {
  31.         flash_message("Sorry, but this plugin requires you to update to 1.8.1 or higher.", "error");
  32.         admin_redirect("index.php?module=config-plugins");
  33.     }
  34.  
  35.     // Add some settings
  36.     $new_setting_group = array(
  37.         "name" => "recentthreads",
  38.         "title" => "Recent Threads Settings",
  39.         "description" => "Customize various aspects of recent threads",
  40.         "disporder" => 77,
  41.         "isdefault" => 0
  42.     );
  43.  
  44.     $gid = $db->insert_query("settinggroups", $new_setting_group);
  45.  
  46.     $new_setting[] = array(
  47.         "name" => "recentthread_threadcount",
  48.         "title" => "Number of Threads",
  49.         "description" => "How many threads are shown.",
  50.         "optionscode" => "numeric",
  51.         "disporder" => 1,
  52.         "value" => 15,
  53.         "gid" => $gid
  54.     );
  55.  
  56.     $new_setting[] = array(
  57.         "name" => "recentthread_threadavatar",
  58.         "title" => $db->escape_string("Show thread starter's avatar"),
  59.         "description" => $db->escape_string("If set to yes, the thread starter's avatar will be shown."),
  60.         "optionscode" => "yesno",
  61.         "disporder" => 2,
  62.         "value" => 0,
  63.         "gid" => $gid
  64.     );
  65.  
  66.     $new_setting[] = array(
  67.         "name" => "recentthread_lastavatar",
  68.         "title" => $db->escape_string("Show last poster's avatar"),
  69.         "description" => $db->escape_string("If set to yes, the last poster's avatar will be shown."),
  70.         "optionscode" => "yesno",
  71.         "disporder" => 3,
  72.         "value" => 0,
  73.         "gid" => $gid
  74.     );
  75.  
  76.     $new_setting[] = array(
  77.         "name" => "recentthread_forumskip",
  78.         "title" => "Forums To Ignore",
  79.         "description" => "The forums threads should not be pulled from.",
  80.         "optionscode" => "forumselect",
  81.         "disporder" => 4,
  82.         "value" => "",
  83.         "gid" => $gid
  84.     );
  85.  
  86.     $new_setting[] = array(
  87.         "name" => "recentthread_subject_length",
  88.         "title" => "Max Title Length",
  89.         "description" => "The amount of characters before the rest of the title is truncated. Enter 0 for no limit.",
  90.         "optionscode" => "numeric",
  91.         "disporder" => 5,
  92.         "value" => 0,
  93.         "gid" => $gid
  94.     );
  95.  
  96.     $new_setting[] = array(
  97.         "name" => "recentthread_subject_breaker",
  98.         "title" => "Word Breaking",
  99.         "description" => "If selected, the title will be kept to full words only in cut off.",
  100.         "optionscode" => "yesno",
  101.         "disporder" => 6,
  102.         "value" => 0,
  103.         "gid" => $gid
  104.     );
  105.  
  106.     $new_setting[] = array(
  107.         "name" => "recentthread_which_groups",
  108.         "title" => "Permissions",
  109.         "description" => "These groups cannot view the reccent threads on index.",
  110.         "optionscode" => "groupselect",
  111.         "disporder" => 7,
  112.         "value" => 7,
  113.         "gid" => $gid
  114.     );
  115.  
  116.     $new_setting[] = array(
  117.         "name" => "recentthread_prefix",
  118.         "title" => "Thread Prefix",
  119.         "description" => "If set to yes, thread prefixes will be shown.",
  120.         "optionscode" => "yesno",
  121.         "disporder" => 8,
  122.         "value" => 1,
  123.         "gid" => $gid
  124.     );
  125.  
  126.     $new_setting[] = array(
  127.         "name" => "recentthread_xthreads",
  128.         "title" => "XThreads",
  129.         "description" => "If set to yes, custom thread fields will be loaded.",
  130.         "optionscode" => "yesno",
  131.         "disporder" => 9,
  132.         "value" => 1,
  133.         "gid" => $gid
  134.     );
  135.  
  136.     $db->insert_query_multiple("settings", $new_setting);
  137.     rebuild_settings();
  138. }
  139.  
  140. function recentthread_is_installed()
  141. {
  142.     global $db;
  143.     $query = $db->simple_select("settinggroups", "*", "name='recentthreads'");
  144.     if($db->num_rows($query))
  145.     {
  146.         return TRUE;
  147.     }
  148.     return FALSE;
  149. }
  150.  
  151. function recentthread_activate()
  152. {
  153.     global $db;
  154.     $new_template['recentthread'] = '<div class="scroll">
  155. <div id="recentthreads">
  156. <table border="0" cellspacing="1" cellpadding="6" class="tborder" style="clear: both;max-height:300px">
  157. <thead>
  158.     <tr>
  159.     <td class="thead{$expthead}" colspan="4" style="text-align:left; font-size: 10pt;">
  160. <div><b><i class="fa fa-bell"></i> {$lang->recentthreads_recentthreads} </b></div>
  161. </td>
  162.     </tr>
  163. </thead>
  164. <tbody style="{$expdisplay}" id="cat_9999_e">
  165.     <tr>
  166.     <td class="tcat" colspan="3"><strong>{$lang->recentthreads_thread} / {$lang->recentthreads_author}</strong></td>
  167.     <td class="tcat"><strong>{$lang->recentthreads_forum}</strong></td>
  168.     <td class="tcat"><strong>{$lang->recentthreads_posts}</strong></td>
  169.     <td class="tcat"><strong>{$lang->recentthreads_last_post}</strong></td>
  170.     </tr>
  171.     {$recentthreads}
  172. </tbody>
  173.     </table>
  174. </div>
  175.     </div>';
  176.  
  177.     $new_template['recentthread_thread'] = '<tr>
  178.     <td class="{$trow}" width="2%">{$icon}</td>
  179.     <td class="{$trow}">{$recentprefix}<a href="{$mybb->settings[\'bburl\']}/showthread.php?tid={$thread[\'tid\']}">{$thread[\'subject\']}</a>&nbsp;{$arrow}&nbsp;{$thread[\'multipage\']}<br />{$thread[\'author\']}<br />{$posteravatar}</td>
  180.     <td class="{$trow}"><a href="{$mybb->settings[\'bburl\']}/forumdisplay.php?fid={$thread[\'fid\']}">{$thread[\'forum\']}</a></td>
  181.     <td class="{$trow}"><a href="javascript:MyBB.whoPosted({$thread[\'tid\']});">{$thread[\'replies\']}</a></td>
  182.     <td class="{$trow}">{$lastposttimeago}<br />
  183.     <a href="{$lastpostlink}">Last Post:</a> {$lastposterlink}<br />{$lastavatar}</td>
  184.     </tr>';
  185.  
  186.     $new_template['recentthread_avatar'] = '<img src="{$avatarurl}" {$dimensions} alt="{$avatarurl}" />';
  187.  
  188.     $new_template['recentthread_headerinclude'] = '<script type="text/javascript">
  189.   <!--
  190.     var refresher = window.setInterval(function () {refresh_recent_threads()}, 30000);
  191.     var stopper = window.setTimeout(function() { stop_recent_threads()}, 900000);
  192.     $(document).ready(function() { refresh_recent_threads(); });
  193.     function refresh_recent_threads()
  194.     {
  195.         var xmlhttp;
  196.         if(window.XMLHttpRequest)
  197.         {// code for IE7+, Firefox, Chrome, Opera, Safari
  198.              xmlhttp=new XMLHttpRequest();
  199.         }
  200.         else
  201.          {// code for IE6, IE5
  202.              xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  203.         }
  204.       xmlhttp.onreadystatechange=function()
  205.       {
  206.         if(xmlhttp.readyState==4 && xmlhttp.status==200)
  207.             {
  208.                  document.getElementById("recentthreads").innerHTML=xmlhttp.responseText;
  209.             }
  210.       }
  211.         xmlhttp.open("GET","xmlhttp.php?action=recent_threads",true);
  212.         xmlhttp.send();
  213.     }
  214.     function stop_recent_threads()
  215.     {
  216.             clearInterval(refresher);
  217.     }
  218.   // -->
  219.   </script>';
  220.  
  221.     foreach($new_template as $title => $template)
  222.     {
  223.         $new_template = array('title' => $db->escape_string($title), 'template' => $db->escape_string($template), 'sid' => '-1', 'version' => '1800', 'dateline' => TIME_NOW);
  224.         $db->insert_query('templates', $new_template);
  225.     }
  226.  
  227.     require_once MYBB_ROOT . "/inc/adminfunctions_templates.php";
  228.  
  229.     find_replace_templatesets('index', "#" . preg_quote('{$forums}') . "#i", '{$forums}<div id="recentthreads">{$recentthreadtable}</div>');
  230.     find_replace_templatesets('index', "#" . preg_quote('{$headerinclude}') . "#i", '{$headerinclude}{$recentthread_headerinclude}');
  231. }
  232.  
  233. function recentthread_deactivate()
  234. {
  235.     global $db;
  236.     $db->delete_query("templates", "title IN('recentthread','recentthread_thread','recentthread_avatar','recentthread_headerinclude')");
  237.  
  238.     require_once MYBB_ROOT . "/inc/adminfunctions_templates.php";
  239.  
  240.     find_replace_templatesets('index', "#" . preg_quote('{$recentthread_headerinclude}') . "#i", '');
  241.     find_replace_templatesets('index', "#" . preg_quote('<div id="recentthreads">{$recentthreadtable}</div>') . "#i", '');
  242. }
  243.  
  244. function recentthread_uninstall()
  245. {
  246.     global $db;
  247.     $query = $db->simple_select("settinggroups", "gid", "name='recentthreads'");
  248.     $gid = $db->fetch_field($query, "gid");
  249.     if(!$gid)
  250.     {
  251.         return;
  252.     }
  253.     $db->delete_query("settinggroups", "name='recentthreads'");
  254.     $db->delete_query("settings", "gid=$gid");
  255.     rebuild_settings();
  256. }
  257.  
  258. function recentthread_update()
  259. {
  260.     global $mybb, $db;
  261.     if($mybb->input['action'] != "update_recentthreads")
  262.     {
  263.         return;
  264.     }
  265.     if(array_key_exists("recentthread_xthreads", $mybb->settings))
  266.     {
  267.         flash_message("You have the most current version of Recent Threads On Index.");
  268.         admin_redirect("index.php?module=config-plugins");
  269.     }
  270.     else
  271.     {
  272.         $query = $db->simple_select("settinggroups", "*", "name='recentthreads'");
  273.         $gid = $db->fetch_field($query, "gid");
  274.         $new_setting = array(
  275.             "name" => "recentthread_xthreads",
  276.             "title" => "XThreads",
  277.             "description" => "If set to yes, custom thread fields will be loaded.",
  278.             "optionscode" => "yesno",
  279.             "disporder" => 9,
  280.             "value" => 1,
  281.             "gid" => $gid
  282.         );
  283.         $db->insert_query("settings" ,$new_setting);
  284.         rebuild_settings();
  285.         $plugin_info = recentthread_info();
  286.         flash_message("Recent Threads On Index has now been updated to version " . $plugin_info['version'] . ".", "success");
  287.         admin_redirect("index.php?module=config-plugins");
  288.     }
  289. }
  290.  
  291. function recentthread_list_threads($return=false)
  292. {
  293.     global $mybb, $db, $templates, $recentthreadtable, $recentthreads, $settings, $canviewrecentthreads, $cache, $theme, $lang, $threadfields, $xthreadfields;
  294.     // First check permissions
  295.     if(!recentthread_can_view())
  296.     {
  297.         return;
  298.     }
  299.     $lang->load("recentthreads");
  300.     $lang->load("forumdisplay");
  301.     $icons = $cache->read("posticons");
  302.     require_once MYBB_ROOT."inc/functions_search.php";
  303.     $threadlimit = (int) $mybb->settings['recentthread_threadcount'];
  304.     if(!$threadlimit) // Provide a fallback
  305.     {
  306.         $threadlimit = 15;
  307.     }
  308.     $onlyusfids = array();
  309.     $onlycanview = array();
  310.     // Check group permissions if we can't view threads not started by us
  311.     $group_permissions = forum_permissions();
  312.     foreach($group_permissions as $fid => $forum_permissions)
  313.     {
  314.         if($forum_permissions['canonlyviewownthreads'] == 1)
  315.         {
  316.             $onlyusfids[] = $fid;
  317.         }
  318.         if ($forum_permissions['canview'] == 0)
  319.         {
  320.             $onlycanview[] = $fid;
  321.         }
  322.     }
  323.     if(!empty($onlyusfids))
  324.     {
  325.         $where .= "AND ((t.fid IN(".implode(',', $onlyusfids).") AND t.uid='{$mybb->user['uid']}') OR t.fid NOT IN(".implode(',', $onlyusfids)."))";
  326.     }
  327.     if (!empty($onlycanview))
  328.     {
  329.         $where .= "AND (t.fid NOT IN(".implode(',', $onlycanview)."))";
  330.     }
  331.     $approved = 0;
  332.  
  333.     // Moderators can view unapproved threads
  334.     if($mybb->usergroup['canmodcp']==1) {
  335.         $approved = -1;
  336.     }
  337.     $unsearchableforums = get_unsearchable_forums();
  338.     $unviewableforums = get_unviewable_forums();
  339.     if($unsearchableforums && $unviewableforums)
  340.     {
  341.         $forumarray = explode(",", $unsearchableforums . "," . $unviewableforums);
  342.         $newarray = array_unique($forumarray);
  343.         $unsearchableforumssql = " AND t.fid NOT IN(" . implode(",", $newarray) . ") ";
  344.     }
  345.     // Take into account any ignored forums
  346.     if($mybb->settings['recentthread_forumskip'])
  347.     {
  348.         $ignoreforums = " AND t.fid NOT IN(" . $mybb->settings['recentthread_forumskip'] . ") ";
  349.     }
  350.     $forums = $cache->read("forums");
  351.     $prefixes = $cache->read("threadprefixes");
  352.  
  353.     // Take XThreads into account
  354.     if(function_exists("xthreads_get_threadfields") && $mybb->settings['recentthread_xthreads'] == 1)
  355.     {
  356.         $quickquery = $db->query("SELECT t.tid as threadid, t.username, t.fid, tf.*
  357.                                     FROM " . TABLE_PREFIX . "threads t
  358.                                     LEFT JOIN " . TABLE_PREFIX . "threadfields_data tf ON(t.tid=tf.tid)
  359.                                     WHERE 1=1 $where AND t.visible > $approved $unsearchableforumssql $ignoreforums
  360.                                     ORDER BY t.lastpost DESC
  361.                                     LIMIT $threadlimit");
  362.  
  363.         while ($threadfields = $db->fetch_array($quickquery))
  364.         {
  365.             $threadfields_raw[$xthreadsfields['threadid']] = $xthreadsfields;
  366.             if ($threadfields['fid'] == $GLOBALS['fid'])
  367.             {
  368.                 // use global cache if we're referring to current forum
  369.                 $threadfield_cache =& $GLOBALS['threadfield_cache'];
  370.             }
  371.             if (!isset($threadfield_cache))
  372.             {
  373.                 $threadfield_cache = xthreads_gettfcache((int)$threadfields['fid']);
  374.             }
  375.             if (!empty($threadfield_cache))
  376.             {
  377.                 if (!isset($threadfields))
  378.                 {
  379.                     $threadfields = array();
  380.                 }
  381.                 foreach ($threadfield_cache as $k => &$v)
  382.                 {
  383.                     xthreads_get_xta_cache($v, $threadfields['threadid']);
  384.                     xthreads_sanitize_disp($threadfields[$k], $v, $threadfields['username'], true);
  385.                 }
  386.                 $threadfields_formatted[$threadfields['threadid']] = $threadfields;
  387.             }
  388.         }
  389.     }
  390.  
  391.     $query = $db->query("
  392.             SELECT t.*, u.username AS userusername, u.usergroup, u.displaygroup, u.avatar as threadavatar, u.avatardimensions as threaddimensions, lp.usergroup AS lastusergroup, lp.avatar as lastavatar, lp.avatardimensions as lastdimensions, lp.displaygroup as lastdisplaygroup
  393.             FROM " . TABLE_PREFIX . "threads t
  394.             LEFT JOIN " . TABLE_PREFIX . "users u ON (u.uid=t.uid)
  395.             LEFT JOIN " . TABLE_PREFIX . "users lp ON (t.lastposteruid=lp.uid)
  396.             WHERE 1=1 $where AND t.visible > {$approved} {$unsearchableforumssql} {$ignoreforums}
  397.             ORDER BY t.lastpost DESC
  398.             LIMIT $threadlimit");
  399.  
  400.     while($thread = $db->fetch_array($query))
  401.     {
  402.         $tid = $thread['tid'];
  403.         $trow = alt_trow();
  404.         $thread['forum'] = $forums[$thread['fid']]['name'];
  405.         if($mybb->settings['recentthread_prefix'])
  406.         {
  407.             $recentprefix = $prefixes[$thread['prefix']]['displaystyle'];
  408.         }
  409.         if($thread['icon'])
  410.         {
  411.             $icon = "<img src='" . $icons[$thread['icon']]['path'] . "' alt='" . $icons[$thread['icon']]['name'] . "' />";
  412.         }
  413.         $threadlink = $thread['newpostlink'] = get_thread_link($tid, "", "newpost"); // Maintain for template compatibility
  414.         eval("\$arrow =\"".$templates->get("forumdisplay_thread_gotounread")."\";");
  415.         $lastpostlink = get_thread_link($tid, "", "lastpost");
  416.         $lastpostdate = my_date($mybb->settings['dateformat'], $thread['lastpost']);
  417.         $lastposttime = my_date($mybb->settings['timeformat'], $thread['lastpost']);
  418.         $lastposttimeago = my_date("relative", $thread['lastpost']);
  419.         $lastposter = $thread['lastposter'];
  420.         $lastposteruid = $thread['lastposteruid'];
  421.         $thread['author'] = build_profile_link(format_name($thread['userusername'], $thread['usergroup'], $thread['displaygroup']), $thread['uid']);
  422.         // Don't link to guest's profiles (they have no profile).
  423.         if($lastposteruid == 0)
  424.         {
  425.             $lastposterlink = $lastposter;
  426.         }
  427.         else
  428.         {
  429.             $lastposterlink = build_profile_link(format_name($lastposter, $thread['lastusergroup'], $thread['lastdisplaygroup']), $lastposteruid);
  430.         }
  431.         if($mybb->settings['recentthread_threadavatar'])
  432.         {
  433.             $threadavatar = format_avatar($thread['threadavatar'], $thread['threaddimensions']);
  434.             $avatarurl = $threadavatar['image'];
  435.             $dimensions = $threadavatar['width_height'];
  436.             eval("\$posteravatar = \"".$templates->get("recentthread_avatar")."\";");
  437.         }
  438.         if($mybb->settings['recentthread_lastavatar'])
  439.         {
  440.             $lastposteravatar = format_avatar($thread['lastavatar'], $thread['lastdimensions']);
  441.             $avatarurl = $lastposteravatar['image'];
  442.             $dimensions = $lastposteravatar['width_height'];
  443.             eval("\$lastavatar = \"".$templates->get("recentthread_avatar")."\";");
  444.         }
  445.         // Now check the length of subjects
  446.         $length = (int) $mybb->settings['recentthread_subject_length'];
  447.         if(strlen($thread['subject']) > $length && $length != 0)
  448.         {
  449.             // Figure out if we need to split it up.
  450.             $title = my_substr($thread['subject'], 0, $length);
  451.             if($mybb->settings['recentthread_subject_breaker'])
  452.             {
  453.                 $words = explode(" ", $title);
  454.                 $count = count($words) -1;
  455.                 $currenttitle = "";
  456.                 for($x = 0; $x < $count; $x++)
  457.                 {
  458.                     $currenttitle .= $words[$x] . " ";
  459.                 }
  460.                 $thread['subject'] = $currenttitle . " ...";
  461.             }
  462.             if(!$mybb->settings['recentthread_subject_breaker'])
  463.             {
  464.                 $thread['subject'] = $title . "...";
  465.             }
  466.         }
  467.         $thread['subject'] = htmlspecialchars_uni($thread['subject']);
  468.         // Moderator stuff baby!
  469.         if(is_moderator($thread['fid']))
  470.         {
  471.             $ismod = TRUE;
  472.             // fetch the inline mod column
  473.         }
  474.         else
  475.         {
  476.             $ismod = FALSE;
  477.         }
  478.         if(is_moderator($thread['fid'], "caneditposts") || $fpermissions['caneditposts'] == 1)
  479.         {
  480.             $can_edit_titles = 1;
  481.         }
  482.         else
  483.         {
  484.             $can_edit_titles = 0;
  485.         }
  486.         $inline_edit_class = '';
  487.         if(($thread['uid'] == $mybb->user['uid'] && $thread['closed'] != 1 && $mybb->user['uid'] != 0 && $can_edit_titles == 1) || $ismod == true)
  488.         {
  489.             $inline_edit_class = "subject_editable";
  490.         }
  491.  
  492.         // Multipage.  Code from forumdisplay.php
  493.         $thread['posts'] = $thread['replies'] +1;
  494.         if($thread['unapprovedposts'] > 0 && $ismod)
  495.         {
  496.             $thread['posts'] += $thread['unapprovedposts'] + $thread['deletedposts'];
  497.         }
  498.         if($thread['posts'] > $mybb->settings['postsperpage'])
  499.         {
  500.             $thread['pages'] = $thread['posts'] / $mybb->settings['postsperpage'];
  501.             $thread['pages'] = ceil($thread['pages']);
  502.             if($thread['pages'] > $mybb->settings['maxmultipagelinks'])
  503.             {
  504.                 $pagesstop = $mybb->settings['maxmultipagelinks'] - 1;
  505.                 $page_link = get_thread_link($thread['tid'], $thread['pages']);
  506.                 eval("\$morelink = \"".$templates->get("forumdisplay_thread_multipage_more")."\";");
  507.             }
  508.             else
  509.             {
  510.                 $pagesstop = $thread['pages'];
  511.             }
  512.             for($i = 1; $i <= $pagesstop; ++$i)
  513.             {
  514.                 $page_link = get_thread_link($thread['tid'], $i);
  515.                 eval("\$threadpages .= \"".$templates->get("forumdisplay_thread_multipage_page")."\";");
  516.             }
  517.             eval("\$thread['multipage'] = \"".$templates->get("forumdisplay_thread_multipage")."\";");
  518.         }
  519.         else
  520.         {
  521.             $threadpages = '';
  522.             $morelink = '';
  523.             $thread['multipage'] = '';
  524.         }
  525.         eval("\$recentthreads .= \"".$templates->get("recentthread_thread")."\";");
  526.         unset($posteravatar);
  527.         unset($lastavatar);
  528.         unset($icon);
  529.     }
  530.     eval("\$recentthreadtable = \"".$templates->get("recentthread")."\";");
  531.     if($return)
  532.     {
  533.         return $recentthreadtable;
  534.     }
  535. }
  536.  
  537. function recentthread_get_templates()
  538. {
  539.     global $templatelist;
  540.     if(THIS_SCRIPT == "index.php")
  541.     {
  542.         $templatelist .= ",recentthread,recentthread_thread,recentthread_avatar,recentthread_headerinclude,forumdisplay_thread_gotounread";
  543.         $templatelist .= ",forumdisplay_thread_multipage,forumdisplay_thread_multipage_page,forumdisplay_thread_multipage_more";
  544.     }
  545. }
  546.  
  547. function recentthread_global_intermediate()
  548. {
  549.     global $templates, $recentthread_headerinclude;
  550.     if(THIS_SCRIPT == "index.php" && recentthread_can_view())
  551.     {
  552.         eval("\$recentthread_headerinclude = \"".$templates->get("recentthread_headerinclude")."\";");
  553.     }
  554. }
  555.  
  556. function recentthread_refresh_threads()
  557. {
  558.     global $db, $mybb, $canviewrecentthreads;
  559.     if($mybb->input['action'] == "recent_threads")
  560.     {
  561.         require_once MYBB_ROOT . "/inc/plugins/recentthread.php";
  562.         if(recentthread_can_view())
  563.         {
  564.             echo(recentthread_list_threads(true));
  565.         }
  566.         die;
  567.     }
  568. }
  569.  
  570. function recentthread_can_view()
  571. {
  572.     global $mybb;
  573.     if($mybb->settings['recentthread_which_groups'])
  574.     {
  575.         $disallowedgroups = explode(",", $mybb->settings['recentthread_which_groups']);
  576.         $mygroups = $mybb->user['usergroup'];
  577.         if($mybb->user['additionalgroups'])
  578.         {
  579.             $mygroups .= "," . $mybb->user['additionalgroups'];
  580.         }
  581.         $groups = explode(",", $mygroups);
  582.         foreach($groups as $group)
  583.         {
  584.             if(in_array($group, $disallowedgroups))
  585.             {
  586.                 return FALSE;
  587.             }
  588.         }
  589.         return TRUE;
  590.     }
  591.     else
  592.     {
  593.         return TRUE;
  594.     }
  595. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top