bug 1138: added function get_gpg_certs
authorINOPIAE <inopiae@cacert.org>
Sun, 8 Dec 2013 16:20:43 +0000 (17:20 +0100)
committerINOPIAE <inopiae@cacert.org>
Sun, 8 Dec 2013 16:20:43 +0000 (17:20 +0100)
includes/notary.inc.php
pages/account/59.php

index d20368b..2537851 100644 (file)
@@ -1287,6 +1287,18 @@ function get_server_certs($userid,$viewall=0){
        return mysql_query($query);
 }
 
+function get_gpg_certs($userid,$viewall=0){
+       //add to gpg/2.php
+       $userid = intval($userid);
+       $query = $query = "select UNIX_TIMESTAMP(`issued`) as `issued`,
+                       UNIX_TIMESTAMP(`expire`) - UNIX_TIMESTAMP() as `timeleft`,
+                       UNIX_TIMESTAMP(`expire`) as `expired`,
+                       `expire` as `expires`, `id`, `level`,
+                       `email`,`keyid`,`description` from `gpg` where `memid`='".$userid."'
+                       ORDER BY `issued` desc";
+       return mysql_query($query);
+}
+
 
 
 function output_log_email_header(){
@@ -1327,6 +1339,7 @@ function output_log_domains_header(){
 
        <?
 }
+
 function output_log_domains($row){
        $italic='';
        if (0==$row['deleted']) {
@@ -1351,6 +1364,7 @@ function output_log_agreement_header(){
        </tr>
        <?
 }
+
 function output_log_agreement($row){
        ?>
        <tr>
@@ -1554,4 +1568,60 @@ function output_log_server_certs($row, $support=0){
                        <td class="DataTD"><input type="checkbox" name="check_comment_<?=$row['id']?>" /></td>
                <?}?>
        </tr>
-}
\ No newline at end of file
+}
+
+function output_gpg_certs_header($support=0){
+       ?>
+       <tr>
+               <td class="DataTD"><?=_("Status")?></td>
+               <td class="DataTD"><?=_("Email Address")?></td>
+               <td class="DataTD"><?=_("Expires")?></td>
+               <td class="DataTD"><?=_("Key ID")?></td>
+               <?if (1==$support) { ?>
+                       <td colspan="2" class="DataTD"><?=_("Comment *")?></td>
+               <? }?>
+       </tr>
+       <?
+}
+
+function output_gpg_certs($row, $support=0){
+       //should be entered in account/55.php
+       if($row['timeleft'] > 0)
+               $verified = _("Valid");
+       if($row['timeleft'] < 0)
+               $verified = _("Expired");
+       if($row['expired'] == 0)
+               $verified = _("Pending");
+       ?>
+       <tr>
+               <? if($verified == _("Valid")) { ?>
+                       <td class="DataTD"><?=$verified?></td>
+                       <?if (1==$support) { ?>
+                               <td class="DataTD"><a href="gpg.php?id=3&amp;cert=<?=$row['id']?>"><?=$row['email']?></a></td>
+                       <? } else { ?>
+                               <td class="DataTD"><?=$row['email']?></td>
+                       <? } ?>
+               <? } else if($verified == _("Pending")) { ?>
+                       <td class="DataTD"><?=$verified?></td>
+                       <td class="DataTD"><?=$row['email']?></td>
+               <? } else { ?>
+                       <td class="DataTD"><?=$verified?></td>
+                       <?if (1==$support) { ?>
+                               <td class="DataTD"><a href="gpg.php?id=3&amp;cert=<?=$row['id']?>"><?=$row['email']?></a></td>
+                       <? } else { ?>
+                               <td class="DataTD"><?=$row['email']?></td>
+                       <? } ?>
+               <? } ?>
+               <td class="DataTD"><?=$row['expires']?></td>
+               <?if (1==$support) { ?>
+                       <td class="DataTD"><a href="gpg.php?id=3&amp;cert=<?=$row['id']?>"><?=$row['keyid']?></a></td>
+               <? } else { ?>
+                       <td class="DataTD"><?=$row['keyid']?></td>
+               <? } ?>
+               <?if (1==$support) { ?>
+                       <td class="DataTD"><input name="comment_<?=$row['id']?>" type="text" value="<?=htmlspecialchars($row['description'])?>" /></td>
+                       <td class="DataTD"><input type="checkbox" name="check_comment_<?=$row['id']?>" /></td>
+               <? } ?>
+       </tr>
+       <?
+}
index e8509df..773c83a 100644 (file)
@@ -114,8 +114,8 @@ if(mysql_num_rows($dres) > 0) {
 output_log_email_header();
 while($drow = mysql_fetch_assoc($dres))
 {
-       output_log_email($drow,$email);
- } ?>
+  output_log_email($drow,$email);
+} ?>
 </table>
 <br/>
 <?
@@ -131,10 +131,10 @@ if(mysql_num_rows($dres) > 0) {
   while($drow = mysql_fetch_assoc($dres))
   {
     output_log_domain($drow,$email);
-  }ELSE{?>
+  }
+}ELSE{?>
     <td colspan="3" ><?=_('no entry avialable')?></td>
-  <?}
-}?>
+<?}?>
 </table>
 <br/>
 
