Skip to content
This repository has been archived by the owner on Feb 5, 2019. It is now read-only.

Commit

Permalink
Version 1.1.0
Browse files Browse the repository at this point in the history
- Add styles in PM lists
- Add styles in portal view
  • Loading branch information
lukasamd committed Sep 17, 2015
1 parent 85ce8b9 commit e65e44c
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 6 deletions.
11 changes: 10 additions & 1 deletion README.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,11 @@
This plugin colorize usernames according to the groups settings.
It's very similar to "Username Styles" plugin, but it's faster and compatible for MyBB 1.6.
It can format nicknames in:

* moderators list
* topic author in forum view
* last post author in forum view
* sender in private messages list
* news author in portal view
* topic author in search results
* last posts author in search results
* announcements author
41 changes: 36 additions & 5 deletions root/inc/plugins/styleUsernames.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ function styleUsernames_info()
'description' => $lang->styleUsernamesDesc,
'website' => 'http://lukasztkacz.com',
'author' => 'Lukasz "LukasAMD" Tkacz',
'authorsite' => 'http://lukasztkacz.com',
'version' => '1.0.0',
'authorsite' => 'https://lukasztkacz.com',
'version' => '1.1.0',
'guid' => '',
'compatibility' => '18*',
'codename' => 'style_usernames'
Expand All @@ -80,15 +80,18 @@ public function __construct()
{
global $plugins;

$plugins->hooks["global_end"][10]["styleUsernames_getModerators"] = array("function" => create_function('', 'global $plugins; $plugins->objects[\'styleUsernames\']->getModerators();'));
$plugins->hooks["pre_output_page"][10]["styleUsernames_parseUsernames"] = array("function" => create_function('&$arg', 'global $plugins; $plugins->objects[\'styleUsernames\']->parseUsernames($arg);'));
$plugins->hooks["global_end"][10]["styleUsernames_getModerators"] = array("function" => create_function('', 'global $plugins; $plugins->objects[\'styleUsernames\']->getModerators();'));
$plugins->hooks["build_forumbits_forum"][10]["styleUsernames_buildForumbits"] = array("function" => create_function('&$arg', 'global $plugins; $plugins->objects[\'styleUsernames\']->buildForumbits($arg);'));
$plugins->hooks["forumdisplay_announcement"][10]["styleUsernames_forumdisplayAnnouncement"] = array("function" => create_function('', 'global $plugins; $plugins->objects[\'styleUsernames\']->forumdisplayAnnouncement();'));
$plugins->hooks["forumdisplay_thread"][10]["styleUsernames_forumdisplayThread"] = array("function" => create_function('', 'global $plugins; $plugins->objects[\'styleUsernames\']->forumdisplayThread();'));
$plugins->hooks["search_results_thread"][10]["styleUsernames_searchThread"] = array("function" => create_function('', 'global $plugins; $plugins->objects[\'styleUsernames\']->searchThread();'));
$plugins->hooks["search_results_post"][10]["styleUsernames_searchPost"] = array("function" => create_function('', 'global $plugins; $plugins->objects[\'styleUsernames\']->searchPost();'));
$plugins->hooks["private_message"][10]["styleUsernames_privateMessage"] = array("function" => create_function('', 'global $plugins; $plugins->objects[\'styleUsernames\']->privateMessage();'));
$plugins->hooks["portal_announcement"][10]["styleUsernames_portalAnnouncement"] = array("function" => create_function('', 'global $plugins; $plugins->objects[\'styleUsernames\']->portalAnnouncement();'));
$plugins->hooks["pre_output_page"][10]["styleUsernames_pluginThanks"] = array("function" => create_function('&$arg', 'global $plugins; $plugins->objects[\'styleUsernames\']->pluginThanks($arg);'));
}


/**
* Change moderators usernames to Style Usernames code and get their ids.
Expand Down Expand Up @@ -133,7 +136,7 @@ public function getModerators()
public function parseUsernames(&$content)
{
global $db, $cache;

// Parse users
$this->cache['users'] = array_unique($this->cache['users']);
$this->cache['guests'] = array_unique($this->cache['guests']);
Expand Down Expand Up @@ -321,6 +324,34 @@ public function searchPost()
}
}

/**
* Style usernames on PM lists
*/
public function privateMessage()
{
global $tofromusername, $tofromuid;

if ($tofromuid != 0)
{
$this->cache['users'][$tofromuid] = $tofromusername;
$tofromusername = "#STYLE_USERNAMES_UID{$tofromuid}#";
}
}

/**
* Style usernames on portal announcements
*/
public function portalAnnouncement()
{
global $profilelink, $announcement;

if ($announcement['uid'])
{
$this->cache['users'][$announcement['uid']] = $announcement['username'];
$profilelink = "#STYLE_USERNAMES_UID{$announcement['uid']}#";
}
}

/**
* Say thanks to plugin author - paste link to author website.
* Please don't remove this code if you didn't make donate
Expand All @@ -332,7 +363,7 @@ public function pluginThanks(&$content)

if (!isset($lukasamd_thanks) && $session->is_spider)
{
$thx = '<div style="margin:auto; text-align:center;">This forum uses <a href="http://lukasztkacz.com">Lukasz Tkacz</a> MyBB addons.</div></body>';
$thx = '<div style="margin:auto; text-align:center;">This forum uses <a href="https://lukasztkacz.com">Lukasz Tkacz</a> MyBB addons.</div></body>';
$content = str_replace('</body>', $thx, $content);
$lukasamd_thanks = true;
}
Expand Down

0 comments on commit e65e44c

Please sign in to comment.