DMail Milestone 1.0
Drupal Mail Client
dmail.module File Reference

Go to the source code of this file.

Enumerations

enum  DMAIL_DEBUG
enum  DMAIL_NL
enum  DMAIL_ADMIN_ROLE
enum  DMAIL_ACCESS_ROLE
enum  DMAIL_POST_ROLE
enum  DMAIL_DEFAULT_HOST
enum  DMAIL_DEFAULT_PORT
enum  DMAIL_DEFAULT_INBOX
enum  DMAIL_DEFAULT_TOPLEVEL_FOLDERS
enum  DMAIL_DEFAULT_ITEMS_ORDERBY
enum  DMAIL_DEFAULT_ITEMS_SORTDIR
enum  DMAIL_DEFAULT_DELIM
enum  DMAIL_DEFAULT_SERVICE
enum  DMAIL_DEFAULT_ENCRYPT
enum  DMAIL_DEFAULT_VALIDATE_CERT
enum  DMAIL_DEFAULT_EXPUNGE
enum  DMAIL_DEFAULT_READONLY
enum  DMAIL_DEFAULT_MOVE_DELETED
enum  DMAIL_DEFAULT_CHECK_MAIL_FREQ
enum  DMAIL_DEFAULT_BODY_CHAR_WRAP

Functions

 dmail_init ()
 dmail_perm ()
 dmail_menu ()
 dmail_block ($op= 'list', $delta=0, $edit=array())
 dmail_theme ()
 mfn_dmail_is_valid_service ($values)
 mfn_dmail_debug ($file, $line, $function, $var, $data)
 _mfn_dmail_debug_data ($data)
 mfn_dmail_datetime ($str)
 mfn_dmail_tablesort_sql ($header, $before= '')
 mfn_dmail_l ($link, $title=NULL, $desc=NULL, $attributes=array(), $options=array(), $image=NULL)
 mfn_dmail_access ($user_id, $role=DMAIL_ACCESS_ROLE)
 mfn_dmail_msgid ($header)
 mfn_dmail_check_string ($string, $encode_quotes=FALSE)
 mfn_dmail_block_identities ()
 mfn_dmail_block_item ($obj, &$tree, $treed=FALSE)
 mfn_dmail_block_trees ($obj, &$trees, $tree=NULL)
 mfn_dmail_block_item_link ($obj, &$links)
 mfn_dmail_block_items (&$links)
 mfn_dmail_li_item ($obj)
 mfn_dmail_ul_item ($links, $tolevel=0)
 mfn_dmail_ul_item_open ()
 mfn_dmail_ul_item_close ($tolevel=0)
 mfn_dmail_spaces ($spccnt)
 mfn_dmail_production_mode ()
 mfn_dmail_get_active_identity ()
 mfn_dmail_set_active_identity ($identity)
 mfn_dmail_theme_block_init ()
 mfn_dmail_security_check ()
 mfn_dmail_list_headers ($which, $form)
 mfn_dmail_natksort (array &$array)
 mfn_dmail_active_mbox ($mbox=NULL)
 mfn_dmail_is_active_mbox_parent ($mbox)
 mfn_dmail_is_active_mbox_child ($mbox)
 mfn_dmail_is_active_mbox ($mbox)
 mfn_dmail_orderby ()
 mfn_dmail_form_text ($type, $field)
 mfn_dmail_form_options ($field)
 mfn_dmail_form_default ($field)
 mfn_dmail_subject_re ($subject)

Detailed Description

Drupal Mail Main Module

Definition in file dmail.module.


Enumeration Type Documentation

User access permission.

Definition at line 39 of file dmail.module.

Admin permission.

Definition at line 34 of file dmail.module.

Turn debugging on or off.

Definition at line 21 of file dmail.module.

Default wrap body lines to N characters for admin/settings/dmail page.

Definition at line 120 of file dmail.module.

Default check mail frequency for admin/settings/dmail page.

Definition at line 115 of file dmail.module.

Default mailbox delimiter for admin/settings/dmail page.

Definition at line 80 of file dmail.module.

Default encryption for admin/settings/dmail page.

Definition at line 90 of file dmail.module.

Default expunge on close for admin/settings/dmail page.

Definition at line 100 of file dmail.module.

Default host for admin/settings/dmail page.

Definition at line 50 of file dmail.module.

Default inbox mailbox for admin/settings/dmail page.

Definition at line 60 of file dmail.module.

Default items list order by column.

Definition at line 70 of file dmail.module.

Default items list sort order.

Definition at line 75 of file dmail.module.

Default move deleted to trash folder for admin/settings/dmail page.

Definition at line 110 of file dmail.module.

Default port for admin/settings/dmail page.

Definition at line 55 of file dmail.module.

Default read only for admin/settings/dmail page.

Definition at line 105 of file dmail.module.

Default service for admin/settings/dmail page.

Definition at line 85 of file dmail.module.

Default allow folders to be created as a top level item.

Definition at line 65 of file dmail.module.

Default validate certificate for admin/settings/dmail page.

Definition at line 95 of file dmail.module.

enum DMAIL_NL

New line.

NULL in production mode to limit the number of characters being sent. "\r\n" in development mode to help with viewing the page source.

Definition at line 29 of file dmail.module.

Allow posting mail to node system.

Definition at line 44 of file dmail.module.


Function Documentation

_mfn_dmail_debug_data ( data)

A private function to give better representation of the data for debugging.

Definition at line 344 of file dmail.module.

Referenced by mfn_dmail_debug().

                                      {
  if ($data === FALSE) {
    return '(bool)FALSE';
  }
  elseif ($data === TRUE) {
    return '(bool)TRUE';
  }
  elseif ($data === NULL) {
    return 'NULL';
  }
  elseif ($data === '') {
    return '(string)EMPTY';
  }
  else {
    return print_r($data, TRUE);
  }
}
dmail_block ( op = 'list',
delta = 0,
edit = array() 
)

The hook_block implementation.

Definition at line 246 of file dmail.module.

References mfn_dmail_access(), and mfn_dmail_block_identities().

                                                                {
  global $user;
  if (mfn_dmail_access($user->uid)) {
    switch ($op) {
      case 'list': {
        return array(
          'dmail identities' => array(
            'info' => t('Email'),
            'cache' => BLOCK_NO_CACHE,
            'status' => 1,
            'region' => 'left',
            'roles' => array('dmail user'),
            'visibility' => '0',
            'pages' => NULL,
          ),
        );
      } break;
      case 'view': {
        return array(
            'subject' => t('Email'),
            'content' => mfn_dmail_block_identities(),
        );
      } break;
    }
  }
}
dmail_init ( )

The hook_init implementation.

Ensure the JS script to refresh the email box is executed.

Definition at line 127 of file dmail.module.

