Closed (fixed)
Project:
OG User Roles
Version:
5.x-2.8
Component:
Code
Priority:
Normal
Category:
Task
Assigned:
Reporter:
Created:
10 May 2008 at 18:51 UTC
Updated:
24 May 2008 at 18:54 UTC
Several changes need to be made to the OGR module for new TAC/OG integration. The new TAC/OG Integration instructions are here: http://groups.drupal.org/node/3700
OGR now uses this table to create it's own node grants realm: ogr_access
In fact, hook_nodeapi('access') no longer used for TAC/OG Integration.
ogr_db_rewrite_sql
ogr_node_access_join_sql
ogr_node_access_where_sql
ogr_tac_db_rewrite_sql
/*
* Implementation of hook_node_grants
*/
function og_user_roles_node_grants($account, $op) {
$array = array('ogr_access' => array());
$result = db_query("SELECT ogr_id FROM {og_users_roles} WHERE uid = %d", $account->uid);
while ($row = db_fetch_object($result)) {
$array['ogr_access'][] = $row->ogr_id;
}
return !empty($array['ogr_access']) ? $array : NULL;
}
/*
* Implementation of hook_node_access_records
*/
function og_user_roles_node_access_records($node) {
$grants = array();
if (variable_get('og_user_roles_tac_og_value', 0) == 1) {
// we need to explicitly label public nodes it seems. OG doesn't label nodes
// of types it doesn't apply to, or the "implicitly public" nodes created by
// leaving all the audience checkboxes blank.
// From: http://drupal.org/node/234087#comment-788876
if (og_is_omitted_type($node->type) || (is_array($node->og_groups) && count($node->og_groups) === 0) || (!is_array($node->og_groups) && !og_is_group_type($node->type))) {
$grants[] = array (
'realm' => 'og_public',
'gid' => 0,
'grant_view' => 1,
'grant_update' => 0,
'grant_delete' => 0 );
}
// This creates all ogr grants
$where = "WHERE ta.rid = ogr.rid AND n.nid = ".$node->nid;
$result = db_query("SELECT n.nid, ta.rid, ogr.ogr_id, BIT_OR(ta.grant_view) AS grant_view, BIT_OR(ta.grant_update) AS grant_update, BIT_OR(ta.grant_delete) AS grant_delete FROM {term_node} n INNER JOIN {term_access} ta ON n.tid = ta.tid INNER JOIN {og_ancestry} oa ON n.nid = oa.nid INNER JOIN {og_users_roles} ogr ON oa.group_nid = ogr.gid $where GROUP BY n.nid, ta.rid");
while($row = db_fetch_object($result)) {
if ($row) {
$grant_view = ($row->grant_view == 1) ? 1 : 0;
$grant_update = ($row->grant_update == 1) ? 1 : 0;
$grant_delete = ($row->grant_delete == 1) ? 1 : 0;
$grants[] = array(
'realm' => 'ogr_access',
'gid' => $row->ogr_id,
'grant_view' => $grant_view,
'grant_update' => $grant_update,
'grant_delete' => $grant_delete,
'priority' => 0,
);
}
}
return $grants;
}
}
Comments
Comment #1
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.