MyBB Community Forums

Full Version: [B] Akismet sample plugin
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am starting my experience with myBB with writing a plugin for aMember. The version I have is 1.4.6 (1406) as a fresh download.

Around line 140 in the function akismet_install you have;
	$query = $db->simple_select("settinggroups", "COUNT(*) as rows");
	$rows = $db->fetch_field($query, "rows");
This is bad because as stuff is added/removed it is not the last settings group id just the number of rows... Should be something like
	$query = $db->simple_select( "settinggroups", "MAX(disporder) as rows" );
	$rows = $db->fetch_field( $query, "rows" );
Test and working as I think you intended...

Thanks,
Larry
(2009-05-27, 12:33 AM)Jenolan Wrote: [ -> ]This is bad because as stuff is added/removed it is not the last settings group id just the number of rows...

The query you've pointed out does not set the group id - it just sets the display order of the settings group. So basically, this is making sure that the Askimet is just appearing at the bottom of the list of settings.

It uses auto_increment for the gid to ensure that it's the latest, and not duplicated.

I know Ryan wrote this, so if I've got this wrong feel free to correct me!
Yes that is correct it is the display order, I did not say it was 'critical' using this code you can have duplicates. Whether that affects the code in question doesn't matter as an example if getting a unique was critical this could cause someone to misstep that was my point.
The order itself for plugins can have duplicates. If there is duplicates it will sub-order those by name iirc.