References mfn_dmail_theme_block_init().

                      {
  global $user;
  drupal_add_js(drupal_get_path('module', 'dmail') . '/dmail.js');
  $settings = array(
    'refresh' => array(
      'path' => url('user/' . $user->uid . '/email/refresh'),
      'refreshNext' => duvar_get('lastRefresh', 0) + duvar_get('safeRefreshThreshold', 600)
    ),
  );
  drupal_add_js(array('dmail' => $settings), 'setting');
  mfn_dmail_theme_block_init();
}
dmail_menu ( )

The hook_menu implmentation.

Definition at line 155 of file dmail.module.

                      {
  $items = array(
    'admin/dmail/settings' => array(
      'title' => 'Mail Client',
      'page callback' => 'drupal_get_form',
      'page arguments' => array('dmail_settings'),
      'access arguments' => array(array(DMAIL_ADMIN_ROLE, 'administer site configuration')),
      'file' => 'dmail.admin.inc',
    ),
    'user/%/email/identities' => array(
      'title' => 'Email',
      'description' => 'User\'s email',
      'page callback' => 'dmail_user_identities',
      'page arguments' => array(1),
      'access callback' => 'mfn_dmail_access',
      'access arguments' => array(1),
      'file' => 'dmail.user.inc',
      'type' => MENU_LOCAL_TASK,
    ),
    'user/%/email/identities/view' => array(
      'title' => 'Identities',
      'description' => 'User\'s identities',
      'type' => MENU_DEFAULT_LOCAL_TASK,
      'weight' => 0,
    ),
    'user/%/email/identities/add' => array(
      'title' => 'New Identity',
      'description' => 'Add a new identity.',
      'page callback' => 'dmail_user_identities_add',
      'page arguments' => array(1),
      'access arguments' => array(DMAIL_ACCESS_ROLE),
      'file' => 'dmail.user.inc',
      'type' => MENU_LOCAL_TASK,
    ),
    'user/%/email/settings' => array(
      'title' => 'Settings',
      'description' => 'Control how your mail client acts',
      'page callback' => 'dmail_user_settings',
      'page arguments' => array(1),
      'access arguments' => array(DMAIL_ACCESS_ROLE),
      'file' => 'dmail.settings.inc',
      'type' => MENU_LOCAL_TASK,
    ),
    'user/%/email/signatures' => array(
      'title' => 'Signatures',
      'description' => 'Create signatures for your mail posts.',
      'page callback' => 'dmail_user_signatures',
      'access arguments' => array(DMAIL_ACCESS_ROLE),
      'file' => 'dmail.signatures.inc',
      'type' => MENU_LOCAL_TASK,
      'weight' => 10,
    ),
    'user/%/email/signatures/view' => array(
      'title' => 'Signatures',
      'description' => 'User\'s identities',
      'type' => MENU_DEFAULT_LOCAL_TASK,
      'weight' => 0,
    ),
    'user/%/email/signatures/add' => array(
      'title' => 'Add',
      'description' => 'Add a new signature.',
      'page callback' => 'dmail_user_signatures_add',
      'page arguments' => array(1),
      'access arguments' => array(DMAIL_ACCESS_ROLE),
      'file' => 'dmail.signatures.inc',
      'type' => MENU_LOCAL_TASK,
      'weight' => 20,
    ),
    'user/%/email/refresh' => array(
      'title' => 'Dmail Refresh',
      'description' => 'Refresh the identities mailbox data.',
      'page callback' => 'mfn_dmail_refresh',
      'access arguments' => array(DMAIL_ACCESS_ROLE),
      'file' => 'dmail.user.inc',
      'type' => MENU_CALLBACK,
    ),
    'user/%/email/%' => array(
      'title' => 'Dmail Director',
      'description' => 'Direct the page output for the dmail module.',
      'page callback' => 'mfn_dmail_callback_director',
      'access arguments' => array(DMAIL_ACCESS_ROLE),
      'file' => 'dmail.user.inc',
      'type' => MENU_CALLBACK,
    ),
  );
  return $items;
}
dmail_perm ( )

The hook_perm implementation.

Definition at line 143 of file dmail.module.

                      {
  $perms = array(
    DMAIL_ADMIN_ROLE,
    DMAIL_ACCESS_ROLE,
    DMAIL_POST_ROLE,
  );
  return $perms;
}
dmail_theme ( )

The hook_theme implementation.

Definition at line 276 of file dmail.module.

                       {
  return array(
    'mfm_dmail_identities' => array(
      'arguments' => array('form' => NULL),
    ),
    'mfm_dmail_display_headers' => array(
      'arguments' => array('form' => NULL),
    ),
    'mfm_dmail_signatures' => array(
      'arguments' => array('form' => NULL),
    ),
  );
}
mfn_dmail_access ( user_id,
role = DMAIL_ACCESS_ROLE 
)

Check the users access to dmail functions.

Parameters:
$user_id
  • The uid as given via the URL.
$role
  • Optionally give a dmail role to check, default DMAIL_ACCESS_ROLE.
Returns:
  • Boolean TRUE or FALSE.

Definition at line 507 of file dmail.module.

Referenced by dmail_block(), mfm_dmail_display_headers(), and mfn_dmail_options_addr().

                                                               {
  global $user;
  return user_access($role) && $user->uid === $user_id;
}
mfn_dmail_active_mbox ( mbox = NULL)

Get or set the active mail box.

Definition at line 1025 of file dmail.module.

Referenced by mfm_dmail_display_headers(), and mfm_dmail_display_item().

                                             {
  $cache = dcache_get(array('active'));
  $active_identity =& $cache['identity'];
  $active_mbox =& $cache['mbox'];
  $active_mbox = new stdClass;
  if ($mbox) {
    $t = explode($active_identity->delimiter, $mbox->name);
    $p = NULL;
    $active_mbox->id = $mbox->id;
    $active_mbox->name = $mbox->name;
    $active_mbox->paths = array();
    $level = 0;
    $active_mbox->levels = count($t);
    foreach ($t as $folder) {
      if ($p) {
        $p .= $active_identity->delimiter;
      }
      $p .= $folder;
      $active_mbox->folders[$p] = ++$level;
    }
  }
  dcache_set(array('active'), $cache);
  return $active_mbox;
}
mfn_dmail_block_identities ( )

Get the contents to fill the block when viewed.

Returns:
  • The html formatted data for the block.

Definition at line 548 of file dmail.module.

References mfn_dmail_block_item_link(), mfn_dmail_block_items(), mfn_dmail_block_trees(), mfn_dmail_db_identities_select(), mfn_dmail_db_mboxes_select(), mfn_dmail_get_active_identity(), mfn_dmail_is_active_mbox(), mfn_dmail_is_active_mbox_child(), mfn_dmail_is_active_mbox_parent(), mfn_dmail_l(), and mfn_dmail_natksort().

