Info about group on non accessible post
igorik - June 21, 2009 - 10:41
| Project: | Organic groups |
| Version: | 6.x-2.x-dev |
| Component: | og_access.module |
| Category: | support request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Jump to:
Description
Hi
I have a block with the latest comments including comments from all group.
If some user click on link to comment to non public post to group where he/she is not member, he got only info "Access denied"
but no info about group, and joining to it.
The second thing is that I would like to change the text "Access denied" to "This is private post - /name of the post/, You have to join to this group first if you want to read it"
Can you please help me how I can display my own blocks with info about group and joining link on this page, and change the text "Access denied" to other text?
Thanks
Igorik
http://www.somvprahe.sk

#1
Hi
I have a big progress with customize no access page on og non public post.
I created own node and set it on admin/settings/error-reporting for no access page.
In this node I can fetch required url
<?php$internal_path = $_REQUEST['destination'];
$url_args = explode('/', $internal_path);
?>
Then I can test if $url_args[0] == 'node' && is_numeric($url_args[1])
and load required node where user has no access
node_load($url_args[1])Then I see if $node[og_groups] or $node[og_groups_both] has some value and I can compare it with logged user. Till now ok.
But I tried to find it using og_determine_context not using $node[og_groups] , because I think that it is more right way.
but I have no success. og_determine_context() is used for the loaded no access node.
I found that og_determine_context use at first menu_get_item (and now it is relative for loaded no access node)
so tried to change it with this:
$path = $_GET['q'];$internal_path = $_REQUEST['destination'];
menu_set_item($path , menu_get_item($internal_path) );
but I have no success. (Maybe it can't be changed from inside node?)
Can you help me with this pls? How I can change menu item and let og_determine_context use another url in menu_get_item ?
Thanks
Igor
#2
Just curious you gave up or found a solution? I am facing the same issues and trying to find a solution.
#3
Hi
yes, i resolve it this way, I am using in that error page this code
<?php
$current_url = $_REQUEST['q'];
$internal_path = drupal_lookup_path('source', $current_url);
$url_args = explode('/', $internal_path);
if ( $url_args[0]=='node' && is_numeric($url_args[1]) ) {
$required_node = node_load($url_args[1]);
if(module_exists('og')){
if ( isset($required_node->og_groups) ) {
$group_list = array(); //nemusi byt
foreach ($required_node->og_groups as $key) {
$group_list[] .= $key;
}
$group_context = node_load($group_list[0]);
if (isset($node->og_public) && $node->og_public == 1) {
} else {
//if user is member of this group
if( isset($user->og_groups[$group_context->nid]) ) {
} else {
print '<h2>Article ' . $required_node->title .
' is private.<br /><br />You have to be <br />a member of group ' . l($group_context->title, $group_context->path);
switch($group_context->og_selective) {
case OG_MODERATED:
$content .= 'This group is moderated, ask for membership.';
break;
case OG_OPEN:
$content .= 'This group is open.';
break;
case OG_INVITE_ONLY:
$content .= 'You have to be invite to this group';
break;
case OG_CLOSED:
$content .= 'This group is closed.';
break;
}
$subsc_link = og_subscribe_link($group_context);
print '<br /><br />' .$content . $subsc_link;
print '</h2>';
}
}
}
}
?>