News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

Show Multiple Badges (AKA Stars)

Started by Thantos, April 04, 2005, 10:03:46 PM

Previous topic - Next topic

quasar

Yes, that's right.  Make sure you back up the files before you do so, so that you can always remove them.  A comparison program is good, helps to check for any changes (if you have files before the install to compare them to).

perplexed

Thantos, I have a question

Ive been using this since last year and have been using it on 1.1 RC2 with no probs at all

the space on the posts is approx 80 pixels wide where the badges go.  so if you have a few badges then currently they are displayed on top of each other thus:

BADGE 1
BADGE 2
BADGE 3
BADGE 4

Is there some way of making the badges line up horizontally within the 80 pixel width so that they take up less space horizontally  eg

BADGE 1  BADGE 2
BADGE 3  BADGE 4

I tried making smaller badges of 35pixels wide but they still display one on top of the other.  Having them display side by side if the badge was small enough would help save space and length of posts.  we use about 6 badges on our site so a 1-2 line post looks kinda empty with all those badges displayed down the post.

Any ideas?

~thanks

ladyshanae

#102
I figured out how to do this and posted it a page or two back.  Here is the code:

QuoteIn Load.php FIND:

  $starstrings = array();
  foreach($allstars AS $star)
        $starstrings[] = str_repeat('<img src="' . str_replace('$language', $context['user']['language'], isset($star[1]) ? $settings['images_url'] . '/' . $star[1] : '') . '" alt="*" border="0" />', empty($star[0]) ? 0 : $star[0]);
  return implode("<br/>", $starstrings);
}

REPLACE  return implode("<br/>", $starstrings);

With

return implode($starstrings);

PrizeLive.com

When will this be made available for version 1.1 RC2?
Get Paid Instantly via PayPal (or other options) at PrizeLive.com!

ladyshanae

The current mod works with 1.1 RC2 ;)

PrizeLive.com

Quote from: ladyshanae on June 10, 2006, 03:45:50 PM
The current mod works with 1.1 RC2 ;)

Are you sure?

Why doesn't this page say it?: http://mods.simplemachines.org/index.php?mod=115

It has:

Compatible With: 1.0.5, 1.1 Beta 3 Public
Get Paid Instantly via PayPal (or other options) at PrizeLive.com!

perplexed

Quote from: ladyshanae on June 10, 2006, 03:43:22 PM
I figured out how to do this and posted it a page or two back.  Here is the code:

QuoteIn Load.php FIND:

  $starstrings = array();
  foreach($allstars AS $star)
        $starstrings[] = str_repeat('<img src="' . str_replace('$language', $context['user']['language'], isset($star[1]) ? $settings['images_url'] . '/' . $star[1] : '') . '" alt="*" border="0" />', empty($star[0]) ? 0 : $star[0]);
  return implode("<br/>", $starstrings);
}

REPLACE  return implode("<br/>", $starstrings);

With

return implode($starstrings);

Hey Ladyshanae - is that in reply to my question?  just checking


And yes I agree, it DOES work with RC2 as I am using it - the same version I was using with beta 2 public last year - no probs at all

Vinspire

Can someone show me the screenshot of the mod ?

I install it ... Saw the function but didnt see any different in the badge and some said the mods is working on 1.1 RC 2 and some said it doesnt.

So, which one is the true answer ?

I am using SMF 1.1 RC 2 by the way. :)

perplexed

have you activated the option in the membership groups you want to include in this?

you have to check the box in each member group in order for them to show up on the posts-

this option should be in each member group:

"Show the stars even if the group is a secondary group?:  "    

Tony Reid

Quote from: Vinspire on June 16, 2006, 12:54:10 AM
Can someone show me the screenshot of the mod ?

I install it ... Saw the function but didnt see any different in the badge and some said the mods is working on 1.1 RC 2 and some said it doesnt.

So, which one is the true answer ?

I am using SMF 1.1 RC 2 by the way. :)

It might conflict with the moderator activity mod ;) - easily fixed though

And to confirm Ive installed this on 1.1RC2 for clients - it works fine.

Admittedly I did it manually.

Tony Reid

Vinspire

Quote from: perplexed on June 16, 2006, 09:34:37 AM
have you activated the option in the membership groups you want to include in this?

you have to check the box in each member group in order for them to show up on the posts-

this option should be in each member group:

"Show the stars even if the group is a secondary group?:  "    

Yeap. I did that but it is still not working ... Maybe it is like what Tony said

