You are here

function slack_cron in Slack 7

Implements hook_cron().

File

./slack.module, line 93
Main module file, only hooks are allowed here.

Code

function slack_cron() {
  if (variable_get('slack_token')) {
    $slack_files_delete = DrupalQueue::get('slack_files_delete');
    $types = '';
    if ($filtered = array_filter(variable_get('slack_file_types'))) {
      $types = implode(',', $filtered);
    }
    $query = array(
      'token' => variable_get('slack_token'),
      'ts_to' => strtotime('-' . slack_get_files_age_number() . ' ' . slack_get_files_age_unit()),
      'types' => $types,
    );
    $files = slack_get_files_list($query);
    if (!empty($files['files'])) {
      foreach ($files['files'] as $file) {
        $slack_files_delete
          ->createItem($file);
      }
    }
  }
}