DMail Milestone 1.0
Drupal Mail Client
|
Go to the source code of this file.
Implemented hooks, forms and themes for the email UI.
- The inbox is the only mail that receives "NEW" mail, modify the refresh to check only the inbox X time for mail.
- In the mailbox display of headers move the actions to a selection that will fire on change. This will allow for more items viewed per screen session.
- In the item display move the options for the item to the body table.
- Need to add action options for mesages from lists (list-help, list-unsubscribe, etc).
Definition in file dmail.user.inc.
dmail_user_identities | ( | ) |
Callback for user/%/email/identities.
Definition at line 24 of file dmail.user.inc.
{ return drupal_get_form('mfm_dmail_identities'); }
dmail_user_identities_add | ( | ) |
Callback for user/%/email/identities/add.
Definition at line 31 of file dmail.user.inc.
{ return drupal_get_form('mfm_dmail_identities_add'); }
mfm_dmail_attachment | ( | &$ | form_state, |
$ | item, | ||
$ | attidx | ||
) |
Attachment form.
Need to provide a return to item and download buttons/links and perhaps a preview of the first few bytes of the file data would be good or even allowing the file to be saved in the files directory.
Should I store the body attachments as files in the files directory?
- This makes a lot of sense to me. Maybe the tmp directory instead.
Definition at line 1504 of file dmail.user.inc.
References mfn_dmail_security_check().
{ global $user; mfn_dmail_security_check(); $cache = dcache_get(array('form', 'item'), DCACHE_SESSION); $attach =& $cache['attach'][$attidx]; drupal_set_header('Content-Type: application/' . strtolower($attach->subtype)); drupal_set_header('Cache-Control: private, must-revalidate, post-check=0, pre-check=0'); drupal_set_header('Content-Disposition: attachment; filename="' . $attach->filename . '"'); print $attach->contents; }
mfm_dmail_cancel_action | ( | &$ | form, |
&$ | form_state | ||
) |
Act on the Cancel button.
Definition at line 1232 of file dmail.user.inc.
{ $ns = array('form','reply'); $cmode = DCACHE_SESSION; dcache_del($ns, $cmode); $args = arg(); $uri = "user/{$args[1]}/email/{$args[3]}/mbox/{$args[5]}/view/{$args[7]}"; drupal_goto($uri); }
mfm_dmail_copy_item | ( | &$ | form_state, |
$ | header_id | ||
) |
Copy this item to another folder form.
Definition at line 1421 of file dmail.user.inc.
References mfn_dmail_security_check().
{ global $user; mfn_dmail_security_check(); drupal_set_message('The Copy form is still under development.', 'warning'); $form['dmail']['reply']['message'] = array( '#value' => "You've requested to copy item: $header_id", ); return $form; }
mfm_dmail_delete_item | ( | &$ | form_state, |
$ | header_id | ||
) |
Mark this item for delete form.
Definition at line 1343 of file dmail.user.inc.
References mfn_dmail_security_check().
{ global $user; mfn_dmail_security_check(); drupal_set_message('The Delete form is still under development.', 'warning'); $form['dmail']['reply']['message'] = array( '#value' => "You've requested to delete item: $header_id", ); return $form; }
mfm_dmail_display_folders | ( | &$ | form_state, |
$ | identity_id | ||
) |
Build the list of mailbox folders.
Definition at line 416 of file dmail.user.inc.
References mfn_dmail_db_identity_select(), mfn_dmail_db_mboxes_select(), mfn_dmail_l(), mfn_dmail_readonly_check(), mfn_dmail_security_check(), and mfn_dmail_set_active_identity().
{ global $user; mfn_dmail_security_check(); mfn_dmail_readonly_check(); $mboxes = mfn_dmail_db_mboxes_select($identity_id); $identity = mfn_dmail_db_identity_select($identity_id); mfn_dmail_set_active_identity($identity); drupal_set_title(t('Folders for %identity', array('%identity' => $identity->name))); foreach ($mboxes as $mbox) { $_mboxes[$mbox->id] = $mbox; } $form = array(); foreach ($mboxes as $weight => $mbox) { $folders = explode($identity->delimiter, $mbox->name); $collapsed = TRUE; for ($i = 0; $i < count($folders)-1; $i++) { switch ($i) { case 0: { if (empty($f[$folders[0]])) { $f[$folders[0]] = array( '#type' => 'fieldset', '#title' => $folders[$i], '#collapsible' => TRUE, '#collapsed' => FALSE, '#weight' => $weight * $i, ); } break; } case 1: { if (empty($f[$folders[0]][$folders[1]])) { $f[$folders[0]][$folders[1]] = array( '#type' => 'fieldset', '#title' => $folders[$i], '#collapsible' => TRUE, '#collapsed' => $collapsed, '#weight' => $weight * $i, ); } break; } case 2: { if (empty($f[$folders[0]][$folders[1]][$folders[2]])) { $f[$folders[0]][$folders[1]][$folders[2]] = array( '#type' => 'fieldset', '#title' => $folders[$i], '#collapsible' => TRUE, '#collapsed' => $collapsed, '#weight' => $weight * $i, ); } break; } case 3: { if (empty($f[$folders[0]][$folders[1]][$folders[2]][$folders[3]])) { $f[$folders[0]][$folders[1]][$folders[2]][$folders[3]] = array( '#type' => 'fieldset', '#title' => $folders[$i], '#collapsible' => TRUE, '#collapsed' => $collapsed, '#weight' => $weight * $i, ); } break; } case 4: { if (empty($f[$folders[0]][$folders[1]][$folders[2]][$folders[3]][$folders[4]])) { $f[$folders[0]][$folders[1]][$folders[2]][$folders[3]][$folders[4]] = array( '#type' => 'fieldset', '#title' => $folders[$i], '#collapsible' => TRUE, '#collapsed' => $collapsed, '#weight' => $weight * $i, ); } break; } case 5: { if (empty($f[$folders[0]][$folders[1]][$folders[2]][$folders[3]][$folders[4]][$folders[5]])) { $f[$folders[0]][$folders[1]][$folders[2]][$folders[3]][$folders[4]][$folders[5]] = array( '#type' => 'fieldset', '#title' => $folders[$i], '#collapsible' => TRUE, '#collapsed' => $collapsed, '#weight' => $weight * $i, ); } break; } default: { //throw new Exception(t('Unmanagable folder depth (' . count($folders) . ')!')); break; } } } } $sep = ' | '; foreach ($mboxes as $weight => $mbox) { $folders = explode($identity->delimiter, $mbox->name); $value = l($folders[count($folders) - 1], 'user/' . $user->uid . '/email/' . $identity_id . '/mbox/' . $mbox->id) . ' ' . $mbox->messages . t(' messages.'); $add_folder = mfn_dmail_l(array( 'url' => 'user/' . $user->uid . '/email/' . $mbox->identity_id . '/mbox/' . $mbox->id . '/add', 'title' => 'Add folder', 'description' => 'Add a new folder to filter mail to.', 'image' => array( 'type' => 'action', 'file' => 'add_folder.png', ), )); $del_folder = mfn_dmail_l(array( 'href' => 'user/' . $user->uid . '/email/' . $mbox->identity_id . '/mbox/' . $mbox->id . '/delete', 'title' => 'Delete folder', 'description' => 'Remove all messages in folder and then remove the folder.', 'image' => array('type' => 'action', 'file' => 'delete_folder.png'), )); if ($mbox->name == $identity->inbox) { $f[$mbox->name][$identity->inbox . $identity->delimiter . $mbox->name] = array( '#type' => 'markup', '#value' => "$value$sep$add_folder", '#prefix' => '<p>', '#suffix' => '</p>', '#weight' => 100, ); } else { $top = $identity->toplevel ? NULL : $identity->inbox . $identity->delimiter; $trash = $top . $identity->deletefolder; $junk = $top . $identity->junkfolder; $draft = $top . $identity->draftfolder; $sent = $top . $identity->sentfolder; if (!in_array($mbox->name, array($trash, $junk, $draft, $sent))) { $value .= $sep . $add_folder . $sep . $del_folder; $weight_m = 1; } else { $weight_m = 10; } switch (count($folders)) { case 1: { if (empty($f[$folders[0]])) { $f[$folders[0]] = array( '#type' => 'markup', '#value' => $value, '#prefix' => '<p>', '#suffix' => '</p>', '#weight' => $weight * 100 * $weight_m, ); } } break; case 2: { if (empty($f[$folders[0]][$folders[1]])) { $f[$folders[0]][$folders[1]] = array( '#type' => 'markup', '#value' => $value, '#prefix' => '<p>', '#suffix' => '</p>', '#weight' => $weight * 200 * $weight_m, ); } } break; case 3: { if (empty($f[$folders[0]][$folders[1]][$folders[2]])) { $f[$folders[0]][$folders[1]][$folders[2]] = array( '#type' => 'markup', '#value' => $value, '#prefix' => '<p>', '#suffix' => '</p>', '#weight' => $weight * 300 * $weight_m, ); } } break; case 4: { if (empty($f[$folders[0]][$folders[1]][$folders[2]][$folders[3]])) { $f[$folders[0]][$folders[1]][$folders[2]][$folders[3]] = array( '#type' => 'markup', '#value' => $value, '#prefix' => '<p>', '#suffix' => '</p>', '#weight' => $weight * 400 * $weight_m, ); } } break; case 5: { if (empty($f[$folders[0]][$folders[1]][$folders[2]][$folders[3]][$folders[4]])) { $f[$folders[0]][$folders[1]][$folders[2]][$folders[3]][$folders[4]] = array( '#type' => 'markup', '#value' => $value, '#prefix' => '<p>', '#suffix' => '</p>', '#weight' => $weight * 500 * $weight_m, ); } } break; case 6: { if (empty($f[$folders[0]][$folders[1]][$folders[2]][$folders[3]][$folders[4]][$folders[5]])) { $f[$folders[0]][$folders[1]][$folders[2]][$folders[3]][$folders[4]][$folders[5]] = array( '#type' => 'markup', '#value' => $value, '#prefix' => '<p>', '#weight' => $weight * 600 * $weight_m, ); } } break; default: { } break; } } } $form['dmail']['folders'] = $f; return $form; }
mfm_dmail_display_headers | ( | &$ | form_state, |
$ | mbox_id | ||
) |
Build the list of mail box items.
Definition at line 631 of file dmail.user.inc.
References mfn_dmail_access(), mfn_dmail_active_mbox(), mfn_dmail_db_identity_select(), mfn_dmail_db_mbox_message_headers_count(), mfn_dmail_db_mbox_message_headers_select_ordered(), mfn_dmail_db_mbox_select(), mfn_dmail_decode_str(), mfn_dmail_get_headers(), mfn_dmail_is_junk(), mfn_dmail_items_list_header(), mfn_dmail_l(), mfn_dmail_orderby(), mfn_dmail_readonly_check(), mfn_dmail_security_check(), and mfn_dmail_set_active_identity().
{ global $user; dcache_del(array('form', 'reply'), DCACHE_SESSION); dcache_del(array('form', 'item'), DCACHE_SESSION); mfn_dmail_security_check(); mfn_dmail_readonly_check(); $form = array(); $mbox = mfn_dmail_db_mbox_select($mbox_id); $identity = mfn_dmail_db_identity_select($mbox->identity_id); mfn_dmail_set_active_identity($identity); mfn_dmail_active_mbox($mbox); drupal_set_title(t('@identity %mbox Items', array('%mbox' => $mbox->name, '@identity' => $identity->name))); $urlf = 'user/' . $user->uid . '/email/' . $mbox->identity_id . '/mbox/' . $mbox_id; $orderby = mfn_dmail_orderby(); $list_header = mfn_dmail_items_list_header(); $headers_count = mfn_dmail_db_mbox_message_headers_count($mbox_id); if ($headers_count != $mbox->messages) { mfn_dmail_get_headers($mbox, $identity); } $headers = mfn_dmail_db_mbox_message_headers_select_ordered($mbox_id); foreach ($headers as $header) { $bspan = '<span class="dmail.normal">'; $espan = '</span>'; if (!$header->seen) { $bspan = '<span class="dmail.unseen">'; } if ($header->deleted) { $bspan = '<span class="dmail.deleted">'; } if ($header->flagged) { $bspan = '<span class="dmail.flagged">'; } $form['dmail']['headers']['msgno'][$header->id] = array( '#value' => $header->msgno, '#suffix' => ' ', ); $form['dmail']['headers']['received'][$header->id] = array( '#value' => $header->date, '#prefix' => ' ' . $bspan, '#suffix' => ' ' . $espan, ); $form['dmail']['headers']['from'][$header->id] = array( '#value' => mfn_dmail_decode_str($header->from), '#prefix' => ' ' . $bspan, '#suffix' => ' ' . $espan, ); $form['dmail']['headers']['subject'][$header->id] = array( '#value' => mfn_dmail_decode_str($header->subject), '#prefix' => ' ' . $bspan, '#suffix' => ' ' . $espan, ); $attributes = array(); $v = mfn_dmail_l($urlf . '/view/' . $header->id, 'View', 'View the mail item.', $attributes, $orderby, array('type' => 'action', 'file' => 'view.png')) . ' | '; $v .= mfn_dmail_l($urlf . '/reply/' . $header->id, 'Reply', 'Reply about this item.', $attributes, $orderby, array('type' => 'action', 'file' => 'reply.png')) . ' | '; $v .= mfn_dmail_l($urlf . '/replyall/' . $header->id, 'Reply All', 'Reply to every address about this item.', $attributes, $orderby, array('type' => 'action', 'file' => 'replyall.png')) . ' | '; $v .= mfn_dmail_l($urlf . '/forward/' . $header->id, 'Forward', 'Forward this item to another mailbox.', $attributes, $orderby, array('type' => 'action', 'file' => 'forward.png')) . ' | '; if (mfn_dmail_is_junk($header->message_id)) { $v .= mfn_dmail_l($urlf . '/unjunk/' . $header->id, 'Unjunk', 'The mail item is not Junk (i.e. not SPAM).', $attributes, $orderby, array('type' => 'action', 'file' => 'unjunk.png')) . ' | '; } else { $v .= mfn_dmail_l($urlf . '/junk/' . $header->id, 'Junk', 'The mail item is Junk (i.e. SPAM).', $attributes, $orderby, array('type' => 'action', 'file' => 'junk.png')) . ' | '; } if ($header->deleted) { $v .= mfn_dmail_l(array( 'url' => $urlf . '/undelete/' . $header->id, 'title' => 'Undelete', 'description' => 'Undelete the mail item.', 'attributes' => $attributes, 'options' => $orderby, 'image' => array('type' => 'action', 'file' => 'undelete.png'), )) . ' | '; } else { $v .= mfn_dmail_l(array( 'url' => $urlf . '/delete/' . $header->id, 'title' => 'Delete', 'description' => 'Delete the mail item.', 'attributes' => $attributes, 'options' => $orderby, 'image' => array('type' => 'action', 'file' => 'delete.png'), )) . ' | '; } if ($header->flagged) { $v .= mfn_dmail_l($urlf . '/unflag/' . $header->id, 'Normal', 'Flag mail item not important.', $attributes, $orderby, array('type' => 'action', 'file' => 'unimportant.png')) . ' | '; } else { $v .= mfn_dmail_l($urlf . '/flag/' . $header->id, 'Important', 'Flag mail item important.', $attributes, $orderby, array('type' => 'action', 'file' => 'important.png')) . ' | '; } if ($header->seen) { $v .= mfn_dmail_l(array( 'url' => $urlf . '/unseen/' . $header->id, 'title' => 'Unseen', 'description' => 'Flag the mail item not seen.', 'attributes' => $attributes, 'options' => $orderby, 'image' => array('type' => 'action', 'file' => 'flag_unseen.png'), )) . ' | '; } else { $v .= mfn_dmail_l(array( 'url' => $urlf . '/seen/' . $header->id, 'title' => 'Seen', 'description' => 'Flag the mail item seen.', 'attributes' => $attributes, 'options' => $orderby, 'image' => array('type' => 'action', file=> 'flag_seen.png'), )) . ' | '; } $v .= mfn_dmail_l($urlf . '/copy/' . $header->id, 'Copy', 'Copy the mail item.', $attributes, $orderby, array('type' => 'action', 'file' => 'copy.png')) . ' | '; $v .= mfn_dmail_l($urlf . '/move/' . $header->id, 'Move', 'Move the mail item.', $attributes, $orderby, array('type' => 'action', 'file' => 'move.png')) . ' | '; if (mfn_dmail_access($user->uid, DMAIL_POST_ROLE)) { $v .= mfn_dmail_l($urlf . '/post/' . $header->id, 'Post', 'Post this message to Drupal.', $attributes, $orderby, array('type' => 'action', 'file' => 'post.png')) . ' | '; } $form['dmail']['headers']['operations'][$header->id] = array( '#value' => $v, '#prefix' => ' ' . $bspan, '#suffix' => ' ' . $espan, ); $form['dmail']['headers']['pager'] = array( '#value' => theme('pager', NULL, duvar_get('items_per_page', 10), 0), ); //$__headers = explode("\n", $imap->fetchheader($_headers->msgno)); $form['dmail']['headers']['headers'][$header->id] = array( '#value' => check_plain(print_r($header->full, TRUE)), '#prefix' => '<pre>', '#suffix' => '</pre>', ); } //$imap->close(); return $form; }
mfm_dmail_display_item | ( | &$ | form_state, |
$ | mbox_id, | ||
$ | header_id, | ||
$ | html = FALSE |
||
) |
Display a mailbox item.
Definition at line 766 of file dmail.user.inc.
References mfn_dmail_active_mbox(), mfn_dmail_check_string(), mfn_dmail_db_identity_select(), mfn_dmail_db_mbox_message_headers_select_ordered(), mfn_dmail_db_mbox_select(), mfn_dmail_decode_str(), mfn_dmail_format_attachments(), mfn_dmail_format_body(), mfn_dmail_get_headerinfo(), mfn_dmail_imap_open(), mfn_dmail_options_addr(), mfn_dmail_readonly_check(), mfn_dmail_security_check(), mfn_dmail_set_active_identity(), mfn_dmail_transform_addr(), and mfn_dmail_xform_header().
{ global $user, $imap; dcache_del(array('form', 'reply'), DCACHE_SESSION); $item = dcache_get(array('form', 'item'), DCACHE_SESSION); if (isset($item)) { if ($item['mbox_id'] === $mbox_id && $item['header_id'] === $header_id && $item['html'] === $html) { return $item['form']; } } mfn_dmail_security_check(); mfn_dmail_readonly_check(); set_time_limit(60); $form = array(); //* We get all the headers to program the Prev/Next Buttons. //* @todo Select needs to include ordering information. //* @todo Determine which page the Prev/Next link would be on in the list // to program the Mailbox Items breadcrumb link. $headers = mfn_dmail_db_mbox_message_headers_select_ordered($mbox_id); for ($i = 0; $i < count($headers); $i++) { if ($headers[$i]->id == $header_id) { $header = $headers[$i]; break; } } if (empty($header)) { $header = $headers[0]; } $mbox = mfn_dmail_db_mbox_select($header->mbox_id); $identity = mfn_dmail_db_identity_select($mbox->identity_id); mfn_dmail_set_active_identity($identity); mfn_dmail_active_mbox($mbox); drupal_set_title(t('View @identity->@mbox', array( '@identity' => $identity->name, '@mbox' => $mbox->name, '%subject' => mfn_dmail_decode_str($header->subject), ))); $header->identity_id = $mbox->identity_id; mfn_dmail_imap_open($identity, $mbox->name); $headerinfo = mfn_dmail_get_headerinfo($header); mfn_dmail_xform_header($header, $headerinfo); if ((isset($header->x_spam_flag) && strtolower(trim($header->x_spam_flag)) === 'yes') || (isset($header->x_va_spam_flag) && strtolower(trim($header->x_va_spam_flag)) === 'yes')) { drupal_set_message('This items headers are indicating it as SPAM.', 'error'); } if ($header->deleted) { drupal_set_message('DELETED item.', 'warning'); } if ($header->draft) { drupal_set_message('DRAFT item.', 'warning'); } if ($header->flagged) { drupal_set_message('IMPORTANT item.', 'warning'); } $bodyplain = $imap->fetch_item($header->msgno, 'TEXT/PLAIN'); $bodyhtml = $imap->fetch_item($header->msgno, 'TEXT/HTML'); $attach = $imap->fetch_item($header->msgno, 'ATTACHMENT'); if (empty($bodyplain)) { $bodyplain = $bodyhtml; } $body = $html ? $bodyhtml : mfn_dmail_format_body(mfn_dmail_check_string($bodyplain, TRUE), 80); $structure = $imap->fetchstructure($header->msgno); $bodystruct['1'] = $imap->bodystruct($header->msgno, '1'); $bodystruct['1.1'] = $imap->bodystruct($header->msgno, '1.1'); $bodystruct['1.2'] = $imap->bodystruct($header->msgno, '1.2'); $bodystruct['2'] = $imap->bodystruct($header->msgno, '2'); $bodystruct['3'] = $imap->bodystruct($header->msgno, '3'); $imap->close(); $form['dmail']['item']['begintable1'] = array( '#prefix' => '<p><table>', '#value' => ' ', ); $form['dmail']['item']['itemnot'] = array( '#prefix' => '<tr><th>', '#value' => 'Item:', '#suffix' => '</th>', ); $form['dmail']['item']['itemno'] = array( '#prefix' => '<td>', '#value' => $header->current_id + 1 . t(' of ') . count($headers), '#suffix' => '</td>', ); $form['dmail']['item']['receivedt'] = array( '#prefix' => '<tr><th>', '#value' => 'Received:', '#suffix' => '</th>', ); $form['dmail']['item']['received'] = array( '#prefix' => '<td>', '#value' => $header->date, '#suffix' => '</td>', ); $xform = mfn_dmail_transform_addr('from', $header); $form['dmail']['item']['fromt'] = array( '#prefix' => '<tr><th>', '#value' => 'From:', '#suffix' => '</th>', ); $form['dmail']['item']['from'] = array( '#prefix' => '<td>', '#value' => $xform[0], '#suffix' => '</td>', ); $form['dmail']['item']['fromo'] = array( '#prefix' => '<td>', '#value' => mfn_dmail_options_addr('from', $header, !is_null($bodyhtml), 0), '#suffix' => '</td></tr>', ); $xform = mfn_dmail_transform_addr('to', $header); $tot = t('To:'); foreach ($xform as $el => $addr) { $form['dmail']['item'][$el]['tot'] = array( '#prefix' => '<tr><th>', '#value' => $tot, '#suffix' => '</th>', ); $tot = ' &'; $form['dmail']['item'][$el]['to'] = array( '#prefix' => '<td>', '#value' => $addr, '#suffix' => '</td>', ); $form['dmail']['item'][$el]['too'] = array( '#prefix' => '<td>', '#value' => mfn_dmail_options_addr('to', $header, !is_null($bodyhtml), $el), '#suffix' => '</td></tr>', ); } if (isset($header->cc)) { $xform = mfn_dmail_transform_addr('cc', $header); $cct = t('Cc:'); foreach ($xform as $el => $addr) { $form['dmail']['item'][$el]['cct'] = array( '#prefix' => '<tr><th>', '#value' => $cct, '#suffix' => '</th>', ); $cct = ' &'; $form['dmail']['item'][$el]['cc'] = array( '#prefix' => '<td>', '#value' => $addr, '#suffix' => '</td>', ); $form['dmail']['item'][$el]['cco'] = array( '#prefix' => '<td>', '#value' => mfn_dmail_options_addr('cc', $header, !is_null($bodyhtml), $el), '#suffix' => '</td></tr>', ); } } $form['dmail']['item']['tsubject'] = array( '#prefix' => '<tr><th>', '#value' => t('Subject:'), '#suffix' => '</th>', ); $form['dmail']['item']['subject'] = array( '#prefix' => '<td colspan="2">', '#value' => check_plain(mfn_dmail_decode_str($header->subject)), '#suffix' => '</td></tr>', ); $list_options = mfn_dmail_options_addr('list options', $header, !is_null($bodyhtml)); if (!empty($list_options)) { $form['dmail']['item']['list_options'] = array( '#prefix' => '<tr><td colspan="3">', '#value' => $list_options, '#suffix' => '</td></tr>', ); } $form['dmail']['item']['endtable1'] = array( '#value' => ' ', '#suffix' => '</table></p>', ); $form['dmail']['item']['begintable2'] = array( '#prefix' => '<p><table border="1" width="80%">', '#value' => ' ', ); $form['dmail']['item']['options'] = array( '#prefix' => '<tr><td>', '#value' => mfn_dmail_options_addr('options', $header, !is_null($bodyhtml), NULL, $html), '#suffix' => '</td></tr>', ); $form['dmail']['item']['attachments'] = array( '#prefix' => '<tr><td>', '#value' => mfn_dmail_format_attachments($attach), '#suffix' => '</td></tr>', ); $form['dmail']['item']['body'] = array( '#type' => 'markup', '#prefix' => '<tr><td>', '#value' => $body, '#suffix' => '</td></tr>', '#disabled' => TRUE, ); $form['dmail']['item']['attachments2'] = array( '#prefix' => '<tr><td>', '#value' => $form['dmail']['item']['attachments']['#value'], '#suffix' => '</td></tr>', ); $form['dmail']['item']['options2'] = array( '#prefix' => '<tr><td>', '#value' => $form['dmail']['item']['options']['#value'], '#suffix' => '</td></tr>', ); $form['dmail']['item']['end'] = array( '#value' => ' ', '#suffix' => '</table></p>', ); $form['dmail']['item']['headers'] = array( '#prefix' => '<!-- <pre>', '#value' => print_r($header,true), '#suffix' => '</pre>', ); $form['dmail']['item']['headerinfo'] = array( '#prefix' => '<pre>', '#value' => print_r($headerinfo,true), '#suffix' => '</pre>', ); $form['dmail']['item']['structure'] = array( '#prefix' => '<pre>', '#value' => print_r($structure,true), '#suffix' => '</pre>', ); $form['dmail']['item']['bodystruct'] = array( '#prefix' => '<pre>', '#value' => print_r($bodystruct,true), '#suffix' => '</pre> -->', ); $form['dmail']['item']['attach'] = array( '#prefix' => '<!-- <pre>', '#value' => print_r($attach,true), '#suffix' => '</pre> -->', ); dcache_set(array('form', 'item'), array( 'identity_id' => $mbox->identity_id, 'mbox_id' => $mbox_id, 'header_id' => $header_id, 'html' => $html, 'bodyplain' => $bodyplain, 'bodyhtml' => $bodyhtml, 'attach' => $attach, 'form' => $form, ), DCACHE_SESSION); return $form; }
mfm_dmail_flag_item | ( | &$ | form_state, |
$ | header_id | ||
) |
Flag this item as important form.
Definition at line 1369 of file dmail.user.inc.
References mfn_dmail_security_check().
{ global $user; mfn_dmail_security_check(); drupal_set_message('The Important form is still under development.', 'warning'); $form['dmail']['reply']['message'] = array( '#value' => "You've requested to mark the item as important: $header_id", ); return $form; }
mfm_dmail_forward_item | ( | &$ | form_state, |
$ | header_id | ||
) |
Item Forward form.
Definition at line 1304 of file dmail.user.inc.
References mfn_dmail_security_check().
{ global $user; mfn_dmail_security_check(); drupal_set_message('The Forward form is still under development.', 'warning'); $form['dmail']['reply']['message'] = array( '#value' => "You've requested to forward item: $header_id", ); return $form; }
mfm_dmail_friendly_addr | ( | &$ | form_state, |
$ | personal, | ||
$ | address | ||
) |
Flag this email address as friendly form.
Definition at line 1447 of file dmail.user.inc.
References mfn_dmail_security_check().
{ global $user; mfn_dmail_security_check(); drupal_set_message('The Friendly Address form is still under development.', 'warning'); if (empty($address)) { $address = $personal; $personal = NULL; } $form['dmail']['reply']['message'] = array( '#value' => "You've requested $personal <$address> be identified as friendly.", ); return $form; }
mfm_dmail_identities | ( | ) |
Build the list of identities.
Definition at line 43 of file dmail.user.inc.
References mfn_dmail_db_identities_with_counts(), mfn_dmail_l(), mfn_dmail_security_check(), and mfn_dmail_set_active_identity().
{ global $user; mfn_dmail_security_check(); $identity->id = 0; mfn_dmail_set_active_identity($identity); $form['dmail']['identity']['list']['header']['#dmail_data'] = array( array('data' => t('##'), 'field' => 'id'), array('data' => t('Identity'), 'field' => 'name'), array('data' => t('Last Checked'), 'field' => 'lastchkd'), array('data' => t('Messages'), 'field' => 'messages'), array('data' => t('Recent'), 'field' => 'recent'), ); $identities = mfn_dmail_db_identities_with_counts(); foreach ($identities as $identity) { $urlf = 'user/' . $user->uid . '/email/' . $identity->id; if (!$identity->messages) { $identity->messages = 0; $identity->recent = 0; } $form['dmail']['identity']['list']['id'][$identity->id] = array( '#value' => l($identity->id, $urlf . '/edit'), ); $form['dmail']['identity']['list']['name'][$identity->id] = array( '#value' => l($identity->name, $urlf . '/folders'), ); $form['dmail']['identity']['list']['lastchkd'][$identity->id] = array( '#value' => mfn_dmail_l($urlf . '/get', $identity->lastchkd, 'Retrieve the mail headers from the server.'), ); $form['dmail']['identity']['list']['messages'][$identity->id] = array( '#value' => mfn_dmail_l($urlf . '/messages', $identity->messages, 'View all messages for this identity.'), ); $form['dmail']['identity']['list']['recent'][$identity->id] = array( '#value' => mfn_dmail_l($urlf . '/recent', $identity->recent, 'View all recent messages for this identity.'), ); $v = mfn_dmail_l(array( 'url' => $urlf . '/expunge', 'title' => 'Expunge', 'description' => 'Purge the mail marked as deleted in all folders.', 'image' => array( 'type' => 'action', 'file' => 'expunge_all.png', ), )) . ' | '; $v .= mfn_dmail_l(array( 'url' => $urlf . '/mailboxes', 'title' => 'Get Folders', 'description' => 'Get the mailbox folders from the server. Use when you have added or modified folders using another email client.', 'image' => array('type' => 'action', 'file' => 'get_folders.png'), )) . ' | '; $v .= mfn_dmail_l(array( 'url' => $urlf . '/sanitize', 'title' => 'Sanitize', 'description' => 'Sanitize the mailbox folders. Use when you have used another email client to process mail; some clients do not do the right thing with the imap data.', 'image' => array( 'type' => 'action', 'file' => 'sanitize.png', ), )) . ' | '; $v .= mfn_dmail_l(array( 'url' => $urlf . '/remove', 'title' => 'Remove', 'description' => 'Remove this identity. This action cannot be undone and all related data will be removed.', 'image' => array( 'type' => 'action', 'file' => 'remove_identity.png', ), )) . ' | '; $form['dmail']['identity']['list']['operations'][$identity->id] = array( '#value' => $v, ); $identities_on_page[$identity->id] = ''; } $form['dmail']['identity']['list']['identities'] = array( '#type' => 'checkboxes', '#options' => $identities_on_page, ); return $form; }
mfm_dmail_identities_add | ( | ) |
Form to add a new identity.
Definition at line 125 of file dmail.user.inc.
References mfn_dmail_form_default(), mfn_dmail_form_options(), mfn_dmail_form_text(), and mfn_dmail_security_check().
Referenced by mfm_dmail_identities_edit().
{ global $user; mfn_dmail_security_check(); $form['dmail']['identities']['add']['name'] = array( '#type' => 'textfield', '#title' => t('Name'), '#description' => t('The visual representation of the identity'), '#required' => TRUE, ); $form['dmail']['identities']['add']['user'] = array( '#type' => 'textfield', '#title' => t('User'), '#description' => t('The account identifier you use for the service login.'), '#required' => TRUE, ); $form['dmail']['identities']['add']['pass'] = array( '#type' => 'password', '#title' => t('Password'), '#description' => t('The account password you use for the service login.'), '#required' => TRUE, ); $default = variable_get('dmail_default_host', DMAIL_DEFAULT_HOST); $form['dmail']['identities']['add']['host'] = array( '#type' => 'textfield', '#title' => t('Host'), '#description' => t('The server name for the email account.'), '#required' => TRUE, '#default_value' => $default, ); $default = variable_get('dmail_default_service', DMAIL_DEFAULT_SERVICE); $form['dmail']['identities']['add']['service'] = array( '#type' => 'select', '#title' => t('Service'), '#description' => t('The type of service provided by the server (imap, pop3, nntp).'), '#required' => TRUE, '#options' => array('imap' => 'imap', 'pop3' => 'pop3', 'nntp' => 'nntp'), '#default_value' => $default, ); $default = variable_get('dmail_default_port', DMAIL_DEFAULT_PORT); $form['dmail']['identities']['add']['port'] = array( '#type' => 'textfield', '#title' => t('Port'), '#description' => t('The port number for the service chosen.'), '#required' => TRUE, '#default_value' => $default, ); $default = variable_get('dmail_default_encrypt', DMAIL_DEFAULT_ENCRYPT); $form['dmail']['identities']['add']['encrypt'] = array( '#type' => 'select', '#title' => t('Encryption type'), '#description' => t('The type of encryption required by the server (plain, tls, ssl).'), '#required' => TRUE, '#options' => array('none' => 'none', 'tls' => 'tls', 'ssl' => 'ssl'), '#default_value' => $default, ); $default = variable_get('dmail_default_validate_cert', DMAIL_DEFAULT_VALIDATE_CERT); $form['dmail']['identities']['add']['validate_cert'] = array( '#type' => 'select', '#title' => t('Validate Certificate'), '#description' => t('Should the server certificate be validated?'), '#required' => TRUE, '#options' => array('yes' => t('Yes'), 'no' => t('No')), '#default_value' => $default, ); $default = variable_get('dmail_default_expunge', DMAIL_DEFAULT_EXPUNGE); $form['dmail']['identities']['add']['expunge'] = array( '#type' => 'select', '#title' => t('Expunge On Close'), '#description' => t('Should the service expunge deleted items on close of the service connection? NOTE: The connection may close for reasons other than exiting or logging off.'), '#required' => TRUE, '#options' => array('yes' => t('Yes'), 'no' => t('No')), '#default_value' => $default, ); $default = variable_get('dmail_default_readonly', DMAIL_DEFAULT_READONLY); $form['dmail']['identities']['add']['readonly'] = array( '#type' => 'select', '#title' => t('Read Only Access'), '#description' => t('Should the service be accessed in read only mode?'), '#required' => TRUE, '#options' => array('yes' => t('Yes'), 'no' => t('No')), '#default_value' => $default, ); $field = 'inbox'; $form['dmail']['identities']['add'][$field] = array( '#type' => 'textfield', '#title' => mfn_dmail_form_text('title', $field), '#description' => mfn_dmail_form_text('desc', $field), '#required' => TRUE, '#default_value' => mfn_dmail_form_default($field), ); $field = 'check_mail_freq'; $form['dmail']['identities']['add'][$field] = array( '#type' => 'select', '#title' => mfn_dmail_form_text('title', $field), '#description' => mfn_dmail_form_text('desc', $field), '#options' => mfn_dmail_form_options($field), '#default_value' => mfn_dmail_form_default($field), ); $field = 'delimiter'; $form['dmail']['identities']['add'][$field] = array( '#type' => 'textfield', '#title' => mfn_dmail_form_text('title', $field), '#description' => mfn_dmail_form_text('desc', $field), '#default_value' => mfn_dmail_form_default($field), '#size' => 1, '#maxlength' => 1, ); $field = 'toplevel'; $form['dmail']['identities']['add'][$field] = array( '#type' => 'checkbox', '#title' => mfn_dmail_form_text('title', $field), '#description' => mfn_dmail_form_text('desc', $field), '#default_value' => mfn_dmail_form_default($field), ); $field = 'orderby'; $form['dmail']['identities']['add'][$orderby] = array( '#type' => 'select', '#title' => mfn_dmail_form_text('title', $field), '#description' => mfn_dmail_form_text('desc', $field), '#options' => mfn_dmail_form_options($field), '#default_value' => mfn_dmail_form_default($field), ); $field = 'sortdir'; $form['dmail']['identities']['add'][$field] = array( '#type' => 'select', '#title' => mfn_dmail_form_text('title', $field), '#description' => mfn_dmail_form_text('desc', $field), '#options' => mfn_dmail_form_options($field), '#default_value' => mfn_dmail_form_default($field), ); $field = 'signature'; $form['dmail']['identities']['add'][$field] = array( '#type' => 'select', '#title' => mfn_dmail_form_text('title', $field), '#description' => mfn_dmail_form_text('desc', $field), '#options' => mfn_dmail_form_options($field), '#default_value' => mfn_dmail_form_default($field), ); $field = 'delete_folder'; $form['dmail']['identities']['add'][$field] = array( '#type' => 'textfield', '#title' => mfn_dmail_form_text('title', $field), '#description' => mfn_dmail_form_text('description', $field), '#default_value' => mfn_dmail_form_default($field), ); $field = 'move_deleted'; $form['dmail']['identities']['add'][$field] = array( '#type' => 'select', '#title' => mfn_dmail_form_text('title', $field), '#description' => mfn_dmail_form_text('description', $field), '#options' => mfn_dmail_form_options($field), '#default_value' => mfn_dmail_form_default($field), ); $field = 'draft_folder'; $form['dmail']['identities']['add'][$field] = array( '#type' => 'textfield', '#title' => mfn_dmail_form_text('title', $field), '#description' => mfn_dmail_form_text('description', $field), '#default_value' => mfn_dmail_form_default($field), ); $field = 'sent_folder'; $form['dmail']['identities']['add'][$field] = array( '#type' => 'textfield', '#title' => mfn_dmail_form_text('title', $field), '#description' => mfn_dmail_form_text('desc', $field), '#default_value' => mfn_dmail_form_default($field), ); $field = 'junk_folder'; $form['dmail']['identities']['add'][$field] = array( '#type' => 'textfield', '#title' => mfn_dmail_form_text('title', $field), '#description' => mfn_dmail_form_text('desc', $field), '#default_value' => mfn_dmail_form_default($field), ); $form['dmail']['identities']['add']['submit'] = array( '#type' => 'submit', '#value' => t('Add Identity'), ); $form['#redirect'] = 'user/' . $user->uid . '/email/identities'; return $form; }
mfm_dmail_identities_add_submit | ( | &$ | form, |
&$ | form_state | ||
) |
Identity add submit handler.
Definition at line 345 of file dmail.user.inc.
References mfn_dmail_db_identity_add(), and mfn_dmail_get_mailboxes().
{ $values =& $form_state['values']; $ret = mfn_dmail_db_identity_add($values); $id =& $ret[1]; mfn_dmail_get_mailboxes($id); }
mfm_dmail_identities_add_validate | ( | &$ | form, |
&$ | form_state | ||
) |
Identity add validation handler.
Definition at line 323 of file dmail.user.inc.
References mfn_dmail_db_identity_select(), mfn_dmail_decrypt(), and mfn_dmail_is_valid_service().
Referenced by mfm_dmail_identities_edit_validate().
{ $values =& $form_state['values']; if (isset($values['id'])) { $identity = mfn_dmail_db_identity_select($values['id']); if (empty($values['pass'])) { $values['pass'] = mfn_dmail_decrypt($identity->pass); } } if (!is_numeric($values['port'])) { form_set_error('port', t('A port must contain a numeric value.')); } if (!mfn_dmail_is_valid_service($values)) { form_set_error('dmail][identities][add]', t('The entered service parameters did not validate.')); } if ($values['readonly'] === 'yes' && $values['expunge'] === 'yes') { form_set_error('dmail][identities][add]', t('Expunge On Close and Read Only Access are mutally exclusive and cannot be both set to Yes')); } }
mfm_dmail_identities_edit | ( | &$ | form_state, |
$ | id | ||
) |
Identity edit form.
Definition at line 355 of file dmail.user.inc.
References mfm_dmail_identities_add(), mfn_dmail_db_identity_select(), and mfn_dmail_security_check().
{ global $user; mfn_dmail_security_check(); $identity = mfn_dmail_db_identity_select($id); if ($identity === FALSE) { throw new Exception('Given identity id (' . $id . ') was not retrieved.'); } $form = mfm_dmail_identities_add(); $form['dmail']['identities']['edit'] = $form['dmail']['identities']['add']; unset($form['dmail']['identities']['add']); $form['dmail']['identities']['edit']['id'] = array( '#type' => 'value', '#value' => $id, ); $form['dmail']['identities']['edit']['name']['#default_value'] = $identity->name; $form['dmail']['identities']['edit']['user']['#default_value'] = $identity->user; unset($form['dmail']['identities']['edit']['pass']['#required']); $form['dmail']['identities']['edit']['pass']['#description'] .= t(' Leave empty if you are not changing your password.'); $form['dmail']['identities']['edit']['host']['#default_value'] = $identity->host; $form['dmail']['identities']['edit']['service']['#default_value'] = $identity->service; $form['dmail']['identities']['edit']['port']['#default_value'] = $identity->port; $form['dmail']['identities']['edit']['encrypt']['#default_value'] = $identity->encryption; $form['dmail']['identities']['edit']['validate_cert']['#default_value'] = $identity->vld8cert ? 'yes' : 'no'; $form['dmail']['identities']['edit']['expunge']['#default_value'] = $identity->expunge ? 'yes' : 'no'; $form['dmail']['identities']['edit']['readonly']['#default_value'] = $identity->readonly ? 'yes' : 'no'; $form['dmail']['identities']['edit']['move_deleted']['#default_value'] = $identity->movedel ? 'yes' : 'no'; $form['dmail']['identities']['edit']['check_mail_freq']['#default_value'] = $identity->checkevery; $form['dmail']['identities']['edit']['signature']['#default_value'] = $identity->signature_id; $form['dmail']['identities']['edit']['inbox']['#default_value'] = $identity->inbox; $form['dmail']['identities']['edit']['delimiter']['#default_value'] = $identity->delimiter; $form['dmail']['identities']['edit']['toplevel']['#default_value'] = $identity->toplevel; $form['dmail']['identities']['edit']['delete_folder']['#default_value'] = $identity->deletefolder; $form['dmail']['identities']['edit']['draft_folder']['#default_value'] = $identity->draftfolder; $form['dmail']['identities']['edit']['sent_folder']['#default_value'] = $identity->sentfolder; $form['dmail']['identities']['edit']['junk_folder']['#default_value'] = $identity->junkfolder; $form['dmail']['identities']['edit']['submit']['#value'] = t('Change Identity'); return $form; }
mfm_dmail_identities_edit_submit | ( | &$ | form, |
&$ | form_state | ||
) |
Identity edit submit handler.
Definition at line 404 of file dmail.user.inc.
References mfn_dmail_db_identity_select(), mfn_dmail_db_identity_update(), and mfn_dmail_decrypt().
{ $values =& $form_state['values']; $identity = mfn_dmail_db_identity_select($values['id']); if (empty($values['pass'])) { $values['pass'] = mfn_dmail_decrypt($identity->pass); } mfn_dmail_db_identity_update($values['id'], $values); }
mfm_dmail_identities_edit_validate | ( | &$ | form, |
&$ | form_state | ||
) |
Identity edit validation handler.
Definition at line 397 of file dmail.user.inc.
References mfm_dmail_identities_add_validate().
{ mfm_dmail_identities_add_validate($form, $form_state); }
mfm_dmail_junk_item | ( | &$ | form_state, |
$ | header_id | ||
) |
Identify this item as junk form.
Definition at line 1317 of file dmail.user.inc.
References mfn_dmail_security_check().
{ global $user; mfn_dmail_security_check(); drupal_set_message('The Junk form is still under development.', 'warning'); $form['dmail']['reply']['message'] = array( '#value' => "You've requested to junk item: $header_id", ); return $form; }
mfm_dmail_move_item | ( | &$ | form_state, |
$ | header_id | ||
) |
Move this item to another folder form.
Definition at line 1434 of file dmail.user.inc.
References mfn_dmail_security_check().
{ global $user; mfn_dmail_security_check(); drupal_set_message('The Move form is still under development.', 'warning'); $form['dmail']['reply']['message'] = array( '#value' => "You've requested to move item: $header_id", ); return $form; }
mfm_dmail_recipient_action | ( | &$ | form, |
&$ | form_state | ||
) |
Act on recipient buttons.
Definition at line 1189 of file dmail.user.inc.
{ $ns = array('form', 'reply'); $cache = dcache_get($ns); $r =& $cache['recipients']; $v =& $form_state['values']; $key =& $form_state['clicked_button']['#name']; switch ($v[$key]) { case 'Add': { $cl = new stdClass; $cl->hval = $v["tot:$key"]; $cl->recipient = $v["to:$key"]; $r[] = $cl; } break; case 'Update': { $cl = new stdClass; $cl->hval = $v["tot:$key"]; $cl->recipient = $v["to:$key"]; $r[$key] = $cl; } break; case 'Remove': { unset($r[$key]); } break; } dcache_set($ns, $cache); }
mfm_dmail_reply_form | ( | &$ | form, |
&$ | recipients, | ||
$ | header | ||
) |
Fill a common set of form items for all reply forms.
Definition at line 1074 of file dmail.user.inc.
References mfn_dmail_reply_body(), mfn_dmail_reply_from(), and mfn_dmail_reply_subject().
Referenced by mfm_dmail_reply_item(), mfm_dmail_replyall_item(), mfm_dmail_replylist_item(), and mfm_dmail_replyto_item().
{ static $hval = array('to' => 'To:', 'cc' => 'Cc:', 'bc' => 'Bcc:', 'rt' => 'Reply-To:'); $form['dmail']['reply']['begintable1'] = array( '#prefix' => '<p><table>', '#value' => ' ', ); $form['dmail']['reply']['fromt'] = array( '#prefix' => '<tr><th>', '#value' => 'From:', '#suffix' => '</th>', ); $form['dmail']['reply']['from'] = array( '#prefix' => '<td>', '#type' => 'select', '#options' => mfn_dmail_reply_from($header), '#default_value' => 0, '#suffix' => '</td></tr>', ); if (!is_array($recipients)) { $t = $recipients; $recipients= array(); $recipients[] = $t; unset($t); } $replycount = 0; foreach($recipients as $key => $obj) { $form['dmail']['reply'][$key]["toitem:$key"] = array( '#type' => 'value', '#value' => $key, ); $form['dmail']['reply'][$key]["tot:$key"] = array( '#prefix' => '<tr><th>', '#type' => 'select', '#options' => $hval, '#default_value' => $obj->hval, '#suffix' => '</th>', ); $form['dmail']['reply'][$key]["to:$key"] = array( '#prefix' => '<td>', '#type' => 'textfield', '#default_value' => $obj->recipient, '#suffix' => '</td>', ); $form['dmail']['reply'][$key]["too:$key"] = array( '#prefix' => '<td>', '#name' => $key, '#type' => 'submit', '#value' => 'Remove', '#suffix' => '</td>', '#submit' => array('mfm_dmail_recipient_action'), ); $form['dmail']['reply'][$key]["too2:$key"] = array( '#prefix' => '<td>', '#name' => $key, '#type' => 'submit', '#value' => 'Update', '#suffix' => '</td>', '#submit' => array('mfm_dmail_recipient_action'), ); } $key = count($recipients); $form['dmail']['reply'][$key]["toitem:$key"] = array( '#type' => 'value', '#value' => $key, ); $form['dmail']['reply'][$key]["tot:$key"] = array( '#prefix' => '</tr><tr><th>', '#type' => 'select', '#options' => $hval, '#suffix' => '</th>', ); $form['dmail']['reply'][$key]["to:$key"] = array( '#prefix' => '<td>', '#type' => 'textfield', '#suffix' => '</td>', ); $form['dmail']['reply'][$key]["too:$key"] = array( '#prefix' => '<td>', '#name' => $key, '#type' => 'submit', '#value' => 'Add', '#suffix' => '</td></tr>', '#submit' => array('mfm_dmail_recipient_action'), ); $form['dmail']['reply']['subject'] = array( '#prefix' => '<tr><td colspan="3">', '#title' => t('Subject'), '#type' => 'textfield', '#default_value' => mfn_dmail_reply_subject($header), ); $form['dmail']['reply']['body'] = array( '#type' => 'textarea', '#default_value' => mfn_dmail_reply_body($header, duvar_get('body_char_wrap', DMAIL_DEFAULT_BODY_CHAR_WRAP)), '#cols' => 85, '#rows' => 25, ); $form['dmail']['reply']['send'] = array( '#type' => 'submit', '#value' => 'Send', '#submit' => array('mfm_dmail_send_action'), ); $form['dmail']['reply']['cancel'] = array( '#type' => 'submit', '#value' => 'Cancel', '#submit' => array('mfm_dmail_cancel_action'), ); $form['dmail']['reply']['endtable1'] = array( '#value' => ' ', '#suffix' => '</td></tr></table></p>', ); }
mfm_dmail_reply_item | ( | &$ | form_state, |
$ | header_id | ||
) |
Item Reply form.
Definition at line 1016 of file dmail.user.inc.
References mfm_dmail_reply_form(), mfn_dmail_db_mbox_message_header_select(), mfn_dmail_get_headerinfo(), mfn_dmail_readonly_check(), mfn_dmail_reply_to(), mfn_dmail_security_check(), and mfn_dmail_xform_header().
{ global $user; mfn_dmail_security_check(); mfn_dmail_readonly_check(); $ns = array('form', 'reply'); $cache = dcache_get($ns); dcache_del($ns); $header = mfn_dmail_db_mbox_message_header_select($header_id); $headerinfo = mfn_dmail_get_headerinfo($header); mfn_dmail_xform_header($header, $headerinfo); drupal_set_message('The Reply form is still under development.', 'warning'); $form['dmail']['reply']['message'] = array( '#value' => "You've requested a reply to item: $header_id", ); if (isset($cache['recipients'])) { $recipients =& $cache['recipients']; } else { $recipients = mfn_dmail_reply_to('reply', $header); } mfm_dmail_reply_form($form, $recipients, $header); dcache_set($ns, array('form' => $form, 'recipients' => $recipients)); return $form; }
mfm_dmail_replyall_item | ( | &$ | form_state, |
$ | header_id | ||
) |
Item Reply All form.
Definition at line 1244 of file dmail.user.inc.
References mfm_dmail_reply_form(), mfn_dmail_db_mbox_message_header_select(), mfn_dmail_get_headerinfo(), mfn_dmail_readonly_check(), mfn_dmail_reply_to(), mfn_dmail_security_check(), and mfn_dmail_xform_header().
{ global $user; mfn_dmail_security_check(); mfn_dmail_readonly_check(); $ns = array('form', 'reply'); $cache = dcache_get($ns); dcache_del($ns); drupal_set_message('The Reply All form is still under development.', 'warning'); $header = mfn_dmail_db_mbox_message_header_select($header_id); $headerinfo = mfn_dmail_get_headerinfo($header); mfn_dmail_xform_header($header, $headerinfo); $form['dmail']['reply']['message'] = array( '#value' => "You've requested a reply all to item: $header_id", ); if (isset($cache['recipients'])) { $recipients =& $cache['recipients']; } else { $recipients = mfn_dmail_reply_to('replyall', $header); } mfm_dmail_reply_form($form, $recipients, $header); dcache_set($ns, array('form' => $form, 'recipients' => $recipients)); return $form; }
mfm_dmail_replylist_item | ( | &$ | form_state, |
$ | header_id | ||
) |
Item Reply List form.
Definition at line 1044 of file dmail.user.inc.
References mfm_dmail_reply_form(), mfn_dmail_db_mbox_message_header_select(), mfn_dmail_get_headerinfo(), mfn_dmail_readonly_check(), mfn_dmail_reply_to(), mfn_dmail_security_check(), and mfn_dmail_xform_header().
{ global $user; static $hval = array('to' => 'To:', 'cc' => 'Cc:', 'bc' => 'Bcc:', 'rt' => 'Reply-To:'); mfn_dmail_security_check(); mfn_dmail_readonly_check(); $ns = array('form', 'reply'); $cmode = DCACHE_SESSION; $cache = dcache_get($ns, $cmode); dcache_del($ns, $cmode); $header = mfn_dmail_db_mbox_message_header_select($header_id); $headerinfo = mfn_dmail_get_headerinfo($header); mfn_dmail_xform_header($header, $headerinfo); drupal_set_message('The List Reply form is still under development.', 'warning', FALSE); if (isset($cache['recipients'])) { $recipients =& $cache['recipients']; } else { $recipients = mfn_dmail_reply_to('replylist', $header); } $form['dmail']['reply']['message'] = array( '#value' => "You've requested a list reply to item: $header_id", ); mfm_dmail_reply_form($form, $recipients, $header); dcache_set($ns, array('form' => $form, 'recipients' => $recipients), $cmode); return $form; }
mfm_dmail_replyto_item | ( | &$ | form_state, |
$ | header_id, | ||
$ | personal, | ||
$ | address | ||
) |
Item Reply To form.
Definition at line 1272 of file dmail.user.inc.
References mfm_dmail_reply_form(), mfn_dmail_db_mbox_message_header_select(), mfn_dmail_get_headerinfo(), mfn_dmail_readonly_check(), mfn_dmail_reply_to(), mfn_dmail_security_check(), and mfn_dmail_xform_header().
{ global $user; mfn_dmail_security_check(); mfn_dmail_readonly_check(); $ns = array('form', 'reply'); $cache = dcache_get($ns); dcache_del($ns); drupal_set_message('The Reply To form is still under development.', 'warning'); $header = mfn_dmail_db_mbox_message_header_select($header_id); $headerinfo = mfn_dmail_get_headerinfo($header); mfn_dmail_xform_header($header, $headerinfo); if (empty($address)) { $address = $personal; $personal = NULL; } $form['dmail']['reply']['message'] = array( '#value' => "You've requested a reply to $personal <$address> for item $header_id", ); if (isset($cache['recipients'])) { $recipients =& $cache['recipients']; } else { $recipients = mfn_dmail_reply_to('replyto', $header); } mfm_dmail_reply_form($form, $recipients, $header); dcache_set($ns, array('form' => $form, 'recipients' => $recipients)); return $form; }
mfm_dmail_seen_item | ( | &$ | form_state, |
$ | header_id | ||
) |
Mark this item as seen form.
Definition at line 1395 of file dmail.user.inc.
References mfn_dmail_security_check().
{ global $user; mfn_dmail_security_check(); drupal_set_message('The Seen form is still under development.', 'warning'); $form['dmail']['reply']['message'] = array( '#value' => "You've requested to mark the item seen: $header_id", ); return $form; }
mfm_dmail_send_action | ( | &$ | form, |
&$ | form_state | ||
) |
Act on the Send button.
Definition at line 1218 of file dmail.user.inc.
References mfn_dmail_db_identity_select().
{ $identity = mfn_dmail_db_identity_select(arg(3)); $ns = array('form','reply'); $cmode = DCACHE_SESSION; if ($identity->readonly) { form_error($form, 'Mail was not sent because the identity is set to read only!'); dcache_del($ns, $cmode); return; } }
mfm_dmail_send_item | ( | &$ | form_state, |
$ | personal, | ||
$ | address | ||
) |
Send new mail form.
Definition at line 1481 of file dmail.user.inc.
References mfn_dmail_security_check().
{ global $user; mfn_dmail_security_check(); drupal_set_message('The Send form is still under development.', 'warning'); if (empty($address)) { $address = $personal; $personal = NULL; } $form['dmail']['reply']['message'] = array( '#value' => "You've requested to send mail to: $personal <$address>", ); return $form; }
mfm_dmail_undelete_item | ( | &$ | form_state, |
$ | header_id | ||
) |
Clear item delete flag form.
Definition at line 1356 of file dmail.user.inc.
References mfn_dmail_security_check().
{ global $user; mfn_dmail_security_check(); drupal_set_message('The Undelete form is still under development.', 'warning'); $form['dmail']['reply']['message'] = array( '#value' => "You've requested to undelete item: $header_id", ); return $form; }
mfm_dmail_unflag_item | ( | &$ | form_state, |
$ | header_id | ||
) |
Clear item important flag form.
Definition at line 1382 of file dmail.user.inc.
References mfn_dmail_security_check().
{ global $user; mfn_dmail_security_check(); drupal_set_message('The Normal form is still under development.', 'warning'); $form['dmail']['reply']['message'] = array( '#value' => "You've requested to mark the item as normal: $header_id", ); return $form; }
mfm_dmail_unfriendly_addr | ( | &$ | form_state, |
$ | personal, | ||
$ | address | ||
) |
Clear this email address friendly flag form.
Definition at line 1464 of file dmail.user.inc.
References mfn_dmail_security_check().
{ global $user; mfn_dmail_security_check(); drupal_set_message('The Unfriendly Address form is still under development.', 'warning'); if (empty($address)) { $address = $personal; $personal = NULL; } $form['dmail']['reply']['message'] = array( '#value' => "You've requested $personal <$address> be identified as unfriendly.", ); return $form; }
mfm_dmail_unjunk_item | ( | &$ | form_state, |
$ | header_id | ||
) |
Identify this item as *not* junk form.
Definition at line 1330 of file dmail.user.inc.
References mfn_dmail_security_check().
{ global $user; mfn_dmail_security_check(); drupal_set_message('The Unjunk form is still under development.', 'warning'); $form['dmail']['reply']['message'] = array( '#value' => "You've requested to unjunk item: $header_id", ); return $form; }
mfm_dmail_unseen_item | ( | &$ | form_state, |
$ | header_id | ||
) |
Mark this item as *not* seen form.
Definition at line 1408 of file dmail.user.inc.
References mfn_dmail_security_check().
{ global $user; mfn_dmail_security_check(); drupal_set_message('The Unseen form is still under development.', 'warning'); $form['dmail']['reply']['message'] = array( '#value' => "You've requested to mark the item unseen: $header_id", ); return $form; }
mfn_dmail_addrmap | ( | $ | addr | ) |
Address mapper.
$addr |
|
Definition at line 2720 of file dmail.user.inc.
References mfn_dmail_db_addrmap_select().
Referenced by mfn_dmail_reply_from().
{ $map = mfn_dmail_db_addrmap_select($addr); if ($map === FALSE) { return $addr; } else { return $map->preferred; } }
mfn_dmail_callback_director | ( | $ | form_state | ) |
Menu callback director.
Due to the limitations placed on the menu router for the number of items in a URI this function is used for any user/%/email/% actions and redirects or form output as controlled by the values from arg().
Definition at line 1870 of file dmail.user.inc.
References mfn_dmail_expunge_mailboxes(), mfn_dmail_get_mail(), mfn_dmail_get_mailboxes(), mfn_dmail_orderby(), mfn_dmail_remove_identity(), and mfn_dmail_sanitize_mailboxes().
{ global $user; $args = arg(); if (isset($args[4])) { $breadcrumbs[] = l(t('Email'), 'user/' . $user->uid . '/email/identities'); drupal_set_breadcrumb($breadcrumbs); switch ($args[4]) { case 'edit': { drupal_set_title(t('Edit Identity')); return drupal_get_form('mfm_dmail_identities_edit', $args[3]); } case 'get': { drupal_set_title(t('Get Mail')); mfn_dmail_get_mail($args[3]); drupal_goto('user/' . $user->uid . '/email/identities'); } break; case 'expunge': { drupal_set_title(t('Expunge')); mfn_dmail_expunge_mailboxes($args[3]); drupal_goto('user/' . $user->uid . '/email/identities'); } case 'mailboxes': { drupal_set_title(t('Get Mailboxes')); mfn_dmail_get_mailboxes($args[3]); drupal_goto('user/' . $user->uid . '/email/identities'); } break; case 'sanitize': { drupal_set_title(t('Sanitize')); mfn_dmail_sanitize_mailboxes($args[3]); drupal_goto('user/' . $user->uid . '/email/identities'); } case 'remove': { drupal_set_title(t('Remove Identity')); mfn_dmail_remove_identity($args[3]); drupal_goto('user/' . $user->uid . '/email/identities'); } case 'folders': { drupal_set_title(t('Folders')); return drupal_get_form('mfm_dmail_display_folders', $args[3]); } break; case 'compose': { drupal_set_title(t('Compose Message')); return drupal_get_form('mfm_dmail_compose_item', $args[3]); } break; case 'mbox': { $breadcrumbs[] = l(t('Folders'), 'user/' . $user->uid . '/email/' . $args[3] . '/folders'); if (isset($args[6])) { $breadcrumbs[] = l(t('Mailbox Items'), 'user/' . $user->uid . '/email/' . $args[3] . '/mbox/' . $args[5], mfn_dmail_orderby()); drupal_set_breadcrumb($breadcrumbs); switch ($args[6]) { case 'recent': { drupal_set_title(t('Recent Items')); return drupal_get_form('mfn_dmail_display_recent', $args[5]); } break; case 'view': { drupal_set_title(t('View Item')); return drupal_get_form('mfm_dmail_display_item', $args[5], $args[7]); } break; case 'html': { drupal_set_title(t('View HTML')); return drupal_get_form('mfm_dmail_display_item', $args[5], $args[7], TRUE); } case 'delete': { $breadcrumbs[] = l(t('Item'), 'user/' . $user->uid . '/email/' . $args[3] . '/mbox/' . $args[5] . '/view/' . $args[7]); drupal_set_breadcrumb($breadcrumbs); drupal_set_title(t('Delete Item')); return drupal_get_form('mfm_dmail_delete_item', $args[7]); } break; case 'undelete': { $breadcrumbs[] = l(t('Item'), 'user/' . $user->uid . '/email/' . $args[3] . '/mbox/' . $args[5] . '/view/' . $args[7]); drupal_set_breadcrumb($breadcrumbs); drupal_set_title(t('Undelete Item')); return drupal_get_form('mfm_dmail_undelete_item', $args[7]); } case 'seen': { $breadcrumbs[] = l(t('Item'), 'user/' . $user->uid . '/email/' . $args[3] . '/mbox/' . $args[5] . '/view/' . $args[7]); drupal_set_breadcrumb($breadcrumbs); drupal_set_title(t('Flag Item as Seen')); return drupal_get_form('mfm_dmail_seen_item', $args[7]); } case 'unseen': { $breadcrumbs[] = l(t('Item'), 'user/' . $user->uid . '/email/' . $args[3] . '/mbox/' . $args[5] . '/view/' . $args[7]); drupal_set_breadcrumb($breadcrumbs); drupal_set_title(t('Flag Item as Not Seen')); return drupal_get_form('mfm_dmail_unseen_item', $args[7]); } case 'flag': { $breadcrumbs[] = l(t('Item'), 'user/' . $user->uid . '/email/' . $args[3] . '/mbox/' . $args[5] . '/view/' . $args[7]); drupal_set_breadcrumb($breadcrumbs); drupal_set_title(t('Flag Item Important')); return drupal_get_form('mfm_dmail_flag_item', $args[7]); } case 'unflag': { $breadcrumbs[] = l(t('Item'), 'user/' . $user->uid . '/email/' . $args[3] . '/mbox/' . $args[5] . '/view/' . $args[7]); drupal_set_breadcrumb($breadcrumbs); drupal_set_title(t('Flag Item Normal')); return drupal_get_form('mfm_dmail_unflag_item', $args[7]); } case 'copy': { $breadcrumbs[] = l(t('Item'), 'user/' . $user->uid . '/email/' . $args[3] . '/mbox/' . $args[5] . '/view/' . $args[7]); drupal_set_breadcrumb($breadcrumbs); drupal_set_title(t('Copy Item')); return drupal_get_form('mfm_dmail_copy_item', $args[7]); } break; case 'move': { $breadcrumbs[] = l(t('Item'), 'user/' . $user->uid . '/email/' . $args[3] . '/mbox/' . $args[5] . '/view/' . $args[7]); drupal_set_breadcrumb($breadcrumbs); drupal_set_title(t('Move Item')); return drupal_get_form('mfm_dmail_move_item', $args[7]); } break; case 'forward': { $breadcrumbs[] = l(t('Item'), 'user/' . $user->uid . '/email/' . $args[3] . '/mbox/' . $args[5] . '/view/' . $args[7]); drupal_set_breadcrumb($breadcrumbs); drupal_set_title(t('Forward Item')); return drupal_get_form('mfm_dmail_forward_item', $args[7]); } break; case 'junk': { $breadcrumbs[] = l(t('Item'), 'user/' . $user->uid . '/email/' . $args[3] . '/mbox/' . $args[5] . '/view/' . $args[7]); drupal_set_breadcrumb($breadcrumbs); drupal_set_title(t('Junk Item')); return drupal_get_form('mfm_dmail_junk_item', $args[7]); } break; case 'reply': { $breadcrumbs[] = l(t('Item'), 'user/' . $user->uid . '/email/' . $args[3] . '/mbox/' . $args[5] . '/view/' . $args[7]); drupal_set_breadcrumb($breadcrumbs); drupal_set_title(t('Reply')); return drupal_get_form('mfm_dmail_reply_item', $args[7]); } break; case 'replylist': { $breadcrumbs[] = l(t('Item'), 'user/' . $user->uid . '/email/' . $args[3] . '/mbox/' . $args[5] . '/view/' . $args[7]); drupal_set_breadcrumb($breadcrumbs); drupal_set_title(t('List Reply')); return drupal_get_form('mfm_dmail_replylist_item', $args[7]); } break; case 'replyall': { $breadcrumbs[] = l(t('Item'), 'user/' . $user->uid . '/email/' . $args[3] . '/mbox/' . $args[5] . '/view/' . $args[7]); drupal_set_breadcrumb($breadcrumbs); drupal_set_title(t('Reply All')); return drupal_get_form('mfm_dmail_replyall_item', $args[7]); } break; case 'replyto': { $breadcrumbs[] = l(t('Item'), 'user/' . $user->uid . '/email/' . $args[3] . '/mbox/' . $args[5] . '/view/' . $args[7]); drupal_set_breadcrumb($breadcrumbs); drupal_set_title(t('Reply To')); return drupal_get_form('mfm_dmail_replyto_item', $args[7], $args[8], $args[9]); } break; case 'friendly': { $breadcrumbs[] = l(t('Item'), 'user/' . $user->uid . '/email/' . $args[3] . '/mbox/' . $args[5] . '/view/' . $args[7]); drupal_set_breadcrumb($breadcrumbs); drupal_set_title(t('Friendly Address')); return drupal_get_form('mfm_dmail_friendly_addr', $args[8], $args[9]); } break; case 'unfriendly': { $breadcrumbs[] = l(t('Item'), 'user/' . $user->uid . '/email/' . $args[3] . '/mbox/' . $args[5] . '/view/' . $args[7]); drupal_set_breadcrumb($breadcrumbs); drupal_set_title(t('Unfriendly Address')); return drupal_get_form('mfm_dmail_unfriendly_addr', $args[8], $args[9]); } break; case 'send': { $breadcrumbs[] = l(t('Item'), 'user/' . $user->uid . '/email/' . $args[3] . '/mbox/' . $args[5] . '/view/' . $args[7]); drupal_set_breadcrumb($breadcrumbs); drupal_set_title(t('Send Mail')); return drupal_get_form('mfm_dmail_send_item', $args[8], $args[9]); } break; case 'attachment': { $breadcrumbs[] = l(t('Item'), 'user/' . $user->uid . '/email/' . $args[3] . '/mbox/' . $args[5] . '/view/' . $args[7]); drupal_set_breadcrumb($breadcrumbs); drupal_set_title(t('Attachment')); return drupal_get_form('mfm_dmail_attachment', $args[7], $args[8]); } break; case 'empty': { drupal_set_breadcrumb($breadcrumbs); drupal_set_title(t('Empty deleted items')); return drupal_get_form('mfm_dmail_empty_deleted', $args[5]); } } } else { drupal_set_title(t('Mailbox Items')); drupal_set_breadcrumb($breadcrumbs); return drupal_get_form('mfm_dmail_display_headers', $args[5]); } } } } }
mfn_dmail_check_mail | ( | $ | identity | ) |
Get new mail for the given identity.
$identity |
|
Definition at line 2303 of file dmail.user.inc.
References mfn_dmail_get_mail().
{ if (empty($identity->checkevery)) { $identity->checkevery = 600; } if ($identity->lastchkd == '0000-00-00 00:00:00' || time() - strtotime($identity->lastchkd) >= $identity->checkevery) { mfn_dmail_get_mail($identity->id); } }
mfn_dmail_decode_str | ( | $ | str, |
$ | charset = 'UTF-8' |
||
) |
Decode a MIME encoded string.
$str |
|
$charset |
|
Definition at line 2324 of file dmail.user.inc.
Referenced by mfm_dmail_display_headers(), mfm_dmail_display_item(), and mfn_dmail_explode_addr().
{ $return = NULL; $lastchr = strlen($str) - 1; if ($str[$lastchr] === '=' && $str[$lastchr - 1] === '=') { $tstr = base64_decode($str); if ($str !== FALSE) { $str = $tstr; } } if ($str[0] === '=' && $str[1] === '?' && $str[$lastchr] === '=' && $str[$lastchr - 1] === '?') { $tstr = imap_utf8($str); if ($tstr !== FALSE) { $str = $tstr; } } $elem = imap_mime_header_decode($str); foreach ($elem as $e) { if ($e->charset == 'default') { $e->charset = 'iso-8859-1'; } $return .= iconv($e->charset, $charset, $e->text); } return $return; }
mfn_dmail_decrypt | ( | $ | str | ) |
Decrypt an encrypted string.
$str |
|
Definition at line 2383 of file dmail.user.inc.
References mfn_dmail_is_encoded().
Referenced by mfm_dmail_identities_add_validate(), mfm_dmail_identities_edit_submit(), and mfn_dmail_imap_open().
{ if (mfn_dmail_is_encoded($str)) { $str = unserialize(gzuncompress(base64_decode($str))); $crypt = mcrypt_module_open(MCRYPT_3DES, NULL, MCRYPT_MODE_CBC, NULL); $key = substr(md5($str[0] . $str[2]), 0, $str[1]); mcrypt_generic_init($crypt, $key, $str[0]); $ret = mdecrypt_generic($crypt, $str[3]); mcrypt_generic_deinit($crypt); mcrypt_module_close($crypt); } else { $ret = $str; } return $ret; }
mfn_dmail_encrypt | ( | $ | str | ) |
Encrypt a string.
$str |
|
Definition at line 2361 of file dmail.user.inc.
Referenced by mfn_dmail_db_identity_add(), and mfn_dmail_db_identity_update().
{ $crypt = mcrypt_module_open(MCRYPT_3DES, NULL, MCRYPT_MODE_CBC, NULL); $ret[0] = mcrypt_create_iv(mcrypt_enc_get_iv_size($crypt), MCRYPT_RAND); $ret[1] = mcrypt_enc_get_key_size($crypt); $ret[2] = date("D.M.j.G.i.s.T.Y"); $key = substr(md5($ret[0] . $ret[2]), 0, $ret[1]); mcrypt_generic_init($crypt, $key, $ret[0]); $ret[3] = mcrypt_generic($crypt, $str); mcrypt_generic_deinit($crypt); mcrypt_module_close($crypt); return base64_encode(gzcompress(serialize($ret))); }
mfn_dmail_explode_addr | ( | $ | string | ) |
Parse the address giving the personalization name and address parts.
$string |
|
Definition at line 2948 of file dmail.user.inc.
References mfn_dmail_check_string(), and mfn_dmail_decode_str().
Referenced by mfn_dmail_reply_body(), and mfn_dmail_transform_addr().
{ $string = mfn_dmail_decode_str($string); list($name, $addr) = explode('<', $string); if (empty($addr)) { $addr = $name; $name = NULL; } else { list($addr) = explode('>', $addr); } if (empty($name)) { list($name, $host) = explode('@', $addr); $name = strtoupper($name); if (empty($host)) { $addr = "$addr@.invalid.addr"; } } $name = mfn_dmail_check_string(trim($name)); $addr = check_plain(trim($addr)); return array($name, $addr); }
mfn_dmail_expunge_mailboxes | ( | $ | identity_id | ) |
Expunge the items marked for delete.
$identity_id |
|
Definition at line 2599 of file dmail.user.inc.
References mfn_dmail_db_identity_select().
Referenced by mfn_dmail_callback_director().
{ global $imap; $identity = mfn_dmail_db_identity_select($identity_id); if ($identity->readonly) { drupal_set_message(t('Expunge operation cannot be performed in readonly mode.'), 'error'); return; } }
mfn_dmail_format_attachments | ( | $ | attachments | ) |
Format links for the attachments.
$attachments |
|
Definition at line 2458 of file dmail.user.inc.
References mfn_dmail_l().
Referenced by mfm_dmail_display_item().
{ if (!is_array($attachments)) { return; } $args = arg(); $urlf = $args[0] . '/' . $args[1] . '/' . $args[2] . '/' . $args[3] . '/' . $args[4] . '/' . $args[5] . '/' . 'attachment' . '/' . $args[7] ; $ret = NULL; foreach ($attachments as $item => $attachment) { if ($ret) { $ret .= ' | '; } $ret .= mfn_dmail_l(array( 'url' => "$urlf/$item", 'title' => $attachment->name, 'description' => $attachment->filename, 'image' => array('type' => 'mime', 'file' => 'attachment.png', 'position' => 'prefix'), )); } if ($ret) { $ret = t('Attached: ') . $ret; } return $ret; }
mfn_dmail_format_body | ( | $ | body, |
$ | length = 75 , |
||
$ | linebreak = "\n" , |
||
$ | cut_long = TRUE |
||
) |
Format the body of the item for display.
$body | |
$length |
|
$linebreak |
|
$cut_long |
|
- The $cut_long parameter isn't used.
Definition at line 2434 of file dmail.user.inc.
References mfn_dmail_format_body_clickable(), and mfn_dmail_format_line().
Referenced by mfm_dmail_display_item().
{ $paras = explode("\r\n\r\n", $body); foreach ($paras as $k1 => $para) { $lines = explode("\n", $para); foreach ($lines as $k2 => $line) { $lines[$k2] = mfn_dmail_format_line($line, $length); } $paras[$k1] = '<p>' . implode("\r\n", $lines) . '</p>'; if (trim($paras[$k1]) == '<p><br/></p>') { unset($paras[$k1]); } } return mfn_dmail_format_body_clickable(implode("\r\n", $paras)); }
mfn_dmail_format_body_clickable | ( | $ | text | ) |
HTML format strings in the given text that resemble URI.
$text |
|
Definition at line 2521 of file dmail.user.inc.
Referenced by mfn_dmail_format_body().
{ $args = arg(); // Copied from http://jmrware.com/articles/2010/linkifyurl/linkify.html // Released as open source under the MIT License // http://www.opensource.org/licenses/mit-license.php $url_pattern = '/# Rev:20100913_0900 github.com\/jmrware\/LinkifyURL # Match http & ftp URL that is not already linkified. # Alternative 1: URL delimited by (parentheses). (\() # $1 "(" start delimiter. ((?:ht|f)tps?:\/\/[a-z0-9\-._~!$&\'()*+,;=:\/?#[\]@%]+) # $2: URL. (\)) # $3: ")" end delimiter. | # Alternative 2: URL delimited by [square brackets]. (\[) # $4: "[" start delimiter. ((?:ht|f)tps?:\/\/[a-z0-9\-._~!$&\'()*+,;=:\/?#[\]@%]+) # $5: URL. (\]) # $6: "]" end delimiter. | # Alternative 3: URL delimited by {curly braces}. (\{) # $7: "{" start delimiter. ((?:ht|f)tps?:\/\/[a-z0-9\-._~!$&\'()*+,;=:\/?#[\]@%]+) # $8: URL. (\}) # $9: "}" end delimiter. | # Alternative 4: URL delimited by <angle brackets>. (<|&(?:lt|\#60|\#x3c);) # $10: "<" start delimiter (or HTML entity). ((?:ht|f)tps?:\/\/[a-z0-9\-._~!$&\'()*+,;=:\/?#[\]@%]+) # $11: URL. (>|&(?:gt|\#62|\#x3e);) # $12: ">" end delimiter (or HTML entity). | # Alternative 5: URL not delimited by (), [], {} or <>. ( # $13: Prefix proving URL not already linked. (?: ^ # Can be a beginning of line or string, or | [^=\s\'"\]] # a non-"=", non-quote, non-"]", followed by ) \s*[\'"]? # optional whitespace and optional quote; | [^=\s]\s+ # or... a non-equals sign followed by whitespace. ) # End $13. Non-prelinkified-proof prefix. ( \b # $14: Other non-delimited URL. (?:ht|f)tps?:\/\/ # Required literal http, https, ftp or ftps prefix. [a-z0-9\-._~!$\'()*+,;=:\/?#[\]@%]+ # All URI chars except "&" (normal*). (?: # Either on a "&" or at the end of URI. (?! # Allow a "&" char only if not start of an... &(?:gt|\#0*62|\#x0*3e); # HTML ">" entity, or | &(?:amp|apos|quot|\#0*3[49]|\#x0*2[27]); # a [&\'"] entity if [.!&\',:?;]? # followed by optional punctuation then (?:[^a-z0-9\-._~!$&\'()*+,;=:\/?#[\]@%]|$) # a non-URI char or EOS. ) & # If neg-assertion true, match "&" (special). [a-z0-9\-._~!$\'()*+,;=:\/?#[\]@%]* # More non-& URI chars (normal*). )* # Unroll-the-loop (special normal*)*. [a-z0-9\-_~$()*+=\/#[\]@%] # Last char can\'t be [.!&\',;:?] ) # End $14. Other non-delimited URL. /imx'; $url_replace = '$1$4$7$10$13<a href="$2$5$8$11$14" target="_dmail_link">$2$5$8$11$14</a>$3$6$9$12'; $text= preg_replace($url_pattern, $url_replace, $text); $text= preg_replace("/([a-z0-9&\-_\.]+?)@([\w\-]+\.([\w\-\.]+)+)((\?*)(subject=)*([a-zA-Z0-9\-_\.]*))/i", "<a href=\"/user/{$args[1]}/email/{$args[3]}/mbox/{$args[5]}/send/{$args[7]}//$1@$2/$7\" target=\"_dmail_link\" >$1@$2$4</a>", $text); return $text; }
mfn_dmail_format_line | ( | $ | line, |
$ | length = 75 |
||
) |
Format a line to a specified length.
$line |
|
$length |
|
Definition at line 2506 of file dmail.user.inc.
Referenced by mfn_dmail_format_body().
{ $ret = wordwrap($line, $length, '<br/>', FALSE); $ret .= '<br/>'; return $ret; }
mfn_dmail_get_headerinfo | ( | $ | header | ) |
Get the extended header information from the DB.
Definition at line 2087 of file dmail.user.inc.
References mfn_dmail_db_headerinfo_add(), mfn_dmail_db_headerinfo_select(), and mfn_dmail_get_imap_headerinfo().
Referenced by mfm_dmail_display_item(), mfm_dmail_reply_item(), mfm_dmail_replyall_item(), mfm_dmail_replylist_item(), and mfm_dmail_replyto_item().
{ $headerinfo = mfn_dmail_db_headerinfo_select($header->msgid); if ($headerinfo === FALSE) { $headerinfo = mfn_dmail_get_imap_headerinfo($header); mfn_dmail_db_headerinfo_add($headerinfo); $headerinfo = mfn_dmail_db_headerinfo_select($header->msgid); } return $headerinfo; }
mfn_dmail_get_headers | ( | $ | mbox, |
$ | identity = NULL |
||
) |
Get and store the mail box header items from the server.
$mbox |
|
$identity |
|
Definition at line 1679 of file dmail.user.inc.
References mfn_dmail_db_identity_select(), mfn_dmail_db_mbox_select(), mfn_dmail_imap_open(), mfn_dmail_process_header(), and mfn_dmail_process_mbox().
Referenced by mfm_dmail_display_headers().
{ global $imap; if (is_numeric($mbox)) { $mbox = mfn_dmail_db_mbox_select($mbox); } if (empty($identity)) { $identity = $mbox->id; } if (is_numeric($identity)) { $identity = mfn_dmail_db_identity_select($identity); } mfn_dmail_imap_open($identity); $status = $imap->status($mbox->name); if ($status->messages != $mbox->messages) { $mbox->messages = $status->messages; $mbox->recent = $status->recent; $mbox->unseen = $status->unseen; $mbox->lastchkd = date('Y-m-d H:i:s'); mfn_dmail_process_mbox($identity, $mbox); } $headers = $imap->list_headers($mbox->name); foreach ($headers as $header) { mfn_dmail_process_header($mbox, $header, $mbox->lastchkd); } }
mfn_dmail_get_imap_headerinfo | ( | $ | header | ) |
Get the extended header information from the server.
$header |
|
Definition at line 2106 of file dmail.user.inc.
Referenced by mfn_dmail_get_headerinfo().
{ global $imap; $headerinfo = $imap->fetchheader($header->msgno); watchdog('dmail debug', 'imap_headerinfo<pre>'.print_r($headerinfo,true).'</pre>'); $lines = explode("\n", $headerinfo); $hlines = array(); $lcnt = 0; foreach ($lines as $line) { $lcnt++; $ord = ord($line); watchdog('dmail ord', $lcnt . ': ' . $ord); if (in_array($ord, array(0, 9, 13, 32))) { watchdog('dmail ord', $lcnt . ': in array'); $hlines[count($hlines) - 1] .= $line; } else { $hlines[] = $line; } } $headers = new stdClass; foreach ($hlines as $line) { list($key, $value) = explode(':', $line, 2); if (empty($key)) { drupal_set_message("Invalid message, please try again!", 'error'); drupal_goto(); } $key = strtolower(str_replace(array('-', ' '), '_', $key)); $headers->$key = $value; } $headers->msgid = $header->msgid; watchdog('dmail debug', 'imap_headerinfo headers<pre>'.print_r($headers,true).'</pre>'); watchdog('dmail debug', 'imap_headerinfo lines<pre>'.print_r($lines,true).'<pre>'); watchdog('dmail debug', 'imap_headerinfo hlines<pre>'.print_r($hlines,true).'<pre>'); return $headers; }
mfn_dmail_get_mail | ( | $ | identity_id | ) |
Get email for specified identity
$identity_id |
|
Definition at line 1732 of file dmail.user.inc.
References mfn_dmail_db_identity_select(), mfn_dmail_db_identity_update_lastchkd(), mfn_dmail_db_mboxes_select(), mfn_dmail_debug(), mfn_dmail_imap_open(), mfn_dmail_process_header(), and mfn_dmail_process_mbox().
Referenced by mfn_dmail_callback_director(), and mfn_dmail_check_mail().
{ global $user, $imap; $identity = mfn_dmail_db_identity_select($identity_id); if (is_object($identity)) { $result = mfn_dmail_imap_open($identity); if (is_resource($result)) { $lastchkd = date('Y-m-d H:i:s'); $mboxes = $imap->list_mboxes(); foreach ($mboxes as $mbox) { mfn_dmail_process_mbox($identity, $mbox); } $mboxes = mfn_dmail_db_mboxes_select($identity_id); foreach ($mboxes as $mbox) { if ($mbox->messages) { $headers = $imap->list_headers($mbox->name); foreach ($headers as $header) { mfn_dmail_debug(__FILE__, __LINE__, __FUNCTION__, 'mbox', $mbox); set_time_limit(20); mfn_dmail_process_header($mbox, $header, $lastchkd); } } } } $imap->close(); mfn_dmail_db_identity_update_lastchkd($identity->id, $lastchkd); drupal_set_message('Message headers for ' . $identity->name . ' have been retrieved.'); } else { drupal_set_message('The identity record was not retrieved!', 'error'); } }
mfn_dmail_get_mailboxes | ( | $ | identity_id | ) |
Get and store the mail boxes and folders from the server.
$identity_id |
|
Definition at line 1659 of file dmail.user.inc.
References mfn_dmail_db_identity_select(), mfn_dmail_imap_open(), and mfn_dmail_process_mbox().
Referenced by mfm_dmail_identities_add_submit(), and mfn_dmail_callback_director().
{ global $imap; $identity = mfn_dmail_db_identity_select($identity_id); mfn_dmail_imap_open($identity); $mboxes = $imap->list_mboxes(); foreach ($mboxes as $mbox) { mfn_dmail_process_mbox($identity, $mbox); } }
mfn_dmail_get_newmail | ( | $ | identity | ) |
Get new mail for this identity.
$identity |
|
Definition at line 1588 of file dmail.user.inc.
References mfn_dmail_db_identity_update_lastchkd(), mfn_dmail_db_mbox_select_by_name(), mfn_dmail_db_mboxes_update(), mfn_dmail_imap_open(), mfn_dmail_process_header(), and mfn_dmail_security_check().
Referenced by mfn_dmail_refresh_check().
{ global $user, $imap; //* Only an authenticated user can call this function. mfn_dmail_security_check(); if ($identity->user_id != $user->uid) { exit; } $lastchkd = date('Y-m-d H:i:s'); $mbox = mfn_dmail_db_mbox_select_by_name($identity->id, $identity->inbox); $res = mfn_dmail_imap_open($identity); $status = $imap->status(); if ($status->messages) { $mbox->messages = $status->messages; $mbox->recent = $status->recent; $mbox->unseen = $status->unseen; $mbox->lastchkd = $lastchkd; mfn_dmail_db_mboxes_update($mbox->id, $mbox); $headers = $imap->fetch_overview("1:{$status->messages}"); foreach ($headers as $header) { mfn_dmail_process_header($mbox, $header, $lastchkd); } } mfn_dmail_db_identity_update_lastchkd($identity->id, $lastchkd); }
mfn_dmail_imap_open | ( | $ | identity, |
$ | mbox_name = NULL , |
||
$ | mode = OP_READONLY |
||
) |
Establish a connection to the service identified in the defined identity.
$identity |
|
$mbox_name |
|
$mode |
|
Definition at line 1628 of file dmail.user.inc.
References mfn_dmail_db_identity_select(), and mfn_dmail_decrypt().
Referenced by mfm_dmail_display_item(), mfn_dmail_get_headers(), mfn_dmail_get_mail(), mfn_dmail_get_mailboxes(), mfn_dmail_get_newmail(), and mfn_dmail_sanitize_mailboxes().
{ global $imap; if (is_numeric($identity)) { $identity = mfn_dmail_db_identity_select($identity); } $imap = new IMAP( $identity->user, mfn_dmail_decrypt($identity->pass), $identity->host, $identity->port, $identity->service, $identity->delimiter, $identity->encryption, $identity->vld8cert, $identity->readonly ); if ($mbox_name) { $imap->mailbox = $mbox_name; } $result = $imap->open($mode); return $result; }
mfn_dmail_is_encoded | ( | $ | str | ) |
Is the string an encoded string?
$str | The string to check for encoding. |
Definition at line 2408 of file dmail.user.inc.
Referenced by mfn_dmail_decrypt().
{ $str = @gzuncompress(@base64_decode($str)); $parts = explode(':', $str); return $parts[0] === 'a' && $parts[1] == 4; }
mfn_dmail_is_friendly | ( | $ | address | ) |
Is this email address flagged as friendly.
$address |
|
Definition at line 2666 of file dmail.user.inc.
Referenced by mfn_dmail_options_addr().
{
return FALSE;
}
mfn_dmail_is_junk | ( | $ | message_id | ) |
Is this message marked as junk?
$message_id |
|
Definition at line 2586 of file dmail.user.inc.
References mfn_dmail_db_junk_message_select().
Referenced by mfm_dmail_display_headers(), and mfn_dmail_options_addr().
{ $junk = mfn_dmail_db_junk_message_select(md5($message_id)); return $junk !== FALSE; }
mfn_dmail_items_list_header | ( | ) |
Get the items list header.
Definition at line 3018 of file dmail.user.inc.
Referenced by mfm_dmail_display_headers(), mfn_dmail_db_mbox_message_headers_select_ordered(), and theme_mfm_dmail_display_headers().
{ return array( array('data' => t('##'), 'field' => 'msgno'), array('data' => t('Received'), 'field' => 'date'), array('data' => t('From'), 'field' => 'from'), array('data' => t('Subject'), 'field' => 'subject'), t('Operations'), ); }
mfn_dmail_mail_address_object | ( | $ | hval, |
$ | addr | ||
) |
Get an object for the given address.
$hval |
|
$addr |
|
Definition at line 2824 of file dmail.user.inc.
Referenced by mfn_dmail_reply_to().
{ $obj = new stdClass; list ($name, ) = explode('<', $addr); if (empty($name)) { list($name, ) = explode('@', $addr); $mail = $addr; } else { list(, $mail) = explode('<', $addr); $mail = substr($mail, 0, -1); } $obj->hval = $hval; $obj->recipient = trim($name) . ' <' . $mail . '>'; return $obj; }
mfn_dmail_options_addr | ( | $ | type, |
$ | header, | ||
$ | has_html = FALSE , |
||
$ | address = 0 , |
||
$ | html = FALSE |
||
) |
Format the options for the item display.
$type |
|
$header |
|
$has_html |
|
$address |
|
$html |
|
Definition at line 2163 of file dmail.user.inc.
References mfn_dmail_access(), mfn_dmail_db_mbox_message_headers_select_ordered(), mfn_dmail_is_friendly(), mfn_dmail_is_junk(), mfn_dmail_l(), and mfn_dmail_orderby().
Referenced by mfm_dmail_display_item().
{ global $user; $args = arg(); $urlf = 'user/' . $user->uid . '/email/' . $header->identity_id . '/mbox/' . $header->mbox_id; switch ($type) { case 'options': { $headers = mfn_dmail_db_mbox_message_headers_select_ordered($header->mbox_id); $urlt = $header->id; $out = NULL; $attr = array(); $orderby = mfn_dmail_orderby(); if ($header->prev_id !== NULL) { $prev_header_id = $headers[$header->prev_id]->id; $out .= mfn_dmail_l($urlf . '/' . $args[6] . '/' . $prev_header_id, 'Prev', 'View the previous item.', $attr, $orderby, array('type' => 'action', 'file' => 'prev.png')) . ' | '; } if ($header->next_id !== NULL) { $next_header_id = $headers[$header->next_id]->id; $out .= mfn_dmail_l($urlf . '/' . $args[6] . '/' . $next_header_id, 'Next', 'View the next item.', $attr, $orderby, array('type' => 'action', 'file' => 'next.png')) . ' | '; } if (isset($header->list_id)) { $out .= mfn_dmail_l($urlf . '/replylist/' . $urlt, 'List Reply', 'Reply to the list address about this item.', $attr, $orderby, array('type' => 'action', 'file' => 'replylist.png')) . ' | '; } else { $out .= mfn_dmail_l($urlf . '/reply/' . $urlt, 'Reply', 'Reply about this item.', $attr, $orderby, array('type' => 'action', 'file' => 'reply.png')) . ' | '; } $out .= mfn_dmail_l($urlf . '/replyall/' . $urlt, 'Reply All', 'Reply to every address about this item.', $attr, $orderby, array('type' => 'action', 'file' => 'replyall.png')) . ' | '; $out .= mfn_dmail_l($urlf . '/forward/' . $urlt, 'Forward', 'Forward this item to another mailbox.', $attr, $orderby, array('type' => 'action', 'file' => 'forward.png')) . ' | '; if (mfn_dmail_is_junk($header->message_id)) { $out .= mfn_dmail_l($urlf . '/unjunk/' . $urlt, 'Unjunk', 'Identify this item as not Junk (i.e. not SPAM).', $attr, $orderby, array('type' => 'aciton', 'file' => 'unjunk.png')) . ' | '; } else { $out .= mfn_dmail_l($urlf . '/junk/' . $urlt, 'Junk', 'Identify this item as Junk (i.e. SPAM).', $attr, $orderby, array('type' => 'action', 'file' => 'junk.png')) . ' | '; } if ($header->deleted) { $out .= mfn_dmail_l($urlf . '/undelete/' . $urlt, 'Undelete', 'Flag this item as undeleted.', $attr, $orderby, array('type' => 'action', 'file' => 'undelete.png')) . ' | '; } else { $out .= mfn_dmail_l($urlf . '/delete/' . $urlt, 'Delete', 'Flag this item as deleted.', $attr, $orderby, array('type' => 'action', 'file' => 'delete.png')) . ' | '; } if ($header->flagged) { $out .= mfn_dmail_l($urlf . '/unflag/' . $urlt, 'Normal', 'Flag this item as unimportant.', $attr, $orderby, array('type' => 'action', 'file' => 'unimportant.png')) . ' | '; } else { $out .= mfn_dmail_l($urlf . '/flag/' . $urlt, 'Important', 'Flag this item as important.', $attr, $orderby, array('type' => 'action', 'file' => 'important.png')) . ' | '; } if ($header->seen) { $out .= mfn_dmail_l($urlf . '/unseen/' . $urlt, 'Unseen', 'Flag this item as unread.', $attr, $orderby, array('type' => 'action', 'file' => 'flag_unseen.png')) . ' | '; } else { $out .= mfn_dmail_l($urlf . '/seen/' . $urlt, 'Seen', 'Flag this item as read.', $attr, $orderby, array('type' => 'action', 'file' => 'flag_seen.png')) . ' | '; } $out .= mfn_dmail_l($urlf . '/copy/' . $urlt, 'Copy', 'Copy this item to another folder.', $attr, $orderby, array('type' => 'action', 'file' => 'copy.png')) . ' | '; $out .= mfn_dmail_l($urlf . '/move/' . $urlt, 'Move', 'Move this item to another folder.', $attr, $orderby, array('type' => 'action', 'file' => 'move.png')) . ' | '; if ($html) { $out .= mfn_dmail_l($urlf . '/view/' . $urlt, 'View PLAIN', 'View the plain text version of this email.', $attr, $orderby, array('type' => 'mime', 'file' => 'text.png')) . ' | '; } else { if ($has_html) { $out .= mfn_dmail_l($urlf . '/html/' . $urlt, 'View HTML', 'View the HTML version of this email.', $attr, $orderby, array('type' => 'mime', 'file' => 'html.png')) . ' | '; } } if (mfn_dmail_access($user->uid, DMAIL_POST_ROLE)) { $out .= mfn_dmail_l($urlf . '/post/' . $urlt, 'Post', 'Post this message to Drupal.', $attributes, $orderby, array('type' => 'action', 'file' => 'post.png')) . ' | '; } $return = $out; } break; case 'list options': { if (isset($header->list_id)) { $return = 'I need to program the list options.'; } } break; default: { $addresses = $header->$type; if (!is_array($addresses)) { $addresses = array($addresses); } $address = $addresses[$address]; list($name, $addr) = explode('<', $address); if (empty($addr)) { $addr = $name; $name = NULL; } else { list($addr) = explode('>', $addr); } if (empty($name)) { list($name) = explode('@', $addr); $name = strtoupper($name); } $name = check_plain(trim($name)); $addr = check_plain(trim($addr)); $urlt = $header->id . '/' . $name . '/' . $addr; if (mfn_dmail_is_friendly($addr)) { $friendly = mfn_dmail_l($urlf . '/unfriendly/' . $urlt, 'Unfriendly', 'This address is NOT friendly. Used by the junk mail control to indicate that mail from this address may contain SPAM.', $attr, $orderby, array('type' => 'action', 'file' => 'unfriendly.png')) . ' | '; } else { $friendly = mfn_dmail_l($urlf . '/friendly/' . $urlt, 'Friendly', 'This address is friendly. Used by the junk mail control to indicate that mail from this address is likely not to be SPAM.', $attr, $orderby, array('type' => 'action', 'file' => 'friendly.png')) . ' | '; } $replyto = mfn_dmail_l($urlf . '/replyto/' . $urlt, 'Reply', 'Reply about this email to this address.', $attr, $orderby, array('type' => 'action', 'file' => 'replyto.png')); $return = $friendly . $replyto; } break; } return $return; }
mfn_dmail_preprocess_headers | ( | $ | mbox | ) |
In refresh mode we need to get rid of the mail box header items for the given mail box.
$mbox | A mail box object. |
Definition at line 2290 of file dmail.user.inc.
Referenced by mfn_dmail_preprocess_mboxes().
{
$headers = mfn_dmail_db_headers_select($mbox->id);
foreach ($headers as $header) {
mfn_dmail_db_header_delete($header->id);
}
}
mfn_dmail_preprocess_mboxes | ( | $ | identity | ) |
In refresh mode we need to get rid of mail boxes and headers for the given identity.
$identity | An identity object. |
Definition at line 2275 of file dmail.user.inc.
References mfn_dmail_db_mbox_delete(), mfn_dmail_db_mboxes_select(), and mfn_dmail_preprocess_headers().
{ $mboxes = mfn_dmail_db_mboxes_select($identity->id); foreach ($mboxes as $mbox) { mfn_dmail_preprocess_headers($mbox); mfn_dmail_db_mbox_delete($mbox->id); } }
mfn_dmail_process_header | ( | $ | mbox, |
$ | header, | ||
$ | lastchkd | ||
) |
Process a mbox header item add or update.
$mbox |
|
$header |
|
$lastchkd |
|
Definition at line 1799 of file dmail.user.inc.
References mfn_dmail_db_mbox_message_header_add(), mfn_dmail_db_mbox_message_header_select(), mfn_dmail_db_mbox_message_header_update(), mfn_dmail_db_message_header_add(), mfn_dmail_db_message_header_select(), mfn_dmail_db_message_header_update(), mfn_dmail_debug(), and mfn_dmail_msgid().
Referenced by mfn_dmail_get_headers(), mfn_dmail_get_mail(), and mfn_dmail_get_newmail().
{ mfn_dmail_debug(__FILE__, __LINE__, __FUNCTION__, 'header', $header); set_time_limit(20); $msgid = mfn_dmail_msgid($header); $message_header = mfn_dmail_db_message_header_select($msgid); $mbox_message_header = mfn_dmail_db_mbox_message_header_select($mbox->id, $msgid); $header->mbox_id = $mbox->id; $header->msgid = $msgid; if ($message_header === FALSE) { mfn_dmail_db_message_header_add($header); } else { mfn_dmail_db_message_header_update($header); } if ($mbox_message_header === FALSE) { $header->display = TRUE; mfn_dmail_db_mbox_message_header_add($header); } else { mfn_dmail_db_mbox_message_header_update($header); } }
mfn_dmail_process_mbox | ( | $ | identity, |
$ | mbox | ||
) |
Process a mbox add or update.
$identity |
|
$mbox |
|
Definition at line 1773 of file dmail.user.inc.
References mfn_dmail_db_mbox_select_by_name(), mfn_dmail_db_mboxes_add(), and mfn_dmail_db_mboxes_update().
Referenced by mfn_dmail_get_headers(), mfn_dmail_get_mail(), and mfn_dmail_get_mailboxes().
{ list(, $mbox_name) = explode('}', $mbox->name); if (empty($mbox_name)) { $mbox_name = $mbox->name; } $mbox_result = mfn_dmail_db_mbox_select_by_name($identity->id, $mbox_name); if ($mbox_result === FALSE) { mfn_dmail_db_mboxes_add($identity, $mbox); } else { mfn_dmail_db_mboxes_update($mbox_result->id, $mbox); } }
mfn_dmail_readonly_check | ( | $ | set_message = TRUE | ) |
Is the identity set to readonly?
$set_message |
|
Definition at line 3001 of file dmail.user.inc.
References mfn_dmail_db_identity_select().
Referenced by mfm_dmail_display_folders(), mfm_dmail_display_headers(), mfm_dmail_display_item(), mfm_dmail_reply_item(), mfm_dmail_replyall_item(), mfm_dmail_replylist_item(), and mfm_dmail_replyto_item().
{ $identity = mfn_dmail_db_identity_select(arg(3)); if ($identity->readonly) { if ($set_message === TRUE) { drupal_set_message(t('This identity is set to read only!'), 'warning', FALSE); } elseif ($set_message) { drupal_set_message($set_message, 'error', FALSE); } return TRUE; } return FALSE; }
mfn_dmail_refresh | ( | ) |
Refresh all mailboxes for all identities.
Definition at line 1825 of file dmail.user.inc.
References mfn_dmail_db_identities_select(), mfn_dmail_refresh_check(), and mfn_dmail_security_check().
{ global $user; mfn_dmail_security_check(); $identities = mfn_dmail_db_identities_select($user->uid); foreach ($identities as $identity) { mfn_dmail_refresh_check($identity); } }
mfn_dmail_refresh_check | ( | $ | identity | ) |
Make sure we aren't already refreshing this identity and that the time limit is met.
$identity |
|
Definition at line 1841 of file dmail.user.inc.
References mfn_dmail_get_newmail().
Referenced by mfn_dmail_refresh().
{ $time = time(); $refresh = FALSE; $checkevery = empty($identity->checkevery) ? 600 : $identity->checkevery; $semaphore = duvar_get('refreshSemaphore', FALSE); if ($semaphore) { if ($time - $semaphore > duvar_get('safeRefreshThreshold', $checkevery * 2)) { watchdog('dmail refresh', 'Refresh has been running %time seconds and may be stuck.', array('%time' => $checkevery * 2)); duvar_del('refreshSemaphore'); } } else { $last = strtotime($identity->lastchkd); if ($time - $last > $checkevery) { watchdog('dmail refresh', "@time @identity", array('@time' => date('H:i:s'), '@identity' => $identity->name)); duvar_set('refreshSemaphore', $time); mfn_dmail_get_newmail($identity); duvar_del('refreshSemaphore'); } } }
mfn_dmail_remove_identity | ( | $ | identity_id | ) |
Remove the specified identity and all the associated items.
$identity_id |
|
Definition at line 1711 of file dmail.user.inc.
References mfn_dmail_db_identity_delete(), mfn_dmail_db_identity_select(), mfn_dmail_db_mbox_delete(), and mfn_dmail_db_mboxes_select().
Referenced by mfn_dmail_callback_director().
{ $identity = mfn_dmail_db_identity_select($identity_id); unset($_SESSION['dmail']['db']['mboxes']); $mboxes = mfn_dmail_db_mboxes_select($identity_id); unset($_SESSION['dmail']['db']['headers']); foreach ($mboxes as $mbox) { $headers = mfn_dmail_db_headers_select($mbox->id); foreach ($headers as $header) { mfn_dmail_db_header_delete($header->id); } mfn_dmail_db_mbox_delete($mbox->id); } mfn_dmail_db_identity_delete($identity->id); }
mfn_dmail_reply_body | ( | $ | header, |
$ | wrap_width = 72 |
||
) |
Format the email body in quoted style for the default_value of the reply form.
$header |
|
$wrap_width |
|
Definition at line 2873 of file dmail.user.inc.
References mfn_dmail_explode_addr(), mfn_dmail_signature(), and mfn_dmail_wordwrap().
Referenced by mfm_dmail_reply_form().
{ $item = dcache_get(array('form', 'item'), DCACHE_SESSION); $ret = NULL; if ($item['header_id'] === $header->id) { $lines = explode("\n", $item['bodyplain']); foreach ($lines as $key => $line) { $lastchr = strlen($line) - 1; if ($line[$lastchr] === "\r") { $line = substr($line, 0, $lastchr); } if ($line[0] == '>') { $lines[$key] = mfn_dmail_wordwrap(">$line", $wrap_width); } else { $lines[$key] = mfn_dmail_wordwrap("> $line", $wrap_width); } } array_unshift($lines, ''); list($name) = mfn_dmail_explode_addr($header->from); $t = t('---In response to message sent by !name---', array('!name' => $name)); array_unshift($lines, $t); $ret = implode("\r\n", $lines); $ret .= "\r\n\r\n"; $ret .= mfn_dmail_signature($item['identity_id']); } else { exit; } return $ret; }
mfn_dmail_reply_from | ( | $ | header | ) |
Get the From address for the reply.
Note that the delivered-to mail header is used to find the addrmap row to determine the From address. If no addrmap row exists then the delivered_to value in the item header object is used as the value to return.
$header |
|
Definition at line 2683 of file dmail.user.inc.
References mfn_dmail_addrmap(), and mfn_dmail_db_identities_select().
Referenced by mfm_dmail_reply_form().
{ $identities = mfn_dmail_db_identities_select(); $from = array(); $mapped = mfn_dmail_addrmap(trim($header->delivered_to)); if ($mapped !== trim($header->delivered_to)) { $from[] = $mapped; } if (!in_array(trim($header->delivered_to), $from)) { if (isset($header->delivered_to)) { $from[] = trim($header->delivered_to); } else { $from[] = mfn_dmail_addrmap(trim($header->to[0])); } } foreach ($identities as $identity) { $mapped = mfn_dmail_addrmap($identity->user); if ($mapped !== $identity->user && !in_array($mapped, $from)) { $from[] = $mapped; } if (!in_array($identity->user, $from)) { $from[] = $identity->user; } } return $from; }
mfn_dmail_reply_subject | ( | $ | header | ) |
Format the Subject string for the reply.
$header |
|
Definition at line 2849 of file dmail.user.inc.
Referenced by mfm_dmail_reply_form().
{ $subject = trim($header->subject); if (isset($header->in_reply_to)) { $ret = $subject; } else { $ret = "Re: $subject"; } return trim($ret); }
mfn_dmail_reply_to | ( | $ | type, |
$ | header | ||
) |
Get the reply To address.
$type |
|
$header |
|
Definition at line 2743 of file dmail.user.inc.
References mfn_dmail_mail_address_object().
Referenced by mfm_dmail_reply_item(), mfm_dmail_replyall_item(), mfm_dmail_replylist_item(), and mfm_dmail_replyto_item().
{ $ret = array(); switch ($type) { case 'replylist': { if (isset($header->list_post)) { $lpostitems = explode(',', $header->list_post); foreach ($lpostitems as $lpostitem) { $lpostitem = trim($lpostitem); $lpostitem[0] = ' '; $lpostitem[strlen($lpostitem) - 1] = ' '; $lpostitem = trim($lpostitem); list($m, $addr) = explode(':', $lpostitem); if ($m == 'mailto') { break; } } } else { $addr = 'No post to this list permitted.'; } list($name, ) = explode('<', $header->list_id); $cl = new stdClass; $cl->hval = 'to'; $cl->recipient = trim($name) . ' <' . $addr . '>'; $ret[] = $cl; $cl = new stdClass; $cl->hval = 'rt'; $cl->recipient = trim($name) . ' <' . $addr . '>'; $ret[] = $cl; } break; case 'reply': { $ret[] = mfn_dmail_mail_address_object('to', $header->reply_to ? $header->reply_to : $header->from); } break; case 'replyall': { if ($header->reply_to) { $ret[] = mfn_dmail_mail_address_object('to', $header->reply_to); $ret[] = mfn_dmail_mail_address_object('cc', $header->from); } else { $ret[] = mfn_dmail_mail_address_object('to', $header->from); } if (is_array($header->to)) { foreach ($header->to as $addr) { $ret[] = mfn_dmail_mail_address_object('cc', $addr); } } else { $ret[] = mfn_dmail_mail_address_object('cc', $header->to); } if ($header->cc) { if (is_array($header->cc)) { foreach ($header->cc as $addr) { $ret[] = mfn_dmail_mail_address_object('cc', $addr); } } else { $ret[] = mfn_dmail_mail_address_object('cc', $header->cc); } } } break; case 'replyto': { } break; } return $ret; }
mfn_dmail_sanitize_mailboxes | ( | $ | identity_id | ) |
Sanitize the mailbox items into appropriate folders based on the item flags.
$identity_id |
|
Definition at line 2616 of file dmail.user.inc.
References mfn_dmail_db_identity_select(), mfn_dmail_db_mboxes_select(), and mfn_dmail_imap_open().
Referenced by mfn_dmail_callback_director().
{ global $imap; $identity = mfn_dmail_db_identity_select($identity_id); if ($identity->readonly) { drupal_set_message(t('Sanitize operation cannot be performed in readonly mode.'), 'error'); return; } $mboxes = mfn_dmail_db_mboxes_select($identity_id); foreach ($mboxes as $mbox) { mfn_dmail_imap_open($identity, $mbox->name); } }
mfn_dmail_signature | ( | $ | identity_id | ) |
Get the signature for the identity.
$identity_id |
|
Definition at line 2979 of file dmail.user.inc.
References mfn_dmail_db_identity_select(), and mfn_dmail_db_signature_select().
Referenced by mfn_dmail_reply_body().
{ $ret = NULL; $identity = mfn_dmail_db_identity_select($identity_id); if ($identity->signature_id) { $signature = mfn_dmail_db_signature_select($identity->signature_id); if ($signature !== FALSE) { $ret = $signature->signature; } } return $ret; }
mfn_dmail_transform_addr | ( | $ | type, |
$ | header | ||
) |
Format a email address for display as found in the header.
$type |
|
$header |
|
Definition at line 2070 of file dmail.user.inc.
References mfn_dmail_explode_addr(), and mfn_dmail_l().
Referenced by mfm_dmail_display_item().
{ global $user; $xform = array(); $val = $header->$type; if (!is_array($val)) { $val = array($val); } foreach ($val as $el => $one) { list($name, $addr) = mfn_dmail_explode_addr($one); $xform[$el] = mfn_dmail_l('user/' . $user->uid . '/email/' . $header->identity_id . '/mbox/' . $header->mbox_id . '/send/' . $header->id . '/' . $name . '/' . $addr, $name, array('description' => 'Compose new mail to !name', 'data' => array('!name' => $name))) . " <$addr>"; } return $xform; }
mfn_dmail_wordwrap | ( | $ | str, |
$ | wrap_width = 72 |
||
) |
Wrap the given multi-line string to lines not longer than wrap width.
Note: This is a helper function to format the body of the email in a reply. The first line of the string is not formatted.
$str |
|
$wrap_width |
|
Definition at line 2919 of file dmail.user.inc.
Referenced by mfn_dmail_reply_body().
{ if (strlen($str) > $wrap_width) { $i = 0; while ($str[$i] === '>') { $i++; } $quote = substr($str, 0, $i); $tstr = wordwrap($str, $wrap_width, "\n"); $tlines = explode("\n", $tstr); $fline = array_shift($tlines); foreach ($tlines as $tkey => $tline) { $tlines[$tkey] = "$quote $tline"; } array_unshift($tlines, $fline); $str = implode("\r\n", $tlines); } return $str; }
mfn_dmail_xform_header | ( | &$ | header, |
$ | headerinfo | ||
) |
Transform the headerinfo data into the header object.
$header |
|
$headerinfo |
|
Definition at line 2638 of file dmail.user.inc.
Referenced by mfm_dmail_display_item(), mfm_dmail_reply_item(), mfm_dmail_replyall_item(), mfm_dmail_replylist_item(), and mfm_dmail_replyto_item().
{ foreach ((array)$headerinfo->headers as $key => $val) { if (!isset($header->$key)) { $header->$key = $val; } else { switch ($key) { case 'cc': case 'to': { // @todo - Need to modify the formatting code for multiple addresses. $header->$key = explode(',', $val); } break; } } } }
theme_mfm_dmail_display_headers | ( | $ | form | ) |
Theme the items list form.
Definition at line 1548 of file dmail.user.inc.
References mfn_dmail_items_list_header().
{ $output = NULL; $pager = NULL; $rows = array(); if (isset($form['dmail']['headers']['msgno'])) { foreach (element_children($form['dmail']['headers']['msgno']) as $key) { $rows[] = array( drupal_render($form['dmail']['headers']['msgno'][$key]), drupal_render($form['dmail']['headers']['received'][$key]), drupal_render($form['dmail']['headers']['from'][$key]), drupal_render($form['dmail']['headers']['subject'][$key]), drupal_render($form['dmail']['headers']['operations'][$key]), ); unset($form['dmail']['headers']['headers']); } if ($form['dmail']['headers']['pager']['#value']) { $pager = drupal_render($form['dmail']['headers']['pager']); } } else { $rows[] = array(array('data' => t('No items in this mailbox folder.'), 'colspan' => '5')); } $header = mfn_dmail_items_list_header(); $output = $pager; $output .= theme('table', $header, $rows); $output .= $pager; $output .= drupal_render($form); return $output; }
theme_mfm_dmail_identities | ( | $ | form | ) |
Theme the identities list
Definition at line 1522 of file dmail.user.inc.
References mfn_dmail_list_headers().
{ $header = mfn_dmail_list_headers('dmail_identities', $form); $output = NULL; $rows = array(); foreach (element_children($form['dmail']['identity']['list']['id']) as $key) { $rows[] = array( drupal_render($form['dmail']['identity']['list']['identities'][$key]), drupal_render($form['dmail']['identity']['list']['id'][$key]), drupal_render($form['dmail']['identity']['list']['name'][$key]), drupal_render($form['dmail']['identity']['list']['lastchkd'][$key]), drupal_render($form['dmail']['identity']['list']['messages'][$key]), drupal_render($form['dmail']['identity']['list']['recent'][$key]), drupal_render($form['dmail']['identity']['list']['operations'][$key]), ); } if (!count($rows)) { $rows[] = array(array('data' => t('No identities to list.'), 'colspan' => '7')); } $output .= theme('table', $header, $rows); $output .= drupal_render($form); return $output; }