]> git.mjollnir.org Git - moodle.git/commitdiff
removing some isteacher()s from glossary
authorskodak <skodak>
Sat, 26 Aug 2006 19:19:36 +0000 (19:19 +0000)
committerskodak <skodak>
Sat, 26 Aug 2006 19:19:36 +0000 (19:19 +0000)
mod/glossary/deleteentry.php
mod/glossary/formats/TEMPLATE/TEMPLATE_format.php
mod/glossary/formats/encyclopedia/encyclopedia_format.php
mod/glossary/formats/fullwithauthor/fullwithauthor_format.php
mod/glossary/index.php
mod/glossary/lib.php
mod/glossary/print.php

index d624f936ffa017b382c5b124f1fc5c680b5381b4..3058025e688cda6052022f0a900bd7575afdafd5 100644 (file)
 
     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!");
     }
 
index edc5e6c16b3a59d8a4ace4e00ff18c6ce6736a9e..bc5a624fe605dabfeb4bfca79d060bbf0a96ddcb 100755 (executable)
@@ -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 = '<a href="'.$CFG->wwwroot.'/user/view.php?id='.$user->id.'&amp;course='.$course->id.'">'.$fullname.'</a>';
         $by->date = userdate($entry->timemodified);
         echo '<span class="author">'.get_string('bynameondate', 'forum', $by).'</span>' . '<br />';
index 00438384daac4c9f58a8af4b7cfc7d2e835fc3e6..70f3f7c5d05ba5127efeb4eff77448b36a997a38 100644 (file)
@@ -21,7 +21,7 @@ function glossary_show_entry_encyclopedia($course, $cm, $glossary, $entry, $mode
         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.'&amp;course='.$course->id.'">'.$fullname.'</a>';
         $by->date = userdate($entry->timemodified);
         echo '<span class="author">'.get_string('bynameondate', 'forum', $by).'</span>';
index c9050f305c5a86455810829fecd518d20da6e2de..263085259ea0ef70650f9980b9eac8585bce8962 100644 (file)
@@ -22,7 +22,7 @@ function glossary_show_entry_fullwithauthor($course, $cm, $glossary, $entry, $mo
         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.'&amp;course='.$course->id.'">'.$fullname.'</a>';
         $by->date = userdate($entry->timemodified);
         echo '<span class="author">'.get_string('bynameondate', 'forum', $by).'</span>';
index 03fdd3df2d68e85ab177b9b43c95ece478b72f8b..9c2477ade663ea7a55bc6575d4b18e69024ab3f3 100644 (file)
@@ -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) &&
index b987daea921c16965c4c8403e48767a1bee39197..f0b2c0df660c9473189f31b92c6fe6f248c3a691 100644 (file)
@@ -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 .= " <a title=\"" . get_string("delete") . "\" href=\"deleteentry.php?id=$cm->id&amp;mode=delete&amp;entry=$entry->id&amp;prevmode=$mode&amp;hook=$hook\"><img src=\"";
             $return .= $icon;
index 106017e6c47ef3131b3b5cbab015bf69435ab124..ced3023567d041b9c9f249128a1ace465179b557 100644 (file)
     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>" ;