Page 1 of 7

Legend Repositioning

Posted: Sat Oct 03, 2009 6:13 am
by Extensions Robot
Modification name: Legend Repositioning
Author: Tom
Modification description: This MOD provides an easy and convenient method for administrators who have permission to manage groups to reorder (or, reposition) the groups that are displayed in the board's legend, both on the index.php and viewonline.php pages.
  • Groups can be easily repositioned by clicking up and down arrows in the ACP.
  • Each time a group's position is moved, the action is logged in the administrator log.
  • When a new group is added, it is automatically positioned at the end (or bottom) of the group list on the legend.
  • When a group is deleted, all other groups below it have their positions modified accordingly.
* This MOD is compatible with phpBB 3.0.12 *

You may safely ignore any "target phpBB version for this MOD is 3.0.6" messages from AutoMOD.
Modification version: 1.0.3
Tested on phpBB version: 3.0.6

Download file: Legend Repositioning 1.0.3.zip
File size: 162.65 KiB

Modification overview page: View

The phpBB Team is not responsible nor required to provide support for this modification. By installing this MOD, you acknowledge that the phpBB Support Team or phpBB Extensions Team may not be able to provide support.

-->Modification support<--

Legend Repositioning

Posted: Sat Oct 03, 2009 6:13 am
by DavidIQ
Modification validated/released

Notes:

Legend Repositioning

Posted: Sat Oct 03, 2009 6:13 am
by Tom
Image

For known issues, screenshots, language translations, and other extended information, view the Legend Repositioning FAQ.

Re: Legend Repositioning

Posted: Sat Oct 03, 2009 8:32 am
by RMcGirr83
[EDIT]Fixed in latest version[/EDIT]

Re: Legend Repositioning

Posted: Sat Oct 03, 2009 2:38 pm
by Tom
RMcGirr83 wrote:Congrats on the validation Tom!!

I ran across an issue recently after installing this and updating the board to 3.0.6-RC2. As you may be aware 3.0.6 adds a new group ("Newly Registered Users"). This new group did not present itself in your new panel to be "moved" even though I selected the group to display on the legend.
Thanks, Rich. :)

The reason that the "Newly Registered Users" group is not showing up on the repositioning panel after installing on 3.0.5 and updating to 3.0.6-RC2 is because, after the code edits are done for the MOD, you ran the install_legend_repositioning.php file and it gave an incrementing numeric value in the group_position field for each of your existing groups in the database. However, once you updated to 3.0.6-RC2 it added the "Newly Registered Users" group, but that group was not assigned a numeric value for the group_position field. Therefore, it didn't show up on the repositioning panel in the ACP on purpose because I designed the panel so that it would only list the groups that have a numeric value for the group_position field. This prevents some problems that may occur when you try to reposition a group that has a group_position value of "0". Your fix will work, but it will no longer show groups that are not shown on the legend in the repositioning panel, and that could be a problem. The reason it could be a problem is because I purposely wanted all groups listed in the repositioning panel (whether they're on the legend or not) so that you can see how each group would be positioned on the legend if it was to be shown there. That's why in the repositioning panel groups that are listed on the legend show up with a light-blue background, and groups that aren't listed on the legend have a white background. ;)

This wouldn't be a problem if the MOD was installed directly on a 3.0.6-RC2 installation, but if it is installed on a 3.0.5 installation and is then updated to 3.0.6-RC2, then that is where problems will arise. I'll need to create a quick fix script that can be run to give a value in the group_position field for the "Newly Registered Users" group - that should fix this problem. I'll get to posting the "fix script" for this issue later today.

Thank you for pointing this out. I submitted this MOD before 3.0.6-RC1 was released, so I never needed to think about an issue like this (because 3.0.5 was the "latest greatest" at the time). ;) I appreciate you checking it out.

Re: Legend Repositioning

Posted: Sat Oct 03, 2009 3:30 pm
by RMcGirr83
I see exactly. :)

FWIW, I use this code in my warning reasons mod to ensure the position is always set.

Code: Select all

		// By default, check that order is valid and fix it if necessary

		$result = $db->sql_query('SELECT reason_id, reason_order FROM ' . WARNING_REASONS_TABLE . ' ORDER BY reason_order');

		if ($row = $db->sql_fetchrow($result))
		{
			$order = 0;
			do
			{
				++$order;
				
				if ($row['reason_order'] != $order)
				{
					$db->sql_query('UPDATE ' . WARNING_REASONS_TABLE . " SET reason_order = $order WHERE reason_id = {$row['reason_id']}");
				}
			}
			while ($row = $db->sql_fetchrow($result));
		}
		$db->sql_freeresult($result);
which I modified from includes/acp/acp_reasons. Six of one half a dozen of another I suppose. ;)

Cheers!

Re: Legend Repositioning

