function mailhandler_mailhandler_authenticate in Mailhandler 7
Same name and namespace in other branches
- 6 mailhandler.retrieve.inc \mailhandler_mailhandler_authenticate()
 
Defines and executes message authentication methods
Message authentication methods can be defined using mailhandler_authenticate_info() which can take one of two $op's:
- info, which is used to define an authentication plugin
 - execute, which is used to execute an authentication plugin
 
Parameters
$op: String info or execute
$name: String identifier for authentication method
$args: Array of arguments to pass in to the authentication method callback
2 calls to mailhandler_mailhandler_authenticate()
- mailhandler_add_edit_mailbox in ./
mailhandler.admin.inc  - Return a form for editing or creating an individual mailbox.
 - mailhandler_node_process_message in ./
mailhandler.module  
File
- ./
mailhandler.retrieve.inc, line 241  
Code
function mailhandler_mailhandler_authenticate($op, $name = NULL, $args = array()) {
  $methods = array();
  switch ($op) {
    case 'info':
      foreach (module_list() as $module) {
        if (module_hook($module, 'mailhandler_authenticate_info')) {
          $function = $module . '_mailhandler_authenticate_info';
          $methods[] = $function();
        }
      }
      return $methods;
    case 'execute':
      foreach (module_list() as $module) {
        if (module_hook($module, 'mailhandler_authenticate_info')) {
          $function = $module . '_mailhandler_authenticate_info';
          $methods = $function('info');
          // TODO - May not be found, like if providing module is disabled.  Must fail gracefully
          foreach ($methods as $key => $method) {
            if ($name == $key) {
              if ($method['extension'] && $method['basename']) {
                module_load_include($method['extension'], $method['module'], $method['basename']);
                return call_user_func_array($method['callback'], $args);
              }
              else {
                drupal_load('module', $method['module']);
                return call_user_func_array($method['callback'], $args);
              }
              break 2;
            }
          }
        }
      }
      // Return FALSE if callback is not found.
      return FALSE;
      break;
  }
}