73 print
'</body></html>';
79$entity = (!empty($_GET[
'entity']) ? (int) $_GET[
'entity'] : (!empty($_POST[
'entity']) ? (int) $_POST[
'entity'] : 1));
80if (is_numeric($entity)) {
81 define(
"DOLENTITY", $entity);
85require
'../../main.inc.php';
86require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
92 $conf->global->MAIN_AGENDA_EXPORT_PAST_DELAY = 100;
98if (
GETPOST(
"format",
'alpha')) {
99 $format =
GETPOST(
"format",
'alpha');
102 $type =
GETPOST(
"type",
'alpha');
118if (
GETPOST(
"project",
'alpha')) {
119 $filters[
'project'] =
GETPOST(
"project",
'alpha');
121if (
GETPOST(
"logina",
'alpha')) {
122 $filters[
'logina'] =
GETPOST(
"logina",
'alpha');
124if (
GETPOST(
"logint",
'alpha')) {
125 $filters[
'logint'] =
GETPOST(
"logint",
'alpha');
127if (
GETPOST(
"notactiontype",
'alpha')) {
128 $filters[
'notactiontype'] =
GETPOST(
"notactiontype",
'alpha');
130if (
GETPOST(
"actiontype",
'alpha')) {
131 $filters[
'actiontype'] =
GETPOST(
"actiontype",
'alpha');
133if (
GETPOST(
"actioncode",
'alpha')) {
134 $filters[
'actioncode'] =
GETPOST(
"actioncode",
'alpha');
137 $filters[
'notolderthan'] =
GETPOSTINT(
"notolderthan");
144 $filters[
'limit'] = 1000;
146if (
GETPOST(
"module",
'alpha')) {
147 $filters[
'module'] =
GETPOST(
"module",
'alpha');
149if (
GETPOST(
"status",
"intcomma")) {
150 $filters[
'status'] =
GETPOST(
"status",
"intcomma");
154if (!isModEnabled(
'agenda')) {
170 print
'<div class="error">Module Agenda was not configured properly.</div>';
176$hookmanager->initHooks(array(
'agendaexport'));
178$reshook = $hookmanager->executeHooks(
'doActions', $filters);
183 if (!empty($hookmanager->errors) && is_array($hookmanager->errors)) {
184 print
'<div class="error">'.implode(
'<br>', $hookmanager->errors).
'</div>';
186 print
'<div class="error">'.$hookmanager->error.
'</div>';
189} elseif (empty($reshook)) {
197 print
'<div class="error">Bad value for key.</div>';
205$shortfilename =
'dolibarrcalendar';
206$filename = $shortfilename;
208foreach ($filters as $key => $value) {
210 if ($key ==
'year') {
211 $filename .=
'-year'.$value;
214 $filename .=
'-id'.$value;
216 if ($key ==
'idfrom') {
217 $filename .=
'-idfrom'.$value;
219 if ($key ==
'idto') {
220 $filename .=
'-idto'.$value;
222 if ($key ==
'project') {
223 $filename .=
'-project'.$value;
224 $shortfilename .=
'-project'.$value;
226 if ($key ==
'logina') {
227 $filename .=
'-logina'.$value;
229 if ($key ==
'logint') {
230 $filename .=
'-logint'.$value;
232 if ($key ==
'notactiontype') {
233 $filename .=
'-notactiontype'.$value;
235 if ($key ==
'actiontype') {
236 $filename .=
'-actiontype'.$value;
238 if ($key ==
'actioncode') {
239 $filename .=
'-actioncode'.$value;
241 if ($key ==
'module') {
242 $filename .=
'-module'.$value;
243 if ($value ==
'project@eventorganization') {
244 $shortfilename .=
'-project';
245 } elseif ($value ==
'conforbooth@eventorganization') {
246 $shortfilename .=
'-conforbooth';
249 if ($key ==
'status') {
250 $filename .=
'-status'.$value;
254if ($format ==
'vcal') {
255 $shortfilename .=
'.vcs';
258if ($format ==
'ical') {
259 $shortfilename .=
'.ics';
262if ($format ==
'rss') {
263 $shortfilename .=
'.rss';
266if ($shortfilename ==
'dolibarrcalendar') {
267 $langs->load(
"errors");
272 print
'<div class="error">'.$langs->trans(
"ErrorWrongValueForParameterX",
'format').
'</div>';
284$exportholidays =
GETPOSTINT(
'includeholidays');
287if ($format ==
'ical' || $format ==
'vcal') {
289 if (!empty($filters[
'project']) && !empty($filters[
'module']) && ($filters[
'module'] ==
'project@eventorganization' || $filters[
'module'] ==
'conforbooth@eventorganization')) {
290 $filters[
'notolderthan'] =
null;
293 $result = $agenda->build_exportfile($format, $type, $cachedelay, $filename, $filters, $exportholidays);
296 if (GETPOSTISSET(
"attachment")) {
297 $attachment =
GETPOST(
"attachment");
300 $contenttype =
'text/calendar';
301 if (GETPOSTISSET(
"contenttype")) {
302 $contenttype =
GETPOST(
"contenttype");
305 $outputencoding =
'UTF-8';
308 header(
'Content-Type: '.$contenttype.($outputencoding ?
'; charset='.$outputencoding :
''));
311 header(
'Content-Disposition: attachment; filename="'.$shortfilename.
'"');
315 header(
'Cache-Control: max-age='.$cachedelay.
', private, must-revalidate');
317 header(
'Cache-Control: private, must-revalidate');
320 header(
"X-Frame-Options: SAMEORIGIN");
323 $outputfile = $conf->agenda->dir_temp.
'/'.$filename;
324 $result = readfile($outputfile);
326 print
'File '.$outputfile.
' was empty.';
334 print
'Error '.$agenda->error;
340if ($format ==
'rss') {
341 $result = $agenda->build_exportfile($format, $type, $cachedelay, $filename, $filters, $exportholidays);
344 if (GETPOSTISSET(
"attachment")) {
345 $attachment =
GETPOST(
"attachment");
348 $contenttype =
'application/rss+xml';
349 if (GETPOSTISSET(
"contenttype")) {
350 $contenttype =
GETPOST(
"contenttype");
353 $outputencoding =
'UTF-8';
356 header(
'Content-Type: '.$contenttype.($outputencoding ?
'; charset='.$outputencoding :
''));
359 header(
'Content-Disposition: attachment; filename="'.$filename.
'"');
361 header(
'Content-Disposition: inline; filename="'.$filename.
'"');
368 header(
'Cache-Control: max-age='.$cachedelay.
', private, must-revalidate');
370 header(
'Cache-Control: private, must-revalidate');
373 header(
"X-Frame-Options: SAMEORIGIN");
376 $outputfile = $conf->agenda->dir_temp.
'/'.$filename;
377 $result = readfile($outputfile);
379 print
'File '.$outputfile.
' was empty.';
387 print
'Error '.$agenda->error;
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
if(!defined( 'NOREQUIREMENU')) if(!empty(GETPOST('seteventmessages', 'alpha'))) if(!function_exists("llxHeader")) top_httphead($contenttype='text/html', $forcenocache=0)
Show HTTP header.