Fix: Export calendar to ical
This commit is contained in:
parent
b207f3419d
commit
e363d42c1d
@ -555,7 +555,7 @@ class ActionComm
|
||||
$result=create_exdir($conf->agenda->dir_temp);
|
||||
$outputfile=$conf->agenda->dir_temp.'/'.$filename;
|
||||
$result=0;
|
||||
|
||||
|
||||
$buildfile=true;
|
||||
if ($cachedelay)
|
||||
{
|
||||
|
||||
@ -50,13 +50,14 @@ $mainmenu=isset($_GET["mainmenu"])?$_GET["mainmenu"]:"";
|
||||
$leftmenu=isset($_GET["leftmenu"])?$_GET["leftmenu"]:"";
|
||||
|
||||
// Define format, type, filename and filter
|
||||
$format='vcal';
|
||||
$format='ical';
|
||||
$type='event';
|
||||
$filename='';
|
||||
if (! empty($_GET["format"])) $format=$_GET["format"];
|
||||
if ($format == 'vcal') $filename='dolibarrcalendar.vcs';
|
||||
if ($format == 'ical') $filename='dolibarrcalendar.ics';
|
||||
if (! empty($_GET["type"])) $type=$_GET["type"];
|
||||
// Check filename
|
||||
if (! $filename)
|
||||
{
|
||||
$langs->load("main");
|
||||
@ -66,6 +67,8 @@ if (! $filename)
|
||||
llxFooter('$Date$ - $Revision$');
|
||||
exit;
|
||||
}
|
||||
// Check exportkey
|
||||
// \TODO
|
||||
$filters=array();
|
||||
if (! empty($_GET["year"])) $filters['year']=$_GET["year"];
|
||||
if (! empty($_GET["idaction"])) $filters['idaction']=$_GET["idaction"];
|
||||
@ -76,7 +79,25 @@ $agenda=new ActionComm($db);
|
||||
$result=$agenda->build_calfile($format,$type,0,$filename,$filters);
|
||||
if ($result >= 0)
|
||||
{
|
||||
header("Location: ".DOL_URL_ROOT.'/document.php?modulepart=agenda&file='.urlencode($filename));
|
||||
$attachment = false;
|
||||
$encoding='UTF-8';
|
||||
$type='text/plain';
|
||||
//$type='text/calendar';
|
||||
|
||||
if ($encoding) header('Content-Encoding: '.$encoding);
|
||||
if ($type) header('Content-Type: '.$type);
|
||||
if ($attachment) header('Content-Disposition: attachment; filename="'.$filename.'"');
|
||||
|
||||
// Ajout directives pour resoudre bug IE
|
||||
//header('Cache-Control: Public, must-revalidate');
|
||||
//header('Pragma: public');
|
||||
|
||||
// Clean parameters
|
||||
$outputfile=$conf->agenda->dir_temp.'/'.$filename;
|
||||
$result=readfile($outputfile);
|
||||
if (! $result) print 'File '.$outputfile.' was empty.';
|
||||
|
||||
// header("Location: ".DOL_URL_ROOT.'/document.php?modulepart=agenda&file='.urlencode($filename));
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
@ -32,7 +32,8 @@ $type = isset($_GET["type"]) ? urldecode($_GET["type"]) : '';
|
||||
|
||||
// Define if we need master or master+main
|
||||
$needmasteronly=false;
|
||||
if ($modulepart == 'webcal') $needmasteronly=true;
|
||||
//if ($modulepart == 'webcal') $needmasteronly=true;
|
||||
//if ($modulepart == 'agenda') $needmasteronly=true;
|
||||
|
||||
// This is to make Dolibarr working with Plesk
|
||||
set_include_path($_SERVER['DOCUMENT_ROOT'].'/htdocs');
|
||||
@ -40,7 +41,7 @@ set_include_path($_SERVER['DOCUMENT_ROOT'].'/htdocs');
|
||||
// Load master or main
|
||||
if ($needmasteronly)
|
||||
{
|
||||
// Pour companylogo, on charge juste environnement sans logon qui charge le user
|
||||
// For some download we don't need login
|
||||
require("./master.inc.php");
|
||||
}
|
||||
else
|
||||
@ -370,22 +371,6 @@ if ($modulepart)
|
||||
$original_file=DOL_DATA_ROOT.'/admin/temp/'.$original_file;
|
||||
$sqlprotectagainstexternals = '';
|
||||
}
|
||||
|
||||
// Wrapping for webcalexport
|
||||
if ($modulepart == 'webcal')
|
||||
{
|
||||
$accessallowed=1;
|
||||
$encoding='UTF-8';
|
||||
$original_file=$conf->webcal->dir_temp.'/'.$original_file;
|
||||
}
|
||||
|
||||
// Wrapping for webcalexport
|
||||
if ($modulepart == 'agenda')
|
||||
{
|
||||
$accessallowed=1;
|
||||
$encoding='UTF-8';
|
||||
$original_file=$conf->agenda->dir_temp.'/'.$original_file;
|
||||
}
|
||||
}
|
||||
|
||||
// Basic protection (against external users only)
|
||||
|
||||
@ -193,7 +193,7 @@ function build_calfile($format='vcal',$title,$desc,$events_array,$outputfile,$fi
|
||||
}
|
||||
|
||||
// Footer
|
||||
fwrite($calfileh,"END:VCALENDAR\n");
|
||||
fwrite($calfileh,"END:VCALENDAR");
|
||||
|
||||
fclose($calfileh);
|
||||
}
|
||||
|
||||
@ -97,7 +97,25 @@ if (! empty($_GET["year"])) $filters['year']=$_GET["year"];
|
||||
$result=$webcal->build_calfile($format,$type,0,$filename,$filters);
|
||||
if ($result >= 0)
|
||||
{
|
||||
header("Location: ".DOL_URL_ROOT.'/document.php?modulepart=webcal&file='.urlencode($filename));
|
||||
$attachment = false;
|
||||
$encoding='UTF-8';
|
||||
$type='text/plain';
|
||||
//$type='text/calendar';
|
||||
|
||||
if ($encoding) header('Content-Encoding: '.$encoding);
|
||||
if ($type) header('Content-Type: '.$type);
|
||||
if ($attachment) header('Content-Disposition: attachment; filename="'.$filename.'"');
|
||||
|
||||
// Ajout directives pour resoudre bug IE
|
||||
//header('Cache-Control: Public, must-revalidate');
|
||||
//header('Pragma: public');
|
||||
|
||||
// Clean parameters
|
||||
$outputfile=$conf->agenda->dir_temp.'/'.$filename;
|
||||
$result=readfile($outputfile);
|
||||
if (! $result) print 'File '.$outputfile.' was empty.';
|
||||
|
||||
// header("Location: ".DOL_URL_ROOT.'/document.php?modulepart=webcal&file='.urlencode($filename));
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user