You are here

function fb_register_cron in Drupal for Facebook 6.2

Implementation of hook_cron().

Register users with Facebook during cron jobs.

File

contrib/fb_register.module, line 275
This code aims to prevent duplicate accounts.

Code

function fb_register_cron() {
  $all_apps = fb_get_all_apps();

  // All applications
  foreach ($all_apps as $fb_app) {
    $fb_app_data = fb_get_app_data($fb_app);
    $fb_register_data = isset($fb_app_data['fb_register']) ? $fb_app_data['fb_register'] : array(
      'register_users' => FALSE,
    );
    if (is_array($fb_register_data) && $fb_register_data['register_users']) {

      // This app has registration enabled.
      $count = _fb_register_register_users($fb_app, variable_get('fb_register_limit', 100));
      if ($count < 0) {

        // errors
        watchdog('fb_register', "Errors incountered while registering users for Facebook App %app", array(
          '%app' => $fb_app->label,
        ), WATCHDOG_ERROR);
      }
      elseif ($count > 0) {
        watchdog('fb_register', "Registered %count users for Facebook App !app", array(
          '%count' => $count,
          '%app' => $fb_app->label,
        ));
      }
    }
  }
}