Add announcement option when editing an event see BT#10950

1.10.x
jmontoya 9 years ago
parent 70be1b2d19
commit a0d9ceb45c
  1. 18
      main/calendar/agenda.php
  2. 4
      main/inc/ajax/agenda.ajax.php
  3. 27
      main/inc/lib/agenda.lib.php

@ -92,7 +92,7 @@ if (api_is_allowed_to_edit(false, true) ||
(api_get_course_setting('allow_user_edit_agenda') &&
!api_is_anonymous() &&
api_is_allowed_to_session_edit(false, true)) ||
GroupManager::user_has_access(api_get_user_id(), $group_id, GroupManager::GROUP_TOOL_CALENDAR) &&
GroupManager::user_has_access(api_get_user_id(), $group_id, GroupManager::GROUP_TOOL_CALENDAR) &&
GroupManager::is_tutor_of_group(api_get_user_id(), $group_id)
) {
switch ($action) {
@ -169,7 +169,7 @@ if (api_is_allowed_to_edit(false, true) ||
$allDay = isset($values['all_day']) ? 'true' : 'false';
$startDate = $values['date_range_start'];
$endDate = $values['date_range_end'];
$sendEmail = isset($values['add_announcement']) ? true : false;
$sendAttachment = isset($_FILES['user_upload']) ? true : false;
$attachment = $sendAttachment ? $_FILES['user_upload'] : null;
$attachmentComment = isset($values['file_comment']) ? $values['file_comment'] : null;
@ -178,7 +178,7 @@ if (api_is_allowed_to_edit(false, true) ||
// This is a sub event. Delete the current and create another BT#7803
if (!empty($event['parent_event_id'])) {
$agenda->delete_event($eventId);
$agenda->deleteEvent($eventId);
$eventId = $agenda->addEvent(
$startDate,
@ -211,7 +211,9 @@ if (api_is_allowed_to_edit(false, true) ||
$values['users_to_send'],
$attachment,
$attachmentComment,
$comment
$comment,
'',
$sendEmail
);
if (!empty($values['repeat']) && !empty($eventId)) {
@ -245,7 +247,7 @@ if (api_is_allowed_to_edit(false, true) ||
case 'importical':
$actionName = get_lang('Import');
$form = $agenda->getImportCalendarForm();
$content = $form->return_form();
$content = $form->returnForm();
if ($form->validate()) {
$ical_name = $_FILES['ical_import']['name'];
@ -274,7 +276,7 @@ if (api_is_allowed_to_edit(false, true) ||
case "delete":
if (!(api_is_course_coach() && !api_is_element_in_the_session(TOOL_AGENDA, $eventId) )) {
// a coach can only delete an element belonging to his session
$content = $agenda->delete_event($eventId);
$content = $agenda->deleteEvent($eventId);
}
break;
}
@ -283,11 +285,11 @@ if (api_is_allowed_to_edit(false, true) ||
if (!empty($group_id)) {
$group_properties = GroupManager :: get_group_properties($group_id);
$interbreadcrumb[] = array(
"url" => api_get_path(WEB_CODE_PATH)."group/group.php",
"url" => api_get_path(WEB_CODE_PATH)."group/group.php?".api_get_cidreq(),
"name" => get_lang('Groups')
);
$interbreadcrumb[] = array(
"url" => api_get_path(WEB_CODE_PATH)."group/group_space.php?gidReq=".$group_id,
"url" => api_get_path(WEB_CODE_PATH)."group/group_space.php?".api_get_cidreq(),
"name" => get_lang('GroupSpace').' '.$group_properties['name']
);
}

@ -70,7 +70,7 @@ switch ($action) {
$id_list = explode('_', $_REQUEST['id']);
$id = $id_list[1];
$deleteAllEventsFromSerie = isset($_REQUEST['delete_all_events']) ? true : false;
$agenda->delete_event($id, $deleteAllEventsFromSerie);
$agenda->deleteEvent($id, $deleteAllEventsFromSerie);
break;
case 'resize_event':
if (!api_is_allowed_to_edit(null, true) && $type == 'course') {
@ -80,7 +80,7 @@ switch ($action) {
$minute_delta = $_REQUEST['minute_delta'];
$id = explode('_', $_REQUEST['id']);
$id = $id[1];
$agenda->resize_event($id, $day_delta, $minute_delta);
$agenda->resizeEvent($id, $day_delta, $minute_delta);
break;
case 'move_event':
if (!api_is_allowed_to_edit(null, true) && $type == 'course') {

@ -289,7 +289,7 @@ class Agenda
// Add announcement.
if ($addAsAnnouncement) {
$this->store_agenda_item_as_announcement($id, $usersToSend);
$this->storeAgendaEventAsAnnouncement($id, $usersToSend);
}
// Add attachment.
@ -507,7 +507,7 @@ class Agenda
* @param array $sentTo
* @return int
*/
public function store_agenda_item_as_announcement($item_id, $sentTo = array())
public function storeAgendaEventAsAnnouncement($item_id, $sentTo = array())
{
$table_agenda = Database::get_course_table(TABLE_AGENDA);
$course_id = api_get_course_int_id();
@ -554,11 +554,11 @@ class Agenda
* @param string $title
* @param string $content
* @param array $usersToSend
* @param int $editRepeatType
* @param array $attachmentArray
* @param string $attachmentComment
* @param string $comment
* @param string $color
* @param bool $addAnnouncement
*
* @return bool
*/
@ -573,7 +573,8 @@ class Agenda
$attachmentArray = array(),
$attachmentComment = '',
$comment = '',
$color = ''
$color = '',
$addAnnouncement = false
) {
$start = api_get_utc_datetime($start);
$end = api_get_utc_datetime($end);
@ -774,9 +775,9 @@ class Agenda
}
// Add announcement.
/*if (isset($addAsAnnouncement) && !empty($addAsAnnouncement)) {
$this->store_agenda_item_as_announcement($id);
}*/
if (isset($addAnnouncement) && !empty($addAnnouncement)) {
$this->storeAgendaEventAsAnnouncement($id, $usersToSend);
}
// Add attachment.
if (isset($attachmentArray) && !empty($attachmentArray)) {
@ -813,7 +814,7 @@ class Agenda
* @param int $id
* @param bool $deleteAllItemsFromSerie
*/
public function delete_event($id, $deleteAllItemsFromSerie = false)
public function deleteEvent($id, $deleteAllItemsFromSerie = false)
{
switch ($this->type) {
case 'personal':
@ -838,23 +839,22 @@ class Agenda
$events = $this->getAllRepeatEvents($eventInfo['parent_event_id']);
if (!empty($events)) {
foreach ($events as $event) {
$this->delete_event($event['id']);
$this->deleteEvent($event['id']);
}
}
// Removing parent.
$this->delete_event($eventInfo['parent_event_id']);
$this->deleteEvent($eventInfo['parent_event_id']);
} else {
// This is the father looking for the children.
$events = $this->getAllRepeatEvents($id);
if (!empty($events)) {
foreach ($events as $event) {
$this->delete_event($event['id']);
$this->deleteEvent($event['id']);
}
}
}
}
// Removing from events.
Database::delete(
$this->tbl_course_agenda,
@ -936,7 +936,6 @@ class Agenda
$this->eventOtherSessionColor
);
} else {
$this->getCourseEvents(
$start,
$end,
@ -1078,7 +1077,7 @@ class Agenda
* @param int $minute_delta
* @return int
*/
public function resize_event($id, $day_delta, $minute_delta)
public function resizeEvent($id, $day_delta, $minute_delta)
{
// we convert the hour delta into minutes and add the minute delta
$delta = ($day_delta * 60 * 24) + $minute_delta;

Loading…
Cancel
Save