|
|
|
@ -82,7 +82,6 @@ function get_calendar_items($select_month, $select_year, $select_day = false) |
|
|
|
|
|
|
|
|
|
$group_id = api_get_group_id(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$session_condition = api_get_session_condition(api_get_session_id()); |
|
|
|
|
|
|
|
|
|
if (api_is_allowed_to_edit(false, true) OR (api_get_course_setting('allow_user_edit_agenda') && !api_is_anonymous())) { |
|
|
|
@ -1556,6 +1555,9 @@ function change_visibility($tool, $id, $visibility) |
|
|
|
|
*/ |
|
|
|
|
function display_courseadmin_links($filter = 0) |
|
|
|
|
{ |
|
|
|
|
if (!api_get_course_int_id()) { |
|
|
|
|
return "<a href='agenda_js.php?type=personal'>".Display::return_icon('calendar.png', get_lang('Agenda'), '', ICON_SIZE_MEDIUM)."</a>"; |
|
|
|
|
} |
|
|
|
|
$form = null; |
|
|
|
|
if (!isset($_GET['action'])) { |
|
|
|
|
$form = show_to($filter, 'selected_form_id_search'); |
|
|
|
@ -1563,6 +1565,7 @@ function display_courseadmin_links($filter = 0) |
|
|
|
|
} else { |
|
|
|
|
$actions = "<a href='agenda_js.php?type=course&".api_get_cidreq()."'>".Display::return_icon('calendar.png', get_lang('Agenda'), '', ICON_SIZE_MEDIUM)."</a>"; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$actions .= "<a href='agenda.php?".api_get_cidreq()."&sort=asc&toolgroup=".api_get_group_id()."&action=add'>".Display::return_icon('new_event.png', get_lang('AgendaAdd'), '', ICON_SIZE_MEDIUM)."</a>"; |
|
|
|
|
$actions .= "<a href='agenda.php?".api_get_cidreq()."&action=importical'>".Display::return_icon('import_calendar.png', get_lang('ICalFileImport'), '', ICON_SIZE_MEDIUM)."</a>"; |
|
|
|
|
$actions .= $form; |
|
|
|
@ -1595,7 +1598,7 @@ function display_student_links() |
|
|
|
|
* get all the information of the agenda_item from the database |
|
|
|
|
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University |
|
|
|
|
* @param integer the id of the agenda item we are getting all the information of |
|
|
|
|
* @return an associative array that contains all the information of the agenda item. The keys are the database fields |
|
|
|
|
* @return array an associative array that contains all the information of the agenda item. The keys are the database fields |
|
|
|
|
*/ |
|
|
|
|
function get_agenda_item($id) |
|
|
|
|
{ |
|
|
|
@ -1651,16 +1654,11 @@ function get_agenda_item($id) |
|
|
|
|
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University |
|
|
|
|
* @author Julio Montoya Adding UTC support |
|
|
|
|
*/ |
|
|
|
|
function store_edited_agenda_item($id_attach, $file_comment) |
|
|
|
|
function store_edited_agenda_item($event_id, $id_attach, $file_comment) |
|
|
|
|
{ |
|
|
|
|
global $_course; |
|
|
|
|
|
|
|
|
|
// database definitions |
|
|
|
|
$TABLE_ITEM_PROPERTY = Database::get_course_table(TABLE_ITEM_PROPERTY); |
|
|
|
|
|
|
|
|
|
// STEP 1: editing the calendar_event table |
|
|
|
|
// 1.a. some filtering of the input data |
|
|
|
|
$id = (int) $_POST['id']; |
|
|
|
|
$id = $event_id; |
|
|
|
|
$title = strip_tags(trim($_POST['title'])); // no html allowed in the title |
|
|
|
|
$content = trim($_POST['content']); |
|
|
|
|
$start_date = (int) $_POST['fyear']."-".(int) $_POST['fmonth']."-".(int) $_POST['fday']." ".(int) $_POST['fhour'].":".(int) $_POST['fminute'].":00"; |
|
|
|
@ -1670,19 +1668,23 @@ function store_edited_agenda_item($id_attach, $file_comment) |
|
|
|
|
if ($_POST['empty_end_date'] == 'on') { |
|
|
|
|
$end_date = "0000-00-00 00:00:00"; |
|
|
|
|
} |
|
|
|
|
$course_info = api_get_course_info(); |
|
|
|
|
|
|
|
|
|
$course_id = api_get_course_int_id(); |
|
|
|
|
|
|
|
|
|
// 1.b. the actual saving in calendar_event table |
|
|
|
|
$agendaObj = new Agenda(); |
|
|
|
|
$agendaObj->set_course(api_get_course_info()); |
|
|
|
|
$agendaObj->type = 'course'; |
|
|
|
|
$all_day = isset($_REQUEST['all_day']) && !empty($_REQUEST['all_day']) ? 1 : 0; |
|
|
|
|
if (empty($course_info)) { |
|
|
|
|
$agendaObj->type = 'personal'; |
|
|
|
|
} else { |
|
|
|
|
$agendaObj->set_course($course_info); |
|
|
|
|
$agendaObj->type = 'course'; |
|
|
|
|
|
|
|
|
|
if (api_is_course_coach() && !api_is_element_in_the_session(TOOL_AGENDA, $event_id)) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$all_day = isset($_REQUEST['all_day']) && !empty($_REQUEST['all_day']) ? 1 : 0; |
|
|
|
|
$agendaObj->edit_event($id, $start_date, $end_date, $all_day, null, $title, $content); |
|
|
|
|
|
|
|
|
|
$start_date = api_get_utc_datetime($start_date); |
|
|
|
|
$end_date = api_get_utc_datetime($end_date); |
|
|
|
|
|
|
|
|
|
if (empty($id_attach)) { |
|
|
|
|
add_agenda_attachment_file($file_comment, $id); |
|
|
|
@ -1749,7 +1751,7 @@ function save_edit_agenda_item($id, $title, $content, $start_date, $end_date) |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* This is the function that deletes an agenda item. |
|
|
|
|
* The agenda item is no longer fycically deleted but the visibility in the item_property table is set to 2 |
|
|
|
|
* The agenda item is no longer physically deleted but the visibility in the item_property table is set to 2 |
|
|
|
|
* which means that it is invisible for the student AND course admin. Only the platform administrator can see it. |
|
|
|
|
* This will in a later stage allow the platform administrator to recover resources that were mistakenly deleted |
|
|
|
|
* by the course administrator |
|
|
|
@ -2286,41 +2288,47 @@ function show_add_form($id = '') |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$default_no_empty_end_date = 0; |
|
|
|
|
$course_info = null; |
|
|
|
|
|
|
|
|
|
// if the id is set then we are editing an agenda item |
|
|
|
|
if (!empty($id)) { |
|
|
|
|
|
|
|
|
|
$item_2_edit = get_agenda_item($id); |
|
|
|
|
$course_info = api_get_course_info(); |
|
|
|
|
|
|
|
|
|
$agendaObj = new Agenda(); |
|
|
|
|
$agendaObj->set_course(api_get_course_info()); |
|
|
|
|
$agendaObj->type = 'course'; |
|
|
|
|
if (!empty($course_info)) { |
|
|
|
|
$agendaObj->set_course($course_info); |
|
|
|
|
$agendaObj->type = 'course'; |
|
|
|
|
} else { |
|
|
|
|
$agendaObj->type = 'personal'; |
|
|
|
|
} |
|
|
|
|
$agendaItem = $agendaObj->get_event($id); |
|
|
|
|
|
|
|
|
|
$title = $item_2_edit['title']; |
|
|
|
|
$content = $item_2_edit['content']; |
|
|
|
|
$title = $agendaItem['title']; |
|
|
|
|
$content = $agendaItem['text']; |
|
|
|
|
|
|
|
|
|
// start date |
|
|
|
|
if ($item_2_edit['start_date'] != '0000-00-00 00:00:00') { |
|
|
|
|
$item_2_edit['start_date'] = api_get_local_time($item_2_edit['start_date']); |
|
|
|
|
list($datepart, $timepart) = explode(" ", $item_2_edit['start_date']); |
|
|
|
|
if ($agendaItem['start_date'] != '0000-00-00 00:00:00') { |
|
|
|
|
$agendaItem['start_date'] = api_get_local_time($agendaItem['start_date']); |
|
|
|
|
list($datepart, $timepart) = explode(" ", $agendaItem['start_date']); |
|
|
|
|
list($year, $month, $day) = explode("-", $datepart); |
|
|
|
|
list($hours, $minutes, $seconds) = explode(":", $timepart); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// end date |
|
|
|
|
if ($item_2_edit['end_date'] != '0000-00-00 00:00:00') { |
|
|
|
|
$item_2_edit['end_date'] = api_get_local_time($item_2_edit['end_date']); |
|
|
|
|
list($datepart, $timepart) = explode(" ", $item_2_edit['end_date']); |
|
|
|
|
if ($agendaItem['end_date'] != '0000-00-00 00:00:00') { |
|
|
|
|
$agendaItem['end_date'] = api_get_local_time($agendaItem['end_date']); |
|
|
|
|
list($datepart, $timepart) = explode(" ", $agendaItem['end_date']); |
|
|
|
|
list($end_year, $end_month, $end_day) = explode("-", $datepart); |
|
|
|
|
|
|
|
|
|
list($end_hours, $end_minutes, $end_seconds) = explode(":", $timepart); |
|
|
|
|
} elseif ($item_2_edit['end_date'] == '0000-00-00 00:00:00') { |
|
|
|
|
} elseif ($agendaItem['end_date'] == '0000-00-00 00:00:00') { |
|
|
|
|
$default_no_empty_end_date = 1; |
|
|
|
|
} |
|
|
|
|
// attachments |
|
|
|
|
edit_added_resources("Agenda", $id); |
|
|
|
|
$to = $item_2_edit['to']; |
|
|
|
|
//edit_added_resources("Agenda", $id); |
|
|
|
|
//$to = $item_2_edit['to']; |
|
|
|
|
} else { |
|
|
|
|
$to = load_edit_users(TOOL_CALENDAR_EVENT, $id); |
|
|
|
|
} |
|
|
|
|
$content = stripslashes($content); |
|
|
|
|
$title = stripslashes($title); |
|
|
|
@ -2331,11 +2339,12 @@ function show_add_form($id = '') |
|
|
|
|
unset_session_resources(); |
|
|
|
|
} |
|
|
|
|
$origin = isset($_GET['origin']) ? Security::remove_XSS($_GET['origin']) : null; |
|
|
|
|
$course_url = empty($course_info) ? null : api_get_cidreq(); |
|
|
|
|
?> |
|
|
|
|
|
|
|
|
|
<!-- START OF THE FORM --> |
|
|
|
|
|
|
|
|
|
<form class="form-horizontal" enctype="multipart/form-data" action="<?php echo api_get_self().'?origin='.$origin.'&'.api_get_cidreq()."&sort=asc&toolgroup=".Security::remove_XSS($_GET['toolgroup']).'&action='.Security::remove_XSS($_GET['action']); ?>" method="post" name="new_calendar_item">
|
|
|
|
|
<form class="form-horizontal" enctype="multipart/form-data" action="<?php echo api_get_self().'?origin='.$origin.'&'.$course_url."&sort=asc&toolgroup=".api_get_group_id().'&action='.Security::remove_XSS($_GET['action']); ?>" method="post" name="new_calendar_item">
|
|
|
|
|
<input type="hidden" name="id" value="<?php if (isset($id)) echo $id; ?>" />
|
|
|
|
|
<input type="hidden" name="action" value="<?php if (isset($_GET['action'])) echo $_GET['action']; ?>" />
|
|
|
|
|
<input type="hidden" name="id_attach" value="<?php echo isset($_REQUEST['id_attach']) ? intval($_REQUEST['id_attach']) : null; ?>" />
|
|
|
|
@ -2361,8 +2370,8 @@ function show_add_form($id = '') |
|
|
|
|
if (isset($title)) |
|
|
|
|
echo $title; |
|
|
|
|
echo '" /> |
|
|
|
|
</div> |
|
|
|
|
</div>'; |
|
|
|
|
</div> |
|
|
|
|
</div>'; |
|
|
|
|
|
|
|
|
|
// selecting the users / groups |
|
|
|
|
$group_id = api_get_group_id(); |
|
|
|
@ -2601,7 +2610,7 @@ function show_add_form($id = '') |
|
|
|
|
</td> |
|
|
|
|
</tr> |
|
|
|
|
<tr> |
|
|
|
|
<td><label for="repeat_type"><?php echo get_lang('RepeatType'); ?></label></td>
|
|
|
|
|
<td><label><?php echo get_lang('RepeatType'); ?></label></td>
|
|
|
|
|
<td> |
|
|
|
|
<select name="repeat_type"> |
|
|
|
|
<option value="daily"><?php echo get_lang('RepeatDaily'); ?></option>
|
|
|
|
@ -2614,7 +2623,7 @@ function show_add_form($id = '') |
|
|
|
|
</td> |
|
|
|
|
</tr> |
|
|
|
|
<tr> |
|
|
|
|
<td><label for="repeat_end_day"><?php echo get_lang('RepeatEnd'); ?></label></td>
|
|
|
|
|
<td><label><?php echo get_lang('RepeatEnd'); ?></label></td>
|
|
|
|
|
<td> |
|
|
|
|
<select name="repeat_end_day"> |
|
|
|
|
<?php |
|
|
|
@ -2701,6 +2710,8 @@ function show_add_form($id = '') |
|
|
|
|
//echo '<textarea class="span5" rows="4" name="content">'.$content.'</textarea>'; |
|
|
|
|
echo '</div> |
|
|
|
|
</div>'; |
|
|
|
|
|
|
|
|
|
if ($agendaObj->type != 'personal') { |
|
|
|
|
// File attachment |
|
|
|
|
echo ' <div class="control-group"> |
|
|
|
|
<label class="control-label"> |
|
|
|
@ -2709,6 +2720,7 @@ function show_add_form($id = '') |
|
|
|
|
<input type="file" name="user_upload"/> '.get_lang('Comment').' <input name="file_comment" type="text" size="20" /> |
|
|
|
|
</div> |
|
|
|
|
</div>'; |
|
|
|
|
} |
|
|
|
|
// the submit button for storing the calendar item |
|
|
|
|
echo ' <div class="control-group"> |
|
|
|
|
<label class="control-label"> |
|
|
|
|