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';
98require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
110 $conf->global->MAIN_AGENDA_EXPORT_PAST_DELAY = 100;
116if (
GETPOST(
"format",
'alpha')) {
117 $format =
GETPOST(
"format",
'alpha');
120 $type =
GETPOST(
"type",
'alpha');
136if (
GETPOST(
"project",
'alpha')) {
137 $filters[
'project'] =
GETPOST(
"project",
'alpha');
139if (
GETPOST(
"logina",
'alpha')) {
140 $filters[
'logina'] =
GETPOST(
"logina",
'alpha');
142if (
GETPOST(
"logint",
'alpha')) {
143 $filters[
'logint'] =
GETPOST(
"logint",
'alpha');
145if (
GETPOST(
"notactiontype",
'alpha')) {
146 $filters[
'notactiontype'] =
GETPOST(
"notactiontype",
'alpha');
148if (
GETPOST(
"actiontype",
'alpha')) {
149 $filters[
'actiontype'] =
GETPOST(
"actiontype",
'alpha');
151if (
GETPOST(
"actioncode",
'alpha')) {
152 $filters[
'actioncode'] =
GETPOST(
"actioncode",
'alpha');
155 $filters[
'notolderthan'] =
GETPOSTINT(
"notolderthan");
162 $filters[
'limit'] = 1000;
164if (
GETPOST(
"module",
'alpha')) {
165 $filters[
'module'] =
GETPOST(
"module",
'alpha');
167if (
GETPOST(
"status",
"intcomma")) {
168 $filters[
'status'] =
GETPOST(
"status",
"intcomma");
172if (!isModEnabled(
'agenda')) {
188 print
'<div class="error">Module Agenda was not configured properly.</div>';
194$hookmanager->initHooks(array(
'agendaexport'));
196$reshook = $hookmanager->executeHooks(
'doActions', $filters);
201 if (!empty($hookmanager->errors) && is_array($hookmanager->errors)) {
202 print
'<div class="error">'.implode(
'<br>', $hookmanager->errors).
'</div>';
204 print
'<div class="error">'.$hookmanager->error.
'</div>';
207} elseif (empty($reshook)) {
215 print
'<div class="error">Bad value for key.</div>';
223$shortfilename =
'calendar';
224$filename = $shortfilename;
226foreach ($filters as $key => $value) {
228 if ($key ==
'year') {
229 $filename .=
'-year'.$value;
232 $filename .=
'-id'.$value;
234 if ($key ==
'idfrom') {
235 $filename .=
'-idfrom'.$value;
237 if ($key ==
'idto') {
238 $filename .=
'-idto'.$value;
240 if ($key ==
'project') {
241 $filename .=
'-project'.$value;
242 $shortfilename .=
'-project'.$value;
244 if ($key ==
'logina') {
245 $filename .=
'-logina'.$value;
247 if ($key ==
'logint') {
248 $filename .=
'-logint'.$value;
250 if ($key ==
'notactiontype') {
251 $filename .=
'-notactiontype'.$value;
253 if ($key ==
'actiontype') {
254 $filename .=
'-actiontype'.$value;
256 if ($key ==
'actioncode') {
257 $filename .=
'-actioncode'.$value;
259 if ($key ==
'module') {
260 $filename .=
'-module'.$value;
261 if ($value ==
'project@eventorganization') {
262 $shortfilename .=
'-project';
263 } elseif ($value ==
'conforbooth@eventorganization') {
264 $shortfilename .=
'-conforbooth';
267 if ($key ==
'status') {
268 $filename .=
'-status'.$value;
272if ($format ==
'vcal') {
273 $shortfilename .=
'.vcs';
276if ($format ==
'ical') {
277 $shortfilename .=
'.ics';
280if ($format ==
'rss') {
281 $shortfilename .=
'.rss';
284if ($shortfilename ==
'dolibarrcalendar') {
285 $langs->load(
"errors");
290 print
'<div class="error">'.$langs->trans(
"ErrorWrongValueForParameterX",
'format').
'</div>';
302$exportholidays =
GETPOSTINT(
'includeholidays');
305if ($format ==
'ical' || $format ==
'vcal') {
307 if (!empty($filters[
'project']) && !empty($filters[
'module']) && ($filters[
'module'] ==
'project@eventorganization' || $filters[
'module'] ==
'conforbooth@eventorganization')) {
308 $filters[
'notolderthan'] =
null;
311 $result = $agenda->build_exportfile($format, $type, $cachedelay, $filename, $filters, $exportholidays);
314 if (GETPOSTISSET(
"attachment")) {
315 $attachment =
GETPOST(
"attachment");
318 $contenttype =
'text/calendar';
319 if (GETPOSTISSET(
"contenttype")) {
320 $contenttype =
GETPOST(
"contenttype");
323 $outputencoding =
'UTF-8';
326 header(
'Content-Type: '.$contenttype.($outputencoding ?
'; charset='.$outputencoding :
''));
329 header(
'Content-Disposition: attachment; filename="'.$shortfilename.
'"');
333 header(
'Cache-Control: max-age='.$cachedelay.
', private, must-revalidate');
335 header(
'Cache-Control: private, must-revalidate');
338 header(
"X-Frame-Options: SAMEORIGIN");
341 $outputfile =
$conf->agenda->dir_temp.
'/'.$filename;
342 $result = readfile($outputfile);
344 print
'File '.$outputfile.
' was empty.';
352 print
'Error '.$agenda->error;
358if ($format ==
'rss') {
359 $result = $agenda->build_exportfile($format, $type, $cachedelay, $filename, $filters, $exportholidays);
362 if (GETPOSTISSET(
"attachment")) {
363 $attachment =
GETPOST(
"attachment");
366 $contenttype =
'application/rss+xml';
367 if (GETPOSTISSET(
"contenttype")) {
368 $contenttype =
GETPOST(
"contenttype");
371 $outputencoding =
'UTF-8';
374 header(
'Content-Type: '.$contenttype.($outputencoding ?
'; charset='.$outputencoding :
''));
377 header(
'Content-Disposition: attachment; filename="'.$filename.
'"');
379 header(
'Content-Disposition: inline; filename="'.$filename.
'"');
386 header(
'Cache-Control: max-age='.$cachedelay.
', private, must-revalidate');
388 header(
'Cache-Control: private, must-revalidate');
391 header(
"X-Frame-Options: SAMEORIGIN");
394 $outputfile =
$conf->agenda->dir_temp.
'/'.$filename;
395 $result = readfile($outputfile);
397 print
'File '.$outputfile.
' was empty.';
405 print
'Error '.$agenda->error;
415print
'<div class="error">'.$agenda->error.
'</div>';
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
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.
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.
if(!defined( 'NOREQUIREMENU')) if(!empty(GETPOST('seteventmessages', 'alpha'))) if(!function_exists("llxHeader")) top_httphead($contenttype='text/html', $forcenocache=0)
Show HTTP header.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
httponly_accessforbidden($message='1', $http_response_code=403, $stringalreadysanitized=0)
Show a message to say access is forbidden and stop program.