version 0.1.2
[fms.git] / admin / localidentities.php
1 <?php\r
2         \r
3         include_once('config.php');\r
4         include_once('linkbar.php');\r
5 \r
6 function truefalsedropdown($name,$currentval)\r
7 {\r
8         ?>\r
9         <select name="<?php print($name); ?>">\r
10                 <option value="true" <?php if($currentval=="true") print("SELECTED"); ?>>true</option>\r
11                 <option value="false" <?php if($currentval=="false") print("SELECTED"); ?>>false</option>\r
12         </select>\r
13         <?php\r
14 }\r
15 \r
16 function content()\r
17 {\r
18         global $dblocation;\r
19         $db=new PDO('sqlite:'.$dblocation);\r
20         \r
21         if(isset($_REQUEST['formaction']))\r
22         {\r
23                 if($_REQUEST['formaction']=='update' && isset($_REQUEST['update']))\r
24                 {\r
25                         $st=$db->prepare("UPDATE tblLocalIdentity SET SingleUse=?, PublishTrustList=? WHERE LocalIdentityID=?;");\r
26                         for($i=0; $i<count($_REQUEST['update']); $i++)\r
27                         {\r
28                                 if($_REQUEST['update'][$i]!='')\r
29                                 {\r
30                                         $st->bindParam(1,$_REQUEST['singleuse'][$_REQUEST['update'][$i]]);\r
31                                         $st->bindParam(2,$_REQUEST['publishtrustlist'][$_REQUEST['update'][$i]]);\r
32                                         $st->bindParam(3,$_REQUEST['localidentityid'][$_REQUEST['update'][$i]]);\r
33                                         $st->execute();\r
34                                 }\r
35                         }\r
36                 }\r
37                 if($_REQUEST['formaction']=='delete' && isset($_REQUEST['update']))\r
38                 {\r
39                         $st=$db->prepare("DELETE FROM tblLocalIdentity WHERE LocalIdentityID=?;");\r
40 \r
41                         for($i=0; $i<count($_REQUEST['update']); $i++)\r
42                         {\r
43                                 if($_REQUEST['update'][$i]!='')\r
44                                 {\r
45                                         $st->bindParam(1,$_REQUEST['localidentityid'][$_REQUEST['update'][$i]]);\r
46                                         $st->execute();\r
47                                 }                               \r
48                         }                       \r
49                 }\r
50         }\r
51         \r
52         $st=$db->prepare("SELECT LocalIdentityID,Name,PublicKey,PublishTrustList,SingleUse,PublishBoardList FROM tblLocalIdentity ORDER BY Name;");\r
53         $st->execute();\r
54         ?>\r
55         <h2>Local Identities</h2>\r
56         <form name="frmlocalidentity" method="post">\r
57         <input type="hidden" name="formaction" value="update">\r
58         <table>\r
59                 <tr>\r
60                         <td></td>\r
61                         <th>Name</th>\r
62                         <th>Single Use</th>\r
63                         <th>Publish Trust List</th>\r
64                 </tr>\r
65         <?php\r
66         $row=0;\r
67         while($record=$st->fetch())\r
68         {\r
69                 ?>\r
70                 <tr>\r
71                         <td>\r
72                                 <input type="checkbox" name="update[]" value="<?php print($row); ?>">\r
73                         </td>\r
74                         <td title="<?php print($record[2]); ?>">\r
75                                 <input type="hidden" name="localidentityid[]" value="<?php print($record[0]); ?>">\r
76                                 <?php print($record[1]); ?>\r
77                         </td>\r
78                         <td>\r
79                                 <?php\r
80                                 truefalsedropdown("singleuse[]",$record[4]);\r
81                                 ?>\r
82                         </td>\r
83                         <td>\r
84                                 <?php\r
85                                 truefalsedropdown("publishtrustlist[]",$record[3]);\r
86                                 ?>\r
87                         </td>\r
88                 </tr>\r
89                 <?php\r
90                 $row++;\r
91         }\r
92         ?>\r
93         </table>\r
94         <input type="submit" value="Update Selected">\r
95         <input type="submit" value="Delete Selected" onClick="if(confirm('Delete Selected Identities?')){frmlocalidentity.formaction.value='delete';}else{return false;}">\r
96         </form>\r
97         <?php\r
98 }\r
99 \r
100         include_once('template.php');\r
101 \r
102 ?>