33if (!defined(
'NOTOKENRENEWAL')) {
34 define(
'NOTOKENRENEWAL',
'1');
36if (!defined(
'NOREQUIREMENU')) {
37 define(
'NOREQUIREMENU',
'1');
39if (!defined(
'NOREQUIREHTML')) {
40 define(
'NOREQUIREHTML',
'1');
42if (!defined(
'NOREQUIREAJAX')) {
43 define(
'NOREQUIREAJAX',
'1');
45if (!defined(
'NOLOGIN')) {
48if (!defined(
'NOCSRFCHECK')) {
49 define(
"NOCSRFCHECK", 1);
51if (!defined(
'NOIPCHECK')) {
52 define(
'NOIPCHECK',
'1');
69function llxHeaderVierge($title, $head =
"", $disablejs = 0, $disablehead = 0, $arrayofjs = [], $arrayofcss = [])
71 print
'<html><title>Export agenda cal</title><body>';
80 print
'</body></html>';
86$entity = (!empty($_GET[
'entity']) ? (int) $_GET[
'entity'] : (!empty($_POST[
'entity']) ? (int) $_POST[
'entity'] : 1));
87if (is_numeric($entity)) {
88 define(
"DOLENTITY", $entity);
92require
'../../main.inc.php';
93require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
105 $conf->global->MAIN_AGENDA_EXPORT_PAST_DELAY = 100;
111if (
GETPOST(
"format",
'alpha')) {
112 $format =
GETPOST(
"format",
'alpha');
115 $type =
GETPOST(
"type",
'alpha');
131if (
GETPOST(
"project",
'alpha')) {
132 $filters[
'project'] =
GETPOST(
"project",
'alpha');
134if (
GETPOST(
"logina",
'alpha')) {
135 $filters[
'logina'] =
GETPOST(
"logina",
'alpha');
137if (
GETPOST(
"logint",
'alpha')) {
138 $filters[
'logint'] =
GETPOST(
"logint",
'alpha');
140if (
GETPOST(
"notactiontype",
'alpha')) {
141 $filters[
'notactiontype'] =
GETPOST(
"notactiontype",
'alpha');
143if (
GETPOST(
"actiontype",
'alpha')) {
144 $filters[
'actiontype'] =
GETPOST(
"actiontype",
'alpha');
146if (
GETPOST(
"actioncode",
'alpha')) {
147 $filters[
'actioncode'] =
GETPOST(
"actioncode",
'alpha');
150 $filters[
'notolderthan'] =
GETPOSTINT(
"notolderthan");
157 $filters[
'limit'] = 1000;
159if (
GETPOST(
"module",
'alpha')) {
160 $filters[
'module'] =
GETPOST(
"module",
'alpha');
162if (
GETPOST(
"status",
"intcomma")) {
163 $filters[
'status'] =
GETPOST(
"status",
"intcomma");
167if (!isModEnabled(
'agenda')) {
183 print
'<div class="error">Module Agenda was not configured properly.</div>';
189$hookmanager->initHooks(array(
'agendaexport'));
191$reshook = $hookmanager->executeHooks(
'doActions', $filters);
196 if (!empty($hookmanager->errors) && is_array($hookmanager->errors)) {
197 print
'<div class="error">'.implode(
'<br>', $hookmanager->errors).
'</div>';
199 print
'<div class="error">'.$hookmanager->error.
'</div>';
202} elseif (empty($reshook)) {
210 print
'<div class="error">Bad value for key.</div>';
218$shortfilename =
'calendar';
219$filename = $shortfilename;
221foreach ($filters as $key => $value) {
223 if ($key ==
'year') {
224 $filename .=
'-year'.$value;
227 $filename .=
'-id'.$value;
229 if ($key ==
'idfrom') {
230 $filename .=
'-idfrom'.$value;
232 if ($key ==
'idto') {
233 $filename .=
'-idto'.$value;
235 if ($key ==
'project') {
236 $filename .=
'-project'.$value;
237 $shortfilename .=
'-project'.$value;
239 if ($key ==
'logina') {
240 $filename .=
'-logina'.$value;
242 if ($key ==
'logint') {
243 $filename .=
'-logint'.$value;
245 if ($key ==
'notactiontype') {
246 $filename .=
'-notactiontype'.$value;
248 if ($key ==
'actiontype') {
249 $filename .=
'-actiontype'.$value;
251 if ($key ==
'actioncode') {
252 $filename .=
'-actioncode'.$value;
254 if ($key ==
'module') {
255 $filename .=
'-module'.$value;
256 if ($value ==
'project@eventorganization') {
257 $shortfilename .=
'-project';
258 } elseif ($value ==
'conforbooth@eventorganization') {
259 $shortfilename .=
'-conforbooth';
262 if ($key ==
'status') {
263 $filename .=
'-status'.$value;
267if ($format ==
'vcal') {
268 $shortfilename .=
'.vcs';
271if ($format ==
'ical') {
272 $shortfilename .=
'.ics';
275if ($format ==
'rss') {
276 $shortfilename .=
'.rss';
279if ($shortfilename ==
'dolibarrcalendar') {
280 $langs->load(
"errors");
285 print
'<div class="error">'.$langs->trans(
"ErrorWrongValueForParameterX",
'format').
'</div>';
297$exportholidays =
GETPOSTINT(
'includeholidays');
300if ($format ==
'ical' || $format ==
'vcal') {
302 if (!empty($filters[
'project']) && !empty($filters[
'module']) && ($filters[
'module'] ==
'project@eventorganization' || $filters[
'module'] ==
'conforbooth@eventorganization')) {
303 $filters[
'notolderthan'] =
null;
306 $result = $agenda->build_exportfile($format, $type, $cachedelay, $filename, $filters, $exportholidays);
309 if (GETPOSTISSET(
"attachment")) {
310 $attachment =
GETPOST(
"attachment");
313 $contenttype =
'text/calendar';
314 if (GETPOSTISSET(
"contenttype")) {
315 $contenttype =
GETPOST(
"contenttype");
318 $outputencoding =
'UTF-8';
321 header(
'Content-Type: '.$contenttype.($outputencoding ?
'; charset='.$outputencoding :
''));
324 header(
'Content-Disposition: attachment; filename="'.$shortfilename.
'"');
328 header(
'Cache-Control: max-age='.$cachedelay.
', private, must-revalidate');
330 header(
'Cache-Control: private, must-revalidate');
333 header(
"X-Frame-Options: SAMEORIGIN");
336 $outputfile =
$conf->agenda->dir_temp.
'/'.$filename;
337 $result = readfile($outputfile);
339 print
'File '.$outputfile.
' was empty.';
347 print
'Error '.$agenda->error;
353if ($format ==
'rss') {
354 $result = $agenda->build_exportfile($format, $type, $cachedelay, $filename, $filters, $exportholidays);
357 if (GETPOSTISSET(
"attachment")) {
358 $attachment =
GETPOST(
"attachment");
361 $contenttype =
'application/rss+xml';
362 if (GETPOSTISSET(
"contenttype")) {
363 $contenttype =
GETPOST(
"contenttype");
366 $outputencoding =
'UTF-8';
369 header(
'Content-Type: '.$contenttype.($outputencoding ?
'; charset='.$outputencoding :
''));
372 header(
'Content-Disposition: attachment; filename="'.$filename.
'"');
374 header(
'Content-Disposition: inline; filename="'.$filename.
'"');
381 header(
'Cache-Control: max-age='.$cachedelay.
', private, must-revalidate');
383 header(
'Cache-Control: private, must-revalidate');
386 header(
"X-Frame-Options: SAMEORIGIN");
389 $outputfile =
$conf->agenda->dir_temp.
'/'.$filename;
390 $result = readfile($outputfile);
392 print
'File '.$outputfile.
' was empty.';
400 print
'Error '.$agenda->error;
410print
'<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.