Mailinglist
 All Data Structures Files Functions Variables Pages
MailinglistMembersOperation Class Reference

Base Class for Mailinglist extensions. More...

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

Public Member Functions

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 MailinglistMembersOperation.class.php.

Member Function Documentation

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.

URL: base/$listname/members/$section

Todo:

Member Page, Build summary.

Member Page, Build Details. (Check extra permissions)

Add variable chunking to listing.

Todo:
add more info into block
Todo:
add paging

Implements MailinglistOperationInterface.

Definition at line 31 of file MailinglistMembersOperation.class.php.

References _mailinglist_datetime_ts(), mailinglist_members_scan(), MAILINGLIST_SUB_DIGEST, MAILINGLIST_SUB_INDEX, MAILINGLIST_SUB_MIME_DIGEST, MAILINGLIST_SUB_NO, MAILINGLIST_SUB_NOMAIL, and MAILINGLIST_SUB_NORMAL.

31  {
32  $section = $form_state['build_info']['args'][2];
33  $chunksize = 30; //@todo: make configurable
34  $listname = $list->admin_name;
35 
36 // Admin Progress line, only show to those with 'administer mailinglist members' permission
37  if (user_access('administer mailinglist members')) {
38  if ($section == "test") {
40  }
41  $ScanStart = format_date(_mailinglist_datetime_ts($list->parameters['ScanStart']), 'long');
42  $progress = 'Progress: ' . $ScanStart . ' : ';
43  $next = $list->parameters['ScanNext'];
44  if (is_array($next)) {
45  foreach ($next as $item) {
46  $progress .= (string)$item . ' ';
47  }
48  }
49  else {
50  if($next === TRUE) {
51  $progress .= 'Cleanup';
52  }
53  elseif ($next === FALSE) {
54  $progress .= 'Done';
55  }
56  else {
57  $progress .= (string)$next;
58  }
59  }
60  $form['progress'] = array('#markup' => $progress . '<br>');
61  }
62 
63  $sub_types = array(
64  MAILINGLIST_SUB_NO => "Not Subscribed",
65  MAILINGLIST_SUB_NOMAIL => "No Mail",
66  MAILINGLIST_SUB_INDEX => "Index:",
67  MAILINGLIST_SUB_DIGEST => 'Digest',
68  MAILINGLIST_SUB_MIME_DIGEST => 'Mime Digest',
69  MAILINGLIST_SUB_NORMAL => 'Individual Messages',
70  );
71 
72 // If don't have 'mailinglist $listname member details" or not in a section
73 // Display a summary of members.
74  if (!user_access('mailinglist ' . $listname . ' member details')
75  or 0 == strlen($section) or $section == 'test') {
76 
77  $sql = 'SELECT sub_type, COUNT(sub_type) as cnt' .
78  ' FROM {mailinglist_members_subscribers__' . $listname . '}' .
79  ' WHERE sub_type > 0 GROUP BY sub_type ORDER BY cnt DESC';
80  $result = db_query($sql, array());
81  $total = 0;
82  while ($row = $result -> fetchAssoc()) {
83  $cat = $row['sub_type'];
84  $cnt = $row['cnt'];
85  $subs[$sub_types[$cat]] = $cnt;
86  $total += $cnt;
87  }
88 
89  $form['Member Total'] =
90  array('#markup' => 'Membership Summary: ' . $total . ' Members<br>');
91  $form['Sub Types'] = array(
92  '#theme' => 'table',
93  '#header' => array(
94  array('data' => t('Subscription Type')),
95  array('data' => t('Percentage')),
96  ),
97  '#rows' => array(),
98  );
99  foreach ($subs as $type => $cnt) {
100  $form['Sub Types']['#rows'][$type] = array($type, number_format(100*$cnt/$total, 1) . '%');
101  }
102 
103  $form['Domains'] = array(
104  '#theme' => 'table',
105  '#header' => array(
106  array('data' => t('Domain')),
107  array('data' => t('Percentage')),
108  ),
109  '#rows' => array(),
110  );
111 
112  $sql = 'SELECT domain, COUNT(sub_type) as cnt' .
113  ' FROM {mailinglist_members_subscribers__' . $listname . '}' .
114  ' WHERE sub_type > 0 GROUP BY domain HAVING cnt >= 20 ORDER BY cnt DESC LIMIT 10' ;
115  $result = db_query($sql, array());
116 
117  while ($row = $result -> fetchAssoc()) {
118  $domain = $row['domain'];
119  $cnt = $row['cnt'];
120  $form['Domains']['#rows'][$domain] = array($domain, number_format(100*$cnt/$total, 1) . '%');
121  }
122  }
123 
124 // Details Section, only show if have 'mailinglist $listname member details'
125 
126  if (user_access('mailinglist ' . $listname . ' member details')) {
127  // Header, with list of letters used
128 
129  $base = variable_get('mailinglist_base', 'mailinglist');
130 
131  $form['details']['home'] = array('#markup' => l('Summary', "$base/$listname/members") . ' ');
132  $sql = 'SELECT SUBSTRING(email, 1, 1) as c' .
133  ' FROM {mailinglist_members_subscribers__' . $listname . '}' .
134  ' GROUP BY c';
135  $result = db_query($sql, array());
136  while ($row = $result -> fetchAssoc()) {
137  $letter = $row['c'];
138  $form['details']['letters'][$letter] =
139  array('#markup' => l($letter, "$base/$listname/members/$letter") . ' ');
140  }
141 
142  if (user_access('administer mailinglist members')) {
143  $form['details']['test'] = array('#markup' => l('Test', "$base/$listname/members/test"));
144  }
145  // Detail block
148  if (0 < strlen($section) and $section != 'test') {
149  $letter = $section[0];
150  $nextletter = $letter . 'zzzzzzzzzzzzzzzzzz'; /* chr(ord($letter)+1); */
151  if(strlen($section) >1) {
152  $skip = $chunksize * (int)substr($section, 1);
153  } else {
154  $skip = 0;
155  }
156  $form['details']['members'] = array(
157  '#theme' => 'table',
158  '#header' => array(
159  'email' => array('data' => t('EMail')),
160  'type' => array('data' => t('Type')),
161  'moderated' => array('data' => t('Moderated')),
162  ),
163  '#rows' => array(),
164  );
165 
166  $sql = 'SELECT email, sub_type, moderated, options' .
167  ' FROM {mailinglist_members_subscribers__' . $listname . '}' .
168  ' WHERE sub_type > 0 and \'' .$letter .'\' <= email and email < \'' . $nextletter . '\'' .
169  ' ORDER BY email ASC';
170  $result = db_query($sql, array());
171  $index = 0;
172  $building = 0;
173  $chunk = 0;
174  while($row = $result -> fetchAssoc()){
175  if(!$building) {
176  $building = 1;
177  $firstname = $row['email'];
178  }
179  if($skip > 0) {
180  $skip--;
181  }
182  else if($index < $chunksize) {
183  $options = unserialize($row['options']);
184  $form['details']['members']['#rows'][$index] = array(
185  'email' => $row['email'],
186  'type' => $sub_types[$row['sub_type']],
187  'moderated' => $row['moderated'] ? 'Moderated' : '',
188  );
189  foreach($options as $key => $value) {
190  $form['details']['members']['#header'][$key] = array('data' => t($key));
191  if($value === False) {
192  $value = '-';
193  }
194  if($value === True) {
195  $value = $key;
196  }
197  $form['details']['members']['#rows'][$index][$key] = $value;
198  }
199  $index++;
200  }
201  else {
202  $index++;
203  }
204  if(($skip + $index) % $chunksize == 0) {
205  $form['details']['index'][$chunk] =
206  array('#markup' => l($firstname . ' - ' . $row['email'],
207  "$base/$listname/members/$letter$chunk") . '<br>');
208  $chunk++;
209  $building = 0;
210  }
211  } // End while($row)
212  }
213  }
214  } // End function form()
const MAILINGLIST_SUB_MIME_DIGEST
const MAILINGLIST_SUB_NO
Defines for sub_types (subscription types)
const MAILINGLIST_SUB_NOMAIL
const MAILINGLIST_SUB_DIGEST
const MAILINGLIST_SUB_INDEX
mailinglist_members_scan($list)
Process a partial scan of members for a mailinglist.
const MAILINGLIST_SUB_NORMAL
_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 233 of file MailinglistMembersOperation.class.php.

233  {
234  }
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 223 of file MailinglistMembersOperation.class.php.

223  {
224  }

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