From e846721dc974bd4aee2a602d4dee001a53bee26e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 18 Feb 2024 00:25:00 +0100 Subject: [PATCH] NEW Add link to export ICS file of an event. --- htdocs/comm/action/class/actioncomm.class.php | 4 ++++ .../conferenceorbooth_list.php | 23 +++++++++++++++++-- htdocs/langs/en_US/eventorganization.lang | 1 + htdocs/public/agenda/agendaexport.php | 19 +++++++++++---- 4 files changed, 41 insertions(+), 6 deletions(-) diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 277a4ae1d94..d4cdd60ce1f 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -2051,6 +2051,7 @@ class ActionComm extends CommonObject } $sql .= " WHERE a.fk_action=c.id"; $sql .= " AND a.entity IN (".getEntity('agenda').")"; + foreach ($filters as $key => $value) { if ($key == 'notolderthan' && $value != '') { $sql .= " AND a.datep >= '".$this->db->idate($now - ($value * 24 * 60 * 60))."'"; @@ -2111,6 +2112,9 @@ class ActionComm extends CommonObject } } if ($key == 'module') { + if ($value == 'conforbooth@eventorganization') { + $value = '@eventorganization'; + } $sql .= " AND c.module LIKE '%".$this->db->escape($value)."'"; } if ($key == 'status') { diff --git a/htdocs/eventorganization/conferenceorbooth_list.php b/htdocs/eventorganization/conferenceorbooth_list.php index b6bafdf9c5f..565d0da7599 100644 --- a/htdocs/eventorganization/conferenceorbooth_list.php +++ b/htdocs/eventorganization/conferenceorbooth_list.php @@ -483,7 +483,7 @@ if ($projectid > 0) { print $form->editfieldval($form->textwithpicto($langs->trans('MaxNbOfAttendees'), ''), 'max_attendees', $project->max_attendees, $project, $permissiontoadd, 'integer:3', '', 0, 0, '', 0, '', 'projectid'); print ""; - print ''.$langs->trans("EventOrganizationICSLink").''; + print ''.$langs->trans("EventOrganizationICSLinkProject").''; // Define $urlwithroot $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; @@ -491,7 +491,26 @@ if ($projectid > 0) { // Show message $message = ''.$langs->trans('DownloadICSLink').img_picto('', 'download', 'class="paddingleft"').''; + $message .= "&project=".$projectid.'&module='.urlencode('project@eventorganization').'&status='.ConferenceOrBooth::STATUS_CONFIRMED.'">'.$langs->trans('DownloadICSLink').img_picto('', 'download', 'class="paddingleft"').''; + print $message; + print ""; + + + print ''.$langs->trans("EventOrganizationICSLink"); + // TODO Add nb of events + $nbofconfbooth = 0; + if ($nbofconfbooth > 0) { + print '('.$nbofconfbooth.')'; + } + print ''; + // Define $urlwithroot + $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); + $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; + + // Show message + $message = ''.$langs->trans('DownloadICSLink').img_picto('', 'download', 'class="paddingleft"').''; print $message; print ""; diff --git a/htdocs/langs/en_US/eventorganization.lang b/htdocs/langs/en_US/eventorganization.lang index 8cfd9f6f981..9d3b5c5fb08 100644 --- a/htdocs/langs/en_US/eventorganization.lang +++ b/htdocs/langs/en_US/eventorganization.lang @@ -88,6 +88,7 @@ PriceOfRegistration=Price of registration PriceOfRegistrationHelp=Price to pay to register or participate in the event PriceOfBooth=Subscription price to stand a booth PriceOfBoothHelp=Subscription price to stand a booth +EventOrganizationICSLinkProject=Link ICS for the event EventOrganizationICSLink=Link ICS for conferences ConferenceOrBoothInformation=Conference Or Booth information Attendees=Attendees diff --git a/htdocs/public/agenda/agendaexport.php b/htdocs/public/agenda/agendaexport.php index bfc5be0b8c3..ede0e9e1ad6 100644 --- a/htdocs/public/agenda/agendaexport.php +++ b/htdocs/public/agenda/agendaexport.php @@ -211,6 +211,7 @@ foreach ($filters as $key => $value) { } if ($key == 'project') { $filename .= '-project'.$value; + $shortfilename .= '-project'.$value; } if ($key == 'logina') { $filename .= '-logina'.$value; // Author @@ -226,6 +227,11 @@ foreach ($filters as $key => $value) { } if ($key == 'module') { $filename .= '-module'.$value; + if ($value == 'project@eventorganization') { + $shortfilename .= '-project'; + } elseif ($value == 'conforbooth@eventorganization') { + $shortfilename .= '-conforbooth'; + } } if ($key == 'status') { $filename .= '-status'.$value; @@ -266,16 +272,21 @@ $exportholidays = GETPOST('includeholidays', 'int'); // Build file if ($format == 'ical' || $format == 'vcal') { + // For export of conforbooth, we disable the filter 'notolderthan' + if (!empty($filters['project']) && !empty($filters['module']) && ($filters['module'] == 'project@eventorganization' || $filters['module'] == 'conforbooth@eventorganization')) { + $filters['notolderthan'] = null; + } + $result = $agenda->build_exportfile($format, $type, $cachedelay, $filename, $filters, $exportholidays); if ($result >= 0) { $attachment = true; - if (isset($_GET["attachment"])) { - $attachment = $_GET["attachment"]; + if (GETPOSTISSET("attachment")) { + $attachment = GETPOST("attachment"); } //$attachment = false; $contenttype = 'text/calendar'; - if (isset($_GET["contenttype"])) { - $contenttype = $_GET["contenttype"]; + if (GETPOSTISSET("contenttype")) { + $contenttype = GETPOST("contenttype"); } //$contenttype='text/plain'; $outputencoding = 'UTF-8';