Mailinglist
 All Data Structures Files Functions Variables Pages
Mailman21List Class Reference

Mailman 2.1.x List Personality Plugin. More...

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

Public Member Functions

ctools_export_ui

 edit_form (&$form, &$form_state)
 Implements ctools_export_ui::edit_form(). More...
 
 edit_form_submit (&$form, &$form_state)
 
MailinglistListInterface

 checkMessage (MailinglistMessageInterface $msg)
 checkMessage() More...
 
 processMessage (MailinglistMessageInterface $msg)
 processMessage() More...
 
 getMemberInfo ($email)
 getMemberInfo() More...
 
 SubscribeForm (&$form, &$form_state)
 Operation Forms. More...
 
 UnsubscribeForm (&$form, &$form_state)
 
 OptionsForm ($form, $form_state)
 
 getMemberPage ($page)
 getMemberPage More...
 
 getWebPage ($url, $post="")
 getWebPage More...
 
- Public Member Functions inherited from MailinglistList
 getWebPage ($url, $post="")
 getWebPage More...
 
 checkMessage (MailinglistMessageInterface $msg)
 Called on each message read from a mailbox to see if we want to process it. More...
 
 genericListMatch (MailinglistMessageInterface $msg)
 generic_list_match() More...
 
 processMessage (MailinglistMessageInterface $message)
 message_process() More...
 
 schema (&$schema, $type)
 schema() More...
 
 getMemberInfo ($email)
 getMemberInfo() More...
 
 getMemberPage ($page)
 getMemberPage() More...
 
 edit_form (&$form, &$form_state)
 Implements ctools_export_ui::edit_form(), cross linked via mailinglist_export_ui.class.php. More...
 
 edit_form_validate (&$form, &$form_state)
 edit_form_validate() More...
 
- Public Member Functions inherited from MailinglistExportable
 get_setting ($name, $def=NULL)
 get_settings() More...
 
 created ()
 created() More...
 
 edited ($old)
 edited() More...
 
 changedType (MailinglistPolymorpicExportableInterface $old)
 changedType() More...
 
 delete ()
 delete() More...
 
 baseName ()
 baseName() More...
 
 edit_form (&$form, &$form_state)
 Implements ctools_export_ui::edit_form() called via mailinglist_export_ui Build an edit form for our object. More...
 
 edit_form_validate (&$form, &$form_state)
 Implements ctools_export_ui::edit_form_validate(). More...
 
 edit_form_submit (&$form, &$form_state)
 Implements ctools_export_ui::edit_form_submit(). More...
 
 log ($str, $level=self::LOG_NOTICE, $parms=array())
 log() More...
 
 log_screen ($str, $parms=array(), $level=self::LOG_NOTICE)
 log_screen() More...
 
 log_db ($str, $parms=array(), $level=self::LOG_ERROR)
 log_db(). More...
 
 log_file ($str, $parms=array(), $level=self::LOG_INFO)
 log_file(). More...
 
MailinglistPolymorphicExportableInterface
MailinglistListInterface

Additional Inherited Members

- Data Fields inherited from MailinglistList
 $operations
 
 $parameters
 
- Data Fields inherited from MailinglistExportable
 $object_type
 The type of object we are. More...
 
 $settings
 Generic Array to hold misc settings so all can use same schema. More...
 
 $export_type
 Needed by CTools. More...
 
const LOG_OFF = 0
 
const LOG_SCREEN = 1
 
const LOG_DB = 2
 
const LOG_DB_SCREEN = 3
 
const LOG_FILE = 4
 
const LOG_FILE_SCREEN = 5
 
const LOG_DEBUG = WATCHDOG_DEBUG
 
const LOG_INFO = WATCHDOG_INFO
 
const LOG_NOTICE = WATCHDOG_NOTICE
 
const LOG_WARNING = WATCHDOG_WARNING
 
const LOG_ERROR = WATCHDOG_ERROR
 
const LOG_CRITICAL = WATCHDOG_CRITICAL
 
