require_login($course->id, false, $cm);
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
+ require_capability('mod/glossary:view', $context);
+ $manageentries = has_capability('mod/glossary:manageentries', $context);
- if (isguest()) {
- error("Guests are not allowed to edit or delete entries", $_SERVER["HTTP_REFERER"]);
- }
-
if (! $glossary = get_record("glossary", "id", $cm->instance)) {
error("Glossary is incorrect");
}
- if (!has_capability('mod/glossary:manageentries', $context) ) {
- error("You are not allowed to edit or delete entries");
- }
$strareyousuredelete = get_string("areyousuredelete","glossary");
navmenu($course, $cm));
- if (($entry->userid != $USER->id) and !isteacher($course->id)) {
+ if (($entry->userid != $USER->id) and !$manageentries) { // guest id is never matched, no need for special check here
error("You can't delete other people's entries!");
}
$ineditperiod = ((time() - $entry->timecreated < $CFG->maxeditingtime) || $glossary->editalways);
- if (!$ineditperiod and !isteacher($course->id)) {
+ if ((!$ineditperiod or !$glossary->studentcanpost) and !$manageentries) {
error("You can't delete this. Time expired!");
}
//Use this code to show author's name
//Comments: Configuration not supported
- $fullname = fullname($user, isteacher($course->id));
+ $fullname = fullname($user);
$by->name = '<a href="'.$CFG->wwwroot.'/user/view.php?id='.$user->id.'&course='.$course->id.'">'.$fullname.'</a>';
$by->date = userdate($entry->timemodified);
echo '<span class="author">'.get_string('bynameondate', 'forum', $by).'</span>' . '<br />';
glossary_print_entry_concept($entry);
echo '</span><br />';
- $fullname = fullname($user, isteacher($course->id));
+ $fullname = fullname($user);
$by->name = '<a href="'.$CFG->wwwroot.'/user/view.php?id='.$user->id.'&course='.$course->id.'">'.$fullname.'</a>';
$by->date = userdate($entry->timemodified);
echo '<span class="author">'.get_string('bynameondate', 'forum', $by).'</span>';
glossary_print_entry_concept($entry);
echo '</span><br />';
- $fullname = fullname($user, isteacher($course->id));
+ $fullname = fullname($user);
$by->name = '<a href="'.$CFG->wwwroot.'/user/view.php?id='.$user->id.'&course='.$course->id.'">'.$fullname.'</a>';
$by->date = userdate($entry->timemodified);
echo '<span class="author">'.get_string('bynameondate', 'forum', $by).'</span>';
}
require_course_login($course);
+ $context = get_context_instance(CONTEXT_COURSE, $course->id);
add_to_log($course->id, "glossary", "view all", "index.php?id=$course->id", "");
$table->align = array ("LEFT", "CENTER");
}
- $can_subscribe = (isstudent($course->id) or isteacher($course->id) or isadmin());
+ $can_subscribe = has_capability('mod/glossary:view', $context);
if ($show_rss = (($can_subscribe || $course->id == SITEID) &&
isset($CFG->enablerssfeeds) && isset($CFG->glossary_enablerssfeeds) &&
// -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->timecreated < $CFG->maxeditingtime) || $glossary->editalways);
- if ( !$importedentry and (has_capability('mod/glossary:manageentries', $context) or ($entry->userid == $USER->id and $ineditperiod))) {
+ if ( !$importedentry and (has_capability('mod/glossary:manageentries', $context) or ($entry->userid == $USER->id and ($ineditperiod and $glossary->studentcanpost)))) {
$output = true;
$return .= " <a title=\"" . get_string("delete") . "\" href=\"deleteentry.php?id=$cm->id&mode=delete&entry=$entry->id&prevmode=$mode&hook=$hook\"><img src=\"";
$return .= $icon;
print_header();
require_course_login($course, true, $cm);
+ $context = get_context_instance(CONTEXT_MODULE, $cm->id);
/// Loading the textlib singleton instance. We are going to need it.
$textlib = textlib_get_instance();
- if (!isteacher($course->id) and !$glossary->allowprintview) {
+ if (!has_capability('mod/glossary:manageentries', $context) and !$glossary->allowprintview) {
notice(get_string('printviewnotallowed', 'glossary'));
}
if ( isset($entry->uid) ) {
// printing the user icon if defined (only when browsing authors)
$user = get_record("user","id",$entry->uid);
- $pivottoshow = fullname($user, isteacher($course->id));
+ $pivottoshow = fullname($user);
}
echo "<p align=\"center\"><strong>".clean_text($pivottoshow)."</strong></p>" ;