Saturday, January 1, 2011

Poll Mod for PunBB 1.2.x - updated version




An update to the punBB poll mod I hacked together a year or so ago - frankly, something that should have been done a long time ago. This update is a major redesign, although it recycles much of the code from the 0.0.3 release. Looking back at the old code is a little embarrassing, to be honest, and it's clear that I hadn't spent any time thinking about its design. This release introduces many new features, but more importantly doesn't feel like it was programmed by a moron.

Changes include
  • Code refactoring, more modular design, greater separation of mod code from punBB code
  • Support for php4 removed - php5 is now a requirement
  • Simplified installation procedure
  • Ability to restore database if uninstalled
  • Existing topics can be turned into polls
  • Ability to edit, close and delete existing polls
  • Poll permissions and colour scheme can be edited via the newly introduced admin console
  • Ability to restrict which classes of user have permission to create polls
  • n-1 polls now show approval ratings (ie percentages do not add up to 100, but results are more meaningful)
  • multi-lingual support
  • licence is now GPLv3, instead of LGPLv3
  • Various performance improvements and bug fixes
The database schema in this release has changed from that of the 0.0.3 release. The current release, and all future releases will write the poll mod version into the database, so that the installation script will be able to update existing polls if the database schema is ever changed again. Sadly, I wasn't so foresighted when I released 0.0.3, so if upgrading from 0.0.3, the database schema will need to be updated by hand. This is not too difficult, though - just create a boolean column "closed" which defaults to 0, and a varchar(200) column named "creator" in the polls table. The following (conf_name, conf_value) pairs then need to be added to the punBB config table:

  • ('rob_poll_version' , "0.1.0")
  • ( 'rob_poll_permission_level' , '1')
  • ( 'rob_poll_bg_colour' , '#FFFFFF')
  • ('rob_poll_bar_colour' , "#190A8F")
  • ( 'rob_poll_text_colour' , "#A0A0A0")
  • ('rob_poll_text_size' , "14")
Optionally, the data type of the following columns in the polls table can be changed as follows
  • question: change Text to varchar(200)
  • options: change Text to varchar(2010)
  • votes: change Text to varchar(110)
In future releases, I'll pay more attention to breaking the database schema. The version numbering convention will help in this regard - whenever I change the database schema in a backwards incompatible way, I'll update the minor version number (eg from 0.0.3 to 0.1.0)

The mod code and installation instructions are linked below. Thanks and acknowledgements go to Jan Odvarko, author of the jscolor script. This script is a javascript colour picker, which I have incorporated into the admin console - it is used to adjust the mod's colour scheme.

robs_poll_mod_0.1.0.tar.gz