How can I tell that my hook_nodeapi function is being called by cron and not a user? I am attempting to filter the viewing of node/cck fields attached to the nodes, so I have written a custom hook_nodeapi function and I am editing the field values if the user doesn't have permissions (redacting them). The problem is, that when cron runs and apachesolr attempts to index the same content, cron doesn't have "the permissions" associated and so ends up indexing redacted content.

I need a simple test that returns a boolean if a function is being called by cron. Any ideas? I have started looking through cron code (Drupal 6) and it looks like bootstrap sets up cron with default anonymous user account details...
How is cron being executed?  If done via crontab like

0 1 * * *   /usr/bin/wget -O - -q -t 1 http://my.site.com/cron.php


then I suspect that

function hook_whatever () {
  global $user;

  if (strpos(request_uri(), "/cron.php") === 0 &amp;&amp; $user-&gt;uid == 0) {
    // from crontab
  } else {
    // from somewhere else
  }
}


would work.

Manually running from one of the admin pages may be trickier, but taking out the $user-&gt;uid check may suffice in that case.