Quote from: Tony on June 16, 2006, 10:38:52 AM
It might conflict with the moderator activity mod ;) - easily fixed though

And to confirm Ive installed this on 1.1RC2 for clients - it works fine.

Admittedly I did it manually.

So, how to fix it sir ? :P

quasar

As Vinspire says, I've got it installed, but not showing up the additional badges.  If there is a conflict, how can it be solved?

Tony Reid

Ive just checked and the only place that this mod conflicts with the moderator activity mod is in ManageMembergroups.php

Im not sure its the cause of the problems your describing....

Search for this....
SELECT groupName, minPosts, onlineColor, maxMessages, stars

and let me know what the rest of the line says.
Tony Reid

quasar

// Fetch the current group information.
$request = db_query("
SELECT groupName, minPosts, onlineColor, maxMessages, stars, showAddBadge, GroupModOptions
FROM {$db_prefix}membergroups
WHERE ID_GROUP = " . (int) $_REQUEST['group'] . "
LIMIT 1", __FILE__, __LINE__);
if (mysql_num_rows($request) == 0)
fatal_lang_error('membergroup_does_not_exist', false);
$row = mysql_fetch_assoc($request);
mysql_free_result($request);

$row['stars'] = explode('#', $row['stars']);

$context['group'] = array(
'id' => $_REQUEST['group'],
'name' => $row['groupName'],
'editable_name' => htmlspecialchars($row['groupName']),
'color' => $row['onlineColor'],
'min_posts' => $row['minPosts'],
'max_messages' => $row['maxMessages'],
'star_count' => (int) $row['stars'][0],
'star_image' => isset($row['stars'][1]) ? $row['stars'][1] : '',
'showAddBadge' => $row['showAddBadge'],
'is_post_group' => $row['minPosts'] != -1,
'allow_post_group' => $_REQUEST['group'] == 2 || $_REQUEST['group'] > 4,
'allow_delete' => $_REQUEST['group'] == 2 || $_REQUEST['group'] > 4,
'allow_primary' => substr_count($row['GroupModOptions'], 'P') == 1
);


That's what it has under that section.  Anything else?

Vinspire

Quote from: Tony on June 18, 2006, 06:39:01 PM
Ive just checked and the only place that this mod conflicts with the moderator activity mod is in ManageMembergroups.php

Im not sure its the cause of the problems your describing....

Search for this....
SELECT groupName, minPosts, onlineColor, maxMessages, stars

and let me know what the rest of the line says.

Where is this file ? I can only find ManageMembergroups.template.php and there is no such codes in it :P

quasar

You need to check under Sources.  The template is used for the language you want to read it in.  Sources contains the core templates/pages that SMF uses for it's database sorting.

Vinspire

Quote from: quasar on June 26, 2006, 08:10:50 AM
You need to check under Sources.  The template is used for the language you want to read it in.  Sources contains the core templates/pages that SMF uses for it's database sorting.

Thanks. Found it :)

Here is mine :

SELECT groupName, minPosts, onlineColor, maxMessages, stars, monitorGroup, showAddBadge
FROM {$db_prefix}membergroups
WHERE ID_GROUP = " . (int) $_REQUEST['group'] . "
LIMIT 1", __FILE__, __LINE__);
if (mysql_num_rows($request) == 0)
fatal_lang_error('membergroup_does_not_exist', false);
$row = mysql_fetch_assoc($request);
mysql_free_result($request);

$row['stars'] = explode('#', $row['stars']);

$context['group'] = array(
'id' => $_REQUEST['group'],
'name' => $row['groupName'],
'editable_name' => htmlspecialchars($row['groupName']),
'color' => $row['onlineColor'],
'min_posts' => $row['minPosts'],
'max_messages' => $row['maxMessages'],
'star_count' => (int) $row['stars'][0],
'star_image' => isset($row['stars'][1]) ? $row['stars'][1] : '', 'monitorGroup' => $row['monitorGroup'],

'showAddBadge' => $row['showAddBadge'],
'is_post_group' => $row['minPosts'] != -1,
'allow_post_group' => $_REQUEST['group'] == 2 || $_REQUEST['group'] > 4,
'allow_delete' => $_REQUEST['group'] == 2 || $_REQUEST['group'] > 4
);