const LOG_ALERT = WATCHDOG_ALERT
 
const LOG_EMERGENCY = WATCHDOG_EMERGENCY
 
 $logging_screen = self::LOG_DEBUG
 
 $logging_db = self::LOG_INFO
 
 $logging_file = self::LOG_DEBUG
 

Detailed Description

Mailman 2.1.x List Personality Plugin.

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

Member Function Documentation

checkMessage ( MailinglistMessageInterface  $msg)

checkMessage()

Implements MailinglistList::checkMessage().

Todo:
Implement Mailman21::checkMessage().

Implements MailinglistListInterface.

Definition at line 70 of file Mailman21List.class.php.

70  {
71  return parent::checkMessage($msg);
72  }
edit_form ( $form,
$form_state 
)

Implements ctools_export_ui::edit_form().

Definition at line 21 of file Mailman21List.class.php.

References _mailinglist_decode_password(), and MailinglistExportable\get_setting().

21  {
22  parent::edit_form($form, $form_state);
23  $form['basic']['settings']['admin_url'] = array(
24  '#type' => 'textfield',
25  '#title' => t('Mailman URL Base'),
26  '#default_value' => $this->get_setting('admin_url'),
27  '#required' => TRUE,
28  '#description' => t('Base URL of admin page (typically something like http://example.com/mailman )'),
29  '#weight' => 60,
30  );
31  $form['basic']['settings']['listname'] = array(
32  '#type' => 'textfield',
33  '#title' => t('List Name'),
34  '#default_value' => $this->get_setting('listname'),
35  '#required' => TRUE,
36  '#description' => t('Name of list as appears in URLs for the list'),
37  '#weight' => 60,
38  );
39  $form['basic']['settings']['admin_password'] = array(
40  '#type' => 'textfield',
41  '#title' => t('Admin Password'),
42  '#default_value' => _mailinglist_decode_password($this->get_setting('admin_password')),
43  '#required' => TRUE,
44  '#description' => t('Password to access List Interface'),
45  '#weight' => 60,
46  );
47  }
get_setting($name, $def=NULL)
get_settings()
_mailinglist_decode_password($code)
_mailinglist_decode_password

Here is the call graph for this function:

edit_form_submit ( $form,
$form_state 
)

Definition at line 51 of file Mailman21List.class.php.

References _mailinglist_encode_password().

51  {
52  dpm($form_state, 'Mailman21List::edit_form_submit');
53 
54  $form_state['values']['settings']['admin_password'] = _mailinglist_encode_password($form_state['values']['settings']['admin_password']);
55  }
_mailinglist_encode_password($pass)
_mailinglist_encode_password

Here is the call graph for this function:

getMemberInfo (   $email)

getMemberInfo()

Get information about a subscriber

Parameters
$emailString with email address of member to look update
Returns
If member does not exist, then returns FALSE, else returns an array with the information about the subcriber.
Todo:
Decode rest of options

Implements MailinglistListInterface.

Definition at line 94 of file Mailman21List.class.php.

References MailinglistExportable\get_setting(), getWebPage(), MAILINGLIST_SUB_DIGEST, MAILINGLIST_SUB_MIME_DIGEST, MAILINGLIST_SUB_NOMAIL, and MAILINGLIST_SUB_NORMAL.

