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');
72function llxHeaderVierge($title, $head =
"", $disablejs = 0, $disablehead = 0, $arrayofjs = [], $arrayofcss = [])
74 print
'<html><title>Export agenda cal</title><body>';
85 print
'</body></html>';
91$entity = (!empty($_GET[
'entity']) ? (int) $_GET[
'entity'] : (!empty($_POST[
'entity']) ? (int) $_POST[
'entity'] : 1));
92if (is_numeric($entity)) {
93 define(
"DOLENTITY", $entity);
97require
'../../main.inc.php';
105require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
113if (
GETPOST(
"format",
'alpha')) {
114 $format =
GETPOST(
"format",
'alpha');
117 $type =
GETPOST(
"type",
'alpha');
133if (
GETPOST(
"project",
'alpha')) {
134 $filters[
'project'] =
GETPOST(
"project",
'alpha');
136if (
GETPOST(
"logina",
'alpha')) {
137 $filters[
'logina'] =
GETPOST(
"logina",
'alpha');
139if (
GETPOST(
"logint",
'alpha')) {
140 $filters[
'logint'] =
GETPOST(
"logint",
'alpha');
142if (
GETPOST(
"notactiontype",
'alpha')) {
143 $filters[
'notactiontype'] =
GETPOST(
"notactiontype",
'alpha');
145if (
GETPOST(
"actiontype",
'alpha')) {
146 $filters[
'actiontype'] =
GETPOST(
"actiontype",
'alpha');
148if (
GETPOST(
"actioncode",
'alpha')) {
149 $filters[
'actioncode'] =
GETPOST(
"actioncode",
'alpha');
152 $filters[
'notolderthan'] =
GETPOSTINT(
"notolderthan");
154 $filters[
'notolderthan'] =
getDolGlobalInt(
'MAIN_AGENDA_EXPORT_PAST_DELAY', 100);
160 $filters[
'limit'] = 1000;
162if (
GETPOST(
"module",
'alpha')) {
163 $filters[
'module'] =
GETPOST(
"module",
'alpha');
165if (
GETPOST(
"status",
"intcomma")) {
166 $filters[
'status'] =
GETPOST(
"status",
"intcomma");
186 print
'<div class="error">Module Agenda was not configured properly.</div>';
192$hookmanager->initHooks(array(
'agendaexport'));
194$reshook = $hookmanager->executeHooks(
'doActions', $filters);
199 if (!empty($hookmanager->errors) && is_array($hookmanager->errors)) {
200 print
'<div class="error">'.implode(
'<br>', $hookmanager->errors).
'</div>';
202 print
'<div class="error">'.$hookmanager->error.
'</div>';
205} elseif (empty($reshook)) {
213 print
'<div class="error">Bad value for key.</div>';
221$shortfilename =
'calendar';
222$filename = $shortfilename;
224foreach ($filters as $key => $value) {
226 if ($key ==
'year') {
227 $filename .=
'-year'.$value;
230 $filename .=
'-id'.$value;
232 if ($key ==
'idfrom') {
233 $filename .=
'-idfrom'.$value;
235 if ($key ==
'idto') {
236 $filename .=
'-idto'.$value;
238 if ($key ==
'project') {
239 $filename .=
'-project'.$value;
240 $shortfilename .=
'-project'.$value;
242 if ($key ==
'logina') {
243 $filename .=
'-logina'.$value;
245 if ($key ==
'logint') {
246 $filename .=
'-logint'.$value;
248 if ($key ==
'notactiontype') {
249 $filename .=
'-notactiontype'.$value;
251 if ($key ==
'actiontype') {
252 $filename .=
'-actiontype'.$value;
254 if ($key ==
'actioncode') {
255 $filename .=
'-actioncode'.$value;
257 if ($key ==
'module') {
258 $filename .=
'-module'.$value;
259 if ($value ==
'project@eventorganization') {
260 $shortfilename .=
'-project';
261 } elseif ($value ==
'conforbooth@eventorganization') {
262 $shortfilename .=
'-conforbooth';
265 if ($key ==
'status') {
266 $filename .=
'-status'.$value;
270if ($format ==
'vcal') {
271 $shortfilename .=
'.vcs';
274if ($format ==
'ical') {
275 $shortfilename .=
'.ics';
278if ($format ==
'rss') {
279 $shortfilename .=
'.rss';
282if ($shortfilename ==
'dolibarrcalendar') {
283 $langs->load(
"errors");
288 print
'<div class="error">'.$langs->trans(
"ErrorWrongValueForParameterX",
'format').
'</div>';
299$exportholidays =
GETPOSTINT(
'includeholidays');
302if ($format ==
'ical' || $format ==
'vcal') {
304 if (!empty($filters[
'project']) && !empty($filters[
'module']) && ($filters[
'module'] ==
'project@eventorganization' || $filters[
'module'] ==
'conforbooth@eventorganization')) {
305 $filters[
'notolderthan'] =
null;
308 $result = $agenda->build_exportfile($format, $type, $cachedelay, $filename, $filters, $exportholidays);
311 if (GETPOSTISSET(
"attachment")) {
312 $attachment =
GETPOST(
"attachment");
315 $contenttype =
'text/calendar';
316 if (GETPOSTISSET(
"contenttype")) {
317 $contenttype =
GETPOST(
"contenttype");
320 $outputencoding =
'UTF-8';
323 header(
'Content-Type: '.$contenttype.($outputencoding ?
'; charset='.$outputencoding :
''));
326 header(
'Content-Disposition: attachment; filename="'.$shortfilename.
'"');
330 header(
'Cache-Control: max-age='.$cachedelay.
', private, must-revalidate');
332 header(
'Cache-Control: private, must-revalidate');
335 header(
"X-Frame-Options: SAMEORIGIN");
338 $outputfile = $conf->agenda->dir_temp.
'/'.$filename;
339 $result = readfile($outputfile);
341 print
'File '.$outputfile.
' was empty.';
349 print
'Error '.$agenda->error;
355if ($format ==
'rss') {
356 $result = $agenda->build_exportfile($format, $type, $cachedelay, $filename, $filters, $exportholidays);
359 if (GETPOSTISSET(
"attachment")) {
360 $attachment =
GETPOST(
"attachment");
363 $contenttype =
'application/rss+xml';
364 if (GETPOSTISSET(
"contenttype")) {
365 $contenttype =
GETPOST(
"contenttype");
368 $outputencoding =
'UTF-8';
371 header(
'Content-Type: '.$contenttype.($outputencoding ?
'; charset='.$outputencoding :
''));
374 header(
'Content-Disposition: attachment; filename="'.$filename.
'"');
376 header(
'Content-Disposition: inline; filename="'.$filename.
'"');
383 header(
'Cache-Control: max-age='.$cachedelay.
', private, must-revalidate');
385 header(
'Cache-Control: private, must-revalidate');
388 header(
"X-Frame-Options: SAMEORIGIN");
391 $outputfile = $conf->agenda->dir_temp.
'/'.$filename;
392 $result = readfile($outputfile);
394 print
'File '.$outputfile.
' was empty.';
402 print
'Error '.$agenda->error;
412print
'<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=[])
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.