MDL-16166 centralised enabling of subsystems, fixed some warnings and general cleanup

This commit is contained in:
skodak 2008-08-26 05:45:07 +00:00
parent 3c184e1464
commit 90658eefb0
24 changed files with 84 additions and 48 deletions

View file

@ -16,6 +16,10 @@ require_login($course->id);
// to create notes the current user needs a capability
require_capability('moodle/notes:manage', $context);
if (empty($CFG->enablenotes)) {
print_error('notesdisabled', 'notes');
}
if (!empty($users) && confirm_sesskey()) {
if (count($users) != count($contents) || count($users) != count($states)) {
print_error('invalidformdata', '', $CFG->wwwroot.'/user/index.php?id='.$id);
@ -25,7 +29,7 @@ if (!empty($users) && confirm_sesskey()) {
$note->courseid = $id;
$note->format = FORMAT_PLAIN;
foreach ($users as $k => $v) {
if(!$user = $DB->get_record('user', array('id'=>$v)) || empty($contents[$k])) {
if (!$user = $DB->get_record('user', array('id'=>$v)) || empty($contents[$k])) {
continue;
}
$note->id = 0;

View file

@ -17,6 +17,10 @@ require_login($course->id);
// to create notes the current user needs a capability
require_capability('moodle/notes:manage', $context);
if (empty($CFG->enablenotes)) {
print_error('notesdisabled', 'notes');
}
if (!empty($users) && !empty($content) && confirm_sesskey()) {
$note = new object();
$note->courseid = $id;

View file

@ -858,7 +858,7 @@
echo '<input type="button" onclick="checknone()" value="'.get_string('deselectall').'" /> ';
$displaylist = array();
$displaylist['messageselect.php'] = get_string('messageselectadd');
if (has_capability('moodle/notes:manage', $context) && $context->id != $frontpagectx->id) {
if (!empty($CFG->enablenotes) && has_capability('moodle/notes:manage', $context) && $context->id != $frontpagectx->id) {
$displaylist['addnote.php'] = get_string('addnewnote', 'notes');
$displaylist['groupaddnote.php'] = get_string('groupaddnewnote', 'notes');
}

View file

@ -2,7 +2,7 @@
require_once(dirname(dirname(__FILE__)) . '/config.php');
if (empty($CFG->portfolioenabled)) {
if (empty($CFG->enableportfolios)) {
print_error('disabled', 'portfolio');
}

View file

@ -59,7 +59,7 @@
$toprow[] = new tabobject('blogs', $CFG->wwwroot.'/blog/index.php?filtertype=course&amp;filterselect='.$filterselect, get_string('blogs','blog'));
}
if (has_capability('moodle/notes:manage', $coursecontext) || has_capability('moodle/notes:view', $coursecontext)) {
if (!empty($CFG->enablenotes) and (has_capability('moodle/notes:manage', $coursecontext) || has_capability('moodle/notes:view', $coursecontext))) {
$toprow[] = new tabobject('notes', $CFG->wwwroot.'/notes/index.php?filtertype=course&amp;filterselect=' . $filterselect, get_string('notes', 'notes'));
}
@ -171,7 +171,7 @@
$toprow[] = new tabobject('blogs', $CFG->wwwroot.'/blog/index.php?userid='.$user->id.'&amp;courseid='.$course->id, get_string('blog', 'blog'));
}
if (has_capability('moodle/notes:manage', $coursecontext) || has_capability('moodle/notes:view', $coursecontext)) {
if (!empty($CFG->enablenotes) and (has_capability('moodle/notes:manage', $coursecontext) || has_capability('moodle/notes:view', $coursecontext))) {
$toprow[] = new tabobject('notes', $CFG->wwwroot.'/notes/index.php?course='.$course->id . '&amp;user=' . $user->id, get_string('notes', 'notes'));
}
@ -239,7 +239,7 @@
}
}
if (empty($userindexpage) && $user->id == $USER->id && !empty($CFG->portfolioenabled) && has_capability('moodle/portfolio:export', get_system_context())) {
if (!empty($user) and empty($userindexpage) && $user->id == $USER->id && !empty($CFG->enableportfolios) && has_capability('moodle/portfolio:export', get_system_context())) {
/// Portfolio tab
require_once($CFG->libdir . '/portfoliolib.php');
@ -249,15 +249,16 @@
}
// Repository Tab
if ($user->id == $USER->id) {
if (!empty($user) and $user->id == $USER->id) {
require_once($CFG->dirroot . '/repository/lib.php');
if (repository_instances($COURSE->context, $USER->id)) {
$coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
if (repository_instances($coursecontext, $USER->id)) {
$toprow[] = new tabobject('repositories', $CFG->wwwroot .'/user/repository.php', get_string('repositories', 'repository'));
}
}
/// Messaging tab
if (has_capability('moodle/user:editownmessageprofile', $systemcontext)) {
if (!empty($user) and empty($userindexpage) and has_capability('moodle/user:editownmessageprofile', $systemcontext)) {
$toprow[] = new tabobject('editmessage', $CFG->wwwroot.'/message/edit.php?id='.$user->id.'&amp;course='.$course->id, get_string('editmymessage', 'message'));
}