Highway to PSR2
[openemr.git] / interface / forms_admin / forms_admin.php
blob60bafac081590cbfec0135a3c6d72d6b873025fa
1 <?php
2 // This program is free software; you can redistribute it and/or
3 // modify it under the terms of the GNU General Public License
4 // as published by the Free Software Foundation; either version 2
5 // of the License, or (at your option) any later version.
10 //INCLUDES, DO ANY ACTIONS, THEN GET OUR DATA
11 require_once("../globals.php");
12 require_once("$srcdir/acl.inc");
13 require_once("$phpgacl_location/gacl_api.class.php");
14 require_once("$srcdir/registry.inc");
16 if ($_GET['method'] == "enable") {
17 updateRegistered($_GET['id'], "state=1");
18 } elseif ($_GET['method'] == "disable") {
19 updateRegistered($_GET['id'], "state=0");
20 } elseif ($_GET['method'] == "install_db") {
21 $dir = getRegistryEntry($_GET['id'], "directory");
22 if (installSQL("$srcdir/../interface/forms/{$dir['directory']}")) {
23 updateRegistered($_GET['id'], "sql_run=1");
24 } else {
25 $err = xl('ERROR: could not open table.sql, broken form?');
27 } elseif ($_GET['method'] == "register") {
28 registerForm($_GET['name']) or $err=xl('error while registering form!');
31 $bigdata = getRegistered("%") or $bigdata = false;
33 //START OUT OUR PAGE....
35 <html>
36 <head>
37 <?php html_header_show();?>
38 <link rel="stylesheet" href="<?php echo $css_header;?>" type="text/css">
39 </head>
40 <body class="body_top">
41 <span class="title"><?php xl('Forms Administration', 'e');?></span>
42 <br><br>
43 <?php
44 foreach ($_POST as $key => $val) {
45 if (preg_match('/nickname_(\d+)/', $key, $matches)) {
46 sqlQuery("update registry set nickname = ? where id = ?", array($val, $matches[1]));
47 } else if (preg_match('/category_(\d+)/', $key, $matches)) {
48 sqlQuery("update registry set category = ? where id = ?", array($val, $matches[1]));
49 } else if (preg_match('/priority_(\d+)/', $key, $matches)) {
50 sqlQuery("update registry set priority = ? where id = ?", array($val, $matches[1]));
51 } else if (preg_match('/aco_spec_(\d+)/', $key, $matches)) {
52 sqlQuery("update registry set aco_spec = ? where id = ?", array($val, $matches[1]));
57 <?php //ERROR REPORTING
58 if ($err) {
59 echo "<span class=bold>" . text($err) . "</span><br><br>\n";
63 <?php //REGISTERED SECTION ?>
64 <span class=bold><?php xl('Registered', 'e');?></span><br>
65 <form method=POST action ='./forms_admin.php'>
66 <i><?php echo xlt('click here to update priority, category, nickname and access control settings'); ?></i>
67 <input type='submit' name='update' value='<?php echo xla('update'); ?>'><br>
68 <table border=0 cellpadding=1 cellspacing=2 width="500">
69 <tr>
70 <td> </td>
71 <td> </td>
72 <td> </td>
73 <td> </td>
74 <td> </td>
75 <td><?php echo xlt('Priority'); ?> </td>
76 <td><?php echo xlt('Category'); ?> </td>
77 <td><?php echo xlt('Nickname'); ?> </td>
78 <td><?php echo xlt('Access Control'); ?></td>
79 </tr>
80 <?php
81 $color="#CCCCCC";
82 if ($bigdata != false) {
83 foreach ($bigdata as $registry) {
84 $priority_category = sqlQuery(
85 "select priority, category, nickname, aco_spec from registry where id = ?",
86 array($registry['id'])
89 <tr>
90 <td bgcolor="<?php echo $color; ?>" width="2%">
91 <span class='text'><?php echo text($registry['id']); ?></span>
92 </td>
93 <td bgcolor="<?php echo attr($color); ?>" width="30%">
94 <span class='bold'><?php echo xl_form_title($registry['name']); ?></span>
95 </td>
96 <?php
97 if ($registry['sql_run'] == 0) {
98 echo "<td bgcolor='" . attr($color) . "' width='10%'><span class='text'>" . xlt('registered') . "</span>";
99 } elseif ($registry['state'] == "0") {
100 echo "<td bgcolor='#FFCCCC' width='10%'><a class='link_submit' href='./forms_admin.php?id={$registry['id']}&method=enable'>" . xlt('disabled') . "</a>";
101 } else {
102 echo "<td bgcolor='#CCFFCC' width='10%'><a class='link_submit' href='./forms_admin.php?id={$registry['id']}&method=disable'>" . xlt('enabled') . "</a>";
104 ?></td>
105 <td bgcolor="<?php echo attr($color); ?>" width="10%">
106 <span class='text'><?php
107 if ($registry['unpackaged']) {
108 echo xlt('PHP extracted');
109 } else {
110 echo xlt('PHP compressed');
112 ?></span>
113 </td>
114 <td bgcolor="<?php echo attr($color); ?>" width="10%">
115 <?php
116 if ($registry['sql_run']) {
117 echo "<span class='text'>" . xlt('DB installed') . "</span>";
118 } else {
119 echo "<a class='link_submit' href='./forms_admin.php?id=" . attr($registry['id']) . "&method=install_db'>" . xlt('install DB') . "</a>";
122 </td>
123 <?php
124 echo "<td><input type='text' size='4' name='priority_" . attr($registry['id']) . "' value='" . attr($priority_category['priority']) . "'></td>";
125 echo "<td><input type='text' size='10' name='category_" . attr($registry['id']) . "' value='" . attr($priority_category['category']) . "'></td>";
126 echo "<td><input type='text' size='10' name='nickname_" . attr($registry['id']) . "' value='" . attr($priority_category['nickname']) . "'></td>";
127 echo "<td>";
128 echo "<select name='aco_spec_" . attr($registry['id']) . "'>";
129 echo "<option value=''></option>";
130 echo gen_aco_html_options($priority_category['aco_spec']);
131 echo "</select>";
132 echo "</td>";
134 </tr>
135 <?php
136 if ($color=="#CCCCCC") {
137 $color="#999999";
138 } else {
139 $color="#CCCCCC";
141 } //end of foreach
144 </table>
145 <hr>
147 <?php //UNREGISTERED SECTION ?>
148 <span class='bold'><?php echo xlt('Unregistered'); ?></span><br>
149 <table border=0 cellpadding=1 cellspacing=2 width="500">
150 <?php
151 $dpath = "$srcdir/../interface/forms/";
152 $dp = opendir($dpath);
153 $color="#CCCCCC";
154 for ($i=0; false != ($fname = readdir($dp)); $i++) {
155 if ($fname != "." && $fname != ".." && $fname != "CVS" && $fname != "LBF" &&
156 (is_dir($dpath.$fname) || stristr($fname, ".tar.gz") ||
157 stristr($fname, ".tar") || stristr($fname, ".zip") ||
158 stristr($fname, ".gz"))) {
159 $inDir[$i] = $fname;
163 // ballards 11/05/2005 fixed bug in removing registered form from the list
164 if ($bigdata != false) {
165 foreach ($bigdata as $registry) {
166 $key = array_search($registry['directory'], $inDir) ; /* returns integer or FALSE */
167 unset($inDir[$key]);
171 foreach ($inDir as $fname) {
172 if (stristr($fname, ".tar.gz") || stristr($fname, ".tar") || stristr($fname, ".zip") || stristr($fname, ".gz")) {
173 $phpState = "PHP compressed";
174 } else {
175 $phpState = "PHP extracted";
178 <tr>
179 <td bgcolor="<?php echo $color?>" width="1%">
180 <span class=text> </span>
181 </td>
182 <td bgcolor="<?php echo $color?>" width="20%">
183 <?php
184 $form_title_file = @file($GLOBALS['srcdir']."/../interface/forms/$fname/info.txt");
185 if ($form_title_file) {
186 $form_title = $form_title_file[0];
187 } else {
188 $form_title = $fname;
191 <span class=bold><?php echo xl_form_title($form_title); ?></span>
192 </td>
193 <td bgcolor="<?php echo $color?>" width="10%"><?php
194 if ($phpState == "PHP extracted") {
195 echo '<a class=link_submit href="./forms_admin.php?name=' . urlencode($fname) . '&method=register">' . xl('register') . '</a>';
196 } else {
197 echo '<span class=text>' . xl('n/a') . '</span>';
199 ?></td>
200 <td bgcolor="<?php echo $color?>" width="20%">
201 <span class=text><?php echo xl($phpState); ?></span>
202 </td>
203 <td bgcolor="<?php echo $color?>" width="10%">
204 <span class=text><?php xl('n/a', 'e'); ?></span>
205 </td>
206 </tr>
207 <?php
208 if ($color=="#CCCCCC") {
209 $color="#999999";
210 } else {
211 $color="#CCCCCC";
214 flush();
215 }//end of foreach
217 </table>
219 </body>
220 </html>