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';
87if (!isModEnabled(
'agenda')) {
92if (empty($conf->global->MAIN_AGENDA_EXPORT_PAST_DELAY)) {
93 $conf->global->MAIN_AGENDA_EXPORT_PAST_DELAY = 100;
99if (
GETPOST(
"format",
'alpha')) {
100 $format =
GETPOST(
"format",
'alpha');
103 $type =
GETPOST(
"type",
'alpha');
108 $filters[
'year'] =
GETPOST(
"year",
'int');
111 $filters[
'id'] =
GETPOST(
"id",
'int');
114 $filters[
'idfrom'] =
GETPOST(
"idfrom",
'int');
117 $filters[
'idto'] =
GETPOST(
"idto",
'int');
119if (
GETPOST(
"project",
'alpha')) {
120 $filters[
'project'] =
GETPOST(
"project",
'alpha');
122if (
GETPOST(
"logina",
'alpha')) {
123 $filters[
'logina'] =
GETPOST(
"logina",
'alpha');
125if (
GETPOST(
"logint",
'alpha')) {
126 $filters[
'logint'] =
GETPOST(
"logint",
'alpha');
128if (
GETPOST(
"notactiontype",
'alpha')) {
129 $filters[
'notactiontype'] =
GETPOST(
"notactiontype",
'alpha');
131if (
GETPOST(
"actiontype",
'alpha')) {
132 $filters[
'actiontype'] =
GETPOST(
"actiontype",
'alpha');
134if (
GETPOST(
"notolderthan",
'int')) {
135 $filters[
'notolderthan'] =
GETPOST(
"notolderthan",
"int");
137 $filters[
'notolderthan'] = $conf->global->MAIN_AGENDA_EXPORT_PAST_DELAY;
139if (
GETPOST(
"module",
'alpha')) {
140 $filters[
'module'] =
GETPOST(
"module",
'alpha');
143 $filters[
'status'] =
GETPOST(
"status",
'int');
146if (empty($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY)) {
150 print
'<div class="error">Module Agenda was not configured properly.</div>';
156$hookmanager->initHooks(array(
'agendaexport'));
158$reshook = $hookmanager->executeHooks(
'doActions', $filters);
161 if (!empty($hookmanager->errors) && is_array($hookmanager->errors)) {
162 print
'<div class="error">'.implode(
'<br>', $hookmanager->errors).
'</div>';
164 print
'<div class="error">'.$hookmanager->error.
'</div>';
167} elseif (empty($reshook)) {
169 if (empty($_GET[
"exportkey"]) || $conf->global->MAIN_AGENDA_XCAL_EXPORTKEY != $_GET[
"exportkey"]) {
173 print
'<div class="error">Bad value for key.</div>';
181$shortfilename =
'dolibarrcalendar';
182$filename = $shortfilename;
184foreach ($filters as $key => $value) {
186 if ($key ==
'year') {
187 $filename .=
'-year'.$value;
190 $filename .=
'-id'.$value;
192 if ($key ==
'idfrom') {
193 $filename .=
'-idfrom'.$value;
195 if ($key ==
'idto') {
196 $filename .=
'-idto'.$value;
198 if ($key ==
'project') {
199 $filename .=
'-project'.$value;
201 if ($key ==
'logina') {
202 $filename .=
'-logina'.$value;
204 if ($key ==
'logint') {
205 $filename .=
'-logint'.$value;
207 if ($key ==
'notactiontype') {
208 $filename .=
'-notactiontype'.$value;
210 if ($key ==
'actiontype') {
211 $filename .=
'-actiontype'.$value;
213 if ($key ==
'module') {
214 $filename .=
'-module'.$value;
216 if ($key ==
'status') {
217 $filename .=
'-status'.$value;
221if ($format ==
'vcal') {
222 $shortfilename .=
'.vcs'; $filename .=
'.vcs';
224if ($format ==
'ical') {
225 $shortfilename .=
'.ics'; $filename .=
'.ics';
227if ($format ==
'rss') {
228 $shortfilename .=
'.rss'; $filename .=
'.rss';
230if ($shortfilename ==
'dolibarrcalendar') {
231 $langs->load(
"errors");
233 print
'<div class="error">'.$langs->trans(
"ErrorWrongValueForParameterX",
'format').
'</div>';
241if (!empty($conf->global->MAIN_AGENDA_EXPORT_CACHE)) {
242 $cachedelay = $conf->global->MAIN_AGENDA_EXPORT_CACHE;
245$exportholidays =
GETPOST(
'includeholidays',
'int');
248if ($format ==
'ical' || $format ==
'vcal') {
249 $result = $agenda->build_exportfile($format, $type, $cachedelay, $filename, $filters, $exportholidays);
252 if (isset($_GET[
"attachment"])) {
253 $attachment = $_GET[
"attachment"];
256 $contenttype =
'text/calendar';
257 if (isset($_GET[
"contenttype"])) {
258 $contenttype = $_GET[
"contenttype"];
261 $outputencoding =
'UTF-8';
264 header(
'Content-Type: '.$contenttype.($outputencoding ?
'; charset='.$outputencoding :
''));
267 header(
'Content-Disposition: attachment; filename="'.$shortfilename.
'"');
271 header(
'Cache-Control: max-age='.$cachedelay.
', private, must-revalidate');
273 header(
'Cache-Control: private, must-revalidate');
277 $outputfile = $conf->agenda->dir_temp.
'/'.$filename;
278 $result = readfile($outputfile);
280 print
'File '.$outputfile.
' was empty.';
286 print
'Error '.$agenda->error;
292if ($format ==
'rss') {
293 $result = $agenda->build_exportfile($format, $type, $cachedelay, $filename, $filters, $exportholidays);
296 if (isset($_GET[
"attachment"])) {
297 $attachment = $_GET[
"attachment"];
300 $contenttype =
'application/rss+xml';
301 if (isset($_GET[
"contenttype"])) {
302 $contenttype = $_GET[
"contenttype"];
305 $outputencoding =
'UTF-8';
308 header(
'Content-Type: '.$contenttype.($outputencoding ?
'; charset='.$outputencoding :
''));
311 header(
'Content-Disposition: attachment; filename="'.$filename.
'"');
318 header(
'Cache-Control: max-age='.$cachedelay.
', private, must-revalidate');
320 header(
'Cache-Control: private, must-revalidate');
324 $outputfile = $conf->agenda->dir_temp.
'/'.$filename;
325 $result = readfile($outputfile);
327 print
'File '.$outputfile.
' was empty.';
333 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.