@@ -143,6 +144,40 @@ function display_default_visibility_form($uploadvisibledisabled) {
, Ghent University, Belgium
+ */
+function display_studentsdelete_form()
+{
+ // by default api_get_course_setting returns -1 and the code only expects 0 or 1 so anything tha
+ // is different than 1 will be converted into 0
+ $current_course_setting_value = api_get_course_setting('student_delete_own_publication');
+ if ($current_course_setting_value <> 1)
+ {
+ $current_course_setting_value = 0;
+ }
+ ?>
+
+

';
- $action .= '
.'delete.gif)
';
+ $action .= '
'.Display::return_icon('delete.gif',get_lang('DirDelete')).'';
$row[] = $action;
} else {
$row[] = "";
@@ -712,7 +741,7 @@ function display_student_publications_list($work_dir,$sub_course_dir,$currentCou
$action = '';
$action .= '

';
- $action .= '

';
+ $action .= '
'.Display::return_icon('delete.gif',get_lang('WorkDelete')).'';
$action .= '

';
if($work->accepted == '1') {
$action .= '

';
@@ -721,10 +750,13 @@ function display_student_publications_list($work_dir,$sub_course_dir,$currentCou
}
$row[] = $action;
- } elseif($is_author) {
+ // the user that is not course admin can only edit/delete own document
+ } elseif($row2['insert_user_id'] == $_user['user_id']) {
$action = '';
$action .= '

';
- $action .= '

';
+ if (api_get_course_setting('student_delete_own_publication')==1) {
+ $action .= '
'.Display::return_icon('delete.gif',get_lang('WorkDelete')).'';
+ }
$row[] = $action;
} else {
diff --git a/main/work/work.php b/main/work/work.php
index 42b38f5aa0..ce093809a8 100644
--- a/main/work/work.php
+++ b/main/work/work.php
@@ -390,9 +390,29 @@ $is_allowed_to_edit = api_is_allowed_to_edit(null,true); //has to come after dis
if (!empty ($_POST['changeProperties'])) {
+ // changing the tool setting: default visibility of an uploaded document
$query = "UPDATE " . $main_course_table . " SET show_score='" . $uploadvisibledisabled . "' WHERE code='" . $_course['sysCode'] . "'";
Database::query($query, __FILE__, __LINE__);
+ // changing the tool setting: is a student allowed to delete his/her own document
+ // database table definition
+ $table_course_setting = Database :: get_course_table(TOOL_COURSE_SETTING);
+
+ // counting the number of occurrences of this setting (if 0 => add, if 1 => update)
+ $query = "SELECT * FROM " . $table_course_setting . " WHERE variable = 'student_delete_own_publication'";
+ $result = Database::query($query, __FILE__, __LINE__);
+ $number_of_setting = Database::num_rows($result);
+ echo $number_of_setting;
+
+ if ($number_of_setting == 1){
+ $query = "UPDATE " . $table_course_setting . " SET value='" . Database::escape_string($_POST['student_delete_own_publication']) . "' WHERE variable='student_delete_own_publication'";
+ Database::query($query, __FILE__, __LINE__);
+ } else {
+ $query = "INSERT INTO " . $table_course_setting . " (variable, value, category) VALUES ('student_delete_own_publication','" . Database::escape_string($_POST['student_delete_own_publication']) . "','work')";
+ Database::query($query, __FILE__, __LINE__);
+ }
+ echo $query;
+
$_course['show_score'] = $uploadvisibledisabled;
} else {
$query = "SELECT * FROM " . $main_course_table . " WHERE code=\"" . $_course['sysCode'] . "\"";
@@ -776,7 +796,7 @@ else {
$author_sql = "SELECT * FROM $iprop_table WHERE tool = 'work' AND insert_user_id='$user_id' AND ref=" .Database::escape_string($delete);
$author_qry = Database::query($author_sql, __FILE__, __LINE__);
- if (Database :: num_rows($author_qry) == 1) {
+ if (Database :: num_rows($author_qry) == 1 AND api_get_course_setting('student_delete_own_publication') == 1) {
//we found the current user is the author
$queryString1 = "SELECT url FROM " . $work_table . " WHERE id = '$delete'";
$queryString2 = "DELETE FROM " . $work_table . " WHERE id='$delete'";
@@ -796,6 +816,9 @@ else {
}
}
}
+ Display::display_confirmation_message(get_lang('TheDocumentHasBeenDeleted'));
+ } else {
+ Display::display_error_message(get_lang('YouAreNotAllowedToDeleteThisDocument'));
}
}
}