31 if (!defined(
'NOTOKENRENEWAL')) define(
'NOTOKENRENEWAL',
'1');
32 if (!defined(
'NOREQUIREMENU')) define(
'NOREQUIREMENU',
'1');
33 if (!defined(
'NOREQUIREHTML')) define(
'NOREQUIREHTML',
'1');
34 if (!defined(
'NOREQUIREAJAX')) define(
'NOREQUIREAJAX',
'1');
35 if (!defined(
'NOLOGIN')) define(
"NOLOGIN", 1);
36 if (!defined(
'NOCSRFCHECK')) define(
"NOCSRFCHECK", 1);
37 if (!defined(
'NOIPCHECK')) define(
'NOIPCHECK',
'1');
49 print '<html><title>Export agenda cal</title><body>';
58 print '</body></html>';
63 $entity = (!empty($_GET[
'entity']) ? (int) $_GET[
'entity'] : (!empty($_POST[
'entity']) ? (int) $_POST[
'entity'] : 1));
64 if (is_numeric($entity)) define(
"DOLENTITY", $entity);
66 require
'../../main.inc.php';
67 require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
73 if (!isset($conf->global->MAIN_AGENDA_EXPORT_PAST_DELAY)) $conf->global->MAIN_AGENDA_EXPORT_PAST_DELAY = 100;
82 if (
GETPOST(
"year",
'int')) $filters[
'year'] =
GETPOST(
"year",
'int');
84 if (
GETPOST(
"idfrom",
'int')) $filters[
'idfrom'] =
GETPOST(
"idfrom",
'int');
85 if (
GETPOST(
"idto",
'int')) $filters[
'idto'] =
GETPOST(
"idto",
'int');
86 if (
GETPOST(
"project",
'apha')) $filters[
'project'] =
GETPOST(
"project",
'apha');
87 if (
GETPOST(
"logina",
'apha')) $filters[
'logina'] =
GETPOST(
"logina",
'apha');
88 if (
GETPOST(
"logint",
'apha')) $filters[
'logint'] =
GETPOST(
"logint",
'apha');
89 if (
GETPOST(
"notactiontype",
'apha')) $filters[
'notactiontype'] =
GETPOST(
"notactiontype",
'apha');
90 if (
GETPOST(
"actiontype",
'apha')) $filters[
'actiontype'] =
GETPOST(
"actiontype",
'apha');
91 if (
GETPOST(
"notolderthan",
'int')) $filters[
'notolderthan'] =
GETPOST(
"notolderthan",
"int");
92 else $filters[
'notolderthan'] = $conf->global->MAIN_AGENDA_EXPORT_PAST_DELAY;
95 if (empty($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY))
100 print '<div class="error">Module Agenda was not configured properly.</div>';
106 $hookmanager->initHooks(array(
'agendaexport'));
108 $reshook = $hookmanager->executeHooks(
'doActions', $filters);
111 if (!empty($hookmanager->errors) && is_array($hookmanager->errors)) {
112 print '<div class="error">'.implode(
'<br/>', $hookmanager->errors).
'</div>';
114 print '<div class="error">'.$hookmanager->error.
'</div>';
117 } elseif (empty($reshook)) {
119 if (empty($_GET[
"exportkey"]) || $conf->global->MAIN_AGENDA_XCAL_EXPORTKEY != $_GET[
"exportkey"]) {
123 print '<div class="error">Bad value for key.</div>';
131 $shortfilename =
'dolibarrcalendar';
132 $filename = $shortfilename;
134 foreach ($filters as $key => $value)
137 if ($key ==
'year') $filename .=
'-year'.$value;
138 if ($key ==
'id') $filename .=
'-id'.$value;
139 if ($key ==
'idfrom') $filename .=
'-idfrom'.$value;
140 if ($key ==
'idto') $filename .=
'-idto'.$value;
141 if ($key ==
'project') $filename .=
'-project'.$value;
142 if ($key ==
'logina') $filename .=
'-logina'.$value;
143 if ($key ==
'logint') $filename .=
'-logint'.$value;
144 if ($key ==
'notactiontype') $filename .=
'-notactiontype'.$value;
147 if ($format ==
'vcal') { $shortfilename .=
'.vcs'; $filename .=
'.vcs'; }
148 if ($format ==
'ical') { $shortfilename .=
'.ics'; $filename .=
'.ics'; }
149 if ($format ==
'rss') { $shortfilename .=
'.rss'; $filename .=
'.rss'; }
151 if ($shortfilename ==
'dolibarrcalendar')
153 $langs->load(
"main");
154 $langs->load(
"errors");
156 print '<div class="error">'.$langs->trans(
"ErrorWrongValueForParameterX",
'format').
'</div>';
164 if (!empty($conf->global->MAIN_AGENDA_EXPORT_CACHE)) $cachedelay = $conf->global->MAIN_AGENDA_EXPORT_CACHE;
166 $exportholidays =
GETPOST(
'includeholidays',
'int');
169 if ($format ==
'ical' || $format ==
'vcal')
171 $result = $agenda->build_exportfile($format, $type, $cachedelay, $filename, $filters, $exportholidays);
175 if (isset($_GET[
"attachment"])) $attachment = $_GET[
"attachment"];
177 $contenttype =
'text/calendar';
178 if (isset($_GET[
"contenttype"])) $contenttype = $_GET[
"contenttype"];
180 $outputencoding =
'UTF-8';
182 if ($contenttype) header(
'Content-Type: '.$contenttype.($outputencoding ?
'; charset='.$outputencoding :
''));
183 if ($attachment) header(
'Content-Disposition: attachment; filename="'.$shortfilename.
'"');
185 if ($cachedelay) header(
'Cache-Control: max-age='.$cachedelay.
', private, must-revalidate');
186 else header(
'Cache-Control: private, must-revalidate');
189 $outputfile = $conf->agenda->dir_temp.
'/'.$filename;
190 $result = readfile($outputfile);
191 if (!$result)
print 'File '.$outputfile.
' was empty.';
196 print 'Error '.$agenda->error;
202 if ($format ==
'rss')
204 $result = $agenda->build_exportfile($format, $type, $cachedelay, $filename, $filters, $exportholidays);
208 if (isset($_GET[
"attachment"])) $attachment = $_GET[
"attachment"];
210 $contenttype =
'application/rss+xml';
211 if (isset($_GET[
"contenttype"])) $contenttype = $_GET[
"contenttype"];
213 $outputencoding =
'UTF-8';
215 if ($contenttype) header(
'Content-Type: '.$contenttype.($outputencoding ?
'; charset='.$outputencoding :
''));
216 if ($attachment) header(
'Content-Disposition: attachment; filename="'.$filename.
'"');
221 if ($cachedelay) header(
'Cache-Control: max-age='.$cachedelay.
', private, must-revalidate');
222 else header(
'Cache-Control: private, must-revalidate');
225 $outputfile = $conf->agenda->dir_temp.
'/'.$filename;
226 $result = readfile($outputfile);
227 if (!$result)
print 'File '.$outputfile.
' was empty.';
232 print 'Error '.$agenda->error;
240 print '<div class="error">'.$agenda->error.
'</div>';
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Class to manage agenda events (actions)
accessforbidden($message= '', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
llxHeaderVierge()
Header function.
print
Draft customers invoices.
llxFooterVierge()
Footer function.
if(!defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN'
Draft customers invoices.