34if (!defined(
'NOTOKENRENEWAL')) {
35 define(
'NOTOKENRENEWAL',
'1');
37if (!defined(
'NOREQUIREMENU')) {
38 define(
'NOREQUIREMENU',
'1');
40if (!defined(
'NOREQUIREHTML')) {
41 define(
'NOREQUIREHTML',
'1');
43if (!defined(
'NOREQUIREAJAX')) {
44 define(
'NOREQUIREAJAX',
'1');
46if (!defined(
'NOLOGIN')) {
49if (!defined(
'NOCSRFCHECK')) {
50 define(
"NOCSRFCHECK", 1);
52if (!defined(
'NOIPCHECK')) {
53 define(
'NOIPCHECK',
'1');
73function llxHeaderVierge($title, $head =
"", $disablejs = 0, $disablehead = 0, $arrayofjs = [], $arrayofcss = [], $ws =
'')
75 print
'<html><title>Export agenda cal</title><body>';
86 print
'</body></html>';
92$entity = (!empty($_GET[
'entity']) ? (int) $_GET[
'entity'] : (!empty($_POST[
'entity']) ? (int) $_POST[
'entity'] : 1));
93if (is_numeric($entity)) {
94 define(
"DOLENTITY", $entity);
98require
'../../main.inc.php';
106require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
114if (
GETPOST(
"format",
'alpha')) {
115 $format =
GETPOST(
"format",
'alpha');
118 $type =
GETPOST(
"type",
'alpha');
134if (
GETPOST(
"project",
'alpha')) {
135 $filters[
'project'] =
GETPOST(
"project",
'alpha');
137if (
GETPOST(
"logina",
'alpha')) {
138 $filters[
'logina'] =
GETPOST(
"logina",
'alpha');
140if (
GETPOST(
"logint",
'alpha')) {
141 $filters[
'logint'] =
GETPOST(
"logint",
'alpha');
143if (
GETPOST(
"notactiontype",
'alpha')) {
144 $filters[
'notactiontype'] =
GETPOST(
"notactiontype",
'alpha');
146if (
GETPOST(
"actiontype",
'alpha')) {
147 $filters[
'actiontype'] =
GETPOST(
"actiontype",
'alpha');
149if (
GETPOST(
"actioncode",
'alpha')) {
150 $filters[
'actioncode'] =
GETPOST(
"actioncode",
'alpha');
153 $filters[
'notolderthan'] =
GETPOSTINT(
"notolderthan");
155 $filters[
'notolderthan'] =
getDolGlobalInt(
'MAIN_AGENDA_EXPORT_PAST_DELAY', 100);
161 $filters[
'limit'] = 1000;
163if (
GETPOST(
"module",
'alpha')) {
164 $filters[
'module'] =
GETPOST(
"module",
'alpha');
166if (
GETPOST(
"status",
"intcomma")) {
167 $filters[
'status'] =
GETPOST(
"status",
"intcomma");
187 print
'<div class="error">Module Agenda was not configured properly.</div>';
193$hookmanager->initHooks(array(
'agendaexport'));
195$reshook = $hookmanager->executeHooks(
'doActions', $filters);
200 if (!empty($hookmanager->errors) && is_array($hookmanager->errors)) {
201 print
'<div class="error">'.implode(
'<br>', $hookmanager->errors).
'</div>';
203 print
'<div class="error">'.$hookmanager->error.
'</div>';
206} elseif (empty($reshook)) {
214 print
'<div class="error">Bad value for key.</div>';
222$shortfilename =
'calendar';
223$filename = $shortfilename;
225foreach ($filters as $key => $value) {
227 if ($key ==
'year') {
228 $filename .=
'-year'.$value;
231 $filename .=
'-id'.$value;
233 if ($key ==
'idfrom') {
234 $filename .=
'-idfrom'.$value;
236 if ($key ==
'idto') {
237 $filename .=
'-idto'.$value;
239 if ($key ==
'project') {
240 $filename .=
'-project'.$value;
241 $shortfilename .=
'-project'.$value;
243 if ($key ==
'logina') {
244 $filename .=
'-logina'.$value;
246 if ($key ==
'logint') {
247 $filename .=
'-logint'.$value;
249 if ($key ==
'notactiontype') {
250 $filename .=
'-notactiontype'.$value;
252 if ($key ==
'actiontype') {
253 $filename .=
'-actiontype'.$value;
255 if ($key ==
'actioncode') {
256 $filename .=
'-actioncode'.$value;
258 if ($key ==
'module') {
259 $filename .=
'-module'.$value;
260 if ($value ==
'project@eventorganization') {
261 $shortfilename .=
'-project';
262 } elseif ($value ==
'conforbooth@eventorganization') {
263 $shortfilename .=
'-conforbooth';
266 if ($key ==
'status') {
267 $filename .=
'-status'.$value;
271if ($format ==
'vcal') {
272 $shortfilename .=
'.vcs';
275if ($format ==
'ical') {
276 $shortfilename .=
'.ics';
279if ($format ==
'rss') {
280 $shortfilename .=
'.rss';
283if ($shortfilename ==
'dolibarrcalendar') {
284 $langs->load(
"errors");
289 print
'<div class="error">'.$langs->trans(
"ErrorWrongValueForParameterX",
'format').
'</div>';
300$exportholidays =
GETPOSTINT(
'includeholidays');
303if ($format ==
'ical' || $format ==
'vcal') {
305 if (!empty($filters[
'project']) && !empty($filters[
'module']) && ($filters[
'module'] ==
'project@eventorganization' || $filters[
'module'] ==
'conforbooth@eventorganization')) {
306 $filters[
'notolderthan'] =
null;
309 $result = $agenda->build_exportfile($format, $type, $cachedelay, $filename, $filters, $exportholidays);
312 if (GETPOSTISSET(
"attachment")) {
313 $attachment =
GETPOST(
"attachment");
316 $contenttype =
'text/calendar';
317 if (GETPOSTISSET(
"contenttype")) {
318 $contenttype =
GETPOST(
"contenttype");
321 $outputencoding =
'UTF-8';
324 header(
'Content-Type: '.$contenttype.($outputencoding ?
'; charset='.$outputencoding :
''));
327 header(
'Content-Disposition: attachment; filename="'.$shortfilename.
'"');
331 header(
'Cache-Control: max-age='.$cachedelay.
', private, must-revalidate');
333 header(
'Cache-Control: private, must-revalidate');
336 header(
"X-Frame-Options: SAMEORIGIN");
339 $outputfile =
$conf->agenda->dir_temp.
'/'.$filename;
340 $result = readfile($outputfile);
342 print
'File '.$outputfile.
' was empty.';
350 print
'Error '.$agenda->error;
356if ($format ==
'rss') {
357 $result = $agenda->build_exportfile($format, $type, $cachedelay, $filename, $filters, $exportholidays);
360 if (GETPOSTISSET(
"attachment")) {
361 $attachment =
GETPOST(
"attachment");
364 $contenttype =
'application/rss+xml';
365 if (GETPOSTISSET(
"contenttype")) {
366 $contenttype =
GETPOST(
"contenttype");
369 $outputencoding =
'UTF-8';
372 header(
'Content-Type: '.$contenttype.($outputencoding ?
'; charset='.$outputencoding :
''));
375 header(
'Content-Disposition: attachment; filename="'.$filename.
'"');
377 header(
'Content-Disposition: inline; filename="'.$filename.
'"');
384 header(
'Cache-Control: max-age='.$cachedelay.
', private, must-revalidate');
386 header(
'Cache-Control: private, must-revalidate');
389 header(
"X-Frame-Options: SAMEORIGIN");
392 $outputfile =
$conf->agenda->dir_temp.
'/'.$filename;
393 $result = readfile($outputfile);
395 print
'File '.$outputfile.
' was empty.';
403 print
'Error '.$agenda->error;
413print
'<div class="error">'.$agenda->error.
'</div>';
if(!defined( 'NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined( 'NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) if(!defined( 'NOLOGIN')) if(!defined('NOCSRFCHECK')) if(!defined( 'NOIPCHECK')) llxHeaderVierge($title, $head="", $disablejs=0, $disablehead=0, $arrayofjs=[], $arrayofcss=[], $ws='')
Header function.
llxFooterVierge()
Footer function.
Class to manage agenda events (actions)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
if(!defined( 'NOREQUIREMENU')) if(!empty(GETPOST('seteventmessages', 'alpha'))) if(!function_exists("llxHeader")) top_httphead($contenttype='text/html', $forcenocache=0)
Show HTTP header.
httponly_accessforbidden($message='1', $http_response_code=403, $stringalreadysanitized=0)
Show a message to say access is forbidden and stop program.