Referenced by dmail_block().

                                      {
  global $user;
  $trees = NULL;
  $folders = array();

  $cache = dcache_get(array('active'));

  $identities = mfn_dmail_db_identities_select();
  $active_identity = mfn_dmail_get_active_identity();
  $mpath = drupal_get_path('module', 'dmail');

  // Need to fold the System menu into the folders work below.
  if ($active_identity->id == 0) {
    $fimage = "<img src=\"/{$mpath}/images/folders/settings.png\" width=\"16\" height=\"16\"/>";
    $tree = theme_menu_item(theme_menu_item_link(array('title' => $fimage . t(' Settings'), 'href' => 'user/' . $user->uid . '/email/settings', 'localized_options' => array('html' => TRUE))), FALSE);
    $new = mfn_dmail_l(array(
      'href' => 'user/' . $user->uid . '/email/signatures/add',
      'title' => '(New)',
      'image' => array('type' => 'action', 'file' => 'new_signature.png'),
    ));
    $fimage = "<img src=\"/{$mpath}/images/folders/signatures.png\" width=\"16\" height=\"16\"/>";
    $tree .= theme_menu_item(theme_menu_item_link(array('title' => $fimage . t(' Signatures '), 'href' => 'user/' . $user->uid . '/email/signatures', 'localized_options' => array('html' => TRUE))) . $new, FALSE);
    $new = mfn_dmail_l(array(
      'href' => 'user/' . $user->uid . '/email/identities/add',
      'title' => '(New)',
      'image' => array('type' => 'action', 'file' => 'new_identity.png'),
    ));
    $fimage = "<img src=\"/{$mpath}/images/folders/identity.png\" width=\"16\" height=\"16\" />";
    $tree .= theme_menu_item(theme_menu_item_link(array('title' => $fimage . t(' Identities '), 'href' => 'user/' . $user->uid . '/email/identities', 'localized_options' => array('html' => TRUE))) . $new, FALSE);
    $tree = theme_menu_tree($tree);
    $fimage = "<img src=\"/{$mpath}/images/folders/system.png\" width=\"16\" height=\"16\"/>";
    $trees .= theme_menu_tree(theme_menu_item(theme_menu_item_link(array('title' => $fimage . t(' System'), 'href' => 'user/' . $user->uid . '/email/identities', 'localized_options' => array('html' => TRUE))), FALSE, $tree));
  }
  else {
    $fimage = "<img src=\"/{$mpath}/images/folders/system.png\" width=\"16\" height=\"16\"/>";
    $trees .= theme_menu_tree(theme_menu_item(theme_menu_item_link(array('title' => $fimage . t(' System'), 'href' => 'user/' . $user->uid . '/email/identities', 'localized_options' => array('html' => TRUE))), TRUE));
  }

  foreach ($identities as $identity) {
    if ($identity->id == $active_identity->id) {
      $mboxes = mfn_dmail_db_mboxes_select($identity->id);
      $folders = array();
      foreach ($mboxes as $mbox) {
        $tfolders = explode($identity->delimiter, $mbox->name);
        $tlvlmbox = $tfolders[0];
        if ($mbox->name === $tlvlmbox) {
          $tlevel = $tlvlmbox;
          $tobj = new stdClass;
          $tobj->id = $mbox->id;
          $tobj->identity_id = $mbox->identity_id;
          $tobj->name = $mbox->name;
          $tobj->attributes = $mbox->attributes;
          $tobj->flags = $mbox->flags;
          $tobj->parent = FALSE;
          $tobj->is_active_mbox = mfn_dmail_is_active_mbox($mbox);
          $tobj->is_active_parent = mfn_dmail_is_active_mbox_parent($mbox);
          $tobj->is_active_child = TRUE;
          $folders[$tlevel] = $tobj;
        }
        else {
          $tfolders = explode($identity->delimiter, $mbox->name);
          $tlvlmbox = $tfolders[0];
          $tlevel = $tlvlmbox;
          foreach ($tfolders as $tfolder) {
            if ($tfolder === $tlvlmbox) {
              $folders[$tlevel]->parent = TRUE;
            }
            else {
              $tlevel .= $identity->delimiter . $tfolder;
            }
            if (empty($folders[$tlevel])) {
              $tobj = new stdClass;
              $tobj->id = $mbox->id;
              $tobj->identity_id = $mbox->identity_id;
              $tobj->name = substr($tlevel, strlen($tlvlmbox) + 1);
              $tobj->attributes = $mbox->attributes;
              $tobj->flags = $mbox->flags;
              $tobj->parent = FALSE;
              $tobj->is_active_mbox = mfn_dmail_is_active_mbox($mbox);
              $tobj->is_active_parent = mfn_dmail_is_active_mbox_parent($mbox);
              $tobj->is_active_child = mfn_dmail_is_active_mbox_child($mbox);
              $folders[$tlevel] = $tobj;
            }
            else {
              $folders[$tlevel]->parent = TRUE;
            }
          }
        }
      }
      mfn_dmail_natksort($folders);
      $tree = array();
      foreach ($folders as $key => $folder) {
        $tfolders = explode($identity->delimiter, $key);
        $tkey = NULL;
        $tlevel = 0;
        while ($tfolder = array_shift($tfolders)) {
          $tkey = ($tkey) ? $tkey . $identity->delimiter . $tfolder : $tfolder;
          if ($key != $tkey) {
            $folders[$tkey]->parent = TRUE;
          }
          $folders[$tkey]->level = ++$tlevel;
          $folders[$tkey]->name = $tfolder;
        }
      }
      $identity->parent = TRUE;
      $identity->level = 0;
      mfn_dmail_block_item_link($identity, $tree);
      foreach ($folders as $folder) {
        mfn_dmail_block_item_link($folder, $tree);
      }
      $trees .= mfn_dmail_block_items($tree);
    }
    else {
      mfn_dmail_block_trees($identity, $trees);
    }
  }
  return $trees;
}
mfn_dmail_block_item ( obj,
&$  tree,
treed = FALSE 
)

HTML format an individual item of the block.

Definition at line 670 of file dmail.module.

References mfn_dmail_l().

Referenced by mfn_dmail_block_trees().

                                                            {
  global $user;
  if (isset($obj->identity_id)) {
    if ($obj->parent) {
      $ttree = theme_menu_item(
        theme_menu_item_link(
          array(
            'title' => $obj->name,
            'href' => 'user/' . $user->uid . '/email/' . $obj->identity_id . '/mbox/' . $obj->id,
          )
        ), 
        TRUE,
        $tree
      );
    }
    else {
      $ttree = theme_menu_item(
        theme_menu_item_link(
          array(
            'title' => $obj->name,
            'href' => 'user/' . $user->uid . '/email/' . $obj->identity_id . '/mbox/' . $obj->id,
          )
        ), 
        $obj->parent
      );
      $ttree = theme_menu_tree($ttree);
    }
    $tree .= $ttree;
  }
  else {
    $compose = mfn_dmail_l(array(
      'href' => "user/{$user->uid}/email/{$obj->id}/compose",
      'title' => ' (Compose)',
      'description' => 'Compose new mail to send to people.',
      'image' => array(
        'type' => 'action',
        'file' => 'compose.png',
      ),
    ));
    $ttree = theme_menu_item(
      theme_menu_item_link(
        array(
          'title' => $obj->name,
          'href' => 'user/' . $user->uid . '/email/' . $obj->id . '/folders'
        )
      ) . $compose,
      $treed,
      $tree
    );
    if ($treed) {
      $tree .= $ttree;
    }
    else {
      $tree = $ttree;
    }
  }
}
mfn_dmail_block_item_link ( obj,
&$  links 
)

