Currently it is not possible for a site administrator to change the way that differences between issues and/or comments are displayed. This is true both for the tables displayed on issue nodes and comments, as well as in email notifications of changes. Besides just allowing a developer to actually theme these displays, this patch does the following:
- Allows the $changes[]['old'] and $changes[]['new'] arrays returned by project_issue_comment_changes() to provide changes in either string or array form.
String form:'taxonomy_vid_10' => array( 'label' => 'Vocabulary 10', 'old' => 'MySQL, pgSQL, javascript', 'new' => 'pgSQL, newbie', ),Array form:
'taxonomy_vid_10' => array( 'label' => 'Vocabulary 10', 'old' => array('MySQL', 'javascript'), 'new' => array('newbie'), ),Without this patch the second form (array) would cause errors. This patch fixes that and also provides for different theming of the output based on whether 'new' and 'old' are strings or arrays. See below for example output and use cases.
- Adds a new hook (
hook_project_issue_issue_table_alter()) that allows other modules to add additional rows of metadata to the metadata table that is displayed at the top of every issue. The addition of the hookhook_followup_metadata_changes()from #140473: refactor code to compute the diff on an issue generated by a given follow-up made it possible for other modules to add rows to the metadata tables displayed on comments, but it didn't occur to me at the time that we'd also want to allow modules to add rows to the table at the top of the issue that shows all of the current values of the metadata. - Fixes a minor bug introduced in #140473: refactor code to compute the diff on an issue generated by a given follow-up that prevented the "Reported by:" and "Updated by:" fields from being added to the metadata information on the top of emails sent in response to issue creation or followups.
- Adds some additional information in the comment of project_issue_comment_changes() describing hook_followup_metadata_changes().
I have tested this pretty extensively, but there's a lot to keep track of during testing so it's possible that this patch breaks something, so I'd like to get someone else to test it out as well in case I did miss something.
I've again provided a simple testing module that you can download and enable. Please note that this fake_testing_module is not smart and just adds some data via the two relevant hooks. Therefore, it will add the same data to every comment of an issue.
As an example of how data is displayed, I've also attached some screenshots and have email output below.
For a new issue, the metadata information in an email looks like this:
Project: Subscribe
Component: Code
Category: task
Priority: normal
Assigned to: Anonymous
Status: active
Reported by: a
Updated by: a
Vocab 8: myterm1
Vocab 8a: myterm1, myterm2
Vocab 9: New term
Vocab 10: Javascript, MySQL, pgSQL, IE7, Safari, Firefox
Vocab 11: Firefox
Vocab 12: newtag1, newtag2, newtag3
Vocab 13: newtag1, newtag2, newtag3
This is the original issue
For a followup on that issue, here's how the metadata looks:
Project: Subscribe
Component: Code
Category: task
-Priority: normal
+Priority: minor
Assigned to: Anonymous
Status: active
Reported by: a
Updated by: site2
-Vocab 9: Old term
+Vocab 9: New term
-Vocab 10: Javascript, MySQL, pgSQL, IE6, IE7, Safari
+Vocab 10: Javascript, MySQL, pgSQL, IE7, Safari, Firefox
Vocab 11: -IE6 +Firefox
Vocab 12: -oldtag1 , -oldtag2 , -oldtag3 +newtag1 , +newtag2 , +newtag3
Vocab 13: +newtag1 , +newtag2 , +newtag3
Vocab 14: -oldtag1 , -oldtag2 , -oldtag3
This is the first follow up to the issue.
Again, let me point out that the Vocab metadata comes from fake_tesing_module and does not actually make any sense. It is there primarily to demonstrate how metadata changes returned as strings and arrays print out. In the second example, you can compare Vocab 10 and Vocab 11 with one another. Both represent the same terms; in the first case all terms for the vocab are printed, whereas in the second case only the terms that were added/removed are printed.
| Comment | File | Size | Author |
|---|---|---|---|
| #10 | project_issue_code_cleanup.patch | 1.44 KB | aclight |
| #7 | project_issue_metadata.patch | 26.32 KB | hunmonk |
| #6 | project_issue_metadata.patch | 24.93 KB | hunmonk |
| #6 | fake_testing_module.module.txt | 2.26 KB | hunmonk |
| #5 | fake_testing_module.module_.txt | 2.07 KB | aclight |
Comments
Comment #1
webchickSubscribe.
Comment #2
hunmonk commentedi think there are some inconsistencies we need to address:
For display of initial metadata values in the original e-mail sent after an issue is created, your module should implement hook_followup_metadata_changes() and watch for the case where $old_data is emptythis seems weird, and makes me think that we need some more thought to make the handling more consistent.
Comment #3
aclight commentedIn response to the comment above (#2):
They operate on the same kind of metadata but they are doing different things. In the case of hook_project_issue_issue_table_alter(), we're altering metadata displayed in the top "current status" table, whereas in hook_followup_metadata_changes() we're not dealing with *display* of metadata yet but instead with finding differences in metadata. I'm not opposed to changing the names of these hooks, but I can't think of any names that are more descriptive and similarly named. Suggestions?
2. I kept the single row/field theme functions but also created new theme functions that theme the entire metadata table.
I know it's kind of weird but in the email summary table we're not printing just the current metadata values, but instead the changes since the last entry. In the project issue node display, we're actually displaying the current state of all metadata. I'm not sure of a better way to do this, given what our actual goal for the type of metadata to display is.
4. Yep, that was dead code. I've taken it out.
Yeah, the first if clause those two conditionals are pretty similar but the else/elseif clauses are different. I'm not sure that creating a new function to reuse this code will help make the code any clearer overall.
Comment #4
aclight commentedThis patch fixes a few things hunmonk and I talked about in person:
1. Instead of passing the stuff that will go into the tables through check_plain(), I'm now passing it through filter_xss, allowing for a, strong, and em tags. This will pave the wave for potentially allowing links in the metadata table (eg. to a username or something like that), which would be nice.
2. The conditional statements in the mail and table row/field theming functions were't checking for array vs. string every place they needed to be, so fixed that.
3. Fixed a few typos in the code comments.
Still to go: potentially changing name of one or more hooks.
Comment #5
aclight commentedHere's the updated fake_testing_module.module file that uses the a, em, and strong tags.
Also, BTW, don't freak out about the use of strip_tags() in my previous patch. That's only used in mail output and only there to get rid of the tags for display purposes, not for security.
Comment #6
hunmonk commentedk, this is a fairly major rewrite, in an attempt to simplify the hooks we're exposing for this functionality.
tested with and updated version of fake testing module, and it seems to work great. posting that here as well.
Comment #7
hunmonk commentedcouple of cleanups:
Comment #8
aclight commentedI tested hunmonk's most recent patch in #7 with auth and admin users. Worked as expected. Code looks good. I think the changes in the hooks hunmonk made make sense.
Comment #9
hunmonk commentedcommitted to 5.x-2.x, applied to d.o, project.d.o
Comment #10
aclight commentedThere's a little cruft in the code that finally got committed. This patch cleans it up. There are extra parenthesis in the filter_xss calls. More importantly, there is an unnecessary call to check_plain() that will mess up the a, em, and strong tags that filter_xss allows.
Comment #11
hunmonk commentedcode looks good. committed to 5.x-2.x and 5.x-3.x, deployed on d.o et. all
Comment #12
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.