mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 08:56:36 +02:00
ROLES AND PERMISSIONS - FIRST CHECK-IN
======================================= WARNING: DEV IS CURRENTLY VERY UNSTABLE. This is a mega-checkin of the new Roles system. A lot of changes have been made in core and modules. Currently there are a lot of rough edges and known problems. We are working hard on these .. .the reason for getting this into HEAD at this stage is enable us to move faster (our branch was diverging from HEAD too much). Please keep an eye on http://docs.moodle.org/en/Roles for current status and information for developers on how to use the new Roles system.
This commit is contained in:
parent
394577c3e4
commit
bbbf2d4015
139 changed files with 40452 additions and 2001 deletions
|
@ -12,7 +12,7 @@
|
|||
if (! $cm = get_record("course_modules", "id", $id)) {
|
||||
error("Course Module ID was incorrect");
|
||||
}
|
||||
|
||||
|
||||
if (! $course = get_record("course", "id", $cm->course)) {
|
||||
error("Course is misconfigured");
|
||||
}
|
||||
|
@ -21,10 +21,11 @@
|
|||
error("Course module is incorrect");
|
||||
}
|
||||
|
||||
require_login($course->id, false, $cm);
|
||||
if (!isteacher($course->id)) {
|
||||
error("You must be a teacher to use this page.");
|
||||
}
|
||||
require_login($course->id, false, $cm);
|
||||
|
||||
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
|
||||
has_capability('mod/glossary:approve', $context->id, true);
|
||||
|
||||
$newentry->id = $eid;
|
||||
$newentry->approved = 1;
|
||||
|
||||
|
|
|
@ -37,8 +37,10 @@
|
|||
}
|
||||
|
||||
require_login($course->id, false, $cm);
|
||||
|
||||
if (isguest()) {
|
||||
|
||||
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
|
||||
|
||||
if (isguest()) {
|
||||
error('Guests are not allowed to post comments', $_SERVER['HTTP_REFERER']);
|
||||
}
|
||||
add_to_log($course->id, 'glossary', 'view', "view.php?id=$cm->id", "$glossary->id",$cm->id);
|
||||
|
@ -72,10 +74,10 @@
|
|||
/// Input section
|
||||
|
||||
if ( $action == 'delete' ) {
|
||||
if (($comment->userid <> $USER->id) and !isteacher($glossary->course)) {
|
||||
if (($comment->userid <> $USER->id) and !has_capability('mod/glossary:managecomments', $context->id)) {
|
||||
error('You can\'t delete other people\'s comments!');
|
||||
}
|
||||
if (!$glossary->allowcomments && !isteacher($glossary->course)) {
|
||||
if (!$glossary->allowcomments && !has_capability('mod/glossary:managecomments', $context->id)) {
|
||||
error('You can\'t delete comments in this glossary!');
|
||||
}
|
||||
if ( $confirm ) {
|
||||
|
@ -111,7 +113,7 @@
|
|||
print_simple_box_end();
|
||||
}
|
||||
} else {
|
||||
if (!$glossary->allowcomments && !isteacher($glossary->course)) {
|
||||
if (!$glossary->allowcomments && !has_capability('mod/glossary:comment', $context->id)) {
|
||||
error('You can\'t add/edit comments to this glossary!');
|
||||
}
|
||||
if ( $action == 'edit' ) {
|
||||
|
@ -121,7 +123,7 @@
|
|||
$timetocheck = $comment->timemodified;
|
||||
}
|
||||
$ineditperiod = ((time() - $timetocheck < $CFG->maxeditingtime) || $glossary->editalways);
|
||||
if ( (!$ineditperiod || $USER->id != $comment->userid) and !isteacher($course->id) and $cid) {
|
||||
if ( (!$ineditperiod || $USER->id != $comment->userid) and !has_capability('mod/glossary:comment', $context->id) and $cid) {
|
||||
if ( $USER->id != $comment->userid ) {
|
||||
error('You can\'t edit other people\'s comments!');
|
||||
} elseif (!$ineditperiod) {
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
error("Entry is incorrect");
|
||||
}
|
||||
|
||||
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
|
||||
|
||||
require_login($course->id, false, $cm);
|
||||
|
||||
|
@ -56,7 +57,7 @@
|
|||
|
||||
print_heading(format_string(get_string('commentson','glossary')." <b>\"$entry->concept\"</b>"));
|
||||
|
||||
if ($glossary->allowcomments || isteacher($glossary->course)) {
|
||||
if ($glossary->allowcomments || has_capability('mod/glossary:managecomments', $context->id)) {
|
||||
print_heading("<a href=\"comment.php?id=$cm->id&eid=$entry->id\">$straddcomment</a> <img title=\"$straddcomment\" src=\"comment.gif\" height=\"11\" width=\"11\" border=\"0\" alt=\"\" />");
|
||||
}
|
||||
|
||||
|
|
192
mod/glossary/db/access.php
Normal file
192
mod/glossary/db/access.php
Normal file
|
@ -0,0 +1,192 @@
|
|||
<?php
|
||||
//
|
||||
// Capability definitions for the glossary module.
|
||||
//
|
||||
// The capabilities are loaded into the database table when the module is
|
||||
// installed or updated. Whenever the capability definitions are updated,
|
||||
// the module version number should be bumped up.
|
||||
//
|
||||
// The system has four possible values for a capability:
|
||||
// CAP_ALLOW, CAP_PREVENT, CAP_PROHIBIT, and inherit (not set).
|
||||
//
|
||||
//
|
||||
// CAPABILITY NAMING CONVENTION
|
||||
//
|
||||
// It is important that capability names are unique. The naming convention
|
||||
// for capabilities that are specific to modules and blocks is as follows:
|
||||
// [mod/block]/<component_name>:<capabilityname>
|
||||
//
|
||||
// component_name should be the same as the directory name of the mod or block.
|
||||
//
|
||||
// Core moodle capabilities are defined thus:
|
||||
// moodle/<capabilityclass>:<capabilityname>
|
||||
//
|
||||
// Examples: mod/forum:viewpost
|
||||
// block/recent_activity:view
|
||||
// moodle/site:deleteuser
|
||||
//
|
||||
// The variable name for the capability definitions array follows the format
|
||||
// $<componenttype>_<component_name>_capabilities
|
||||
//
|
||||
// For the core capabilities, the variable is $moodle_capabilities.
|
||||
|
||||
|
||||
$mod_glossary_capabilities = array(
|
||||
|
||||
'mod/glossary:view' => array(
|
||||
|
||||
'captype' => 'read',
|
||||
'contextlevel' => CONTEXT_MODULE,
|
||||
'legacy' => array(
|
||||
'guest' => CAP_PREVENT,
|
||||
'student' => CAP_ALLOW,
|
||||
'teacher' => CAP_ALLOW,
|
||||
'editingteacher' => CAP_ALLOW,
|
||||
'coursecreator' => CAP_ALLOW,
|
||||
'admin' => CAP_ALLOW
|
||||
)
|
||||
),
|
||||
|
||||
'mod/glossary:write' => array(
|
||||
|
||||
'captype' => 'write',
|
||||
'contextlevel' => CONTEXT_MODULE,
|
||||
'legacy' => array(
|
||||
'guest' => CAP_PREVENT,
|
||||
'student' => CAP_ALLOW,
|
||||
'teacher' => CAP_ALLOW,
|
||||
'editingteacher' => CAP_ALLOW,
|
||||
'coursecreator' => CAP_ALLOW,
|
||||
'admin' => CAP_ALLOW
|
||||
)
|
||||
),
|
||||
|
||||
'mod/glossary:manageentries' => array(
|
||||
|
||||
'captype' => 'write',
|
||||
'contextlevel' => CONTEXT_MODULE,
|
||||
'legacy' => array(
|
||||
'guest' => CAP_PREVENT,
|
||||
'student' => CAP_PREVENT,
|
||||
'teacher' => CAP_ALLOW,
|
||||
'editingteacher' => CAP_ALLOW,
|
||||
'coursecreator' => CAP_ALLOW,
|
||||
'admin' => CAP_ALLOW
|
||||
)
|
||||
),
|
||||
|
||||
'mod/glossary:managecategories' => array(
|
||||
|
||||
'captype' => 'write',
|
||||
'contextlevel' => CONTEXT_MODULE,
|
||||
'legacy' => array(
|
||||
'guest' => CAP_PREVENT,
|
||||
'student' => CAP_PREVENT,
|
||||
'teacher' => CAP_ALLOW,
|
||||
'editingteacher' => CAP_ALLOW,
|
||||
'coursecreator' => CAP_ALLOW,
|
||||
'admin' => CAP_ALLOW
|
||||
)
|
||||
),
|
||||
|
||||
'mod/glossary:comment' => array(
|
||||
|
||||
'captype' => 'write',
|
||||
'contextlevel' => CONTEXT_MODULE,
|
||||
'legacy' => array(
|
||||
'guest' => CAP_PREVENT,
|
||||
'student' => CAP_ALLOW,
|
||||
'teacher' => CAP_ALLOW,
|
||||
'editingteacher' => CAP_ALLOW,
|
||||
'coursecreator' => CAP_ALLOW,
|
||||
'admin' => CAP_ALLOW
|
||||
)
|
||||
),
|
||||
|
||||
'mod/glossary:managecomments' => array(
|
||||
|
||||
'captype' => 'write',
|
||||
'contextlevel' => CONTEXT_MODULE,
|
||||
'legacy' => array(
|
||||
'guest' => CAP_PREVENT,
|
||||
'student' => CAP_PREVENT,
|
||||
'teacher' => CAP_ALLOW,
|
||||
'editingteacher' => CAP_ALLOW,
|
||||
'coursecreator' => CAP_ALLOW,
|
||||
'admin' => CAP_ALLOW
|
||||
)
|
||||
),
|
||||
|
||||
'mod/glossary:import' => array(
|
||||
|
||||
'captype' => 'write',
|
||||
'contextlevel' => CONTEXT_MODULE,
|
||||
'legacy' => array(
|
||||
'guest' => CAP_PREVENT,
|
||||
'student' => CAP_PREVENT,
|
||||
'teacher' => CAP_ALLOW,
|
||||
'editingteacher' => CAP_ALLOW,
|
||||
'coursecreator' => CAP_ALLOW,
|
||||
'admin' => CAP_ALLOW
|
||||
)
|
||||
),
|
||||
|
||||
'mod/glossary:export' => array(
|
||||
|
||||
'captype' => 'write',
|
||||
'contextlevel' => CONTEXT_MODULE,
|
||||
'legacy' => array(
|
||||
'guest' => CAP_PREVENT,
|
||||
'student' => CAP_PREVENT,
|
||||
'teacher' => CAP_ALLOW,
|
||||
'editingteacher' => CAP_ALLOW,
|
||||
'coursecreator' => CAP_ALLOW,
|
||||
'admin' => CAP_ALLOW
|
||||
)
|
||||
),
|
||||
|
||||
'mod/glossary:approve' => array(
|
||||
|
||||
'captype' => 'write',
|
||||
'contextlevel' => CONTEXT_MODULE,
|
||||
'legacy' => array(
|
||||
'guest' => CAP_PREVENT,
|
||||
'student' => CAP_PREVENT,
|
||||
'teacher' => CAP_ALLOW,
|
||||
'editingteacher' => CAP_ALLOW,
|
||||
'coursecreator' => CAP_ALLOW,
|
||||
'admin' => CAP_ALLOW
|
||||
)
|
||||
),
|
||||
|
||||
'mod/glossary:rate' => array(
|
||||
|
||||
'captype' => 'write',
|
||||
'contextlevel' => CONTEXT_MODULE,
|
||||
'legacy' => array(
|
||||
'guest' => CAP_PREVENT,
|
||||
'student' => CAP_PREVENT,
|
||||
'teacher' => CAP_ALLOW,
|
||||
'editingteacher' => CAP_ALLOW,
|
||||
'coursecreator' => CAP_ALLOW,
|
||||
'admin' => CAP_ALLOW
|
||||
)
|
||||
),
|
||||
|
||||
'mod/glossary:viewrating' => array(
|
||||
|
||||
'captype' => 'read',
|
||||
'contextlevel' => CONTEXT_MODULE,
|
||||
'legacy' => array(
|
||||
'guest' => CAP_PREVENT,
|
||||
'student' => CAP_PREVENT,
|
||||
'teacher' => CAP_ALLOW,
|
||||
'editingteacher' => CAP_ALLOW,
|
||||
'coursecreator' => CAP_ALLOW,
|
||||
'admin' => CAP_ALLOW
|
||||
)
|
||||
),
|
||||
|
||||
);
|
||||
|
||||
?>
|
|
@ -29,7 +29,8 @@
|
|||
}
|
||||
|
||||
require_login($course->id, false, $cm);
|
||||
|
||||
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
|
||||
|
||||
if (isguest()) {
|
||||
error("Guests are not allowed to edit or delete entries", $_SERVER["HTTP_REFERER"]);
|
||||
}
|
||||
|
@ -38,7 +39,7 @@
|
|||
error("Glossary is incorrect");
|
||||
}
|
||||
|
||||
if (!isteacher($course->id) and !$glossary->studentcanpost ) {
|
||||
if (!has_capability('mod/glossary:manageentries', $context->id) ) {
|
||||
error("You are not allowed to edit or delete entries");
|
||||
}
|
||||
|
||||
|
|
|
@ -16,6 +16,8 @@ if (! $cm = get_record("course_modules", "id", $id)) {
|
|||
error("Course Module ID was incorrect");
|
||||
}
|
||||
|
||||
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
|
||||
|
||||
if (! $course = get_record("course", "id", $cm->course)) {
|
||||
error("Course is misconfigured");
|
||||
}
|
||||
|
@ -36,7 +38,7 @@ if ($CFG->dbtype == 'postgres7' ) {
|
|||
$lcase = 'lcase';
|
||||
}
|
||||
|
||||
if (!$glossary->studentcanpost && !isteacher($glossary->course)) {
|
||||
if (!$glossary->studentcanpost && !has_capability('mod/glossary:manageentries', $context->id)) {
|
||||
error("You can't add/edit entries to this glossary!");
|
||||
}
|
||||
if ( $confirm ) {
|
||||
|
@ -65,7 +67,7 @@ if ( $confirm ) {
|
|||
$newentry->timemodified = $timenow;
|
||||
$newentry->approved = 0;
|
||||
$newentry->aliases = "";
|
||||
if ( $glossary->defaultapproval or isteacher($course->id) ) {
|
||||
if ( $glossary->defaultapproval or has_capability('mod/glossary:approve', $context->id) ) {
|
||||
$newentry->approved = 1;
|
||||
}
|
||||
|
||||
|
@ -119,7 +121,7 @@ if ( $confirm ) {
|
|||
//Perhaps too much security? Anyway thanks to skodak (Bug 1823)
|
||||
$old = get_record('glossary_entries', 'id', $e);
|
||||
$ineditperiod = ((time() - $old->timecreated < $CFG->maxeditingtime) || $glossary->editalways);
|
||||
if ( (!$ineditperiod || $USER->id != $old->userid) and !isteacher($course->id) and $e) {
|
||||
if ( (!$ineditperiod || $USER->id != $old->userid) and !has_capability('mod/glossary:manageentries', $context->id) and $e) {
|
||||
if ( $USER->id != $old->userid ) {
|
||||
error("You can't edit other people's entries!");
|
||||
} elseif (!$ineditperiod) {
|
||||
|
@ -164,11 +166,11 @@ if ( $confirm ) {
|
|||
error("Could not update this glossary entry because this concept already exist.");
|
||||
}
|
||||
} else {
|
||||
|
||||
|
||||
$newentry->userid = $USER->id;
|
||||
$newentry->timecreated = $timenow;
|
||||
$newentry->sourceglossaryid = 0;
|
||||
$newentry->teacherentry = isteacher($course->id);
|
||||
$newentry->teacherentry = has_capability('mod/glossary:manageentries', $context->id);
|
||||
|
||||
$permissiongranted = 1;
|
||||
if ( !$glossary->allowduplicatedentries ) {
|
||||
|
@ -235,7 +237,7 @@ if ( $confirm ) {
|
|||
$newentry->definition = $form->definition;
|
||||
$newentry->format = $form->format;
|
||||
$newentry->timemodified = time();
|
||||
$newentry->approved = $glossary->defaultapproval or isteacher($course->id);
|
||||
$newentry->approved = $glossary->defaultapproval or has_capability('mod/glossary:approve', context->id);
|
||||
$newentry->usedynalink = $form->usedynalink;
|
||||
$newentry->casesensitive = $form->casesensitive;
|
||||
$newentry->fullmatch = $form->fullmatch;
|
||||
|
@ -306,7 +308,7 @@ print_header_simple(format_string($glossary->name), "",
|
|||
"", true, "", navmenu($course, $cm));
|
||||
|
||||
$ineditperiod = ((time() - $newentry->timecreated < $CFG->maxeditingtime) || $glossary->editalways);
|
||||
if ( (!$ineditperiod || $USER->id != $newentry->userid) and !isteacher($course->id) and $e) {
|
||||
if ( (!$ineditperiod || $USER->id != $newentry->userid) and !has_capability('mod/glossary:manageentries', $context->id) and $e) {
|
||||
if ( $USER->id != $newentry->userid ) {
|
||||
error("You can't edit other people's entries!");
|
||||
} elseif (!$ineditperiod) {
|
||||
|
@ -329,6 +331,10 @@ if ( (!$ineditperiod || $USER->id != $newentry->userid) and !isteacher($course-
|
|||
$tab = GLOSSARY_ADDENTRY_VIEW;
|
||||
include("tabs.html");
|
||||
|
||||
if (!$e) {
|
||||
has_capability('glossary_write', $context->id, true);
|
||||
}
|
||||
|
||||
include("edit.html");
|
||||
|
||||
echo '</center>';
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
if (! $cm = get_record("course_modules", "id", $id)) {
|
||||
error("Course Module ID was incorrect");
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (! $course = get_record("course", "id", $cm->course)) {
|
||||
error("Course is misconfigured");
|
||||
|
@ -41,9 +43,8 @@
|
|||
|
||||
require_login($course->id, false);
|
||||
|
||||
if ( !isteacher($course->id) ) {
|
||||
error("You must be a teacher to use this page.");
|
||||
}
|
||||
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
|
||||
has_capability('mod/glossary:managecategories', $context->id, true);
|
||||
|
||||
$strglossaries = get_string("modulenameplural", "glossary");
|
||||
$strglossary = get_string("modulename", "glossary");
|
||||
|
|
|
@ -22,10 +22,10 @@
|
|||
error("Course module is incorrect");
|
||||
}
|
||||
|
||||
require_login($course->id, false);
|
||||
if (!isteacher($course->id)) {
|
||||
error("You must be a teacher to use this page.");
|
||||
}
|
||||
require_login($course->id, false);
|
||||
|
||||
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
|
||||
has_capability('mod/glossary:export', $context->id, true);
|
||||
|
||||
$strglossaries = get_string("modulenameplural", "glossary");
|
||||
$strglossary = get_string("modulename", "glossary");
|
||||
|
|
|
@ -29,10 +29,8 @@
|
|||
$lcase = 'lcase';
|
||||
}
|
||||
|
||||
if ( !isteacher($cm->course) ) {
|
||||
$PermissionGranted = 0;
|
||||
error('You must be a teacher to use this page.');
|
||||
}
|
||||
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
|
||||
has_capability('mod/glossary:export', $context->id, true);
|
||||
|
||||
if (! $course = get_record('course', 'id', $cm->course)) {
|
||||
error('Course is misconfigured');
|
||||
|
|
|
@ -21,10 +21,10 @@
|
|||
}
|
||||
|
||||
require_login($course->id, false);
|
||||
if (!isteacher($course->id)) {
|
||||
error("You must be a teacher to use this page.");
|
||||
}
|
||||
|
||||
|
||||
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
|
||||
has_capability('mod/glossary:export', $context->id, true);
|
||||
|
||||
$filename = clean_filename(strip_tags(format_string($glossary->name,true)).'.xml');
|
||||
$content = glossary_generate_export_file($glossary,$l,$cat);
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
if (! $cm = get_record("course_modules", "id", $id)) {
|
||||
error("Course Module ID was incorrect");
|
||||
}
|
||||
|
||||
|
||||
if (! $course = get_record("course", "id", $cm->course)) {
|
||||
error("Course is misconfigured");
|
||||
}
|
||||
|
@ -27,10 +27,10 @@
|
|||
error("Course module is incorrect");
|
||||
}
|
||||
|
||||
require_login($course->id, false);
|
||||
if (!isteacher($course->id)) {
|
||||
error("You must be a teacher to use this page.");
|
||||
}
|
||||
require_login($course->id, false);
|
||||
|
||||
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
|
||||
has_capability('mod/glossary:import', $context->id, true);
|
||||
|
||||
if ($dest != 'new' and $dest != 'current') {
|
||||
$dest = 'current';
|
||||
|
|
|
@ -738,10 +738,11 @@ function glossary_print_entry_aliases($course, $cm, $glossary, $entry,$mode='',
|
|||
|
||||
function glossary_print_entry_icons($course, $cm, $glossary, $entry, $mode='',$hook='', $type = 'print') {
|
||||
global $USER, $CFG;
|
||||
|
||||
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
|
||||
|
||||
$output = false; //To decide if we must really return text in "return". Activate when needed only!
|
||||
$importedentry = ($entry->sourceglossaryid == $glossary->id);
|
||||
$isteacher = isteacher($course->id);
|
||||
$ismainglossary = $glossary->mainglossary;
|
||||
|
||||
|
||||
|
@ -752,16 +753,16 @@ function glossary_print_entry_icons($course, $cm, $glossary, $entry, $mode='',$h
|
|||
}
|
||||
$return .= glossary_print_entry_commentslink($course, $cm, $glossary, $entry,$mode,$hook,'html');
|
||||
|
||||
if ( (!empty($USER->id) && $glossary->allowcomments && !isguest()) || $isteacher) {
|
||||
$output = true;
|
||||
if (has_capability('mod/glossary:comment', $context->id)) {
|
||||
$output = true;
|
||||
$return .= ' <a title="' . get_string('addcomment','glossary') . '" href="comment.php?id='.$cm->id.'&eid='.$entry->id.'"><img src="comment.gif" height="11" width="11" border="0" alt="'.get_string('addcomment','glossary').'" /></a>';
|
||||
}
|
||||
|
||||
|
||||
if ($isteacher or (!empty($USER->id) and $glossary->studentcanpost and $entry->userid == $USER->id)) {
|
||||
if (has_capability('mod/glossary:write', $context->id) or (!empty($USER->id) and $glossary->studentcanpost and $entry->userid == $USER->id)) {
|
||||
// only teachers can export entries so check it out
|
||||
if ($isteacher and !$ismainglossary and !$importedentry) {
|
||||
$mainglossary = get_record('glossary','mainglossary',1,'course',$course->id);
|
||||
if (has_capability('mod/glossary:export', $context->id) and !$ismainglossary and !$importedentry) {
|
||||
$mainglossary = get_record('glossary','mainglossary',1,'course',$course->id);
|
||||
if ( $mainglossary ) { // if there is a main glossary defined, allow to export the current entry
|
||||
$output = true;
|
||||
$return .= ' <a title="'.get_string('exporttomainglossary','glossary') . '" href="exportentry.php?id='.$cm->id.'&entry='.$entry->id.'&mode='.$mode.'&hook='.$hook.'"><img src="export.gif" height="11" width="11" border="0" alt="'.get_string('exporttomainglossary','glossary').'" /></a>';
|
||||
|
@ -778,7 +779,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 ($isteacher or ($entry->userid == $USER->id and $ineditperiod))) {
|
||||
if ( !$importedentry and (has_capability('mod/glossary:manageentries', $context->id) or ($entry->userid == $USER->id and $ineditperiod))) {
|
||||
$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;
|
||||
|
@ -1301,13 +1302,16 @@ function glossary_print_author_menu($cm, $glossary,$mode, $hook, $sortkey = '',
|
|||
}
|
||||
|
||||
function glossary_print_categories_menu($cm, $glossary, $hook, $category) {
|
||||
global $CFG;
|
||||
|
||||
global $CFG;
|
||||
|
||||
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
|
||||
|
||||
echo '<table border="0" width="100%">';
|
||||
echo '<tr>';
|
||||
|
||||
echo '<td align="center" width="20%">';
|
||||
if ( isteacher($glossary->course) ) {
|
||||
if (has_capability('mod/glossary:managecategories', $context->id)) {
|
||||
$options['id'] = $cm->id;
|
||||
$options['mode'] = 'cat';
|
||||
$options['hook'] = $hook;
|
||||
|
@ -1507,6 +1511,8 @@ function glossary_sort_entries ( $entry0, $entry1 ) {
|
|||
|
||||
function glossary_print_comment($course, $cm, $glossary, $entry, $comment) {
|
||||
global $CFG, $USER;
|
||||
|
||||
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
|
||||
|
||||
$user = get_record('user', 'id', $comment->userid);
|
||||
$strby = get_string('writtenby','glossary');
|
||||
|
@ -1536,11 +1542,11 @@ function glossary_print_comment($course, $cm, $glossary, $entry, $comment) {
|
|||
echo '<div class="icons commands">';
|
||||
|
||||
$ineditperiod = ((time() - $comment->timemodified < $CFG->maxeditingtime) || $glossary->editalways);
|
||||
if ( ($glossary->allowcomments && $ineditperiod && $USER->id == $comment->userid) || isteacher($course->id) ) {
|
||||
if ( ($glossary->allowcomments && $ineditperiod && $USER->id == $comment->userid) || has_capability('mod/glossary:managecomments', $context->id)) {
|
||||
echo "<a href=\"comment.php?id=$cm->id&eid=$entry->id&cid=$comment->id&action=edit\"><img
|
||||
alt=\"" . get_string("edit") . "\" src=\"$CFG->pixpath/t/edit.gif\" height=\"11\" width=\"11\" border=\"0\" /></a> ";
|
||||
}
|
||||
if ( ($glossary->allowcomments && $USER->id == $comment->userid) || isteacher($course->id) ) {
|
||||
if ( ($glossary->allowcomments && $USER->id == $comment->userid) || has_capability('mod/glossary:managecomments', $context->id) ) {
|
||||
echo "<a href=\"comment.php?id=$cm->id&eid=$entry->id&cid=$comment->id&action=delete\"><img
|
||||
alt=\"" . get_string("delete") . "\" src=\"$CFG->pixpath/t/delete.gif\" height=\"11\" width=\"11\" border=\"0\" /></a>";
|
||||
}
|
||||
|
@ -1552,7 +1558,14 @@ function glossary_print_comment($course, $cm, $glossary, $entry, $comment) {
|
|||
|
||||
function glossary_print_entry_ratings($course, $entry, $ratings = NULL) {
|
||||
|
||||
global $USER;
|
||||
global $USER, $CFG;
|
||||
|
||||
$glossary = get_record('glossary', 'id', $entry->glossaryid);
|
||||
$glossarymod = get_record('modules','name','glossary');
|
||||
$cm = get_record_sql("select * from {$CFG->prefix}course_modules where course = $course->id
|
||||
and module = $glossarymod->id and instance = $glossary->id");
|
||||
|
||||
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
|
||||
|
||||
$ratingsmenuused = false;
|
||||
if (!empty($ratings) and !empty($USER->id)) {
|
||||
|
@ -1563,7 +1576,7 @@ function glossary_print_entry_ratings($course, $entry, $ratings = NULL) {
|
|||
}
|
||||
}
|
||||
if ($useratings) {
|
||||
if (isteacher($course->id)) {
|
||||
if (has_capability('mod/glossary:viewrating', $context->id)) {
|
||||
glossary_print_ratings_mean($entry->id, $ratings->scale);
|
||||
if ($USER->id != $entry->userid) {
|
||||
glossary_print_rating_menu($entry->id, $USER->id, $ratings->scale);
|
||||
|
|
|
@ -18,8 +18,12 @@
|
|||
if (! $course = get_record("course", "id", $glossary->course)) {
|
||||
error("Course ID was incorrect");
|
||||
}
|
||||
|
||||
if (!isteacher($course->id) and $USER->id != $entry->userid) {
|
||||
|
||||
$module = get_record("modules","name","glossary");
|
||||
$cm = get_record("course_modules","module",$module->id,"instance",$entry->glossaryid);
|
||||
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
|
||||
|
||||
if (!has_capability('mod/glossary:manageentries', $context->id) and $USER->id != $entry->userid) {
|
||||
error("You can only look at results for your own entries");
|
||||
}
|
||||
|
||||
|
@ -50,7 +54,7 @@
|
|||
echo "<th width=\"100%\" class=\"header\"><a href=\"report.php?id=$entry->id&sort=rating\">$strrating</a></th>";
|
||||
echo "<th class=\"header\"><a href=\"report.php?id=$entry->id&sort=time\">$strtime</a></th>";
|
||||
foreach ($ratings as $rating) {
|
||||
if (isteacher($glossary->course, $rating->id)) {
|
||||
if (has_capability('mod/glossary:manageentries', $context->id)) {
|
||||
echo '<tr class="teacher">';
|
||||
} else {
|
||||
echo '<tr>';
|
||||
|
|
|
@ -16,20 +16,19 @@
|
|||
$data[GLOSSARY_CATEGORY_VIEW]->caption = get_string("categoryview", "glossary");
|
||||
$data[GLOSSARY_DATE_VIEW]->caption = get_string("dateview", "glossary");
|
||||
$data[GLOSSARY_AUTHOR_VIEW]->caption = get_string("authorview","glossary");
|
||||
if (!isguest()) {
|
||||
if ( isteacher($course->id) or $glossary->studentcanpost ) {
|
||||
$data[GLOSSARY_ADDENTRY_VIEW]->caption = get_string("addentry", "glossary");
|
||||
$data[GLOSSARY_ADDENTRY_VIEW]->link = "edit.php?id=$cm->id";
|
||||
}
|
||||
|
||||
if (has_capability('mod/glossary:write', $context->id)) {
|
||||
$data[GLOSSARY_ADDENTRY_VIEW]->caption = get_string("addentry", "glossary");
|
||||
$data[GLOSSARY_ADDENTRY_VIEW]->link = "edit.php?id=$cm->id";
|
||||
}
|
||||
|
||||
if ( isteacher($course->id) ) {
|
||||
if (has_capability('mod/glossary:import', $context->id)) {
|
||||
$data[GLOSSARY_IMPORT_VIEW]->caption = get_string("importentries", "glossary");
|
||||
$data[GLOSSARY_EXPORT_VIEW]->caption = get_string("exportentries", "glossary");
|
||||
|
||||
$data[GLOSSARY_IMPORT_VIEW]->link = "import.php?id=$cm->id";
|
||||
$data[GLOSSARY_IMPORT_VIEW]->link = "import.php?id=$cm->id";
|
||||
}
|
||||
|
||||
if (has_capability('mod/glossary:export', $context->id)) {
|
||||
$data[GLOSSARY_EXPORT_VIEW]->caption = get_string("exportentries", "glossary");
|
||||
$data[GLOSSARY_EXPORT_VIEW]->link = "export.php?id=$cm->id&mode=$mode&hook=$hook";
|
||||
|
||||
}
|
||||
|
||||
// $data[GLOSSARY_DATE_VIEW]->link = "view.php?id=$id&tab=".GLOSSARY_DATE_VIEW;
|
||||
|
@ -40,9 +39,8 @@
|
|||
$data[GLOSSARY_CATEGORY_VIEW]->link = "view.php?id=$id&mode=cat";
|
||||
$data[GLOSSARY_AUTHOR_VIEW]->link = "view.php?id=$id&mode=author";
|
||||
|
||||
|
||||
if (isteacher($course->id)) {
|
||||
$data[GLOSSARY_APPROVAL_VIEW]->caption = get_string("waitingapproval", "glossary");
|
||||
if (has_capability('mod/glossary:approve', $context->id)) {
|
||||
$data[GLOSSARY_APPROVAL_VIEW]->caption = get_string("waitingapproval", "glossary");
|
||||
$data[GLOSSARY_APPROVAL_VIEW]->link = "";
|
||||
|
||||
$hiddenentries = get_records_select("glossary_entries","glossaryid = $glossary->id and approved = 0");
|
||||
|
|
|
@ -5,10 +5,8 @@
|
|||
/// This fragment is called by moodle_needs_upgrading() and /admin/index.php
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
$module->version = 2005041900;
|
||||
$module->version = 2006080800;
|
||||
$module->requires = 2005031000; // Requires this Moodle version
|
||||
$module->cron = 0; // Period for cron to check this module (secs)
|
||||
|
||||
$release = "1.5 development"; // User-friendly version number
|
||||
|
||||
?>
|
||||
|
|
|
@ -44,6 +44,9 @@
|
|||
error("Must specify glossary ID or course module ID");
|
||||
}
|
||||
|
||||
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
|
||||
has_capability('mod/glossary:view', $context->id, true); // kill the page if user can't even read
|
||||
|
||||
if ($CFG->forcelogin) {
|
||||
require_login();
|
||||
}
|
||||
|
@ -320,7 +323,7 @@
|
|||
$ratings->assesstimestart = $glossary->assesstimestart;
|
||||
$ratings->assesstimefinish = $glossary->assesstimefinish;
|
||||
}
|
||||
if ($glossary->assessed == 2 and !isteacher($course->id)) {
|
||||
if ($glossary->assessed == 2 and !has_capability('mod/glossary:rate', $context->id)) {
|
||||
$ratings->allow = false;
|
||||
} else {
|
||||
$ratings->allow = true;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue