forked from Evarisk/DigiQuali
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dolismqindex.php
140 lines (120 loc) · 4.67 KB
/
dolismqindex.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
<?php
/* Copyright (C) 2022 EVARISK <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
/**
* \file dolismqindex.php
* \ingroup dolismq
* \brief Home page of dolismq top menu
*/
// Load Dolibarr environment
if (file_exists('../../main.inc.php')) {
require_once '../../main.inc.php';
} else {
die('Include of main fails');
}
// Libraries
require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT . '/includes/parsedown/Parsedown.php';
require_once __DIR__ . '/core/modules/modDoliSMQ.class.php';
// Global variables definitions
global $conf, $db, $langs, $user;
// Load translation files required by the page
$langs->loadLangs(['dolismq@dolismq']);
// Get parameters
$action = GETPOST('action', 'aZ09');
// Initialize technical objects
$dolismq = new modDoliSMQ($db);
$parse = new Parsedown();
// Security check
if (!$user->rights->dolismq->lire) accessforbidden();
/*
* Actions
*/
if ($action == 'closenotice') {
dolibarr_set_const($db, "DoliSMQ_SHOW_PATCH_NOTE", 0, 'integer', 0, '', $conf->entity);
}
/*
* View
*/
$help_url = 'FR:Module_DoliSMQ';
$title = $langs->trans('DoliSMQArea');
$morejs = ['/dolismq/js/dolismq.js'];
$morecss = ['/dolismq/css/dolismq.css'];
llxHeader('', $title . ' ' . $dolismq->version, $help_url, '', 0, 0, $morejs, $morecss);
print load_fiche_titre($title . ' ' . $dolismq->version, '', 'dolismq_color.png@dolismq');
if ($conf->global->DOLISMQ_JUST_UPDATED == 1) : ?>
<div class="wpeo-notice notice-success">
<div class="notice-content">
<div class="notice-subtitle"><strong><?php echo $langs->trans("DoliSMQUpdate"); ?></strong>
<?php echo $langs->trans('DoliSMQHasBeenUpdatedTo', $dolismq->version) ?>
</div>
</div>
</div>
<?php dolibarr_set_const($db, 'DOLISMQ_JUST_UPDATED', 0, 'integer', 0, '', $conf->entity);
endif;
if ($conf->global->DOLISMQ_VERSION != $dolismq->version) {
$dolismq->remove();
$dolismq->init();
dolibarr_set_const($db, 'DOLISMQ_JUST_UPDATED', 1, 'integer', 0, '', $conf->entity);
dolibarr_set_const($db, 'DOLISMQ_SHOW_PATCH_NOTE', 1, 'integer', 0, '', $conf->entity);
}
if ($conf->global->DOLISMQ_SHOW_PATCH_NOTE) : ?>
<div class="wpeo-notice notice notice-info">
<input type="hidden" name="token" value="<?php echo newToken(); ?>">
<div class="notice-content">
<div class="notice-title"><?php echo $langs->trans("DoliSMQPatchNote", $dolismq->version); ?>
<div class="show-patchnote wpeo-button button-square-40 button-blue wpeo-tooltip-event modal-open" aria-label="<?php echo $langs->trans('ShowPatchNote'); ?>">
<i class="fas fa-list button-icon"></i>
</div>
</div>
</div>
<div class="notice-close notice-close-forever wpeo-tooltip-event" aria-label="<?php echo $langs->trans("DontShowPatchNote"); ?>" data-direction="left"><i class="fas fa-times"></i></div>
</div>
<div class="wpeo-modal wpeo-modal-patchnote">
<div class="modal-container wpeo-modal-event" style="max-width: 1280px; max-height: 1000px">
<!-- Modal-Header -->
<div class="modal-header">
<h2 class="modal-title"><?php echo $langs->trans("DoliSMQPatchNote", $dolismq->version); ?></h2>
<div class="modal-close"><i class="fas fa-times"></i></div>
</div>
<!-- Modal Content-->
<div class="modal-content">
<?php $ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.github.com/repos/evarisk/dolismq/releases/tags/' . $dolismq->version);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_USERAGENT,'DoliSMQ');
$output = curl_exec($ch);
curl_close($ch);
$data = json_decode($output);
$data->body = preg_replace('/- #\b\d{1,4}\b/', '-', $data->body);
$data->body = preg_replace('/- #\b\d{1,4}\b/', '-', $data->body);
$html = $parse->text($data->body);
print $html;
?>
</div>
<!-- Modal-Footer -->
<div class="modal-footer">
<div class="wpeo-button button-grey button-uppercase modal-close">
<span><?php echo $langs->trans('CloseModal'); ?></span>
</div>
</div>
</div>
</div>
<?php endif;
// End of page
llxFooter();
$db->close();