User:Zachary/Watchlist categories

I just successfully implemented a feature on my test wiki that allows for the creation of "watchlist categories" for filtering the watchlist. You can find a patch for this here (sorry, this was lost), or you can see it in action here (sorry, not set up anymore). There is a feature request on bugzilla for this here (bug 5875).

To be honest, I'm not very experienced in PHP programming (I am more of a perl guy myself), so I'm sure there is a better way to implement this. This is my first attempt at hacking the MediaWiki software (aside from some skins I created), so I'm not completely aware of all of the internal workings. Also, I'm not very good at user interface. There's probably a "friendlier" way to design the user interface as well... but feel free to apply/test/modify/whatever the patch as you wish. If you find a different or better way at implementing any part of this, please let me know and I can update the patch.

How it works
My goal was to make the least changes to the database schema as possible, so I added a one-byte field, `wl_catid` to the `watchlist` table (allowing for a maximum of 255 custom categories per user, which could be limited to any number of categories). Custom categories are stored in the `user_options` field of the `user` table.

All pages are by default added to the "default" category. A new subpage to Special:Watchlist, "/categories", is where you can manage custom categories. To add or remove watchlist items from categories, use the "/edit" subpage, where you can check the watchlist items you want to "move" to the specified category.

Upon deletion of a category, all watchlist items contained in it will be moved back to the "default" category.

Installation
You'll need to run "update.php" after applying the patch, or you can manually update your database using the following mysql command (your watchlist table might not be named "watchlist" if you have a db table prefix setting):

> ALTER TABLE `watchlist` ADD (`wl_catid` TINYINT UNSIGNED NOT NULL DEFAULT 0);

If you have already modified the "watchdetails" system message, you may need to update it manually. For the UI to link to the "Special:Watchlist/categories" page, you'll need to alter the system message on your wiki, and add this (or something similar) to it:

* Show and edit watchlist categories

That's all! You should be ready to go from here. If you have any questions/comments/suggestions, feel free to email me or post a message on my talk page. Enjoy!