When moderating a lot of content (eg: g.d.o), often the same issue pops up repeatedly, and needs the same response. It would be really convenient if modr8 could handle this. In fact, implementing this could be done by making the existing /admin/settings/modr8 page more general:

- allow any number of options here (with an "add more" button, or making sure there's a blank one at the bottom - so administrator can always add one more)

- each option has radio button for selecting moderation action approve/deny/noaction, and a checkbox for sending mail.

- default to the existing three options, of course.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

lyricnz’s picture

Alternatively, this could be managed with a table of canned responses, and add/edit/delete actions, like the Path editing screen. If pwolanin has interest in this, I can write a patch.

pwolanin’s picture

This almost sounds like a separate general-purpose module that would store text snippets via some admin UI. Somehow you need to be able to assoicate some or all of the available snippets with a specific form's textarea. Then you could have a little ajax widget to grab and insert the selected snippet.

lyricnz’s picture

I guess there are two approaches here:

- canned "notes" which would be inserted into the three current actions, presumably via client-side javascript

- generalise the current 3 options to the point where an administrator can create new "stock responses" (shown as radio buttons), which would approve/deny/noaction the moderation, optionally send an email, with configurable subject/body. The current three options would be the default configuration, of course.

I was thinking of the second option (to give maximum flexability in the message format), but perhaps that's not really required. In fact, these options are not mutually exclusive - which one(s) are you interested in getting?

pwolanin’s picture

I think approach #1 is much more general and useful - there are probably 3 or 4 common responses I use for denying a group, adn similarly at least a couple no-op messages. So, i don't thin 1 message per radio would be that useful since it would just prolieferate the # of radios for waht are really just 3 possible actions.

lyricnz’s picture

Some implementation questions for discussion (think first, code later :). My guesses in [brackets]

- should the canned responses be associated with a particular approve/deny/none action (ie: should it change the state of the radio button?) [no]

- how should these appear in the UI? A list of hyperlinks/buttons/icons below the text area? Below the node? [list of links below textarea, inserted by JS so degrades cleanly]

- any preferences on the location of the canned-node admin screen? Part of admin/settings/modr8? Separate tab? [Separate tab??]

- any preferences on the UI of that screen? [table with title+body+edit/delete columns, and an add-note form at the bottom]

- any preferences on the storage of notes? [single array in a new variable]

lyricnz’s picture

I've started writing this as another module, but perhaps it'll be worth distributing with modr8, eventually. Here's the javascript I'm using to populate the textareas (only depends on <div id="*-note-wrapper"> markup):

Drupal.behaviors.modr8canned = function(context) {
  // Build some HTML containing all the links that add canned responses to the textarea.
  var settings = Drupal.settings.modr8canned;
  var linkshtml = '<ul class="modr8canned">';
  for (var i in settings) {
    for (var j in settings[i]) {
      linkshtml += '<li><a href="#" title="' + settings[i][j] + '">' + j + '</a></li>';
    }
  }
  linkshtml += '</ul>';

  var links = $(linkshtml);

  // Add the event handler.
  $('a', links).click(function(event) {
    $(this).parents('div[id$=-note-wrapper]').find('textarea').val(this.title);
    event.preventDefault();
  });

  // Add these elements to every note-wrapper div.
  // TODO: do we need to clone(true) these?
  $('div[id$=-note-wrapper]').append(links);
};

And a screenshot (canned responses currently formatted as UL, but open for discussion)

pwolanin’s picture

Looks like a good start - I'd think in the end we'd want a hidden set of links (since I imagine there will be 10+). On click or on hover, we'd show the possible links (maybe above the actually node teaser, rather then using more vertical space)

Clicking one of the links to get a pre-defined snippet should probably hide the links again, if we assume that the typical use cae is to just grab one snippet of text as a canned response?

pwolanin’s picture

You know what would be really cool - have a permission "add textarea to snippet list" or some such. Users with this permission would see a JS (or not) button under each text area. (essentially this is just a general form_alter looking for textarea elements).

If the admin clicks that button a request is made that adds the form ID and element name (hopefully enough to define the JS selector) is stored as an available form to add/use snippet.

This would be a great auto-discovery admin approach, and would allow nice separation of at least 3 perms:

1) add new forms
2) add new snippets
3) use pre-defined snippets

