You are here

function drupagram_cron in Drupagram 6

Same name and namespace in other branches
  1. 7 drupagram.module \drupagram_cron()

Implementation hook_cron().

Imports new Instagram statuses for site users, and deletes expired media.

File

./drupagram.module, line 159

Code

function drupagram_cron() {
  if (!variable_get('drupagram_import', TRUE)) {
    return;
  }
  module_load_include('inc', 'drupagram');
  $result = db_query_range("SELECT drupagram_id FROM {drupagram_account} WHERE import = %d ORDER BY last_refresh ASC", 1, 0, 20);
  while ($account = db_fetch_object($result)) {
    if ($account->drupagram_id) {

      //drupagram_fetch_user_feed($account->drupagram_id);
      drupagram_fetch_recent_items($account->drupagram_id);
    }
  }
  if ($age = variable_get('drupagram_expire', 0)) {
    db_query("DELETE FROM {drupagram} WHERE created_time=%d", REQUEST_TIME - $age);
  }
}