mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 22:08:20 +01:00
fixed admin defaults, some warnings during install and added trmporary hack to make $CFG->notloggedinroleid work
This commit is contained in:
parent
73254f625a
commit
35a518c5de
@ -96,14 +96,17 @@ $ADMIN->add('userinterface', $temp);
|
||||
|
||||
// "languageandlocation" settingpage
|
||||
$temp = new admin_settingpage('languageandlocation', get_string('languageandlocation', 'admin'));
|
||||
$temp->add(new admin_setting_configselect('lang', get_string('lang', 'admin'), get_string('configlang', 'admin'), (!empty($CFG->unicodedb) ? 'en_utf8' : 'en'), get_list_of_languages()));
|
||||
$temp->add(new admin_setting_configselect('lang', get_string('lang', 'admin'), get_string('configlang', 'admin'), $CFG->lang, get_list_of_languages())); // $CFG->lang might be set in installer already, default en or en_utf8 is in setup.php
|
||||
$temp->add(new admin_setting_configcheckbox('langmenu', get_string('langmenu', 'admin'), get_string('configlangmenu', 'admin'), 1));
|
||||
$temp->add(new admin_setting_configtext('langlist', get_string('langlist', 'admin'), get_string('configlanglist', 'admin'), '', PARAM_NOTAGS));
|
||||
$temp->add(new admin_setting_configcheckbox('langcache', get_string('langcache', 'admin'), get_string('configlangcache', 'admin'), 1));
|
||||
$temp->add(new admin_setting_configtext('locale', get_string('localetext', 'admin'), get_string('configlocale', 'admin'), '', PARAM_FILE));
|
||||
$temp->add(new admin_setting_configselect('timezone', get_string('timezone','admin'), get_string('configtimezone', 'admin'), 99, get_list_of_timezones()));
|
||||
$temp->add(new admin_setting_configselect('country', get_string('country', 'admin'), get_string('configcountry', 'admin'), '', get_list_of_countries()));
|
||||
unset($options);
|
||||
$options = get_list_of_timezones();
|
||||
$options[99] = get_string('serverlocaltime');
|
||||
$temp->add(new admin_setting_configselect('timezone', get_string('timezone','admin'), get_string('configtimezone', 'admin'), 99, $options));
|
||||
$options = get_list_of_timezones();
|
||||
$options[0] = get_string('choose') .'...';
|
||||
$temp->add(new admin_setting_configselect('country', get_string('country', 'admin'), get_string('configcountry', 'admin'), 0, $options));
|
||||
$options = get_list_of_timezones();
|
||||
$options[99] = get_string('timezonenotforced', 'admin');
|
||||
$temp->add(new admin_setting_configselect('forcetimezone', get_string('forcetimezone', 'admin'), get_string('helpforcetimezone', 'admin'), 99, $options));
|
||||
|
@ -400,10 +400,11 @@ class block_base {
|
||||
$errors[] = 'invalid_content_type';
|
||||
$correct = false;
|
||||
}
|
||||
if ($this->get_content() === NULL) {
|
||||
//following selftest was not working when roles&capabilitites were used from block
|
||||
/* if ($this->get_content() === NULL) {
|
||||
$errors[] = 'content_not_set';
|
||||
$correct = false;
|
||||
}
|
||||
}*/
|
||||
if ($this->get_version() === NULL) {
|
||||
$errors[] = 'version_not_set';
|
||||
$correct = false;
|
||||
|
@ -51,8 +51,11 @@ class block_site_main_menu extends block_list {
|
||||
$strcancel= get_string('cancel');
|
||||
$stractivityclipboard = $USER->activitycopyname;
|
||||
}
|
||||
|
||||
$modinfo = unserialize($course->modinfo);
|
||||
if ($course->modinfo !== NULL) {
|
||||
$modinfo = unserialize($course->modinfo);
|
||||
} else {
|
||||
$modinfo = null;
|
||||
}
|
||||
$editbuttons = '';
|
||||
|
||||
if ($ismoving) {
|
||||
|
@ -38,6 +38,12 @@ function load_notloggedin_role() {
|
||||
$sitecontext = get_context_instance(CONTEXT_SYSTEM, SITEID);
|
||||
// load default not logged in role capabilities when user is not logged in
|
||||
|
||||
// HACK ALERT!!!! - replace with proper default value!!!!!
|
||||
if (empty($CFG->notloggedinroleid)) {
|
||||
$guestrole = get_record('role', 'name', 'Guest');
|
||||
$CFG->notloggedinroleid = $guestrole->id;
|
||||
}
|
||||
|
||||
$SQL = "select * from {$CFG->prefix}role_capabilities where roleid=$CFG->notloggedinroleid
|
||||
AND contextid = $sitecontext->id";
|
||||
|
||||
|
@ -1981,9 +1981,12 @@ function isadmin($userid=0) {
|
||||
if (!empty($CFG->rolesactive)) {
|
||||
|
||||
$context = get_context_instance(CONTEXT_SYSTEM, SITEID);
|
||||
|
||||
if (!$userid) {
|
||||
return has_capability('moodle/legacy:admin', $context, $USER->id, false);
|
||||
if (empty($USER->id)) {
|
||||
return false;
|
||||
} else {
|
||||
return has_capability('moodle/legacy:admin', $context, $USER->id, false);
|
||||
}
|
||||
} else {
|
||||
return has_capability('moodle/legacy:admin', $context, false, $userid, false);
|
||||
}
|
||||
@ -2043,10 +2046,13 @@ function isteacher($courseid=0, $userid=0, $includeadmin=true) {
|
||||
}
|
||||
|
||||
if (!$userid) {
|
||||
|
||||
return (has_capability('moodle/legacy:teacher', $context, $USER->id, false)
|
||||
if (empty($USER->id)) {
|
||||
return false;
|
||||
} else {
|
||||
return (has_capability('moodle/legacy:teacher', $context, $USER->id, false)
|
||||
or has_capability('moodle/legacy:editingteacher', $context, $USER->id, false)
|
||||
or has_capability('moodle/legacy:admin', $context, $USER->id, false));
|
||||
}
|
||||
} else {
|
||||
return (has_capability('moodle/legacy:teacher', $context, $userid, false)
|
||||
or has_capability('moodle/legacy:editingteacher', $context, $userid, false)
|
||||
@ -2137,8 +2143,12 @@ function isteacheredit($courseid, $userid=0, $ignorestudentview=false) {
|
||||
}
|
||||
|
||||
if (!$userid) {
|
||||
return (has_capability('moodle/legacy:editingteacher', $context, $USER->id, false)
|
||||
if (empty($USER->id)) {
|
||||
return false;
|
||||
} else {
|
||||
return (has_capability('moodle/legacy:editingteacher', $context, $USER->id, false)
|
||||
or has_capability('moodle/legacy:admin', $context, $USER->id, false));
|
||||
}
|
||||
} else {
|
||||
return (has_capability('moodle/legacy:editingteacher', $context, $userid, false)
|
||||
or has_capability('moodle/legacy:admin', $context, $userid, false));
|
||||
@ -2181,8 +2191,12 @@ function iscreator ($userid=0) {
|
||||
$context = get_context_instance(CONTEXT_SYSTEM, SITEID);
|
||||
|
||||
if (!$userid) {
|
||||
return (has_capability('moodle/legacy:coursecreator', $context, $USER->id, false)
|
||||
if (empty($USER->id)) {
|
||||
return false;
|
||||
} else {
|
||||
return (has_capability('moodle/legacy:coursecreator', $context, $USER->id, false)
|
||||
or has_capability('moodle/legacy:admin', $context, $USER->id, false));
|
||||
}
|
||||
} else {
|
||||
return (has_capability('moodle/legacy:coursecreator', $context, $userid, false)
|
||||
or has_capability('moodle/legacy:admin', $context, $userid, false));
|
||||
@ -2227,7 +2241,11 @@ function isstudent($courseid, $userid=0) {
|
||||
}
|
||||
|
||||
if (!$userid) {
|
||||
return has_capability('moodle/legacy:student', $context, $USER->id, false);
|
||||
if (empty($USER->id)) {
|
||||
return false;
|
||||
} else {
|
||||
return has_capability('moodle/legacy:student', $context, $USER->id, false);
|
||||
}
|
||||
} else {
|
||||
return has_capability('moodle/legacy:student', $context, $userid, false);
|
||||
}
|
||||
|
@ -447,6 +447,9 @@ $CFG->os = PHP_OS;
|
||||
|
||||
$SESSION = &$_SESSION['SESSION']; // Makes them easier to reference
|
||||
$USER = &$_SESSION['USER'];
|
||||
if (!isset($USER->id)) {
|
||||
$USER->id = 0; // to enable proper function of $CFG->notloggedinroleid hack
|
||||
}
|
||||
}
|
||||
else {
|
||||
$SESSION = NULL;
|
||||
|
Loading…
x
Reference in New Issue
Block a user