This month I carried on plugging away intermittently at the promised Drafts features. May's new feature was the option to ask for editor review of a draft by setting its status to 'review.' To support this feature, I started by making changes to a couple of existing features: notifications and node notes.
To inform the content editors that a user wanted a draft reviewed a new notification was needed. (Are you using the Notifications nodelet? Test-drive it today, for no additional fee!) To create this new notification I had to find out how the notification system worked. It turned out that it could work more simply: it needed the node_id of the type of notification being added, and it had been implemented when htmlcodes could only accept strings as arguments, so every time addNotification was called there was a fair amount of messing around to find the node_id from the name of the notification, and to convert whatever arguments were required for the particular kind of notification involved to strings. Since it was essentially the same messing around every time, I put it into addNotification, which can now be called with one line of code referring to the notification by name and not number. The 'blank writeup' notification in Writeup maintenance update was the first piece of code to experience the benefits of the new simplicity and confirm that it did in fact work.
After updating canseeNotification so that only editors will be notified of drafts for review, it was the work of but a moment to have draft maintenance update add the new 'draft for review' notification when the status of a draft is changed to 'review.' Normally, all editors/administrators are notified; if a user is suspended, only the suspending editor gets the notification. Other users who are interested can see drafts for review at Drafts for Review.
System-generated node notes
When an editor responds to the notification and has a look at a draft, it is useful for them to know when the user asked for review. And when it is possible to return writeups to draft status, it will no doubt sometimes be useful to have a record of draft/writeup history. There is a system in place enabling editors and site administrators to make notes on any node on the site, and that seemed like an appropriate place to put the information. So:
- There is a new column in the nodenote database table to record which user is entering the note.
- The code to create notes has been moved out of the nodenote opcode to a new htmlcode (addNodenote), which records the user entering the note if told who it is.
- The nodenote htmlcode, which displays nodenotes, shows a more precise timestamp and offers no delete option for system notes, which are identified by the fact that they were not entered by an individual user.
- Everything User Search does not flag the presence of system notes.
- draft maintenance update enters a system node note on a draft when its status is changed to 'review'.
Activate and Tweak
With these new features in place, all that remained was to make status 'review' available:
- setdraftstatus lets the user set draft status to 'review', and also lets the server know what the prior status of a draft was, so that the notification is only made when the status is changing to 'review', and not if the draft is being updated without a change in status.
- parentdraft offers the option to request review (and thus possible permission to publish) when a draft cannot be published to a node because the node is locked or the user is suspended.
After people started using the review system, it turned out that a way of indicating whether an editor had already looked at a draft would be useful. I had vanished for a few days due to a sudden spike in paid work, so OldMiner took up the slack and added an indication to the notification of how many node notes had been added to a draft since it was put up for review.
A user whose name begins with an 'm' and which I will mention in full if they remind me of it accidentally created a draft without a title, which made it impossible to access, and took the trouble to let me know of the problem. So draft maintenance update now provides a title if the user forgets.
Staff have a link to Drafts for Review in their super secret oppressor nodelet, for convenient access to it if their review notifications have all rolled off the bottom of Notifications. Gods no longer have a delete option there for writeups and drafts: they have no business deleting other people's drafts, and there are other ways of removing writeups.
Speaking of other ways of removing writeups: the next item on the list of features for the drafts system is removal of writeups by returning them to draft status rather than by nuking them. Users will even be able to do this for themselves. Now if that isn't a treat worth looking forward to...