Merge branch '1.11.x' of github.com:chamilo/chamilo-lms into 1.11.x

pull/4863/head
Yannick Warnier 2 years ago
commit 903606b2c2
  1. 40
      main/calendar/exportEventMembers.php
  2. 32
      main/inc/lib/agenda.lib.php
  3. 29
      main/template/default/agenda/month.tpl

@ -0,0 +1,40 @@
<?php
/* For licensing terms, see /license.txt */
/**
* This file exclusively export event members for invitation or subscription.
*
* @author Nicolas Ducoulombier <nicolas.ducoulombier@beeznest.com>
*/
// setting the global file that gets the general configuration, the databases, the languages, ...
require_once __DIR__.'/../inc/global.inc.php';
$this_section = SECTION_MYAGENDA;
api_block_anonymous_users();
$type = 'personal';
$id = (int) explode('_', $_REQUEST['id'])[1];
$action = $_REQUEST['a'] ?? null;
if (empty($id)) {
exit;
}
$agenda = new Agenda($type);
switch ($action) {
case 'export_invitees' :
if (!$agenda->getIsAllowedToEdit()) {
break;
}
$data = $agenda->exportEventMembersToCsv($id, "Invitee");
Export::arrayToCsv($data);
break;
case 'export_subscribers' :
if (!$agenda->getIsAllowedToEdit()) {
break;
}
$data = $agenda->exportEventMembersToCsv($id, "Subscriber");
Export::arrayToCsv($data);
break;
}
exit;

@ -1414,6 +1414,38 @@ class Agenda
break;
}
}
public function exportEventMembersToCsv(int $id, $type = "Invitee")
{
if (false === api_get_configuration_value('agenda_event_subscriptions') && false === api_get_configuration_value('agenda_collective_invitations')) {
return;
}
if ('personal' !== $this->type) {
return;
}
if ($type === "Invitee") {
$members = self::getInviteesForPersonalEvent($id, AgendaEventInvitee::class);
} elseif ($type === "Subscriber") {
$members = self::getInviteesForPersonalEvent($id, AgendaEventSubscriber::class);
}
$data = [];
$data[] = [
'OfficialCode',
'Lastname',
'Firsname',
'Email',
];
$count = 1;
foreach ($members as $member) {
$user = api_get_user_info($member['id']);
$data[$count][] = $user['official_code'];
$data[$count][] = $user['lastname'];
$data[$count][] = $user['firstname'];
$data[$count][] = $user['email'];
$count++;
}
return $data;
}
public function subscribeCurrentUserToEvent(int $id)
{

@ -719,6 +719,8 @@ $(function() {
$("#dialog-form").dialog({
buttons: {
// Reduced options to simplify interface
/*
'{{ "ExportiCalConfidential"|get_lang }}' : function() {
url = "{{ _p.web_main }}calendar/ical_export.php?id=" + calEvent.id+'&course_id='+calEvent.course_id+"&class=confidential";
window.location.href = url;
@ -727,6 +729,7 @@ $(function() {
url = "{{ _p.web_main }}calendar/ical_export.php?id=" + calEvent.id+'&course_id='+calEvent.course_id+"&class=private";
window.location.href = url;
},
*/
'{{ "ExportiCalPublic"|get_lang }}': function() {
url = "{{ _p.web_main }}calendar/ical_export.php?id=" + calEvent.id+'&course_id='+calEvent.course_id+"&class=public";
window.location.href = url;
@ -828,7 +831,18 @@ $(function() {
$("#dialog-form").dialog('close');
}
});
}
},
{% if (agenda_collective_invitations or agenda_event_subscriptions) and 'personal' == type %}
'{{ "ExportUsers" | get_lang }}' : function() {
if (isInvitation(calEvent)) {
url = "{{ _p.web_main }}calendar/exportEventMembers.php?a=export_invitees&id=" + calEvent.id;
} else {
url = "{{ _p.web_main }}calendar/exportEventMembers.php?a=export_subscribers&id=" + calEvent.id;
}
window.location.href = url;
},
{% endif %}
},
close: function() {
$("#title_edit").hide();
@ -963,6 +977,8 @@ $(function() {
{% endif %}
var buttons = {
// Reduced options to simplify interface
/*
'{{"ExportiCalConfidential"|get_lang}}' : function() {
url = "ical_export.php?id=" + calEvent.id+'&course_id='+calEvent.course_id+"&class=confidential";
window.location.href = url;
@ -971,6 +987,7 @@ $(function() {
url = "ical_export.php?id=" + calEvent.id+'&course_id='+calEvent.course_id+"&class=private";
window.location.href = url;
},
*/
'{{"ExportiCalPublic"|get_lang}}': function() {
url = "ical_export.php?id=" + calEvent.id+'&course_id='+calEvent.course_id+"&class=public";
window.location.href = url;
@ -1074,6 +1091,16 @@ $(function() {
{{ agenda_reminders_js }}
function isInvitation (calEvent) {
if ((calEvent.invitees && calEvent.invitees.length)
|| !calEvent.subscription_visibility
) {
return true;
} else {
return false;
}
}
function showSubcriptionsContainer (calEvent) {
if ((calEvent.invitees && calEvent.invitees.length)
|| !calEvent.subscription_visibility

Loading…
Cancel
Save