Seems like no matter what I do I get multiple notes if my node has been flagged more than once. I have attached a screenshot of a my exported view of a node with 2 flags. I am not sure how to being fixing this. Here is my exported view:
$view = new view;
$view->name = 'content_flagged_for_review';
$view->description = 'Content Flagged For Review';
$view->tag = '';
$view->view_php = '';
$view->base_table = 'node';
$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' => 'flag_for_review',
'user_scope' => 'any',
'id' => 'flag_content_rel',
'table' => 'node',
'field' => 'flag_content_rel',
'relationship' => 'none',
),
'flag_count_rel' => array(
'label' => 'counter',
'required' => 1,
'flag' => 'flag_for_review',
'id' => 'flag_count_rel',
'table' => 'node',
'field' => 'flag_count_rel',
'relationship' => 'none',
),
'flag_note_node_rel' => array(
'label' => 'Flag note on node',
'required' => 1,
'flag' => 'flag_for_review',
'user_scope' => 'any',
'id' => 'flag_note_node_rel',
'table' => 'node',
'field' => 'flag_note_node_rel',
'relationship' => 'none',
),
'flag_note_content_rel' => array(
'label' => 'flag_note_conent',
'required' => 1,
'id' => 'flag_note_content_rel',
'table' => 'flag_note',
'field' => 'flag_note_content_rel',
'relationship' => 'flag_note_node_rel',
),
));
$handler->override_option('fields', array(
'count' => array(
'label' => 'Flag Count',
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => '',
'link_class' => '',
'alt' => '',
'prefix' => '',
'suffix' => '',
'target' => '',
'help' => '',
'trim' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,
'html' => 0,
'strip_tags' => 0,
),
'empty' => '',
'hide_empty' => 0,
'empty_zero' => 0,
'set_precision' => FALSE,
'precision' => 0,
'decimal' => '.',
'separator' => ',',
'prefix' => '',
'suffix' => '',
'exclude' => 0,
'id' => 'count',
'table' => 'flag_counts',
'field' => 'count',
'relationship' => 'flag_count_rel',
),
'nid' => array(
'label' => 'Nid',
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => '',
'link_class' => '',
'alt' => '',
'prefix' => '',
'suffix' => '',
'target' => '',
'help' => '',
'trim' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,
'html' => 0,
'strip_tags' => 0,
),
'empty' => '',
'hide_empty' => 0,
'empty_zero' => 0,
'link_to_node' => 0,
'exclude' => 1,
'id' => 'nid',
'table' => 'node',
'field' => 'nid',
'relationship' => 'none',
),
'title' => array(
'label' => '',
'alter' => array(
'alter_text' => 1,
'text' => '[title]',
'make_link' => 0,
'path' => 'node/[nid]/edit?destination=my-account',
'link_class' => '',
'alt' => '',
'prefix' => '',
'suffix' => '',
'target' => '',
'help' => '',
'trim' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,
'html' => 0,
'strip_tags' => 0,
),
'empty' => '',
'hide_empty' => 0,
'empty_zero' => 0,
'link_to_node' => 1,
'exclude' => 0,
'id' => 'title',
'table' => 'node',
'field' => 'title',
'relationship' => 'none',
),
'type' => array(
'label' => 'Content Type',
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => '',
'link_class' => '',
'alt' => '',
'prefix' => '',
'suffix' => '',
'target' => '',
'help' => '',
'trim' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,
'html' => 0,
'strip_tags' => 0,
),
'empty' => '',
'hide_empty' => 0,
'empty_zero' => 0,
'link_to_node' => 0,
'machine_name' => 0,
'exclude' => 0,
'id' => 'type',
'table' => 'node',
'field' => 'type',
'relationship' => 'none',
),
'timestamp' => array(
'label' => 'Last Flagged',
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => '',
'link_class' => '',
'alt' => '',
'prefix' => '',
'suffix' => '',
'target' => '',
'help' => '',
'trim' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,
'html' => 0,
'strip_tags' => 0,
),
'empty' => '',
'hide_empty' => 0,
'empty_zero' => 0,
'date_format' => 'time ago',
'custom_date_format' => '',
'exclude' => 0,
'id' => 'timestamp',
'table' => 'flag_content',
'field' => 'timestamp',
'relationship' => 'flag_content_rel',
),
'note' => array(
'label' => 'Flagged Reason',
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => '',
'link_class' => '',
'alt' => '',
'prefix' => '',
'suffix' => '',
'target' => '',
'help' => '',
'trim' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,
'html' => 0,
'strip_tags' => 0,
),
'empty' => '',
'hide_empty' => 0,
'empty_zero' => 0,
'exclude' => 0,
'id' => 'note',
'table' => 'flag_note',
'field' => 'note',
'relationship' => 'flag_note_node_rel',
),
));
$handler->override_option('sorts', array(
'timestamp' => array(
'order' => 'DESC',
'granularity' => 'second',
'id' => 'timestamp',
'table' => 'flag_content',
'field' => 'timestamp',
'relationship' => 'flag_content_rel',
),
));
$handler->override_option('filters', array(
'status' => array(
'operator' => '=',
'value' => '1',
'group' => '0',
'exposed' => FALSE,
'expose' => array(
'operator' => FALSE,
'label' => '',
),
'id' => 'status',
'table' => 'node',
'field' => 'status',
'relationship' => 'none',
),
'flagged' => array(
'operator' => '=',
'value' => '1',
'group' => '0',
'exposed' => FALSE,
'expose' => array(
'operator' => FALSE,
'label' => '',
),
'id' => 'flagged',
'table' => 'flag_content',
'field' => 'flagged',
'relationship' => 'flag_content_rel',
),
));
$handler->override_option('access', array(
'type' => 'none',
));
$handler->override_option('cache', array(
'type' => 'none',
));
$handler->override_option('title', 'Content Flagged For Review');
$handler->override_option('header', '<div class="info-container">
<a href="#" class="more_info">More Info</a>
<div class="long-description">This content has been flagged for review by users. This is done if users deem your content outdated, inaccurate, or offensive. Please click the \'title\' to edit the content and check for any errors, after editing the flags will be cleared and your content will be published normally.</div>
</div>');
$handler->override_option('header_format', '2');
$handler->override_option('header_empty', 0);
$handler->override_option('distinct', 1);
$handler->override_option('style_plugin', 'table');
$handler->override_option('style_options', array(
'grouping' => '',
'override' => 1,
'sticky' => 0,
'order' => 'asc',
'columns' => array(
'count' => 'count',
'nid' => 'nid',
'title' => 'title',
'type' => 'type',
'timestamp' => 'timestamp',
'note' => 'note',
),
'info' => array(
'count' => array(
'sortable' => 0,
'separator' => '',
),
'nid' => array(
'sortable' => 0,
'separator' => '',
),
'title' => array(
'sortable' => 0,
'separator' => '',
),
'type' => array(
'sortable' => 0,
'separator' => '',
),
'timestamp' => array(
'sortable' => 0,
'separator' => '',
),
'note' => array(
'sortable' => 0,
'separator' => '',
),
),
'default' => '-1',
));
$handler = $view->new_display('block', 'Block', 'block_1');
$handler->override_option('relationships', array(
'flag_note_node_rel' => array(
'label' => 'Flag note on node',
'required' => 1,
'flag' => 'flag_for_review',
'user_scope' => 'any',
'id' => 'flag_note_node_rel',
'table' => 'node',
'field' => 'flag_note_node_rel',
'relationship' => 'none',
),
'flag_note_content_rel' => array(
'label' => 'flag_note_conent',
'required' => 1,
'id' => 'flag_note_content_rel',
'table' => 'flag_note',
'field' => 'flag_note_content_rel',
'relationship' => 'flag_note_node_rel',
),
'flag_content_rel' => array(
'label' => 'flag',
'required' => 1,
'flag' => 'flag_for_review',
'user_scope' => 'any',
'id' => 'flag_content_rel',
'table' => 'node',
'field' => 'flag_content_rel',
'override' => array(
'button' => 'Use default',
),
'relationship' => 'none',
),
));
$handler->override_option('fields', array(
'nid' => array(
'label' => 'Nid',
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => '',
'link_class' => '',
'alt' => '',
'prefix' => '',
'suffix' => '',
'target' => '',
'help' => '',
'trim' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,
'html' => 0,
'strip_tags' => 0,
),
'empty' => '',
'hide_empty' => 0,
'empty_zero' => 0,
'link_to_node' => 0,
'exclude' => 1,
'id' => 'nid',
'table' => 'node',
'field' => 'nid',
'relationship' => 'none',
),
'title' => array(
'label' => '',
'alter' => array(
'alter_text' => 1,
'text' => '[title]',
'make_link' => 0,
'path' => 'node/[nid]/edit?destination=my-account',
'link_class' => '',
'alt' => '',
'prefix' => '',
'suffix' => '',
'target' => '',
'help' => '',
'trim' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,
'html' => 0,
'strip_tags' => 0,
),
'empty' => '',
'hide_empty' => 0,
'empty_zero' => 0,
'link_to_node' => 1,
'exclude' => 0,
'id' => 'title',
'table' => 'node',
'field' => 'title',
'relationship' => 'none',
),
'type' => array(
'label' => 'Content Type',
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => '',
'link_class' => '',
'alt' => '',
'prefix' => '',
'suffix' => '',
'target' => '',
'help' => '',
'trim' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,
'html' => 0,
'strip_tags' => 0,
),
'empty' => '',
'hide_empty' => 0,
'empty_zero' => 0,
'link_to_node' => 0,
'machine_name' => 0,
'exclude' => 0,
'id' => 'type',
'table' => 'node',
'field' => 'type',
'relationship' => 'none',
),
'note' => array(
'label' => 'Flagged Reason',
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => '',
'link_class' => '',
'alt' => '',
'prefix' => '',
'suffix' => '',
'target' => '',
'help' => '',
'trim' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,
'html' => 0,
'strip_tags' => 0,
),
'empty' => '',
'hide_empty' => 0,
'empty_zero' => 0,
'exclude' => 0,
'id' => 'note',
'table' => 'flag_note',
'field' => 'note',
'relationship' => 'flag_note_node_rel',
),
'timestamp' => array(
'label' => 'Note created time',
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => '',
'link_class' => '',
'alt' => '',
'prefix' => '',
'suffix' => '',
'target' => '',
'help' => '',
'trim' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,
'html' => 0,
'strip_tags' => 0,
),
'empty' => '',
'hide_empty' => 0,
'empty_zero' => 0,
'date_format' => 'small',
'custom_date_format' => '',
'exclude' => 0,
'id' => 'timestamp',
'table' => 'flag_note',
'field' => 'timestamp',
'relationship' => 'flag_note_node_rel',
'override' => array(
'button' => 'Use default',
),
),
));
$handler->override_option('arguments', array(
'nid' => array(
'default_action' => 'default',
'style_plugin' => 'default_summary',
'style_options' => array(),
'wildcard' => 'all',
'wildcard_substitution' => 'All',
'title' => '',
'breadcrumb' => '',
'default_argument_type' => 'node',
'default_argument' => '',
'validate_type' => 'none',
'validate_fail' => 'not found',
'break_phrase' => 0,
'not' => 0,
'id' => 'nid',
'table' => 'node',
'field' => 'nid',
'validate_user_argument_type' => 'uid',
'validate_user_roles' => array(
'2' => 0,
'4' => 0,
'5' => 0,
'3' => 0,
),
'me_redirect' => 0,
'me_validate_user_argument_type' => 'uid',
'me_validate_user_roles' => array(
'2' => 0,
'4' => 0,
'5' => 0,
'3' => 0,
),
'override' => array(
'button' => 'Use default',
),
'relationship' => 'none',
'default_options_div_prefix' => '',
'default_argument_image_size' => '_original',
'default_argument_fixed' => '',
'default_argument_user' => 0,
'default_argument_php' => '',
'validate_argument_node_flag_name' => '*relationship*',
'validate_argument_node_flag_test' => 'flaggable',
'validate_argument_node_flag_id_type' => 'id',
'validate_argument_user_flag_name' => '*relationship*',
'validate_argument_user_flag_test' => 'flaggable',
'validate_argument_user_flag_id_type' => 'id',
'image_size' => array(
'_original' => '_original',
'thumbnail' => 'thumbnail',
'preview' => 'preview',
),
'validate_argument_node_type' => array(
'ad' => 0,
'image' => 0,
'product' => 0,
'banner' => 0,
'panel' => 0,
'event' => 0,
'group_class_event' => 0,
'page' => 0,
'renew_expired_banner_ad' => 0,
'story' => 0,
'studio_listing' => 0,
),
'validate_argument_node_access' => 0,
'validate_argument_nid_type' => 'nid',
'validate_argument_vocabulary' => array(
'1' => 0,
),
'validate_argument_type' => 'tid',
'validate_argument_transform' => 0,
'validate_user_restrict_roles' => 0,
'validate_argument_php' => '',
'me_validate_user_restrict_roles' => 0,
),
));
$handler->override_option('distinct', 0);
$handler->override_option('block_description', '');
$handler->override_option('block_caching', -1);
Comments
Comment #1
gunzip commenteddo you mean, even with "disable flag history" option, if the note is flagged multiple time by the same user
you get multiple notes ? can you please tell the flag module version and the flag note one ? thank you.
Comment #2
twistedindustries commentedI do have the disable flag history option checked and this problem is when multiple users flag the same node. I am trying to show each time the node was flagged and for what reason to the node's author. I am using flag 6.x-1.3 and I am currently using flag note 6.x-dev but the 6.x-1.1 is doing the same thing. Thanks for your help.
Comment #3
gunzip commentedI've tried importing the view and i cannot replicate the issue. I get only one row with flag count = 2
(because i've flagged the node twice, once for two different users). The generated query follows.
and in the database i've got 2 rows into the flag_note table.
Tested with flag_6.x-1.3 and flag_note-6.x-1.x-dev.
Have you got a sandbox to do some debugging ?
Comment #4
twistedindustries commentedYes your right I'm sorry I must have somehow uploaded the Wong view. Here is where it isn't working right. "Wacky" was flagged before "not right". Select distinct kind of helped but still not as expected. Here is my query:
Comment #5
gunzip commentedif you add "distinct = yes" to the view it should add a "GROUP BY nid" clause so I cannot see from the query above how you still get multiple rows for one nid. can you paste the generated query with the distinct applied ? even more, if you have a vanilla database (ie. a db with whom i can reproduce the issue) may you please provide it someway ? thank you.
Comment #6
twistedindustries commentedYour right it does add the "GROUP BY nid". But then it only returns the most recent flag for 'flag note' with the first time it was flagged for 'flagged time'. Is that right? I want something that shows more of a history, notes with the time they where entered. Is that possible? I can give you a copy of my test database.
Here is that query
Comment #7
gunzip commentedit would be easier indeed if you can provide your db to me somehow.
anyway, probably what you're trying to do is possible through the use of the views group by module:
http://drupal.org/project/views_groupby
or http://drupal.org/project/views_calc
Comment #8
gunzip commentedComment #9
hanoiiI was about to post an issue about this and find this, I am also seeing the duplicate notes and the problem is in the query, or maybe on the way the relationships are set up.
I tried quite a bit to work around this and even though I eventually can get the proper data, I am then missing a few things as well.
So, I have two flag_notes of a content flagged by two different users.
The relationship on my views is as follows:
- Flags: abuse_node by any user
- (flag) Flags: User
- Flag note: abuse_node by any user
- (Flag note on node) Flag note: Predefined note
Which basically means get all abuse_node flags, link them to the user that flagged the, add a flag note relationship and then relate them to the predefined note.
What you say on #3 is fine but I cannot add DISTINCT as I actually wants to dislpay all notes of different users for the same content, so I shouldn't be grouping them by nid. If you take out DISTINCT you will probably see for rows in that query.
The problem is in the independent flag_note relationship which emulates the flag relationship and creates an independent join.
By looking at #3 again which is very similar to what I have have a look at this two joins:
The two of them together creates ^2 rows, because the first JOIN generates 2 rows, and the second join will generate 2 rows per each of the previous rows, thus, 2^2 = 4 rows.
I tried different things here but still can't figure out how to fix it. One way I tried is to remove actual flag relationships and only use the flag_note_relationship as most of the data is there. This worked as far as retrieving the only rows on the flag_note table, the problem I found with this is when I want to use certain Flag fields, like Flag:links, and even though I tried relating flags to flags_note (the opposite of what I said before) with your
flag_note_content_rel, that's not working fine because the flag fields handler adds all soft of things to the query making this to fail.The SQL way to fix this is to have the second JOIN use another join field such as the user id, but I am not sure how or where this should be added and whether this will work for every use case. I have an ok knowledge of views but this one is proving to be quite odd.
Something like :
This is addition has to be only added if the relationship is configured like it was mentioned here.
I think I will manually add the SQL on a helper module for now, but it might be good to try to fix this in the 'proper' way
Comment #10
gunzip commentedfirst, sorry for the delay and thank you for the very in-depth analysis.
as you've said flag note discourages the use of flag module realationships, but I see, sometimes these are a requirement (as in your case) and you're right when you point out that the real issue is "the flag fields handler adds all soft of things to the query making this to fail".
maybe we could put a tag "flag_note" on the view and a view alter hook to apply there, or it's possible to do it with some view handler, i have to investigate this as it seems not and easy task to accomplish in a clean way, I'll put updates here.
Comment #11
asb commentedAny updates on this issue?
Comment #12
soulfroysPlease, does someone managed to fix this?
Comment #13
WadimKo51 commentedHello
I'll try to describe the same problem with duplicate content, and try to describe the conditions under which they appear.
The site has a complaints system with flag comment, your module is used to describe the cause of the complaint.
There is a task to create views which will display the field in the user profile in the tab menu
and it will show a list of complaints to the owner of the profile.
The list must be a field.
(Flag note on comment) Flag note: Note created time
Comment: Title
(Flag note on comment) Flag note: Note text
User: Name (user login which left flag, this my problem)
but the problem is that the name of the complainant is not possible to infer from the relationship using only flag_note To display the name of the complainant must establish (flag) Flags: User then create a field User: Name of the field in the settings and Relationships: select Flag user.
But the problem is that the relationship (flag) Flags: User not created without the use of Flags: flag_name, it is not in the list to select when creating, without first creating Flags: flag_name.
So, to bring the list of names of those who have left the flag you need two Relationships
1 Flag note: no_comment by any user
2 Flags: no_comment by any user
only then can we deduce
3 (flag) Flags: User
and select the field User: Name in settings which are set Relationships: Flag user
Just to filter comments created the Owner Profile viewed using fourth Relationships
4 Comment: User further Arguments User: Uid
Action to take if argument is not present: Provide default argument -> User ID from URL
and a link to the page user /% / track / abuses-to-my
With this configuration, if two different users have complained of the same comment, it turns duplication.
Of all described only one question, how to get the Relationships Flags: User not using 2 Flags: no_comment by any user? to create a fild in which to User: Name the author who send the flag
Thank you.