Changeset 7596968 in github


Ignore:
Timestamp:
Aug 10, 2009 5:32:44 PM (4 years ago)
Author:
thomascube <thomas@…>
Branches:
master, HEAD, courier-fix, dev-browser-capabilities, pdo, release-0.6, release-0.7, release-0.8
Children:
db52218
Parents:
996f0b4
Message:

Added 'message_compose' hook

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • CHANGELOG

    r2a34eb9 r7596968  
    22=========================== 
    33 
     4- Added 'message_compose' hook 
    45- Added 'imap_connect' hook (#1485956) 
    56- Fix vcard_attachments plugin (#1486035) 
  • program/include/main.inc

    r1fcad15 r7596968  
    546546 */ 
    547547function get_input_value($fname, $source, $allow_html=FALSE, $charset=NULL) 
    548   { 
     548{ 
    549549  global $OUTPUT; 
    550550  $value = NULL; 
     
    583583  else 
    584584    return $value; 
    585   } 
     585} 
     586 
     587/** 
     588 * Convert array of request parameters (prefixed with _) 
     589 * to a regular array with non-prefixed keys. 
     590 * 
     591 * @param  int   Source to get value from (GPC) 
     592 * @return array Hash array with all request parameters 
     593 */ 
     594function request2param($mode = RCUBE_INPUT_GPC) 
     595{ 
     596  $out = array(); 
     597  $src = $mode == RCUBE_INPUT_GET ? $_GET : ($mode == RCUBE_INPUT_POST ? $_POST : $_REQUEST); 
     598  foreach ($src as $key => $value) { 
     599    $fname = $key[0] == '_' ? substr($key, 1) : $key; 
     600    $out[$fname] = get_input_value($key, $mode); 
     601  } 
     602   
     603  return $out; 
     604} 
    586605 
    587606/** 
     
    959978  $args = func_get_args(); 
    960979 
    961   if (class_exists('rcmail', false)) 
    962     rcmail::get_instance()->plugins->exec_hook('console', $args); 
     980  if (class_exists('rcmail', false)) { 
     981    $rcmail = rcmail::get_instance(); 
     982    if (is_object($rcmail->plugins)) 
     983      $rcmail->plugins->exec_hook('console', $args); 
     984  } 
    963985 
    964986  $msg = array(); 
  • program/steps/mail/compose.inc

    ree258ce r7596968  
    3939  $_SESSION['compose'] = array( 
    4040    'id' => uniqid(rand()), 
    41     'param' => array_map('strip_tags', $_GET), 
     41    'param' => request2param(RCUBE_INPUT_GET), 
    4242    'mailbox' => $IMAP->get_mailbox_name(), 
    4343  ); 
    4444   
    4545  // process values like "mailto:foo@bar.com?subject=new+message&cc=another" 
    46   if ($_SESSION['compose']['param']['_to']) { 
    47     $mailto = explode('?', $_SESSION['compose']['param']['_to']); 
     46  if ($_SESSION['compose']['param']['to']) { 
     47    $mailto = explode('?', $_SESSION['compose']['param']['to']); 
    4848    if (count($mailto) > 1) { 
    49       $_SESSION['compose']['param']['_to'] = $mailto[0]; 
     49      $_SESSION['compose']['param']['to'] = $mailto[0]; 
    5050      parse_str($mailto[1], $query); 
    5151      foreach ($query as $f => $val) 
    52         $_SESSION['compose']['param']["_$f"] = $val; 
    53     } 
    54   } 
     52        $_SESSION['compose']['param'][$f] = $val; 
     53    } 
     54  } 
     55   
     56  // pipe compose parameters thru plugins 
     57  $plugin = $RCMAIL->plugins->exec_hook('message_compose', $_SESSION['compose']); 
     58  $_SESSION['compose']['param'] = $plugin['param']; 
    5559 
    5660  // redirect to a unique URL with all parameters stored in session 
     
    7276 
    7377// get reference message and set compose mode 
    74 if ($msg_uid = $_SESSION['compose']['param']['_reply_uid']) 
     78if ($msg_uid = $_SESSION['compose']['param']['reply_uid']) 
    7579  $compose_mode = RCUBE_COMPOSE_REPLY; 
    76 else if ($msg_uid = $_SESSION['compose']['param']['_forward_uid']) 
     80else if ($msg_uid = $_SESSION['compose']['param']['forward_uid']) 
    7781  $compose_mode = RCUBE_COMPOSE_FORWARD; 
    78 else if ($msg_uid = $_SESSION['compose']['param']['_uid']) 
     82else if ($msg_uid = $_SESSION['compose']['param']['uid']) 
    7983  $compose_mode = RCUBE_COMPOSE_EDIT; 
    80 else if ($msg_uid = $_SESSION['compose']['param']['_draft_uid']) { 
     84else if ($msg_uid = $_SESSION['compose']['param']['draft_uid']) { 
    8185  $RCMAIL->imap->set_mailbox($CONFIG['drafts_mbox']); 
    8286  $compose_mode = RCUBE_COMPOSE_DRAFT; 
     
    99103    $_SESSION['compose']['references']  = trim($MESSAGE->headers->references . " " . $MESSAGE->headers->messageID); 
    100104 
    101     if (!empty($_SESSION['compose']['param']['_all'])) 
     105    if (!empty($_SESSION['compose']['param']['all'])) 
    102106      $MESSAGE->reply_all = 1; 
    103107  } 
     
    139143    case 'to': 
    140144      $fname = '_to'; 
    141       $header = 'to'; 
     145      $header = $param = 'to'; 
    142146       
    143147      // we have a set of recipients stored is session 
    144       if (($mailto_id = $_SESSION['compose']['param']['_mailto']) && $_SESSION['mailto'][$mailto_id]) 
     148      if (($mailto_id = $_SESSION['compose']['param']['mailto']) && $_SESSION['mailto'][$mailto_id]) 
    145149        $fvalue = urldecode($_SESSION['mailto'][$mailto_id]); 
    146150       
     
    149153      { 
    150154        $fname = '_cc'; 
    151         $header = 'cc'; 
     155        $header = $param = 'cc'; 
    152156      } 
    153157    case 'bcc': 
     
    155159      { 
    156160        $fname = '_bcc'; 
    157         $header = 'bcc'; 
     161        $header = $param = 'bcc'; 
    158162      } 
    159163         
     
    165169    case 'reply-to': 
    166170      $fname = '_replyto'; 
     171      $param = 'replyto'; 
    167172      $allow_attrib = array('id', 'class', 'style', 'size', 'tabindex'); 
    168173      $field_type = 'html_inputfield'; 
     
    170175  } 
    171176  
    172   if ($fname && !empty($_POST[$fname])) 
     177  if ($fname && !empty($_POST[$fname])) { 
    173178    $fvalue = get_input_value($fname, RCUBE_INPUT_POST, TRUE); 
    174   else if ($fname && !$fvalue && !empty($_SESSION['compose']['param'][$fname])) 
    175     $fvalue = $_SESSION['compose']['param'][$fname]; 
    176   else if ($header && $compose_mode == RCUBE_COMPOSE_REPLY) 
    177   { 
     179  } 
     180  else if ($fname && !$fvalue && !empty($_SESSION['compose']['param'][$param])) { 
     181    $fvalue = $_SESSION['compose']['param'][$param]; 
     182  } 
     183  else if ($header && $compose_mode == RCUBE_COMPOSE_REPLY) { 
    178184    // get recipent address(es) out of the message headers 
    179185    if ($header=='to' && !empty($MESSAGE->headers->replyto)) 
     
    299305 
    300306      // add signature to array 
    301       if (!empty($sql_arr['signature']) && empty($_SESSION['compose']['param']['_nosig'])) 
     307      if (!empty($sql_arr['signature']) && empty($_SESSION['compose']['param']['nosig'])) 
    302308      { 
    303309        $a_signatures[$identity_id]['text'] = $sql_arr['signature']; 
     
    369375  { 
    370376    $body = get_input_value('_message', RCUBE_INPUT_POST, true); 
     377  } 
     378  else if ($_SESSION['compose']['param']['body']) 
     379  { 
     380    $body = $_SESSION['compose']['param']['body']; 
     381    $isHtml = false; 
    371382  } 
    372383  else if ($compose_mode) 
     
    393404      $body = rcmail_create_draft_body($body, $isHtml); 
    394405  } 
    395   else if (!empty($_SESSION['compose']['param']['_body'])) 
    396   { 
    397     $body = $_SESSION['compose']['param']['_body']; 
     406  else if (!empty($_SESSION['compose']['param']['body'])) 
     407  { 
     408    $body = $_SESSION['compose']['param']['body']; 
    398409  } 
    399410 
     
    720731    $subject = $MESSAGE->subject; 
    721732  } 
    722   else if (!empty($_SESSION['compose']['param']['_subject'])) { 
    723     $subject = $_SESSION['compose']['param']['_subject']; 
     733  else if (!empty($_SESSION['compose']['param']['subject'])) { 
     734    $subject = $_SESSION['compose']['param']['subject']; 
    724735  } 
    725736   
Note: See TracChangeset for help on using the changeset viewer.