Changeset 5604
- Timestamp:
- 03/02/12 03:48:47 (12 years ago)
- Location:
- trunk
- Files:
-
- 3 added
- 16 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/expressoMail1_2/inc/class.imap_functions.inc.php
r5548 r5604 2531 2531 } 2532 2532 2533 function send_mail($params) 2534 { 2535 require_once dirname(__FILE__) . '/../../services/class.servicelocator.php'; 2536 $mailService = ServiceLocator::getService('mail'); 2537 2538 include_once("class.db_functions.inc.php"); 2539 $db = new db_functions(); 2540 $fromaddress = $params['input_from'] ? explode(';',$params['input_from']) : ""; 2541 $message_attachments_contents = (isset($params['message_attachments_content'])) ? $params['message_attachments_content'] : false; 2542 2543 ## 2544 # @AUTHOR Rodrigo Souza dos Santos 2545 # @DATE 2008/09/17$fileName 2546 # @BRIEF Checks if the user has permission to send an email with the email address used. 2547 ## 2548 if ( is_array($fromaddress) && ($fromaddress[1] != $_SESSION['phpgw_info']['expressomail']['user']['email']) ) 2549 { 2550 $deny = true; 2551 foreach( $_SESSION['phpgw_info']['expressomail']['user']['shared_mailboxes'] as $key => $val ) 2552 if ( array_key_exists('mail', $val) && $val['mail'][0] == $fromaddress[1] ) 2553 $deny = false and end($_SESSION['phpgw_info']['expressomail']['user']['shared_mailboxes']); 2554 2555 if ( $deny ) 2556 return "The server denied your request to send a mail, you cannot use this mail address."; 2557 } 2558 2559 $toaddress = $db->getAddrs(explode(',',$params['input_to']));//implode(',',); 2560 $ccaddress = $db->getAddrs(explode(',',$params['input_cc']));//implode(',',); 2561 $ccoaddress = $db->getAddrs(explode(',',$params['input_cco']));//implode(',',); 2562 2563 if($toaddress["False"] || $ccaddress["False"] || $ccoaddress["False"]){ 2564 return $this->parse_error("Invalid Mail:", ($toaddress["False"] ? $toaddress["False"] : ($ccaddress["False"] ? $ccaddress["False"] : $ccoaddress["False"]))); 2565 } 2566 2567 $toaddress = implode(',', $toaddress); 2568 $ccaddress = implode(',', $ccaddress); 2569 $ccoaddress = implode(',', $ccoaddress); 2570 2571 if($toaddress == "" && $ccaddress == "" && $ccoaddress == ""){ 2572 return $this->parse_error("Invalid Mail:", ($params['input_to'] ? $params['input_to'] :($params['input_cc'] ? $params['input_cc'] : $params['input_cco'])) ); 2573 } 2574 2575 $toaddress = preg_replace('/<\s+/', '<', $toaddress); 2576 $toaddress = preg_replace('/\s+>/', '>', $toaddress); 2577 2578 $ccaddress = preg_replace('/<\s+/', '<', $ccaddress); 2579 $ccaddress = preg_replace('/\s+>/', '>', $ccaddress); 2580 2581 $ccoaddress = preg_replace('/<\s+/', '<', $ccoaddress); 2582 $ccoaddress = preg_replace('/\s+>/', '>', $ccoaddress); 2583 2584 $replytoaddress = $params['input_replyto']; 2585 $subject = $params['input_subject']; 2586 $msg_uid = $params['msg_id']; 2587 $return_receipt = $params['input_return_receipt']; 2588 $is_important = $params['input_important_message']; 2589 $encrypt = $params['input_return_cripto']; 2590 $signed = $params['input_return_digital']; 2591 2592 $message_attachments = $params['message_attachments']; 2593 2594 if(substr($params['input_to'],-1) == ',') 2595 $params['input_to'] = substr($params['input_to'],0,-1); 2596 2597 if(substr($params['input_cc'],-1) == ',') 2598 $params['input_cc'] = substr($params['input_cc'],0,-1); 2599 2600 if(substr($params['input_cco'],-1) == ',') 2601 $params['input_cco'] = substr($params['input_cco'],0,-1); 2602 2603 // Valida numero Maximo de Destinatarios 2604 if($_SESSION['phpgw_info']['expresso']['expressoMail']['expressoAdmin_maximum_recipients'] > 0) 2605 { 2606 $sendersNumber = count(explode(',',$params['input_to'])); 2607 2608 if($params['input_cc']) 2609 $sendersNumber += count(explode(',',$params['input_cc'])); 2610 if($params['input_cco']) 2611 $sendersNumber += count(explode(',',$params['input_cco'])); 2612 2613 $userMaxmimumSenders = $db->getMaximumRecipientsUser($this->username); 2614 if($userMaxmimumSenders) 2615 { 2616 if($sendersNumber > $userMaxmimumSenders) 2617 return $this->functions->getLang('Number of recipients greater than allowed'); 2618 } 2619 else 2620 { 2621 $ldap = new ldap_functions(); 2622 $groupsToUser = $ldap->get_user_groups($this->username); 2623 2624 $groupMaxmimumSenders = $db->getMaximumRecipientsGroup($groupsToUser); 2625 2626 if($groupMaxmimumSenders > 0) 2627 { 2628 if($sendersNumber > $groupMaxmimumSenders) 2629 return $this->functions->getLang('Number of recipients greater than allowed'); 2630 } 2631 else 2632 { 2633 if($sendersNumber > $_SESSION['phpgw_info']['expresso']['expressoMail']['expressoAdmin_maximum_recipients']) 2634 return $this->functions->getLang('Number of recipients greater than allowed'); 2635 } 2636 } 2637 2638 } 2639 //Fim Valida numero maximo de destinatarios 2640 2641 2642 //Valida envio de email para shared accounts 2643 if($_SESSION['phpgw_info']['expresso']['expressoMail']['expressoMail_block_institutional_comunication'] == 'true') 2644 { 2533 function send_mail($params) { 2534 2535 require_once dirname(__FILE__) . '/../../services/class.servicelocator.php'; 2536 require_once dirname(__FILE__) . '/../../prototype/api/controller.php'; 2537 $mailService = ServiceLocator::getService('mail'); 2538 2539 include_once("class.db_functions.inc.php"); 2540 $db = new db_functions(); 2541 $fromaddress = $params['input_from'] ? explode(';', $params['input_from']) : ""; 2542 $message_attachments_contents = (isset($params['message_attachments_content'])) ? $params['message_attachments_content'] : false; 2543 2544 ## 2545 # @AUTHOR Rodrigo Souza dos Santos 2546 # @DATE 2008/09/17$fileName 2547 # @BRIEF Checks if the user has permission to send an email with the email address used. 2548 ## 2549 if (is_array($fromaddress) && ($fromaddress[1] != $_SESSION['phpgw_info']['expressomail']['user']['email'])) { 2550 $deny = true; 2551 foreach ($_SESSION['phpgw_info']['expressomail']['user']['shared_mailboxes'] as $key => $val) 2552 if (array_key_exists('mail', $val) && $val['mail'][0] == $fromaddress[1]) 2553 $deny = false and end($_SESSION['phpgw_info']['expressomail']['user']['shared_mailboxes']); 2554 2555 if ($deny) 2556 return "The server denied your request to send a mail, you cannot use this mail address."; 2557 } 2558 2559 $toaddress = $db->getAddrs(explode(',', $params['input_to'])); //implode(',',); 2560 $ccaddress = $db->getAddrs(explode(',', $params['input_cc'])); //implode(',',); 2561 $ccoaddress = $db->getAddrs(explode(',', $params['input_cco'])); //implode(',',); 2562 2563 if ($toaddress["False"] || $ccaddress["False"] || $ccoaddress["False"]) { 2564 return $this->parse_error("Invalid Mail:", ($toaddress["False"] ? $toaddress["False"] : ($ccaddress["False"] ? $ccaddress["False"] : $ccoaddress["False"]))); 2565 } 2566 2567 $toaddress = implode(',', $toaddress); 2568 $ccaddress = implode(',', $ccaddress); 2569 $ccoaddress = implode(',', $ccoaddress); 2570 2571 if ($toaddress == "" && $ccaddress == "" && $ccoaddress == "") { 2572 return $this->parse_error("Invalid Mail:", ($params['input_to'] ? $params['input_to'] : ($params['input_cc'] ? $params['input_cc'] : $params['input_cco']))); 2573 } 2574 2575 $toaddress = preg_replace('/<\s+/', '<', $toaddress); 2576 $toaddress = preg_replace('/\s+>/', '>', $toaddress); 2577 2578 $ccaddress = preg_replace('/<\s+/', '<', $ccaddress); 2579 $ccaddress = preg_replace('/\s+>/', '>', $ccaddress); 2580 2581 $ccoaddress = preg_replace('/<\s+/', '<', $ccoaddress); 2582 $ccoaddress = preg_replace('/\s+>/', '>', $ccoaddress); 2583 2584 $replytoaddress = $params['input_replyto']; 2585 $subject = $params['input_subject']; 2586 $return_receipt = $params['input_return_receipt']; 2587 $is_important = $params['input_important_message']; 2588 $encrypt = $params['input_return_cripto']; 2589 $signed = $params['input_return_digital']; 2590 2591 $message_attachments = $params['message_attachments']; 2592 2593 if (substr($params['input_to'], -1) == ',') 2594 $params['input_to'] = substr($params['input_to'], 0, -1); 2595 2596 if (substr($params['input_cc'], -1) == ',') 2597 $params['input_cc'] = substr($params['input_cc'], 0, -1); 2598 2599 if (substr($params['input_cco'], -1) == ',') 2600 $params['input_cco'] = substr($params['input_cco'], 0, -1); 2601 2602 // Valida numero Maximo de Destinatarios 2603 if ($_SESSION['phpgw_info']['expresso']['expressoMail']['expressoAdmin_maximum_recipients'] > 0) { 2604 $sendersNumber = count(explode(',', $params['input_to'])); 2605 2606 if ($params['input_cc']) 2607 $sendersNumber += count(explode(',', $params['input_cc'])); 2608 if ($params['input_cco']) 2609 $sendersNumber += count(explode(',', $params['input_cco'])); 2610 2611 $userMaxmimumSenders = $db->getMaximumRecipientsUser($this->username); 2612 if ($userMaxmimumSenders) { 2613 if ($sendersNumber > $userMaxmimumSenders) 2614 return $this->functions->getLang('Number of recipients greater than allowed'); 2615 } 2616 else { 2645 2617 $ldap = new ldap_functions(); 2646 $arrayF = explode(';', $params['input_from']); 2618 $groupsToUser = $ldap->get_user_groups($this->username); 2619 2620 $groupMaxmimumSenders = $db->getMaximumRecipientsGroup($groupsToUser); 2621 2622 if ($groupMaxmimumSenders > 0) { 2623 if ($sendersNumber > $groupMaxmimumSenders) 2624 return $this->functions->getLang('Number of recipients greater than allowed'); 2625 } 2626 else { 2627 if ($sendersNumber > $_SESSION['phpgw_info']['expresso']['expressoMail']['expressoAdmin_maximum_recipients']) 2628 return $this->functions->getLang('Number of recipients greater than allowed'); 2629 } 2630 } 2631 } 2632 //Fim Valida numero maximo de destinatarios 2633 //Valida envio de email para shared accounts 2634 if ($_SESSION['phpgw_info']['expresso']['expressoMail']['expressoMail_block_institutional_comunication'] == 'true') { 2635 $ldap = new ldap_functions(); 2636 $arrayF = explode(';', $params['input_from']); 2637 2638 /* 2639 * Verifica se o remetente n?o ? uma conta compartilhada 2640 */ 2641 if (!$ldap->isSharedAccountByMail($arrayF[1])) { 2642 $groupsToUser = $ldap->get_user_groups($this->username); 2643 $sharedAccounts = $ldap->returnSharedsAccounts($toaddress, $ccaddress, $ccoaddress); 2647 2644 2648 2645 /* 2649 * Verifica se o remetente n?o ? uma conta compartilhada2646 * Pega o UID do remetente 2650 2647 */ 2651 if(!$ldap->isSharedAccountByMail($arrayF[1])) 2652 { 2653 $groupsToUser = $ldap->get_user_groups($this->username); 2654 $sharedAccounts = $ldap->returnSharedsAccounts($toaddress, $ccaddress, $ccoaddress); 2655 2656 /* 2657 * Pega o UID do remetente 2658 */ 2659 $uidFrom = $ldap->mail2uid($arrayF[1]); 2660 2661 /* 2662 * Remove a conta compartilhada caso o uid do remetente exista na conta compartilhada 2663 */ 2664 foreach ($sharedAccounts as $key => $value) 2665 { 2666 if($value) 2667 $acl = $this->getaclfrombox($value); 2668 2669 if (array_key_exists($uidFrom, $acl)) 2670 unset($sharedAccounts[$key]); 2671 2672 } 2673 2674 /* 2675 * Caso ainda exista contas compartilhadas, verifica se existe alguma exce??o para estas contas 2676 */ 2677 if(count($sharedAccounts) > 0) 2678 $accountsBlockeds = $db->validadeSharedAccounts($this->username, $groupsToUser, $sharedAccounts); 2679 2680 /* 2681 * Retorna as contas compartilhadas bloqueadas 2682 */ 2683 if(count($accountsBlockeds) > 0) 2684 { 2685 $return = ''; 2686 2687 foreach ($accountsBlockeds as $accountBlocked) 2688 $return.= $accountBlocked.', '; 2689 2690 $return = substr($return,0,-2); 2691 2692 return $this->functions->getLang('you are blocked from sending mail to the following addresses').': '.$return; 2648 $uidFrom = $ldap->mail2uid($arrayF[1]); 2649 2650 /* 2651 * Remove a conta compartilhada caso o uid do remetente exista na conta compartilhada 2652 */ 2653 foreach ($sharedAccounts as $key => $value) { 2654 if ($value) 2655 $acl = $this->getaclfrombox($value); 2656 2657 if (array_key_exists($uidFrom, $acl)) 2658 unset($sharedAccounts[$key]); 2659 } 2660 2661 /* 2662 * Caso ainda exista contas compartilhadas, verifica se existe alguma exce??o para estas contas 2663 */ 2664 if (count($sharedAccounts) > 0) 2665 $accountsBlockeds = $db->validadeSharedAccounts($this->username, $groupsToUser, $sharedAccounts); 2666 2667 /* 2668 * Retorna as contas compartilhadas bloqueadas 2669 */ 2670 if (count($accountsBlockeds) > 0) { 2671 $return = ''; 2672 2673 foreach ($accountsBlockeds as $accountBlocked) 2674 $return.= $accountBlocked . ', '; 2675 2676 $return = substr($return, 0, -2); 2677 2678 return $this->functions->getLang('you are blocked from sending mail to the following addresses') . ': ' . $return; 2679 } 2680 } 2681 } 2682 // Fim Valida envio de email para shared accounts 2683 // TODO - implementar tratamento SMIME no novo serviço de envio de emails e retirar o AND false abaixo 2684 if ($params['smime'] AND false) { 2685 $body = $params['smime']; 2686 $mail->SMIME = true; 2687 // A MSG assinada deve ser testada neste ponto. 2688 // Testar o certificado e a integridade da msg.... 2689 include_once(dirname(__FILE__) . "/../../security/classes/CertificadoB.php"); 2690 $erros_acumulados = ''; 2691 $certificado = new certificadoB(); 2692 $validade = $certificado->verificar($body); 2693 if (!$validade) { 2694 foreach ($certificado->erros_ssl as $linha_erro) { 2695 $erros_acumulados .= $linha_erro; 2696 } 2697 } else { 2698 // Testa o CERTIFICADO: se o CPF he o do usuario logado, se pode assinar msgs e se nao esta expirado... 2699 if ($certificado->apresentado) { 2700 if ($certificado->dados['EXPIRADO']) 2701 $erros_acumulados .='Certificado expirado.'; 2702 $this->cpf = isset($GLOBALS['phpgw_info']['server']['certificado_atributo_cpf']) && $GLOBALS['phpgw_info']['server']['certificado_atributo_cpf'] != '' ? $_SESSION['phpgw_info']['expressomail']['user'][$GLOBALS['phpgw_info']['server']['certificado_atributo_cpf']] : $this->username; 2703 if ($certificado->dados['CPF'] != $this->cpf) 2704 $erros_acumulados .=' CPF no certificado diferente do logado no expresso.'; 2705 if (!($certificado->dados['KEYUSAGE']['digitalSignature'] && $certificado->dados['EXTKEYUSAGE']['emailProtection'])) 2706 $erros_acumulados .=' Certificado nao permite assinar mensagens.'; 2707 } 2708 else { 2709 $$erros_acumulados .= 'Nao foi possivel usar o certificado para assinar a msg'; 2710 } 2711 } 2712 if (!$erros_acumulados == '') { 2713 return $erros_acumulados; 2714 } 2715 } else { 2716 //Compatibilização com Outlook, ao encaminhar a mensagem 2717 $body = mb_ereg_replace('<!--\[', '<!-- [', $params['body']); 2718 } 2719 2720 $attachments = $_FILES; 2721 $forwarding_attachments = $params['forwarding_attachments']; 2722 $local_attachments = $params['local_attachments']; 2723 2724 //Test if must be saved in shared folder and change if necessary 2725 if ($fromaddress[2] == 'y') { 2726 //build shared folder path 2727 $newfolder = "user" . $this->imap_delimiter . $fromaddress[3] . $this->imap_delimiter . $this->imap_sentfolder; 2728 if ($this->folder_exists($newfolder)) 2729 $folder = $newfolder; 2730 else 2731 $folder = $params['folder']; 2732 } else { 2733 $folder = $params['folder']; 2734 } 2735 2736 $folder = mb_convert_encoding($folder, 'UTF7-IMAP', 'ISO_8859-1'); 2737 $folder = preg_replace('/INBOX[\/.]/i', 'INBOX' . $this->imap_delimiter, $folder); 2738 $folder_name = $params['folder_name']; 2739 2740 // TODO - tratar assinatura e remover o AND false 2741 if ($signed && !$params['smime'] AND false) { 2742 $mail->Mailer = "smime"; 2743 $mail->SignedBody = true; 2744 } 2745 2746 2747 if ($fromaddress) 2748 $mailService->setFrom('"' . $fromaddress[0] . '" <' . $fromaddress[1] . '>'); 2749 else 2750 $mailService->setFrom('"' . $_SESSION['phpgw_info']['expressomail']['user']['firstname'] . ' ' . $_SESSION['phpgw_info']['expressomail']['user']['lastname'] . '" <' . $_SESSION['phpgw_info']['expressomail']['user']['email'] . '>'); 2751 2752 $bol = $this->add_recipients('to', $toaddress, $mailService); 2753 if (!$bol) { 2754 return $this->parse_error("Invalid Mail:", $toaddress); 2755 } 2756 $bol = $this->add_recipients('cc', $ccaddress, $mailService); 2757 if (!$bol) { 2758 return $this->parse_error("Invalid Mail:", $ccaddress); 2759 } 2760 $allow = $_SESSION['phpgw_info']['server']['expressomail']['allow_hidden_copy']; 2761 2762 if ($allow) { 2763 //$mailService->addBcc($ccoaddress); 2764 $bol = $this->add_recipients('cco', $ccoaddress, $mailService); 2765 2766 if (!$bol) { 2767 return $this->parse_error("Invalid Mail:", $ccoaddress); 2768 } 2769 } 2770 2771 //Implementação para o In-Reply-To e References 2772 $msg_numb = $params['messageNum']; 2773 $msg_folder = $params['messageFolder']; 2774 $this->mbox = $this->open_mbox($msg_folder); 2775 2776 $header = $this->get_header($msg_numb); 2777 $header_ = imap_fetchheader($this->mbox, $msg_numb, FT_UID); 2778 $pattern = '/^[ \t]*Disposition-Notification-To:[ ]*<?[[:alnum:]\._-]+@[[:alnum:]_-]+[\.[:alnum:]]+>?/sm'; 2779 if (preg_match($pattern, $header_, $fields)) { 2780 if (preg_match('/[[:alnum:]\._\-]+@[[:alnum:]_\-\.]+/', $fields[0], $matches)) { 2781 $return['DispositionNotificationTo'] = "<" . $matches[0] . ">"; 2782 } 2783 } 2784 2785 $message_id = $header->message_id; 2786 $references = array(); 2787 if ($message_id != "") { 2788 $mailService->addHeaderField('In-Reply-To', $message_id); 2789 2790 if (isset($header->references)) { 2791 array_push($references, $header->references); 2792 } 2793 array_push($references, $message_id); 2794 $mailService->addHeaderField('References', $references); 2795 } 2796 2797 2798 $mailService->setSubject($subject); 2799 $isHTML = ( (array_key_exists('type', $params) && in_array(strtolower($params['type']), array('html', 'plain')) ) ? 2800 strtolower($params['type']) != 'plain' : true ); 2801 2802 2803 // TODO - tratar mensagem criptografada e remover o AND false abaixo 2804 if (($encrypt && $signed && $params['smime']) || ($encrypt && !$signed) AND false) { // a msg deve ser enviada cifrada... 2805 $email = $this->add_recipients_cert($toaddress . ',' . $ccaddress . ',' . $ccoaddress); 2806 $email = explode(",", $email); 2807 // Deve ser testado se foram obtidos os certificados de todos os destinatarios. 2808 // Deve ser verificado um numero limite de destinatarios. 2809 // Deve ser verificado se os certificados sao validos. 2810 // Se uma das verificacoes falhar, nao enviar o e-mail e avisar o usuario. 2811 // O array $mail->Certs_crypt soh deve ser preenchido se os certificados passarem nas verificacoes. 2812 $numero_maximo = $_SESSION['phpgw_info']['user']['preferences']['expressoMail']['num_max_certs_to_cipher']; // Este valor dever ser configurado pelo administrador do site .... 2813 $erros_acumulados = ""; 2814 $aux_mails = array(); 2815 $mail_list = array(); 2816 if (count($email) > $numero_maximo) { 2817 $erros_acumulados .= "Excedido o numero maximo (" . $numero_maximo . ") de destinatarios para uma msg cifrada...." . chr(0x0A); 2818 return $erros_acumulados; 2819 } 2820 // adiciona o email do remetente. eh para cifrar a msg para ele tambem. Assim vai poder visualizar a msg na pasta enviados.. 2821 $email[] = $_SESSION['phpgw_info']['expressomail']['user']['email']; 2822 foreach ($email as $item) { 2823 $certificate = $db->get_certificate(strtolower($item)); 2824 if (!$certificate) { 2825 $erros_acumulados .= "Chamada com parametro invalido. e-Mail nao pode ser vazio." . chr(0x0A); 2826 return $erros_acumulados; 2827 } 2828 2829 if (array_key_exists("dberr1", $certificate)) { 2830 2831 $erros_acumulados .= "Ocorreu um erro quando pesquisava certificados dos destinatarios para cifrar a msg." . chr(0x0A); 2832 return $erros_acumulados; 2833 } 2834 if (array_key_exists("dberr2", $certificate)) { 2835 $erros_acumulados .= $item . ' : Nao pode cifrar a msg. Certificado nao localizado.' . chr(0x0A); 2836 //continue; 2837 } 2838 /* Retirado este teste para evitar mensagem de erro duplicada. 2839 if (!array_key_exists("certs", $certificate)) 2840 { 2841 $erros_acumulados .= $item . ' : Nao pode cifrar a msg. Certificado nao localizado.' . chr(0x0A); 2842 continue; 2843 } 2844 */ 2845 include_once(dirname(__FILE__) . "/../../security/classes/CertificadoB.php"); 2846 2847 foreach ($certificate['certs'] as $registro) { 2848 $c1 = new certificadoB(); 2849 $c1->certificado($registro['chave_publica']); 2850 if ($c1->apresentado) { 2851 $c2 = new Verifica_Certificado($c1->dados, $registro['chave_publica']); 2852 if (!$c1->dados['EXPIRADO'] && !$c2->revogado && $c2->status) { 2853 $aux_mails[] = $registro['chave_publica']; 2854 $mail_list[] = strtolower($item); 2855 } else { 2856 if ($c1->dados['EXPIRADO'] || $c2->revogado) { 2857 $db->update_certificate($c1->dados['SERIALNUMBER'], $c1->dados['EMAIL'], $c1->dados['AUTHORITYKEYIDENTIFIER'], $c1->dados['EXPIRADO'], $c2->revogado); 2858 } 2859 2860 $erros_acumulados .= $item . ': ' . $c2->msgerro . chr(0x0A); 2861 foreach ($c2->erros_ssl as $linha) { 2862 $erros_acumulados .= $linha . chr(0x0A); 2863 } 2864 $erros_acumulados .= 'Emissor: ' . $c1->dados['EMISSOR'] . chr(0x0A); 2865 $erros_acumulados .= $c1->dados['CRLDISTRIBUTIONPOINTS'] . chr(0x0A); 2866 } 2867 } else { 2868 $erros_acumulados .= $item . ' : Nao pode cifrar a msg. Certificado invalido.' . chr(0x0A); 2693 2869 } 2694 2870 } 2871 if (!(in_array(strtolower($item), $mail_list)) && !empty($erros_acumulados)) { 2872 return $erros_acumulados; 2873 } 2695 2874 } 2696 // Fim Valida envio de email para shared accounts 2697 2698 2699 // TODO - implementar tratamento SMIME no novo serviço de envio de emails e retirar o AND false abaixo 2700 if($params['smime'] AND false) 2701 { 2702 $body = $params['smime']; 2703 $mail->SMIME = true; 2704 // A MSG assinada deve ser testada neste ponto. 2705 // Testar o certificado e a integridade da msg.... 2706 include_once(dirname( __FILE__ ) ."/../../security/classes/CertificadoB.php"); 2707 $erros_acumulados = ''; 2708 $certificado = new certificadoB(); 2709 $validade = $certificado->verificar($body); 2710 if(!$validade) 2875 2876 $mail->Certs_crypt = $aux_mails; 2877 } 2878 2879 $attachment = json_decode($params['attachments'],TRUE); 2880 2881 foreach ($attachment as &$value) 2711 2882 { 2712 foreach($certificado->erros_ssl as $linha_erro)2883 if((int)$value > 0) //BD attachment 2713 2884 { 2714 $erros_acumulados .= $linha_erro; 2885 $att = Controller::read(array('id'=> $value , 'concept' => 'mailAttachment')); 2886 2887 if($att['disposition'] == 'embedded') 2888 { 2889 $body = str_replace('"../prototype/getArchive.php?mailAttachment='.$att['id'].'"', $att['name'], $body); 2890 $mailService->addStringImage(base64_decode($att['source']), $att['type'], $att['name']); 2891 } 2892 else 2893 $mailService->addStringAttachment(base64_decode($att['source']), $att['name'], $att['type'], 'base64', isset($att['disposition']) ? $att['disposition'] :'attachment' ); 2894 2895 unset($att); 2896 } 2897 else //message attachment 2898 { 2899 $value = json_decode($value, true); 2900 $sub = $value['name'] ? $value['name'].'.eml' :'no title.eml'; 2901 $mbox_stream = $this->open_mbox($value['folder']); 2902 $rawmsg = $this->getRawHeader($value['uid']) . "\r\n\r\n" . $this->getRawBody($value['uid']); 2903 $mailService->addStringAttachment($rawmsg, $sub, 'message/rfc822', '7bit', 'attachment' ); 2904 $message_size_total += mb_strlen($rawmsg); //Adiciona o tamanho do anexo a variavel que controlao tamanho da msg. 2905 unset($rawmsg); 2906 } 2907 2908 } 2909 2910 $message_size_total += strlen($params['body']); /* Tamanho do corpo da mensagem. */ 2911 2912 //////////////////////////////////////////////////////////////////////////////////////////////////// 2913 /** 2914 * Faz a validação pelo tamanho máximo de mensagem permitido para o usuário. Se o usuário não estiver em nenhuma regra, usa o tamanho padrão. 2915 */ 2916 $default_max_size_rule = $db->get_default_max_size_rule(); 2917 if (!$default_max_size_rule) { 2918 $default_max_size_rule = str_replace("M", "", ini_get('upload_max_filesize')) * 1024 * 1024; /* hack para não bloquear o envio de email quando não for configurado um tamanho padrão */ 2919 } else { 2920 foreach ($default_max_size_rule as $i => $value) { 2921 $default_max_size_rule = $value['config_value']; 2715 2922 } 2716 2923 } 2717 else 2718 { 2719 // Testa o CERTIFICADO: se o CPF he o do usuario logado, se pode assinar msgs e se nao esta expirado... 2720 if ($certificado->apresentado) 2721 { 2722 if($certificado->dados['EXPIRADO']) $erros_acumulados .='Certificado expirado.'; 2723 $this->cpf = isset($GLOBALS['phpgw_info']['server']['certificado_atributo_cpf'])&&$GLOBALS['phpgw_info']['server']['certificado_atributo_cpf']!=''?$_SESSION['phpgw_info']['expressomail']['user'][$GLOBALS['phpgw_info']['server']['certificado_atributo_cpf']]:$this->username; 2724 if($certificado->dados['CPF'] != $this->cpf) $erros_acumulados .=' CPF no certificado diferente do logado no expresso.'; 2725 if(!($certificado->dados['KEYUSAGE']['digitalSignature'] && $certificado->dados['EXTKEYUSAGE']['emailProtection'])) $erros_acumulados .=' Certificado nao permite assinar mensagens.'; 2726 } 2727 else 2728 { 2729 $$erros_acumulados .= 'Nao foi possivel usar o certificado para assinar a msg'; 2924 2925 $default_max_size_rule = $default_max_size_rule * 1024 * 1024; /* Tamanho da regra padrão, em bytes */ 2926 $id_user = $_SESSION['phpgw_info']['expressomail']['user']['userid']; 2927 2928 2929 $ldap = new ldap_functions(); 2930 $groups_user = $ldap->get_user_groups($id_user); 2931 2932 $size_rule_by_group = array(); 2933 foreach ($groups_user as $k => $value_) { 2934 $rule_in_group = $db->get_rule_by_user_in_groups($k); 2935 if ($rule_in_group != "") 2936 array_push($size_rule_by_group, $rule_in_group); 2937 } 2938 2939 $n_rule_groups = 0; 2940 $maior_valor_regra_grupo = 0; 2941 foreach ($size_rule_by_group as $i => $value) { 2942 if (is_array($value[0])) { 2943 $n_rule_groups++; 2944 if ($value[0]['email_max_recipient'] > $maior_valor_regra_grupo) 2945 $maior_valor_regra_grupo = $value[0]['email_max_recipient']; 2730 2946 } 2731 2947 } 2732 if(!$erros_acumulados =='') 2733 { 2734 return $erros_acumulados; 2735 } 2736 } 2737 else 2738 { 2739 //Compatibilização com Outlook, ao encaminhar a mensagem 2740 $body = mb_ereg_replace('<!--\[', '<!-- [', $params['body']); 2741 } 2742 2743 $attachments = $_FILES; 2744 $forwarding_attachments = $params['forwarding_attachments']; 2745 $local_attachments = $params['local_attachments']; 2746 2747 //Test if must be saved in shared folder and change if necessary 2748 if( $fromaddress[2] == 'y' ){ 2749 //build shared folder path 2750 $newfolder = "user".$this->imap_delimiter.$fromaddress[3].$this->imap_delimiter.$this->imap_sentfolder; 2751 if($this->folder_exists($newfolder)) 2752 $folder = $newfolder; 2753 else 2754 $folder = $params['folder']; 2755 2756 } else { 2757 $folder = $params['folder']; 2758 } 2759 2760 $folder = mb_convert_encoding($folder, 'UTF7-IMAP','ISO_8859-1'); 2761 $folder = preg_replace('/INBOX[\/.]/i', 'INBOX'.$this->imap_delimiter, $folder); 2762 $folder_name = $params['folder_name']; 2763 2764 // TODO - tratar assinatura e remover o AND false 2765 if($signed && !$params['smime'] AND false) 2766 { 2767 $mail->Mailer = "smime"; 2768 $mail->SignedBody = true; 2769 } 2770 2771 2772 if($fromaddress) 2773 $mailService->setFrom ('"'.$fromaddress[0].'" <'.$fromaddress[1].'>'); 2774 else 2775 $mailService->setFrom ('"'.$_SESSION['phpgw_info']['expressomail']['user']['firstname'].' '.$_SESSION['phpgw_info']['expressomail']['user']['lastname'].'" <'.$_SESSION['phpgw_info']['expressomail']['user']['email'].'>'); 2776 //$mailService->addTo($toaddress); 2777 //$mailService->addCc($ccaddress); 2778 $bol = $this->add_recipients('to', $toaddress, $mailService); 2779 if(!$bol){ 2780 return $this->parse_error("Invalid Mail:", $toaddress); 2781 } 2782 $bol = $this->add_recipients('cc', $ccaddress, $mailService); 2783 if(!$bol){ 2784 return $this->parse_error("Invalid Mail:", $ccaddress); 2785 } 2786 $allow = $_SESSION['phpgw_info']['server']['expressomail']['allow_hidden_copy']; 2787 2788 if($allow) 2789 { 2790 //$mailService->addBcc($ccoaddress); 2791 $bol = $this->add_recipients('cco', $ccoaddress, $mailService); 2792 2793 if(!$bol){ 2794 return $this->parse_error("Invalid Mail:", $ccoaddress); 2795 } 2796 } 2797 2798 //Implementação para o In-Reply-To e References 2799 $msg_numb = $params['messageNum']; 2800 $msg_folder = $params['messageFolder']; 2801 $this->mbox = $this->open_mbox($msg_folder); 2802 2803 $header = $this->get_header($msg_numb); 2804 $header_ = imap_fetchheader($this->mbox, $msg_numb, FT_UID); 2805 $pattern = '/^[ \t]*Disposition-Notification-To:[ ]*<?[[:alnum:]\._-]+@[[:alnum:]_-]+[\.[:alnum:]]+>?/sm'; 2806 if (preg_match($pattern, $header_, $fields)) 2807 { 2808 if(preg_match('/[[:alnum:]\._\-]+@[[:alnum:]_\-\.]+/',$fields[0], $matches)){ 2809 $return['DispositionNotificationTo'] = "<".$matches[0].">"; 2810 } 2811 } 2812 2813 $message_id = $header->message_id; 2814 $references = array(); 2815 if($message_id != "") 2816 { 2817 $mailService->addHeaderField('In-Reply-To',$message_id); 2818 2819 if(isset($header->references)){ 2820 array_push($references, $header->references); 2821 } 2822 array_push($references, $message_id); 2823 $mailService->addHeaderField('References',$references); 2824 2825 } 2826 2827 2828 $mailService->setSubject($subject); 2829 $isHTML = ( (array_key_exists('type', $params) && in_array(strtolower($params['type']), array('html', 'plain')) ) ? 2830 strtolower($params['type']) != 'plain' : true ); 2831 2832 2833 // TODO - tratar mensagem criptografada e remover o AND false abaixo 2834 if (($encrypt && $signed && $params['smime']) || ($encrypt && !$signed) AND false) // a msg deve ser enviada cifrada... 2835 { 2836 $email = $this->add_recipients_cert($toaddress . ',' . $ccaddress. ',' .$ccoaddress); 2837 $email = explode(",",$email); 2838 // Deve ser testado se foram obtidos os certificados de todos os destinatarios. 2839 // Deve ser verificado um numero limite de destinatarios. 2840 // Deve ser verificado se os certificados sao validos. 2841 // Se uma das verificacoes falhar, nao enviar o e-mail e avisar o usuario. 2842 // O array $mail->Certs_crypt soh deve ser preenchido se os certificados passarem nas verificacoes. 2843 $numero_maximo = $_SESSION['phpgw_info']['user']['preferences']['expressoMail']['num_max_certs_to_cipher']; // Este valor dever ser configurado pelo administrador do site .... 2844 $erros_acumulados = ""; 2845 $aux_mails = array(); 2846 $mail_list = array(); 2847 if(count($email) > $numero_maximo) 2848 { 2849 $erros_acumulados .= "Excedido o numero maximo (" . $numero_maximo . ") de destinatarios para uma msg cifrada...." . chr(0x0A); 2850 return $erros_acumulados; 2851 } 2852 // adiciona o email do remetente. eh para cifrar a msg para ele tambem. Assim vai poder visualizar a msg na pasta enviados.. 2853 $email[] = $_SESSION['phpgw_info']['expressomail']['user']['email']; 2854 foreach($email as $item) 2855 { 2856 $certificate = $db->get_certificate(strtolower($item)); 2857 if(!$certificate) 2858 { 2859 $erros_acumulados .= "Chamada com parametro invalido. e-Mail nao pode ser vazio." . chr(0x0A); 2860 return $erros_acumulados; 2948 2949 if ($default_max_size_rule) { 2950 $size_rule = $db->get_rule_by_user($_SESSION['phpgw_info']['expressomail']['user']['userid']); 2951 2952 if (!$size_rule && $n_rule_groups == 0) /* O usuário não está em nenhuma regra por usuário nem por grupo. Vai usar a regra padrão. */ { 2953 if ($message_size_total > $default_max_size_rule) 2954 return $this->functions->getLang("Message size greateruler than allowed (Default rule)"); 2861 2955 } 2862 2956 2863 if (array_key_exists("dberr1", $certificate)) 2864 { 2865 2866 $erros_acumulados .= "Ocorreu um erro quando pesquisava certificados dos destinatarios para cifrar a msg." . chr(0x0A); 2867 return $erros_acumulados; 2868 } 2869 if (array_key_exists("dberr2", $certificate)) 2870 { 2871 $erros_acumulados .= $item . ' : Nao pode cifrar a msg. Certificado nao localizado.' . chr(0x0A); 2872 //continue; 2873 } 2874 /* Retirado este teste para evitar mensagem de erro duplicada. 2875 if (!array_key_exists("certs", $certificate)) 2876 { 2877 $erros_acumulados .= $item . ' : Nao pode cifrar a msg. Certificado nao localizado.' . chr(0x0A); 2878 continue; 2879 } 2880 */ 2881 include_once(dirname( __FILE__ ) ."/../../security/classes/CertificadoB.php"); 2882 2883 foreach ($certificate['certs'] as $registro) 2884 { 2885 $c1 = new certificadoB(); 2886 $c1->certificado($registro['chave_publica']); 2887 if ($c1->apresentado) 2888 { 2889 $c2 = new Verifica_Certificado($c1->dados,$registro['chave_publica']); 2890 if (!$c1->dados['EXPIRADO'] && !$c2->revogado && $c2->status) 2891 { 2892 $aux_mails[] = $registro['chave_publica']; 2893 $mail_list[] = strtolower($item); 2957 else { 2958 if (count($size_rule) > 0) /* Verifica se existe regra por usuário. Se houver, ela vai se sobresair das regras por grupo. */ { 2959 $regra_mais_permissiva = 0; 2960 foreach ($size_rule as $i => $value) { 2961 if ($regra_mais_permissiva < $value['email_max_recipient']) 2962 $regra_mais_permissiva = $value['email_max_recipient']; 2894 2963 } 2895 else 2896 { 2897 if ($c1->dados['EXPIRADO'] || $c2->revogado) 2898 { 2899 $db->update_certificate($c1->dados['SERIALNUMBER'],$c1->dados['EMAIL'],$c1->dados['AUTHORITYKEYIDENTIFIER'], 2900 $c1->dados['EXPIRADO'],$c2->revogado); 2901 } 2902 2903 $erros_acumulados .= $item . ': ' . $c2->msgerro . chr(0x0A); 2904 foreach($c2->erros_ssl as $linha) 2905 { 2906 $erros_acumulados .= $linha . chr(0x0A); 2907 } 2908 $erros_acumulados .= 'Emissor: ' . $c1->dados['EMISSOR'] . chr(0x0A); 2909 $erros_acumulados .= $c1->dados['CRLDISTRIBUTIONPOINTS'] . chr(0x0A); 2910 } 2964 $regra_mais_permissiva = $regra_mais_permissiva * 1024 * 1024; 2965 if ($message_size_total > $regra_mais_permissiva) 2966 return $this->functions->getLang("Message size greater than allowed (Rule By User)"); 2911 2967 } 2912 else 2913 { 2914 $erros_acumulados .= $item . ' : Nao pode cifrar a msg. Certificado invalido.' . chr(0x0A); 2968 else /* Regra por grupo */ { 2969 $maior_valor_regra_grupo = $maior_valor_regra_grupo * 1024 * 1024; 2970 if ($message_size_total > $maior_valor_regra_grupo) 2971 return $this->functions->getLang("Message size greater than allowed (Rule By Group)"); 2915 2972 } 2916 2973 } 2917 if(!(in_array(strtolower($item),$mail_list)) && !empty($erros_acumulados))2918 {2919 return $erros_acumulados;2920 }2921 2974 } 2922 2923 $mail->Certs_crypt = $aux_mails; 2924 } 2925 2926 if( count($forwarding_attachments) > 0 )// Build CID images 2927 $this->buildEmbeddedImages($mailService,$msg_uid,$forwarding_attachments, $body); 2928 2929 // Build Uploading Attachments!!! 2930 if (count($attachments)>0) //Caso seja forward normal... 2931 { 2932 $total_uploaded_size = 0; 2933 foreach ($attachments as $attach) 2934 { 2935 if($attach['error'] == UPLOAD_ERR_INI_SIZE) 2936 return $this->parse_error("message file too big"); 2937 if($attach['name']=='Unknown') 2938 continue; 2939 $mailService->addFileAttachment($attach['tmp_name'], $attach['name'], $this->get_file_type($attach['name']), 'base64', 'attachment'); 2940 $total_uploaded_size = $total_uploaded_size + $attach['size']; 2941 } 2942 if($_SESSION['phpgw_info']['user']['preferences']['expressoMail']['max_attachment_size']) 2943 { 2944 2945 $upload_max_filesize = str_replace('M','',$_SESSION['phpgw_info']['user']['preferences']['expressoMail']['max_attachment_size']) * 1024 * 1024; 2946 if( $total_uploaded_size > $upload_max_filesize) 2947 return $this->parse_error("message file too big"); 2948 } 2949 } 2950 if(count($local_attachments)>0) { //Caso seja forward de mensagens locais 2951 2952 $total_uploaded_size = 0; 2953 2954 foreach($local_attachments as $local_attachment) { 2955 $file_description = unserialize(rawurldecode($local_attachment)); 2956 $tmp = array_values($file_description); 2957 foreach($file_description as $i => $descriptor){ 2958 $tmp[$i] = eregi_replace('\'*\'','',$descriptor); 2959 } 2960 $mailService->addFileAttachment($_FILES[$tmp[1]]['tmp_name'], $tmp[2], $this->get_file_type($tmp[2]), 'base64', 'attachment'); 2961 $total_uploaded_size = $total_uploaded_size + $_FILES[$tmp[1]]['size']; 2962 } 2963 if($_SESSION['phpgw_info']['user']['preferences']['expressoMail']['max_attachment_size']) 2964 { 2965 $upload_max_filesize = str_replace('M','',$_SESSION['phpgw_info']['user']['preferences']['expressoMail']['max_attachment_size']) * 1024 * 1024; 2966 if( $total_uploaded_size > $upload_max_filesize) 2967 return $this->parse_error("message file too big"); 2968 } 2969 } 2970 2971 // Build Forwarding Attachments!!! 2972 if (count($forwarding_attachments) > 0) 2973 { 2974 // Bug fixed for array_search function 2975 $name_cid_files = array(); 2976 if(count($name_cid_files) > 0) { 2977 $name_cid_files[count($name_cid_files)] = $name_cid_files[0]; 2978 $name_cid_files[0] = null; 2979 } 2980 2981 foreach($forwarding_attachments as $forwarding_attachment) 2982 { 2983 $file_description = unserialize(rawurldecode($forwarding_attachment)); 2984 2985 foreach($file_description as $i => $item) 2986 $file_description[$i] = urldecode($item); 2987 2988 $tmp = array_values($file_description); 2989 foreach($file_description as $i => $descriptor){ 2990 $tmp[$i] = eregi_replace('\'*\'','',$descriptor); 2991 } 2992 $file_description = $tmp; 2993 $fileContent = $this->get_forwarding_attachment($file_description[0], $file_description[1], $file_description[3],$file_description[4]); 2994 $fileName = $file_description[2]; 2995 if(!array_search(trim($fileName),$name_cid_files)) { 2996 $filename_dec = html_entity_decode(rawurldecode($fileName)); 2997 $mailService->addStringAttachment($fileContent, $filename_dec, $this->get_file_type($file_description[2]), $file_description[4] ); 2998 2999 } 3000 } 3001 } 3002 3003 //Build Message Attachments!!! 3004 if(count($message_attachments) > 0 ) 3005 { 3006 foreach($message_attachments as $folder_name => $messages) 3007 { 3008 foreach ($messages as $message_number => $message_subject) 3009 { 3010 if (!$message_subject) 3011 $message_subject = 'no title.eml'; 3012 else 3013 $message_subject .= '.eml'; 3014 3015 if( $message_attachments_contents && isset($message_attachments_contents[$folder_name]) ) 3016 $rawmsg = base64_decode( $message_attachments_contents[$folder_name][$message_number] ); 3017 else{ 3018 $mbox_stream = $this->open_mbox($folder_name); 3019 $rawmsg = $this->getRawHeader($message_number) . "\r\n\r\n" . $this->getRawBody($message_number); 3020 } 3021 3022 $return_forward[] = array( 'name' => $message_subject, 'size' => mb_strlen($rawmsg)); 3023 $mailService->addStringAttachment($rawmsg, $message_subject, 'message/rfc822', '7bit', 'attachment' ); 3024 } 3025 } 3026 } 3027 3028 $message_size_total += strlen($params['body']); /* Tamanho do corpo da mensagem. */ 3029 $message_size_total += $total_uploaded_size; /* Incrementa com os anexos da nova mensagem, se houver. */ 3030 3031 //////////////////////////////////////////////////////////////////////////////////////////////////// 3032 /** 3033 * Faz a validação pelo tamanho máximo de mensagem permitido para o usuário. Se o usuário não estiver em nenhuma regra, usa o tamanho padrão. 3034 */ 3035 $default_max_size_rule = $db->get_default_max_size_rule(); 3036 if(!$default_max_size_rule) 3037 { 3038 $default_max_size_rule = str_replace("M","",ini_get('upload_max_filesize')) * 1024 * 1024; /* hack para não bloquear o envio de email quando não for configurado um tamanho padrão */ 3039 } 3040 else 3041 { 3042 foreach($default_max_size_rule as $i=>$value) 3043 { 3044 $default_max_size_rule = $value['config_value']; 3045 } 3046 } 3047 3048 $default_max_size_rule = $default_max_size_rule * 1024 * 1024; /* Tamanho da regra padrão, em bytes */ 3049 $id_user = $_SESSION['phpgw_info']['expressomail']['user']['userid']; 3050 3051 3052 $ldap = new ldap_functions(); 3053 $groups_user = $ldap->get_user_groups($id_user); 3054 3055 $size_rule_by_group = array(); 3056 foreach($groups_user as $k=>$value_) 3057 { 3058 $rule_in_group = $db->get_rule_by_user_in_groups($k); 3059 if ($rule_in_group != "") 3060 array_push($size_rule_by_group, $rule_in_group); 3061 } 3062 3063 $n_rule_groups = 0; 3064 $maior_valor_regra_grupo = 0; 3065 foreach($size_rule_by_group as $i=>$value) 3066 { 3067 if(is_array($value[0])) 3068 { 3069 $n_rule_groups++; 3070 if($value[0]['email_max_recipient'] > $maior_valor_regra_grupo) 3071 $maior_valor_regra_grupo = $value[0]['email_max_recipient']; 3072 } 3073 } 3074 3075 if($default_max_size_rule) 3076 { 3077 $size_rule = $db->get_rule_by_user($_SESSION['phpgw_info']['expressomail']['user']['userid']); 3078 3079 if(!$size_rule && $n_rule_groups == 0) /* O usuário não está em nenhuma regra por usuário nem por grupo. Vai usar a regra padrão. */ 3080 { 3081 if($message_size_total > $default_max_size_rule) 3082 return $this->functions->getLang("Message size greateruler than allowed (Default rule)"); 3083 } 3084 3085 else 3086 { 3087 if(count($size_rule) > 0) /* Verifica se existe regra por usuário. Se houver, ela vai se sobresair das regras por grupo. */ 3088 { 3089 $regra_mais_permissiva = 0; 3090 foreach($size_rule as $i=>$value) 3091 { 3092 if($regra_mais_permissiva < $value['email_max_recipient']) 3093 $regra_mais_permissiva = $value['email_max_recipient']; 3094 } 3095 $regra_mais_permissiva = $regra_mais_permissiva * 1024 * 1024; 3096 if($message_size_total > $regra_mais_permissiva) 3097 return $this->functions->getLang("Message size greater than allowed (Rule By User)"); 3098 } 3099 else /* Regra por grupo */ 3100 { 3101 $maior_valor_regra_grupo = $maior_valor_regra_grupo * 1024 * 1024; 3102 if($message_size_total > $maior_valor_regra_grupo) 3103 return $this->functions->getLang("Message size greater than allowed (Rule By Group)"); 3104 3105 3106 } 3107 } 3108 } 3109 /** 3110 * Fim da validação do tamanho da regra do tamanho de mensagem. 3111 */ 3112 //////////////////////////////////////////////////////////////////////////////////////////////////// 3113 3114 3115 3116 3117 3118 if($isHTML) 3119 $mailService->setBodyHtml($body); 3120 else 3121 $mailService->setBodyText($body); 3122 3123 if($is_important) 3124 $mailService->addHeaderField('Importance','High'); 3125 3126 if($return_receipt) 3127 $mailService->addHeaderField('Disposition-Notification-To', $_SESSION['phpgw_info']['expressomail']['user']['email']); 3128 3129 3130 if ($folder != 'null'){ 3131 $mbox_stream = $this->open_mbox($folder); 3132 @imap_append($mbox_stream, "{".$this->imap_server.":".$this->imap_port."}".$folder, $mailService->getMessage(), "\\Seen"); 3133 } 3134 3135 $sent = $mailService->send(); 3136 3137 if($sent !== true) 3138 { 3139 return $this->parse_error($sent); 3140 } 3141 else 3142 { 3143 if ($signed && !$params['smime']) 3144 { 3145 return $sent; 3146 } 3147 if($_SESSION['phpgw_info']['server']['expressomail']['expressoMail_enable_log_messages'] == "True") 3148 { 3149 $userid = $_SESSION['phpgw_info']['expressomail']['user']['userid']; 3150 $userip = $_SESSION['phpgw_info']['expressomail']['user']['session_ip']; 3151 $now = date("d/m/y H:i:s"); 3152 $addrs = $toaddress.$ccaddress.$ccoaddress; 3153 $sent = trim($sent); 3154 error_log("$now - $userip - $sent [$subject] - $userid => $addrs\r\n", 3, "/home/expressolivre/mail_senders.log"); 3155 } 3156 if($_SESSION['phpgw_info']['user']['preferences']['expressoMail']['use_dynamic_contacts']) { 3157 $contacts = new dynamic_contacts(); 3158 $new_contacts = $contacts->add_dynamic_contacts($toaddress.",".$ccaddress.",".$ccoaddress); 3159 return array("success" => true, "new_contacts" => $new_contacts); 3160 } 3161 return array("success" => true); 3162 } 3163 } 2975 /** 2976 * Fim da validação do tamanho da regra do tamanho de mensagem. 2977 */ 2978 //////////////////////////////////////////////////////////////////////////////////////////////////// 2979 2980 if ($isHTML) 2981 $mailService->setBodyHtml($body); 2982 else 2983 $mailService->setBodyText($body); 2984 2985 if ($is_important) 2986 $mailService->addHeaderField('Importance', 'High'); 2987 2988 if ($return_receipt) 2989 $mailService->addHeaderField('Disposition-Notification-To', $_SESSION['phpgw_info']['expressomail']['user']['email']); 2990 2991 2992 if ($folder != 'null') { 2993 $mbox_stream = $this->open_mbox($folder); 2994 @imap_append($mbox_stream, "{" . $this->imap_server . ":" . $this->imap_port . "}" . $folder, $mailService->getMessage(), "\\Seen"); 2995 } 2996 2997 $sent = $mailService->send(); 2998 2999 if ($sent !== true) { 3000 return $this->parse_error($sent); 3001 } else { 3002 if ($signed && !$params['smime']) { 3003 return $sent; 3004 } 3005 if ($_SESSION['phpgw_info']['server']['expressomail']['expressoMail_enable_log_messages'] == "True") { 3006 $userid = $_SESSION['phpgw_info']['expressomail']['user']['userid']; 3007 $userip = $_SESSION['phpgw_info']['expressomail']['user']['session_ip']; 3008 $now = date("d/m/y H:i:s"); 3009 $addrs = $toaddress . $ccaddress . $ccoaddress; 3010 $sent = trim($sent); 3011 error_log("$now - $userip - $sent [$subject] - $userid => $addrs\r\n", 3, "/home/expressolivre/mail_senders.log"); 3012 } 3013 if ($_SESSION['phpgw_info']['user']['preferences']['expressoMail']['use_dynamic_contacts']) { 3014 $contacts = new dynamic_contacts(); 3015 $new_contacts = $contacts->add_dynamic_contacts($toaddress . "," . $ccaddress . "," . $ccoaddress); 3016 return array("success" => true, "new_contacts" => $new_contacts); 3017 } 3018 3019 if($params['uids_save'] ) 3020 $this->delete_msgs(array('folder'=> $params['save_folder'] , 'msgs_number' => $params['uids_save'])); 3021 3022 3023 return array("success" => true); 3024 3025 } 3026 } 3164 3027 3165 3028 3166 /**3167 * @license http://www.gnu.org/copyleft/gpl.html GPL3168 * @author Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br)3169 * @param $mail email3170 * @param $msg_uid uid da mensagem3171 * @param $forwarding_attachments anexos3172 */3173 3174 function buildEmbeddedImages(&$mail,$msg_uid,&$forwarding_attachments ,&$body)3175 {3176 //Procura e retorna em $cids_imgs imagens embarcadas no corpo do e-mail3177 $pattern = '/src=("[^"]*?get_archive.php\?msgFolder=(.+)?&(amp;)?msgNumber=(.+)?&(amp;)?indexPart=(.+)?")/isU';3178 $cid_imgs = '';3179 preg_match_all( $pattern , $body , $cid_imgs , PREG_PATTERN_ORDER );3180 //-------------------------------------------------------------------//3181 3182 $attPostions = array(); //Array que linka a possição da imagem com o indice que esta se encontra no array $forwarding_attachments3183 3184 foreach ($forwarding_attachments as $i => $v){ // Monta o array de link3185 $desc = unserialize(rawurldecode($v));3186 $attPostions[$desc[3]] = $i;3187 }3188 3189 //Intera as imagens encontradas3190 foreach($cid_imgs[6] as $j => $val)3191 {3192 $cid = base_convert(microtime().$j, 10, 36); //Gera um cid3193 $body = str_replace($cid_imgs[1][$j], '"cid:'.$cid.'"', $body ); //tira o src da imagem e coloca o cid.3194 $count = strlen($cid_imgs[6][$j]);3195 3196 $attach_img = $forwarding_attachments[$attPostions['\''.$cid_imgs[6][$j].'\'']];3197 $file_description = unserialize(rawurldecode($attach_img));3198 3199 if (is_array($file_description))3200 foreach($file_description as $i => $descriptor)3201 $file_description[$i] = mb_ereg_replace('\'*\'','',$descriptor);3202 3203 // The image is not in the same mail?3204 if ($msg_uid != $cid_imgs[4][$j])3205 {3206 $fa = $this->get_forwarding_attachment2($cid_imgs[2][$j], $cid_imgs[4][$j], $cid_imgs[6][$j], 'base64');3207 $fileContent = &$fa['binary'];3208 $fileName = $fa['name'];3209 $fileCode = $fa['encoding'];3210 $fileType = $fa['type'];3211 $file_attached[0] = $cid_imgs[2][$j];3212 $file_attached[1] = $cid_imgs[4][$j];3213 $file_attached[2] = $fileName;3214 $file_attached[3] = '0.'.(string)($j+1);3215 $file_attached[4] = 'base64';3216 $file_attached[5] = strlen($fileContent); //Size of file3217 $file_attached[6] = $cid_imgs[6][$j];3218 $return_forward[] = $file_attached;3219 3220 if ($file_attached[3] == $file_description[3] || $msg_uid == 'undefined')3221 unset($forwarding_attachments[$attPostions['\''.$cid_imgs[6][$j].'\'']]);3222 3223 }3224 else3225 {3226 $fileContent = $this->get_forwarding_attachment($file_description[0], $msg_uid, $file_description[3], 'base64');3227 $fileName = $file_description[2];3228 $fileCode = $file_description[4];3229 $file_description[3] = '0.'.(string)($j+1);3230 $file_description[6] = $cid_imgs[6][$j];3231 $fileType = $this->get_file_type($file_description[2]);3232 unset($forwarding_attachments[$attPostions['\''.$cid_imgs[6][$j].'\'']]);3233 if (!empty($file_description))3234 {3235 $file_description[5] = strlen($fileContent); //Size of file3236 $return_forward[] = $file_description;3237 }3238 }3239 3240 if ($fileContent)3241 $mail->addStringImage($fileContent,$fileType,$fileName, $cid);3242 }3243 3244 return $return_forward;3245 }3246 3029 function add_recipients_cert($full_address) 3247 3030 { … … 3664 3447 } 3665 3448 } 3666 3667 3668 function save_msg($params)3669 {3670 3671 require_once dirname(__FILE__) . '/../../services/class.servicelocator.php';3672 $mailService = ServiceLocator::getService('mail');3673 3674 $return_receipt = $params['input_return_receipt'];3675 $is_important = $params['input_important_message'];3676 3677 $msg_uid = $params['msg_id'];3678 $body = $params['body'];3679 $body = str_replace("%nbsp;"," ",$body);3680 $body = preg_replace("/\n/"," ",$body);3681 $body = preg_replace("/\r/","" ,$body);3682 $body = html_entity_decode ( $body, ENT_QUOTES , 'ISO-8859-1' );3683 $forwarding_attachments = $params['forwarding_attachments'];3684 $message_attachments = $params['message_attachments'];3685 $attachments = $params['FILES'];3686 $return_files = $params['FILES'];3687 $message_attachments_contents = (isset($params['message_attachments_content'])) ? $params['message_attachments_content'] : false;3688 3689 if(is_array($params['local_attachments'])){3690 foreach ($params['local_attachments'] as $key => $local_attach) {3691 $tmp = unserialize(urldecode($local_attach));3692 $attachments[$key]['name'] = urldecode($tmp[2]);3693 $return_files[$key]['name'] = urldecode($tmp[2]);3694 }3695 }3696 3697 $folder = mb_convert_encoding($params['folder'], "UTF7-IMAP","ISO-8859-1, UTF-8");3698 $folder = @eregi_replace("INBOX[/.]", "INBOX".$this->imap_delimiter, $folder);3699 3700 $mailService->setFrom ('"'.$fromaddress[0].'" <'.$fromaddress[1].'>');3701 $mailService->addTo($params['input_to']);3702 $mailService->addCc( $params['input_cc']);3703 $mailService->addBcc($params['input_cco']);3704 $mailService->setSubject($params['input_subject']);3705 3706 if($is_important){3707 $mailService->addHeaderField('Importance','High');3708 }3709 3710 if($return_receipt)3711 $mailService->addHeaderField('Disposition-Notification-To', $_SESSION['phpgw_info']['expressomail']['user']['email']);3712 3713 $isHTML = ( ( array_key_exists( 'type', $params ) && in_array( strtolower( $params[ 'type' ] ), array( 'html', 'plain' ) ) ) ? strtolower( $params[ 'type' ] ) != 'plain' : true );3714 3715 3716 if( count($forwarding_attachments) > 0 )3717 $return_forward = $this->buildEmbeddedImages($mailService, $msg_uid, $forwarding_attachments , $body);3718 3719 //Build Message Attachments!!!3720 if(count($message_attachments) > 0 )3721 {3722 foreach($message_attachments as $folder_name => $messages)3723 {3724 foreach ($messages as $message_number => $message_subject)3725 {3726 if (!$message_subject)3727 $message_subject = 'no title.eml';3728 else3729 $message_subject .= '.eml';3730 3731 if( $message_attachments_contents && isset($message_attachments_contents[$folder_name]) )3732 $rawmsg = base64_decode( $message_attachments_contents[$folder_name][$message_number] );3733 else{3734 $mbox_stream = $this->open_mbox($folder_name);$mbox_stream = $this->open_mbox($folder_name);3735 $rawmsg = $this->getRawHeader($message_number) . "\r\n\r\n" . $this->getRawBody($message_number);3736 }3737 3738 $return_forward[] = array( 'name' => $message_subject, 'size' => mb_strlen($rawmsg));3739 $mailService->addStringAttachment($rawmsg, $message_subject, 'message/rfc822', '7bit', 'attachment' );3740 }3741 }3742 }3743 3744 $imagesParts = array();3745 3746 if(count($return_forward) > 0 )3747 foreach ($return_forward as $value)3748 $imagesParts[$value[6]] = $value[3];3749 3750 //Build Forwarding Attachments!!!3751 if(count($forwarding_attachments) > 0 )3752 {3753 foreach($forwarding_attachments as $forwarding_attachment)3754 {3755 3756 $file_description = unserialize(rawurldecode($forwarding_attachment));3757 foreach($file_description as $i => $item)3758 $file_description[$i] = urldecode($item);3759 3760 $file_description = array_values($file_description);3761 3762 foreach($file_description as $i => $descriptor)3763 $file_description[$i] = eregi_replace('\'*\'','',$descriptor);3764 3765 $fileContent = $this->get_forwarding_attachment($file_description[0], $file_description[1], $file_description[3],$file_description[4]);3766 $file_description[2] = html_entity_decode($file_description[2]);3767 3768 $file_description[5] = strlen($fileContent); //Size of file3769 $return_forward[] = $file_description;3770 $mailService->addStringAttachment($fileContent, $file_description[2], $this->get_file_type($file_description[2]), $file_description[4] );3771 }3772 }3773 3774 if ((count($return_forward) > 0) && (count($return_files) > 0))3775 $return_files = array_merge_recursive($return_forward,$return_files);3776 else if (count($return_files) < 1)3777 $return_files = $return_forward;3778 3779 //Build Uploading Attachments!!!3780 $sizeof_attachments = count($attachments);3781 if ($sizeof_attachments)3782 foreach ($attachments as $numb => $attach)3783 $mailService->addFileAttachment($attach['tmp_name'], $attach['name'],$attach['type'], 'base64', 'attachment');3784 3785 3786 if (!$body)3787 $body = ' ';3788 3789 if($isHTML)3790 $mailService->setBodyHtml($body);3791 else3792 $mailService->setBodyText($body);3793 3794 3795 $mbox_stream = $this->open_mbox($folder);3796 $return['append'] = imap_append($mbox_stream, "{".$this->imap_server.":".$this->imap_port."}".$folder, $mailService->getMessage(), "\\Seen \\Draft");3797 3798 $status = imap_status($mbox_stream, "{".$this->imap_server.":".$this->imap_port."}".$folder, SA_UIDNEXT);3799 $return['msg_no'] = $status->uidnext - 1;3800 $return['folder_id'] = $folder;3801 $return['imagesParts'] = $imagesParts;3802 3803 if($mbox_stream)3804 imap_close($mbox_stream);3805 3806 $returnFiles = array();3807 $ii = 0;3808 3809 if(count($return_files) > 0)3810 {3811 foreach ($return_files as $index => $_attachment)3812 {3813 if (array_key_exists("name", $_attachment))3814 {3815 $returnFiles[$ii]['name'] = base64_encode(mb_convert_encoding( $_attachment['name'], 'UTF-8', 'UTF-8, ISO-8859-1') );3816 $returnFiles[$ii]['size'] = $_attachment['size'];3817 $ii++;3818 }3819 else if($_attachment[2])3820 {3821 $returnFiles[$ii]['name'] = base64_encode(mb_convert_encoding( $_attachment[2], 'UTF-8', 'UTF-8, ISO-8859-1'));3822 $returnFiles[$ii]['size'] = $_attachment[5];3823 $ii++;3824 }3825 }3826 }3827 $return['files'] = serialize($returnFiles);3828 $return["subject"] = $params['input_subject'];3829 if (!$return['append']) $return['append'] = imap_last_error();3830 3831 return $return;3832 }3833 3834 3449 3835 3450 function set_messages_flag_from_search($params){ -
trunk/expressoMail1_2/index.php
r5539 r5604 12 12 $GLOBALS['phpgw_info']['flags'] = array( 13 13 'noheader' => False, 14 'nonavbar' => False,14 'nonavbar' => false, 15 15 'currentapp' => 'expressoMail1_2', 16 16 'enable_nextmatchs_class' => True … … 391 391 <link rel='stylesheet' type='text/css' href='../prototype/modules/calendar/css/layout.css' /> 392 392 <link rel='stylesheet' type='text/css' href='../prototype/modules/calendar/css/style.css' /> 393 393 <link rel='stylesheet' type='text/css' href='../prototype/plugins/fileupload/jquery.fileupload-ui.css' /> 394 <script src="../prototype/plugins/fileupload/jquery.fileupload.js"></script> 395 <script src="../prototype/plugins/fileupload/jquery.iframe-transport.js"></script> 394 396 </body> 395 397 </html> -
trunk/expressoMail1_2/js/abas.js
r5602 r5604 3 3 var countBorders = 0; 4 4 var partMsgs = new Array(); 5 5 var msgAttachments = new Array(); 6 var imgAttachmentFlag = new Array(); 7 var uidsSave = new Array(); 6 8 7 9 function setBorderAttributes(ID) … … 151 153 152 154 borderTitle = ( ( borderTitle && borderTitle.constructor == String && borderTitle.length > 0 ) ? borderTitle : ' ' ); 153 155 154 156 var resize = false; 155 157 resize = resize_borders(); … … 335 337 Element("exmail_main_body").insertBefore(div,Element("footer_menu")); 336 338 alternate_border(ID); 339 uidsSave[ID] = []; 337 340 return ID; 338 341 } … … 498 501 { 499 502 openTab.toPreserve[ID] = false; 500 openTab.imapUid[ID] = 0;501 502 503 // Limpa o autosave 503 504 if (preferences.auto_save_draft == 1 && autoSaveControl.timer[ID] !== null ) … … 579 580 } 580 581 } 582 583 function addAttachment(ID, att) 584 { 585 if(typeof(msgAttachments[ID]) == 'undefined') 586 msgAttachments[ID] = []; 587 588 msgAttachments[ID].push(att); 589 } 590 591 function delAttachment(ID, att) 592 { 593 594 if(msgAttachments[ID] == undefined) return; 595 var len = msgAttachments[ID].length; 596 for(var i = 0; i < len; i++) 597 { 598 if(msgAttachments[ID][i] == att) 599 { 600 msgAttachments[ID].splice(i,1); 601 break; 602 } 603 } 604 } 605 606 function listAttachment(ID) 607 { 608 return (typeof(msgAttachments[ID]) == 'undefined') ? '' : JSON.stringify(msgAttachments[ID]); 609 } 610 -
trunk/expressoMail1_2/js/draw_api.js
r5600 r5604 1341 1341 return $(DataLayer.render('../prototype/modules/mail/templates/draggin_box.ejs', {texto : $(this).find(".td_msg_subject").text(), type: "messages"})); 1342 1342 }, 1343 cursorAt: { cursor: "move", top: 5, left: 56},1343 cursorAt: {cursor: "move", top: 5, left: 56}, 1344 1344 refreshPositions: true , 1345 1345 scroll: true, … … 2966 2966 ['=', 'folderName', current_folder], 2967 2967 ['=','messageNumber',folder_id]], 2968 criteria : { deepness: 2}});2968 criteria : {deepness: 2}} ); 2969 2969 2970 2970 if(labels.length != 0){ … … 3421 3421 var form = document.createElement("FORM"); 3422 3422 form.name = "form_message_"+ID; 3423 form.id = "form_message_"+ID; 3423 3424 form.method = "POST"; 3425 form.action = "message:detail"; 3424 3426 form.onsubmit = function(){return false;} 3425 3427 if(!is_ie) … … 3427 3429 else 3428 3430 form.encoding="multipart/form-data"; 3431 3432 var aba_id = document.createElement("INPUT"); 3433 aba_id.style.display='none'; 3434 aba_id.name = "abaID"; 3435 aba_id.value = ID; 3436 form.appendChild(aba_id); 3429 3437 ///////////////////////////////////////////////////////////////////////////////////////////////////////// 3430 3438 //ConstructMenuNewMessage(ID); … … 4007 4015 }; 4008 4016 4009 var add_files = document.createElement("A"); 4010 add_files.setAttribute("href", "javascript:void(0)"); 4011 add_files.onclick = function () { 4012 var obj = addFile(ID); 4013 if (preferences.auto_save_draft == 1 && obj) { 4014 if ( obj.addEventListener ){ 4015 obj.addEventListener('click', save_onchange_attachment_handler, false); 4016 } 4017 } 4018 return false; 4019 }; 4020 4021 add_files.innerHTML = get_lang("Attachments: add+"); 4022 add_files.setAttribute("tabIndex","-1"); 4023 4024 var add_msgs = document.createElement("A"); 4025 add_msgs.setAttribute("href", "javascript:void(0)"); 4026 add_msgs.setAttribute("tabIndex","-1"); 4027 is_ie ? add_msgs.setAttribute("className", 'message-attach-link') : add_msgs.setAttribute("class", 'message-attach-link'); 4028 add_msgs.innerHTML = get_lang("Messages: add+"); 4029 var divfiles = document.createElement("DIV"); 4030 divfiles.id = "divFiles_"+ID; 4031 4032 jQuery(add_msgs).click(function(event){ 4017 4018 var tr5 = document.createElement("TR"); 4019 var td5_link = document.createElement("TD"); 4020 var td5_input = document.createElement("TD"); 4021 td5_input.innerHTML = " " 4022 td5_link.setAttribute("valign","top"); 4023 $(td5_link).append('<div id="message-attach-dialog" title="'+get_lang('Select messages to attach...')+'"> </div>'); 4024 $(td5_link).prepend(DataLayer.render("../prototype/modules/mail/templates/attachment.ejs", {ID:ID})); 4025 tr5.appendChild(td5_input); 4026 tr5.appendChild(td5_link); 4027 4028 tbody_message.appendChild(tr5); 4029 var tr6 = document.createElement("TR"); 4030 var td6_link = document.createElement("TD"); 4031 var td6_input = document.createElement("TD"); 4032 tr6.appendChild(td6_link); 4033 4034 tr6.appendChild(td6_input); 4035 tbody_message.appendChild(tr6); 4036 4037 var tr7 = document.createElement("TR"); 4038 //var td5 = document.createElement("TD"); 4039 //td5.innerHTML = " "; 4040 var td_body = document.createElement("TD"); 4041 td_body.setAttribute("colSpan","2"); 4042 var div_body_position = document.createElement("DIV"); 4043 div_body_position.id = "body_position_" + ID; 4044 td_body.appendChild(div_body_position); 4045 //tr5.appendChild(td5); 4046 tr7.appendChild(td_body); 4047 tbody_message.appendChild(tr7); 4048 var _div = document.createElement("DIV"); 4049 _div.id = "div_message_scroll_"+ID; 4050 _div.style.overflow = "auto"; 4051 _div.style.width = "100%"; 4052 4053 // Hide the contac tips and re-position the pallete color. 4054 _div.onscroll = function() { 4055 var intElemScrollTop = Element("div_message_scroll_"+ID).scrollTop; 4056 if (!is_ie) 4057 ColorPalette.repos(intElemScrollTop); 4058 Tooltip.scrollChanged(); 4059 }; 4060 ////////////////////////////////////////////////////////////////////////////////////////////////////// 4061 _div.appendChild(form); 4062 content.appendChild(_div); 4063 table_message.appendChild(tbody_message); 4064 form.appendChild(table_message); 4065 4066 var attDisposition = document.createElement("INPUT"); 4067 attDisposition.style.display='none'; 4068 attDisposition.id = 'attDisposition'+ID; 4069 attDisposition.name = 'attDisposition'+ID; 4070 attDisposition.value = 'attachment'; 4071 form.appendChild(attDisposition); 4072 4073 RichTextEditor.loadEditor(ID); 4074 4075 var rich_button = document.createElement("button"); 4076 4077 if(preferences.plain_text_editor == 1){ 4078 var texto = get_lang("Rich Text"); 4079 }else{ 4080 var texto = get_lang("Simple Text"); 4081 } 4082 4083 rich_button.innerHTML = texto; 4084 rich_button.className = "button small rich-button"; 4085 rich_button.name = "textplain_rt_checkbox_"+ID; 4086 4087 ////////////////////////////////////////////////////////////////////////////////////////////////////// 4088 if(!expresso_offline) 4089 draw_from_field(sel_from,tr1_1); 4090 4091 resizeWindow(); 4092 4093 if ( ! expresso_offline ) 4094 { 4095 if ( mobile_device ) 4096 { 4097 text_plain.click( ); 4098 text_plain.parentNode.style.display = 'none'; 4099 } 4100 } 4101 //var a_cc_link2 = document.createElement("button"); 4102 4103 $("#another_adress_"+ID).append(a_cc_link); 4104 4105 if(a_cco_link != undefined) 4106 $("#another_adress_"+ID).append(a_cco_link); 4107 4108 $("#another_adress_"+ID).append(rich_button); 4109 4110 $("#to_"+ID).elastic().unbind('blur'); 4111 $(".another_adress").button(); 4112 $(".rich-button").button(); 4113 $(".rich-button").click(function(){ 4114 //TO-DO : Se o usuário clicar varias vezes no botão, a função de iniciar o ckeditor se perde e morre. 4115 $(this).button({disabled: true}); 4116 if($(this).find("span:first-child").html() == get_lang("Rich text")){ 4117 $(this).find("span:first-child").html(get_lang("Simple Text")); 4118 }else{ 4119 $(this).find("span:first-child").html(get_lang("Rich Text")); 4120 } 4121 4122 var check = $("#"+$(this).attr("name")).attr("checked"); 4123 $("#"+$(this).attr("name")).attr("checked", (!check ? true : false)); 4124 $("#"+$(this).attr("name")).trigger('click'); 4125 $("#"+$(this).attr("name")).attr("checked", (!check ? true : false)); 4126 //$(this).button({ disabled: false }); 4127 if (RichTextEditor.plain[id] != true) 4128 setTimeout("RichTextEditor.focus("+ID+")",100); 4129 else 4130 $('#body_'+ID).focus(); 4131 }); 4132 4133 if($("#send_and_custom_save_"+ID)[0]) 4134 $("#send_and_custom_save_"+ID).button({ 4135 icons : { 4136 primary :"expressomail-icon-save_and_send" 4137 } 4138 }) 4139 $("#content_id_"+ID).find(".adress_button").button().click(function(){ 4140 emQuickSearch($("#"+($(this).attr("name"))+"_"+ID).val(), $(this).attr("name"), ID, undefined, true); 4141 }); 4142 4143 $("#send_button_"+ID).button({ 4144 icons : { 4145 primary : "expressomail-icon-send" 4146 } 4147 }).next().button({ 4148 icons : { 4149 primary : "expressomail-icon-save" 4150 } 4151 }); 4152 $("#content_id_"+ID).find("[name=return_receipt_"+ID+"]").button({ 4153 icons : { 4154 primary : "expressomail-icon-read-confirmation" 4155 } 4156 }); 4157 $("#important_message_options_"+ID).button({ 4158 icons : { 4159 primary : "expressomail-icon-important" 4160 } 4161 }); 4162 $("#return_digital_options_"+ID).button({ 4163 icons : { 4164 primary : "expressomail-icon-signature" 4165 } 4166 }); 4167 $("#return_cripto_options_"+ID).button({ 4168 icons : { 4169 primary : "expressomail-icon-encryption" 4170 } 4171 }); 4172 4173 $("#content_id_"+ID).find(".send_option").click(function(){ 4174 var check = $("#"+$(this).attr("name")).attr("checked"); 4175 $("#"+$(this).attr("name")).attr("checked", (!check ? true : false)); 4176 $(this).toggleClass("expressomail-button-icon-ative"); 4177 }); 4178 4179 var fileUploadMSG = $('#fileupload_msg'+ID); 4180 var maxAttachmentSise = (preferences.max_attachment_size !== "" && preferences.max_attachment_size != 0) ? (parseInt(preferences.max_attachment_size.replace('M', '')) * 1048576 ) : false; 4181 4182 fileUploadMSG.fileupload({ 4183 sequentialUploads: true, 4184 add: function (e, data) { 4185 if(!maxAttachmentSise || data.files[0].size < maxAttachmentSise) { 4186 setTimeout(function() { 4187 $('#attDisposition'+ID).val('attachment'); 4188 data.submit(); 4189 }, 5000); 4190 } 4191 }, 4192 change: function (e, data) { 4193 $.each(data.files, function (index, file) { 4194 var attach = {}; 4195 attach.fullFileName = file.name; 4196 attach.fileName = file.name; 4197 if(file.name.length > 10) 4198 attach.fileName = file.name.substr(0, 18) + "..." + file.name.substr(file.name.length-9, file.name.length); 4199 attach.fileSize = formatBytes(file.size); 4200 if(maxAttachmentSise && file.size > maxAttachmentSise) 4201 attach.error = 'Tamanho de arquivo nao permitido!!' 4202 4203 fileUploadMSG.find('.attachments-list').append(DataLayer.render("../prototype/modules/mail/templates/attachment_add_itemlist.ejs", {file : attach})); 4204 4205 if(!maxAttachmentSise || file.size < maxAttachmentSise){ 4206 fileUploadMSG.find('.fileinput-button.new').append(data.fileInput[0]).removeClass('new'); 4207 fileUploadMSG.find('.attachments-list').find('[type=file]').addClass('hidden'); 4208 }else 4209 fileUploadMSG.find(' .fileinput-button.new').removeClass('new'); 4210 4211 fileUploadMSG.find(' .attachments-list').find('.button.close').button({ 4212 icons: { 4213 primary: "ui-icon-close" 4214 }, 4215 text: false 4216 }).click(function(){ 4217 var idAttach = $(this).parent().find('input[name="fileId[]"]').val(); 4218 fileUploadMSG.find(' .attachments-list').find('input[value="'+idAttach+'"]').remove(); 4219 delAttachment(ID, idAttach) 4220 $(this).parent().remove(); 4221 }); 4222 4223 })}, 4224 4225 done: function(e, data){ 4226 if(!!data.result && data.result != "[]"){ 4227 var newAttach = jQuery.parseJSON(data.result); 4228 fileUploadMSG.find('.in-progress:first').parents('p').append('<input type="hidden" name="fileId[]" value="'+newAttach['mailAttachment'][0][0].id+'"/>'); 4229 addAttachment(ID,newAttach['mailAttachment'][0][0].id); 4230 4231 }else { 4232 fileUploadMSG.find(' .progress.on-complete:first').removeClass('on-complete').parents('p').find('.status-upload').addClass('ui-icon ui-icon-cancel'); 4233 } 4234 fileUploadMSG.find(' .in-progress:first').remove(); 4235 4236 4237 } 4238 }); 4239 4240 fileUploadMSG.find("span.message-attach-link").click(function(event){ 4033 4241 jQuery('#message-attach-dialog').html(DataLayer.render("../prototype/modules/attach_message/attach_message.ejs", {})); 4034 4242 jQuery('#message-attach-dialog').dialog({ … … 4043 4251 jQuery.getScript("../prototype/modules/attach_message/attach_message.js", function(){ 4044 4252 jQuery('#message-attach-dialog').dialog('open'); 4045 4046 4253 jQuery('#message-attach-attach-btn').click(function(event){ 4047 //alert(dump(selectedMessages));../4048 4254 jQuery.each(selectedMessages, function(folder_name, messages) { 4049 4050 var isOffline = /^local_messages/.test(folder_name);4051 4052 4255 jQuery.each(selectedMessages[folder_name], function(message_number, message) { 4053 4256 if (message) { 4054 var subject = onceOpenedMessages[folder_name][message_number].subject; 4055 var text_input = '<input type="text" name="message_attachments['+folder_name+']['+message_number+']" value="'+subject+'"/>'; 4056 text_input += '<a href="javascript:void(0)" onclick="javascript:this.parentNode.parentNode.removeChild(this.parentNode);">' + get_lang("Remove")+'</a>'; 4057 if( isOffline ) 4058 text_input += '<input type="hidden" name="message_attachments_content['+folder_name+']['+message_number+']" value="'+Base64.encode( onceOpenedMessages[folder_name][message_number].eml )+'"/>'; 4059 jQuery(divfiles).append('<div>'+text_input+'</div>'); 4257 var att = new Object(); 4258 att.foder = folder_name; 4259 att.uid = message_number; 4260 att.name = onceOpenedMessages[folder_name][message_number].subject + '.eml'; 4261 var idATT = JSON.stringify(att); 4262 addAttachment( ID , idATT); 4263 var attach = {}; 4264 attach.fileName = att.name 4265 attach.fileSize = formatBytes(onceOpenedMessages[folder_name][message_number].size); 4266 var upload = $(DataLayer.render("../prototype/modules/mail/templates/attachment_add_itemlist.ejs", {file : attach})); 4267 upload.find('.status-upload').remove(); 4268 upload.find('.in-progress').remove(); 4269 upload.find('p').append('<input type="hidden" name="fileId[]" value=\''+idATT+'\'/>'); 4270 fileUploadMSG.find('.attachments-list').append(upload); 4271 4060 4272 } 4061 4273 … … 4064 4276 4065 4277 jQuery('#message-attach-dialog').dialog('close'); 4278 4279 //botao fechar 4280 $('.attachments-list').find('.button.close').button({ 4281 icons: { 4282 primary: "ui-icon-close" 4283 }, 4284 text: false 4285 }).click(function(){ 4286 var idAttach = $(this).parent().find('input[name="fileId[]"]').val(); 4287 fileUploadMSG.find(' .attachments-list').find('input[value="'+idAttach+'"]'); 4288 delAttachment(ID,idAttach); 4289 $(this).parent().remove(); 4290 }); 4291 4066 4292 }); 4067 4293 jQuery('#message-attach-cancel-btn').click(function(event){ 4068 4294 jQuery('#message-attach-dialog').dialog('close'); 4069 }); 4295 }); 4070 4296 }); 4297 4071 4298 }); 4072 var tr5 = document.createElement("TR"); 4073 var td5_link = document.createElement("TD"); 4074 var td5_input = document.createElement("TD"); 4075 td5_input.innerHTML = " " 4076 //td5_input.style.width = "1%"; 4077 td5_link.setAttribute("valign","top"); 4078 //td5_link.setAttribute("colSpan","2"); 4079 td5_link.appendChild(add_files); 4080 td5_link.appendChild(add_msgs); 4081 $(td5_link).append('<div id="message-attach-dialog" title="'+get_lang('Select messages to attach...')+'"> </div>'); 4082 tr5.appendChild(td5_input); 4083 tr5.appendChild(td5_link); 4084 tbody_message.appendChild(tr5); 4085 var tr6 = document.createElement("TR"); 4086 var td6_link = document.createElement("TD"); 4087 var td6_input = document.createElement("TD"); 4088 //td6_link.style.width = "1%"; 4089 tr6.appendChild(td6_link); 4090 td6_input.appendChild(divfiles); 4091 tr6.appendChild(td6_input); 4092 tbody_message.appendChild(tr6); 4093 ////////////////////////////////////////////////////////////////////////////////////////////////////// 4094 var tr5 = document.createElement("TR"); 4095 //var td5 = document.createElement("TD"); 4096 //td5.innerHTML = " "; 4097 var td_body = document.createElement("TD"); 4098 td_body.setAttribute("colSpan","2"); 4099 var div_body_position = document.createElement("DIV"); 4100 div_body_position.id = "body_position_" + ID; 4101 td_body.appendChild(div_body_position); 4102 //tr5.appendChild(td5); 4103 tr5.appendChild(td_body); 4104 tbody_message.appendChild(tr5); 4105 var _div = document.createElement("DIV"); 4106 _div.id = "div_message_scroll_"+ID; 4107 _div.style.overflow = "auto"; 4108 _div.style.width = "100%"; 4109 4110 // Hide the contac tips and re-position the pallete color. 4111 _div.onscroll = function() { 4112 var intElemScrollTop = Element("div_message_scroll_"+ID).scrollTop; 4113 if (!is_ie) 4114 ColorPalette.repos(intElemScrollTop); 4115 Tooltip.scrollChanged(); 4116 }; 4117 ////////////////////////////////////////////////////////////////////////////////////////////////////// 4118 _div.appendChild(form); 4119 content.appendChild(_div); 4120 table_message.appendChild(tbody_message); 4121 form.appendChild(table_message); 4122 RichTextEditor.loadEditor(ID); 4123 4124 var rich_button = document.createElement("button"); 4125 4126 if(preferences.plain_text_editor == 1){ 4127 var texto = get_lang("Rich Text"); 4128 }else{ 4129 var texto = get_lang("Simple Text"); 4130 } 4131 4132 rich_button.innerHTML = texto; 4133 rich_button.className = "button small rich-button"; 4134 rich_button.name = "textplain_rt_checkbox_"+ID; 4135 4136 ////////////////////////////////////////////////////////////////////////////////////////////////////// 4137 if(!expresso_offline) 4138 draw_from_field(sel_from,tr1_1); 4139 4140 resizeWindow(); 4141 4142 if ( ! expresso_offline ) 4143 { 4144 if ( mobile_device ) 4145 { 4146 text_plain.click( ); 4147 text_plain.parentNode.style.display = 'none'; 4148 } 4149 } 4150 //var a_cc_link2 = document.createElement("button"); 4151 4152 $("#another_adress_"+ID).append(a_cc_link); 4153 4154 if(a_cco_link != undefined) 4155 $("#another_adress_"+ID).append(a_cco_link); 4156 4157 $("#another_adress_"+ID).append(rich_button); 4158 4159 $("#to_"+ID).elastic().unbind('blur'); 4160 //$(".mail_fields"); 4161 //$(".mail_fields").css("width","100%"); 4162 4163 $(".another_adress").button(); 4164 $(".rich-button").button(); 4165 $(".rich-button").click(function(){ 4166 //TO-DO : Se o usuário clicar varias vezes no botão, a função de iniciar o ckeditor se perde e morre. 4167 $(this).button({disabled: true}); 4168 if($(this).find("span:first-child").html() == get_lang("Rich text")){ 4169 $(this).find("span:first-child").html(get_lang("Simple Text")); 4170 }else{ 4171 $(this).find("span:first-child").html(get_lang("Rich Text")); 4172 } 4173 4174 var check = $("#"+$(this).attr("name")).attr("checked"); 4175 $("#"+$(this).attr("name")).attr("checked", (!check ? true : false)); 4176 $("#"+$(this).attr("name")).trigger('click'); 4177 $("#"+$(this).attr("name")).attr("checked", (!check ? true : false)); 4178 //$(this).button({ disabled: false }); 4179 if (RichTextEditor.plain[id] != true) 4180 setTimeout("RichTextEditor.focus("+ID+")",100); 4181 else 4182 $('#body_'+ID).focus(); 4183 }); 4184 4185 if($("#send_and_custom_save_"+ID)[0]) 4186 $("#send_and_custom_save_"+ID).button({ 4187 icons : { 4188 primary :"expressomail-icon-save_and_send" 4189 } 4190 }) 4191 $("#content_id_"+ID).find(".adress_button").button().click(function(){ 4192 emQuickSearch($("#"+($(this).attr("name"))+"_"+ID).val(), $(this).attr("name"), ID, undefined, true); 4193 }); 4194 4195 $("#send_button_"+ID).button({ 4196 icons : { 4197 primary : "expressomail-icon-send" 4198 } 4199 }).next().button({ 4200 icons : { 4201 primary : "expressomail-icon-save" 4202 } 4203 }); 4204 $("#content_id_"+ID).find("[name=return_receipt_"+ID+"]").button({ 4205 icons : { 4206 primary : "expressomail-icon-read-confirmation" 4207 } 4208 }); 4209 $("#important_message_options_"+ID).button({ 4210 icons : { 4211 primary : "expressomail-icon-important" 4212 } 4213 }); 4214 $("#return_digital_options_"+ID).button({ 4215 icons : { 4216 primary : "expressomail-icon-signature" 4217 } 4218 }); 4219 $("#return_cripto_options_"+ID).button({ 4220 icons : { 4221 primary : "expressomail-icon-encryption" 4222 } 4223 }); 4224 4225 $("#content_id_"+ID).find(".send_option").click(function(){ 4226 var check = $("#"+$(this).attr("name")).attr("checked"); 4227 $("#"+$(this).attr("name")).attr("checked", (!check ? true : false)); 4228 $(this).toggleClass("expressomail-button-icon-ative"); 4229 }); 4230 4299 // 4231 4300 return ID; 4232 4301 } -
trunk/expressoMail1_2/js/main.js
r5588 r5604 277 277 var save_link = Element("save_message_options_"+border_id); 278 278 save_link.onclick = function onclick(event) {openTab.toPreserve[border_id] = true;save_msg(border_id);} ; 279 $("#save_message_options_"+border_id).button({ disabled: false});279 $("#save_message_options_"+border_id).button({disabled: false}); 280 280 $(".header-button").button(); 281 281 }; … … 580 580 return $(DataLayer.render('../prototype/modules/mail/templates/draggin_box.ejs', {texto : $(this).find(".td_msg_subject").text(), type: "messages"})); 581 581 }, 582 cursorAt: { cursor: "move", top: 5, left: 56},582 cursorAt: {cursor: "move", top: 5, left: 56}, 583 583 refreshPositions: true , 584 584 scroll: true, … … 1805 1805 case "edit": 1806 1806 openTab.imapBox[new_border_ID] = folder_message.value; 1807 //openTab.toPreserve[new_border_ID] = true;1808 openTab.imapUid[new_border_ID] = parseInt(border_ID.substr(0,border_ID.indexOf("_")));1809 1807 document.getElementById('font_border_id_'+new_border_ID).innerHTML = data.subject; 1810 1808 title = "Edição: "+data.subject; … … 2073 2071 } 2074 2072 } 2075 if ((! openTab.toPreserve[ID]) && (openTab.imapUid[ID] != 0)) 2076 cExecute ("$this.imap_functions.delete_msgs&folder="+openTab.imapBox[ID]+"&msgs_number="+openTab.imapUid[ID],function(data){return}); 2077 delete_border(ID,'true'); // Becarefull: email saved automatically should be deleted. delete_border erase information about openTab 2073 delete_border(ID,'true'); 2078 2074 } 2079 2075 else{ … … 2087 2083 var save_link = Element("save_message_options_"+ID); 2088 2084 save_link.onclick = function onclick(event) {openTab.toPreserve[ID] = true;save_msg(ID);} ; 2089 $("#save_message_options_"+ID).button({ disabled: false});2085 $("#save_message_options_"+ID).button({disabled: false}); 2090 2086 //save_link.className = 'message_options'; 2091 2087 } … … 2173 2169 save_link.onclick = ''; 2174 2170 $("#save_message_options_"+ID).button({ disabled: true }); 2175 //save_link.className = 'message_options_inactive';2176 2171 2177 2172 ID_tmp = ID; … … 2184 2179 mail_as_plain = ( mail_as_plain ) ? mail_as_plain.checked : false; 2185 2180 2186 var content_body = RichTextEditor.getData('body_'+ID); 2187 //Remove imagens do corpo que estao com o checkbox desmarcados 2188 var files_checkbox = $("#divFiles_"+ID+" input:checkbox"); 2189 var files_unchecked = new Array(); 2190 for (var i = 0; i < files_checkbox.length; i++) 2191 if(files_checkbox[i].checked !== true) 2192 files_unchecked.push(connector.unserialize(unescape(trim(files_checkbox[i].value)))); 2193 2194 var imagens = content_body.match(/<img[^>]*>/g); 2195 2196 if(imagens != null) 2197 for (var x = 0; x < imagens.length; x++) 2198 for (var xx = 0; xx < files_unchecked.length; xx++) 2199 if(imagens[x].indexOf('indexPart='+files_unchecked[xx][3].replace(/'/g,'')) !== -1) 2200 content_body = content_body.replace(imagens[x],''); 2201 2202 //--------------------------------------------------------------------------// 2203 2181 var content_body = RichTextEditor.getData('body_'+ID); 2204 2182 var textArea = document.createElement("TEXTAREA"); 2205 2183 textArea.style.display='none'; … … 2210 2188 input_folder.style.display='none'; 2211 2189 input_folder.name = "folder"; 2212 input_folder.value = folder; 2213 var msg_id = document.createElement("INPUT"); 2214 msg_id.style.display='none'; 2215 msg_id.name = "msg_id"; 2216 msg_id.value = openTab.imapUid[ID]; 2190 input_folder.value = folder; 2191 2192 var uids = document.createElement("INPUT"); 2193 uids.style.display='none'; 2194 uids.name = "uids_save"; 2195 uids.value = uidsSave[ID].toString(); 2196 2197 var save_folder = document.createElement("INPUT"); 2198 save_folder.style.display='none'; 2199 save_folder.name = "save_folder"; 2200 save_folder.value = (openTab.imapBox[ID] && openTab.type[ID] < 6) ? openTab.imapBox[ID]: "INBOX" + cyrus_delimiter + draftsfolder; 2201 2202 var msg_attachments = document.createElement("INPUT"); 2203 msg_attachments.style.display='none'; 2204 msg_attachments.name = "attachments"; 2205 msg_attachments.value = listAttachment(ID); 2217 2206 2218 2207 if (is_ie){ … … 2239 2228 form.appendChild(textArea); 2240 2229 form.appendChild(input_folder); 2241 form.appendChild(msg_id);2242 2243 2230 2244 2231 // Implementação do In_Reply_To e References … … 2248 2235 msgId.value = currentTab; 2249 2236 2250 var msgFolder = document.createElement("INPUT"); 2251 msgFolder.style.display = 'none'; 2252 msgFolder.name = 'messageFolder'; 2253 msgFolder.value = openTab.imapBox[currentTab]; 2237 2254 2238 2255 2239 form.appendChild(msgId); 2256 form.appendChild(msgFolder);2257 2258 2240 form.appendChild(save_folder); 2241 form.appendChild(uids); 2242 form.appendChild(msg_attachments); 2259 2243 2260 2244 var mail_type = document.createElement('input'); … … 2350 2334 } 2351 2335 2352 function return_save(data,border_id,folder_name,folder_id,message_id)2353 {2354 Element("send_button_"+border_id).style.visibility="visible";2355 var handler_delete_msg = function(data){refresh(preferences.alert_new_msg);RichTextEditor.execPosInstance('body_'+border_id);};2356 2357 2358 if(data === null)2359 {2360 write_msg(get_lang('ERROR saving your message.'));2361 return null;2362 }2363 if(typeof(data.append) == 'undefined')2364 data.append = false;2365 2366 if(data.append === "Over quota"){2367 write_msg(get_lang('ERROR saving your message over quota.'));2368 return;2369 }2370 else if ( data.append !== true )2371 {2372 if (data.append == null)2373 write_msg(get_lang('ERROR saving your message.'));2374 else2375 {2376 if (data.append.match(/^(.*)TRYCREATE(.*)$/))2377 {2378 connector.loadScript('TreeS');2379 alert(get_lang('There is not %1 folder, Expresso is creating it for you... Please, repeat your request later.',draftsfolder));2380 connector.loadScript('TreeShow');2381 ttree.FOLDER = 'root';2382 ttreeBox.new_past(draftsfolder);2383 setTimeout('save_msg('+border_id+')',3000);2384 }2385 else2386 write_msg(data.append);2387 }2388 }2389 else2390 {2391 var newImage = false;2392 RichTextEditor.saveFlag = 1;2393 openTab.imapUid[border_id] = data.msg_no;2394 openTab.imapBox[border_id] = data.folder_id;2395 2396 var newTitle = document.getElementById('subject_'+border_id).value;2397 if (newTitle.length > 18)2398 newTitle = newTitle.substr(18) + '...';2399 else if (newTitle == '')2400 newTitle = get_lang("No subject");2401 document.getElementById('font_border_id_'+border_id).innerHTML = newTitle;2402 Element('border_id_'+border_id).title = newTitle;2403 2404 // Replace the embedded images for new uids2405 var content_body = RichTextEditor.getData('body_'+border_id);2406 var body_images = content_body.match(/msgNumber=\d*/g);2407 var folder_images = content_body.match(/msgFolder=[^&]*&/g);2408 2409 if (body_images != null)2410 {2411 for (var i=0; i<body_images.length; i++)2412 {2413 if( folder_images != null)2414 content_body = content_body.replace(folder_images[i], "msgFolder=INBOX" + cyrus_delimiter + draftsfolder +"&");2415 2416 2417 2418 2419 content_body = content_body.replace(body_images[i],"msgNumber="+openTab.imapUid[border_id]);2420 }2421 2422 var images_part = content_body.match(/indexPart=[0-9.]*/g);2423 2424 if(images_part != null)2425 {2426 for (var x = 0; x < images_part.length; x++)2427 {2428 var position = images_part[x].substr(10,images_part[x].length);2429 content_body = content_body.replace(images_part[x],'indexPart(||.|||.||)='+data.imagesParts[position]);2430 }2431 2432 }2433 content_body = content_body.replace(/indexPart\(\|\|\.\|\|\|\.\|\|\)=/g,'indexPart=');2434 }2435 2436 2437 2438 //Replace all files to new files2439 var divFiles = Element("divFiles_"+border_id);2440 divFiles.innerHTML = '';2441 2442 2443 var attach_files = connector.unserialize(data.files);2444 if (attach_files != null) {2445 openTab.countFile[border_id] = attach_files.length;2446 for (var att_index = 0; att_index < attach_files.length; att_index++){2447 2448 var link_attachment = document.createElement("a");2449 2450 var fileName = Base64.decode(attach_files[att_index].name);2451 var fileSize = attach_files[att_index].size / 1024;2452 2453 2454 link_attachment.innerHTML = fileName + " ("+parseInt(fileSize)+" kb)";2455 2456 var encoding = /\.eml$/.exec(fileName)? '7bit' : 'base64';2457 var href = "'"+folder_id+"','"+data.msg_no+"','"+(att_index)+"','0."+(att_index+1)+"','"+encoding+"'";2458 2459 link_attachment.setAttribute("href", "javascript:download_attachments("+href+")");2460 2461 var a_tmp = href.split(',');2462 a_tmp[2] = fileName;2463 s_tmp = escape(connector.serialize(a_tmp));2464 2465 var check_attachment = document.createElement("input");2466 check_attachment.type = 'CHECKBOX';2467 check_attachment.name = 'forwarding_attachments[]';2468 check_attachment.value = s_tmp;2469 2470 2471 2472 divFiles.appendChild(check_attachment);2473 divFiles.appendChild(link_attachment);2474 2475 divFiles.appendChild(document.createElement("br"));2476 2477 check_attachment.checked = true;2478 check_attachment.setAttribute("checked", "checked");2479 }2480 }2481 2482 if(RichTextEditor.newImageId !== false)2483 {2484 var rex = new RegExp('<img id="'+RichTextEditor.newImageId+'" src="" [^\/>]*\/>', 'i');2485 var newImg = '<img src="./inc/get_archive.php?msgFolder=INBOX'+cyrus_delimiter+draftsfolder+'&msgNumber='+openTab.imapUid[border_id]+'&indexPart=0.'+(openTab.countFile[border_id])+'" />';2486 content_body = content_body.replace(rex,newImg);2487 2488 RichTextEditor.newImageID = false;2489 newImage = true;2490 }2491 2492 if(body_images != null || newImage === true)2493 {2494 RichTextEditor.setData('body_'+border_id,content_body);2495 }2496 2497 if (message_id)2498 {2499 cExecute ("$this.imap_functions.delete_msgs&folder="+openTab.imapBox[border_id]+"&msgs_number="+message_id,handler_delete_msg);2500 if (openTab.imapBox[0] == "INBOX" + cyrus_delimiter + draftsfolder)2501 {2502 //Update mailbox2503 var tr_msg = document.getElementById(message_id);2504 change_tr_properties(tr_msg, data.msg_no, data.subject);2505 }2506 2507 }2508 setTimeout( function(){RichTextEditor.saveFlag = 1;RichTextEditor.execPosInstance('body_'+border_id);}, 1000 );2509 }2510 return null;2511 }2512 2336 2513 2337 function autoSave( ID ) … … 2517 2341 } 2518 2342 2519 function save_msg(border_id ,withImage, out){2343 function save_msg(border_id){ 2520 2344 2521 //seta o status do auto_save = true 2522 if (preferences.auto_save_draft == 1) 2523 autoSaveControl.status[border_id] = true; 2524 /////////////////////////////////////////// 2525 2526 if (typeof(withImage) == 'undefined') 2527 withImage = false; 2528 2529 var sendButton = Element("send_button_"+border_id); 2530 if (sendButton) 2531 sendButton.style.visibility="hidden"; 2532 2533 if (openTab.imapBox[border_id] && openTab.type[border_id] < 6) //Gets the imap folder 2534 var folder_id = openTab.imapBox[border_id]; 2535 else 2536 var folder_id = "INBOX" + cyrus_delimiter + draftsfolder; 2537 2538 if (folder_id == 'INBOX') // and folder name from border 2539 var folder_name = get_lang(folder_id); 2540 else 2541 var folder_name = folder_id.substr(6); 2542 2543 // hack to avoid form connector bug, escapes quotation. Please see #179 2544 tmp_border_id=border_id; 2545 tmp_folder_name=folder_name; 2546 tmp_folder_id=folder_id; 2547 message_id = openTab.imapUid[border_id]; 2548 var handler_save_msg = function(data){ 2549 if(typeof(out) == 'undefined'){ 2550 return_save(data,this.tmp_border_id,this.tmp_folder_name,this.tmp_folder_id,this.message_id); 2551 var save_link = Element("save_message_options_"+border_id); 2552 if(!withImage){ 2553 if(data.append === true){ 2554 $("#save_message_options_"+border_id).button(); 2555 $("#save_message_options_"+border_id).button({ disabled: true }); 2556 watch_changes_in_msg(border_id); 2557 write_msg(get_lang('Your message was save as draft in folder %1.', lang_folder(folder_name))); 2558 } 2559 if(auto){ 2560 auto = false; 2561 } 2562 } 2563 else{ 2564 write_msg(get_lang('Wait a moment, your image is uploading ...')); 2565 var auto = true; 2566 setTimeout( function(){save_msg(border_id)}, 1000 ); 2567 } 2568 }else{ 2569 if(data.append === true){ 2570 write_msg(get_lang('Your message was save as draft in folder %1.', lang_folder(folder_name))); 2571 }else if(data.append == null){ 2572 write_msg(get_lang('ERROR saving your message.')); 2573 }if(data.append === "Over quota"){ 2574 write_msg(get_lang('ERROR saving your message over quota.')); 2575 } 2576 } 2577 2578 } 2579 2580 var mail_as_plain = document.getElementById( 'textplain_rt_checkbox_' + border_id ); 2581 mail_as_plain = ( mail_as_plain ) ? mail_as_plain.checked : false; 2582 2583 var content_body = RichTextEditor.getData("body_"+border_id); 2584 //Remove imagens do corpo que estao com o checkbox desmarcados 2585 var files_checkbox = $("#divFiles_"+border_id+" input:checkbox"); 2586 var files_unchecked = new Array(); 2587 for (var i = 0; i < files_checkbox.length; i++) 2588 if(files_checkbox[i].checked !== true) 2589 files_unchecked.push(connector.unserialize(unescape(trim(files_checkbox[i].value)))); 2590 2591 var imagens = content_body.match(/<img[^>]*>/g); 2592 if(imagens != null) 2593 for (var x = 0; x < imagens.length; x++) 2594 for (var xx = 0; xx < files_unchecked.length; xx++) 2595 if(imagens[x].indexOf('indexPart='+files_unchecked[xx][3].replace(/'/g,'')) !== -1) 2596 content_body = content_body.replace(imagens[x],''); 2597 2598 if(files_unchecked.length > 0) 2599 RichTextEditor.setData("body_"+border_id,content_body); 2600 2601 2602 var textArea = document.createElement("TEXTAREA"); 2603 textArea.style.display='none'; 2604 textArea.name = "body"; 2605 textArea.value = content_body; 2606 var input_folder = document.createElement("INPUT"); 2607 input_folder.style.display='none'; 2608 input_folder.name = "folder"; 2609 input_folder.value = folder_id; 2610 var input_msgid = document.createElement("INPUT"); 2611 input_msgid.style.display='none'; 2612 input_msgid.name = "msg_id"; 2613 input_msgid.value = message_id; 2614 var input_insertImg = document.createElement("INPUT"); 2615 input_insertImg.style.display='none'; 2616 input_insertImg.name = "insertImg"; 2617 input_insertImg.value = withImage; 2618 2619 2620 if (is_ie) 2345 //seta o status do auto_save = true 2346 if (preferences.auto_save_draft == 1) 2347 autoSaveControl.status[border_id] = true; 2348 /////////////////////////////////////////// 2349 2350 var idJavascript = DataLayer.put('message',DataLayer.form("#form_message_"+border_id)); 2351 uidsSave[border_id] = []; 2352 DataLayer.commit(false,false,function(data){ 2353 if(data != null && data['message://'+idJavascript].id !== undefined ) 2621 2354 { 2622 var i = 0; 2623 while (document.forms(i).name != "form_message_"+border_id){i++} 2624 form = document.forms(i); 2625 } 2626 else 2627 { 2628 form = document.forms["form_message_"+border_id]; 2629 } 2630 2631 form.appendChild(textArea); 2632 form.appendChild(input_folder); 2633 form.appendChild(input_msgid); 2634 form.appendChild(input_insertImg); 2635 2636 var mail_type; 2637 2638 if (is_ie) 2639 { 2640 mail_type = document.createElement('<input type="hidden" />'); 2355 uidsSave[border_id].push(data['message://'+idJavascript].id); 2356 write_msg('Mensagem salva com sucesso!'); 2641 2357 } 2642 2358 else 2643 { 2644 mail_type = document.createElement('input'); 2645 mail_type.setAttribute('type', 'hidden'); 2646 } 2647 mail_type.setAttribute('name', 'type'); 2648 var mail_type_value = ( mail_as_plain ) ? 'plain' : 'html'; 2649 mail_type.setAttribute("value", mail_type_value); 2650 2651 form.parentNode.appendChild(mail_type); 2652 2653 cExecuteForm ("$this.imap_functions.save_msg", form, handler_save_msg,border_id); 2654 } 2655 2656 function return_saveas(data,border_id,folder_name) 2657 { 2658 if(!verify_session(data)) 2659 return; 2660 if (data.append) 2661 { 2662 delete_border(border_id,null); 2663 write_msg(get_lang('Your message was save as draft in folder %1.', folder_name)); 2664 } 2665 else 2666 write_msg(get_lang('ERROR saving your message.')); 2667 } 2668 2669 2670 function save_as_msg(border_id, folder_id, folder_name){ 2671 // hack to avoid form connector bug, escapes quotation. Please see #179 2672 tmp_border_id=border_id; 2673 tmp_folder_name=folder_name; 2674 var handler_save_msg = function(data){return_saveas(data,this.tmp_border_id,this.tmp_folder_name);} 2675 2676 var content_body = RichTextEditor.getData("body_"+border_id); 2677 //Remove imagens do corpo que estao com o checkbox desmarcados 2678 var files_checkbox = $("#divFiles_"+border_id+" input:checkbox"); 2679 var files_unchecked = new Array(); 2680 for (var i = 0; i < files_checkbox.length; i++) 2681 if(files_checkbox[i].checked !== true) 2682 files_unchecked.push(connector.unserialize(unescape(trim(files_checkbox[i].value)))); 2683 2684 var imagens = content_body.match(/<img[^>]*>/g); 2685 2686 if(imagens != null) 2687 for (var x = 0; x < imagens.length; x++) 2688 for (var xx = 0; xx < files_unchecked.length; xx++) 2689 if(imagens[x].indexOf('indexPart='+files_unchecked[xx][3].replace(/'/g,'')) !== -1) 2690 content_body = content_body.replace(imagens[x],''); 2691 2692 var textArea = document.createElement("TEXTAREA"); 2693 textArea.style.display='none'; 2694 textArea.name = "body"; 2695 textArea.value = content_body; 2696 2697 var input_folder = document.createElement("INPUT"); 2698 input_folder.style.display='none'; 2699 input_folder.name = "folder"; 2700 input_folder.value = folder_id; 2701 2702 if (is_ie){ 2703 var i = 0; 2704 while (document.forms(i).name != "form_message_"+border_id){i++} 2705 form = document.forms(i); 2706 } 2707 else 2708 form = document.forms["form_message_"+border_id]; 2709 form.appendChild(textArea); 2710 form.appendChild(input_folder); 2711 2712 cExecuteForm ("$this.imap_functions.save_msg", form, handler_save_msg,border_id); 2359 write_msg('Erro ao salvar sua menssagem!'); 2360 }); 2361 2713 2362 } 2714 2363 … … 3874 3523 } 3875 3524 3525 3526 DataLayer.codec( "message", "detail", { 3527 3528 decoder:function( form ){ 3529 var border_id = form.abaID; 3530 ///Dfininindo pasta a ser salva mensagem 3531 var folder_id = (openTab.imapBox[border_id] && openTab.type[border_id] < 6) ? openTab.imapBox[border_id]: "INBOX" + cyrus_delimiter + draftsfolder; 3532 form.folder = folder_id; 3533 form.body = RichTextEditor.getData("body_"+border_id); 3534 form.attachments = listAttachment(border_id); 3535 form.uidsSave = uidsSave[border_id].toString(); 3536 return( form ); 3537 3538 }, 3539 3540 encoder:function( pref ){ 3541 3542 return( pref ); 3543 } 3544 3545 }); 3546 3547 DataLayer.codec( "mailAttachment", "detail", { 3548 3549 decoder: function(evtObj){ 3550 3551 if( notArray = $.type(evtObj) !== "array" ) 3552 evtObj = [ evtObj ]; 3553 3554 var res = $.map(evtObj, function( form){ 3555 return [$.map(form.files , function( files){ 3556 return { source: files , disposition : form['attDisposition'+form.abaID]}; 3557 })]; 3558 }); 3559 return notArray ? res[0] : res; 3560 }, 3561 3562 encoder: function(){} 3563 3564 3565 }); -
trunk/expressoMail1_2/js/rich_text_editor.js
r5496 r5604 145 145 } 146 146 147 cRichTextEditor.prototype.createImage = function(){ 148 149 var form = document.getElementById("attachment_window"); 150 151 if (form == null){ 152 form = document.createElement("DIV"); 153 form.id = "attachment_window"; 154 form.style.visibility = "hidden"; 155 form.style.position = "absolute"; 156 form.style.background = "#eeeeee"; 157 form.style.left = "0px"; 158 form.style.top = "0px"; 159 form.style.width = "0px"; 160 form.style.height = "0px"; 161 document.body.appendChild(form); 162 } 163 var form_upload = Element('form_upload'); 164 if (form_upload == null) 165 form_upload = document.createElement("DIV"); 166 form_upload.id = "form_upload"; 167 form_upload.style.position = "absolute"; 168 form_upload.style.top = "5px"; 169 form_upload.style.left = "5px"; 170 form_upload.name = get_lang("Upload File"); 171 form_upload.style.width = "450px"; 172 form_upload.style.height = "75px"; 173 form_upload.innerHTML = get_lang('Select the desired image file')+':<br>'+ 174 '<input name="image_at" maxlength="255" size="40" id="inputFile_img" type="file"><br>' + 175 '<input title="' + get_lang('Include') + '" value="' + get_lang('Include') + '"' + 176 'type="button" onclick="RichTextEditor.addInputFile();"> ' + 177 '<input title="' + get_lang('Close') + '" value="' + get_lang('Close') + '"' + 178 ' type="button" onclick="win.close()">'; 179 form.appendChild(form_upload); 180 181 this.showWindow(form); 182 } 183 cRichTextEditor.prototype.showWindow = function (div){ 184 185 if(! div) { 186 return; 187 } 188 189 if(! this.emwindow[div.id]) { 190 div.style.width = div.firstChild.style.width; 191 div.style.height = div.firstChild.style.height; 192 div.style.zIndex = "10000"; 193 var title = div.firstChild.name; 194 var wHeight = div.offsetHeight + "px"; 195 var wWidth = div.offsetWidth + "px"; 196 div.style.width = div.offsetWidth - 5; 197 198 win = new dJSWin({ 199 id: 'win_'+div.id, 200 content_id: div.id, 201 width: wWidth, 202 height: wHeight, 203 title_color: '#3978d6', 204 bg_color: '#eee', 205 title: title, 206 title_text_color: 'white', 207 button_x_img: '../phpgwapi/images/winclose.gif', 208 border: true}); 209 210 this.emwindow[div.id] = win; 211 win.draw(); 212 } 213 else 214 win = this.emwindow[div.id]; 215 win.open(); 216 } 217 cRichTextEditor.prototype.addInputFile = function() 218 { 219 //Begin: Verify if the image extension is allowed. 220 var imgExtensions = new Array("jpeg", "jpg", "gif", "png", "bmp", "xbm", "tiff", "pcx"); 221 var inputFile = document.getElementById('inputFile_img'); 222 if(!inputFile.value) return false; 223 var fileExtension = inputFile.value.split("."); 224 fileExtension = fileExtension[(fileExtension.length-1)]; 225 var deniedExtension = true; 226 for(var i=0; i<imgExtensions.length; i++) { 227 if(imgExtensions[i].toUpperCase() == fileExtension.toUpperCase()) { 228 deniedExtension = false; 229 break; 230 } 231 } 232 if(deniedExtension) { 233 alert(get_lang('File extension forbidden or invalid file') + '.'); 234 return false; 235 } 236 // End: Verify image extension. 237 var id = currentTab; 238 divFiles = document.getElementById("divFiles_"+id); 239 var countDivFiles = divFiles.childNodes.length + 1; 240 241 var divFiles = document.getElementById('divFiles_'+id); 242 inputFile.id = 'inputFile_'+id +"_"+countDivFiles; 243 inputFile.name = 'file_'+countDivFiles; 244 divFile = document.createElement('DIV'); 245 divFile.appendChild(inputFile); 246 divFiles.appendChild(divFile); 247 248 var form_upload = document.getElementById('form_upload'); 249 form_upload.parentNode.removeChild(form_upload); 250 win.close(); 251 252 RichTextEditor.saveFlag = 0; // See if save function finished 253 var save_link = document.getElementById("save_message_options_"+id); 254 save_link.onclick = function () {}; 255 this.newImageId = new Date().getTime(); 256 CKEDITOR.instances['body_'+id].insertHtml('<img id="'+this.newImageId+'" src=""/>'); 257 save_msg(id,true); 258 } 147 259 148 260 149 cRichTextEditor.prototype.execPosInstance = function(inst) { -
trunk/expressoMail1_2/setup/setup.inc.php
r5547 r5604 12 12 $setup_info['expressoMail1_2']['name'] = 'expressoMail1_2'; 13 13 $setup_info['expressoMail1_2']['title'] = 'Expresso Mail'; 14 $setup_info['expressoMail1_2']['version'] = '2.4. 1';14 $setup_info['expressoMail1_2']['version'] = '2.4.2'; 15 15 $setup_info['expressoMail1_2']['app_order'] = 2; 16 16 $setup_info['expressoMail1_2']['tables'][] = 'phpgw_expressomail_contacts'; 17 17 $setup_info['expressoMail1_2']['tables'][] = 'phpgw_certificados'; 18 18 19 $setup_info['expressoMail1_2']['tables'][] = 'expressomail_label'; 19 $setup_info['expressoMail1_2']['tables'][] = 'mail_attachment'; 20 $setup_info['expressoMail1_2']['tables'][] = 'expressomail_label'; 20 21 $setup_info['expressoMail1_2']['tables'][] = 'expressomail_followupflag'; 21 22 $setup_info['expressoMail1_2']['tables'][] = 'expressomail_message_followupflag'; -
trunk/expressoMail1_2/setup/tables_current.inc.php
r5603 r5604 77 77 'ix' => array(), 78 78 'uc' => array() 79 )79 80 80 ); 81 81 ?> -
trunk/expressoMail1_2/setup/tables_update.inc.php
r5557 r5604 206 206 $GLOBALS['setup_info']['expressoMail1_2']['currentver'] = '2.4.1'; 207 207 return $GLOBALS['setup_info']['expressoMail1_2']['currentver']; 208 } 208 } 209 $test[] = '2.4.1'; 210 function expressoMail1_2_upgrade2_4_1() { 211 $oProc = $GLOBALS['phpgw_setup']->oProc; 212 $oProc->CreateTable('mail_attachment',array( 213 'fd' => array( 214 'id' => array('type' => 'auto','nullable' => False), 215 'source' => array('type' => 'blob','nullable' => False), 216 'type' => array('type' => 'varchar','precision' => '50','nullable' => False), 217 'name' => array('type' => 'varchar','precision' => '255','nullable' => False), 218 'disposition' => array('type' => 'varchar','precision' => '20','nullable' => true), 219 'size' => array('type' => 'int','precision' => '16','nullable' => False), 220 'dtstamp' => array('type' => 'int','precision' => '16','nullable' => False), 221 'owner' => array('type' => 'int', 'precision' => '8','nullable' => True) 222 ), 223 'pk' => array('id'), 224 'fk' => array(), 225 'ix' => array(), 226 'uc' => array() 227 ) 228 ); 229 $GLOBALS['setup_info']['expressoMail1_2']['currentver'] = '2.4.2'; 230 return $GLOBALS['setup_info']['expressoMail1_2']['currentver']; 231 } 209 232 ?> -
trunk/expressoMail1_2/templates/default/expressomail.css
r5569 r5604 136 136 .context-menu-item.icon-empty-trash { background-image: url(images/menu/trash.png); } 137 137 .context-menu-item.icon-queue { background-image: url(images/menu/queue.png); } 138 139 form.fileupload { margin: 14px 0 0 -13px; float: left; margin-bottom: -20px; } 140 form.fileupload .files-list { margin-left: 5px;} 141 ul.attachments-list { padding: 0; } 142 .button-files-upload { float:left; } 143 144 form.fileupload .ui-button .ui-button-text { line-height: 2; } 145 form.fileupload .ui-button { margin-left: 5px; } 146 147 .button.add.button-add-attachment{margin: -9px 0 0 8px;} 148 .button.upload{margin-bottom: 4px;} 149 div.fileupload-buttonbar{padding: 0.2em 0.5em } 150 .archive-error{color: #F00;} 151 152 .progress.in-progress{width: 100px; height: 12px;} 153 154 .row.fileupload-buttonbar{margin-top: -14px; padding: 0.2em 0.7em;} 155 156 .archive-attach.name{width: 200px;} 157 .archive-attach.name label{display: block; position: absolute; left: 136px; top: 194px;} 158 .size{min-width: 60px; max-width: 60px;} 159 160 .message-attach.name{width: 200px;} 161 .message-attach.size{margin:0 4px 0 4px;} -
trunk/library/PEAR/PEAR.php
r5146 r5604 728 728 729 729 if (PEAR_ZE2) { 730 include_once 'PEAR5.php';730 include_once dirname(__FILE__).'/PEAR5.php'; 731 731 } 732 732 -
trunk/library/ckeditor/plugins/expresso/plugin.js
r5081 r5604 9 9 { 10 10 label: 'Adicionar Imagem', 11 command: ' expAddImageCMD',11 command: 'imgDialog', 12 12 icon: CKEDITOR.plugins.getPath('expresso') + 'img/Image.gif' 13 13 }); … … 43 43 }); 44 44 45 46 editor.addCommand( 'imgDialog',new CKEDITOR.dialogCommand( 'imgDialog' ) ); 47 48 if ( editor.contextMenu ) 49 { 50 editor.addMenuGroup( 'mygroup', 10 ); 51 editor.addMenuItem( 'My Dialog', 52 { 53 label : 'Open dialog', 54 command : 'imgDialog', 55 group : 'mygroup' 56 }); 57 editor.contextMenu.addListener( function( element ) 58 { 59 return {'My Dialog' : CKEDITOR.TRISTATE_OFF}; 60 }); 61 } 62 63 CKEDITOR.dialog.add( 'imgDialog', function( api ) 64 { 65 var ID = currentTab; 66 // CKEDITOR.dialog.definition 67 var dialogDefinition = 68 { 69 70 title : 'Inserir Imagem', 71 minWidth : 400, 72 minHeight : 70, 73 contents : [ 74 { 75 id : 'tab1', 76 label : 'Label', 77 title : 'Title', 78 expand : true, 79 padding : 0, 80 elements : 81 [ 82 { 83 type : 'html', 84 html : '<form id="fileupload_img'+ID+'" class="fileupload" action="mailAttachment:img" method="POST"> <input type="file" name="files[]" multiple="" onclick="bindFileUpload();" style="margin-left:10px"></form>' 85 } 86 ] 87 } 88 ], 89 buttons : [ CKEDITOR.dialog.cancelButton] 90 91 }; 92 93 return dialogDefinition; 94 } ); 95 45 96 46 var cmd = editor.addCommand('expAddImageCMD', { exec: showexpIncImageDialog }); 97 47 98 } 48 99 }); 49 function showexpIncImageDialog(e) { 50 RichTextEditor.createImage(); 100 function bindFileUpload(e) { 101 var ID = currentTab; 102 var newImageId = new Date().getTime(); 103 var fileUploadIMG = $('#fileupload_img'+ID); 104 var fileUploadMSG = $('#fileupload_msg'+ID); 105 var maxAttachmentSise = (preferences.max_attachment_size !== "" && preferences.max_attachment_size != 0) ? (parseInt(preferences.max_attachment_size.replace('M', '')) * 1048576 ) : false; 106 fileUploadIMG.fileupload({ 107 sequentialUploads: true, 108 add: function (e, data) { 109 110 if(!maxAttachmentSise || data.files[0].size < maxAttachmentSise) { 111 setTimeout(function() { 112 $('#attDisposition'+ID).val('embedded'); 113 data.submit(); 114 }, 5000); 115 } 116 117 }, 118 change: function (e, data) { 119 $.each(data.files, function (index, file) { 120 var attach = {}; 121 attach.fullFileName = file.name; 122 attach.fileName = file.name; 123 if(file.name.length > 10) 124 attach.fileName = file.name.substr(0, 18) + "..." + file.name.substr(file.name.length-9, file.name.length); 125 attach.fileSize = formatBytes(file.size); 126 if(maxAttachmentSise && file.size > maxAttachmentSise) 127 attach.error = 'Tamanho de arquivo nao permitido!!' 128 129 fileUploadMSG.find('.attachments-list').append(DataLayer.render("../prototype/modules/mail/templates/attachment_add_itemlist.ejs", {file : attach})); 130 131 if(!maxAttachmentSise || file.size < maxAttachmentSise){ 132 fileUploadMSG.find(' .fileinput-button.new').append(data.fileInput[0]).removeClass('new'); 133 fileUploadMSG.find(' .attachments-list').find('[type=file]').addClass('hidden'); 134 135 }else 136 fileUploadMSG.find(' .fileinput-button.new').removeClass('new'); 137 138 139 fileUploadMSG.find(' .attachments-list').find('.button.close').button({ 140 icons: { 141 primary: "ui-icon-close" 142 }, 143 text: false 144 }).click(function(){ 145 var idAttach = $(this).parent().find('input[name="fileId[]"]').val(); 146 147 var content_body = RichTextEditor.getData('body_'+ID); 148 var imagens = content_body.match(/<img[^>]*>/g); 149 150 if(imagens != null) 151 for (var x = 0; x < imagens.length; x++) 152 if(imagens[x].indexOf('src="../prototype/getArchive.php?mailAttachment='+idAttach+'"') !== -1) 153 content_body = content_body.replace(imagens[x],''); 154 155 RichTextEditor.setData('body_'+ID,content_body); 156 157 $('.attachments-list').find('input[value="'+idAttach+'"]').remove(); 158 delAttachment(ID, idAttach); 159 $(this).parent().remove(); 160 }); 161 162 CKEDITOR.instances['body_'+ID].insertHtml('<img id="'+newImageId+'" src=""/>'); 163 164 }); 165 166 CKEDITOR.dialog.getCurrent().hide(); 167 }, 168 done: function(e, data){ 169 if(!!data.result && data.result != "[]"){ 170 var newAttach = jQuery.parseJSON(data.result); 171 fileUploadMSG.find('.in-progress:first').parents('p').append('<input type="hidden" name="fileId[]" value="'+newAttach['mailAttachment'][0][0].id+'"/>'); 172 addAttachment(ID,newAttach['mailAttachment'][0][0].id); 173 var content_body = RichTextEditor.getData('body_'+ID); 174 var rex = new RegExp('<img id="'+newImageId+'" src="" [^\/>]*\/>', 'i'); 175 var newImg = '<img src="../prototype/getArchive.php?mailAttachment='+newAttach['mailAttachment'][0][0].id+'" />'; 176 content_body = content_body.replace(rex,newImg); 177 RichTextEditor.setData('body_'+ID,content_body); 178 179 }else { 180 fileUploadMSG.find(' .progress.on-complete:first').removeClass('on-complete').parents('p').find('.status-upload').addClass('ui-icon ui-icon-cancel'); 181 } 182 fileUploadMSG.find('.in-progress:first').remove(); 183 184 } 185 }); 51 186 } -
trunk/library/mime/mime.php
r5316 r5604 873 873 $rep[] = '\1\2=\3cid:' . $value['cid'] .'\3'; 874 874 $rep[] = 'url(\1cid:' . $value['cid'] . '\1)'; 875 875 876 876 $this->_htmlbody = preg_replace($regex, $rep, $this->_htmlbody); 877 877 $this->_html_images[$key]['name'] 878 878 = $this->_basename($this->_html_images[$key]['name']); 879 880 //Alteração para o Expresso. 881 //Ver https://dev.prognus.com.br/expresso/ticket/1256 882 $this->_htmlbody = str_replace("src=\"cid:".substr($value['cid'], 0, strpos($value['cid'], '@'))."\"", "src=\"cid:".$value['cid']."\"", $this->_htmlbody); 883 879 884 880 } 885 881 } -
trunk/prototype/api/datalayer.js
r5601 r5604 19 19 20 20 if( isIframe.test( options.dataType ) || options.data instanceof FormData ) 21 { 21 { 22 options.url = options.fileInput.parents( 'form' ).attr( 'action' ); 23 22 24 res = internalUrl.exec( options.url ); 23 25 -
trunk/prototype/config/mailAttachment.ini
r5514 r5604 1 1 service = PostgreSQL 2 PostgreSQL.concept = attachment 3 4 [model.hasOne] 5 schedulable = schedulable.attachments 2 PostgreSQL.concept = mail_attachment 6 3 7 4 [before.create] 8 encodeCreateAttachment = modules/calendar/interceptors/DBMapping.php 9 10 [after.delete] 11 deleteAttachmentDependences = modules/calendar/interceptors/DBMapping.php 5 encodeCreateAttachment = modules/mail/interceptors/Attachments.php 12 6 13 7 [PostgreSQL.mapping] … … 17 11 name = "name" 18 12 size = "size" 19 13 owner = "owner" 14 disposition = "disposition" 15 dtstamp = "dtstamp" -
trunk/prototype/getArchive.php
r5514 r5604 7 7 8 8 foreach($data as $concept => $value){ 9 9 10 10 $arquive = Controller::find( array( 'concept' => $concept ) , false ,array( 'filter' => array('=', 'id' , $data[$concept]) )); 11 11 -
trunk/prototype/services/ImapServiceAdapter.php
r5586 r5604 333 333 334 334 public function create( $URI, $data) 335 { 335 { 336 336 switch( $URI['concept'] ) 337 337 { … … 364 364 } 365 365 return array (); 366 } 367 case 'message': 368 { 369 $GLOBALS['phpgw_info']['flags'] = array( 'noheader' => true, 'nonavbar' => true,'currentapp' => 'expressoMail1_2','enable_nextmatchs_class' => True ); 370 $return = array(); 371 372 require_once dirname(__FILE__) . '/../../services/class.servicelocator.php'; 373 $mailService = ServiceLocator::getService('mail'); 374 375 $msg_uid = $data['msg_id']; 376 $body = $data['body']; 377 $body = str_replace("%nbsp;"," ",$body); 378 $body = preg_replace("/\n/"," ",$body); 379 $body = preg_replace("/\r/","" ,$body); 380 $body = html_entity_decode ( $body, ENT_QUOTES , 'ISO-8859-1' ); 381 382 $folder = mb_convert_encoding($data['folder'], "UTF7-IMAP","ISO-8859-1, UTF-8"); 383 $folder = @eregi_replace("INBOX[/.]", "INBOX".$this->imap_delimiter, $folder); 384 385 $mailService->addTo($data['input_to']); 386 $mailService->addCc( $data['input_cc']); 387 $mailService->addBcc($data['input_cco']); 388 $mailService->setSubject($data['input_subject']); 389 390 if(isset($data['input_important_message'])) 391 $mailService->addHeaderField('Importance','High'); 392 393 if(isset($data['input_return_receipt'])) 394 $mailService->addHeaderField('Disposition-Notification-To', Config::me('mail')); 395 396 $isHTML = ( ( array_key_exists( 'type', $data ) && in_array( strtolower( $data[ 'type' ] ), array( 'html', 'plain' ) ) ) ? strtolower( $data[ 'type' ] ) != 'plain' : true ); 397 398 if (!$body) $body = ' '; 399 400 401 $mbox_stream = $this->open_mbox($folder); 402 403 $attachment = json_decode($data['attachments'],TRUE); 404 405 406 foreach ($attachment as &$value) 407 { 408 409 if((int)$value > 0) //BD attachment 410 { 411 $att = Controller::read(array('id'=> $value , 'concept' => 'mailAttachment')); 412 413 if($att['disposition'] == 'embedded') 414 { 415 $body = str_replace('"../prototype/getArchive.php?mailAttachment='.$att['id'].'"', $att['name'], $body); 416 $mailService->addStringImage(base64_decode($att['source']), $att['type'], $att['name']); 417 } 418 else 419 $mailService->addStringAttachment(base64_decode($att['source']), $att['name'], $att['type'], 'base64', isset($att['disposition']) ? $att['disposition'] :'attachment' ); 420 421 unset($att); 422 } 423 else //message attachment 424 { 425 $value = json_decode($value, true); 426 $sub = $value['name'] ? $value['name'].'.eml' :'no title.eml'; 427 $mbox_stream = $this->open_mbox($value['folder']); 428 $rawmsg = $this->getRawHeader($value['uid']) . "\r\n\r\n" . $this->getRawBody($value['uid']); 429 $mailService->addStringAttachment($rawmsg, $sub, 'message/rfc822', '7bit', 'attachment' ); 430 unset($rawmsg); 431 } 432 433 } 434 435 if($isHTML) $mailService->setBodyHtml($body); else $mailService->setBodyText($body); 436 437 if(imap_append($mbox_stream, "{".$this->imap_server.":".$this->imap_port."}".$folder, $mailService->getMessage(), "\\Seen \\Draft")) 438 { 439 $status = imap_status($mbox_stream, "{".$this->imap_server.":".$this->imap_port."}".$folder, SA_UIDNEXT); 440 $return['id'] = $status->uidnext - 1; 441 442 if($data['uidsSave'] ) 443 $this->delete_msgs(array('folder'=> $folder , 'msgs_number' => $data['uidsSave'])); 444 445 } 446 447 if($mbox_stream) imap_close($mbox_stream); 448 449 450 451 return $return; 366 452 } 367 453 }
Note: See TracChangeset
for help on using the changeset viewer.