bug 1010: new gui for org server certs
authorINOPIAE <inopiae@cacert.org>
Sat, 13 Jul 2013 15:38:14 +0000 (17:38 +0200)
committerINOPIAE <inopiae@cacert.org>
Sat, 13 Jul 2013 15:38:14 +0000 (17:38 +0200)
pages/account/18.php
pages/account/22.php

index 5d45f37..05f30de 100644 (file)
@@ -91,7 +91,6 @@ if(array_key_exists('status',$_SESSION['_config'])) $status=intval($_SESSION['_c
     <td colspan="9" class="DataTD"> </td>
   </tr>
 
-//rebuild query
 <?
        $query = "select UNIX_TIMESTAMP(`oemail`.`created`) as `created`,
                        UNIX_TIMESTAMP(`oemail`.`expire`) - UNIX_TIMESTAMP() as `timeleft`,
index cb40cf2..72e3dff 100644 (file)
     You should have received a copy of the GNU General Public License
     along with this program; if not, write to the Free Software
     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
-*/ ?>
-<? $viewall=0; if(array_key_exists('viewall',$_REQUEST)) $viewall=intval($_REQUEST['viewall']); ?>
+*/
+
+$orgfilterid=0;
+if(array_key_exists('dorgfilterid',$_SESSION['_config'])) $orgfilterid=intval($_SESSION['_config']['dorgfilterid']);
+$sorting=0;
+if(array_key_exists('dsorting',$_SESSION['_config'])) $sorting=intval($_SESSION['_config']['dsorting']);
+$status=0;
+if(array_key_exists('dstatus',$_SESSION['_config'])) $status=intval($_SESSION['_config']['dstatus']); ?>
 <form method="post" action="account.php">
 <table align="center" valign="middle" border="0" cellspacing="0" cellpadding="0" class="wrapper">
+    <td colspan="8" class="title"><?=_("Organisation Server Certificates")?> </td>
+  </tr>
   <tr>
-    <td colspan="8" class="title"><?=_("Domain Certificates")?> - <a href="account.php?id=22&amp;viewall=<?=!$viewall?>"><?=_("View all certificates")?></a></td>
+    <td colspan="8" class="title"><?=_("Filter/Sorting")?></td>
+  </tr>
+    <tr>
+      <td class="DataTD"><?=_("Organisation")?></td>
+      <td colspan="7" class="DataTD" >
+        <select name="dorgfilterid">
+          <option value="0"<?
+       if (0==$orgfilterid) {
+               ?> selected <?
+       }
+       ?>><?=_("All")?></option> <?
+       $query = "select `orginfo`.`O`, `orginfo`.`id`
+               from `org`, `orginfo`
+               where `org`.`memid`='".intval($_SESSION['profile']['id'])."' `orginfo`.`id` = `org`.`orgid`
+               ORDER BY `oemail`.`modified` desc";
+$reso = mysql_query($query);
+if(mysql_num_rows($reso) >= 1){
+       while($row = mysql_fetch_assoc($res)){
+               ?><option <?if ($row['id']==$orgfilterid) {
+                       ?> selected <?
+               }?> value="><?=$row['id']?>"><?=$row['O']?></option>
+               <?}
+}?>
+        </select>
+    </td>
   </tr>
   <tr>
-    <td class="DataTD"><?=_("Renew/Revoke/Delete")?></td>
-    <td class="DataTD"><?=_("Status")?></td>
-    <td class="DataTD"><?=_("CommonName")?></td>
-    <td class="DataTD"><?=_("SerialNumber")?></td>
-    <td class="DataTD"><?=_("Revoked")?></td>
-    <td class="DataTD"><?=_("Expires")?></td>
-    <td colspan="2" class="DataTD"><?=_("Comment *")?></td>
+    <td class="DataTD"><?=_("Sorting")?></td>
+    <td colspan="7" class="DataTD" >
+      <select name="dsorting">
+        <option <?if (0==$sorting) {
+               ?> selected <?
+        }?>value="0"><?=_("expire date (desc)")?></option>
+        <option <?if (1==$sorting) {
+               ?> selected <?
+        }?>value="1"><?=_("Common name, expire date (desc)")?></option>
+      </select>
+    </td>
+  </tr>
+  <tr>
+    <td class="DataTD"><?=_("Certificate status")?></td>
+    <td colspan="7" class="DataTD" >
+      <select name="dstatus">
+        <option <?if (0==$status) {
+               ?> selected <?
+        }?>value="0"><?=_("Actual")?></option>
+        <option <?if (0==$status) {
+               ?> selected <?
+        }?>value="1"><?=_("All")?></option>
+      </select>
+    </td>
+  </tr>
+  <tr>
+    <td class="DataTD" colspan="8"><input type="submit" name="reset" value="<?=_("Reset")?>" />&#160;&#160;&#160;&#160;
+      <input type="submit" name="filter" value="<?=_("Apply filter/sort")?>" /></td>
+  </tr>
+    <td colspan="9" class="DataTD"> </td>
+  </tr>
+
+
 <?
        $query = "select UNIX_TIMESTAMP(`orgdomaincerts`.`created`) as `created`,
                        UNIX_TIMESTAMP(`orgdomaincerts`.`expire`) - UNIX_TIMESTAMP() as `timeleft`,
                        UNIX_TIMESTAMP(`revoked`) as `revoked`, `CN`,
                        `orgdomaincerts`.`serial`,
                        `orgdomaincerts`.`id` as `id`,
-                       `orgdomaincerts`.`description`
-                       from `orgdomaincerts`,`org`
-                       where `org`.`memid`='".intval($_SESSION['profile']['id'])."' and `orgdomaincerts`.`orgid`=`org`.`orgid` ";
-       if($viewall != 1)
-       {
-               $query .= "AND `revoked`=0 AND `renewed`=0 ";
-               $query .= "HAVING `timeleft` > 0 ";
-       }
-       $query .= "ORDER BY `orgdomaincerts`.`modified` desc";
+                       `orgdomaincerts`.`description`, `orginfo`.`O`
+                       from `orgdomaincerts`,`org`, `orginfo`
+                       where `org`.`memid`='".intval($_SESSION['profile']['id'])."'
+                       and `orgdomaincerts`.`orgid`=`org`.`orgid` and `orginfo`.`id` = `org`.`orgid`";
+
+               if($dorgfilterid>0)
+               {
+                       $query .= "AND `org`.`orgid`=$dorgfilterid ";
+               }
+
+               if(1==$dstatus)
+               {
+                       $query .= "AND `revoked`=0 AND `renewed`=0 ";
+                       $query .= "HAVING `timeleft` > 0 ";
+               }
+               switch ($dsorting){
+                       case 0:
+                               $query .= "ORDER BY `orgdomaincerts`.`expire` desc";
+                               break;
+                       case 1:
+                               $query .= "ORDER BY `orgdomaincerts`.`CN`, `orgdomaincerts`.`expire` desc";
+                               break;
+               }
+
+
 //echo $query."<br>\n";
        $res = mysql_query($query);
        if(mysql_num_rows($res) <= 0)
     <td colspan="8" class="DataTD"><?=_("No domains are currently listed.")?></td>
   </tr>
 <? } else {
+       $orgname='';
        while($row = mysql_fetch_assoc($res))
        {
+               if ($row['O']<>$orgname) {
+                       $orgname=$row['O'];?>
+  <tr>
+    <td colspan="9" class="title"></td>
+  </tr>
+  <tr>
+    <td colspan="9" class="title"><?=_("Certificates for ").$orgname?> </td>
+  </tr>
+  <tr>
+    <td class="DataTD"><?=_("Renew/Revoke/Delete")?></td>
+    <td class="DataTD"><?=_("Status")?></td>
+    <td class="DataTD"><?=_("CommonName")?></td>
+    <td class="DataTD"><?=_("SerialNumber")?></td>
+    <td class="DataTD"><?=_("Revoked")?></td>
+    <td class="DataTD"><?=_("Expires")?></td>
+    <td colspan="2" class="DataTD"><?=_("Comment *")?></td>
+  </tr>
+                       <?
+               }
                if($row['timeleft'] > 0)
                        $verified = _("Valid");
                if($row['timeleft'] < 0)
            <input type="submit" name="revoke" value="<?=_("Revoke/Delete")?>" /></td>
     <td class="DataTD" colspan="2"><input type="submit" name="change" value="<?=_("Change settings")?>" /> </td>
   </tr>
+  <tr>
+    <td class="DataTD" colspan="9"><?=_("From here you can delete pending requests, or revoke valid certificates.")?></td>
+  </tr>
 <? } ?>
 </table>
 <input type="hidden" name="oldid" value="<?=$id?>" />
 <input type="hidden" name="csrf" value="<?=make_csrf('orgsrvcerchange')?>" />
 </form>
-<p><?=_("From here you can delete pending requests, or revoke valid certificates.")?></p>
+