Mailinglist
 All Data Structures Files Functions Variables Pages
Public Member Functions
MailinglistArchiveOperation Class Reference

Base Class for Mailinglist extensions. More...

Inheritance diagram for MailinglistArchiveOperation:
Inheritance graph
[legend]
Collaboration diagram for MailinglistArchiveOperation:
Collaboration graph
[legend]

Public Member Functions

 encodeDate ($date)
 Decode a "compressed" date into normal form. More...
 
 decodeDate ($date)
 
MailinglistOperationInterface
 form (&$form, &$form_state, $list)
 Operation page form generation. More...
 
 validate (&$form, &$form_state, $list)
 Operation page form validation. More...
 
 submit (&$form, &$form_state, $list)
 Operation page form submission. More...
 
- Public Member Functions inherited from MailinglistOperation
 isAvailable (MailinglistListInterface $list)
 Implements MailinglistOperationInterface::isAvailable(). More...
 
 hasPermission (MailinglistListInterface $list)
 Implements MailinglistOperationInterface::hasPermission(). More...
 
 enabled (MailinglistListInterface $list)
 Implements MailinglistOperationInterface::enabled(). More...
 
 disabled (MailinglistListInterface $list)
 Implements MailinglistOperationInterface::disabled(). More...
 
 form (&$form, &$form_state, $list)
 Operation page form generation. More...
 
 validate (&$form, &$form_state, $list)
 Operation page form validation. More...
 
 submit (&$form, &$form_state, $list)
 Operation page form submission. More...
 
MailinglistOperationInterface

Detailed Description

Base Class for Mailinglist extensions.

Definition at line 10 of file MailinglistArchiveOperation.class.php.

Member Function Documentation

decodeDate (   $date)

Definition at line 291 of file MailinglistArchiveOperation.class.php.

Referenced by form().

291  {
292 // dpm($date, 'Decode Start');
293  if(strlen($date) < 4) {
294  $date .= '0';
295  }
296  if(strlen($date) > 4) {
297  $date = substr($date, 0, 4) .'-' . substr($date, 4);
298  }
299  else {
300  $date .= '-00';
301  }
302  if(strlen($date) > 7) {
303  $date = substr($date, 0, 7) .'-' . substr($date, 7);
304  }
305  else {
306  $date .= '-00';
307  }
308  if(strlen($date) > 10) {
309  $date = substr($date, 0, 10) .' ' . substr($date, 10);
310  }
311  else {
312  $date .= ' 00';
313  }
314  if(strlen($date) > 13) {
315  $date = substr($date, 0, 13) .':' . substr($date, 13);
316  }
317  else {
318  $date .= ':00';
319  }
320  if(strlen($date) > 16) {
321  $date = substr($date, 0, 16) .':' . substr($date, 16);
322  }
323  else {
324  $date .= ':00';
325  }
326 // dpm($date, 'Decode End');
327  return $date;
328  }

Here is the caller graph for this function:

encodeDate (   $date)

Decode a "compressed" date into normal form.

Definition at line 285 of file MailinglistArchiveOperation.class.php.

Referenced by submit().

285  {
286  $time = strtotime($date);
287  $str = gmdate("YmdHis", $time);
288  return $str;
289  }

Here is the caller graph for this function:

form ( $form,
$form_state,
  $list 
)

Operation page form generation.

Parameters
$formForm for the page.
$form_stateForm state for the page.
$listList we are generating the page for.

Page parameters: [0]: list name.

[2]: Sorting/Special: msg/search/test/author/date/subject/thread/new. [3]: date range. [4]: page number.

For Special msg: [3] = mid of message to show. following parameters are for the search that got you there (so Sort in [4])

For Special search: [3]: date range. [4]: page number of chunck. [5]: Search parameters.

Todo:
Build Archives Page
Todo:
Achives parse data range.
Todo:
add navagation menu
Todo:
Archives Search

Implements MailinglistOperationInterface.

Definition at line 43 of file MailinglistArchiveOperation.class.php.

References _mailinglist_archive_scan(), _mailinglist_base_filename(), _mailinglist_datetime_ts(), _mailinglist_mailbox_scan(), decodeDate(), mailinglist_archive_message_get(), mailinglist_archive_reply_tree(), and mailinglist_archive_summary_list().

