forked from Evarisk/Digirisk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
digiriskdolibarrindex.php
187 lines (162 loc) · 7.12 KB
/
digiriskdolibarrindex.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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
<?php
/* Copyright (C) 2021 EOXIA <[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 digiriskdolibarrindex.php
* \ingroup digiriskdolibarr
* \brief Home page of digiriskdolibarr top menu
*/
// Load Dolibarr environment
$res = 0;
// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined)
if ( ! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"] . "/main.inc.php";
// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME
$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1;
while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; }
if ( ! $res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1)) . "/main.inc.php")) $res = @include substr($tmp, 0, ($i + 1)) . "/main.inc.php";
if ( ! $res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1))) . "/main.inc.php")) $res = @include dirname(substr($tmp, 0, ($i + 1))) . "/main.inc.php";
// Try main.inc.php using relative path
if ( ! $res && file_exists("../../main.inc.php")) $res = @include "../../main.inc.php";
if ( ! $res && file_exists("../../../main.inc.php")) $res = @include "../../../main.inc.php";
if ( ! $res) die("Include of main fails");
require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php';
require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/modules/project/mod_project_simple.php';
require_once DOL_DOCUMENT_ROOT . '/includes/parsedown/Parsedown.php';
require_once './core/modules/modDigiriskDolibarr.class.php';
require_once __DIR__ . '/class/dashboarddigiriskstats.class.php';
global $user, $langs, $conf, $db;
// Load translation files required by the page
$langs->loadLangs(array("digiriskdolibarr@digiriskdolibarr"));
// Initialize technical objects
$digirisk = new modDigiriskdolibarr($db);
$project = new Project($db);
$third_party = new Societe($db);
$stats = new DashboardDigiriskStats($db);
$parse = new Parsedown();
$projectRef = new $conf->global->PROJECT_ADDON();
// Security check
if ( ! $user->rights->digiriskdolibarr->lire) accessforbidden();
// Parameters
$action = GETPOST('action', 'alpha');
$backtopage = GETPOST('backtopage', 'alpha');
$value = GETPOST('value', 'alpha');
$error = 0;
/*
* Actions
*/
require_once './core/tpl/digiriskdolibarr_projectcreation_action.tpl.php';
/*
* View
*/
$help_url = 'FR:Module_DigiriskDolibarr';
$morejs = array("/digiriskdolibarr/js/digiriskdolibarr.js");
$morecss = array("/digiriskdolibarr/css/digiriskdolibarr.css");
llxHeader("", $langs->trans("DigiriskDolibarrArea") . ' ' . $digirisk->version, $help_url, '', '', '', $morejs, $morecss);
print load_fiche_titre($langs->trans("DigiriskDolibarrArea") . ' ' . $digirisk->version, '', 'digiriskdolibarr32px.png@digiriskdolibarr');
?>
<?php if ($conf->global->DIGIRISKDOLIBARR_JUST_UPDATED == 1) : ?>
<div class="wpeo-notice notice-success">
<div class="notice-content">
<div class="notice-subtitle"><strong><?php echo $langs->trans("DigiriskUpdate"); ?></strong>
<?php echo $langs->trans('DigiriskHasBeenUpdatedTo', $digirisk->version) ?>
</div>
</div>
</div>
<?php
dolibarr_set_const($db, 'DIGIRISKDOLIBARR_JUST_UPDATED', 0, 'integer', 0, '', $conf->entity);
?>
<?php endif; ?>
<?php if ($conf->global->DIGIRISKDOLIBARR_VERSION != $digirisk->version) : ?>
<?php
$digirisk->remove();
global $langs;
require_once DOL_DOCUMENT_ROOT . '/core/modules/modECM.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/modules/modProjet.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/modules/modSociete.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/modules/modTicket.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/modules/modCategorie.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/modules/modFckeditor.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/modules/modApi.class.php';
$modEcm = new modECM($db);
$modProjet = new modProjet($db);
$modSociete = new modSociete($db);
$modTicket = new modTicket($db);
$modCategorie = new modCategorie($db);
$modFckeditor = new modFckeditor($db);
$modApi = new modApi($db);
$modEcm->init();
$modProjet->init();
$modSociete->init();
$modTicket->init();
$modCategorie->init();
$modFckeditor->init();
$modApi->init();
$langs->loadLangs(array("digiriskdolibarr@digiriskdolibarr", "other"));
$digirisk->init();
dolibarr_set_const($db, 'DIGIRISKDOLIBARR_JUST_UPDATED', 1, 'integer', 0, '', $conf->entity);
?>
<script>
window.location.reload()
</script>
<?php endif; ?>
<div class="wpeo-notice notice-info">
<div class="notice-content">
<div class="notice-title"><?php echo $langs->trans("DigiriskPatchNote", $digirisk->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>
<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("DigiriskPatchNote", $digirisk->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/digirisk/releases/tags/' . $digirisk->version);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_USERAGENT,'DigiriskDolibarr');
$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
require_once __DIR__ . '/core/tpl/digiriskdolibarr_dashboard.tpl.php';
// End of page
llxFooter();
$db->close();