home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 April / CMCD0404.ISO / Software / Freeware / Programare / groupoffice-com-2.01 / modules / email / compose.inc < prev    next >
Encoding:
Text File  |  2004-03-08  |  23.4 KB  |  782 lines

  1. <?php
  2. /*
  3. Copyright Intermesh 2003
  4. Author: Merijn Schering <mschering@intermesh.nl>
  5. Version: 1.0 Release date: 08 July 2003
  6.  
  7. This program is free software; you can redistribute it and/or modify it
  8. under the terms of the GNU General Public License as published by the
  9. Free Software Foundation; either version 2 of the License, or (at your
  10. option) any later version.
  11. */
  12.  
  13. //reset attachments array in case user aborted a message or changed format
  14. if ($_SERVER['REQUEST_METHOD'] != "POST" || $sendaction=='load_template')
  15. {
  16.     if (!isset($_REQUEST['email_file']))
  17.     {
  18.         unset($attach_array);
  19.         unset($num_attach);
  20.         unset($_SESSION['attach_array']);
  21.         unset($_SESSION['num_attach']);
  22.         unset($_SESSION['url_replacements']);
  23.     }
  24. }
  25.  
  26. //get users email accounts to determine from addresses
  27. $count = $email->get_accounts($GO_SECURITY->user_id);
  28. while ($email->next_record())
  29. {
  30.     if ($mail_from == 0)
  31.     {
  32.         $mail_from = $email->f('id');
  33.     }
  34.     $addresses[] = $email->f("email");
  35.     $names[] = $email->f("email")." (".$email->f("name").")";
  36.     $ids[] = $email->f("id");
  37. }
  38.  
  39. //check for the contacts module
  40. $ab_module = $GO_MODULES->get_module('addressbook');
  41. if (!$ab_module || !($GO_SECURITY->has_permission($GO_SECURITY->user_id, $ab_module['acl_read']) || $GO_SECURITY->has_permission($GO_SECURITY->user_id, $ab_module['acl_write'])))
  42. {
  43.     $ab_module = false;
  44. }else
  45. {
  46.     require_once($GO_CONFIG->class_path.'addressbook.class.inc');
  47.     $ab = new addressbook();
  48.     $ab->enable_contact_selector();
  49. }
  50.  
  51. if ($mail_from > 0)
  52. {
  53.     $account = $email->get_account($mail_from);
  54.  
  55.     if ($content_type == 'text/HTML' && $account['signature'] != '')
  56.     {
  57.         $signature = '<br />'.text_to_html($account['signature']).'<br /><br />';
  58.     }else
  59.     {
  60.         $signature = "\r\n".$account['signature']."\r\n\r\n";
  61.     }
  62. }else
  63. {
  64.     $signature = '';
  65. }
  66.  
  67.  
  68. //if a uid is given then the user is replying or forwarding
  69. if ($uid > 0)
  70. {
  71.     //get the original message
  72.     require($GO_CONFIG->class_path."imap.class.inc");
  73.     $mail = new imap();
  74.  
  75.     $account = $email->get_account($_REQUEST['account_id']);
  76.  
  77.     if ($account && $mail->open($account['host'], $account['type'],$account['port'],$account['username'],$GO_CRYPTO->decrypt($account['password']), $_REQUEST['mailbox']))
  78.     {
  79.         $preferred_type = ($content_type=='text/HTML') ? 'html' : 'text';
  80.         $content = $mail->get_message($uid,"","",$preferred_type);
  81.         $parts = array_reverse($mail->f("parts"));
  82.  
  83.         //fill in the header fields
  84.         $subject = isset($content['subject']) ? $content['subject'] : $ml_no_subject;
  85.         switch($_REQUEST['action'])
  86.         {
  87.             case "reply":
  88.                 $mail_to = $content["sender"];
  89.                 $mail_subject = "Re: ".$subject;
  90.             break;
  91.  
  92.             case "reply_all":
  93.                 $mail_to = $content["sender"];
  94.                 $mail_subject = "Re: ".$subject;
  95.  
  96.                 //add all recievers from this email
  97.                 for ($i=0;$i<sizeof($content["to"]);$i++)
  98.                 {
  99.                     $lt = strpos($content["to"][$i], "<") + 4;
  100.                     $gt = strpos($content["to"][$i], ">");
  101.  
  102.                     $length = $gt-$lt;
  103.  
  104.                     $address = trim(substr($content["to"][$i],$lt,$length));
  105.  
  106.                     if ($address != "" && !in_array($address,$addresses))
  107.                     {
  108.                         $mail_to .= ",".$address;
  109.                     }
  110.                 }
  111.  
  112.             break;
  113.  
  114.             case "forward":
  115.                 //reattach attachments
  116.                 $mail_subject = "Fwd: ".$subject;
  117.  
  118.                 for ($i=0;$i<count($parts);$i++)
  119.                 {
  120.                     if (eregi("attachment", $parts[$i]["disposition"]) && !eregi("message/RFC822", $parts[$i]["mime"]))
  121.                     {
  122.                         $file = $mail->view_part($uid, $parts[$i]["number"], $parts[$i]["transfer"], $parts[$i]["mime"]);
  123.  
  124.                         $name = $parts[$i]['name'] != '' ? $parts[$i]['name'] : 'attach_'.$i;
  125.  
  126.                         $tmp_file = $GO_CONFIG->tmpdir.md5(uniqid(time()));
  127.                         $fp = fopen($tmp_file,"wb");
  128.                         fwrite ($fp,$file);
  129.                         fclose($fp);
  130.                         $email->register_attachment($tmp_file, $parts[$i]["name"], $parts[$i]["size"], $parts[$i]["mime"], 'attachment', $parts[$i]["id"]);
  131.                     }
  132.                 }
  133.  
  134.             break;
  135.         }
  136.  
  137.         //reatach inline attachements
  138.         for ($i=0;$i<count($parts);$i++)
  139.         {
  140.             if ($parts[$i]["id"] != '')// && eregi("inline", $parts[$i]["disposition"]))
  141.             {
  142.                 $file = $mail->view_part($uid, $parts[$i]["number"], $parts[$i]["transfer"], $parts[$i]["mime"]);
  143.  
  144.                 $tmp_file = $GO_CONFIG->tmpdir.md5(uniqid(time()));
  145.  
  146.                 $fp = fopen($tmp_file,"wb");
  147.                 fwrite ($fp,$file);
  148.                 fclose($fp);
  149.  
  150.                 if (strpos($parts[$i]["id"],'>'))
  151.                 {
  152.                     $parts[$i]["id"] = substr($parts[$i]["id"], 1,strlen($parts[$i]["id"])-2);
  153.                 }
  154.                 $email->register_attachment($tmp_file, $parts[$i]["name"], $parts[$i]["size"], $parts[$i]["mime"], 'inline', $parts[$i]["id"]);
  155.                 //Content-ID's that need to be replaced with urls when message is send
  156.  
  157.                 //replace inline images identified by a content id with the url to display the part by Group-Office
  158.                 $url_replacement['id'] = $parts[$i]["id"];
  159.                 $url_replacement['url'] = "attachment.php?account_id=".$_REQUEST['account_id']."&mailbox=".$_REQUEST['mailbox']."&uid=".$uid."&part=".$parts[$i]["number"]."&transfer=".$parts[$i]["transfer"]."&mime=".$parts[$i]["mime"]."&filename=".urlencode($parts[$i]["name"]);
  160.                 $_SESSION['url_replacements'][] = $url_replacement;
  161.             }
  162.         }
  163.  
  164.         $html_message_count = 0;
  165.         for ($i=0;$i<count($parts);$i++)
  166.         {
  167.             if($content_type=='text/HTML')
  168.             {
  169.                 $mime = strtolower($parts[$i]["mime"]);
  170.  
  171.                 if (!eregi("attachment", $parts[$i]["disposition"]))
  172.                 {
  173.                     switch ($mime)
  174.                     {
  175.                         case 'text/plain':
  176.                             $html_part = text_to_html($mail->view_part($uid, $parts[$i]["number"], $parts[$i]["transfer"]));
  177.                             $mail_body .= addslashes($html_part);
  178.                         break;
  179.  
  180.                         case 'text/html':
  181.                             $html_part = get_html_body($mail->view_part($uid, $parts[$i]["number"], $parts[$i]["transfer"]));
  182.                             $mail_body .= addslashes($html_part);
  183.                         break;
  184.  
  185.                         case 'text/enriched':
  186.                             $html_part = enriched_to_html($mail->view_part($uid, $parts[$i]["number"], $parts[$i]["transfer"]));
  187.                             $mail_body .= addslashes($html_part);
  188.                         break;
  189.                     }
  190.                 }
  191.             }else
  192.             {
  193.                 if (strtolower($parts[$i]["mime"]) == "text/plain" && !eregi("ATTACHMENT", $parts[$i]["disposition"]))
  194.                 {
  195.                     $text_part = $mail->view_part($uid, $parts[$i]["number"], $parts[$i]["transfer"]);
  196.                     if ($_REQUEST['action'] == 'forward')
  197.                     {
  198.                         $mail_body .= $text_part;
  199.                     }else
  200.                     {
  201.                         $mail_body .= quote($text_part);
  202.                     }
  203.                 }
  204.  
  205.                 //add html messages as an attachment since we don't have an html editor to display it coreect yet
  206.                 if (strtolower($parts[$i]["mime"]) == "text/html" && !eregi("ATTACHMENT", $parts[$i]["disposition"]))
  207.                 {
  208.                     if ($parts[$i]["name"] == '' && $parts[$i]["mime"] == "text/HTML")
  209.                     {
  210.                         if ($html_message_count == 0)
  211.                             $parts[$i]["name"] = $content["sender"].".html";
  212.                         else
  213.                             $parts[$i]["name"] = $content["sender"]."(".$html_message_count.").html";
  214.  
  215.                         $html_message_count++;
  216.                     }
  217.  
  218.                     $file = $mail->view_part($uid, $parts[$i]["number"], $parts[$i]["transfer"], $parts[$i]["mime"]);
  219.  
  220.                     $tmp_file = $GO_CONFIG->tmpdir.md5(uniqid(time()));
  221.  
  222.                     $fp = fopen($tmp_file,"w");
  223.                     fwrite ($fp,$file);
  224.                     fclose($fp);
  225.  
  226.                     $email->register_attachment($tmp_file, $parts[$i]["name"], $parts[$i]["size"], $parts[$i]["mime"]);
  227.                 }
  228.             }
  229.         }
  230.  
  231.         if ($content_type=='text/HTML')
  232.         {
  233.             if ($mail_body != '')
  234.             {
  235.                 //replace inline images with the url to display the part by Group-Office
  236.                 if (isset($_SESSION['url_replacements']))
  237.                 {
  238.                     for ($i=0;$i<count($_SESSION['url_replacements']);$i++)
  239.                     {
  240.                         $mail_body = str_replace('cid:'.$_SESSION['url_replacements'][$i]['id'], $_SESSION['url_replacements'][$i]['url'], $mail_body);
  241.                     }
  242.                 }
  243.             }
  244.             $header_om  = '<font face="verdana" size="2">'.$ml_original_follows."<br />";
  245.             $om_to = '';
  246.             if (isset($content))
  247.             {
  248.                 $header_om .= "<b>".$ml_subject.": </b>".addslashes($subject)."<br />";
  249.                 $header_om .= "<b>".$ml_from.": </b>".$content["sender"]."<br />";
  250.                 if (isset($content['to']))
  251.                 {
  252.                     for ($i=0;$i<sizeof($content["to"]);$i++)
  253.                     {
  254.                         $lt = strpos($content["to"][$i], "<") + 4;
  255.                         $gt = strpos($content["to"][$i], ">");
  256.  
  257.                         $length = $gt-$lt;
  258.  
  259.                         $address = trim(substr($content["to"][$i],$lt,$length));
  260.                         if ($i!=0)    $om_to .= ';';
  261.                         $om_to .= $address;
  262.  
  263.                     }
  264.                 }else
  265.                 {
  266.                     $om_to=$ml_no_reciepent;
  267.                 }
  268.                 $header_om .= "<b>".$ml_to.": </b>".addslashes($om_to)."<br />";
  269.                 $header_om .= "<b>".$strDate.": </b>".date($_SESSION['GO_SESSION']['date_format'],$content["udate"])."<br />";
  270.             }
  271.             $header_om .= "</font><br /><br />";
  272.  
  273.             $mail_body = $signature.'<br /><blockquote style="border:0;border-left: 2px solid #22437f; padding:0px; margin:0px; padding-left:5px; margin-left: 5px; ">'.$header_om.$mail_body.'</blockquote>';
  274.         }else
  275.         {
  276.             $header_om  = $ml_original_follows."\r\n";
  277.             if (isset($content))
  278.             {
  279.                 $header_om .= $ml_subject.": ".$subject."\r\n";
  280.                 $header_om .= $ml_from.": ".$content["sender"]."\r\n";
  281.                 $om_to = '';
  282.                 for ($i=0;$i<sizeof($content["to"]);$i++)
  283.                 {
  284.                     $lt = strpos($content["to"][$i], "<") + 4;
  285.                     $gt = strpos($content["to"][$i], ">");
  286.  
  287.                     $length = $gt-$lt;
  288.  
  289.                     $address = trim(substr($content["to"][$i],$lt,$length));
  290.                     if ($i!=0)    $om_to .= ';';
  291.                     $om_to .= $address;
  292.  
  293.                 }
  294.                 $header_om .= $ml_to.": ".$om_to."\r\n";
  295.                 $header_om .= $strDate.": ".date($_SESSION['GO_SESSION']['date_format'],$content["udate"])."\r\n\r\n\r\n";
  296.             }
  297.  
  298.             if ($html_message_count > 0)
  299.             {
  300.                 $mail_body = $signature.$ml_html_message_attached."\r\n\r\n".$header_om.$mail_body;
  301.             }else
  302.             {
  303.                 $mail_body = $signature.$header_om.$mail_body;
  304.             }
  305.         }
  306.     }
  307.     $mail->close();
  308. }else
  309. {
  310.     if($mail_body == '')
  311.     {
  312.         $mail_body = $signature;
  313.     }
  314. }
  315.  
  316. //replace signatures when user changed his mail account
  317. if($sendaction == 'change_mail_from' && $old_signature != '')
  318. {
  319.     $mail_body = str_replace($old_signature, $signature, $mail_body);
  320. }
  321.  
  322. //check for the templates plugin
  323. if ($sendaction == 'load_template')
  324. {
  325.     //if contact_id is not set but email is check if there's contact info available
  326.     if ($mail_to != '' && $contact_id == 0)
  327.     {
  328.         if ($contact = $ab->get_contact_profile_by_email($mail_to, $GO_SECURITY->user_id))
  329.         {
  330.             $contact_id = $contact['id'];
  331.         }
  332.     }
  333.  
  334.     require($GO_CONFIG->class_path.'mimeDecode.class.inc');
  335.  
  336.     $template_body = '';
  337.  
  338.     if ($template_id > 0)
  339.     {
  340.         $template = $tp->get_template($template_id);
  341.  
  342.         //get the raw mime message and decode it.
  343.  
  344.         $part_number = 0;
  345.         $url_replacements = array();
  346.         $attachments = array();
  347.  
  348.         $params['include_bodies'] = true;
  349.         $params['decode_bodies'] = true;
  350.         $params['decode_headers'] = true;
  351.         $params['input'] = $template['content'];
  352.  
  353.         $structure = Mail_mimeDecode::decode($params);
  354.         $notification_check = isset($structure->headers['disposition-notification-to']) ? true : false;
  355.  
  356.         $_SESSION['url_replacements'] = array();
  357.  
  358.         //loop through all parts
  359.         if (isset($structure->parts))
  360.         {
  361.             foreach ($structure->parts as $part) {
  362.  
  363.                 $disposition = isset($part->disposition) ? $part->disposition : '';
  364.  
  365.                 //text part and no attachment so it must be the body
  366.                 if ($part->ctype_primary == 'text' && $disposition != 'attachment')
  367.                 {
  368.                     //convert text to html
  369.                     if (eregi('plain', $part->ctype_primary))
  370.                     {
  371.                         $text_part = nl2br($part->body);
  372.                     }else
  373.                     {
  374.                         $text_part = $part->body;
  375.                     }
  376.                     $template_body .= $text_part;
  377.                 }else
  378.                 {
  379.                     //save attachments to a temporarily file
  380.                     $tmp_file = $GO_CONFIG->tmpdir.md5(uniqid(time()));
  381.  
  382.                     $fp = fopen($tmp_file,"w");
  383.                     fwrite ($fp,$part->body);
  384.                     fclose($fp);
  385.  
  386.                     $filename = isset($part->d_parameters['filename']) ? $part->d_parameters['filename'] : '';
  387.  
  388.                     $content_id = isset($part->headers['content-id']) ? trim($part->headers['content-id']) : '';
  389.                     if ($content_id != '')
  390.                     {
  391.                         if (strpos($content_id,'>'))
  392.                         {
  393.                             $content_id = substr($part->headers['content-id'], 1,strlen($part->headers['content-id'])-2);
  394.                         }
  395.  
  396.                         //replace inline images identified by a content id with the url to display the part by Group-Office
  397.                         $url_replacement['id'] = $content_id;
  398.                         $url_replacement['url'] = $ab_module['url'].'templates/mime_part.php?template_id='.$template_id.'&part_number='.$part_number;
  399.                         $_SESSION['url_replacements'][] = $url_replacement;
  400.                     }
  401.                     $email->register_attachment($tmp_file, $filename, strlen($part->body), $part->ctype_primary.'/'.$part->ctype_secondary, $disposition, $content_id);
  402.                 }
  403.                 $part_number++;
  404.             }
  405.         }elseif(isset($structure->body))
  406.         {
  407.             //convert text to html
  408.             if (eregi('plain', $structure->ctype_primary))
  409.             {
  410.                 $text_part = nl2br($structure->body);
  411.             }else
  412.             {
  413.                 $text_part = $structure->body;
  414.             }
  415.             $template_body .= $text_part;
  416.  
  417.         }
  418.         unset($structure);
  419.         //replace inline images with the url to display the part by Group-Office
  420.         if (isset($_SESSION['url_replacements']))
  421.         {
  422.             for ($i=0;$i<count($_SESSION['url_replacements']);$i++)
  423.             {
  424.                 $template_body = str_replace('cid:'.$_SESSION['url_replacements'][$i]['id'], $_SESSION['url_replacements'][$i]['url'], $template_body);
  425.             }
  426.         }
  427.  
  428.         //get the addressbook language file
  429.         require($GO_LANGUAGE->get_language_file('contacts'));
  430.         if ($mailing_group_id == 0)
  431.         {
  432.             $template_body = $tp->replace_data_fields($template_body, $contact_id);
  433.         }
  434.  
  435.         if ($content_type=='text/HTML')
  436.         {
  437.             $mail_body = str_replace('</body>', $mail_body.'</body>', $template_body);
  438.         }else
  439.         {
  440.             $mail_body = $template_body.$mail_body;
  441.         }
  442.     }
  443. }
  444. ?>
  445.  
  446.  
  447. <form name="sendform" enctype="multipart/form-data" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
  448. <input type="hidden" name="sendaction" value="" />
  449. <?php
  450. if($uid > 0)
  451. {
  452.     echo '<input type="hidden" name="uid" value="" />';
  453.     echo '<input type="hidden" name="account_id" value="'.$_REQUEST['account_id'].'" />';
  454.     echo '<input type="hidden" name="mailbox" value="'.$_REQUEST['mailbox'].'" />';
  455.     echo '<input type="hidden" name="action" value="'.$_REQUEST['action'].'" />';
  456.  
  457. }
  458. echo '<input type="hidden" name="old_signature" value="'.$signature.'" />';
  459.  
  460. if (isset($feedback)) echo $feedback;
  461. ?>
  462. <input type="hidden" name="num_attach" value="<?php if (isset($_SESSION['num_attach'])) echo $_SESSION['num_attach']; ?>" />
  463. <input type="hidden" name="MAX_FILE_SIZE" value="<?php echo $GO_CONFIG->max_attachment_size; ?>" />
  464.  
  465. <table  cellspacing="2" cellpadding="1" border="0" width="100%">
  466.  
  467.     <?php
  468.     if ($count > 0)
  469.     {
  470.         echo '<tr><td>'.$ml_from.':</td><td colspan="2">';
  471.         $dropbox = new dropbox();
  472.         $dropbox->add_arrays($ids, $names);
  473.         $dropbox->print_dropbox('mail_from',$mail_from, 'onchange="javascript:change_mail_from()"');
  474.         echo '</td></tr>';
  475.     }
  476.  
  477.     if ($mailing_group_id > 0 && $mailing_group = $tp->get_mailing_group($mailing_group_id))
  478.     {
  479.         echo '<input type="hidden" name="mailing_group_id" value="'.$mailing_group_id.'" />';
  480.         echo '<tr><td>'.$ml_to.': </td><td>'.$mailing_group['name'].'</td></tr>';
  481.     }else
  482.     {
  483.     ?>
  484.         <tr>
  485.             <td>
  486.                 <table border="0" cellpadding="0" cellspacing="0">
  487.                 <tr>
  488.                     <td valign="center">
  489.                     <?php
  490.                     if ($ab_module)
  491.                     {
  492.                         echo '<a class="normal" href="'.$ab->select_contacts('document.sendform.mail_to', $GO_MODULES->url.'add_contacts.php').'">';
  493.                         echo '<img src="'. $GO_THEME->images['addressbook_small'].'" width="16" height="16" border="0" /></a> </td><td valign="center"><a class="normal" href="'.$ab->select_contacts('document.sendform.mail_to', $GO_MODULES->url.'add_contacts.php').'">'. $ml_to.'</a> :';
  494.                     }else
  495.                     {
  496.                         echo $ml_to.':';
  497.                     }
  498.                     ?>
  499.                     </td>
  500.                 </tr>
  501.                 </table>
  502.             </td>
  503.             <td colspan="2"><input class="textbox" type="text" name="mail_to" size="95" value="<?php echo (isset($mail_to) ? htmlspecialchars($mail_to) : ''); ?>" /></td>
  504.         </tr>
  505.         <tr>
  506.             <td>
  507.             <table border="0" cellpadding="0" cellspacing="0">
  508.                 <tr>
  509.                     <td valign="center">
  510.                     <?php
  511.                     if ($ab_module)
  512.                     {
  513.                         echo '<a class="normal" href="'.$ab->select_contacts('document.sendform.mail_cc', $GO_MODULES->url.'add_contacts.php').'">';
  514.                         echo '<img src="'. $GO_THEME->images['addressbook_small'].'" width="16" height="16" border="0" /></a> </td><td valign="center"><a class="normal" href="'.$ab->select_contacts('document.sendform.mail_cc', $GO_MODULES->url.'add_contacts.php').'">CC</a> :';
  515.                     }else
  516.                     {
  517.                         echo 'CC:';
  518.                     }
  519.                     ?>
  520.                     </td>
  521.                 </tr>
  522.                 </table>
  523.             </td>
  524.             <td colspan="2"><input class="textbox" type="text" name="mail_cc" size="95" value="<?php echo (isset($mail_cc) ? htmlspecialchars($mail_cc) : '') ?>" /></td>
  525.         </tr>
  526.         <tr>
  527.             <td>
  528.             <table border="0" cellpadding="0" cellspacing="0">
  529.                 <tr>
  530.                     <td valign="center">
  531.                     <?php
  532.                     if ($ab_module)
  533.                     {
  534.                         echo '<a class="normal" href="'.$ab->select_contacts('document.sendform.mail_bcc', $GO_MODULES->url.'add_contacts.php').'">';
  535.                         echo '<img src="'. $GO_THEME->images['addressbook_small'].'" width="16" height="16" border="0" /></a> </td><td valign="center"><a class="normal" href="'.$ab->select_contacts('document.sendform.mail_bcc', $GO_MODULES->url.'add_contacts.php').'">BCC</a> :';
  536.                     }else
  537.                     {
  538.                         echo 'BCC:';
  539.                     }
  540.                     ?>
  541.                     </td>
  542.                 </tr>
  543.                 </table>
  544.             </td>
  545.             <td colspan="2"><input class="textbox" type="text" name="mail_bcc" size="95" value="<?php echo (isset($mail_bcc) ? htmlspecialchars($mail_bcc) : '') ?>" /></td>
  546.         </tr>
  547.     <?php
  548.     }//endif mailing_group_id
  549.     ?>
  550.     <tr>
  551.         <td ><?php echo $ml_subject ?> : </td>
  552.         <td colspan="2"><input class="textbox" type="text" name="mail_subject" size="95" value="<?php echo (isset($mail_subject) ? htmlspecialchars($mail_subject) : '') ?>" /></td>
  553.     </tr>
  554.     <tr>
  555.         <td ><?php echo $ml_attachment ?> : </td>
  556.         <td colspan="2" nowrap>
  557.             <input class="textbox" type="file" name="mail_att" maxlength="200" size="30" value="" />
  558.             <?php
  559.             $button = new button($ml_attach, 'javascript:attach()');
  560.             echo '  ';
  561.             if ($module = $GO_MODULES->get_module('filesystem'))
  562.             {
  563.                 if ($GO_SECURITY->has_permission($GO_SECURITY->user_id, $module['acl_read']) || $GO_SECURITY->has_permission($GO_SECURITY->user_id, $module['acl_write']))
  564.                 {
  565.                     $button = new button($ml_online_files, "javascript:popup('select_file.php','600','400')");
  566.                 }
  567.             }
  568.             ?>
  569.         </td>
  570.     </tr>
  571.     <tr>
  572.         <td valign="top"><?php echo $ml_priority ?> : </td>
  573.         <td valign="top">
  574.         <?php
  575.         $priority = isset($_POST['priority']) ? $_POST['priority'] : '3';
  576.  
  577.         $dropbox = new dropbox();
  578.         $dropbox->add_value('1',$ml_high);
  579.         $dropbox->add_value('3',$ml_normal);
  580.         $dropbox->add_value('5',$ml_low);
  581.         $dropbox->print_dropbox('priority',$priority);
  582.         $notification_check = isset($_POST['notification']) ? true : false;
  583.         ?>
  584.           
  585.         </td>
  586.         <?php
  587.         echo '<td valign="top" ';
  588.         if ($wysiwyg) echo 'rowspan="2"';
  589.         echo '>';
  590.  
  591.         $checkbox = new checkbox('notification', 'true', $ml_notification, $notification_check);
  592.  
  593.         /*if ($ab_module)
  594.         {
  595.             echo '<br />';
  596.             $checkbox = new checkbox('add_recievers', 'true', $ml_add_recievers, $add_recievers_check);
  597.         }*/
  598.         ?>
  599.         </td>
  600.     </tr>
  601.     <?php
  602.     if ($wysiwyg)
  603.     {
  604.         echo '<tr><td>'.$ml_format.':</td><td>';
  605.         $dropbox = new dropbox();
  606.         $dropbox->add_value('text/PLAIN', 'text');
  607.         $dropbox->add_value('text/HTML', 'HTML');
  608.         $dropbox->print_dropbox('content_type',$content_type, 'onchange="javascript:change_format()"');
  609.         echo '</td><td></td></tr>';
  610.     }else
  611.     {
  612.         echo '<input type="hidden" value="text/PLAIN" name="content_type" />';
  613.     }
  614.  
  615.     if (isset($_SESSION['num_attach']) && ($_SESSION['num_attach'] > 0))
  616.     {
  617.         echo '<tr><td colspan="3">';
  618.         echo '<table border="0" cellspacing="2"><tr>';
  619.         $totalsize = 0;
  620.         $splitter=0;
  621.         $count = 0;
  622.         for ($i=1;$i<=$_SESSION['num_attach'];$i++)
  623.         {
  624.             if ($_SESSION['attach_array'][$i]->disposition == 'attachment')
  625.             {
  626.                 $count++;
  627.                 $splitter++;
  628.                 $totalsize += $_SESSION['attach_array'][$i]->file_size;
  629.                 $att_name = imap_mime_header_decode($_SESSION['attach_array'][$i]->file_name);
  630.                 echo '<td><table border="0" cellpadding="0" cellspacing="0"><tr><td><input type="checkbox" name="file'.$i.'" /></td><td><img border="0" width="16" height="16" src="'.$GO_CONFIG->control_url.'icon.php?extension='.get_extension($_SESSION['attach_array'][$i]->file_name).'&mime='.urlencode($_SESSION['attach_array'][$i]->file_mime).'" /></td><td nowrap> '.htmlentities($att_name[0]->text).' ('.format_size($_SESSION['attach_array'][$i]->file_size).'); </td></tr></table></td>';
  631.                 if ($splitter=="2")
  632.                 {
  633.                     echo "</tr><tr>\n";
  634.                     $splitter=0;
  635.                 }
  636.             }
  637.         }
  638.         if ($count > 0)
  639.         {
  640.             echo '<tr><td>';
  641.             $button = new button($cmdDelete, 'javascript:delete_attach()');
  642.             echo '</td><td>'.$ml_total_size.' : '.format_size($totalsize).'</td></tr></table>';
  643.         }
  644.     }
  645.     echo '</td></tr>';
  646.     ?>
  647.     <tr>
  648.         <td colspan="3" width="100%" height="100%">
  649.         <?php
  650.         if ($content_type=='text/HTML')
  651.         {
  652.             $htmlarea->print_htmlarea(stripslashes(htmlspecialchars($mail_body)));
  653.         }else
  654.         {
  655.             echo '<textarea class="textbox" name="mail_body" cols="110" rows="12" style="width: 100%;">'.htmlspecialchars($mail_body).'</textarea>';
  656.         }
  657.         ?>
  658.         </td>
  659.     </tr>
  660.     <tr>
  661.         <td align="center" colspan="3">
  662.             <?php
  663.             $button = new button($ml_send,"javascript:send()");
  664.             echo '  ';
  665.             $button = new button($cmdCancel,"javascript:window.close()");
  666.             ?>
  667.         </td>
  668.     </tr>
  669. </table>
  670. </form>
  671.  
  672.  
  673. <script type="text/javascript">
  674. <!--
  675.  
  676.  
  677. function validate()
  678. {
  679.     if (window.RegExp)
  680.     {
  681.         var reg = new RegExp("[0-9A-Za-z]+","g");
  682.         if (!reg.test(document.sendform.mail_to.value) && !reg.test(document.sendform.mail_cc.value) && !reg.test(document.sendform.mail_bcc.value))
  683.         {
  684.             alert("<?php echo $ml_to_empty ?>");
  685.             document.sendform.mail_to.focus();
  686.             return (false);
  687.         }
  688.     }
  689.     if (document.sendform.mail_att.value != "")
  690.     {
  691.         alert("<?php echo $ml_attach_forget ?>")
  692.         return (false);
  693.     }
  694.     return (true);
  695. }
  696.  
  697. function send()
  698. {
  699.     if (document.sendform.sendaction.value != 'send')
  700.     {
  701.         <?php
  702.         if ($mailing_group_id == 0) echo 'if (validate()){';
  703.         ?>
  704.  
  705.             document.sendform.sendaction.value = "send";
  706.             <?php
  707.             if (isset($uid) && $uid > 0)
  708.             {
  709.                 echo 'document.sendform.uid.value="'.$uid.'";';
  710.             }
  711.             if ($content_type == 'text/HTML')
  712.             {
  713.                 echo 'document.sendform.onsubmit();';
  714.             }
  715.             ?>
  716.             document.sendform.submit();
  717.         <?php if ($mailing_group_id == 0) echo '}'; ?>
  718.     }
  719. }
  720.  
  721. function attach()
  722. {
  723.     if (document.sendform.mail_att.value != "")
  724.     {
  725.         <?php
  726.         if ($content_type == 'text/HTML')
  727.         {
  728.             echo 'document.sendform.onsubmit();';
  729.         }
  730.         ?>
  731.         document.sendform.sendaction.value = "add";
  732.         document.sendform.submit();
  733.     }
  734. }
  735.  
  736. function change_format()
  737. {
  738.     if (confirm('<?php echo $ml_loose_changes; ?>'))
  739.     {
  740.         <?php
  741.         if (isset($uid) && $uid > 0)
  742.         {
  743.             echo 'document.sendform.uid.value="'.$uid.'";';
  744.         }
  745.         if ($content_type == 'text/HTML')
  746.         {
  747.             echo 'document.sendform.onsubmit();';
  748.         }
  749.         ?>
  750.         document.sendform.mail_body.value='';
  751.         document.sendform.sendaction.value = 'change_format';
  752.         document.sendform.submit();
  753.     }
  754. }
  755.  
  756. function change_mail_from()
  757. {
  758.     <?php
  759.     if ($content_type == 'text/HTML')
  760.     {
  761.         echo 'document.sendform.onsubmit();';
  762.     }
  763.     ?>
  764.     document.sendform.sendaction.value = 'change_mail_from';
  765.     document.sendform.submit();
  766. }
  767.  
  768. function delete_attach()
  769. {
  770.     document.sendform.sendaction.value = "delete";
  771.     <?php
  772.     if ($content_type == 'text/HTML')
  773.     {
  774.         echo 'document.sendform.onsubmit();';
  775.     }
  776.     ?>
  777.     document.sendform.submit();
  778. }
  779.  
  780. //-->
  781. </script>
  782.