Please make sure IN_MYBB is defined."); } global $mybb, $lang; $plugins->add_hook("showthread_threaded", "Regentronique_ViewThreadReaders_Show"); $plugins->add_hook("showthread_linear", "Regentronique_ViewThreadReaders_Show"); function Regentronique_ViewThreadReaders_info() { /** * Array of information about the plugin. * name: The name of the plugin * description: Description of what the plugin does * website: The website the plugin is maintained at (Optional) * author: The name of the author of the plugin * authorsite: The URL to the website of the author (Optional) * version: The version number of the plugin * guid: Unique ID issued by the MyBB Mods site for version checking * compatibility: A CSV list of MyBB versions supported. Ex, "121,123", "12*". Wildcards supported. */ return array( "name" => "Regentronique View Thread Readers!", "description" => "This plugin will allow you to View Thread Readers at the bottom of each thread.", "website" => "http://MyBBCodes.com", "author" => "Exdiogene", "authorsite" => "http://Regentronique.com", "version" => "1.3", 'guid' => '', "compatibility" => "*" ); } function Regentronique_ViewThreadReaders_install(){ global $db; $regentronique_group = array( 'gid' => 'NULL', 'name' => 'Regentronique_ViewThreadReaders', 'title' => 'Regentronique ViewThreadReaders Settings', 'description' => 'Settings for the Regentronique ViewThreadReaders plugin', 'disporder' => '1', 'isdefault' => 'no', ); $db->insert_query('settinggroups', $regentronique_group); $gid = $db->insert_id(); $regentronique_setting = array( 'sid' => 'NULL', 'name' => 'Regentronique_ViewThreadReaders_Text', 'title' => 'View Thread Readers Text', 'description' => 'Text used for the View Thread Readers bar.(You can include {MemberNumber} and {DayNumber})', 'optionscode' => 'text', 'value' => '{MemberNumber} members viewed this thread in the last {DayNumber} days :', 'disporder' => 1, 'gid' => intval($gid), ); $db->insert_query('settings', $regentronique_setting); $regentronique_setting = array( 'sid' => 'NULL', 'name' => 'Regentronique_ViewThreadReaders_TextColor', 'title' => 'View Thread Readers Text Color', 'description' => 'Text Color used for the View Thread Readers bar.', 'optionscode' => 'text', 'value' => '#906000', 'disporder' => 2, 'gid' => intval($gid), ); $db->insert_query('settings', $regentronique_setting); $regentronique_setting = array( 'sid' => 'NULL', 'name' => 'Regentronique_ViewThreadReaders_EnableGroupStyle', 'title' => 'Enable Group Style Display for users', 'description' => 'If this is enabled, then the users name will be formated with its group style.', 'optionscode' => 'yesno', 'value' => '1', 'disporder' => 3, 'gid' => intval($gid), ); $db->insert_query('settings', $regentronique_setting); $regentronique_setting = array( 'sid' => 'NULL', 'name' => 'Regentronique_ViewThreadReaders_EnableBanned', 'title' => 'Enable Display of Banned users', 'description' => 'If this is enabled, then the banned users will be displayed.', 'optionscode' => 'yesno', 'value' => '1', 'disporder' => 4, 'gid' => intval($gid), ); $db->insert_query('settings', $regentronique_setting); $regentronique_setting = array( 'sid' => 'NULL', 'name' => 'Regentronique_ViewThreadReaders_UserCount', 'title' => 'Number of User in the ViewThreadReaders', 'description' => 'The maximum number of users that will be displayed.', 'optionscode' => 'text', 'value' => '50', 'disporder' => 5, 'gid' => intval($gid), ); $db->insert_query('settings', $regentronique_setting); $regentronique_setting = array( 'sid' => 'NULL', 'name' => 'Regentronique_ViewThreadReaders_ExcludedGroups', 'title' => 'Groups excluded from viewing ViewThreadReaders', 'description' => 'The users groups, separated by commas, excluded from having ViewThreadReaders displayed.(Leave blank for all to see.)', 'optionscode' => 'text', 'value' => '0,1,2,5,7', 'disporder' => 6, 'gid' => intval($gid), ); $db->insert_query('settings', $regentronique_setting); rebuildsettings(); } function Regentronique_ViewThreadReaders_is_installed() { global $db, $mybb; $query = $db->simple_select("settinggroups", "name", "name='Regentronique_ViewThreadReaders'"); $num = $db->num_rows($query); if($num != "0"){ return true; }else{ return false; } } function Regentronique_ViewThreadReaders_uninstall() { global $mybb, $db; $db->query("DELETE FROM ".TABLE_PREFIX."settinggroups WHERE name='Regentronique_ViewThreadReaders'"); $db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name IN( 'Regentronique_ViewThreadReaders_TextColor', 'Regentronique_ViewThreadReaders_EnableBanned', 'Regentronique_ViewThreadReaders_EnableGroupStyle', 'Regentronique_ViewThreadReaders_UserCount', 'Regentronique_ViewThreadReaders_ExcludedGroups' )"); } function Regentronique_ViewThreadReaders_Show(){ global $mybb, $db, $tid, $posts, $showthread, $thread; if ( $mybb->settings['Regentronique_ViewThreadReaders_ExcludedGroups'] ){ $ExcludedGroups = explode(',', $mybb->settings['Regentronique_ViewThreadReaders_ExcludedGroups']); }else{ $ExcludedGroups = Array(); } if (!in_array($mybb->user['usergroup'], $ExcludedGroups)){ if ( $mybb->settings['Regentronique_ViewThreadReaders_EnableBanned'] != '1'){ $Banned = 'AND u.usergroup <> 7'; }else{ $Banned = ''; } $query1 = $db->query(" SELECT t.uid, t.dateline , u.username , u.usergroup FROM ".TABLE_PREFIX."threadsread t LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid = t.uid) WHERE t.tid='$tid' $Banned ORDER BY dateline DESC "); $rows = $db->num_rows($query1); $MyList = ''; $x = 0; if ($rows < $mybb->settings['Regentronique_ViewThreadReaders_UserCount']){ $xMax = $rows; }else{ $xMax = $mybb->settings['Regentronique_ViewThreadReaders_UserCount']; } while (($TUser = $db->fetch_array($query1)) && ($x < $mybb->settings['Regentronique_ViewThreadReaders_UserCount'])){ if ($mybb->settings['Regentronique_ViewThreadReaders_EnableGroupStyle'] != '0'){ $UserText = format_name($TUser['username'],$TUser['usergroup']); }else{ $UserText = $TUser['username']; } if (!$UserText){ $UserText = '(deleted)'; } /* if ( $mybb->settings['Regentronique_ViewThreadReaders_EnableBanned'] != '1'){ if ($TUser['usergroup'] == '7'){ if ($rows < $mybb->settings['Regentronique_ViewThreadReaders_UserCount']){ $xMax = $xMax - 1; } continue; } } */ $x++; if (($rows > 1) && ($x < $xMax)){ $MyList = ', '.$UserText.'' . $MyList; }else{ $MyList = ''.$UserText.'' . $MyList; } } if (substr($MyList,0,2) == ', '){ $MyList = substr($MyList,2); } $Days = Floor((time() - $thread['dateline']) / 86400); if ($Days > $mybb->settings['threadreadcut']){ $Days = $mybb->settings['threadreadcut']; } $text = str_replace(array('{MemberNumber}','{DayNumber}'),array($rows,$Days),$mybb->settings['Regentronique_ViewThreadReaders_Text']); $posts .= '
'.$text.'
'.$MyList.'
'; } } ?>