Note - use a button/proper FAPI ajax to avoid CRSF, or maybe have links open in a new page with a confirm form

lyricnz’s picture

The problem I can see with the general textarea/snippet model is that it's hard to automatically pick a selector that's accurate. For example, the textarea used by modr8 module is formed something like:

<textarea id="edit-573-note" class="form-textarea resizable textarea-processed" name="573[note]">

So without a bunch of "magic logic" dealing with numbers, it wouldn't be possible to be able to click on one instance of such a textarea, and say "add canned response for this".

FYI, what I'm doing in the JS above is using the outer 'div[id$=-note-wrapper]' then looking inside that for textarea...

<div id="edit-573-note-wrapper" class="form-item">
  <label for="edit-573-note">Note to author: </label>
  <div class="resizable-textarea">
    <span>
      <textarea id="edit-573-note" class="form-textarea resizable textarea-processed" name="573[note]" rows="5" cols="15"/>
      <div class="grippie" style="margin-right: -2px;"/>
    </span>
  </div>
</div>

So... I'm not sure the general solution is possible when using a list of textarea like we do in mod8.

greggles’s picture

pwolanin’s picture

In general, FAPI should construct the id or name attributes in a consistent way from the form array - I guess for this it's hard in as much as the values for modr8 probably change based on the node IDs.

lyricnz’s picture

FileSize
79.06 KB
30.69 KB

Okay, I've done a first implementation of this module:
- uses a vocabulary to manage the list of stock responses (term=link, description=body), to save reinventing all those editing screens
- adds a vocabulary selection to the modr8 settings (see first screenshot)
- adds a number of links below the node body on the moderation screen (see second screenshot)
- clicking on one of those links will copy the text to the textarea

lyricnz’s picture

FileSize
1.34 KB

See attached module (or could be added to modr8 module)

lyricnz’s picture

Status: Active » Needs review

Here are a few example stock responses:

english
From http://groups.drupal.org/node/add/og
"Feel free to use your native language instead of English for all group fields, except for the title and the group description. Please provide these two fields in English in all cases."
commercial
No advertising / commercial groups please
existing
There is an existing, active group: http://groups.drupal.org/GROUPNAME
moreinfo
Please supply more details about the goals and purpose of the group.
bigger
Groups should be for a fairly large geographic region. We prefer to have fewer, larger groups.
modules
This seems very specific. Why not put your questions out there in the issue queue of the modules you use for this?
greggles’s picture

Issue tags: +gdolove

Thanks for your work here, lyricnz.

What more needs to happen on this?

lyricnz’s picture

Hi greggles,

I haven't looked at this patch/module in six months, so it might need to be retested, to make sure it hasn't gone stale. As far as getting it onto gdo goes - we need some decision about whether this is better implemented as a separate module, or an update to modr8.

Actually, this might be gdo-specific, since the jquery selector used to put the text in the textarea is technically theme-overridable (how do people normally solve that?):

$('div[id$=-note-wrapper]')

Then, if gdo admins are willing to install it, we should come up with some canned responses for them to apply (since modifying these will require edit-taxonomy access). We can review moderation history to get an accurate view of the types of responses most often used.

A more basic question: do you guys want this functionality for gdo?

Regards, Simon

greggles’s picture

I want it, but I don't do a lot of moderation...

Pwolanin?

Now that I think about it, I started doing http://growingventuresolutions.com/blog/create-templates-quick-thoughtfu... a little while ago, though that's something that is harder to share between admins...

mathankumarc’s picture

pwolanin’s picture

Version: 6.x-1.1 » 6.x-1.x-dev
lyricnz’s picture

So... the reason for my suggestion, and code, was to get it on gdo. Without some buy-in from the d.o team, who it was written for, this will never go anywhere.

greggles’s picture

I think it had/has buy in, but the process has shifted under foot and is now being done in the issue queue on d.o.

crankyhippo’s picture

Issue summary: View changes

i apologize from bringing this back from the dead but I am offering a 50$ amazon gift card (US and UK only) to anyone willing to take this module the last bit and turn it into a real module on drupal with support for CKEditor and the current D6 version.

In its current form, i can't seem to get it to work as it appears it isn't binding the click() event properly.