94  {
95  $listname = $this->get_setting('listname');
96  $url = $this->get_setting('admin_url') . '/options/' . $this->get_setting('listname') . '/' . str_replace('@', '--at--', $email);
97  $data = $this->getWebPage($url);
98  dpm($data, 'Get Info: ' . $email);
99  $body = $data['body'];
100  $pos = strpos($body, 'Your ' . $listname . ' Subscription Options');
101  if ($pos === FALSE) {
102  dpm(FALSE, 'Info');
103  return FALSE;
104  }
105  $info = array('Email' => $email);
106  $pos1 = strpos($body, 'name="fullname"');
107  $pos1 = strpos($body, 'value=', $pos1)+7;
108  $end = strpos($body, '"', $pos1);
109  $name = substr($body, $pos1, $end-$pos1);
110  $info['Name'] = $name;
111 
112  $pos = strpos($body, 'name="disablemail"', $pos);
113  $pos = strpos($body, 'CHECKED', $pos);
114  $no_mail = substr($body, $pos-3, 1);
115  //$info['NoMail'] = $no_mail;
116 
117  $pos = strpos($body, 'name="digest"', $pos);
118  $pos = strpos($body, 'CHECKED', $pos);
119  $digest = substr($body, $pos-3, 1);
120  //$info['Digest'] = $digest;
121 
122  $pos = strpos($body, 'name="mime"', $pos);
123  $pos = strpos($body, 'CHECKED', $pos);
124  $plain = substr($body, $pos-3, 1);
125  //$info['Plain'] = $plain;
126 
127  $info['Type'] = ($no_mail == '1' ? MAILINGLIST_SUB_NOMAIL :
128  ($digest == '0' ? MAILINGLIST_SUB_NORMAL :
130 
132  dpm($info, 'Info');
133  return $info;
134  }
const MAILINGLIST_SUB_MIME_DIGEST
get_setting($name, $def=NULL)
get_settings()
const MAILINGLIST_SUB_NOMAIL
const MAILINGLIST_SUB_DIGEST
getWebPage($url, $post="")
getWebPage
const MAILINGLIST_SUB_NORMAL

Here is the call graph for this function:

getMemberPage (   $page)

getMemberPage

Parameters
$pagePage code to fetch.
Returns
array of member info. Subscript is email address of subscriber element is an array of subscriber info. ['Email'] Email address. ['Name'] Name of subscriber ['Moderated'] Is subscriber on moderation? ['Hide'] Has subscriber chosen to hide their membership. ['NoMail'] Source of being on Nomail (U/A/B) ['Ack'] Should user get message Ack? ['MeToo'] Supress MeToo Setting. ['NoDups'] Suppress Duplicate messages. ['Type'] Subscription Type ( (None), Nomail, Normal, Digest, MimeDigest) ['Language'] Subscriber language setting.

Note, this function needs mailinglist_members loaded

Bug:
need to check that we HAVE multiple pages
Bug:
need to check that we have multiple pages

Implements MailinglistListInterface.

Definition at line 222 of file Mailman21List.class.php.

References MailinglistExportable\get_setting(), getWebPage(), MailinglistExportable\log(), MAILINGLIST_SUB_DIGEST, MAILINGLIST_SUB_MIME_DIGEST, MAILINGLIST_SUB_NOMAIL, and MAILINGLIST_SUB_NORMAL.

222  {
223  if (!$page) {
224  $pagecode = '';
225  }
226  else {
227  $pagecode = '?letter=' . $page[0] . '&chunk=' . $page[1];
228  }
229  $url = $this->get_setting('admin_url') . '/admin/' . $this->get_setting('listname') . '/members' . $pagecode;
230  $data = $this->getWebPage($url);
231  dpm($data, 'Page Data');
232  $body = $data['body'];
233  $pos = strpos($body, 'Membership List');
234  $liststart = $pos;
235  if (!$page) {
236  // If starting, find where we start
238  $pos = strpos($body, 'letter=', $pos)+7;
239  $page[0] = substr($body, $pos, 1);
240  $page[1] = 0;
241  }
242  $next = $page;
244  $next[1] = $next[1]+1;
245  if (FALSE === strpos($body, 'chunk=' . $next[1], $pos)) {
246  // Don't find a listing for next chunk for this letter.
247  $next[1] = 0;
248  if($pos < 7) {
249  $this->log('Bad Pos1 ' . $pos . '\n' . html_specialchars($body), SELF::LOG_ERROR);
250  return array('next' => $next, 'page' => $page, 'members' => array());
251  }
252  $pos = strpos($body, 'letter=' . $next[0] . '"', $pos-7); // need to back up in case we found first letter
253  if($pos < 7) {
254  $this->log('Bad Pos2 ' . $pos . '\n' . html_specialchars($body), SELF::LOG_ERROR);
255  return array('next' => $next, 'page' => $page, 'members' => array());
256  }
257  $pos = strpos($body, 'letter=', $pos+7) + 7;
258  $letter = substr($body, $pos, 1);
259  if ($pos > 7 && $letter != $next[0]) {
260  $next[0] = $letter;
261  }
262  else {
263  $next = FALSE; // end of data.
264  }
265  }
266 
267  $members = array();
268  $pos = strpos($body, 'member address', $pos); // Advance to Header
269  $endpos = strpos($body, '</table>', $pos); // End of table
270  $pos = strpos($body, '<tr>', $pos);
271  while ($pos < $endpos) {
272  $pos1 = strpos($body, '</tr>', $pos);
273  $record = substr($body, $pos, $pos1-$pos+5);
274  $record = explode('<td>', $record);
275  // record [0] is <tr>
276  // record [1] is unsub.
277  // record [2] is email address, real name
278  $start = strpos($record[2], '>');
279  $end = strpos($record[2], '</a>');
280  $email = substr($record[2], $start+1, $end - $start-1);
281  $info['Email'] = $email;
282  $start = strpos($record[2], 'value=', $end) + 7;
283  $end = strpos($record[2], '"', $start);
284  $name = substr($record[2], $start, $end - $start);
285  $info['Name'] = $name;
286  // record[3] = Moderated.
287  $start = strpos($record[3], 'value=') + 7;
288  $end = strpos($record[3], '"', $start);
289  $mod = substr($record[3], $start, $end - $start);
290  $info['Moderated'] = $mod == "on";
291  // record[4] = Hide.
292  $start = strpos($record[4], 'value=') + 7;
293  $end = strpos($record[4], '"', $start);
294  $hide = substr($record[4], $start, $end - $start);
295  $info['Hide'] = $hide == "on";
296  // record[5] = NoMail.
297  $start = strpos($record[5], 'value=') + 7;
298  $end = strpos($record[5], '"', $start);
299  $no_mail = substr($record[5], $start, $end - $start);
300  if ($no_mail == 'on') {
301  $start = strpos($record[5], '[', $end)+1;
302  $info['NoMail'] = substr($record[5], $start, 1);
303  }
304  else {
305  $info['NoMail'] = FALSE;
306  }
307  // record[6] = Ack.
308  $start = strpos($record[6], 'value=') + 7;
309  $end = strpos($record[6], '"', $start);
310  $ack = substr($record[6], $start, $end - $start);
311  $info['Ack'] = $ack == "on";
312  // record[7] = MeToo.
313  $start = strpos($record[7], 'value=') + 7;
314  $end = strpos($record[7], '"', $start);
315  $metoo = substr($record[7], $start, $end - $start);
316  $info['MeToo'] = $metoo == 'on';
317  // record[8] = NoDups.
318  $start = strpos($record[8], 'value=') + 7;
319  $end = strpos($record[8], '"', $start);
320  $no_dups = substr($record[8], $start, $end - $start);
321  $info['NoDups'] = $no_dups == 'on';
322  // record[9] = digest.
323  $start = strpos($record[9], 'value=') + 7;
324  $end = strpos($record[9], '"', $start);
325  $digest = substr($record[9], $start, $end - $start);
326  // record[10] = Plain Digest.
327  $start = strpos($record[10], 'value=') + 7;
328  $end = strpos($record[10], '"', $start);
329  $plain = substr($record[10], $start, $end - $start);
330  $info['Type'] = ($no_mail == "on" ? MAILINGLIST_SUB_NOMAIL :
331  ($digest == 'off' ? MAILINGLIST_SUB_NORMAL :
333 
334  // record[11] = Language.
335  $end = strpos($record[11], 'Selected') - 2;
336  $string = substr($record[11], 0, $end);
337  $start = strrpos($string, '"') + 1;
338  $lang = substr($record[11], $start, $end - $start);
339  $info['Language'] = $lang;
340 
341  $members[$email] = $info;
342  // Find next entry
343  $pos = strpos($body, '<tr>', $pos1);
344  }
345  return array('next' => $next, 'page' => $page, 'members' => $members);
346  }
const MAILINGLIST_SUB_MIME_DIGEST
get_setting($name, $def=NULL)
get_settings()
log($str, $level=self::LOG_NOTICE, $parms=array())
log()
const MAILINGLIST_SUB_NOMAIL
const MAILINGLIST_SUB_DIGEST
getWebPage($url, $post="")
getWebPage
const MAILINGLIST_SUB_NORMAL

Here is the call graph for this function:

getWebPage (   $url,
  $post = "" 
)

getWebPage

Fetch web page via cURL, and return resultant page.

Parameters
$urlThe URL to fetch.
$postPost data for request (if any)
Returns
The results web page and headers as an array.
Todo:
Do we want to check for bad login and error out here?

Definition at line 357 of file Mailman21List.class.php.

References _mailinglist_decode_password(), and MailinglistExportable\get_setting().

Referenced by getMemberInfo(), and getMemberPage().

357  {
358  $page = parent::getWebPage($url, $post);
359  if (strpos($page['body'], 'name="admlogin"') ) {
360  $login_post = 'adminpw=' . _mailinglist_decode_password($this->get_setting('admin_password'));
361  $page = parent::getWebPage( $url, $login_post);
363  }
364  return $page;
365  }
get_setting($name, $def=NULL)
get_settings()
_mailinglist_decode_password($code)
_mailinglist_decode_password

Here is the call graph for this function:

Here is the caller graph for this function:

OptionsForm (   $form,
  $form_state 
)

Definition at line 184 of file Mailman21List.class.php.

184  {
185  $form['notice'] = array(
186  '#markup' => '<b>** Notice: Not Fully Implemented</b>',
187  '#weight' => -90);
188 
189  $form['email'] = array(
190  '#type' => 'textfield',
191  '#title' => t('EMail Address'),
192  '#default_value' => 'somebody@example.com',
193  '#required' => TRUE,
194  '#description' => t('This is the Email address which email from the list will be sent'),
195  '#weight' => 20,
196  );
197 
198  dpm($form, 'Options Form');
199  }
processMessage ( MailinglistMessageInterface  $msg)

processMessage()

Implements MailinglistList::processMessage().

Todo:
Implement Mailman21::processMessage().

Implements MailinglistListInterface.

Definition at line 80 of file Mailman21List.class.php.

80  {
81  return parent::processMessage($msg);
82  }
SubscribeForm ( $form,
$form_state 
)

Operation Forms.

Definition at line 143 of file Mailman21List.class.php.

143  {
144  global $help;
145  $form['notice'] = array(
146  '#markup' => '<b>** Notice: Not Fully Implemented</b>',
147  '#weight' => -90);
148 
149  $form['email'] = array(
150  '#type' => 'textfield',
151  '#title' => t('EMail Address'),
152  '#default_value' => 'somebody@example.com',
153  '#required' => TRUE,
154  '#description' => t('This is the Email address which email from the list will be sent'),
155  '#weight' => 20,
156  );
157 
158  dpm($form, 'Subscribe Form');
159  }
UnsubscribeForm ( $form,
$form_state 
)

Definition at line 164 of file Mailman21List.class.php.

164  {
165  $form['notice'] = array(
166  '#markup' => '<b>** Notice: Not Fully Implemented</b>',
167  '#weight' => -90);
168 
169  $form['email'] = array(
170  '#type' => 'textfield',
171  '#title' => t('EMail Address'),
172  '#default_value' => 'somebody@example.com',
173  '#required' => TRUE,
174  '#description' => t('This is the Email address which email from the list will be sent'),
175  '#weight' => 20,
176  );
177 
178  dpm($form, 'Unsubscribe Form');
179  }

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