Fix delete event session permission BT#16878

pull/3170/head
Julio Montoya 6 years ago
parent 3bc2176e8a
commit 03a2b5eb2f
  1. 45
      main/inc/lib/agenda.lib.php

@ -1065,33 +1065,16 @@ class Agenda
break; break;
case 'course': case 'course':
$courseId = api_get_course_int_id(); $courseId = api_get_course_int_id();
$sessionId = api_get_session_id(); $isAllowToEdit = $this->getIsAllowedToEdit();
$isAllowToEdit = api_is_allowed_to_edit(null, true);
if ($isAllowToEdit == false && !empty($sessionId)) {
$allowDhrToEdit = api_get_configuration_value('allow_agenda_edit_for_hrm');
if ($allowDhrToEdit) {
$isHrm = SessionManager::isUserSubscribedAsHRM(
$sessionId,
api_get_user_id()
);
if ($isHrm) {
$isAllowToEdit = true;
}
}
}
if (!empty($courseId) && $isAllowToEdit) { if (!empty($courseId) && $isAllowToEdit) {
// Delete
$eventInfo = $this->get_event($id); $eventInfo = $this->get_event($id);
if ($deleteAllItemsFromSerie) { if ($deleteAllItemsFromSerie) {
/* This is one of the children. /* This is one of the children.
Getting siblings and delete 'Em all + the father! */ Getting siblings and delete 'Em all + the father! */
if (isset($eventInfo['parent_event_id']) && !empty($eventInfo['parent_event_id'])) { if (isset($eventInfo['parent_event_id']) && !empty($eventInfo['parent_event_id'])) {
// Removing items. // Removing items.
$events = $this->getAllRepeatEvents( $events = $this->getAllRepeatEvents($eventInfo['parent_event_id']);
$eventInfo['parent_event_id']
);
if (!empty($events)) { if (!empty($events)) {
foreach ($events as $event) { foreach ($events as $event) {
$this->deleteEvent($event['id']); $this->deleteEvent($event['id']);
@ -1392,8 +1375,8 @@ class Agenda
case 'course': case 'course':
$sql = "UPDATE $this->tbl_course_agenda SET $sql = "UPDATE $this->tbl_course_agenda SET
end_date = DATE_ADD(end_date, INTERVAL $delta MINUTE) end_date = DATE_ADD(end_date, INTERVAL $delta MINUTE)
WHERE WHERE
c_id = ".$this->course['real_id']." AND c_id = ".$this->course['real_id']." AND
id = ".$id; id = ".$id;
Database::query($sql); Database::query($sql);
break; break;
@ -1440,11 +1423,11 @@ class Agenda
break; break;
case 'course': case 'course':
$sql = "UPDATE $this->tbl_course_agenda SET $sql = "UPDATE $this->tbl_course_agenda SET
all_day = $allDay, all_day = $allDay,
start_date = DATE_ADD(start_date, INTERVAL $delta MINUTE), start_date = DATE_ADD(start_date, INTERVAL $delta MINUTE),
end_date = DATE_ADD(end_date, INTERVAL $delta MINUTE) end_date = DATE_ADD(end_date, INTERVAL $delta MINUTE)
WHERE WHERE
c_id = ".$this->course['real_id']." AND c_id = ".$this->course['real_id']." AND
id=".$id; id=".$id;
Database::query($sql); Database::query($sql);
break; break;
@ -1510,9 +1493,7 @@ class Agenda
); );
if (!empty($event['parent_event_id'])) { if (!empty($event['parent_event_id'])) {
$event['parent_info'] = $this->get_event( $event['parent_info'] = $this->get_event($event['parent_event_id']);
$event['parent_event_id']
);
} }
$event['attachment'] = $this->getAttachmentList( $event['attachment'] = $this->getAttachmentList(
@ -1898,8 +1879,8 @@ class Agenda
FROM $tlb_course_agenda agenda FROM $tlb_course_agenda agenda
INNER JOIN $tbl_property ip INNER JOIN $tbl_property ip
ON ( ON (
agenda.id = ip.ref AND agenda.id = ip.ref AND
agenda.c_id = ip.c_id AND agenda.c_id = ip.c_id AND
ip.tool = '".TOOL_CALENDAR_EVENT."' ip.tool = '".TOOL_CALENDAR_EVENT."'
) )
WHERE WHERE
@ -2491,14 +2472,14 @@ class Agenda
$form->addLabel( $form->addLabel(
get_lang('FilesAttachment'), get_lang('FilesAttachment'),
'<div id="filepaths" class="file-upload-event"> '<div id="filepaths" class="file-upload-event">
<div id="filepath_1"> <div id="filepath_1">
<input type="file" name="attach_1"/> <input type="file" name="attach_1"/>
<label>'.get_lang('Description').'</label> <label>'.get_lang('Description').'</label>
<input class="form-control" type="text" name="legend[]" /> <input class="form-control" type="text" name="legend[]" />
</div> </div>
</div>' </div>'
); );

Loading…
Cancel
Save