43  {
44  $type = $form_state['build_info']['args'][2];
45  if ($type == 'msg') {
46  $msgid = $form_state['build_info']['args'][3];
47  $sort = $form_state['build_info']['args'][4];
48  $off = 2;
49  }
50  else {
51  $off = 0;
52  $sort = $type;
53  }
54 
55  if(empty($sort)) {
56  $sort = 'new';
57  }
58 
59  $dates = $form_state['build_info']['args'][$off+3];
60  if(empty($dates)) {
61  $start_date = '1980-00-00 00:00:00';
62  $end_date = '2030-12-31 23:59:59';
63  }
64  else {
65  $pos = strpos($dates, '-');
66  if($pos === FALSE) {
67  $pos = strlen($dates);
68  }
69  if($pos > 0) {
70  $start_date = $this->decodeDate(substr($dates, 0, $pos));
71  }
72  else {
73  $start_date = '1980-00-00 00:00:00';
74  }
75  if($pos < strlen($dates) -1 ) {
76  $end_date = $this->decodeDate(substr($dates, $pos+1));
77  }
78  else {
79  $end_date = '2030-12-31 23:59:59';
80  }
81  }
82  $start_ts = _mailinglist_datetime_ts($start_date);
83  $end_ts = _mailinglist_datetime_ts($end_date);
84 
86  $page = $form_state['build_info']['args'][$off+4];
87 
88  $tablename = 'mailinglist_archives__' . $list->admin_name;
89 
90  $base = variable_get('mailinglist_base', 'mailinglist');
91 
93 
94  $pre = "$base/{$list->admin_name}/archive/";
95  $post = '';
96  if(!empty($dates)) {
97  $post .= '/' . $dates;
98  }
99 
100  $form['#theme'] = 'mailinglist_archive_form';
101 
102  /* Build Top of Form Nav Box */
103  $form['nav'] = array(
104  '#theme' => 'mailinglist_archive_form_header',
105  '#weight' => -10,
106  'order' => array(
107  '#type' => 'radios',
108  '#title' => 'Sort Order:',
109  '#required' => TRUE,
110  '#default_value' => $sort,
111  '#options' => array(
112  'author' => 'Author ',
113  'date' => 'Date ',
114  'new' => 'Newest ',
115  'subject' => 'Subject ',
116  'thread' => 'Threads ',
117  ),
118  ),
119  'start-wrap' => array(
120  '#type' => 'container',
121  '#attributes' => array('style' => array('float: left')),
122  '#weight' => 200,
123  'start' => array(
124  '#type' => 'textfield',
125  '#size' => 20,
126  '#title' => t('Start Date'),
127  '#default_value' => date('Y-m-d H:i:s', $start_ts),
128  '#required' => TRUE,
129  '#description' => t('The beginning of the period to use'),
130  ),
131  ),
132  'end-wrap' => array(
133  '#type' => 'container',
134  '#attributes' => array('style' => array('float: left')),
135  '#weight' => 210,
136  'end' => array(
137  '#type' => 'textfield',
138  '#size' => 20,
139  '#title' => t('End Date'),
140  '#default_value' => date('Y-m-d H:i:s', $end_ts),
141  '#required' => TRUE,
142  '#description' => t('The ending of the period to use'),
143  ),
144  ),
145  'buttons' => array(
146  '#weight' => 100,
147  '#type' => 'container',
148  '#attributes' => array('style' => array('float: left')),
149  'sort' => array(
150  '#type' => 'submit',
151  '#value' => t('Sort'),
152  ),
153  ),
154  'clear' => array(
155  '#type' => 'container',
156  '#weight' => 999,
157  '#attributes' => array('style' => array('clear: both')),
158  ),
159  );
160  if (user_access('administer mailinglist archive')) {
161  $listname = variable_get('mailinglist_mailbox_current_list');
162  $path = _mailinglist_base_filename(variable_get('mailinglist_mailbox_current', FALSE));
163  $offset = variable_get('mailinglist_mailbox_current_offset');
164  $msgcnt = variable_get('mailinglist_mailbox_current_max');
165  $queue = DrupalQueue::get('mailinglist_message');
166  $numitems = $queue->numberOfItems();
167 
168  if(empty($path)) {
169  $progress = 'Idle ';
170  }
171  else {
172  $progress = "$listname:$path (" . number_format($offset) . ' / ' .
173  number_format($msgcnt) . ") ";
174  }
175  $progress .= "Items to process " . $numitems;
176 
177  $mid = $list->parameters['ArchiveCheck'];
178  $form['progress'] = array(
179  '#weight' => -20,
180  '#markup' => $progress,
181  );
182  }
183  $domsglist = FALSE;
184  switch ($type) {
185  case 'test':
186  if (user_access('administer mailinglist archive')) {
189  }
190  break;
191  case 'search':
193  break;
194  case 'msg':
195  $result = mailinglist_archive_message_get($list, $msgid);
196 // dpm($result, 'Msg');
197  $form['msg'] = array(
198  '#theme' => 'mailinglist_message',
199  '#type' => 'item',
200  '#date' => _mailinglist_datetime_ts($result['time']),
201  'subject' => array('#markup' => $result['subject']),
202  'email' => array('#markup' => $result['email']),
203  'name' => array('#markup' => $result['name']),
204  'body' => array(
205  '#theme' => 'mailinglist_body',
206  '#item' => $result['body'],
207  '#markup' => nl2br(check_plain($result['body'])),
208  ),
209  );
210  if($result['reply_to']){
211  $form['msg']['reply_to'] = mailinglist_archive_summary_list($list, $result['reply_to']);
212  }
213  $form['msg']['replies'] = mailinglist_archive_reply_tree($list, $msgid);
214  break;
215  case 'author':
216  $domsglist = TRUE;
217  $order = 'ORDER BY n.name ASC';
218  break;
219  case 'date':
220  $domsglist = TRUE;
221  $order = 'ORDER BY a.time ASC';
222  break;
223  case 'thread':
224 // break;
225  case 'subject':
226  $domsglist = TRUE;
227  $order = 'ORDER BY a.subject ASC';
228  break;
229  default:
230  case 'new': // Reverse date order
231  $domsglist = TRUE;
232  $order = 'ORDER BY a.time DESC';
233  }
234  if($domsglist) {
235  $form['msglist'] = mailinglist_archive_summary_list($list,
236  array(':start' => $start_date, ':end' => $end_date),
237  'a.time >= :start AND a.time <= :end', $order, 50);
238  }
239 // dpm($form, 'form');
240  }
_mailinglist_mailbox_scan()
Process the configured mailing boxes.
_mailinglist_archive_scan($list)
Perform incremental scan of archive for problems.
mailinglist_archive_reply_tree($list, $msgid, $n=0)
mailinglist_archive_message_get($list, $msgid)
Get a full message by Msg ID.
mailinglist_archive_summary_list($list, $vars, $cond= '', $order="", $limit="")
Return list of message summaries.
_mailinglist_base_filename($path)
_mailinglist_base_filename().
_mailinglist_datetime_ts($time)
Convert a 'datetime' field into a timestamp.

