Add delete_correction feature

pull/2487/head
jmontoyaa 9 years ago
parent 2f9edaf4ae
commit c20c3a2669
  1. 26
      main/work/view.php
  2. 19
      main/work/work.lib.php

@ -97,6 +97,19 @@ if ((user_is_author($id) || $isDrhOfCourse || (api_is_allowed_to_edit() || api_i
);
Display::addFlash(Display::return_message(get_lang('DocDeleted')));
header('Location: '.$url);
exit;
break;
case 'delete_correction':
if (isset($work['url_correction']) && !empty($work['url_correction'])) {
if (api_is_allowed_to_edit()) {
deleteCorrection($courseInfo, $work);
Display::addFlash(
Display::return_message(get_lang('Deleted'))
);
}
}
header('Location: '.$url);
exit;
break;
@ -123,7 +136,7 @@ if ((user_is_author($id) || $isDrhOfCourse || (api_is_allowed_to_edit() || api_i
$work['download_url']
);
if (isset($work['url_correction'])) {
if (!empty($work['url_correction'])) {
$actions .= Display::url(
Display::return_icon(
'check-circle.png',
@ -133,6 +146,17 @@ if ((user_is_author($id) || $isDrhOfCourse || (api_is_allowed_to_edit() || api_i
),
$work['download_url'].'&correction=1'
);
if (api_is_allowed_to_edit()) {
$actions .= Display::url(
Display::return_icon(
'delete.png',
get_lang('Delete').': '.get_lang('Correction'),
null,
ICON_SIZE_MEDIUM
),
api_get_self().'?action=delete_correction&id='.$id.'&'.api_get_cidreq()
);
}
}
}
}

@ -5129,3 +5129,22 @@ function protectWork($courseInfo, $workId)
}
}
}
function deleteCorrection($courseInfo, $work)
{
if (isset($work['url_correction']) && !empty($work['url_correction']) && isset($work['iid'])) {
$id = $work['iid'];
$table = Database:: get_course_table(TABLE_STUDENT_PUBLICATION);
$sql = "UPDATE $table SET
url_correction = '',
title_correction = ''
WHERE iid = $id";
Database::query($sql);
$coursePath = api_get_path(SYS_COURSE_PATH).$courseInfo['path'].'/';
if (file_exists($coursePath.$work['url_correction'])) {
if (Security::check_abs_path($coursePath.$work['url_correction'], $coursePath)) {
unlink($coursePath.$work['url_correction']);
}
}
}
}

Loading…
Cancel
Save