From b3e570450fc1cc2c08e927caa144191b0fd61b7d Mon Sep 17 00:00:00 2001 From: skodak Date: Sat, 26 Aug 2006 19:19:36 +0000 Subject: [PATCH] removing some isteacher()s from glossary --- mod/glossary/deleteentry.php | 13 ++++--------- mod/glossary/formats/TEMPLATE/TEMPLATE_format.php | 2 +- .../formats/encyclopedia/encyclopedia_format.php | 2 +- .../fullwithauthor/fullwithauthor_format.php | 2 +- mod/glossary/index.php | 3 ++- mod/glossary/lib.php | 2 +- mod/glossary/print.php | 5 +++-- 7 files changed, 13 insertions(+), 16 deletions(-) diff --git a/mod/glossary/deleteentry.php b/mod/glossary/deleteentry.php index d624f936ff..3058025e68 100644 --- a/mod/glossary/deleteentry.php +++ b/mod/glossary/deleteentry.php @@ -30,18 +30,13 @@ 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"); @@ -51,11 +46,11 @@ 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!"); } diff --git a/mod/glossary/formats/TEMPLATE/TEMPLATE_format.php b/mod/glossary/formats/TEMPLATE/TEMPLATE_format.php index edc5e6c16b..bc5a624fe6 100755 --- a/mod/glossary/formats/TEMPLATE/TEMPLATE_format.php +++ b/mod/glossary/formats/TEMPLATE/TEMPLATE_format.php @@ -23,7 +23,7 @@ function glossary_show_entry_TEMPLATE($course, $cm, $glossary, $entry, $mode='', //Use this code to show author's name //Comments: Configuration not supported - $fullname = fullname($user, isteacher($course->id)); + $fullname = fullname($user); $by->name = ''.$fullname.''; $by->date = userdate($entry->timemodified); echo ''.get_string('bynameondate', 'forum', $by).'' . '
'; diff --git a/mod/glossary/formats/encyclopedia/encyclopedia_format.php b/mod/glossary/formats/encyclopedia/encyclopedia_format.php index 00438384da..70f3f7c5d0 100644 --- a/mod/glossary/formats/encyclopedia/encyclopedia_format.php +++ b/mod/glossary/formats/encyclopedia/encyclopedia_format.php @@ -21,7 +21,7 @@ function glossary_show_entry_encyclopedia($course, $cm, $glossary, $entry, $mode glossary_print_entry_concept($entry); echo '
'; - $fullname = fullname($user, isteacher($course->id)); + $fullname = fullname($user); $by->name = ''.$fullname.''; $by->date = userdate($entry->timemodified); echo ''.get_string('bynameondate', 'forum', $by).''; diff --git a/mod/glossary/formats/fullwithauthor/fullwithauthor_format.php b/mod/glossary/formats/fullwithauthor/fullwithauthor_format.php index c9050f305c..263085259e 100644 --- a/mod/glossary/formats/fullwithauthor/fullwithauthor_format.php +++ b/mod/glossary/formats/fullwithauthor/fullwithauthor_format.php @@ -22,7 +22,7 @@ function glossary_show_entry_fullwithauthor($course, $cm, $glossary, $entry, $mo glossary_print_entry_concept($entry); echo '
'; - $fullname = fullname($user, isteacher($course->id)); + $fullname = fullname($user); $by->name = ''.$fullname.''; $by->date = userdate($entry->timemodified); echo ''.get_string('bynameondate', 'forum', $by).''; diff --git a/mod/glossary/index.php b/mod/glossary/index.php index 03fdd3df2d..9c2477ade6 100644 --- a/mod/glossary/index.php +++ b/mod/glossary/index.php @@ -14,6 +14,7 @@ } 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", ""); @@ -55,7 +56,7 @@ $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) && diff --git a/mod/glossary/lib.php b/mod/glossary/lib.php index b987daea92..f0b2c0df66 100644 --- a/mod/glossary/lib.php +++ b/mod/glossary/lib.php @@ -819,7 +819,7 @@ function glossary_print_entry_icons($course, $cm, $glossary, $entry, $mode='',$h // -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 .= " id&mode=delete&entry=$entry->id&prevmode=$mode&hook=$hook\">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')); } @@ -169,7 +170,7 @@ 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 "

".clean_text($pivottoshow)."

" ; -- 2.39.5