HTML format individual block item URL.

Definition at line 744 of file dmail.module.

References mfn_dmail_db_identity_select(), mfn_dmail_db_mbox_select(), and mfn_dmail_l().

Referenced by mfn_dmail_block_identities().

                                                  {
  global $user;
  $tlinks = new stdClass;
  if (isset($obj->identity_id)) {
    $identity = mfn_dmail_db_identity_select($obj->identity_id);
    $mbox = mfn_dmail_db_mbox_select($obj->id);
    $isdeletefolder = FALSE;
    if ($identity->movedel) {
      if (!$identity->toplevel) {
        $isdeletefolder = $mbox->name == "{$identity->inbox}{$identity->delimiter}{$identity->deletefolder}";
      }
      else {
        $isdeletefolder = $mbox->name == $identity->deletefolder;
      }
    }
    $empty = $isdeletefolder
           ? mfn_dmail_l(array(
            'url' => "user/{$user->uid}/email/{$identity->id}/mbox/{$obj->id}/empty",
            'title' => ' (Empty)',
            'description' => 'Remove all items from the deleted folder.',
            'image' => array(
              'file' => 'empty_trash.png',
              'type' => 'action',
            ),
          ))
           : NULL;
    $tlinks->link = theme_menu_item_link(
      array(
        'title' => $obj->name,
        'href' => 'user/' . $user->uid . '/email/' . $obj->identity_id . '/mbox/' . $obj->id,
      )
    ) . $empty;
    $tlinks->parent = $obj->parent;
    $tlinks->is_active_mbox = $obj->is_active_mbox;
    $tlinks->is_active_parent = $obj->is_active_parent;
    $tlinks->is_active_child = $obj->is_active_child;
  }
  else {
    $compose = mfn_dmail_l(array(
      'url' => "user/{$user->uid}/email/{$obj->id}/compose",
      'title' => ' (Compose)',
      'description' => 'Compose new mail to send to people.',
      'image' => array(
        'type' => 'action',
        'file' => 'compose.png',
      ),
    ));
    $tlinks->link = theme_menu_item_link(
      array(
        'title' => $obj->name,
        'href' => 'user/' . $user->uid . '/email/' . $obj->id . '/folders',
      )
    ) . $compose;
    $tlinks->parent = TRUE;
    $tlinks->is_active_mbox = FALSE;
    $tlinks->is_active_parent = TRUE;
    $tlinks->is_active_child = FALSE;
  }
  $tlinks->level = $obj->level;
  $links[] = $tlinks;
}
mfn_dmail_block_items ( &$  links)

HTML format links for parent/child/sibling views.

Note that we cannot wrap the following into mfn_dmail_ul_item which sounds natural but we end up loosing the proper ul /ul tag pairs causing the outcome to shift right too far.

Definition at line 809 of file dmail.module.

References mfn_dmail_li_item(), mfn_dmail_ul_item(), mfn_dmail_ul_item_close(), and mfn_dmail_ul_item_open().

Referenced by mfn_dmail_block_identities().

                                        {
  $tlink = NULL;
  static $last_obj = NULL;

  while ($obj = array_shift($links)) {
    if ($obj->parent) {
      if ($tlink) {
        array_unshift($links, $obj);
        $return = NULL;
        if ($last_obj->is_active_child) {
          $return = mfn_dmail_ul_item($tlink, $obj->level);
        }
        $return .= mfn_dmail_block_items($links);
      }
      else {
        $prefix = NULL;
        if ($obj->level < $last_obj->level) {
          $prefix = mfn_dmail_ul_item_close($obj->level);
        }
        $return = $prefix;
        if ($obj->is_active_mbox || $obj->is_active_parent || $obj->is_active_child) {
          $return .= mfn_dmail_ul_item_open() . mfn_dmail_li_item($obj);
        }
        $return .= mfn_dmail_block_items($links);
      }
      $last_obj = $obj;
      return $return;
    }
    else {
      $prefix = NULL;
      if ($obj->level < $last_obj->level) {
        $prefix .= mfn_dmail_ul_item_close($obj->level);
      }
      if ($obj->is_active_child) {
        $tlink .= $prefix . mfn_dmail_li_item($obj);
      }
      $last_obj = $obj;
    }
  }
  return mfn_dmail_ul_item($tlink);
}
mfn_dmail_block_trees ( obj,
&$  trees,
tree = NULL 
)

HTML format a groups of formatted items for the block.

Definition at line 731 of file dmail.module.

References mfn_dmail_block_item().

Referenced by mfn_dmail_block_identities().

                                                            {
  $treed = TRUE;
  if ($tree) {
    $tree = theme_menu_tree($tree);
    $treed = FALSE;
  }
  mfn_dmail_block_item($obj, $tree, $treed);
  $trees .= theme_menu_tree($tree);
}
mfn_dmail_check_string ( string,
encode_quotes = FALSE 
)

Encode html special characters of strings from the mail header.

We can't use check_plain because we need to leave the quote character " unencoded.

Parameters:
$string
  • The string to encode.
Returns:
  • The encoded string.

Definition at line 537 of file dmail.module.

Referenced by mfm_dmail_display_item(), and mfn_dmail_explode_addr().

                                                                 {
  $mode = $encode_quotes ? ENT_QUOTES : ENT_NOQUOTES;
  return htmlspecialchars($string, $mode, 'UTF-8');
}
mfn_dmail_datetime ( str)

Definition at line 362 of file dmail.module.

Referenced by mfn_dmail_db_message_header_add(), and mfn_dmail_db_message_header_update().

                                  {
  $utime = strtotime($str);
  $cnv = date('Y-m-d H:i:s', $utime);
  return $cnv;
}
mfn_dmail_debug ( file,
line,
function,
var,
data 
)

Add debug messages via watchdog.

Parameters:
$file
  • A string giving the file name usually the value of __FILE__.
$line
  • A numeric giving the line number in the file usually the value of __LINE__.
$function
  • A string giving the function name usually the value of __FUNCTION__.
$var
  • A string giving the name of the variable.
$data
  • Mixed data type of the data contained in the named variable.

Definition at line 335 of file dmail.module.

References _mfn_dmail_debug_data().

Referenced by mfn_dmail_get_mail(), and mfn_dmail_process_header().

                                                               {
  if (DMAIL_DEBUG) {
    watchdog('dmailDebug', "%svar:>%sdata<: %sfile, %dline, %sfunction, ", array('%sfile' => $file, '%dline' => $line, '%sfunction' => $function, '%svar' => $var, '%sdata' => _mfn_dmail_debug_data($data)));
  }
}
mfn_dmail_form_default ( field)

