Project

General

Profile

Revision 082b75eb

Added by Assos Assos over 6 years ago

Weekly update of contrib modules

View differences:

drupal7/sites/all/modules/job_scheduler/modules/job_scheduler_trigger/job_scheduler_trigger.admin.inc
2 2

  
3 3
/**
4 4
 * @file
5
 * Job Scheduler Trigger admin pages
5
 * Job Scheduler Trigger admin pages.
6
 */
7

  
8
/**
9
 * Admin Overview.
6 10
 */
7 11
function job_scheduler_trigger_admin_overview() {
8 12
  $base_path = 'admin/config/system/job_scheduler';
......
52 56
  return $form;
53 57
}
54 58

  
55

  
56 59
/**
57
 * Edit form for a trigger
60
 * Edit form for a trigger.
58 61
 */
59 62
function job_scheduler_trigger_edit_form($form, &$form_state, $trigger) {
60 63
  if (!$trigger) {
61
    $trigger = (object)array('trid' => NULL, 'title' => t('New trigger'), 'crontab' => '* * * * *', 'status' => 0, 'last' => 0);
64
    $trigger = (object) array(
65
      'trid' => NULL,
66
      'title' => t('New trigger'),
67
      'crontab' => '* * * * *',
68
      'status' => 0,
69
      'last' => 0,
70
    );
62 71
  }
63 72
  $form['trigger'] = array('#tree' => TRUE);
64 73
  $form['trigger']['trid'] = array('#type' => 'value', '#value' => $trigger->trid);
......
84 93
    '#description' => t('When enabled, a trigger will be created with this crontab and jobs will be scheduled for it. Check everything is OK before enabling the trigger.'),
85 94
  );
86 95
  $form['trigger']['last'] = array(
87
     '#type' => 'item',
88
     '#title' => t('Last triggered'),
89
     '#markup' => format_date($trigger->last),
96
    '#type' => 'item',
97
    '#title' => t('Last triggered'),
98
    '#markup' => format_date($trigger->last),
90 99
  );
91 100
  if ($trigger->trid && $trigger->crontab) {
92 101
    $next = job_scheduler_trigger_next_time($trigger->crontab);
93 102
    $form['trigger']['next'] = array(
94
       '#type' => 'item',
95
       '#title' => t('Next trigger'),
96
       '#markup' => $next ? format_date($next) : t('Never in the next year.'),
103
      '#type' => 'item',
104
      '#title' => t('Next trigger'),
105
      '#markup' => $next ? format_date($next) : t('Never in the next year.'),
97 106
    );
98 107
  }
99 108
  $form['buttons']['update'] = array('#type' => 'submit', '#value' => t('Save'));
......
106 115
}
107 116

  
108 117
/**
109
 * Validate trigger
118
 * Validate trigger.
110 119
 */
111 120
function job_scheduler_trigger_edit_form_validate($form, &$form_state) {
112 121
  $trigger = $form_state['values']['trigger'];
......
118 127
}
119 128

  
120 129
/**
121
 * Submit trigger
130
 * Submit trigger.
122 131
 */
123 132
function job_scheduler_trigger_edit_form_submit($form, &$form_state) {
124 133
  $op = isset($form_state['values']['op']) ? $form_state['values']['op'] : '';
125 134
  $trigger = $form_state['values']['trigger'];
126 135
  if ($op == t('Save')) {
127 136
    if (empty($trigger['trid'])) {
128
      // Create and then assign trigger name and create trigger
137
      // Create and then assign trigger name and create trigger.
129 138
      drupal_write_record('job_scheduler_trigger', $trigger);
130 139
      $trigger['hook'] = 'job_scheduler_' . $trigger['trid'];
131 140
      drupal_write_record('job_scheduler_trigger', $trigger, 'trid');
......
149 158
}
150 159

  
151 160
/**
152
 * Quick calculate next time cron
161
 * Quick calculate next time cron.
153 162
 */
154 163
function job_scheduler_trigger_next_time($crontab) {
155 164
  $crontab = new JobSchedulerCronTab($crontab);

Also available in: Unified diff