// are added to them.
$systemcontext = get_context_instance(CONTEXT_SYSTEM);
-if (empty($CFG->rolesactive)) {
- // installation starts - no permission checks
- $hassiteconfig = true;
-} else {
- $hassiteconfig = has_capability('moodle/site:config', $systemcontext);
-}
+$hassiteconfig = has_capability('moodle/site:config', $systemcontext);
$ADMIN->add('root', new admin_externalpage('adminnotifications', get_string('notifications'), "$CFG->wwwroot/$CFG->admin/index.php"));
require_once($CFG->dirroot .'/course/lib.php');
require_once($CFG->dirroot .'/lib/blocklib.php');
- if (empty($SITE)) {
- redirect($CFG->wwwroot .'/'. $CFG->admin .'/index.php');
- }
-
// Bounds for block widths
// more flexible for theme designers taken from theme config.php
$lmin = (empty($THEME->block_l_min_width)) ? 100 : $THEME->block_l_min_width;
define('BLOCK_R_MAX_WIDTH', $rmax);
// check if major upgrade needed - also present in login/index.php
- if ((int)$CFG->version < 2006101100) { //1.7 or older
+ if (empty($CFG->version) or (int)$CFG->version < 2009011400) { //1.9 or older
@require_logout();
redirect("$CFG->wwwroot/$CFG->admin/");
}
- // Trigger 1.9 accesslib upgrade?
- if ((int)$CFG->version < 2007092000
- && isset($USER->id)
- && is_siteadmin($USER->id)) { // this test is expensive, but is only triggered during the upgrade
- redirect("$CFG->wwwroot/$CFG->admin/");
- }
if ($CFG->forcelogin) {
require_login();
user_accesstime_log();
}
- if (!empty($CFG->rolesactive)) { // if already using roles system
- if (has_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM))) {
- if (moodle_needs_upgrading()) {
- redirect($CFG->wwwroot .'/'. $CFG->admin .'/index.php');
- }
- } else if (!empty($CFG->mymoodleredirect)) { // Redirect logged-in users to My Moodle overview if required
- if (isloggedin() && $USER->username != 'guest') {
- redirect($CFG->wwwroot .'/my/index.php');
- }
- }
- } else { // if upgrading from 1.6 or below
- if (is_siteadmin($USER->id) && moodle_needs_upgrading()) {
+ if (has_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM))) {
+ if (moodle_needs_upgrading()) {
redirect($CFG->wwwroot .'/'. $CFG->admin .'/index.php');
}
+ } else if (!empty($CFG->mymoodleredirect)) { // Redirect logged-in users to My Moodle overview if required
+ if (isloggedin() && $USER->username != 'guest') {
+ redirect($CFG->wwwroot .'/my/index.php');
+ }
}
* @return bool
*/
function has_capability($capability, $context, $userid=NULL, $doanything=true) {
- global $USER, $ACCESS, $CFG, $DIRTYCONTEXTS, $DB;
+ global $USER, $ACCESS, $CFG, $DIRTYCONTEXTS, $DB, $SCRIPT;
+
+ if (empty($CFG->rolesactive)) {
+ if ($SCRIPT === "/$CFG->admin/index.php" or $SCRIPT === "/$CFG->admin/cliupgrade.php") {
+ // we are in an installer - roles can not work yet
+ return true;
+ } else {
+ return false;
+ }
+ }
// the original $CONTEXT here was hiding serious errors
// for security reasons do not reuse previous context
global $CFG, $DB;
- // this flag has not been set!
- // (not clean install, or upgraded successfully to 1.7 and up)
- if (empty($CFG->rolesactive)) {
- return false;
- }
-
/* Get in 3 cheap DB queries...
* - role assignments - with role_caps
* - relevant role caps
function load_all_capabilities() {
global $USER, $CFG, $DIRTYCONTEXTS;
+ // roles not installed yet - we are in the middle of installation
if (empty($CFG->rolesactive)) {
return;
}
*/
public function check_access() {
global $CFG;
- if (empty($CFG->rolesactive)) {
- return true; // no access check before site is fully set up
- }
$context = empty($this->context) ? get_context_instance(CONTEXT_SYSTEM) : $this->context;
foreach($this->req_capability as $cap) {
if (is_valid_capability($cap) and has_capability($cap, $context)) {
// see admin_externalpage
public function check_access() {
global $CFG;
- if (empty($CFG->rolesactive)) {
- return true; // no access check before site is fully set up
- }
$context = empty($this->context) ? get_context_instance(CONTEXT_SYSTEM) : $this->context;
foreach($this->req_capability as $cap) {
if (is_valid_capability($cap) and has_capability($cap, $context)) {
/// Is the user able to access this course as a teacher?
global $CFG;
- if (empty($CFG->rolesactive)) { // Teachers are locked out during an upgrade to 1.7
- return false;
- }
-
if ($courseid) {
$context = get_context_instance(CONTEXT_COURSE, $courseid);
} else {
function isteacherinanycourse($userid=0, $includeadmin=true) {
global $USER, $CFG, $DB;
- if (empty($CFG->rolesactive)) { // Teachers are locked out during an upgrade to 1.7
- return false;
- }
-
if (!$userid) {
if (empty($USER->id)) {
return false;
function isguest($userid=0) {
global $CFG;
- if (empty($CFG->rolesactive)) {
- return false;
- }
-
$context = get_context_instance(CONTEXT_SYSTEM);
return has_capability('moodle/legacy:guest', $context, $userid, false);
require_once("../config.php");
// check if major upgrade needed - also present in /index.php
- if ((int)$CFG->version < 2006101100) { //1.7 or older
+ if ((int)$CFG->version < 2009011400) { //1.9 or older
@require_logout();
redirect("$CFG->wwwroot/$CFG->admin/");
}
$session_has_timed_out = false;
}
-// setup and verify auth settings
-
-if (!isset($CFG->registerauth)) {
- set_config('registerauth', '');
-}
-
-if (!isset($CFG->auth_instructions)) {
- set_config('auth_instructions', '');
-}
-
// auth plugins may override these - SSO anyone?
$frm = false;
$user = false;