Wednesday, September 23, 2009

HTML default buttons

I had been having a difficult time at work with a supposedly simple problem. I have a series of buttons in a web application, basically a "Previous", "Save & Exit", and "Next" button to guide the user of the web application through a wizard type application. The elements were declared as <>, not <>, because I wanted the customer to be able to customize the button layout and potentially use image buttons.

For the life of me, IE wanted to make the default button the first one and I couldn't override it to the "Next" button. At first what I had was a hack that I thought pretty much always worked.... Do a hidden <> tag with type=submit, then make that apply whatever button you wanted as the default... works great in Firefox but not in IE. So I tried making the "Next" an actual <> just to see if that functionality worked in IE. I set the type=submit, and the other buttons were still <>.... Still no dice and this time it broke Firefox, too! Google'ing around you get all sorts of weird suggestions like trying to trap the enter key and then firing an event. That borders on keylogger-ish behavior and some browsers and/or plugins might not allow that to work, just seemed like a big hack, too.

Final solution... specify type on BOTH buttons made through <> and <>... I was able to go back to making all 3 buttons a <> (therefore allowing image button support). On the default button, set type=submit. On ALL the other buttons (and this is the key), set type=button..... Now my rant...... why the heck would NORMAL non-attributed BUTTONS take precedence over anything that had a type=submit?!?!

phpBB forums -> Joomla's ccboard & auth integration

I've been working with LanOC ( http://www.lanoc.org ), a large gamer group from Van Wert, to help them convert their present website which runs mainly off of phpBB with several items like Wordpress integrated. Lately they've decided to migrate to the Joomla CMS ( preview of new site at ( http://test.lanocreviews.com/ ) ), and after looking at that for a while, I am giving serious consideration to moving FWGamers as well. LanOC's admin has been extremely fun to work with, he's getting a migration for free and I've been getting advice on running larger parties.

That aside, anyone who has used phpBB before knows that the only headache along the way is converting the users. LanOC had over 400 user accounts (only 370ish active from what I can see), and you can bet at that size, they didn't want to tell everyone to just go enroll again or come up with a password migration scheme.

I proposed developing a sort of bridge, but one they could eventually move off of, not something they would need to keep installed forever. Mostly the reason for that was I didn't want to have to change my code every time Joomla decided to update their core authentication. What I came up with is something that will first check and see when someone goes to log in if the user already has a Joomla password set up, if they do, it just skips my code & runs like normal. However, if the Joomla password field is blank, I take the password supplied (it's in clear text at this point since the user just typed it) and compute the phpBB hash using some functions I cobbled together and modified from the phpBB source code. I then connect to the old phpBB database and attempt to find the user record there. Assuming it exists, I just compare the computed hash with the database. If they match, I take the cleartext password and run it through the standard Joomla encrypter and update the Joomla user record. At that point I just re-read the Joomla user record & then fall through to the existing Joomla logic.

Other bridges out there for phpBB -> Joomla seem to go in a direction that doesn't really make sense to me, other than if you were trying to supply multiple UI choices to access your CMS environment (which still makes no sense... just choose 1 and provide good themes). Basically they disregard authenticating against the Joomla database and just go straight to phpBB. Any user updates that happen occur in phpBB, not Joomla (unless phpBB doesn't have the appropritate field being updated). Those integration packages are very nicely done, but I just feel it's better to do as close as possible to a 100% migration.

The result is, over the next 6 months or so, LanOC's users can seamlessly migrate themselves to their new site and then totally remove my custom modification as well as delete the phpbb_users table (that's the only table I need access to). Anyone who hasn't logged in for 6 months (password in Joomla user's table would be empty) could be given a random password and the next time they try to log in could go through the password reset procedure.

Additionally I helped with some UI enhancements to their new site. It looks & functions 100% like what they want it to, now. There are a few things I would change up personally but think overall it is worlds better than what they have now.

If anyone needs a phpBB -> Joomla conversion and is looking at using the ccboard forums, I can send you my conversion package. It converts users, categories, forums, topics, posts, attachments, private messages (assuming you have the "community" Joomla extension). It does not convert the groups currently because it's quick and easy to convert those manually. The conversion itself is database agnostic, just change the DSN string to whatever database you're using and it will work. The authentication piece I custom coded, however, is coded for MySQL. With only one query being done, though, it could easily be changed.

Now 1 more project to complete, then back to working on my game .... :-)