@@ -147,16 +147,17 @@ $dres = get_training_result($userid);
   </tr>
 <?
 if(mysql_num_rows($dres) > 0) {
-       output_log_training_header();
-       while($drow = mysql_fetch_assoc($dres))
-       {
-               output_log_training($drow);
-       }ELSE{
-               ?><td colspan="3" ><?=_('no entry avialable')?></td><?
-       }
+  output_log_training_header();
+  while($drow = mysql_fetch_assoc($dres))
+  {
+    output_log_training($drow);
+  }
+}ELSE{
+  ?><td colspan="3" ><?=_('no entry avialable')?></td><?
 }?>
 </table>
 <br/>
+
 <?
 $dres = get_user_agreement($userid,'',1);
 ?>
@@ -170,12 +171,13 @@ if(mysql_num_rows($dres) > 0) {
   while($drow = mysql_fetch_assoc($dres))
   {
     output_log_agreement($drow);
-  }ELSE{
-    ?><td colspan="4" ><?=_('no entry avialable')?></td><?
   }
+}ELSE{
+  ?><td colspan="4" ><?=_('no entry avialable')?></td><?
 }?>
 </table>
 <br/>
+
 <?
 $dres = get_client_certs($userid);
 $colspan=10;
@@ -189,18 +191,19 @@ if (1==$support) {
   </tr>
 <?
 if(mysql_num_rows($dres) > 0) {
-       output_client_cert_header($support);
-       while($drow = mysql_fetch_assoc($dres))
-       {
-               output_client_cert($drow,$support);
-       }ELSE{
-               ?><td colspan="<? $colspan?>" ><?=_('no entry avialable')?></td><?
-       }
+  output_client_cert_header($support);
+  while($drow = mysql_fetch_assoc($dres))
+  {
+    output_client_cert($drow,$support);
+  }
+}ELSE{
+  ?><td colspan="<? $colspan?>" ><?=_('no entry avialable')?></td><?
 }?>
 </table>
 <br/>
-       <?
-       $dres = get_server_certs($userid);
+
+<?
+$dres = get_server_certs($userid);
 $colspan=8;
 if (1==$support) {
        $colspan=5;
@@ -212,21 +215,37 @@ if (1==$support) {
   </tr>
 <?
 if(mysql_num_rows($dres) > 0) {
-       output_log_server_certs_header($support);
-       while($drow = mysql_fetch_assoc($dres))
-       {
-               output_log_server_certs($drow,$support);
-       }ELSE{
-               ?><td colspan="<? $colspan?>" ><?=_('no entry avialable')?></td><?
-       }
+  output_log_server_certs_header($support);
+  while($drow = mysql_fetch_assoc($dres))
+  {
+    output_log_server_certs($drow,$support);
+  }
+}ELSE{
+  ?><td colspan="<? $colspan?>" ><?=_('no entry avialable')?></td><?
 }?>
 </table>
 <br/>
 
-<table>
-
-
+<?
+$dres = get_server_certs($userid);
+$colspan=6;
+if (1==$support) {
+       $colspan=4;
+}
+?>
+<table align="center" valign="middle" border="0" cellspacing="0" cellpadding="0" class="wrapper">
   <tr>
-    <td colspan="<? $colspandefault ?>" class="title"><?=_('GPG certificates')?></td>
+    <td colspan="<? $colspan?>" class="title"><?=_('Server certificates')?></td>
   </tr>
-</table>
\ No newline at end of file
+<?
+if(mysql_num_rows($dres) > 0) {
+  output_log_server_certs_header($support);
+  while($drow = mysql_fetch_assoc($dres))
+  {
+    output_log_server_certs($drow,$support);
+  }
+}ELSE{
+  ?><td colspan="<? $colspan?>" ><?=_('no entry avialable')?></td><?
+}?>
+</table>
+}
\ No newline at end of file