3 // This program is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU General Public License
5 // as published by the Free Software Foundation; either version 2
6 // of the License, or (at your option) any later version.
11 //INCLUDES, DO ANY ACTIONS, THEN GET OUR DATA
12 require_once("../globals.php");
13 require_once("$srcdir/registry.inc.php");
15 use OpenEMR\Common\Acl\AclMain
;
16 use OpenEMR\Common\Acl\AclExtended
;
17 use OpenEMR\Common\Csrf\CsrfUtils
;
18 use OpenEMR\Common\Forms\CoreFormToPortalUtility
;
19 use OpenEMR\Common\Twig\TwigContainer
;
20 use OpenEMR\Core\Header
;
22 if (!AclMain
::aclCheckCore('admin', 'forms')) {
23 echo (new TwigContainer(null, $GLOBALS['kernel']))->getTwig()->render('core/unauthorized.html.twig', ['pageTitle' => xl("Forms Administration")]);
27 if (!empty($_GET['method']) && ($_GET['method'] == "enable")) {
28 if (!CsrfUtils
::verifyCsrfToken($_GET["csrf_token_form"])) {
29 CsrfUtils
::csrfNotVerified();
31 updateRegistered($_GET['id'], "state=1");
32 } elseif (!empty($_GET['method']) && ($_GET['method'] == "disable")) {
33 if (!CsrfUtils
::verifyCsrfToken($_GET["csrf_token_form"])) {
34 CsrfUtils
::csrfNotVerified();
36 updateRegistered($_GET['id'], "state=0");
37 } elseif (!empty($_GET['method']) && ($_GET['method'] == "install_db")) {
38 if (!CsrfUtils
::verifyCsrfToken($_GET["csrf_token_form"])) {
39 CsrfUtils
::csrfNotVerified();
41 $dir = getRegistryEntry($_GET['id'], "directory");
42 if (installSQL("$srcdir/../interface/forms/{$dir['directory']}")) {
43 updateRegistered($_GET['id'], "sql_run=1");
45 $err = xl('ERROR: could not open table.sql, broken form?');
47 } elseif (!empty($_GET['method']) && ($_GET['method'] == "register")) {
48 if (!CsrfUtils
::verifyCsrfToken($_GET["csrf_token_form"])) {
49 CsrfUtils
::csrfNotVerified();
51 $newRegisteredFormId = registerForm($_GET['name']) or $err = xl('error while registering form!');
53 // below block of code will insert the patient portal template (if it has not yet already been added) if the
54 // form is patient portal compliant
55 CoreFormToPortalUtility
::insertPatientPortalTemplate($newRegisteredFormId);
59 $bigdata = getRegistered("%") or $bigdata = false;
61 //START OUT OUR PAGE....
66 <?php Header
::setupHeader(); ?
>
68 <body
class="body_top">
70 <div
class="container-fluid">
74 <h2
class="title"><?php
echo xlt('Forms Administration');?
></h2
>
79 <div
class="col-12 mt-3">
82 if (!CsrfUtils
::verifyCsrfToken($_POST["csrf_token_form"])) {
83 CsrfUtils
::csrfNotVerified();
85 foreach ($_POST as $key => $val) {
86 if (preg_match('/nickname_(\d+)/', $key, $matches)) {
87 sqlQuery("update registry set nickname = ? where id = ?", array($val, $matches[1]));
88 } elseif (preg_match('/category_(\d+)/', $key, $matches)) {
89 sqlQuery("update registry set category = ? where id = ?", array($val, $matches[1]));
90 } elseif (preg_match('/priority_(\d+)/', $key, $matches)) {
91 sqlQuery("update registry set priority = ? where id = ?", array($val, $matches[1]));
92 } elseif (preg_match('/aco_spec_(\d+)/', $key, $matches)) {
93 sqlQuery("update registry set aco_spec = ? where id = ?", array($val, $matches[1]));
99 <?php
//ERROR REPORTING
101 echo "<span>" . text($err) . "</span>\n";
105 <?php
//REGISTERED SECTION ?>
106 <span
class="font-weight-bold"><?php
echo xlt('Registered');?
></span
>
107 <form method
="post" action
='./forms_admin.php'>
108 <span
class="font-italic">
109 <?php
echo xlt('click here to update priority, category, nickname and access control settings'); ?
>
111 <input type
="hidden" name
="csrf_token_form" value
="<?php echo attr(CsrfUtils::collectCsrfToken()); ?>" />
112 <input
class="btn btn-primary" type
='submit' name
='update' value
='<?php echo xla('Save
'); ?>'>
114 <div
class="table-responsive mt-3">
115 <table
class="table table-striped table-sm">
118 <th colspan
="5"></th
>
119 <th
><?php
echo xlt('Priority'); ?
> </th
>
120 <th
><?php
echo xlt('Category'); ?
> </th
>
121 <th
><?php
echo xlt('Nickname'); ?
> </th
>
122 <th
><?php
echo xlt('Access Control'); ?
></th
>
126 if ($bigdata != false) {
127 foreach ($bigdata as $registry) {
128 $priority_category = sqlQuery(
129 "select priority, category, nickname, aco_spec from registry where id = ?",
130 array($registry['id'])
132 $patientPortalCompliant = file_exists($GLOBALS['srcdir'] . "/../interface/forms/" . $registry['directory'] . "/patient_portal.php");
136 <span
class='text'><?php
echo text($registry['id']); ?
></span
>
140 echo text(xl_form_title($registry['name']));
141 echo ($patientPortalCompliant) ?
' <i class="fas fa-cloud-arrow-up" title="' . xla('Patient Portal Compliant') . '"></i>' : '';
145 if ($registry['sql_run'] == 0) {
146 echo "<td><span class='text'>" . xlt('registered') . "</span>";
147 } elseif ($registry['state'] == "0") {
148 echo "<td><a class='link_submit text-danger' href='./forms_admin.php?id=" . attr_url($registry['id']) . "&method=enable&csrf_token_form=" . attr_url(CsrfUtils
::collectCsrfToken()) . "'>" . xlt('disabled') . "</a>";
150 echo "<td><a class='link_submit text-success' href='./forms_admin.php?id=" . attr_url($registry['id']) . "&method=disable&csrf_token_form=" . attr_url(CsrfUtils
::collectCsrfToken()) . "'>" . xlt('enabled') . "</a>";
155 <span
class='text'><?php
156 if ($registry['unpackaged']) {
157 echo xlt('PHP extracted');
159 echo xlt('PHP compressed');
166 if ($registry['sql_run']) {
167 echo "<span class='text'>" . xlt('DB installed') . "</span>";
169 echo "<a class='link_submit' href='./forms_admin.php?id=" . attr_url($registry['id']) . "&method=install_db&csrf_token_form=" . attr_url(CsrfUtils
::collectCsrfToken()) . "'>" . xlt('install DB') . "</a>";
174 echo "<td><input type='text' class='form-control form-control-sm' size='4' name='priority_" . attr($registry['id']) . "' value='" . attr($priority_category['priority']) . "'></td>";
175 echo "<td><input type='text' class='form-control form-control-sm' size='10' name='category_" . attr($registry['id']) . "' value='" . attr($priority_category['category']) . "'></td>";
176 echo "<td><input type='text' class='form-control form-control-sm' size='10' name='nickname_" . attr($registry['id']) . "' value='" . attr($priority_category['nickname']) . "'></td>";
178 echo "<select name='aco_spec_" . attr($registry['id']) . "' class='form-control form-control-sm'>";
179 echo "<option value=''></option>";
180 echo AclExtended
::genAcoHtmlOptions($priority_category['aco_spec']);
193 <?php
//UNREGISTERED SECTION ?>
194 <span
class="font-weight-bold"><?php
echo xlt('Unregistered'); ?
></span
>
195 <div
class="table-responsive mt-3">
196 <table
class="table table-striped table-sm">
198 $dpath = "$srcdir/../interface/forms/";
199 $dp = opendir($dpath);
201 for ($i = 0; false != ($fname = readdir($dp)); $i++
) {
203 $fname != "." && $fname != ".." && $fname != "CVS" && $fname != "LBF" &&
204 (is_dir($dpath . $fname) ||
stristr($fname, ".tar.gz") ||
205 stristr($fname, ".tar") ||
stristr($fname, ".zip") ||
206 stristr($fname, ".gz"))
212 // ballards 11/05/2005 fixed bug in removing registered form from the list
213 if ($bigdata != false) {
214 foreach ($bigdata as $registry) {
215 $key = array_search($registry['directory'], $inDir) ; /* returns integer or FALSE */
220 foreach ($inDir as $fname) {
221 if (stristr($fname, ".tar.gz") ||
stristr($fname, ".tar") ||
stristr($fname, ".zip") ||
stristr($fname, ".gz")) {
222 $phpState = "PHP compressed";
224 $phpState = "PHP extracted";
230 $form_title_file = @file
($GLOBALS['srcdir'] . "/../interface/forms/$fname/info.txt");
231 if ($form_title_file) {
232 $form_title = $form_title_file[0];
234 $form_title = $fname;
236 $patientPortalCompliant = file_exists($GLOBALS['srcdir'] . "/../interface/forms/" . $fname . "/patient_portal.php");
239 echo text(xl_form_title($form_title));
240 echo ($patientPortalCompliant) ?
' <i class="fas fa-cloud-arrow-up" title="' . xla('Patient Portal Compliant') . '"></i>' : '';
245 if ($phpState == "PHP extracted") {
246 echo '<a class="link_submit" href="./forms_admin.php?name=' . attr_url($fname) . '&method=register&csrf_token_form=' . attr_url(CsrfUtils
::collectCsrfToken()) . '">' . xlt('register') . '</a>';
248 echo '<span class="text">' . xlt('n/a') . '</span>';
253 <span
class="text"><?php
echo xlt($phpState); ?
></span
>
256 <span
class="text"><?php
echo xlt('n/a'); ?
></span
>