From ced34cb15e095836767971aa4d27b141fb1d7ec9 Mon Sep 17 00:00:00 2001
From: Aleksander Machniak <alec@alec.pl>
Date: Sat, 18 Oct 2014 08:47:54 -0400
Subject: [PATCH] Merge pull request #230 from bytesatwork-xx/master

---
 plugins/enigma/enigma.php |   58 ++++++++++++++++++++++++++++++++++------------------------
 1 files changed, 34 insertions(+), 24 deletions(-)

diff --git a/plugins/enigma/enigma.php b/plugins/enigma/enigma.php
index fb7c986..870b923 100644
--- a/plugins/enigma/enigma.php
+++ b/plugins/enigma/enigma.php
@@ -47,6 +47,8 @@
         $rcmail = rcmail::get_instance();
         $this->rc = $rcmail;
 
+        $section = rcube_utils::get_input_value('_section', rcube_utils::INPUT_GET);
+
         if ($this->rc->task == 'mail') {
             // message parse/display hooks
             $this->add_hook('message_part_structure', array($this, 'parse_structure'));
@@ -79,7 +81,6 @@
             $this->register_action('plugin.enigma', array($this, 'preferences_ui'));
 
             // grab keys/certs management iframe requests
-            $section = get_input_value('_section', RCUBE_INPUT_GET);
             if ($this->rc->action == 'edit-prefs' && preg_match('/^enigma(certs|keys)/', $section)) {
                 $this->load_ui();
                 $this->ui->init($section);
@@ -148,7 +149,7 @@
      */
     function parse_structure($p)
     {
-        $struct = $p['structure'];
+//        $struct = $p['structure'];
 
         if ($p['mimetype'] == 'text/plain' || $p['mimetype'] == 'application/pgp') {
             $this->parse_plain($p);
@@ -178,10 +179,11 @@
     {
         // add labels
         $this->add_texts('localization/');
-
+/*
         $p['list']['enigmasettings'] = array(
             'id' => 'enigmasettings', 'section' => $this->gettext('enigmasettings'),
         );
+*/
         $p['list']['enigmacerts'] = array(
             'id' => 'enigmacerts', 'section' => $this->gettext('enigmacerts'),
         );
@@ -202,11 +204,13 @@
      */
     function preferences_list($p)
     {
+/*
         if ($p['section'] == 'enigmasettings') {
             // This makes that section is not removed from the list
             $p['blocks']['dummy']['options']['dummy'] = array();
         }
-        else if ($p['section'] == 'enigmacerts') {
+        else */
+        if ($p['section'] == 'enigmacerts') {
             // This makes that section is not removed from the list
             $p['blocks']['dummy']['options']['dummy'] = array();
         }
@@ -230,7 +234,7 @@
     {
         if ($p['section'] == 'enigmasettings') {
             $a['prefs'] = array(
-//                'dummy' => get_input_value('_dummy', RCUBE_INPUT_POST),
+//                'dummy' => rcube_utils::get_input_value('_dummy', rcube_utils::INPUT_POST),
             );
         }
 
@@ -285,16 +289,16 @@
                 $attrib['class'] = 'enigmaerror';
                 $code = $status->getCode();
                 if ($code == enigma_error::E_KEYNOTFOUND)
-                    $msg = Q(str_replace('$keyid', enigma_key::format_id($status->getData('id')),
+                    $msg = rcube::Q(str_replace('$keyid', enigma_key::format_id($status->getData('id')),
                         $this->gettext('decryptnokey')));
                 else if ($code == enigma_error::E_BADPASS)
-                    $msg = Q($this->gettext('decryptbadpass'));
+                    $msg = rcube::Q($this->gettext('decryptbadpass'));
                 else
-                    $msg = Q($this->gettext('decrypterror'));
+                    $msg = rcube::Q($this->gettext('decrypterror'));
             }
             else {
                 $attrib['class'] = 'enigmanotice';
-                $msg = Q($this->gettext('decryptok'));
+                $msg = rcube::Q($this->gettext('decryptok'));
             }
 
             $p['prefix'] .= html::div($attrib, $msg);
@@ -312,30 +316,36 @@
             $attrib['id'] = 'enigma-message';
 
             if ($sig instanceof enigma_signature) {
-                if ($sig->valid) {
+                $sender = ($sig->name ? $sig->name . ' ' : '') . '<' . $sig->email . '>';
+
+                if ($sig->valid === enigma_error::E_UNVERIFIED) {
+                    $attrib['class'] = 'enigmawarning';
+                    $msg = str_replace('$sender', $sender, $this->gettext('sigunverified'));
+                    $msg = str_replace('$keyid', $sig->id, $msg);
+                    $msg = rcube::Q($msg);
+                }
+                else if ($sig->valid) {
                     $attrib['class'] = 'enigmanotice';
-                    $sender = ($sig->name ? $sig->name . ' ' : '') . '<' . $sig->email . '>';
-                    $msg = Q(str_replace('$sender', $sender, $this->gettext('sigvalid')));
+                    $msg = rcube::Q(str_replace('$sender', $sender, $this->gettext('sigvalid')));
                 }
                 else {
                     $attrib['class'] = 'enigmawarning';
-                    $sender = ($sig->name ? $sig->name . ' ' : '') . '<' . $sig->email . '>';
-                    $msg = Q(str_replace('$sender', $sender, $this->gettext('siginvalid')));
+                    $msg = rcube::Q(str_replace('$sender', $sender, $this->gettext('siginvalid')));
                 }
             }
-            else if ($sig->getCode() == enigma_error::E_KEYNOTFOUND) {
+            else if ($sig && $sig->getCode() == enigma_error::E_KEYNOTFOUND) {
                 $attrib['class'] = 'enigmawarning';
-                $msg = Q(str_replace('$keyid', enigma_key::format_id($sig->getData('id')),
+                $msg = rcube::Q(str_replace('$keyid', enigma_key::format_id($sig->getData('id')),
                     $this->gettext('signokey')));
             }
             else {
                 $attrib['class'] = 'enigmaerror';
-                $msg = Q($this->gettext('sigerror'));
+                $msg = rcube::Q($this->gettext('sigerror'));
             }
 /*
             $msg .= '&nbsp;' . html::a(array('href' => "#sigdetails",
-                'onclick' => JS_OBJECT_NAME.".command('enigma-sig-details')"),
-                Q($this->gettext('showdetails')));
+                'onclick' => rcmail_output::JS_OBJECT_NAME.".command('enigma-sig-details')"),
+                rcube::Q($this->gettext('showdetails')));
 */
             // test
 //            $msg .= '<br /><pre>'.$sig->body.'</pre>';
@@ -390,7 +400,7 @@
     function message_load($p)
     {
         $this->message = $p['object'];
-    
+
         // handle attachments vcard attachments
         foreach ((array)$this->message->attachments as $attachment) {
             if ($this->is_keys_part($attachment)) {
@@ -398,7 +408,7 @@
             }
         }
         // the same with message bodies
-        foreach ((array)$this->message->parts as $idx => $part) {
+        foreach ((array)$this->message->parts as $part) {
             if ($this->is_keys_part($part)) {
                 $this->keys_parts[] = $part->mime_id;
                 $this->keys_bodies[] = $part->mime_id;
@@ -429,13 +439,13 @@
             $style = "margin:0 1em; padding:0.2em 0.5em; border:1px solid #999; width: auto"
                 ." border-radius:4px; -moz-border-radius:4px; -webkit-border-radius:4px";
 
-            // add box below messsage body
+            // add box below message body
             $p['content'] .= html::p(array('style' => $style),
                 html::a(array(
                     'href' => "#",
-                    'onclick' => "return ".JS_OBJECT_NAME.".enigma_import_attachment('".JQ($part)."')",
+                    'onclick' => "return ".rcmail_output::JS_OBJECT_NAME.".enigma_import_attachment('".rcube::JQ($part)."')",
                     'title' => $this->gettext('keyattimport')),
-                    html::img(array('src' => $this->url('skins/default/key_add.png'), 'style' => "vertical-align:middle")))
+                    html::img(array('src' => $this->url('skins/classic/key_add.png'), 'style' => "vertical-align:middle")))
                 . ' ' . html::span(null, $this->gettext('keyattfound')));
 
             $attach_script = true;

--
Gitblit v1.9.1