Get form default value.

Definition at line 1350 of file dmail.module.

References mfn_dmail_db_signature_select().

Referenced by mfm_dmail_identities_add(), and mfm_dmail_settings().

                                        {
  $cache = dcache_get('form default', DCACHE_DRUPAL);
  if ($cache && isset($cache[$field])) {
    return $cache[$field];
  }
  switch ($field) {
    case 'inbox':
    case 'default_inbox': {
      $cache[$field] = duvar_get('default_inbox', variable_get('dmail_default_inbox', DMAIL_DEFAULT_INBOX));
    } break;

    case 'delimiter':
    case 'default_delimiter': {
      $cache[$field] = duvar_get('default_delimiter', variable_get('dmail_default_delim', DMAIL_DEFAULT_DELIM));
    } break;

    case 'toplevel':
    case 'default_allow_toplevel_folders': {
      $cache[$field] = duvar_get('default_allow_toplevel_folders', variable_get('dmail_default_toplevel_folders', DMAIL_DEFAULT_TOPLEVEL_FOLDERS));
    } break;

    case 'sortdir':
    case 'default_items_sortdir': {
      $cache[$field] = duvar_get('default_items_sortdir', variable_get('dmail_default_items_sortdir', DMAIL_DEFAULT_ITEMS_SORTDIR));
    } break;

    case 'orderby':
    case 'default_items_orderby': {
      $cache[$field] = duvar_get('default_items_orderby', variable_get('dmail_default_items_orderby', DMAIL_DEFAULT_ITEMS_ORDERBY));
    } break;

    case 'check_mail_freq':
    case 'default_check_mail_freq': {
      $cache[$field] = duvar_get('default_check_mail_freq', variable_get('dmail_default_check_mail_freq', DMAIL_DEFAULT_CHECK_MAIL_FREQ));
    } break;

    case 'signature': {
      $tmp = duvar_get('default_signature_name', 0);
      if ($tmp) {
        $tmp = mfn_dmail_db_signature_select($tmp);
        if ($tmp === FALSE) {
          $tmp = 0;
        }
        else {
          $tmp = $tmp->id;
        }
      }
      $cache[$field] = $tmp;
      unset($tmp);
    } break;

    case 'items_per_page': {
      $cache[$field] = duvar_get('items_per_page', 10);
    } break;

    case 'body_char_wrap': {
      $cache[$field] = duvar_get('body_char_wrap', variable_get('dmail_default_body_char_wrap', DMAIL_DEFAULT_BODY_CHAR_WRAP));
    } break;

    case 'delete_folder':
    case 'default_delete_folder': {
      $cache[$field] = duvar_get('default_delete_folder', t('Trash'));
    } break;

    case 'move_deleted':
    case 'default_move_deleted': {
      $cache[$field] = duvar_get('default_move_deleted', variable_get('dmail_default_move_deleted', DMAIL_DEFAULT_MOVE_DELETED));
    } break;

    case 'draft_folder':
    case 'default_draft_folder': {
      $cache[$field] = duvar_get('default_draft_folder', t('Drafts'));
    } break;

    case 'sent_folder':
    case 'default_sent_folder': {
      $cache[$field] = duvar_get('default_sent_folder', t('Sent'));
    } break;

    case 'junk_folder':
    case 'default_junk_folder': {
      $cache[$field] = duvar_get('default_junk_folder', t('Junk'));
    } break;

    default: {
      throw new Exception(t('Unknown field: @field', array('@field' => $field)));
    }
  }
  dcache_set('form default', $cache, DCACHE_DRUPAL);
  return $cache[$field];
}
mfn_dmail_form_options ( field)

Get form options.

Definition at line 1269 of file dmail.module.

References mfn_dmail_db_signatures_select().

Referenced by mfm_dmail_identities_add(), and mfm_dmail_settings().

                                        {
  $cache = dcache_get('form options', DCACHE_DRUPAL);
  if ($cache && isset($cache[$field])) {
    return $cache[$field];
  }
  switch ($field) {
    case 'orderby':
    case 'default_items_orderby': {
      $cache[$field] = array(
        '##' => t('Message number'),
        'received' => t('Received'),
        'from' => t('From'),
        'subject' => t('Subject'),
      );
    } break;

    case 'sortdir':
    case 'default_items_sortdir': {
      $cache[$field] = array(
        'asc' => t('Ascending'),
        'desc' => t('Descending'),
      );
    } break;

    case 'check_mail_freq':
    case 'default_check_mail_freq': {
      $cache[$field] = array(
        1 => t('Every minute'),
        5 => t('Every 5 minutes'),
        10 => t('Every 10 minutes'),
        15 => t('Every 15 minutes'),
        30 => t('Every 30 minutes'),
        60 => t('Every hour'),
        120 => t('Every 2 hours'),
        240 => t('Every 4 hours'),
        360 => t('Every 6 hours'),
        480 => t('Every 8 hours'),
        720 => t('Every 12 hours'),
        1440 => t('Once a day'),
      );
    } break;

    case 'signature': {
      $cache[$field][0] = t('none');
      $signatures = mfn_dmail_db_signatures_select();
      foreach ($signatures as $signature) {
        $cache[$field][$signature->id] = $signature->name;
      }
    } break;

    case 'items_per_page': {
      $cache[$field] = array(
        5 => t('5 items'),
        10 => t('10 items'),
        15 => t('15 items'),
        25 => t('25 items'),
        50 => t('50 items'),
        100 => t('100 items'),
        150 => t('150 items'),
        200 => t('200 items'),
      );
    } break;

    case 'readonly':
    case 'default_readonly':
    case 'move_deleted':
    case 'default_move_deleted': {
      $cache[$field] = array('yes' => t('Yes'), 'no' => t('No'));
    } break;

    default: {
      throw new Exception(t('Unknown field: @field', array('@field' => $field)));
    }
  }
  dcache_set('form options', $cache, DCACHE_DRUPAL);
  return $cache[$field];
}
mfn_dmail_form_text ( type,
field 
)

Get a title or description.

Definition at line 1125 of file dmail.module.

