72 print
'</body></html>';
77$entity = (!empty($_GET[
'entity']) ? (int) $_GET[
'entity'] : (!empty($_POST[
'entity']) ? (int) $_POST[
'entity'] : 1));
78if (is_numeric($entity)) {
79 define(
"DOLENTITY", $entity);
83require
'../../main.inc.php';
84require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
90 $conf->global->MAIN_AGENDA_EXPORT_PAST_DELAY = 100;
96if (
GETPOST(
"format",
'alpha')) {
97 $format =
GETPOST(
"format",
'alpha');
100 $type =
GETPOST(
"type",
'alpha');
105 $filters[
'year'] =
GETPOST(
"year",
'int');
108 $filters[
'id'] =
GETPOST(
"id",
'int');
111 $filters[
'idfrom'] =
GETPOST(
"idfrom",
'int');
114 $filters[
'idto'] =
GETPOST(
"idto",
'int');
116if (
GETPOST(
"project",
'alpha')) {
117 $filters[
'project'] =
GETPOST(
"project",
'alpha');
119if (
GETPOST(
"logina",
'alpha')) {
120 $filters[
'logina'] =
GETPOST(
"logina",
'alpha');
122if (
GETPOST(
"logint",
'alpha')) {
123 $filters[
'logint'] =
GETPOST(
"logint",
'alpha');
125if (
GETPOST(
"notactiontype",
'alpha')) {
126 $filters[
'notactiontype'] =
GETPOST(
"notactiontype",
'alpha');
128if (
GETPOST(
"actiontype",
'alpha')) {
129 $filters[
'actiontype'] =
GETPOST(
"actiontype",
'alpha');
131if (
GETPOST(
"notolderthan",
'int')) {
132 $filters[
'notolderthan'] =
GETPOST(
"notolderthan",
"int");
134 $filters[
'notolderthan'] = $conf->global->MAIN_AGENDA_EXPORT_PAST_DELAY;
136if (
GETPOST(
"module",
'alpha')) {
137 $filters[
'module'] =
GETPOST(
"module",
'alpha');
140 $filters[
'status'] =
GETPOST(
"status",
'int');
144if (!isModEnabled(
'agenda')) {
158 print
'<div class="error">Module Agenda was not configured properly.</div>';
164$hookmanager->initHooks(array(
'agendaexport'));
166$reshook = $hookmanager->executeHooks(
'doActions', $filters);
169 if (!empty($hookmanager->errors) && is_array($hookmanager->errors)) {
170 print
'<div class="error">'.implode(
'<br>', $hookmanager->errors).
'</div>';
172 print
'<div class="error">'.$hookmanager->error.
'</div>';
175} elseif (empty($reshook)) {
177 if (empty($_GET[
"exportkey"]) || $conf->global->MAIN_AGENDA_XCAL_EXPORTKEY != $_GET[
"exportkey"]) {
181 print
'<div class="error">Bad value for key.</div>';
189$shortfilename =
'dolibarrcalendar';
190$filename = $shortfilename;
192foreach ($filters as $key => $value) {
194 if ($key ==
'year') {
195 $filename .=
'-year'.$value;
198 $filename .=
'-id'.$value;
200 if ($key ==
'idfrom') {
201 $filename .=
'-idfrom'.$value;
203 if ($key ==
'idto') {
204 $filename .=
'-idto'.$value;
206 if ($key ==
'project') {
207 $filename .=
'-project'.$value;
209 if ($key ==
'logina') {
210 $filename .=
'-logina'.$value;
212 if ($key ==
'logint') {
213 $filename .=
'-logint'.$value;
215 if ($key ==
'notactiontype') {
216 $filename .=
'-notactiontype'.$value;
218 if ($key ==
'actiontype') {
219 $filename .=
'-actiontype'.$value;
221 if ($key ==
'module') {
222 $filename .=
'-module'.$value;
224 if ($key ==
'status') {
225 $filename .=
'-status'.$value;
229if ($format ==
'vcal') {
230 $shortfilename .=
'.vcs';
233if ($format ==
'ical') {
234 $shortfilename .=
'.ics';
237if ($format ==
'rss') {
238 $shortfilename .=
'.rss';
241if ($shortfilename ==
'dolibarrcalendar') {
242 $langs->load(
"errors");
244 print
'<div class="error">'.$langs->trans(
"ErrorWrongValueForParameterX",
'format').
'</div>';
253 $cachedelay = $conf->global->MAIN_AGENDA_EXPORT_CACHE;
256$exportholidays =
GETPOST(
'includeholidays',
'int');
259if ($format ==
'ical' || $format ==
'vcal') {
260 $result = $agenda->build_exportfile($format, $type, $cachedelay, $filename, $filters, $exportholidays);
263 if (isset($_GET[
"attachment"])) {
264 $attachment = $_GET[
"attachment"];
267 $contenttype =
'text/calendar';
268 if (isset($_GET[
"contenttype"])) {
269 $contenttype = $_GET[
"contenttype"];
272 $outputencoding =
'UTF-8';
275 header(
'Content-Type: '.$contenttype.($outputencoding ?
'; charset='.$outputencoding :
''));
278 header(
'Content-Disposition: attachment; filename="'.$shortfilename.
'"');
282 header(
'Cache-Control: max-age='.$cachedelay.
', private, must-revalidate');
284 header(
'Cache-Control: private, must-revalidate');
288 $outputfile = $conf->agenda->dir_temp.
'/'.$filename;
289 $result = readfile($outputfile);
291 print
'File '.$outputfile.
' was empty.';
297 print
'Error '.$agenda->error;
303if ($format ==
'rss') {
304 $result = $agenda->build_exportfile($format, $type, $cachedelay, $filename, $filters, $exportholidays);
307 if (isset($_GET[
"attachment"])) {
308 $attachment = $_GET[
"attachment"];
311 $contenttype =
'application/rss+xml';
312 if (isset($_GET[
"contenttype"])) {
313 $contenttype = $_GET[
"contenttype"];
316 $outputencoding =
'UTF-8';
319 header(
'Content-Type: '.$contenttype.($outputencoding ?
'; charset='.$outputencoding :
''));
322 header(
'Content-Disposition: attachment; filename="'.$filename.
'"');
329 header(
'Cache-Control: max-age='.$cachedelay.
', private, must-revalidate');
331 header(
'Cache-Control: private, must-revalidate');
335 $outputfile = $conf->agenda->dir_temp.
'/'.$filename;
336 $result = readfile($outputfile);
338 print
'File '.$outputfile.
' was empty.';
344 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.