Projet

Général

Profil

Révision 082b75eb

Ajouté par Assos Assos il y a environ 6 ans

Weekly update of contrib modules

Voir les différences:

drupal7/sites/all/modules/job_scheduler/modules/job_scheduler_trigger/job_scheduler_trigger.module
2 2

  
3 3
/**
4 4
 * @file
5
 * job scheduler module.
5
 * Job scheduler module.
6 6
 */
7 7

  
8 8
/**
......
11 11
function job_scheduler_trigger_help($path, $arg) {
12 12
  switch ($path) {
13 13
    case 'admin/structure/trigger/job_scheduler':
14
      // The first line is the very same text trigger module provides. Do not edit.
14
      // The first line is the very same text trigger module provides. Do not
15
      // edit.
15 16
      $output = '<p>' . t('Triggers are events on your site, such as new content being added or a user logging in. The Trigger module associates these triggers with actions (functional tasks), such as unpublishing content containing certain keywords or e-mailing an administrator. The <a href="@url">Actions settings page</a> contains a list of existing actions and provides the ability to create and configure advanced actions (actions requiring configuration, such as an e-mail address or a list of banned words).', array('@url' => url('admin/config/system/actions'))) . '</p>';
16 17
      $output .= '<p>' . t('Below you can assign actions to run on a periodic basis. To create more triggers of this type use the <a href="@url">Job Scheduler configuration</a> page.', array('@url' => url('admin/config/system/job_scheduler'))) . '</p>';
17 18
      return $output;
19

  
18 20
    case 'admin/config/system/job_scheduler':
19 21
      $output = '<p>' . t('You can create any number of jobs that are triggered depending on a crontab.') . '</p>';
20 22
      $output .= '<p>' . t('To set actions for these triggers, go to the <a href="@url">Job Scheduler Triggers</a> page.', array('@url' => url('admin/structure/trigger/job_scheduler'))) . '</p>';
......
23 25
}
24 26

  
25 27
/**
26
 * Implementation of hook_menu()
28
 * Implements hook_menu().
27 29
 */
28 30
function job_scheduler_trigger_menu() {
29 31
  $items['admin/config/system/job_scheduler'] = array(
......
34 36
    'file' => 'job_scheduler_trigger.admin.inc',
35 37
  );
36 38
  $items['admin/config/system/job_scheduler/add'] = array(
37
    'title' => 'Trigger scheduler',
39
    'title' => 'Add a new trigger',
38 40
    'description' => 'Configure timely triggers',
39 41
    'page callback' => 'drupal_get_form',
40 42
    'page arguments' => array('job_scheduler_trigger_edit_form', NULL),
......
53 55
}
54 56

  
55 57
/**
56
 * Implementation of hook_trigger_info().
58
 * Implements hook_trigger_info().
57 59
 */
58 60
function job_scheduler_trigger_trigger_info() {
59 61
  $triggers = array();
......
67 69
}
68 70

  
69 71
/**
70
 * Implementation of hook_job_scheduler_info()
72
 * Implements hook_job_scheduler_info().
71 73
 */
72 74
function job_scheduler_trigger_cron_job_scheduler_info() {
73 75
  foreach (job_scheduler_trigger_list() as $trigger) {
74 76
    if ($trigger->status) {
75
      $jobs[$trigger->trid] = array('id' => $trigger->trid, 'type' => $trigger->hook, 'crontab' => $trigger->crontab, 'periodic' => TRUE);
77
      $jobs[$trigger->trid] = array(
78
        'id' => $trigger->trid,
79
        'type' => $trigger->hook,
80
        'crontab' => $trigger->crontab,
81
        'periodic' => TRUE,
82
      );
76 83
    }
77 84
  }
78 85
  if (!empty($jobs)) {
......
85 92
}
86 93

  
87 94
/**
88
 * Get job list for job scheduler
95
 * Get job list for job scheduler.
89 96
 */
90 97
function job_scheduler_trigger_list() {
91 98
  return db_select('job_scheduler_trigger', 't')
......
95 102
}
96 103

  
97 104
/**
98
 * Fire up a scheduled trigger
105
 * Fire up a scheduled trigger.
99 106
 */
100 107
function job_scheduler_trigger_worker($job) {
101
  // Mark last time triggered for the records
108
  // Mark last time triggered for the records.
102 109
  db_update('job_scheduler_trigger')
103 110
    ->fields(array('last' => REQUEST_TIME))
104 111
    ->condition('trid', $job['id'])
......
109 116
      'hook' => $job['type'],
110 117
      'job' => $job,
111 118
    );
112
    // Scheduler's object is the job from job_scheduler
113
    $object = (object)$job;
119
    // Scheduler's object is the job from job_scheduler.
120
    $object = (object) $job;
114 121
    actions_do(array_keys($aids), $object, $context);
115 122
  }
116 123
}
117 124

  
118 125
/**
119
 * Menu loader
126
 * Menu loader.
120 127
 */
121 128
function job_scheduler_trigger_load($trid) {
122 129
  return db_select('job_scheduler_trigger', 't')

Formats disponibles : Unified diff