Referenced by mfm_dmail_identities_add(), and mfm_dmail_settings().

                                            {
  $cache = dcache_get('form texts', DCACHE_DRUPAL);
  if ($type === 'desc') {
    $type = 'description';
  }
  if ($cache && isset($cache[$field][$type])) {
    return $cache[$field][$type];
  }
  $note = t('  Note this is a default value for the new identities and can be different for each identity.');
  switch ($field) {
    case 'default_inbox': {
      $cache[$field]['title'] = t('Default inbox');
      $cache[$field]['description'] = mfn_dmail_form_text('description', 'inbox') . $note;
    } break;
    case 'inbox': {
      $cache[$field]['title'] = t('Inbox');
      $cache[$field]['description'] = t('The default new mail delivery mailbox, usually INBOX.');
    } break;

    case 'default_check_mail_freq': {
      $cache[$field]['title'] = t('Default check mail frequency');
      $cache[$field]['description'] = mfn_dmail_form_text('description', 'check_mail_freq') . $node;
    } break;
    case 'check_mail_freq': {
      $cache[$field]['title'] = t('Check mail frequency');
      $cache[$field]['description'] =  t('How ofter should the identity be check for new mail?');
    } break;

    case 'default_delimiter': {
      $cache[$field]['title'] = t('Default mailbox delimiter');
      $cache[$field]['description'] = mfn_dmail_form_text('description', 'delimiter') . $note;
    } break;
    case 'delimiter': {
      $cache[$field]['title'] = t('Delimiter');
      $cache[$field]['description'] = t('The mailbox delimiter, usually a period (.) or a slash (/).');
    } break;

    case 'default_allow_toplevel_folders': {
      $cache[$field]['title'] = t('Default allow top level folders');
      $cache[$field]['description'] = mfn_dmail_form_text('description', 'toplevel') . $note;
    } break;
    case 'toplevel': {
      $cache[$field]['title'] = t('Top level folders');
      $cache[$field]['description'] = t('Allow folders to be created as a top level item.');
    } break;

    case 'default_items_orderby': {
      $cache[$field]['title'] = t('Default order by');
      $cache[$field]['description'] = mfn_dmail_form_text('description', 'orderby') . $note;
    } break;
    case 'orderby': {
      $cache[$field]['title'] = t('Order by');
      $cache[$field]['description'] = t('Which column do you wish the default display of items to order by?');
    } break;

    case 'default_items_sortdir': {
      $cache[$field]['title'] = t('Default sort direction');
      $cache[$field]['description'] = mfn_dmail_form_text('description', 'sortdir') . $note;
    } break;
    case 'sortdir': {
      $cache[$field]['title'] = t('Sort direction');
      $cache[$field]['description'] = t('Which direction do you wish the order by column to sort.');
    } break;

    case 'signature': {
      $cache[$field]['title'] = t('Signature');
      $cache[$field]['description'] = t('Which signature do you wish to use for replies, forwards and new mail for this identity?');
    } break;

    case 'items_per_page': {
      $cache[$field]['title'] = t('Items per page');
      $cache[$field]['description'] = t('How many items in a list to display per page? Note the larger the number the slower the response may become and the more memory the system will require.');
    } break;

    case 'body_char_wrap': {
      $cache[$field]['title'] = t('Body character wrap');
      $cache[$field]['description'] = t('How many characters do you wish to wrap the email body to?');
    } break;

    case 'default_delete_folder': {
      $cache[$field]['title'] = t('Default trash folder');
      $cache[$field]['description'] = mfn_dmail_form_text('description', 'delete_folder') . $note;
    } break;
    case 'delete_folder': {
      $cache[$field]['title'] = t('Trash folder');
      $cache[$field]['description'] = t('If you use a delete folder then name it here, otherwise leave it empty.');
    } break;

    case 'default_draft_folder': {
      $cache[$field]['title'] = t('Default draft folder');
      $cache[$field]['description'] = mfn_dmail_form_text('description', 'draft_folder') . $note;
    } break;
    case 'draft_folder': {
      $cache[$field]['title'] = t('Draft folder');
      $cache[$field]['description'] = t('If you use a draft folder then name it here, otherwise leave it empty.');
    } break;

    case 'default_move_deleted': {
      $cache[$field]['title'] = t('Default move deleted items to delete folder');
      $cache[$field]['description'] = mfn_dmail_form_text('description', 'move_deleted') . $note;
    } break;
    case 'move_deleted': {
      $cache[$field]['title'] = t('Move deleted items to delete folder');
      $cache[$field]['description'] = t('Should a deleted item be moved to the delete folder?');
    } break;

    case 'default_sent_folder': {
      $cache[$field]['title'] = t('Default sent folder');
      $cache[$field]['description'] = mfn_dmail_form_text('description', 'sent_folder') . $note;
    } break;
    case 'sent_folder': {
      $cache[$field]['title'] = t('Sent folder');
      $cache[$field]['description'] = t('If you use a sent folder then name it here, otherwise leave it empty.');
    } break;

    case 'default_junk_folder': {
      $cache[$field]['title'] = t('Default junk folder');
      $cache[$field]['description'] = mfn_dmail_form_text('description', 'junk_folder') . $note;
    } break;
    case 'junk_folder': {
      $cache[$field]['title'] = t('Junk folder');
      $cache[$field]['description'] = t('If you use a junk folder then name it here, otherwise leave it empty.');
    } break;

    case 'default_readonly': {
      $cache[$field]['title'] = t('Default read only access');
      $cache[$field]['description'] = mfn_dmail_form_text('description', 'readonly') . $desc;
    } break;
    case 'readonly': {
      $cache[$field]['title'] = t('Read only access');
      $cache[$field]['description'] = t('Should the service be accessed in read only mode?  Usually this is used for debugging.');
    } break;

    default: {
      throw new Exception(t('Unknown field: @field', array('@field' => $field)));
    }
  }
  dcache_set('form texts', $cache, DCACHE_DRUPAL);
  return $cache[$field][$type];
}
mfn_dmail_get_active_identity ( )

Get the active identity.

Definition at line 938 of file dmail.module.

Referenced by mfn_dmail_block_identities().

                                         {
  $cache = dcache_get(array('active'));
  return $cache['identity'];
}
mfn_dmail_is_active_mbox ( mbox)

Is this mbox the active mbox?

Definition at line 1087 of file dmail.module.

Referenced by mfn_dmail_block_identities().

                                         {
  $cache = dcache_get(array('active'));
  $active_mbox =& $cache['mbox'];
  return $mbox->name == $active_mbox->name;
}
mfn_dmail_is_active_mbox_child ( mbox)

Is this mbox a direct child of the active mbox?

Definition at line 1070 of file dmail.module.

Referenced by mfn_dmail_block_identities().

                                               {
  $cache = dcache_get(array('active'));
  if (!isset($cache['identity']) || !isset($cache['mbox'])) {
    return FALSE;
  }
  $active_identity =& $cache['identity'];
  $active_mbox =& $cache['mbox'];
  if (!($pos = strrpos($mbox->name, $active_identity->delimiter))) {
    $pos = strlen($mbox->name);
  }
  $mname = substr($mbox->name, 0, $pos);
  return in_array($mname, array_keys($active_mbox->folders));
}
mfn_dmail_is_active_mbox_parent ( mbox)

Is this mbox a parent to active mbox?

Definition at line 1053 of file dmail.module.

Referenced by mfn_dmail_block_identities().

                                                {
  $cache = dcache_get(array('active'));
  if (!isset($cache['mbox'])) {
    return FALSE;
  }
  $active_identity =& $cache['identity'];
  $active_mbox =& $cache['mbox'];
  if (!($pos = strrpos($active_mbox->name, $active_identity->delimiter))) {
    $pos = 0;
  }
  $t = explode($active_identity->delimiter, $mbox->name);
  return count($t) < $active_mbox->levels && in_array($mbox->name, array_keys($active_mbox->folders));
}
mfn_dmail_is_valid_service ( values)

