diff --git a/mod/glossary/comment.php b/mod/glossary/comment.php index 546141ae2bf..bb7c649ce32 100644 --- a/mod/glossary/comment.php +++ b/mod/glossary/comment.php @@ -71,6 +71,9 @@ /// Input section if ( $action == "delete" ) { + if (($comment->userid <> $USER->id) and !isteacher($glossary->course)) { + error("You can't delete other people's comments!"); + } if ( $confirm ) { delete_records("glossary_comments","id", $cid); @@ -105,16 +108,13 @@ } } else { if ( $action == "edit" ) { - if ( (time() - $comment->timemodified >= $CFG->maxeditingtime or - $USER->id != $comment->userid) and !isteacher($course->id) ) { - echo "
$strareyousuredelete
", - "deleteentry.php?id=$cm->id&mode=delete&confirm=1&entry=".s($entry)."&prevmode=$prevmode&hook=$hook", + "deleteentry.php?id=$cm->id&mode=delete&confirm=1&entry=".s($entry->concept)."&prevmode=$prevmode&hook=$hook", "view.php?id=$cm->id&mode=$prevmode&hook=$hook"); } diff --git a/mod/glossary/edit.php b/mod/glossary/edit.php index 532d19d684e..b1573f196f4 100644 --- a/mod/glossary/edit.php +++ b/mod/glossary/edit.php @@ -192,6 +192,8 @@ if ( $confirm ) { $newentry->casesensitive = $form->casesensitive; $newentry->fullmatch = $form->fullmatch; $newentry->aliases = ""; + $newentry->userid = $form->userid; + $newentry->timemodified = $form->timemodified; if ( $aliases = get_records("glossary_alias","entryid",$e) ) { foreach ($aliases as $alias) { @@ -232,6 +234,9 @@ if (!isset($newentry->fullmatch)) { if (!isset($newentry->definition)) { $newentry->definition = ""; } +if (!isset($newentry->timemodified)) { + $newentry->timemodified = 0; +} $strglossary = get_string("modulename", "glossary"); $strglossaries = get_string("modulenameplural", "glossary"); $stredit = get_string("edit"); @@ -247,6 +252,16 @@ print_header_simple(strip_tags("$glossary->name"), "", id\">$glossary->name -> $stredit", "", "", true, "", navmenu($course, $cm)); +$ineditperiod = ((time() - $newentry->timemodified < $CFG->maxeditingtime) || $glossary->editalways); +if ( (!$ineditperiod || $USER->id != $newentry->userid) and !isteacher($course->id) and $e) { + if ( $USER->id != $newentry->userid ) { + error("You can't edit other people's entries!"); + } elseif (!$ineditperiod) { + error("You can't edit this. Time expired!"); + } + die; + } + echo '' . stripslashes_safe($glossary->name); echo '
'; diff --git a/mod/glossary/lib.php b/mod/glossary/lib.php index 4e038fd8c08..5696500bebd 100644 --- a/mod/glossary/lib.php +++ b/mod/glossary/lib.php @@ -710,8 +710,8 @@ function glossary_print_entry_icons($course, $cm, $glossary, $entry,$mode="",$ho //Decide if an entry is editable: // -It isn't a imported entry (so nobody can edit a imported (from secondary to main) entry)) and // -The user is teacher or he is a student with time permissions (edit period or editalways defined). - $ineditperiod = (time() - $entry->timemodified < $CFG->maxeditingtime); - if ( !$importedentry and ($isteacher or ($entry->userid == $USER->id and ($glossary->editalways or $ineditperiod)))) { + $ineditperiod = ((time() - $entry->timemodified < $CFG->maxeditingtime) || $glossary->editalways); + if ( !$importedentry and ($isteacher or ($entry->userid == $USER->id and $ineditperiod))) { $return .= " id&mode=delete&entry=$entry->id&prevmode=$mode&hook=$hook\">";
- if ( (time() - $comment->timemodified < $CFG->maxeditingtime and $USER->id == $comment->userid) or isteacher($course->id) ) {
+ $ineditperiod = ((time() - $comment->timemodified < $CFG->maxeditingtime) || $glossary->editalways);
+ if ( ($ineditperiod && $USER->id == $comment->userid) or isteacher($course->id) ) {
echo "id&eid=$entry->id&cid=$comment->id&action=edit\">pixpath/t/edit.gif\" height=11 width=11 border=0> ";
}