Skip to content

Commit 903606b

Browse files
committed
Merge branch '1.11.x' of github.com:chamilo/chamilo-lms into 1.11.x
2 parents 704dd78 + d84b6d2 commit 903606b

File tree

3 files changed

+100
-1
lines changed

3 files changed

+100
-1
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
/* For licensing terms, see /license.txt */
3+
4+
/**
5+
* This file exclusively export event members for invitation or subscription.
6+
*
7+
* @author Nicolas Ducoulombier <nicolas.ducoulombier@beeznest.com>
8+
*/
9+
// setting the global file that gets the general configuration, the databases, the languages, ...
10+
require_once __DIR__.'/../inc/global.inc.php';
11+
$this_section = SECTION_MYAGENDA;
12+
api_block_anonymous_users();
13+
14+
$type = 'personal';
15+
$id = (int) explode('_', $_REQUEST['id'])[1];
16+
$action = $_REQUEST['a'] ?? null;
17+
18+
if (empty($id)) {
19+
exit;
20+
}
21+
$agenda = new Agenda($type);
22+
23+
switch ($action) {
24+
case 'export_invitees' :
25+
if (!$agenda->getIsAllowedToEdit()) {
26+
break;
27+
}
28+
$data = $agenda->exportEventMembersToCsv($id, "Invitee");
29+
Export::arrayToCsv($data);
30+
break;
31+
case 'export_subscribers' :
32+
if (!$agenda->getIsAllowedToEdit()) {
33+
break;
34+
}
35+
$data = $agenda->exportEventMembersToCsv($id, "Subscriber");
36+
Export::arrayToCsv($data);
37+
break;
38+
}
39+
exit;
40+

main/inc/lib/agenda.lib.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1414,6 +1414,38 @@ public function deleteEvent($id, $deleteAllItemsFromSerie = false)
14141414
break;
14151415
}
14161416
}
1417+
1418+
public function exportEventMembersToCsv(int $id, $type = "Invitee")
1419+
{
1420+
if (false === api_get_configuration_value('agenda_event_subscriptions') && false === api_get_configuration_value('agenda_collective_invitations')) {
1421+
return;
1422+
}
1423+
if ('personal' !== $this->type) {
1424+
return;
1425+
}
1426+
if ($type === "Invitee") {
1427+
$members = self::getInviteesForPersonalEvent($id, AgendaEventInvitee::class);
1428+
} elseif ($type === "Subscriber") {
1429+
$members = self::getInviteesForPersonalEvent($id, AgendaEventSubscriber::class);
1430+
}
1431+
$data = [];
1432+
$data[] = [
1433+
'OfficialCode',
1434+
'Lastname',
1435+
'Firsname',
1436+
'Email',
1437+
];
1438+
$count = 1;
1439+
foreach ($members as $member) {
1440+
$user = api_get_user_info($member['id']);
1441+
$data[$count][] = $user['official_code'];
1442+
$data[$count][] = $user['lastname'];
1443+
$data[$count][] = $user['firstname'];
1444+
$data[$count][] = $user['email'];
1445+
$count++;
1446+
}
1447+
return $data;
1448+
}
14171449

14181450
public function subscribeCurrentUserToEvent(int $id)
14191451
{

main/template/default/agenda/month.tpl

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -719,6 +719,8 @@ $(function() {
719719
720720
$("#dialog-form").dialog({
721721
buttons: {
722+
// Reduced options to simplify interface
723+
/*
722724
'{{ "ExportiCalConfidential"|get_lang }}' : function() {
723725
url = "{{ _p.web_main }}calendar/ical_export.php?id=" + calEvent.id+'&course_id='+calEvent.course_id+"&class=confidential";
724726
window.location.href = url;
@@ -727,6 +729,7 @@ $(function() {
727729
url = "{{ _p.web_main }}calendar/ical_export.php?id=" + calEvent.id+'&course_id='+calEvent.course_id+"&class=private";
728730
window.location.href = url;
729731
},
732+
*/
730733
'{{ "ExportiCalPublic"|get_lang }}': function() {
731734
url = "{{ _p.web_main }}calendar/ical_export.php?id=" + calEvent.id+'&course_id='+calEvent.course_id+"&class=public";
732735
window.location.href = url;
@@ -828,7 +831,18 @@ $(function() {
828831
$("#dialog-form").dialog('close');
829832
}
830833
});
831-
}
834+
},
835+
{% if (agenda_collective_invitations or agenda_event_subscriptions) and 'personal' == type %}
836+
'{{ "ExportUsers" | get_lang }}' : function() {
837+
if (isInvitation(calEvent)) {
838+
url = "{{ _p.web_main }}calendar/exportEventMembers.php?a=export_invitees&id=" + calEvent.id;
839+
} else {
840+
url = "{{ _p.web_main }}calendar/exportEventMembers.php?a=export_subscribers&id=" + calEvent.id;
841+
}
842+
window.location.href = url;
843+
},
844+
{% endif %}
845+
832846
},
833847
close: function() {
834848
$("#title_edit").hide();
@@ -963,6 +977,8 @@ $(function() {
963977
{% endif %}
964978
965979
var buttons = {
980+
// Reduced options to simplify interface
981+
/*
966982
'{{"ExportiCalConfidential"|get_lang}}' : function() {
967983
url = "ical_export.php?id=" + calEvent.id+'&course_id='+calEvent.course_id+"&class=confidential";
968984
window.location.href = url;
@@ -971,6 +987,7 @@ $(function() {
971987
url = "ical_export.php?id=" + calEvent.id+'&course_id='+calEvent.course_id+"&class=private";
972988
window.location.href = url;
973989
},
990+
*/
974991
'{{"ExportiCalPublic"|get_lang}}': function() {
975992
url = "ical_export.php?id=" + calEvent.id+'&course_id='+calEvent.course_id+"&class=public";
976993
window.location.href = url;
@@ -1074,6 +1091,16 @@ $(function() {
10741091
10751092
{{ agenda_reminders_js }}
10761093
1094+
function isInvitation (calEvent) {
1095+
if ((calEvent.invitees && calEvent.invitees.length)
1096+
|| !calEvent.subscription_visibility
1097+
) {
1098+
return true;
1099+
} else {
1100+
return false;
1101+
}
1102+
}
1103+
10771104
function showSubcriptionsContainer (calEvent) {
10781105
if ((calEvent.invitees && calEvent.invitees.length)
10791106
|| !calEvent.subscription_visibility

0 commit comments

Comments
 (0)