MDL-7716 In visible groups mode, It is possible to put a database entries in other group that it his

This commit is contained in:
skodak
2006-12-10 20:16:03 +00:00
parent 411f589fa7
commit cca1547e7c
5 changed files with 52 additions and 2 deletions
+5 -1
View File
@@ -180,7 +180,11 @@
redirect($CFG->wwwroot.'/mod/data/view.php?d='.$data->id.'&rid='.$rid);
} else { /// Add some new records
if (!data_user_can_add_entry($data, $currentgroup, $groupmode)) {
error('Can not add entries!');
}
/// Check if maximum number of entry as specified by this database is reached
/// Of course, you can't be stopped if you are an editting teacher! =)
+7
View File
@@ -78,6 +78,13 @@
print_header_simple($data->name, "", "<a href='index.php?id=$course->id'>$strdata</a> -> $data->name", "", "", true, "", navmenu($course));
print_heading(format_string($data->name));
/// Groups needed for Add entry tab
if ($groupmode = groupmode($course, $cm)) { // Groups are being used
$currentgroup = get_and_set_current_group($course, $groupmode);
} else {
$currentgroup = 0;
}
/// Print the tabs
$currenttab = 'add';
include('tabs.php');
+32
View File
@@ -1415,6 +1415,13 @@ function data_print_header($course, $cm, $data, $currenttab='') {
print_heading(format_string($data->name));
/// Groups needed for Add entry tab
if ($groupmode = groupmode($course, $cm)) { // Groups are being used
$currentgroup = get_and_set_current_group($course, $groupmode);
} else {
$currentgroup = 0;
}
/// Print the tabs
if ($currenttab) {
@@ -1430,4 +1437,29 @@ function data_print_header($course, $cm, $data, $currenttab='') {
}
}
function data_user_can_add_entry($data, $currentgroup=false, $groupmode='') {
global $USER;
if (!$cm = get_coursemodule_from_instance('data', $data->id)) {
error('Course Module ID was incorrect');
}
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
if (!has_capability('mod/data:writeentry', $context) and !has_capability('mod/data:manageentries',$context)) {
return false;
}
if ($currentgroup) {
return (has_capability('moodle/site:accessallgroups', $context) or ismember($currentgroup));
} else {
//else it might be group 0 in visible mode
if ($groupmode == VISIBLEGROUPS){
return (ismember($currentgroup));
} else {
return true;
}
}
}
?>
+1 -1
View File
@@ -43,7 +43,7 @@
}
if (isloggedin()) {
if (has_capability('mod/data:writeentry', $context)) { // took out participation list here!
if (data_user_can_add_entry($data, $currentgroup, $groupmode)) { // took out participation list here!
$addstring = empty($editentry) ? get_string('add', 'data') : get_string('editentry', 'data');
$row[] = new tabobject('add', $CFG->wwwroot.'/mod/data/edit.php?d='.$data->id, $addstring, '', true);
}
+7
View File
@@ -84,6 +84,13 @@
print_heading(format_string($data->name));
/// Groups needed for Add entry tab
if ($groupmode = groupmode($course, $cm)) { // Groups are being used
$currentgroup = get_and_set_current_group($course, $groupmode);
} else {
$currentgroup = 0;
}
/// Print the tabs.
$currenttab = 'templates';
include('tabs.php');