Is the user defined service valid?

Parameters:
$values
  • An array of the user entered values defining the service for the identity.
Returns:
  • Boolean TRUE or FALSE.

Definition at line 299 of file dmail.module.

Referenced by mfm_dmail_identities_add_validate().

                                             {
  global $imap;
  $user =& $values['user'];
  $pass =& $values['pass'];
  $host =& $values['host'];
  $port =& $values['port'];
  $service =& $values['service'];
  $inbox =& $values['inbox'];
  $delim =& $values['delim'];
  $encrypt =& $values['encrypt'];
  $validate =& $values['validate_cert'];
  $readonly =& $values['readonly'];
  $imap = new IMAP($user, $pass, $host, $port, $service, $delim, $encrypt, $validate, $readonly);
  $open = $imap->open();
  return is_resource($open);
}
mfn_dmail_l ( link,
title = NULL,
desc = NULL,
attributes = array(),
options = array(),
image = NULL 
)

Create html links allowing for easier application of description on mouseover than the Drupal l function.

NOTE: Do not use t() on the title or description as this function will do that for you.

Parameters:
$link
  • The URL address, relative or absolute.
  • Or an associative array of all parameter elements.
$title
  • The title or text to give to the URL link.
  • Optionally required, if $link is an array the title parameter can be associatively specified in it.
$desc
  • The mouseover description of the link.
  • Optional, may be specified in the associative array give to $link.
$attributes
  • An array of additional attributes to give the link.
  • Optional, may be specified in the associative array give to $link.
$options
  • An array of additional options to give the link.
  • Optional, may be specified in the associative array give to $link.
$image
  • The name of an image file in the images directory.
  • Or an associative array of 'type' and 'file', if type is given it is used to construct the path to the file as a subdirectory of the images directory.
  • Optional, may be specified in the associative array give to $link.
Returns:
  • The html formatted link.

Definition at line 427 of file dmail.module.

Referenced by mfm_dmail_display_folders(), mfm_dmail_display_headers(), mfm_dmail_identities(), mfm_dmail_signatures(), mfn_dmail_block_identities(), mfn_dmail_block_item(), mfn_dmail_block_item_link(), mfn_dmail_format_attachments(), mfn_dmail_options_addr(), mfn_dmail_transform_addr(), and tryit().

                                                                                                                   {
  global $user;
  if (is_array($link)) {
    $args = $link;
    $link = ($args['href'] ? $args['href'] : $args['url']);
    $title =& $args['title'];
    $desc =& $args['description'];
    $attributes =& $args['attributes'];
    $options =& $args['options'];
    $image =& $args['image'];
  }
  if ($desc && empty($attributes['title'])) {
    if (is_array($desc)) {
      $data = $desc['data'];
      $desc = $desc['description'];
      $attributes['title'] = t($desc, $data);
    }
    else {
      $attributes['title'] = t($desc);
    }
  }
  if (empty($options['attributes'])) {
    $options['attributes'] = $attributes;
  }
  if ($image) {
    if (is_array($image)) {
      $itype =& $image['type'];
      $ifile =& $image['file'];
      $ipos =& $image['position'];
      switch ($itype) {
        case 'action': {
          $image = "actions/{$ifile}";
        } break;
        case 'folder': {
          $image = "folders/{$ifile}";
        } break;
        case 'mime': {
          $image = "mimetypes/{$ifile}";
        } break;
        default: {
          $image = ($itype) ? "{$itype}/{$ifile}" : $ifile;
        }
      }
    }
    $path = dirname(__FILE__) . "/images/{$image}";
    if (file_exists($path)) {
      list($width, $height) = getimagesize($path);
      $alt = $title;
      $title = $attributes['title'];
      $path = drupal_get_path('module', 'dmail') . "/images/{$image}";
      $attributes['width'] = $width;
      $attributes['height'] = $height;
      if ($ipos) {
        switch ($ipos) {
          case 'prefix': {
            $title = theme_image($path, $alt, $title, $attributes, FALSE) . ' ' . $alt;
          } break;
        }
      }
      else {
        $title = ' ' . theme_image($path, $alt, $title, $attributes, FALSE);
      }
      $options['html'] = TRUE;
    }
  }
  return l(t($title), $link, $options);
}
mfn_dmail_li_item ( obj)

HTML format the li tag for the link.

Definition at line 859 of file dmail.module.

Referenced by mfn_dmail_block_items().

                                 {
  if ($obj->parent || $obj->is_active_mbox || $obj->is_active_parent || $obj->is_active_child) {
    $class = $obj->parent ? $obj->is_active_mbox || $obj->is_active_parent ? '"expanded"' : '"collapsed"' : '"leaf"';
    return "<li class=$class>{$obj->link}</li>";
  }
}
mfn_dmail_list_headers ( which,
form 
)

Headers for various form lists.

Todo:
Good idea?

Definition at line 980 of file dmail.module.

Referenced by theme_mfm_dmail_identities(), and theme_mfm_dmail_signatures().

                                               {
  switch ($which) {
    case 'dmail_identities': {
      $return[] = theme('table_select_header_cell');
      foreach ($form['dmail']['identity']['list']['header']['#dmail_data'] as $h) {
        $return[] = $h;
      }
      $return[] = t('Operations');
    } break;
    case 'dmail_signatures': {
      $return[] = theme('table_select_header_cell');
      foreach ($form['dmail']['signature']['list']['header']['#dmail_data'] as $h) {
        $return[] = $h;
      }
      $return[] = t('Operations');
    } break;
  }
  return $return;
}
mfn_dmail_msgid ( header)

Get a unique id to identify each individual message.

Parameters:
$header
  • The mail header object.
Returns:
  • The unique id string.

Definition at line 521 of file dmail.module.

Referenced by mfn_dmail_process_header().

                                  {
  return md5($header->from) . md5($header->message_id);
}
mfn_dmail_natksort ( array &$  array)

Sort an array based on the natural sort of the associative key values.

Parameters:
$array
  • An associative array.
Returns:
  • An array sorted by natural sort of the associative keys.

Definition at line 1009 of file dmail.module.

Referenced by mfn_dmail_block_identities().

                                           {
  $keys = array_keys($array);
  $ret = natsort($keys);
  if ($ret !== FALSE) {
    $newarray = array();
    foreach ($keys as $key) {
      $newarray[$key] = $array[$key];
    }
    $array = $newarray;
  }
  return $ret;
}
mfn_dmail_orderby ( )

The mail list is ordered by?

Definition at line 1096 of file dmail.module.