// Get a list of boards this membergroup is allowed to see.
$context['boards'] = array();
if ($_REQUEST['group'] == 2 || $_REQUEST['group'] > 3)
{
$result = db_query("
SELECT ID_BOARD, name, childLevel, FIND_IN_SET(" . (int) $_REQUEST['group'] . ", memberGroups) AS can_access
FROM {$db_prefix}boards", __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($result))
$context['boards'][] = array(
'id' => $row['ID_BOARD'],
'name' => $row['name'],
'child_level' => $row['childLevel'],
'selected' => !empty($row['can_access']),
);
mysql_free_result($result);
}
$context['sub_template'] = 'edit_group';
$context['page_title'] = $txt['membergroups_edit_group'];
}

// Display members of a group, and allow adding of members to a group. Silly function name though ;)
function MembergroupMembers()
{
global $txt, $scripturl, $db_prefix, $context, $modSettings, $sourcedir;

$_REQUEST['group'] = (int) $_REQUEST['group'];

// No browsing of guests, membergroup 0 or moderators.
if (in_array($_REQUEST['group'], array(-1, 0, 3)))
fatal_lang_error('membergroup_does_not_exist', false);

// Load up the group details - and ensure this ISN'T a post group ;)
$request = db_query("
SELECT ID_GROUP AS id, groupName AS name, minPosts = -1 AS assignable, minPosts != -1 AS is_post_group
FROM {$db_prefix}membergroups
WHERE ID_GROUP = " . (int) $_REQUEST['group'] . "
LIMIT 1", __FILE__, __LINE__);
// Not really possible...
if (mysql_num_rows($request) == 0)
fatal_lang_error('membergroup_does_not_exist', false);
$context['group'] = mysql_fetch_assoc($request);
mysql_free_result($request);

// Non-admins cannot assign admins.
if ($context['group']['id'] == 1 && !allowedTo('admin_forum'))
$context['group']['assignable'] = 0;

// Removing member from group?
if (isset($_POST['remove']) && !empty($_REQUEST['rem']) && is_array($_REQUEST['rem']) && $context['group']['assignable'])
{
checkSession();

require_once($sourcedir . '/Subs-Members.php');
removeMembersFromGroups($_REQUEST['rem'], $_REQUEST['group']);
}
// Must be adding new members to the group...
elseif (isset($_REQUEST['add']) && !empty($_REQUEST['toAdd']) && $context['group']['assignable'])
{
checkSession();

// Get all the members to be added... taking into account names can be quoted ;)
$_REQUEST['toAdd'] = strtr(preg_replace('~&amp;#(\d{4,5}|[2-9]\d{2,4}|1[2-9]\d);~', '&#$1;', htmlspecialchars(stripslashes($_REQUEST['toAdd']), ENT_QUOTES)), array('&quot;' => '"'));
preg_match_all('~"([^"]+)"~', $_REQUEST['toAdd'], $matches);
$memberNames = array_unique(array_merge($matches[1], explode(',', preg_replace('~"([^"]+)"~', '', $_REQUEST['toAdd']))));

foreach ($memberNames as $index => $memberName)
{
$memberNames[$index] = trim($memberNames[$index]);

if (strlen($memberNames[$index]) == 0)
unset($memberNames[$index]);
}

$request = db_query("
SELECT ID_MEMBER
FROM {$db_prefix}members
WHERE memberName IN ('" . implode("', '", $memberNames) . "') OR realName IN ('" . implode("', '", $memberNames) . "')
LIMIT " . count($memberNames), __FILE__, __LINE__);
$members = array();
while ($row = mysql_fetch_assoc($request))
$members[] = $row['ID_MEMBER'];
mysql_free_result($request);

// !!! Add $_POST['additional'] to templates!

// Do the updates...
require_once($sourcedir . '/Subs-Members.php');
addMembersToGroup($members, $_REQUEST['group'], isset($_POST['additional']) ? 'only_additional' : 'auto');
}

// Sort out the sorting!
$sort_methods = array(
'name' => 'realName',
'email' => 'emailAddress',
'active' => 'lastLogin',
'registered' => 'dateRegistered',
'posts' => 'posts',
);

// They didn't pick one, default to by name..
if (!isset($_REQUEST['sort']) || !isset($sort_methods[$_REQUEST['sort']]))
{
$context['sort_by'] = 'name';
$querySort = 'realName';
}
// Otherwise default to ascending.
else
{
$context['sort_by'] = $_REQUEST['sort'];
$querySort = $sort_methods[$_REQUEST['sort']];
}

$context['sort_direction'] = isset($_REQUEST['desc']) ? 'down' : 'up';

// Count members of the group.
$request = db_query("
SELECT COUNT(ID_MEMBER)
FROM {$db_prefix}members
WHERE " . (empty($context['group']['is_post_group']) ? "ID_GROUP = " . (int) $_REQUEST['group'] . " OR FIND_IN_SET(" . (int) $_REQUEST['group'] . ", additionalGroups)" : "ID_POST_GROUP = " . (int) $_REQUEST['group']), __FILE__, __LINE__);
list ($context['total_members']) = mysql_fetch_row($request);
mysql_free_result($request);

// Create the page index.
$context['page_index'] = constructPageIndex($scripturl . '?action=membergroups;sa=members;group=' . $_REQUEST['group'] . ';sort=' . $context['sort_by'] . (isset($_REQUEST['desc']) ? ';desc' : ''), $_REQUEST['start'], $context['total_members'], $modSettings['defaultMaxMembers']);
$context['start'] = $_REQUEST['start'];

// Load up all members of this group.
$request = db_query("
SELECT ID_MEMBER, memberName, realName, emailAddress, memberIP, dateRegistered, lastLogin, posts, is_activated
FROM {$db_prefix}members
WHERE " . (empty($context['group']['is_post_group']) ? "ID_GROUP = " . (int) $_REQUEST['group'] . " OR FIND_IN_SET(" . (int) $_REQUEST['group'] . ", additionalGroups)" : "ID_POST_GROUP = " . (int) $_REQUEST['group']) . "
ORDER BY $querySort " . ($context['sort_direction'] == 'down' ? 'DESC' : 'ASC') . "
LIMIT $context[start], $modSettings[defaultMaxMembers]", __FILE__, __LINE__);
$context['members'] = array();
while ($row = mysql_fetch_assoc($request))
{
$last_online = empty($row['lastLogin']) ? $txt['never'] : timeformat($row['lastLogin']);

// Italicize the online note if they aren't activated.
if ($row['is_activated'] % 10 != 1)
$last_online = '<i title="' . $txt['not_activated'] . '">' . $last_online . '</i>';

$context['members'][] = array(
'id' => $row['ID_MEMBER'],
'name' => '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '">' . $row['realName'] . '</a>',
'email' => '<a href="mailto:' . $row['emailAddress'] . '">' . $row['emailAddress'] . '</a>',
'ip' => '<a href="' . $scripturl . '?action=trackip;searchip=' . $row['memberIP'] . '">' . $row['memberIP'] . '</a>',
'registered' => timeformat($row['dateRegistered']),
'last_online' => $last_online,
'posts' => $row['posts'],
'is_activated' => $row['is_activated'] % 10 == 1,
);
}
mysql_free_result($request);

// Select the template.
$context['sub_template'] = 'group_members';
$context['page_title'] = $txt['membergroups_members_title'] . ': ' . $context['group']['name'];
}

// Set general membergroup settings.
function ModifyMembergroupSettings()
{
global $context, $db_prefix, $sourcedir, $modSettings;

$context['sub_template'] = 'membergroup_settings';

// Needed for the inline permission functions.
require_once($sourcedir . '/ManagePermissions.php');

if (!empty($_POST['save_settings']))
{
checkSession();

// Save the permissions.
save_inline_permissions(array('manage_membergroups'));
}

// Initialize permissions.
init_inline_permissions(array('manage_membergroups'), array(-1));
}

?>

PrizeLive.com

Does this work for version 1.1 RC2?
Get Paid Instantly via PayPal (or other options) at PrizeLive.com!

URPG

Quote from: SurfExcelerator.com on June 28, 2006, 10:08:34 AM
Does this work for version 1.1 RC2?

That was my question too, but:

Quote from: Tony on June 16, 2006, 10:38:52 AM
And to confirm Ive installed this on 1.1RC2 for clients - it works fine.

and

Quote from: perplexed on June 11, 2006, 09:20:59 AMAnd yes I agree, it DOES work with RC2 as I am using it - the same version I was using with beta 2 public last year - no probs at all

URPG

I tried to use this MOD (yes, it IS working) to give stars based on posts and on Membergroups (Sheriffs star for Moderators, etc.) but it does not seem to like my Star images... all it displays are *

What is the max size of a starimage? they are all 16x16px but i want the sheriffs star for example to be 45x45 so anyone can easilie see and recognize it...

Advertisement: