/[drupal]/contributions/modules/schedule/schedule.module
ViewVC logotype

Diff of /contributions/modules/schedule/schedule.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.5, Mon Jan 8 16:25:56 2007 UTC revision 1.6, Fri Mar 9 21:58:11 2007 UTC
# Line 17  function schedule_help($section = "admin Line 17  function schedule_help($section = "admin
17    
18  // ********** FORMS *****************************  // ********** FORMS *****************************
19    
 // deprecated for above individual functions  
20  function schedule_form_admin(&$form) {  function schedule_form_admin(&$form) {
21    
22      if (!empty($form['schedule_id']['#value'])) $schedule = schedule_select_schedule($form['schedule_id']['#value']);      if (!empty($form['schedule_id']['#value'])) $schedule = schedule_select_schedule($form['schedule_id']['#value']);
# Line 120  function schedule_form_admin(&$form) { Line 119  function schedule_form_admin(&$form) {
119        '#multiple' => NULL,        '#multiple' => NULL,
120      );      );
121    
   
     /*  
     // date to start including from  
     */  
   
     // Schedule has already started - no need to display include field  
     if (!empty($schedule['last']) && !empty($schedule['start'])) {  
         $form['start'] = array(  
           '#type' => 'hidden',  
           '#value' => date('m/d/y', $schedule['start']),  
         );  
         return $form;  
     }  
   
     $include_date = (empty($schedule['start'])) ? '1/1/99' : date ('m/d/y', $schedule['start']);  
   
     $form['include'] = array(  
       '#type' => 'fieldset',  
       '#title' => t('Include'),  
       '#description' => t('On first send out, include nodes stating from this date.'),  
     );  
   
     $form['include']['start'] = array(  
       '#type' => 'textfield',  
       '#title' => t('Include Nodes From (date)'),  
       '#default_value' => $include_date,  
       '#size' => 10,  
       '#maxlength' => 10,  
       '#description' => t('Leave blank to include all. (mm/dd/yy)'),  
     );  
   
