MyBB Community Forums

Full Version: Sidebar usernamestyle
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I was able to put to authors codes together to make one unique Side bar with UserStyleNames. Those who where looking for one here it is. For MyBB 1.8*


<?php

//Recent Threads Sidebar Mod by Borbole

//Trying to access directly the file, are we :D

if(!defined("IN_MYBB"))
{
    die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
}

//Hooking into index_start with our function

$plugins->add_hook("index_end", "sidebarthreads");

//Show some info about our mod
function sidebarthreads_info()
{
 return array(
 "name" => "Recent Threads Sidebar",
 "description" => "It shows the recent posts on the sidebar.",
 "website" => "http://www.forumservices.eu/mybb",
 "version" => "1.0",
 "author" => "borbole",
 "authorsite" => "http://www.forumservices.eu/mybb",
 "compatibility"  => "18*",
 'guid'        => '99c9a5bd8f5ae93cfe6d5fad258df89d'
 );
}

//Activate it
function sidebarthreads_activate()
{
 global $db; $lang;

 //Insert the mod settings in the portal settinggroup
 $lang->load("latestposts");
 $query = $db->simple_select("settinggroups", "gid", "name='portal'");
 $gid = $db->fetch_field($query, "gid");

 $setting = array(
 'name' => 'sidebar_enable',
 'title' => 'Lates Threads Sidebar',
 'description' => 'Do you wish to show the Lates Threads in the sidebar as well?',
 'optionscode' => 'yesno',
 'value' => '1',
 'disporder' => '90',
 'gid' => intval($gid)
 );
 $db->insert_query('settings',$setting);

    $setting = array(
        "sid" => "NULL",
        "name" => "sidebar_position",
        "title" => "Position",
        "description" => "On which side do you wish to show the Lates Threads in the sidebar?",
        "optionscode" => "select
         1= Right Side
         2= Left Side",
        "value" => "2",
        "disporder" => "91",
        "gid" => intval($gid),
        );
    $db->insert_query("settings", $setting);


 $template = array(
 "tid" => NULL,
 "title" => 'thread_sidebar',
 "template" => '{$showrecentthreads}',
 "sid" => "-1",
 "version" => "1.0",
 "dateline" => time(),
 );

 $db->insert_query("templates", $template);

    rebuild_settings();
}

//Don't want to use it anymore? Let 's deactivate it then and drop the settings and the custom var as well
function sidebarthreads_deactivate()
{
 global $db, $mybb;

 $db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name='sidebar_enable'"); 
    $db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name='sidebar_position'");
 
 $db->delete_query("templates","title = 'thread_sidebar'");

    rebuild_settings();
}


//Insert our function 
function sidebarthreads()
{
   global $db, $mybb, $forums, $templates;

   //Get the recent threads settings from the portal
   if($mybb->settings['portal_showdiscussions'] != 0 && $mybb->settings['portal_showdiscussionsnum'])
   {
       $showrecentthreads = showrecentthreads();
   }
    //Show the recent threads on the sidebar on board index
   if($mybb->settings['sidebar_enable'] == 1)
   {
      
  //Get the template
  eval("\$sidebarposition = \"".$templates->get("thread_sidebar")."\";");

  //Display it on the right side
  if ($mybb->settings['sidebar_position'] == "2") 
  {
          $forums ='<table border="0" width="100%">
          <tr>
              <td width="200" valign="top">'. $sidebarposition. '</td>
              <td valign="top">'. $forums. '</td>
         </tr>
         </table>';
  }
  
   //Display it on the left side
 if ($mybb->settings['sidebar_position'] == "1") 
 {
        $forums ='<table border="0" width="100%">
        <tr>
            <td valign="top">'. $forums. '</td>
            <td width="200" valign="top">'. $sidebarposition. '</td>
        </tr>
       </table>';
 }
  }
}


//Get the recent threads from the portal to show them on the sidebar in forum index
function showrecentthreads()
{
    global $db, $mybb, $templates, $latestthreads, $lang, $theme, $forum_cache;
 
 // Load global language phrases
    $lang->load("portal");

 // Latest forum discussions
 $altbg = alt_trow();
 $threadlist = '';
 $query = $db->query("
 SELECT t.*, u.username AS userusername, u.usergroup, u.displaygroup, lp.usergroup AS lastusergroup, lp.displaygroup as lastdisplaygroup
 FROM ".TABLE_PREFIX."threads t
 LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=t.uid)
 LEFT JOIN ".TABLE_PREFIX."users lp ON (t.lastposteruid=lp.uid)
 WHERE 1=1 $unviewwhere AND t.visible='1' AND t.closed NOT LIKE 'moved|%'
 ORDER BY t.lastpost DESC 
 LIMIT 0, ".$mybb->settings['portal_showdiscussionsnum']
 );
 while($thread = $db->fetch_array($query))
 {
 $tid = $thread['tid'];
        $postname = $thread['subject'];
        $lastpostlink = get_thread_link($thread['tid'], "", "lastpost");
 $lastposttimeago = my_date("relative", $thread['lastpost']);
 $lastposter = $thread['lastposter'];
 $lastposteruid = $thread['lastposteruid'];
 $permissions = forum_permissions($thread['fid']);
 $forumpermissions[$thread['fid']] = forum_permissions($thread['fid']);

 // Make sure we can view this thread
 if($forumpermissions[$thread['fid']]['canview'] == 0 || $forumpermissions[$thread['fid']]['canviewthreads'] == 0 || $forumpermissions[$thread['fid']]['canonlyviewownthreads'] == 1 && $thread['uid'] != $mybb->user['uid'])
 {
 continue;
 }

 $lastpostdate = my_date($mybb->settings['dateformat'], $thread['lastpost']);
 $lastposttime = my_date($mybb->settings['timeformat'], $thread['lastpost']);
 // Don't link to guest's profiles (they have no profile).
 if($thread['lastposteruid'] == 0)
 {
 $lastposterlink = $thread['lastposter'];
 }
 else
 {
 $lastposterlink = build_profile_link(format_name($lastposter, $thread['lastusergroup'], $thread['lastdisplaygroup']), $lastposteruid);
 }
 if(my_strlen($thread['subject']) > 25)
 {
 $thread['subject'] = my_substr($thread['subject'], 0, 25) . "...";
 }
 $thread['subject'] = htmlspecialchars_uni($thread['subject']);
 $thread['threadlink'] = get_thread_link($thread['tid']);
 $thread['lastpostlink'] = get_thread_link($thread['tid'], 0, "lastpost");
 eval("\$threadlist .= \"".$templates->get("portal_latestthreads_thread")."\";");
 $altbg = alt_trow();
 }
 if($threadlist)
 { 
 // Show the table only if there are threads
 eval("\$latestthreads = \"".$templates->get("portal_latestthreads")."\";");
 }

 return $latestthreads;
}

?>
Just name it sidebarthreads.php copy and paste into /inc/plugins folder.

Special Thanks to borbole and DanielM plugins I was able to make them into one
[attachment=33887]
Hi

Dont work.

I can see last date but ı cant last time.