Smart fhir admin enable / disable management (#4142)
[openemr.git] / sql_patch.php
blobf7194b5c4be4f94a1917361a13bc0332fcb604fd
1 <?php
3 // Copyright (C) 2008-2010 Rod Roark <rod@sunsetsystems.com>
4 //
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
9 //
10 // This may be run after an upgraded OpenEMR has been installed.
11 // Its purpose is to upgrade the MySQL OpenEMR database as needed
12 // for the new release.
14 // Checks if the server's PHP version is compatible with OpenEMR:
15 require_once(dirname(__FILE__) . "/src/Common/Compatibility/Checker.php");
16 $response = OpenEMR\Common\Compatibility\Checker::checkPhpVersion();
17 if ($response !== true) {
18 die(htmlspecialchars($response));
21 // Disable PHP timeout. This will not work in safe mode.
22 ini_set('max_execution_time', '0');
24 $ignoreAuth = true; // no login required
26 require_once('interface/globals.php');
27 require_once('library/sql_upgrade_fx.php');
29 use OpenEMR\Services\VersionService;
31 // Force logging off
32 $GLOBALS["enable_auditlog"] = 0;
34 $EMRversion = trim(preg_replace('/\s*\([^)]*\)/', '', $GLOBALS['openemr_version']));
38 <html>
39 <head>
40 <title>OpenEMR <?php echo attr($EMRversion) ?> <?php echo xlt('Database Patch'); ?></title>
41 <link rel='STYLESHEET' href='interface/themes/style_blue.css'>
42 <link rel="shortcut icon" href="public/images/favicon.ico" />
43 </head>
44 <body style="color:green;">
46 <div style="box-shadow: 3px 3px 5px 6px #ccc; border-radius: 20px; padding: 10px 40px;background-color:#EFEFEF; width:500px; margin:40px auto">
48 <p style="font-weight:bold; font-size:1.8em; text-align:center">OpenEMR <?php echo text($EMRversion),' ',xlt('Database Patch'),' ',text($v_realpatch) ?></p>
49 <p style="font-weight:bold; text-align:center;"><?php echo xlt('Applying Patch to site'),' : ',text($_SESSION['site_id']) ?></p>
52 <?php
53 upgradeFromSqlFile('patch.sql');
54 flush();
56 echo '<p style="font-weight:bold; text-align:left; color:green">',xlt('Updating global configuration defaults'),'...</p>';
57 $skipGlobalEvent = true; //use in globals.inc.php script to skip event stuff
58 require_once("library/globals.inc.php");
59 foreach ($GLOBALS_METADATA as $grpname => $grparr) {
60 foreach ($grparr as $fldid => $fldarr) {
61 list($fldname, $fldtype, $flddef, $flddesc) = $fldarr;
62 if (is_array($fldtype) || (substr($fldtype, 0, 2) !== 'm_')) {
63 $row = sqlQuery("SELECT count(*) AS count FROM globals WHERE gl_name = '$fldid'");
64 if (empty($row['count'])) {
65 sqlStatement("INSERT INTO globals ( gl_name, gl_index, gl_value ) " .
66 "VALUES ( '$fldid', '0', '$flddef' )");
72 $versionService = new VersionService();
73 $currentVersion = $versionService->fetch();
74 $desiredVersion = $currentVersion;
75 $desiredVersion['v_database'] = $v_database;
76 $desiredVersion['v_tag'] = $v_tag;
77 $desiredVersion['v_realpatch'] = $v_realpatch;
78 $desiredVersion['v_patch'] = $v_patch;
79 $desiredVersion['v_minor'] = $v_minor;
80 $desiredVersion['v_major'] = $v_major;
82 $canRealPatchBeApplied = $versionService->canRealPatchBeApplied($desiredVersion);
83 if ($canRealPatchBeApplied) {
84 echo '<p style="font-weight:bold; text-align:left;">',xlt('Updating version indicators'),'...</p>';
85 $versionService->update($desiredVersion);
88 echo '<p style="text-align:center; font-size:1.8em;">',xlt('Database Patch'),' ',text($desiredVersion['v_realpatch']),' ',xlt('finished'),'.</p>';
90 echo '<p style="text-align:center; font-size:1.8em;">OpenEMR ',xlt('Version'),' = ',text($EMRversion . '(' . $desiredVersion['v_realpatch'] . ')'),'.</p>';
92 echo '<p><a style="border-radius: 10px; padding:5px; width:200px; margin:0 auto; background-color:green; color:white; font-weight:bold; display:block; text-align:center;" href="index.php?site=',attr($_SESSION['site_id']) . '">',xlt('Log in'),'</a></p>';
94 if (isset($_SERVER['HTTP_REFERER'])) {
95 $split = preg_split('/\//', $_SERVER['HTTP_REFERER']);
96 if ($split[count($split) - 1] == 'admin.php') {
97 echo '<p><a style="border-radius: 10px; padding:5px; width:200px; margin:0 auto; background-color:green; color:white; font-weight:bold; display:block; text-align:center;" href="admin.php">',xlt('Back to Admin Page'),'</a></p>';
102 </div>
103 </body>
104 </html>