[development] private areas inside Organic Groups

Lluís enboig at gmail.com
Mon Mar 23 12:30:50 UTC 2009


I am developing a module to enable private sections inside any organic
group. The idea is to be able to create a group and define areas like
"paper administration", "human resources", etc...

I have created a module to create and a block to choose be able to
define "staff roles" inside a OG, so now when a user create a node and
have a "staff role" activated, that role should only be visible for
users inside this group and with the "staff role" activated. I supose
I can achieve this using hook_node_grants and
hook_node_access_records, but I don't get how, could anybody give me a
hint?


My nodes are saved with:
realm= 'staff1'
gid=4
view=1
update=1
delete=1

function ogsubroles_node_grants($account, $op) {
   $grup=og_get_group_context();
  if ($_SESSION['ogsubrole_active_'.$grup->nid]) {
    $grants[$_SESSION['ogsubrole_active_'.$grup->nid]] = array(1);
    return $grants; //sempre hem de retornar alguna cosa per fer que
els no valids no es mostrin
  }
  $grants['staff1']=array(1);
  $grants['4']=array(1);
  $grants['view']=array(1);
  return $grants;
}


function ogsubroles_node_access_records($node) {
  $result = db_query('SELECT * FROM {ogsubroles_nodes} WHERE vid =
%d', $node->vid);
  while ($grant = db_fetch_object($result)) {
    $grants[] = array(
      'realm' => $grant->subrole_code,
      'gid' => $grant->gid,
      'grant_view' => 1, //$grant->grant_view,
      'grant_update' => 1, // $grant->grant_update,
      'grant_delete' => 1, //$grant->grant_delete,
    );
  }
  return $grants;
}


-- 
*La vida és com una taronja, que esperes a exprimir-la?
*Si creus que l'educació és cara, prova la ignorància.
*La vida és com una moneda, la pots gastar en el que vulguis però
només una vegada.
*Abans d'imprimir aquest missatge, pensa en el medi ambient.


More information about the development mailing list