Posted by pwiniacki on February 18, 2012 at 12:00am
4 followers
| Project: | Domain Access |
| Version: | 7.x-3.x-dev |
| Component: | Code |
| Category: | feature request |
| Priority: | major |
| Assigned: | Unassigned |
| Status: | needs work |
Issue Summary
I'm using simply views block to display latest user comments. But the link to the comment always start with the current domain path. This is wrong cause it allow to see comments from other domains (with should be disallow). I have tried to add Domain Source: Domain Source ID, Domain Access: Domain ID and so on, but without any results.
$view = new view;
$view->name = 'user_latest_content';
$view->description = 'user_latest_content';
$view->tag = 'default';
$view->base_table = 'comment';
$view->human_name = 'user_latest_content';
$view->core = 7;
$view->api_version = '3.0';
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
/* Display: Master */
$handler = $view->new_display('default', 'Master', 'default');
$handler->display->display_options['title'] = 'User Latest Comments/Posts:';
$handler->display->display_options['access']['type'] = 'perm';
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['query']['options']['query_comment'] = FALSE;
$handler->display->display_options['exposed_form']['type'] = 'basic';
$handler->display->display_options['pager']['type'] = 'some';
$handler->display->display_options['pager']['options']['items_per_page'] = '5';
$handler->display->display_options['pager']['options']['offset'] = '0';
$handler->display->display_options['style_plugin'] = 'default';
$handler->display->display_options['row_plugin'] = 'fields';
/* Relationship: Comment: Author */
$handler->display->display_options['relationships']['uid']['id'] = 'uid';
$handler->display->display_options['relationships']['uid']['table'] = 'comment';
$handler->display->display_options['relationships']['uid']['field'] = 'uid';
$handler->display->display_options['relationships']['uid']['required'] = 1;
/* Relationship: Comment: Content */
$handler->display->display_options['relationships']['nid']['id'] = 'nid';
$handler->display->display_options['relationships']['nid']['table'] = 'comment';
$handler->display->display_options['relationships']['nid']['field'] = 'nid';
$handler->display->display_options['relationships']['nid']['required'] = 0;
/* Field: Comment: Title */
$handler->display->display_options['fields']['subject']['id'] = 'subject';
$handler->display->display_options['fields']['subject']['table'] = 'comment';
$handler->display->display_options['fields']['subject']['field'] = 'subject';
$handler->display->display_options['fields']['subject']['label'] = '';
$handler->display->display_options['fields']['subject']['alter']['alter_text'] = 0;
$handler->display->display_options['fields']['subject']['alter']['make_link'] = 0;
$handler->display->display_options['fields']['subject']['alter']['absolute'] = 0;
$handler->display->display_options['fields']['subject']['alter']['external'] = 0;
$handler->display->display_options['fields']['subject']['alter']['replace_spaces'] = 0;
$handler->display->display_options['fields']['subject']['alter']['trim_whitespace'] = 0;
$handler->display->display_options['fields']['subject']['alter']['nl2br'] = 0;
$handler->display->display_options['fields']['subject']['alter']['word_boundary'] = 0;
$handler->display->display_options['fields']['subject']['alter']['ellipsis'] = 0;
$handler->display->display_options['fields']['subject']['alter']['strip_tags'] = 0;
$handler->display->display_options['fields']['subject']['alter']['trim'] = 0;
$handler->display->display_options['fields']['subject']['alter']['html'] = 0;
$handler->display->display_options['fields']['subject']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['subject']['element_default_classes'] = 1;
$handler->display->display_options['fields']['subject']['hide_empty'] = 0;
$handler->display->display_options['fields']['subject']['empty_zero'] = 0;
$handler->display->display_options['fields']['subject']['hide_alter_empty'] = 1;
$handler->display->display_options['fields']['subject']['link_to_comment'] = 1;
$handler->display->display_options['fields']['subject']['link_to_node'] = 0;
/* Sort criterion: Comment: Post date */
$handler->display->display_options['sorts']['created']['id'] = 'created';
$handler->display->display_options['sorts']['created']['table'] = 'comment';
$handler->display->display_options['sorts']['created']['field'] = 'created';
$handler->display->display_options['sorts']['created']['order'] = 'DESC';
$handler->display->display_options['sorts']['created']['granularity'] = 'minute';
/* Contextual filter: User: Uid */
$handler->display->display_options['arguments']['uid']['id'] = 'uid';
$handler->display->display_options['arguments']['uid']['table'] = 'users';
$handler->display->display_options['arguments']['uid']['field'] = 'uid';
$handler->display->display_options['arguments']['uid']['relationship'] = 'uid';
$handler->display->display_options['arguments']['uid']['default_action'] = 'default';
$handler->display->display_options['arguments']['uid']['default_argument_type'] = 'user';
$handler->display->display_options['arguments']['uid']['default_argument_options']['user'] = FALSE;
$handler->display->display_options['arguments']['uid']['default_argument_skip_url'] = 0;
$handler->display->display_options['arguments']['uid']['summary']['number_of_records'] = '0';
$handler->display->display_options['arguments']['uid']['summary']['format'] = 'default_summary';
$handler->display->display_options['arguments']['uid']['summary_options']['items_per_page'] = '25';
$handler->display->display_options['arguments']['uid']['break_phrase'] = 0;
$handler->display->display_options['arguments']['uid']['not'] = 0;
/* Filter criterion: Comment: Approved */
$handler->display->display_options['filters']['status']['id'] = 'status';
$handler->display->display_options['filters']['status']['table'] = 'comment';
$handler->display->display_options['filters']['status']['field'] = 'status';
$handler->display->display_options['filters']['status']['value'] = 1;
$handler->display->display_options['filters']['status']['group'] = 0;
$handler->display->display_options['filters']['status']['expose']['operator'] = FALSE;
/* Filter criterion: Content: Published */
$handler->display->display_options['filters']['status_node']['id'] = 'status_node';
$handler->display->display_options['filters']['status_node']['table'] = 'node';
$handler->display->display_options['filters']['status_node']['field'] = 'status';
$handler->display->display_options['filters']['status_node']['relationship'] = 'nid';
$handler->display->display_options['filters']['status_node']['value'] = 1;
$handler->display->display_options['filters']['status_node']['group'] = 0;
$handler->display->display_options['filters']['status_node']['expose']['operator'] = FALSE;
/* Filter criterion: Content translation: Language */
$handler->display->display_options['filters']['language']['id'] = 'language';
$handler->display->display_options['filters']['language']['table'] = 'node';
$handler->display->display_options['filters']['language']['field'] = 'language';
$handler->display->display_options['filters']['language']['relationship'] = 'nid';
$handler->display->display_options['filters']['language']['value'] = array(
'***CURRENT_LANGUAGE***' => '***CURRENT_LANGUAGE***',
);
$handler->display->display_options['filters']['language']['group'] = '0';
/* Display: Block */
$handler = $view->new_display('block', 'Block', 'block');If I set node source as subdomain2 then link to the comment should look http://www.subdomain2.mypage.com/comment/6247#comment-6247 and not http://www.subdomain(1 or 3).mypage.com/comment/6247#comment-6247
Please test it. Maybe I do set views wrong or simply misunderstood DAviews behavior ? Any advice is much appreciated.
Comments
#1
The problem is that DA doesn't know how to look up the path for direct comment links, only nodes.
#2
I tried to change that with no luck, anyway its nice feature request then.
#3
This would have to go into the main module.
The idea is that we need to map
comment/%cid/viewand related paths to lookup the canonical domain of the nodes those comments are attached to.#4
#5
I just tried to add similar functionality on my site but without good results. I guess it won't be possible till 'we' 'fix' DA.
#6
Did you try using hook_domain_source_path_alter()?
#7
I guess he used hook_domain_source_alter()... ? Gona check this and post an answer.
#8
hook_domain_source_alter() only runs on node paths, this is explained in domain.api.php.
#9
You were right about hook_domain_source_path_alter() I don't know what goes wrong but he wasn't able to close this issue. When he goes back from trip I will call him to the blackboard.
#10
Here's a patch that adds support for comment URLs. Could really use a good test.
#11
I was away for a few days. I'm gonna find some time and test it. THX agent !
EDIT: This is working great ! All comment links to proper domains with proper language affix. Amazing job - tested on localhost drupal 7.15 and domain access 7.x-3.3. More live tests are coming !
EDIT2: Everything goes extremely well. There is proper link for comments to domain they belong to. Even if you try some specific options like - Publish to and - Source domain everything is working as intended. This is working with forum comments to (however not with forum topics - forum nodes - itself cause they are nodes not comments).
#12
Thanks!
Have you noticed any performance slowdown? I'd still like to get an automated test here, too.
#13
Nope I didn't notice any performance slowdown. But honestly I was exited that it works just fine and my eyes were not direct on performance issues.
#14
I have test it, it's working !
#15
The tests are almost ready, but the last two fail.
#16
@agentrickard your patch is working with DA 3.3 I'm using it for a long time with a good result. I didn't test it with newest version of DA. However I'm in need to upgrade one of my site to 7.18 so it will be a good opportunity to upgrade DA too and test it. I'm not a programmer so I won't help with a code but I can write here if errors were found.
#17
Thanks. I think the code is fine, we just needs automated tests for maintainability.