Index: branches/2.2.0.1/preferences/handlecertificate.php
===================================================================
--- branches/2.2.0.1/preferences/handlecertificate.php	(revision 3991)
+++ branches/2.2.0.1/preferences/handlecertificate.php	(revision 4123)
@@ -16,4 +16,10 @@
 if($_POST['certificado'])
     {
+        $GLOBALS['phpgw_info']['flags']['app_header'] = lang('Digital Certificate Registration');
+        $GLOBALS['phpgw']->common->phpgw_header();
+        echo parse_navbar();
+        echo '<form id="answerForm" name="answerForm" method="POST" action="index.php" >';
+        echo '<BR/><BR/><BR/>';
+        
         require_once('../security/classes/CertificadoB.php');
         require_once('../security/classes/Verifica_Certificado.php');
@@ -25,6 +31,6 @@
         if (!$c->apresentado)
             {
-               echo '2'.chr(0x0D).chr(0x0A).lang('Fail to get certificate');
-               exit();
+                echo '<div align="center"><h2>'.lang('Fail to get certificate').'</h2>';
+                exit();
             }
         $b = new Verifica_Certificado($c->dados,$cert);
@@ -37,5 +43,5 @@
                         $msg .= "\n" . $linha;
                    }
-               echo $msg;
+                   echo '<div align="center"><h2>'.$msg.'</h2>';
                exit();
             }
@@ -54,5 +60,5 @@
         if (!$ds)
              {
-                echo '4'.chr(0x0D).chr(0x0A).lang('Failure when get user data to login');
+                 echo '<div align="center"><h2>'.lang('Failure when get user data to login').'</h2>';
                 exit();
              }
@@ -77,12 +83,18 @@
         if($info["count"]!=1)
             {
-                echo '5'.chr(0x0D).chr(0x0A).lang('Invalid data from users directory').'('.$cert_atrib_cpf.' = ' . $c->dados['2.16.76.1.3.1']['CPF'] . ')';
+                echo '<div align="center"><h2>'.lang('Invalid data from users directory').'('.$cert_atrib_cpf.' = ' . $c->dados['2.16.76.1.3.1']['CPF'] . ')'.'</h2>';
                 ldap_close($ds);
                 exit();
             }
-        if($info[0]["userCertificate"][0] && $cert == $info[0]["userCertificate"][0] )
+            if($info[0]["uid"][0] != $GLOBALS['phpgw_info']['user']['userid'])
+            {
+                echo '<div align="center"><h2>'.lang('Invalid data from users directory').'('.$cert_atrib_cpf.' = ' . $c->dados['2.16.76.1.3.1']['CPF'] . ' - ' . $info[0]["uid"][0] . ' - ' . $GLOBALS['phpgw_info']['user']['userid'] . ')'.'</h2>';
+                ldap_close($ds);
+                exit();
+            }
+            if($info[0]["userCertificate"][0] && $cert == $info[0]["userCertificate"][0] )
             {
                 //echo '0'.chr(0x0D).chr(0x0A).$info[0]["uid"][0].chr(0x0D).chr(0x0A).$info[0]["cryptpassword"][0];
-                echo '6'.chr(0x0D).chr(0x0A).lang('Certificate already registered');
+                echo '<div align="center"><h2>'.lang('Certificate already registered').'</h2>';
                 ldap_close($ds);
                 exit();
@@ -108,10 +120,14 @@
         if(!ldap_modify($ds,$aux1,$user_info))
             {
-                echo '7'.chr(0x0D).chr(0x0A).lang('Error in Certificate registration'). '  -  ' . $aux1;
-            }
-        else
-            {
-                echo '0'.chr(0x0D).chr(0x0A).lang('To conclude your Certificate registration change your password');
-            }
+                echo '<div align="center"><h2>'.lang('Error in Certificate registration'). '  -  ' . $aux1.'</h2>';
+            }
+        else
+            {
+                echo '<div align="center"><h2>'.lang('To conclude your Certificate registration change your password').'</h2>';
+            }
+
+            echo '<h2><img style="border:0px;margin:31px 0px 58px 0px;" src="../phpgwapi/templates/default/images/acao.gif" /></h2>';
+            echo '<input type="submit" name="ok" value="' . lang('ok') . '" ></div></form>';
+            $GLOBALS['phpgw']->common->phpgw_footer();
         ldap_close($ds);
         exit();
@@ -193,9 +209,10 @@
                                     </script>';
                   echo $cod_applet;
-                  echo '<form method="POST" action="preferences" >';
+                  echo '<form id="certificateForm" name="certificateForm" method="POST" action="handlecertificate.php" >';
                   echo '<BR/><BR/><BR/>';
                   echo '<div align="center"><h2>'.lang('Getting your Certificate').'</h2>';
                   echo '<h2><img style="border:0px;margin:31px 0px 58px 0px;" src="../phpgwapi/templates/default/images/acao.gif" /></h2>';
-                  echo '<input type="submit" name="cancel" value="' . lang('cancel') . '" ></div>';
+                  echo '<input type="hidden" name="certificado" value="" />';
+                  echo '<input type="submit" name="cancel" value="' . lang('cancel') . '" ></div></form>';
                   $GLOBALS['phpgw']->common->phpgw_footer();
         }
