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