Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
bulkmail_post_office_edit_fns.inc
1 <?php
17 require_once SQ_INCLUDE_PATH.'/asset_edit/asset_edit_fns.inc';
18 require_once SQ_DATA_PATH.'/private/conf/tools.inc';
19 
20 
35 {
36 
37 
42  function __construct()
43  {
44  parent::__construct();
45  $this->static_screens['details']['force_unlock'] = FALSE;
46 
47  }//end constructor
48 
49 
50 //-- DETAILS --//
51 
52 
63  function paintRecipients(&$asset, &$o, $prefix)
64  {
65  $write_access = $asset->writeAccess('attributes');
66  $recipients = $asset->attr('recipients');
67 
68  if ($write_access) {
69  multiple_asset_finder($prefix.'_groups', $recipients);
70  } else {
71  ?><ul><?php
72  foreach ($recipients as $assetid) {
73  $group_asset = NULL;
74  if (!empty($assetid)) {
75  $group_asset = $GLOBALS['SQ_SYSTEM']->am->getAsset($assetid);
76  }
77 
78  if (!is_null($group_asset)) {
79  ?><li><?php echo get_asset_tag_line($group_asset->id); ?></li><?php
80  } else {
81  echo translate('bulkmail_recipient_group_asset_not_found');
82  }
83  }
84  ?></ul><?php
85  }
86 
87  return $write_access;
88 
89  }//end paintRecipients()
90 
91 
102  function processRecipients(&$asset, &$o, $prefix)
103  {
104  // need to have write access to make any changes
105  if (!$asset->writeAccess('attributes')) return FALSE;
106 
107  $groups = Array();
108  if (is_array($_POST[$prefix.'_groups'])) {
109  foreach ($_POST[$prefix.'_groups'] as $group_node) {
110  if (!empty($group_node['assetid'])) {
111  $groups[] = $group_node['assetid'];
112  }
113  }
114  }
115 
116  return $asset->setAttrValue('recipients', $groups);
117 
118  }//end processRecipients()
119 
120 
131  function paintServerDetails(&$asset, &$o, $prefix)
132  {
133  $write_access = $asset->writeAccess('attributes');
134  $server_details = $asset->attr('server_details');
135 
136  $field_name = translate('bulkmail_server_detail_mail_method_field_name');
137  $o->openField($field_name);
138  $options = Array(
139  'smtp' => 'SMTP',
140  'sendmail' => 'Sendmail',
141  );
142 
143  $onChange = 'onChange="switchDriver(this.value)"';
144  $value = array_get_index($server_details, 'driver', 'smtp');
145  if ($write_access) {
146  combo_box($prefix.'_server_det_driver', $options, FALSE, $value, 0, $onChange);
147  } else {
148  echo $options[$value];
149  }
150  $o->closeField();
151 
152  $smtp = !($value == 'smtp');
153 
154  $field_name = translate('bulkmail_server_detail_host_field_name');
155  $name = $prefix.'_server_detail_smtp_host';
156  $o->openField($field_name, '', '', $smtp, $name.'_field');
157  $value = array_get_index($server_details, 'host', '');
158  if ($write_access) {
159  text_box($name, array_get_index($server_details, 'host', ''));
160  } else {
161  echo $value;
162  }
163  $o->closeField();
164 
165  $field_name = translate('bulkmail_server_detail_port_field_name');
166  $name = $prefix.'_server_detail_smtp_port';
167  $o->openField($field_name, '', '', $smtp, $name.'_field');
168  $value = array_get_index($server_details, 'port', '');
169  if ($write_access) {
170  int_text_box($name, $value, FALSE, 4);
171  } else {
172  echo $value;
173  }
174  $o->closeField();
175 
176  $field_name = translate('bulkmail_server_detail_auth_field_name');
177  $name = $prefix.'_server_detail_smtp_auth';
178  $o->openField($field_name, '', 'Server requires authentication?', $smtp, $name.'_field');
179  $auth = array_get_index($server_details, 'auth', FALSE);
180 
181  if ($write_access) {
182  check_box($name, TRUE, $auth, 'switchAuthentication(this.checked)');
183  } else {
184  ?>
185  <img src="<?php echo sq_web_path('lib'); ?>/web/images/<?php echo $auth ? 'tick' : 'cross'; ?>.gif" width="15" height="15" />
186  <?php
187  }
188  $o->closeField();
189 
190  $disabled = ($auth) ? '' : 'disabled=TRUE';
191 
192  $name = $prefix.'_server_detail_smtp_auth_username';
193  $o->openField(translate('username'), '', '', $smtp, $name.'_field');
194  $value = array_get_index($server_details, 'username', '');
195  if ($write_access) {
196  text_box($name, $value, '', '', FALSE, $disabled);
197  } else {
198  echo $value;
199  }
200  $o->closeField();
201 
202  $name = $prefix.'_server_detail_smtp_auth_password';
203  $o->openField(translate('password'), '', '', $smtp, $name.'_field');
204  $value = array_get_index($server_details, 'password', '');
205  if ($write_access) {
206  password_box($name, $value, '', '', $disabled);
207  } else {
208  echo str_repeat('*', strlen($value));
209  }
210  $o->closeField();
211 
212  $field_name = translate('bulkmail_server_detail_path_field_name');
213  $name = $prefix.'_server_detail_sendmail_sendmail_path';
214  $o->openField($field_name, '', 'The path to your sendmail binary. Use config file data/private/conf/tools.inc.', !$smtp, $name.'_field');
215  echo SQ_TOOL_SENDMAIL_PATH;
216  $o->closeField();
217 
218  $field_name = translate('bulkmail_server_detail_arg_field_name');
219  $name = $prefix.'_server_detail_sendmail_sendmail_args';
220  $o->openField($field_name, '', 'Use config file data/private/conf/tools.inc.', !$smtp, $name.'_field');
221  echo SQ_TOOL_SENDMAIL_ARGS;
222  // $o->closeField(); This field is closed in the edit interface
223 
224  ?>
225  <script type="text/javascript">
226  function switchDriver(driver) {
227  var prefix = '<?php echo $prefix; ?>';
228  var regex_string1 = prefix + '_server_detail.*_field';
229  var regex_string2 = prefix + '_server_detail_' + driver + '.*_field';
230  var re1 = new RegExp(regex_string1);
231  var re2 = new RegExp(regex_string2);
232  var elements = document.getElementsByTagName('tr');
233 
234  for (i = 0; i < elements.length; i++) {
235  if (elements[i].id.match(re1)) {
236  if (elements[i].id.match(re2)) {
237  elements[i].style['display'] = '';
238  } else {
239  elements[i].style['display'] = 'none';
240  }
241  }
242  }
243  }
244 
245  function switchAuthentication(checked) {
246  var prefix = '<?php echo $prefix; ?>';
247  var regex_string1 = prefix + '_server_detail_smtp_auth_.*';
248  var re1 = new RegExp(regex_string1);
249  var elements = document.main_form.elements;
250 
251  for (i = 0; i < elements.length; i++) {
252  if (elements[i].name.match(re1)) {
253  elements[i].disabled = !checked;
254  }
255  }
256  }
257  </script>
258  <?php
259 
260  return $write_access;
261 
262  }//end paintServerDetails()
263 
264 
275  function processServerDetails(&$asset, &$o, $prefix)
276  {
277  // need to have write access to make any changes
278  if (!$asset->writeAccess('attributes')) return FALSE;
279 
280  $driver = array_get_index($_REQUEST, $prefix.'_server_det_driver', 'smtp');
281  foreach ($_REQUEST as $key => $value) {
282  if (preg_match('/'.$prefix.'_server_detail_'.$driver.'_(auth_)?([^^]*)/', $key, $matches)) {
283  // do not store empty string so that we can use PEAR mail default params
284  if ($value) $server_details[$matches[2]] = $value;
285  }
286  }
287  $server_details['driver'] = $driver;
288 
289  if (array_get_index($server_details, 'driver', 'smtp') == 'smtp') {
290  if (array_get_index($server_details, 'auth', FALSE) == FALSE) {
291  $server_details['auth'] = FALSE;
292  $server_details['username'] = '';
293  $server_details['password'] = '';
294  }
295  }
296  return $asset->setAttrValue('server_details', $server_details);
297 
298  }//end processServerDetails()
299 
300 
311  function paintCurrentHeaders(&$asset, &$o, $prefix)
312  {
313  $width = 30;
314  $write_access = $asset->writeAccess('attributes');
315 
316  $header_details = $asset->attr('header_details');
317  if (!empty($header_details)) {
318  ?>
319  <table class="sq-backend-table">
320  <tr>
321  <th class="sq-backend-table-header"><b><?php echo translate('bulkmail_header_detail_field_name'); ?></b></th>
322  <th class="sq-backend-table-header"><b><?php echo translate('bulkmail_header_detail_field_body'); ?></b></th>
323  <?php
324  if ($write_access) {
325  ?><th class="sq-backend-table-header"><b><?php echo translate('delete_question'); ?></b></th><?php
326  }
327  ?>
328  </tr>
329  <?php
330  $index = 0;
331  foreach ($header_details as $field_name => $field_body) {
332  if ($write_access) {
333  ?><tr>
334  <td class="sq-backend-table-cell"><?php echo text_box($prefix.'_header_key_'.$index, $field_name);?></td>
335  <td class="sq-backend-table-cell"><?php echo text_box($prefix.'_header_value_'.$index, $field_body);?></td>
336  <td class="sq-backend-table-cell"><?php check_box($prefix.'_header_delete_'.$index, TRUE, FALSE);?></td>
337  </tr><?php
338  } else {
339  ?><tr>
340  <td class="sq-backend-table-cell"><?php echo $field_name;?></td>
341  <td class="sq-backend-table-cell" colspan="2"><?php echo htmlspecialchars($field_body);?></td>
342  </tr><?php
343  }
344  $index++;
345  }
346  ?>
347  </table>
348  <?php
349 
350  } else {
351  echo translate('bulkmail_header_none');
352  }
353 
354  return $write_access;
355 
356  }//end paintCurrentHeaders()
357 
358 
369  function processCurrentHeaders(&$asset, &$o, $prefix)
370  {
371  // need to have write access to make any changes
372  if (!$asset->writeAccess('attributes')) return FALSE;
373 
374  $header_details = $asset->attr('header_details');
375 
376  $index = 0;
377  $new_header_details = Array();
378  foreach ($header_details as $field_name => $field_body) {
379  $key = trim(array_get_index($_REQUEST, $prefix.'_header_key_'.$index));
380  $value = trim(array_get_index($_REQUEST, $prefix.'_header_value_'.$index));
381  $delete = array_get_index($_REQUEST, $prefix.'_header_delete_'.$index, FALSE);
382 
383  if (!empty($key) && !$delete) {
384  $new_header_details[$key] = $value;
385  }
386  $index++;
387  }
388 
389  $asset->setAttrValue('header_details', $new_header_details);
390  return TRUE;
391 
392  }//end processCurrentHeaders()
393 
394 
405  function paintNewHeader(&$asset, &$o, $prefix)
406  {
407  $write_access = $asset->writeAccess('attributes');
408 
409  // text box for new field entry
410  if ($write_access) {
411  echo translate('key'), ': ';
412  text_box($prefix.'_header_new_key', '', 30);
413  echo '&nbsp;', translate('value'), ': ';
414  text_box($prefix.'_header_new_value', '', 30);
415  }
416 
417  $write_access;
418 
419  }//end paintNewHeader()
420 
421 
432  function processNewHeader(&$asset, &$o, $prefix)
433  {
434  $header_key = array_get_index($_REQUEST, $prefix.'_header_new_key', '');
435  $header_value = array_get_index($_REQUEST, $prefix.'_header_new_value', '');
436 
437  $header_details = $asset->attr('header_details');
438 
439  if ( (!empty($header_key)) && (!empty($header_value)) ) {
440  $header_details[$header_key] = $header_value;
441  }
442 
443  $asset->setAttrValue('header_details', $header_details);
444 
445  return TRUE;
446 
447  }//end processNewHeader()
448 
449 
450 //-- THRESHOLD --//
451 
452 
463  function paintThresholds(&$asset, &$o, $prefix)
464  {
465  $write_access = $asset->writeAccess('attributes');
466  // check if bulkmail manager's default's post office overrides threshold settings
467  $bm = $GLOBALS['SQ_SYSTEM']->am->getSystemAsset('bulkmail_manager');
468  $use_bm_threshold = $bm->attr('use_bm_threshold');
469  if ($use_bm_threshold && !($asset instanceof Bulkmail_Manager)) {
470  $threshold = $bm->attr('threshold');
471  $write_access = FALSE;
472  } else {
473  $threshold = $asset->attr('threshold');
474  }
475 
476  // paint existing rules
477  if (!empty($threshold)) {
478  $o->openField(translate('bulkmail_threshold_current_rules'));
479  ?><table class="sq-backend-table">
480  <tr>
481  <th class="sq-backend-table-header"><?php echo translate('type') ?></th>
482  <th class="sq-backend-table-header"><?php echo translate('bulkmail_threshold_allow_multiple') ?></th>
483  <th class="sq-backend-table-header"><?php echo translate('rule') ?></th>
484  <?php
485  if ($write_access) {
486  ?><th class="sq-backend-table-header"><?php echo translate('delete_rule') ?></th><?php
487  }
488  ?>
489  </tr><?php
490  foreach ($threshold as $key => $rule) {
491  ?><tr>
492  <td class="sq-backend-table-cell"><?php echo $rule['type']; ?></td>
493  <td class="sq-backend-table-cell"><?php echo ($rule['multiple']) ? translate('yes') : translate('no'); ?></td>
494  <?php
495  switch ($rule['type']) {
496  case translate('bulkmail_threshold_rule_excluded_time') :
497  $this->_paintExcludedTimeRule($asset, $o, $prefix.'_threshold_rule_'.$key, $rule, $write_access);
498  break;
499  case translate('bulkmail_threshold_rule_send_rate') :
500  $this->_paintSendRateRule($asset, $o, $prefix.'_threshold_rule_'.$key, $rule, $write_access);
501  break;
502  default:
503  break;
504  }
505  ?></tr><?php
506  }
507  ?></table><?php
508  if ($use_bm_threshold && !($asset instanceof Bulkmail_Manager)) {
509  $o->note(translate('bulkmail_threshold_override_note', get_asset_tag_line($bm->id)));
510  }
511  $o->closeField();
512  }//end if
513 
514  // the dropdown box that allows user to add new rules
515  if (!($use_bm_threshold && !($asset instanceof Bulkmail_Manager))) {
516  $this->paintAddRule($asset, $o, $prefix, $write_access);
517  }
518 
519  return TRUE;
520 
521  }//end paintThresholds()
522 
523 
534  function processThresholds(&$asset, &$o, $prefix)
535  {
536  $write_access = $asset->writeAccess('attributes');
537  // check if bulkmail manager's default's post office overrides threshold settings
538  $bm = $GLOBALS['SQ_SYSTEM']->am->getSystemAsset('bulkmail_manager');
539  $use_bm_threshold = $bm->attr('use_bm_threshold');
540  if ($use_bm_threshold && !($asset instanceof Bulkmail_Manager)) {
541  $write_access = FALSE;
542  }
543  if (!$write_access) return FALSE;
544 
545  $threshold = $asset->attr('threshold');
546  if (!empty($threshold)) {
547  foreach ($threshold as $key => $rule) {
548  switch ($rule['type']) {
549  case translate('bulkmail_threshold_rule_excluded_time') :
550  $threshold = $this->_processExcludedTimeRule($prefix.'_threshold_rule_'.$key, $threshold, $key);
551  break;
552  case translate('bulkmail_threshold_rule_send_rate') :
553  $threshold = $this->_processSendRateRule($prefix.'_threshold_rule_'.$key, $threshold, $key);
554  break;
555  default:
556  break;
557  }
558  }
559  }
560  $threshold = $this->processAddRule($asset, $o, $prefix, $threshold, $write_access);
561  $asset->setAttrValue('threshold', $threshold);
562  return TRUE;
563 
564  }//end processThresholds()
565 
566 
578  function paintAddRule(&$asset, &$o, $prefix, $write_access)
579  {
580  $o->openField(translate('bulkmail_threshold_add_rule'), '', translate('bulkmail_threshold_add_rule_note'));
581  if ($write_access) {
582  $rules = Array('' => '-- '.translate('bulkmail_threshold_choose_type').' --');
583  $rules += Array(
584  translate('bulkmail_threshold_rule_excluded_time'),
585  translate('bulkmail_threshold_rule_send_rate'),
586  );
587  combo_box($prefix.'_rule_type', $rules, FALSE, '');
588  }
589  $o->closeField();
590 
591  }//end paintAddRule()
592 
593 
606  function processAddRule(&$asset, &$o, $prefix, $threshold, $write_access)
607  {
608  if ($write_access) {
609  $rules = Array(
610  translate('bulkmail_threshold_rule_excluded_time'),
611  translate('bulkmail_threshold_rule_send_rate'),
612  );
613  if (isset($_POST[$prefix.'_rule_type'])) {
614  $type = (isset($rules[$_POST[$prefix.'_rule_type']])) ? $rules[$_POST[$prefix.'_rule_type']] : '';
615  }
616  // multiple entries not allowed for this rule type
617  foreach ($threshold as $key => $val) {
618  if ($val['type'] == $type) {
619  if (!$val['multiple']) return $threshold;
620  }
621  }
622  $threshold_types = $asset->attr('threshold_types');
623  switch ($type) {
624  case translate('bulkmail_threshold_rule_excluded_time') :
625  $threshold_types[0]['type'] = $type;
626  $threshold[] = $threshold_types[0];
627  break;
628  case translate('bulkmail_threshold_rule_send_rate') :
629  $threshold_types[1]['type'] = $type;
630  $threshold[] = $threshold_types[1];
631  break;
632  default:
633  break;
634  }
635  }
636 
637  return $threshold;
638 
639  }//end processAddRule()
640 
641 
654  function _paintExcludedTimeRule(&$asset, &$o, $prefix, $rule, $write_access)
655  {
656  $hours_array = Array(
657  0 => '00',
658  1 => '01',
659  2 => '02',
660  3 => '03',
661  4 => '04',
662  5 => '05',
663  6 => '06',
664  7 => '07',
665  8 => '08',
666  9 => '09',
667  10 => '10',
668  11 => '11',
669  12 => '12',
670  13 => '13',
671  14 => '14',
672  15 => '15',
673  16 => '16',
674  17 => '17',
675  18 => '18',
676  19 => '19',
677  20 => '20',
678  21 => '21',
679  22 => '22',
680  23 => '23',
681  );
682  $days_array = Array(
683  0 => translate('sunday'),
684  1 => translate('monday'),
685  2 => translate('tuesday'),
686  3 => translate('wednesday'),
687  4 => translate('thursday'),
688  5 => translate('friday'),
689  6 => translate('saturday'),
690  );
691 
692  if ($write_access) {
693  ob_start();
694  combo_box($prefix.'_from', $hours_array, FALSE, $rule['params']['from']);
695  $from = ob_get_contents();
696  ob_end_clean();
697  ob_start();
698  combo_box($prefix.'_to', $hours_array, FALSE, $rule['params']['to']);
699  $to = ob_get_contents();
700  ob_end_clean();
701  ob_start();
702  combo_box($prefix.'_days', $days_array, TRUE, $rule['params']['days']);
703  $days = ob_get_contents();
704  ob_end_clean();
705  ?><td class="sq-backend-table-cell"><?php
706  echo translate('bulkmail_threshold_rule_excluded_time_hour', $from, $to);
707  echo translate('bulkmail_threshold_rule_excluded_time_days', $days);
708  ?></td><td class="sq-backend-table-cell"><?php
709  check_box($prefix.'_delete', TRUE, FALSE);?></td><?php
710  } else {
711  $from = $hours_array[$rule['params']['from']];
712  $to = $hours_array[$rule['params']['to']];
713  if (!empty($rule['params']['days'])) {
714  $selected_days = Array();
715  foreach ($rule['params']['days'] as $day) {
716  $selected_days[] = $days_array[$day];
717  }
718  $days = implode(', ', $selected_days);
719  }
720  ?><td class="sq-backend-table-cell" colspan="2"><?php
721  echo translate('bulkmail_threshold_rule_excluded_time_hour', $from, $to);
722  if (!empty($days)) {
723  if (count($selected_days) == 7) {
724  echo translate('bulkmail_threshold_rule_excluded_time_every_day');
725  } else {
726  echo translate('bulkmail_threshold_rule_excluded_time_days', $days);
727  }
728  }
729  ?></td><?php
730  }
731 
732  }//end _paintExcludedTimeRule()
733 
734 
745  function _processExcludedTimeRule($prefix, $threshold, $key)
746  {
747  // make changes to threshold attribute accordingly and pass it back to the process function
748  $remove = FALSE;
749  if (isset($_POST[$prefix.'_from'])) {
750  $params['from'] = $_POST[$prefix.'_from'];
751  $params['to'] = $_POST[$prefix.'_to'];
752  // check for valid range
753  if ($_POST[$prefix.'_to'] == $params['from']) {
754  trigger_localised_error('BML0014', E_USER_NOTICE);
755 
756  if ($threshold[$key]['params']['to'] == $_POST[$prefix.'_to'] && $threshold[$key]['params']['from'] == $_POST[$prefix.'_from']) {
757  $remove = TRUE;
758  } else {
759  $params['from'] = $threshold[$key]['params']['from'];
760  $params['to'] = $threshold[$key]['params']['to'];
761  }
762  }
763 
764  if (!isset($_POST[$prefix.'_days']) && !isset($threshold[$key]['params']['days'])) {
765  trigger_localised_error('BML0015', E_USER_NOTICE);
766  $remove = TRUE;
767  } else if (!isset($_POST[$prefix.'_days']) && isset($threshold[$key]['params']['days'])) {
768  trigger_localised_error('BML0015', E_USER_NOTICE);
769  $params['days'] = $threshold[$key]['params']['days'];
770  } else {
771  $params['days'] = (isset($_POST[$prefix.'_days'])) ? $_POST[$prefix.'_days'] : Array();
772  }
773  }
774  $threshold[$key]['params'] = $params;
775  // delete box is checked
776  if (isset($_POST[$prefix.'_delete']) || $remove) {
777  unset($threshold[$key]);
778  }
779 
780  return $threshold;
781 
782  }//end _processExcludedTimeRule()
783 
784 
797  function _paintSendRateRule(&$asset, &$o, $prefix, $rule, $write_access)
798  {
799  $time_unit = Array(
800  60 => translate('minute'),
801  3600 => translate('hour'),
802  86400 => translate('day'),
803  );
804  // make sure the send rate is within this range
805  $min_send_rate = 1;
806  $max_send_rate = 600;
807  $send_rate = ($rule['params']['value']/$rule['params']['unit']) * 60;
808  if ($write_access) {
809  ob_start();
810  int_text_box($prefix.'_value', $rule['params']['value'], FALSE);
811  $value = ob_get_contents();
812  ob_end_clean();
813  ob_start();
814  combo_box($prefix.'_unit', $time_unit, FALSE, $rule['params']['unit']);
815  $unit = ob_get_contents();
816  ob_end_clean();
817  ?><td class="sq-backend-table-cell"><?php
818  echo translate('bulkmail_threshold_rule_send_rate_detail', $value, $unit);
819  if ($send_rate < $min_send_rate) {
820  ?><br /><span class="sq-backend-warning"><?php echo translate('bm_warning_send_rate_min', $min_send_rate); ?></span><?php
821  } else if ($send_rate > $max_send_rate) {
822  ?><br /><span class="sq-backend-warning"><?php echo translate('bm_warning_send_rate_max', $max_send_rate); ?></span><?php
823  }
824  ?></td><td class="sq-backend-table-cell"><?php
825  check_box($prefix.'_delete', TRUE, FALSE);?></td><?php
826  } else {
827  $value = $rule['params']['value'];
828  $unit = $time_unit[$rule['params']['unit']];
829  ?><td class="sq-backend-table-cell" colspan="2"><?php
830  echo translate('bulkmail_threshold_rule_send_rate_detail', $value, $unit);
831  if ($send_rate < $min_send_rate) {
832  ?><br /><span class="sq-backend-warning"><?php echo translate('bm_warning_send_rate_min', $min_send_rate); ?></span><?php
833  } else if ($send_rate > $max_send_rate) {
834  ?><br /><span class="sq-backend-warning"><?php echo translate('bm_warning_send_rate_max', $max_send_rate); ?></span><?php
835  }
836  ?></td><?php
837  }
838 
839  }//end _paintSendRateRule()
840 
841 
852  function _processSendRateRule($prefix, $threshold, $key)
853  {
854  if (isset($_POST[$prefix.'_value'])) {
855  $params['value'] = $_POST[$prefix.'_value'];
856  $params['unit'] = $_POST[$prefix.'_unit'];
857  // do not allow zero rate
858  if (!$params['value']) $params['value'] = 1;
859  }
860  $threshold[$key]['params'] = $params;
861  if (isset($_POST[$prefix.'_delete'])) {
862  unset($threshold[$key]);
863  }
864 
865  return $threshold;
866 
867  }//end _processSendRateRule()
868 
869 
870 //-- JOB MANAGEMENT --//
871 
872 
883  function paintJobQueue(&$asset, &$o, $prefix)
884  {
885  $write_access = $asset->writeAccess('attributes');
886  $bulkmail_manager = $GLOBALS['SQ_SYSTEM']->am->getSystemAsset('bulkmail_manager');
887  $bulkmail_manager_edit_fns = $bulkmail_manager->getEditFns();
888  $o->openField('');
889  $jobs = $bulkmail_manager->getQueuedJobs(NULL, $asset->id);
890  $bulkmail_manager_edit_fns->_paintJobQueue($asset, $jobs);
891  $o->closeField();
892 
893  return $write_access;
894 
895  }//end paintJobQueue()
896 
897 
908  function processJobQueue(&$asset, &$o, $prefix)
909  {
910  $write_access = $asset->writeAccess('attributes');
911  $bulkmail_manager = $GLOBALS['SQ_SYSTEM']->am->getSystemAsset('bulkmail_manager');
912  $bulkmail_manager_edit_fns = $bulkmail_manager->getEditFns();
913  if (!$write_access) return;
914 
915  $jobs = $bulkmail_manager->getQueuedJobs(NULL, $asset->id);
916  $bulkmail_manager_edit_fns->_processJobQueue($asset, $jobs);
917 
918  return TRUE;
919 
920  }//end processJobQueue()
921 
922 
932  function showProgressSection(&$asset, $prefix)
933  {
934  $bulkmail_manager = $GLOBALS['SQ_SYSTEM']->am->getSystemAsset('bulkmail_manager');
935  $jobs = $bulkmail_manager->getQueuedJobs(NULL, $asset->id);
936 
937  return (empty($jobs) ? FALSE : TRUE);
938 
939  }//end showProgressSection()
940 
941 
942 }//end class
943 
944 
945 ?>