You are here

function elysia_cron_help in Elysia Cron 7.2

Same name and namespace in other branches
  1. 5.2 elysia_cron.module \elysia_cron_help()
  2. 5 elysia_cron.module \elysia_cron_help()
  3. 6.2 elysia_cron.module \elysia_cron_help()
  4. 6 elysia_cron.module \elysia_cron_help()
  5. 7 elysia_cron.module \elysia_cron_help()

Implements hook_cron().

I use help section for admin/build/modules page to check if elysia_cron is the module with the smallest weight. If it's not i'll set it and print a message.

File

./elysia_cron.module, line 202

Code

function elysia_cron_help($section, $arg = FALSE) {
  if ($section == 'admin/modules') {
    $query = db_select('system', 's');
    $query
      ->addExpression('MIN(weight)');
    $min = $query
      ->condition('s.name', 'elysia_cron', '!=')
      ->execute()
      ->fetchField();
    $weight = db_select('system', 's')
      ->fields('s', array(
      'weight',
    ))
      ->condition('s.name', 'elysia_cron')
      ->execute()
      ->fetchField();
    if ($min <= $weight) {
      elysia_cron_message('Elysia cron module is not the module with the smallest weight (and it must be). Updating weight...');
      db_update('system')
        ->fields(array(
        'weight' => $min - 1,
      ))
        ->condition('name', 'elysia_cron')
        ->execute();
    }
  }
}