Here is a default View for comments. There is a lot of intelligence here - 3 relationships! You might want to tweak slightly before commit. Add that $flag->name look that you do for the node default View. Search for abuse_comments to see the hard coded flag name.
$view = new view;
$view->name = 'abuse_comments';
$view->description = '';
$view->tag = 'mw';
$view->view_php = '';
$view->base_table = 'comments';
$view->is_cacheable = FALSE;
$view->api_version = 2;
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
$handler = $view->new_display('default', 'Defaults', 'default');
$handler->override_option('relationships', array(
'flag_content_rel' => array(
'label' => 'flag',
'required' => 1,
'flag' => 'abuse_comments',
'user_scope' => 'any',
'id' => 'flag_content_rel',
'table' => 'comments',
'field' => 'flag_content_rel',
'relationship' => 'none',
),
'uid' => array(
'id' => 'uid',
'table' => 'flag_content',
'field' => 'uid',
'relationship' => 'flag_content_rel',
),
'nid' => array(
'label' => 'Node',
'required' => 0,
'id' => 'nid',
'table' => 'comments',
'field' => 'nid',
'override' => array(
'button' => 'Override',
),
'relationship' => 'none',
),
));
$handler->override_option('fields', array(
'subject' => array(
'id' => 'subject',
'table' => 'comments',
'field' => 'subject',
'label' => '',
'link_to_comment' => 1,
'relationship' => 'none',
),
'name' => array(
'label' => 'Name',
'link_to_user' => 1,
'exclude' => 0,
'id' => 'name',
'table' => 'users',
'field' => 'name',
'relationship' => 'uid',
),
));
$handler->override_option('sorts', array(
'timestamp' => array(
'order' => 'DESC',
'granularity' => 'second',
'id' => 'timestamp',
'table' => 'flag_content',
'field' => 'timestamp',
'relationship' => 'flag_content_rel',
'override' => array(
'button' => 'Override',
),
),
));
$handler->override_option('access', array(
'type' => 'none',
'role' => array(),
'perm' => '',
));
$handler->override_option('title', 'Recent comments');
$handler->override_option('items_per_page', 5);
$handler->override_option('use_more', 1);
$handler->override_option('style_plugin', 'table');
$handler->override_option('style_options', array(
'grouping' => '',
'override' => 0,
'sticky' => 1,
'order' => 'asc',
'columns' => array(
'subject' => 'subject',
'name' => 'name',
'timestamp' => 'timestamp',
'ops' => 'ops',
'delete_comment' => 'ops',
'edit_comment' => 'ops',
),
'info' => array(
'subject' => array(
'sortable' => 1,
'separator' => '',
),
'name' => array(
'sortable' => 1,
'separator' => '',
),
'timestamp' => array(
'sortable' => 1,
'separator' => '',
),
'ops' => array(
'separator' => ' | ',
),
'delete_comment' => array(
'separator' => '',
),
'edit_comment' => array(
'separator' => '',
),
),
'default' => '-1',
));
$handler = $view->new_display('page', 'Page', 'page');
$handler->override_option('fields', array(
'subject' => array(
'label' => 'Comment',
'link_to_comment' => 1,
'exclude' => 0,
'id' => 'subject',
'table' => 'comments',
'field' => 'subject',
'relationship' => 'none',
'override' => array(
'button' => 'Use default',
),
),
'title' => array(
'label' => 'Post',
'link_to_node' => 1,
'exclude' => 0,
'id' => 'title',
'table' => 'node',
'field' => 'title',
'relationship' => 'nid',
'override' => array(
'button' => 'Use default',
),
),
'name' => array(
'label' => 'Flagged by',
'link_to_user' => 1,
'exclude' => 0,
'id' => 'name',
'table' => 'users',
'field' => 'name',
'relationship' => 'uid',
'override' => array(
'button' => 'Use default',
),
),
'timestamp' => array(
'id' => 'timestamp',
'table' => 'flag_content',
'field' => 'timestamp',
),
'ops' => array(
'label' => 'Operations',
'exclude' => 0,
'id' => 'ops',
'table' => 'flag_content',
'field' => 'ops',
'relationship' => 'flag_content_rel',
'override' => array(
'button' => 'Use default',
),
),
'delete_comment' => array(
'label' => 'Delete',
'text' => '',
'exclude' => 0,
'id' => 'delete_comment',
'table' => 'comments',
'field' => 'delete_comment',
'override' => array(
'button' => 'Use default',
),
'relationship' => 'none',
),
'edit_comment' => array(
'label' => 'Edit',
'text' => '',
'exclude' => 0,
'id' => 'edit_comment',
'table' => 'comments',
'field' => 'edit_comment',
'override' => array(
'button' => 'Use default',
),
'relationship' => 'none',
),
));
$handler->override_option('items_per_page', 25);
$handler->override_option('use_pager', '1');
$handler->override_option('path', 'abuse/comments');
$handler->override_option('menu', array(
'type' => 'none',
'title' => '',
'weight' => 0,
'name' => 'navigation',
));
$handler->override_option('tab_options', array(
'type' => 'none',
'title' => '',
'weight' => 0,
));
$handler = $view->new_display('block', 'Block', 'block');
$handler->override_option('block_description', 'Recent comments view');
$handler->override_option('block_caching', -1);
Comments
Comment #1
mooffie commentedI'm tending to this.
Comment #2
mooffie commentedMoshe, thanks.
Comment #3
mooffie commentedThat's a starting patch.
I wonder. This view lists all comments together with the user(s) who flagged them. This will cause duplicate records. Won't it be more useful to list the "flag counter" instead of the user who flagged the comment? OTOH, perhaps in communities where the administrator knows the participants, the names could be meaningful.
Comment #4
mooffie commentedI forgot to attach the patch. (It's Moshe's, with some cleanups.)
Comment #5
quicksketchIt seems like a count would be more universally useful than the individual names of the user, imo. Nice work on cleaning up this view also mooffie, it's much better not being tied to an existing flag.
Comment #6
moshe weitzman commentedI agree that count is usually more useful. So, here is the same view but without the relationship to from flag to user and without username field. i added the relationship for flag comment count and the flag count field. Hopefully Moofie work the same magic he did last time to make it generic. Thanks.
Comment #7
mooffie commentedThis won't be so simple.
The "Flag link" field (that is, the "Ops" field) is useless when the flag isn't 'global'. OTOH, when the flag is 'global', it's the "counter" field that's useless (because it'd always show "1").
We can fix this, but tomorrow we'll find some other problem ("Hey, shouldn't we sort by the flag counter, descending?").
In other words, the problem is: Programmers need to work quite hard to convert an "exported view" to a "default view". There's some cleaning up to do. And when they discover some error, they need to repeat this tedious process.
Remember that we've yet to provide a "Who's bookmarked this" view.
So I think a better approach is to stop and instead build some tool to automate the process of converting an exported view to a default view that can be shipped.
Comment #8
moshe weitzman commentedYeah, I feel a similar pain in og module. Perhaps you are willing to commit the original View that you converted since thats still valid? If not, we can wait for the arrival of your export tweaker. No big deal.
Comment #9
mooffie commentedIts "flag/unflag" link doesn't make sense for non-global flags. The admin would exect this link to remove a comment from the "spam" list, but it wouldn't.
I believe it will be quite soon, because, I believe, it'd be a very simple script ("Famous Last Words"? :-).
Comment #10
mooffie commentedBTW, there's an issue discussing this limitation in our module:
#327901: Action: clearing a node's flaggings
(In short: admin has no way to clear a node's flaggings.)
Comment #11
mooffie commentedNo, I decided not to execute this "ingenious" plan of mine. Programmers will have to waste their time studying my tool (and they probably won't be inclined to do this) instead of wasting it tweaking Views' exported views. So no time will be saved.
Comment #12
mooffie commentedWe'll have to provide two views: one for global flags, one for non-globals.
Comment #13
quicksketchNow that we have the ability to expose default flags, I'd encourage this to be a "prepackaged" module that simply defines an offensive flag and the default views to match it. We're moving in the other direction of simplifying and reducing the default views, rather than bundling several more.
Comment #14
mooffie commentedGreat.
Alternatively, this issue could be regarded as a duplicate of #327901: Action: clearing a node's flaggings.
Comment #15
sirkitree commentedI've also used this to provide offensive flags, for node, user and comment along with default views.
The admin clearing functionality still exists, but at least they're aware of what is going on and can edit the flagged item if needed thus far. I can attach what I've done so far if anyone is interested.
Comment #16
dnewkerk commentedSince I'm looking to test any patch that comes out for this, just following this issue as well in case anything further gets discussed here.