122    
123      /*      /*
124      // Next send out      // Next send out
# Line 201  function schedule_form_admin(&$form) { Line 169  function schedule_form_admin(&$form) {
169      $form['timeout']['timeout'] = array(      $form['timeout']['timeout'] = array(
170        '#type' => 'textfield',        '#type' => 'textfield',
171        '#title' => t('Hours'),        '#title' => t('Hours'),
172        '#default_value' => $schedule['timeout'],        '#default_value' => empty($schedule['timeout']) ? 24 : $schedule['timeout'],
173        '#size' => 5,        '#size' => 5,
174        '#maxlength' => 4,        '#maxlength' => 4,
175          '#required' => TRUE,
176        );
177    
178        /*
179        // date to start including from
180        */
181    
182        // Schedule has already started - no need to display include field
183        if (!empty($schedule['last']) && !empty($schedule['start'])) {
184            $form['start'] = array(
185              '#type' => 'hidden',
186              '#value' => date('m/d/y', $schedule['start']),
187            );
188            return $form;
189        }
190    
191        $include_date = (empty($schedule['start'])) ? '1/1/99' : date ('m/d/y', $schedule['start']);
192    
193        $form['include'] = array(
194          '#type' => 'fieldset',
195          '#title' => t('Include'),
196          '#description' => t('On first send out, include nodes stating from this date.'),
197        );
198    
199        $form['include']['start'] = array(
200          '#type' => 'textfield',
201          '#title' => t('Include Nodes From (date)'),
202          '#default_value' => $include_date,
203          '#size' => 10,
204          '#maxlength' => 10,
205          '#description' => t('Leave blank to include all. (mm/dd/yy)'),
206      );      );
207    
208  }  }
# Line 259  function schedule_insert_schedule($type, Line 258  function schedule_insert_schedule($type,
258    
259    if (isset($schedule['next_date']) && !is_numeric($schedule['next_date'])) $schedule = schedule_convert_form_data($schedule);    if (isset($schedule['next_date']) && !is_numeric($schedule['next_date'])) $schedule = schedule_convert_form_data($schedule);
260    
261    db_query("INSERT INTO {schedules}    db_query("INSERT INTO {schedule}
262      (schedule_id, schedule_title, type, publication_id, start, first, next, last, every, frequency, relative, relative_date, timeout) VALUES      (schedule_id, schedule_title, type, publication_id, start, first, next, last, every, frequency, relative, relative_date, timeout) VALUES
263      (NULL, '%s', '%s', %d, %d, %d, %d, %d, %d, '%s', '%s', '%s', %d)",      (NULL, '%s', '%s', %d, %d, %d, %d, %d, %d, '%s', '%s', '%s', %d)",
264      $schedule['schedule_title'], $type, $schedule['publication_id'], $schedule['start'], $schedule['first'], $schedule['next'], $schedule['last'], $schedule['every'], $schedule['frequency'], $schedule['relative'], $schedule['relative_date'], $schedule['timeout']);      $schedule['schedule_title'], $type, $schedule['publication_id'], $schedule['start'], $schedule['first'], $schedule['next'], $schedule['last'], $schedule['every'], $schedule['frequency'], $schedule['relative'], $schedule['relative_date'], $schedule['timeout']);
# Line 272  function schedule_update_schedule($type, Line 271  function schedule_update_schedule($type,
271    
272    if (isset($schedule['next_date']) && !is_numeric($schedule['next_date'])) $schedule = schedule_convert_form_data($schedule);    if (isset($schedule['next_date']) && !is_numeric($schedule['next_date'])) $schedule = schedule_convert_form_data($schedule);
273    
274    db_query("UPDATE {schedules} SET    db_query("UPDATE {schedule} SET
275      schedule_title = '%s', start = %d, first = %d, next = %d, last = %d, every = %d, frequency = '%s', relative = '%s', relative_date = '%s', timeout = %d WHERE schedule_id = %d AND type = '%s'",      schedule_title = '%s', start = %d, first = %d, next = %d, last = %d, every = %d, frequency = '%s', relative = '%s', relative_date = '%s', timeout = %d WHERE schedule_id = %d AND type = '%s'",
276      $schedule['schedule_title'], $schedule['start'], $schedule['first'], $schedule['next'], $schedule['last'], $schedule['every'], $schedule['frequency'], $schedule['relative'], $schedule['relative_date'], $schedule['timeout'], $schedule['schedule_id'], $type);      $schedule['schedule_title'], $schedule['start'], $schedule['first'], $schedule['next'], $schedule['last'], $schedule['every'], $schedule['frequency'], $schedule['relative'], $schedule['relative_date'], $schedule['timeout'], $schedule['schedule_id'], $type);
277    return;    return;
# Line 290  function schedule_update_send_now($type, Line 289  function schedule_update_send_now($type,
289          if ($schedule['frequency'] == 'manual') {          if ($schedule['frequency'] == 'manual') {
290    
291              schedule_set_action($type, $publication_id, $schedule_id, $time);              schedule_set_action($type, $publication_id, $schedule_id, $time);
292              db_query("UPDATE {schedules} SET last = %d WHERE publication_id = %d AND schedule_id = %d AND type = '%s'", $time, $publication_id, $schedule_id, $type);              db_query("UPDATE {schedule} SET last = %d WHERE publication_id = %d AND schedule_id = %d AND type = '%s'", $time, $publication_id, $schedule_id, $type);
293    
294          } else {          } else {
295    
296              db_query("UPDATE {schedules} SET next = %d WHERE publication_id = %d AND schedule_id = %d AND type = '%s'", $time, $publication_id, $schedule_id, $type);              db_query("UPDATE {schedule} SET next = %d WHERE publication_id = %d AND schedule_id = %d AND type = '%s'", $time, $publication_id, $schedule_id, $type);
297          }          }
298      }      }
299    
# Line 309  function schedule_select_schedule($sched Line 308  function schedule_select_schedule($sched
308    
309      // avoid making more than one database call for a schedule      // avoid making more than one database call for a schedule
310      if (empty($schedules_static[$schedule_id])) {      if (empty($schedules_static[$schedule_id])) {
311          $schedules_static[$schedule_id] = db_fetch_array(db_query("SELECT * FROM {schedules} WHERE schedule_id = %d LIMIT 1", $schedule_id));          $schedules_static[$schedule_id] = db_fetch_array(db_query("SELECT * FROM {schedule} WHERE schedule_id = %d LIMIT 1", $schedule_id));
312      }      }
313    
314      return $schedules_static[$schedule_id];      return $schedules_static[$schedule_id];
# Line 319  function schedule_select_schedule($sched Line 318  function schedule_select_schedule($sched
318  function schedule_select_schedules($type = NULL, $publication_id = NULL) {  function schedule_select_schedules($type = NULL, $publication_id = NULL) {
319    
320    if (!empty($publication_id)) {    if (!empty($publication_id)) {
321        $results = db_query("SELECT * FROM {schedules} WHERE publication_id = %d AND type = '%s'", $publication_id, $type);        $results = db_query("SELECT * FROM {schedule} WHERE publication_id = %d AND type = '%s'", $publication_id, $type);
322    }    }
323    
324    if (!empty($type) && empty($publication_id)) {    if (!empty($type) && empty($publication_id)) {
325        $results = db_query("SELECT * FROM {schedules} WHERE type = '%s'", $type);        $results = db_query("SELECT * FROM {schedule} WHERE type = '%s'", $type);
326    }    }
327    
328    if (empty($type) && empty($publication_id)) {    if (empty($type) && empty($publication_id)) {
329        $results = db_query("SELECT * FROM {schedules}");        $results = db_query("SELECT * FROM {schedule}");
330    }    }
331    
332    while ($row = db_fetch_array($results)) {    while ($row = db_fetch_array($results)) {
# Line 340  function schedule_select_schedules($type Line 339  function schedule_select_schedules($type
339    
340  function schedule_delete_publication_schedules($type, $publication_id) {  function schedule_delete_publication_schedules($type, $publication_id) {
341    
342      db_query("DELETE FROM {schedules} WHERE publication_id = %d AND type = '%s'", $publication_id, $type);      db_query("DELETE FROM {schedule} WHERE publication_id = %d AND type = '%s'", $publication_id, $type);
343      return;      return;
344  }  }
345    
346  function schedule_delete($schedule_id) {  function schedule_delete($schedule_id) {
347    
348      db_query("DELETE FROM {schedules} WHERE schedule_id = %d", $schedule_id);      db_query("DELETE FROM {schedule} WHERE schedule_id = %d", $schedule_id);
349      db_query("DELETE FROM {schedules_action} WHERE schedule_id = %d", $schedule_id);      db_query("DELETE FROM {schedule_action} WHERE schedule_id = %d", $schedule_id);
350      return;      return;
351  }  }
352    
# Line 462  function schedule_count_sent($type, $pub Line 461  function schedule_count_sent($type, $pub
461    
462      $sent_count = db_result(db_query("      $sent_count = db_result(db_query("
463      SELECT count(s.sent)      SELECT count(s.sent)
464      FROM {schedules_action} a      FROM {schedule_action} a
465      LEFT JOIN {subscribed_sent} s ON a.action_id = s.action_id      LEFT JOIN {subscribed_sent} s ON a.action_id = s.action_id
466      WHERE a.type = '%s'      WHERE a.type = '%s'
467      AND a.publication_id = %d      AND a.publication_id = %d
# Line 508  function schedule_count_queued($type, $p Line 507  function schedule_count_queued($type, $p
507      FROM {subscribed} s      FROM {subscribed} s
508      LEFT JOIN {users} u ON s.uid = u.uid      LEFT JOIN {users} u ON s.uid = u.uid
509      LEFT JOIN {bounced_email_count} b ON u.mail = b.email      LEFT JOIN {bounced_email_count} b ON u.mail = b.email
510      LEFT JOIN {schedules_action} a ON (a.type = s.type AND a.publication_id = s.publication_id AND a.pub_time = %d)      LEFT JOIN {schedule_action} a ON (a.type = s.type AND a.publication_id = s.publication_id AND a.pub_time = %d)
511      LEFT JOIN {subscribed_sent} m ON (m.uid = s.uid AND m.action_id = a.action_id)      LEFT JOIN {subscribed_sent} m ON (m.uid = s.uid AND m.action_id = a.action_id)
512      WHERE s.publication_id = %d      WHERE s.publication_id = %d
513      AND s.schedule_id = %d      AND s.schedule_id = %d
# Line 654  function _schedule_profile_fields($key = Line 653  function _schedule_profile_fields($key =
653  function schedule_set_action($type, $publication_id, $schedule_id, $pub_time) {  function schedule_set_action($type, $publication_id, $schedule_id, $pub_time) {
654    
655      // check if action exists      // check if action exists
656      $action_id = db_result(db_query("SELECT action_id FROM {schedules_action} WHERE publication_id = %d AND schedule_id = %d AND pub_time = %d AND type = '%s'", $publication_id, $schedule_id, $pub_time, $type));      $action_id = db_result(db_query("SELECT action_id FROM {schedule_action} WHERE publication_id = %d AND schedule_id = %d AND pub_time = %d AND type = '%s'", $publication_id, $schedule_id, $pub_time, $type));
657    
658      // if not create action      // if not create action
659      if (empty($action_id)) {      if (empty($action_id)) {
660    
661          db_query("INSERT INTO {schedules_action}          db_query("INSERT INTO {schedule_action}
662                          (action_id, type, publication_id, schedule_id, pub_time) VALUES                          (action_id, type, publication_id, schedule_id, pub_time) VALUES
663                          (NULL, '%s', %d, %d, %d)",                          (NULL, '%s', %d, %d, %d)",
664                          $type, $publication_id, $schedule_id, $pub_time);                          $type, $publication_id, $schedule_id, $pub_time);
# Line 668  function schedule_set_action($type, $pub Line 667  function schedule_set_action($type, $pub
667    
668      } else {      } else {
669    
670          db_query("UPDATE {schedules_action} SET          db_query("UPDATE {schedule_action} SET
671                          type = '%s', publication_id = %d, schedule_id = %d, pub_time = %d WHERE action_id = %d",                          type = '%s', publication_id = %d, schedule_id = %d, pub_time = %d WHERE action_id = %d",
672                          $type, $publication_id, $schedule_id, $pub_time, $action_id);                          $type, $publication_id, $schedule_id, $pub_time, $action_id);
673      }      }

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.6

  ViewVC Help
Powered by ViewVC 1.1.2