mirror of
https://github.com/moodle/moodle.git
synced 2025-08-07 09:56:38 +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
79
mod/assignment/db/access.php
Normal file
79
mod/assignment/db/access.php
Normal file
|
@ -0,0 +1,79 @@
|
|||
<?php
|
||||
//
|
||||
// Capability definitions for the assignment 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_assignment_capabilities = array(
|
||||
|
||||
'mod/assignment: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/assignment:submit' => 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/assignment:grade' => 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
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
?>
|
|
@ -106,8 +106,11 @@ class assignment_base {
|
|||
* This in turn calls the methods producing individual parts of the page
|
||||
*/
|
||||
function view() {
|
||||
|
||||
add_to_log($this->course->id, "assignment", "view", "view.php?id={$this->cm->id}",
|
||||
|
||||
$context = get_context_instance(CONTEXT_MODULE,$this->cm->id);
|
||||
has_capability('mod/assignment:view', $context->id, true);
|
||||
|
||||
add_to_log($this->course->id, "assignment", "view", "view.php?id={$this->cm->id}",
|
||||
$this->assignment->id, $this->cm->id);
|
||||
|
||||
$this->view_header();
|
||||
|
@ -273,9 +276,13 @@ class assignment_base {
|
|||
|
||||
$submitted = '';
|
||||
|
||||
if (isteacher($this->course->id)) {
|
||||
if (!isteacheredit($this->course->id) and (groupmode($this->course, $this->cm) == SEPARATEGROUPS)) {
|
||||
$count = $this->count_real_submissions($this->currentgroup); // Only their group
|
||||
$context = get_context_instance(CONTEXT_MODULE,$this->cm->id);
|
||||
if (has_capability('mod/assignment:grade', $context->id) && (groupmode($this->course, $this->cm) == SEPARATEGROUPS)) {
|
||||
|
||||
// if this user can mark and is put in a group
|
||||
// then he can only see/mark submission in his own groups
|
||||
if (user_group($this->course->id, $USER->id)) {
|
||||
$count = $this->count_real_submissions($this->currentgroup); // Only their groups
|
||||
} else {
|
||||
$count = $this->count_real_submissions(); // Everyone
|
||||
}
|
||||
|
@ -2349,7 +2356,9 @@ function assignment_print_overview($courses, &$htmlarray) {
|
|||
$str .= '<div class="info">'.$strduedateno.'</div>';
|
||||
}
|
||||
|
||||
if (isteacher($assignment->course)) {
|
||||
// if (isteacher($assignment->course)) {
|
||||
$context = get_context_instance(CONTEXT_MODULE,$this->cm->id);
|
||||
if (has_capability('mod/assignment:grade', $context->id)) {
|
||||
$submissions = count_records_sql("SELECT COUNT(*)
|
||||
FROM {$CFG->prefix}assignment_submissions a,
|
||||
{$CFG->prefix}user_students s,
|
||||
|
|
|
@ -13,8 +13,11 @@ class assignment_online extends assignment_base {
|
|||
function view() {
|
||||
|
||||
global $USER;
|
||||
|
||||
$submission = $this->get_submission();
|
||||
|
||||
$context = get_context_instance(CONTEXT_MODULE,$this->cm->id);
|
||||
has_capability('mod/assignment:view', $context->id, true);
|
||||
|
||||
$submission = $this->get_submission();
|
||||
|
||||
//Guest can not submit nor edit an assignment (bug: 4604)
|
||||
if (isguest($USER->id)) {
|
||||
|
@ -56,27 +59,29 @@ class assignment_online extends assignment_base {
|
|||
notify(get_string('submissionsaved', 'assignment'));
|
||||
}
|
||||
|
||||
print_simple_box_start('center', '70%', '', '', 'generalbox', 'online');
|
||||
if ($editmode) {
|
||||
$this->view_edit_form($submission);
|
||||
} else {
|
||||
if ($submission) {
|
||||
echo format_text($submission->data1, $submission->data2);
|
||||
} else if (isguest($USER->id)) { //fix for #4604
|
||||
echo '<center>'. get_string('guestnosubmit', 'assignment').'</center>';
|
||||
} else if ($this->isopen()){ //fix for #4206
|
||||
echo '<center>'.get_string('emptysubmission', 'assignment').'</center>';
|
||||
}
|
||||
if ($editable) {
|
||||
print_single_button('view.php', array('id'=>$this->cm->id,'edit'=>'1'),
|
||||
get_string('editmysubmission', 'assignment'));
|
||||
}
|
||||
}
|
||||
print_simple_box_end();
|
||||
|
||||
if ($editmode and $this->usehtmleditor) {
|
||||
use_html_editor(); // MUst be at the end of the page
|
||||
}
|
||||
if (has_capability('mod/assignment:submit', $context->id)) {
|
||||
print_simple_box_start('center', '70%', '', '', 'generalbox', 'online');
|
||||
if ($editmode) {
|
||||
$this->view_edit_form($submission);
|
||||
} else {
|
||||
if ($submission) {
|
||||
echo format_text($submission->data1, $submission->data2);
|
||||
} else if (isguest($USER->id)) { //fix for #4604
|
||||
echo '<center>'. get_string('guestnosubmit', 'assignment').'</center>';
|
||||
} else if ($this->isopen()){ //fix for #4206
|
||||
echo '<center>'.get_string('emptysubmission', 'assignment').'</center>';
|
||||
}
|
||||
if ($editable) {
|
||||
print_single_button('view.php', array('id'=>$this->cm->id,'edit'=>'1'),
|
||||
get_string('editmysubmission', 'assignment'));
|
||||
}
|
||||
}
|
||||
print_simple_box_end();
|
||||
|
||||
if ($editmode and $this->usehtmleditor) {
|
||||
use_html_editor(); // MUst be at the end of the page
|
||||
}
|
||||
}
|
||||
|
||||
$this->view_feedback();
|
||||
|
||||
|
|
|
@ -45,9 +45,12 @@ class assignment_uploadsingle extends assignment_base {
|
|||
}
|
||||
|
||||
function view() {
|
||||
|
||||
|
||||
global $USER;
|
||||
|
||||
|
||||
$context = get_context_instance(CONTEXT_MODULE,$this->cm->id);
|
||||
has_capability('mod/assignment:view', $context->id, true);
|
||||
|
||||
add_to_log($this->course->id, "assignment", "view", "view.php?id={$this->cm->id}", $this->assignment->id, $this->cm->id);
|
||||
|
||||
$this->view_header();
|
||||
|
@ -66,7 +69,7 @@ class assignment_uploadsingle extends assignment_base {
|
|||
}
|
||||
}
|
||||
|
||||
if (!isguest($USER->id) && $this->isopen() && (!$filecount || $this->assignment->resubmit || !$submission->timemarked)) {
|
||||
if (has_capability('mod/assignment:submit', $context->id) && $this->isopen() && (!$filecount || $this->assignment->resubmit || !$submission->timemarked)) {
|
||||
$this->view_upload_form();
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
// This fragment is called by /admin/index.php
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
$module->version = 2005060100;
|
||||
$module->version = 2006080800;
|
||||
$module->requires = 2005031000; // Requires this Moodle version
|
||||
$module->cron = 60;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue