[development] temporary access module

Karoly Negyesi karoly at negyesi.net
Fri Feb 16 22:46:46 UTC 2007


> The client wants to be able to create a page, and then fire off a
> bunch of emails to people who may or may not have accounts, allowing
> them to access the page temporarily.

Great. Unpublish nodes, generate a random, store (random, nid) pairs and send

peek/<random>

URLs. 

function peek_menu($may_cache) {
  if ($may_cache) {
    $items[] = array('path' => 'peek', 'access' => TRUE, 'type' => MENU_CALLBACK);
  }
  return $items;
}

function peek_view($random) {
  $nid = db_result(db_query("SELECT nid FROM {peek} WHERE random = '%s'", $random));
  if ($nid && ($node = node_load($nid))) {
    return node_show($node);
  }
  drupal_not_found();
}

The above works because we bypass node_access thus peek_view can view unpublished nodes but your users who are not node admins can't.

Why are you generating users, I can't readily understand. 


More information about the development mailing list