You are here

function social_content_cronapi in Social Content 7.2

Same name and namespace in other branches
  1. 7 social_content.module \social_content_cronapi()

Implements hook_cronapi().

Elysia Cron / Ultimate Cron hook. Split all social content imports into their own jobs. Stagger the time by five minutes for each run.

File

./social_content.module, line 188
Social Content module.

Code

function social_content_cronapi($op, $job = NULL) {

  // $classes = social_content_get_classes();
  // Get all enabled instances.
  $instances = array_keys(SocialContent::getAllInstances(array(), TRUE));
  $items = array();
  $mins = 0;
  foreach ($instances as $id) {
    $instance = social_content_load($id);
    $mins += 5;
    if ($mins > 60) {
      $mins -= 60;
    }
    $items['social_content_' . $instance
      ->getMachineName() . '_' . $id] = array(
      'description' => t('Social content import for !title', array(
        '!title' => $instance
          ->getInstanceTitle(),
      )),
      'rule' => $mins . ' */2 * * *',
      'callback' => 'social_content_run_import',
      'arguments' => array(
        $instance,
      ),
    );
  }
  $items['social_content_purge'] = array(
    'description' => t('Delete old nodes imported by Social Content.'),
    'rule' => '0 0 * * *',
    'callback' => 'social_content_delete_old_nodes',
  );
  return $items;
}