This forum is for module development and code related questions, not general module support. For general support, use the Post installation forum.

How to use "hook_cron" in a new module????

I am attempting to write a module to extend the functionality of pablobm's excellent LDAP authentication modules. He now has split them into 3 pieces, and they gather data, get group info and authenticate to a LDAP server. What I want to do is synchronize a few drupal roles to LDAP groups and do this daily or at scheduled times. This I thought would involve "hook_cron". I have the code working, dislaying what it does on the settings page, but now I want it to be called at timed intervals. I grabbed the cron chunk of code from aggregator.module, and changed it to look like this...

/**
 * Implementation of hook_cron().
 *
 * checks for differences between ldap and drupal user database.
 */
function ldapsync_cron() {

  watchdog('cron', "Hello cron hooked...", WATCHDOG_WARNING);
  sync_ldap_to_drupal();

//  $result = db_query('SELECT * FROM {aggregator_feed} WHERE checked + refresh < %d', time());
//  while ($feed = db_fetch_array($result)) {
//    aggregator_refresh($feed);
//  }
}

I am right in thinking I am supposed to put " function module-name_cron() { " to use the hook, right? Is there any special voodoo magic I need to do to enable it? Any GLOBAL include, etc? How does cron know which modules have a hook in it? I have tried disabling and enabling the module, I have done a forum search, to no avail. I am just expecting a watchdog entry to say that it ran. Cron is working for my site, as my search index is at 100%.
I will be putting all the code up here when I get it working, because it makes things like a web searchable directory (Office, e-mail,phone,etc) available for those who already have the info stored in an LDAP without requiring everyone to log in to drupal to create the account information, and keeps it up to date from the LDAP. Any help would be appreciated, Thanks!

Liveoutloud2day

How do you get a nid in hook_filter()?

Given that hook_filter() is defined as hook_filter($op, $delta = 0, $format = -1, $text = ''), how can you get the current node ID?

I want to create a replacement pattern based upon the name of attachments.

Am I missing a utility function somewhere or should I hack the core so that hook_filter gives me a node ID?

Cron alternative?

I am currently using DB cron (http://drupal.org/node/42922) for some automated housekeeping. The machine that runs cron.php is frequently down for maintenance, so the question is whether DB Cron can be configured to do cron.php's job instead.

Thanks in advance

Does flexinode need

Does creation of flexinode lead to database/table changes or addition.

Regards

ContentO ?

Hi

First of all what is being referred to as 'content', is it the fields of modules ( ex: teaser, body etc. for story module). or is it simply referring to 'story' (module) as a content type.

I want to know what is the utility of ContentO module, because there is very little documentation available. Please help.

Actually I am looking to create customized forms to enter data, which can be other than the common story and page fields. But do answer that what contentO does?

Regards

why is there _ever_ a locked menu item?

In hacking around this morning I bumped into those damn locked menu options (my blog, my account, ...) and I'm left to wonder where is there _ever_ a need for a locked menu item? Is there something going on under the hood programactically that requires these menu options to be there or.... what?

Pages

Subscribe with RSS Subscribe to RSS - Module development and code questions