Posted: Sat Oct 03, 2009 3:51 pm
by Tom
Oh, I see what you've done there. Maybe that would be a better idea than creating a script that has to be run manually to fix the problem, whereas using a system such as the one you posted would take care of undefined positions automatically. Thank you for sharing that, and a fix/update should be coming soon. :)

Re: Legend Repositioning

Posted: Sat Oct 03, 2009 4:13 pm
by bonelifer
Nice mod. If the "Group Legend Positioning" mod I'm using doesn't work with 3.0.6, I'm going to use this one.

Re: Legend Repositioning

Posted: Sun Oct 04, 2009 6:48 am
by PinoyEngineâ„¢
This is a very wonderful MOD.
Two Thumbs up for this. :D

Re: Legend Repositioning

Posted: Sun Oct 04, 2009 10:18 pm
by Tom
Attention: The bug that Rich addressed earlier in this topic now has a fix available. Whether you are running this MOD on phpBB 3.0.6 or not, you should still preform this fix to ensure that there are no problems when updating to future versions.

Issue #001 - Fix Instructions

Code: Select all

#
#-----[ OPEN ]------------------------------------------
#
includes/acp/acp_groups.php
#
#-----[ FIND ]------------------------------------------
#
# The tabbing on this find may not be exactly correct, so look 
# at the bottom of the file for this find.
#
		// Get all the groups that show on the legend
		$sql = 'SELECT g.group_id, g.group_name, g.group_type, g.group_legend
			FROM ' . GROUPS_TABLE . ' g
			WHERE g.group_position > 0
			ORDER BY g.group_position ASC';
		$result = $db->sql_query($sql);

		$lookup = $cached_group_data_full = array();
		while ($row = $db->sql_fetchrow($result))
		{
			// used for easy access to the data within a group
			$cached_group_data_full[$type][$row['group_id']] = $row;
		}
		$db->sql_freeresult($result);
#
#-----[ REPLACE WITH ]------------------------------------------
#
		// Get all the groups to show in the repositioning panel
		$sql = 'SELECT g.group_id, g.group_name, g.group_type, g.group_legend, g.group_position
			FROM ' . GROUPS_TABLE . ' g
			ORDER BY g.group_position ASC';
		$result = $db->sql_query($sql);

		$lookup = $cached_group_data_full = array();
		if ($row = $db->sql_fetchrow($result))
		{
			$position = 0;
			do
			{
				++$position;
				if ($row['group_position'] != $position)
				{
					$sql = 'UPDATE ' . GROUPS_TABLE . "
						SET group_position = $position
						WHERE group_id = {$row['group_id']}";
					$db->sql_query($sql);
				}
				$cached_group_data_full[$type][$row['group_id']] = $row;
			}
			while ($row = $db->sql_fetchrow($result));
		}
		$db->sql_freeresult($result);
#
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------
#
# EoM
This will fix Issue #001 on the Known Issues list for this MOD. Special thanks to Rich for reporting this bug and suggesting a useful means of fixing it. As I've said before, be sure to preform this fix no matter what version of phpBB you are running.

Also, if anyone tried using the fix posted by Rich here, you may want to put that line back to the way it was previously. Since I have released a fix for this issue, using the fix Rich described there may now cause problems with the MOD. ;)

Thanks, everyone, and if you are noticing any bugs with this new fix please report them. I am going to be submitting this revision to the MODDB very soon for validation.

Legend Repositioning

Posted: Mon Oct 19, 2009 3:24 pm
by DavidIQ
MOD Updated to version 1.0.1
See first post for Download Link

Re: Legend Repositioning

Posted: Wed Oct 28, 2009 6:56 pm
by CrudeR
Nice MOD just what I needed! Had to make a few edits to some other files to make it work on our portal but works perfect with it now. Thanks Tom. 8-)

Re: Legend Repositioning

Posted: Sat Oct 31, 2009 9:50 pm
by anthies
Thanks for the mod! Now we can actually re-organize the legend line alphabetically.

Re: Legend Repositioning

Posted: Sun Nov 01, 2009 6:57 am
by ziscross
I recommended to repositioning in online list above the legend

I can't find out in /include/function.php

sincerely

from Thailand

Re: Legend Repositioning

Posted: Sun Nov 01, 2009 6:30 pm
by Tom
ziscross wrote:I recommended to repositioning in online list above the legend
This MOD is only for repositioning the usergroups listed on the legend. The Who is Online list shows all of the users who are currently online and sorts them alphabetically. Repositioning the legend and the Who is Online area are two very different things. I'm not sure if I understand your suggestion correctly, but it seems as though you want to be able to select a specific order for how each user on your forum will be listed in the Who is Online area? I'm not sure why you would want to do that (unless you have a small forum), but this MOD does not relate to that idea, sorry.
ziscross wrote:I can't find out in /include/function.php
What exactly can't you find? Are you looking for a line in that file and you can't find it? Sorry, but I can't understand your question. By the way, the file /include/function.php does not exist, but there is a file called /include/functions.php with an "s" in "functions". Maybe you were looking for the wrong file. ;)