roundcubemail/plugins/enigma/lib/enigma_ui.php
function message_compose($p)
    {
        $engine = $this->enigma->load_engine();

        // skip: message has no signed/encoded content
        if (!$this->enigma->engine) {
            return $p;
        }

        $engine = $this->enigma->engine;
        $locks  = (array) $this->rc->config->get('enigma_options_lock');

        // Decryption status
        foreach ($engine->decryptions as $status) {
            if ($status instanceof enigma_error) {
                $code = $status->getCode();

                if ($code == enigma_error::KEYNOTFOUND) {
                    $msg = rcube::Q(str_replace('$keyid', enigma_key::format_id($status->getData('id')),
                        $this->enigma->gettext('decryptnokey')));
                }
                else if ($code == enigma_error::BADPASS) {
                    $this->password_prompt($status, array('compose-init' => true));
                    return $p;
                }
                else {
                    $msg = rcube::Q($this->enigma->gettext('decrypterror'));
                }
            }
        }

        if ($msg) {
            $this->rc->output->show_message($msg, 'error');
        }

        // Check sign/ecrypt options for signed/encrypted drafts
        if (!in_array('encrypt', $locks)) {
            $this->rc->output->set_env('enigma_force_encrypt', !empty($engine->decryptions));
        }
        if (!in_array('sign', $locks)) {
            $this->rc->output->set_env('enigma_force_sign', !empty($engine->signatures));
        }

        return $p;
    }
function message_compose($p)
    {
        $engine = $this->enigma->load_engine();

        // skip: message has no signed/encoded content
        if (!$this->enigma->engine) {
            return $p;
        }

        $engine = $this->enigma->engine;
        $locks  = (array) $this->rc->config->get('enigma_options_lock');

        // Decryption status
        foreach ($engine->decryptions as $status) {
            if ($status instanceof enigma_error) {
                $code = $status->getCode();

                if ($code == enigma_error::KEYNOTFOUND) {
                    $msg = rcube::Q(str_replace('$keyid', enigma_key::format_id($status->getData('id')),
                        $this->enigma->gettext('decryptnokey')));
                }
                else if ($code == enigma_error::BADPASS) {
                    $this->password_prompt($status, array('compose-init' => true));
                    return $p;
                }
                else {
                    $msg = rcube::Q($this->enigma->gettext('decrypterror'));
                }
            }
        }

        if ($msg) {
            $this->rc->output->show_message($msg, 'error');
        }

        // Check sign/ecrypt options for signed/encrypted drafts
        if (!in_array('encrypt', $locks)) {
            $this->rc->output->set_env('enigma_force_encrypt', !empty($engine->decryptions));
        }
        if (!in_array('sign', $locks)) {
            $this->rc->output->set_env('enigma_force_sign', !empty($engine->signatures));
        }

        return $p;
    }
function message_compose ( $ p ) { $ engine = $ this -> enigma -> load_engine ( ) ; // skip: message has no signed/encoded content if ( ! $ this -> enigma -> engine ) { return $ p ; } $ engine = $ this -> enigma -> engine ; $ locks = ( array ) $ this -> rc -> config -> get ( 'enigma_options_lock' ) ; // Decryption status foreach ( $ engine -> decryptions as $ status ) { if ( $ status instanceof enigma_error ) { $ code = $ status -> getCode ( ) ; if ( $ code == enigma_error :: KEYNOTFOUND ) { $ msg = rcube :: Q ( str_replace ( '$keyid' , enigma_key :: format_id ( $ status -> getData ( 'id' ) ) , $ this -> enigma -> gettext ( 'decryptnokey' ) ) ) ; } else if ( $ code == enigma_error :: BADPASS ) { $ this -> password_prompt ( $ status , array ( 'compose-init' => true ) ) ; return $ p ; } else { $ msg = rcube :: Q ( $ this -> enigma -> gettext ( 'decrypterror' ) ) ; } } } if ( $ msg ) { $ this -> rc -> output -> show_message ( $ msg , 'error' ) ; } // Check sign/ecrypt options for signed/encrypted drafts if ( ! in_array ( 'encrypt' , $ locks ) ) { $ this -> rc -> output -> set_env ( 'enigma_force_encrypt' , ! empty ( $ engine -> decryptions ) ) ; } if ( ! in_array ( 'sign' , $ locks ) ) { $ this -> rc -> output -> set_env ( 'enigma_force_sign' , ! empty ( $ engine -> signatures ) ) ; } return $ p ; }
Handler for message_compose_body hook
Display error when the message cannot be encrypted
and provide a way to try again with a password.
Handler for message_compose_body hook Display error when the message cannot be encrypted and provide a way to try again with a password .