Referenced by mfm_dmail_display_headers(), mfn_dmail_callback_director(), and mfn_dmail_options_addr().

                             {
  $sort =& $_GET['sort'];
  $order =& $_GET['order'];
  $page =& $_GET['page'];
  $query = NULL;
  $amp = NULL;
  if ($sort) {
    $query .= "sort={$sort}";
    $amp = '&';
  }
  else {
    $sort = 'desc';
    $order = 'Received';
    return mfn_dmail_orderby();
  }
  if ($order) {
    $query .= "{$amp}order={$order}";
    $amp = '&';
  }
  if ($page) {
    $query .= "{$amp}page={$page}";
    $amp = '&';
  }
  return array('query' => $query);
}
mfn_dmail_production_mode ( )

Are we in production mode?

Returns:
  • Boolean TRUE or FALSE.

Definition at line 931 of file dmail.module.

Referenced by mfn_dmail_spaces().

                                     {
  return variable_get('dmail_production_mode', FALSE);
}
mfn_dmail_security_check ( )

Ensure that only the authenticated user can access her data.

Note: Even the administrators cannot be allowed to view the individual user mail data including UID 1.

Definition at line 966 of file dmail.module.

Referenced by mfm_dmail_attachment(), mfm_dmail_copy_item(), mfm_dmail_delete_item(), mfm_dmail_display_folders(), mfm_dmail_display_headers(), mfm_dmail_display_item(), mfm_dmail_flag_item(), mfm_dmail_forward_item(), mfm_dmail_friendly_addr(), mfm_dmail_identities(), mfm_dmail_identities_add(), mfm_dmail_identities_edit(), mfm_dmail_junk_item(), mfm_dmail_move_item(), mfm_dmail_reply_item(), mfm_dmail_replyall_item(), mfm_dmail_replylist_item(), mfm_dmail_replyto_item(), mfm_dmail_seen_item(), mfm_dmail_send_item(), mfm_dmail_settings(), mfm_dmail_signatures(), mfm_dmail_signatures_add(), mfm_dmail_undelete_item(), mfm_dmail_unflag_item(), mfm_dmail_unfriendly_addr(), mfm_dmail_unjunk_item(), mfm_dmail_unseen_item(), mfn_dmail_get_newmail(), and mfn_dmail_refresh().

                                    {
  global $user;
  if ($user->uid !== arg(1)) {
    watchdog('dmail security', t('Invalid access to another users dmail links.'));
    drupal_set_message('Only the authenticated user may access his email form.', 'error');
    drupal_goto('/');
  }
}
mfn_dmail_set_active_identity ( identity)

Set the active identity.

Definition at line 946 of file dmail.module.

Referenced by mfm_dmail_display_folders(), mfm_dmail_display_headers(), mfm_dmail_display_item(), and mfm_dmail_identities().

                                                  {
  $cache = dcache_get(array('active'));
  $active_identity =& $cache['identity'];
  $active_identity = $identity;
  dcache_set(array('active'), $cache);
}
mfn_dmail_spaces ( spccnt)

Format indentation in for the browser page source view.

Definition at line 915 of file dmail.module.

References mfn_dmail_production_mode().

Referenced by mfn_dmail_ul_item_close(), and mfn_dmail_ul_item_open().

                                   {
  $spaces = NULL;
  if (!mfn_dmail_production_mode()) {
    for ($i = 0; $i < $spccnt; $i++) {
      $spaces .= ' ';
    }
  }
  return $spaces;
}
mfn_dmail_subject_re ( subject)

Does the string match a reply specification?

Parameters:
$subject
Returns:
  • Object of subject and boolean re.

Definition at line 1450 of file dmail.module.

Referenced by mfn_dmail_db_message_header_add(), and mfn_dmail_db_message_header_update().

                                        {
  $obj = new stdClass;
  list($re, $subj) = explode(':', trim($subject));
  if (strtolower($re) === 're') {
    $obj->subject = substr($subject, strlen($re) + 1);
    $obj->re = TRUE;
  }
  else {
    $obj->subject = $subject;
    $obj->re = FALSE;
  }
  return $obj;
}
mfn_dmail_tablesort_sql ( header,
before = '' 
)

Replication of tablesort_sql for use with field names that are reserved by the DB engine.

The difference between this function and Drupal's core function is the `` around the field name.

Definition at line 375 of file dmail.module.

                                                        {
  $ts = tablesort_init($header);
  if ($ts['sql']) {
    // Based on code from db_escape_table(), but this can also contain a dot.
    $field = preg_replace('/[^A-Za-z0-9_.]+/', '', $ts['sql']);

    // Sort order can only be ASC or DESC.
    $sort = drupal_strtoupper($ts['sort']);
    $sort = in_array($sort, array('ASC', 'DESC')) ? $sort : '';

    return " ORDER BY $before `$field` $sort";
  }
}
mfn_dmail_theme_block_init ( )
Todo:
Do I need this?

Definition at line 956 of file dmail.module.

Referenced by dmail_init().

                                      {
  // Using list_theme(), ensure we've enabled for each theme listed.
}
mfn_dmail_ul_item ( links,
tolevel = 0 
)

HTML format the ul tag for the links.

Definition at line 869 of file dmail.module.

References mfn_dmail_ul_item_close(), and mfn_dmail_ul_item_open().

Referenced by mfn_dmail_block_items().

                                                 {
  return mfn_dmail_ul_item_open() . $links . mfn_dmail_ul_item_close($tolevel);
}
mfn_dmail_ul_item_close ( tolevel = 0)

HTML format the close /ul tag.

Definition at line 893 of file dmail.module.

References mfn_dmail_spaces().

Referenced by mfn_dmail_block_items(), and mfn_dmail_ul_item().

                                               {
  global $dmail_obj;
  if (empty($dmail_obj)) {
    $dmail_obj = new stdClass;
  }
  if (empty($dmail_obj->ul)) {
    $dmail_obj->ul = new stdClass;
    $dmail_obj->ul->level = 0;
  }
  $ret .= NULL;
  $endcnt = $dmail_obj->ul->level - $tolevel - 1;
  for ($i = 0; $i <= $endcnt; $i++) {
    $spaces = mfn_dmail_spaces($dmail_obj->ul->level - 1);
    $ret .=  DMAIL_NL . $spaces . "</ul>";
    $dmail_obj->ul->level--;
  }
  return $ret;
}
mfn_dmail_ul_item_open ( )

HTML format the open ul tag.

Definition at line 876 of file dmail.module.

References mfn_dmail_spaces().

Referenced by mfn_dmail_block_items(), and mfn_dmail_ul_item().

                                  {
  global $dmail_obj;
  if (empty($dmail_obj)) {
    $dmail_obj = new stdClass;
  }
  if (empty($dmail_obj->ul)) {
    $dmail_obj->ul = new stdClass;
    $dmail_obj->ul->level = 0;
  }
  $spaces = mfn_dmail_spaces($dmail_obj->ul->level - 1);
  $dmail_obj->ul->level++;
  return DMAIL_NL . $spaces . '<ul class="menu">';
}
All Data Structures Files Functions Variables Enumerations