Here is the call graph for this function:

submit ( $form,
$form_state,
  $list 
)

Operation page form submission.

Parameters
$formForm for the page.
$form_stateForm state for the page.
$listList we are generating the page for.

Implements MailinglistOperationInterface.

Definition at line 261 of file MailinglistArchiveOperation.class.php.

References encodeDate().

261  {
262  $base = variable_get('mailinglist_base', 'mailinglist');
263  $pre = "$base/{$list->admin_name}/archive/";
264 
265 // dpm($form);
266 // dpm($form_state);
267 
268  switch($form_state['values']['op']){
269  case 'Sort':
270  $order = $form_state['values']['order'];
271  $start = $this->encodeDate($form_state['values']['start']);
272  $end = $this->encodeDate($form_state['values']['end']);
273  $page = 0;
274  drupal_goto("$pre$order/$start-$end/$page");
275  default:
276 
277  }
278  }
encodeDate($date)
Decode a "compressed" date into normal form.

Here is the call graph for this function:

validate ( $form,
$form_state,
  $list 
)

Operation page form validation.

Parameters
$formForm for the page.
$form_stateForm state for the page.
$listList we are generating the page for.

Implements MailinglistOperationInterface.

Definition at line 249 of file MailinglistArchiveOperation.class.php.

249  {
250 // dpm($form);
251 // dpm($form_state);
252  }

The documentation for this class was generated from the following file: