define('PARAM_INTEGER', 0x0002);
/**
- * PARAM_NUMBER - a real/floating point number.
+ * PARAM_NUMBER - a real/floating point number.
*/
define('PARAM_NUMBER', 0x000a);
if (empty($plugin)) {
return delete_records('config', 'name', $name);
- } else {
+ } else {
return delete_records('config_plugins', 'name', $name, 'plugin', $plugin);
}
}
/// Redefine global $COURSE if needed
if (empty($courseorid)) {
// no change in global $COURSE - for backwards compatibiltiy
- // if require_rogin() used after require_login($courseid);
+ // if require_rogin() used after require_login($courseid);
} else if (is_object($courseorid)) {
$COURSE = clone($courseorid);
} else {
if ($USER->loginascontext->contextlevel == CONTEXT_COURSE) {
if ($USER->loginascontext->instanceid != $COURSE->id) {
print_error('loginasonecourse', '', $CFG->wwwroot.'/course/view.php?id='.$USER->loginascontext->instanceid);
- }
+ }
}
}
if ($COURSE->id == SITEID) {
/// We can eliminate hidden site activities straight away
- if (!empty($cm) && !$cm->visible and !has_capability('moodle/course:viewhiddenactivities',
+ if (!empty($cm) && !$cm->visible and !has_capability('moodle/course:viewhiddenactivities',
get_context_instance(CONTEXT_SYSTEM, SITEID))) {
redirect($CFG->wwwroot, get_string('activityiscurrentlyhidden'));
}
return;
- } else {
+ } else {
/// Check if the user can be in a particular course
if (!$context = get_context_instance(CONTEXT_COURSE, $COURSE->id)) {
print_error('nocontext');
!has_capability('moodle/course:viewhiddencourses', get_context_instance(CONTEXT_COURSE, $COURSE->id)) ){
print_header_simple();
notice(get_string('coursehidden'), $CFG->wwwroot .'/');
- }
-
+ }
+
/// Non-guests who don't currently have access, check if they can be allowed in as a guest
if ($USER->username != 'guest' and !has_capability('moodle/course:view', $context)) {
if (has_capability('moodle/legacy:guest', $context, NULL, false)) {
switch ($COURSE->guest) { /// Check course policy about guest access
- case 1: /// Guests always allowed
+ case 1: /// Guests always allowed
if (!has_capability('moodle/course:view', $context)) { // Prohibited by capability
print_header_simple();
notice(get_string('guestsnotallowed', '', format_string($COURSE->fullname)), "$CFG->wwwroot/login/index.php");
}
if (!empty($cm) and !$cm->visible) { // Not allowed to see module, send to course page
- redirect($CFG->wwwroot.'/course/view.php?id='.$cm->course,
+ redirect($CFG->wwwroot.'/course/view.php?id='.$cm->course,
get_string('activityiscurrentlyhidden'));
}
break;
- case 2: /// Guests allowed with key
+ case 2: /// Guests allowed with key
if (!empty($USER->enrolkey[$COURSE->id])) { // Set by enrol/manual/enrol.php
return true;
}
/// Make sure they can read this activity too, if specified
- if (!empty($cm) and !$cm->visible and !has_capability('moodle/course:viewhiddenactivities', $context)) {
+ if (!empty($cm) and !$cm->visible and !has_capability('moodle/course:viewhiddenactivities', $context)) {
redirect($CFG->wwwroot.'/course/view.php?id='.$cm->course, get_string('activityiscurrentlyhidden'));
}
return; // User is allowed to see this course
/**
* Goes through all enrolment records for the courses inside the metacourse and sync with them.
- *
+ *
* @param mixed $course the metacourse to synch. Either the course object itself, or the courseid.
*/
function sync_metacourse($course) {
return false; // invalid course id
}
}
-
+
// Check that we actually have a metacourse.
if (empty($course->metacourse)) {
return false;
// Get a list of roles that should not be synced.
if (!empty($CFG->nonmetacoursesyncroleids)) {
$roleexclusions = 'ra.roleid NOT IN (' . $CFG->nonmetacoursesyncroleids . ') AND';
- } else {
+ } else {
$roleexclusions = '';
}
}
return $success;
-
+
// TODO: finish timeend and timestart
// maybe we could rely on cron job to do the cleaning from time to time
}
if (empty($user->editing)) {
return false;
}
-
+
$capcheck = false;
$coursecontext = get_context_instance(CONTEXT_COURSE, $courseid);
-
+
if (has_capability('moodle/course:manageactivities', $coursecontext) ||
has_capability('moodle/site:manageblocks', $coursecontext)) {
- $capcheck = true;
+ $capcheck = true;
} else {
- // loop through all child context, see if user has moodle/course:manageactivities or moodle/site:manageblocks
+ // loop through all child context, see if user has moodle/course:manageactivities or moodle/site:manageblocks
if ($children = get_child_contexts($coursecontext)) {
foreach ($children as $child) {
$childcontext = get_record('context', 'id', $child);
has_capability('moodle/site:manageblocks', $childcontext)) {
$capcheck = true;
break;
- }
- }
+ }
+ }
}
}
-
+
return ($user->editing && $capcheck);
//return ($user->editing and has_capability('moodle/course:manageactivities', get_context_instance(CONTEXT_COURSE, $courseid)));
}
*/
function exists_auth_plugin($auth) {
global $CFG;
-
+
if (file_exists("{$CFG->dirroot}/auth/$auth/auth.php")) {
return is_readable("{$CFG->dirroot}/auth/$auth/auth.php");
}
/**
* Checks if a given plugin is in the list of enabled authentication plugins.
- *
+ *
* @param string $auth Authentication plugin.
* @return boolean Whether the plugin is enabled.
*/
*/
function get_auth_plugin($auth) {
global $CFG;
-
+
// check the plugin exists first
if (! exists_auth_plugin($auth)) {
error("Authentication plugin '$auth' not found.");
}
-
+
// return auth plugin instance
require_once "{$CFG->dirroot}/auth/$auth/auth.php";
$class = "auth_plugin_$auth";
$newuser->auth = $auth;
$newuser->username = $username;
-
+
// fix for MDL-8480
// user CFG lang for user if $newuser->lang is empty
// or $user->lang is not an installed language
$sitelangs = array_keys(get_list_of_languages());
if (empty($newuser->lang) || !in_array($newuser->lang, $sitelangs)) {
$newuser -> lang = $CFG->lang;
- }
+ }
$newuser->confirmed = 1;
$newuser->lastip = getremoteaddr();
$newuser->timemodified = time();
return $user;
- }
-
+ }
+
// failed if all the plugins have failed
add_to_log(0, 'login', 'error', 'index.php', $username);
error_log('[client '.$_SERVER['REMOTE_ADDR']."] $CFG->wwwroot Failed Login: $username ".$_SERVER['HTTP_USER_AGENT']);
/**
* Compare password against hash stored in internal user table.
* If necessary it also updates the stored hash to new format.
- *
+ *
* @param object user
* @param string plain text password
* @return bool is password valid?
/**
* Calculate hashed value from password using current hash mechanism.
- *
+ *
* @param string password
* @return string password hash
*/
/**
* Update pssword hash in user object.
- *
+ *
* @param object user
* @param string plain text password
* @param bool store changes also in db, default true
if (is_null($mnethostid)) {
// if null, we restrict to local users
// ** testing for local user can be done with
- // mnethostid = $CFG->mnet_localhost_id
+ // mnethostid = $CFG->mnet_localhost_id
// or with
- // auth != 'mnet'
+ // auth != 'mnet'
// but the first one is FAST with our indexes
$mnethostid = $CFG->mnet_localhost_id;
}
/// Delete course blocks
- if ($blocks = get_records_sql("SELECT *
+ if ($blocks = get_records_sql("SELECT *
FROM {$CFG->prefix}block_instance
WHERE pagetype = '".PAGE_COURSE_VIEW."'
AND pageid = $course->id")) {
if ($showfeedback) {
notify($strdeleted .' block_instance');
}
-
+
require_once($CFG->libdir.'/blocklib.php');
foreach ($blocks as $block) { /// Delete any associated contexts for this block
-
+
// Block instances are rarely created. Since the block instance is gone from the above delete
// statement, calling delete_context() will generate a warning as get_context_instance could
- // no longer create the context as the block is already gone.
+ // no longer create the context as the block is already gone.
if (record_exists('context', 'contextlevel', CONTEXT_BLOCK, 'instanceid', $block->id)) {
delete_context(CONTEXT_BLOCK, $block->id);
}
-
- // fix for MDL-7164
+
+ // fix for MDL-7164
// Get the block object and call instance_delete()
if (!$record = blocks_get_record($block->blockid)) {
$result = false;
}
/// Delete any associated context for this group ??
delete_context(CONTEXT_GROUP, $groupid);
-
+
if (groups_delete_group($groupid)) {
if ($showfeedback) {
notify($strdeleted .' groups');
if ($courseid != SITEID) {
delete_context(CONTEXT_COURSE, $course->id);
}
-
+
// fix for MDL-9016
// clear the cache because the course context is deleted, and
// we don't want to write assignment, overrides and context_rel table
} else if (!empty($SESSION->lang)) { // Session language can override other settings
$return = $SESSION->lang;
- } else if (!empty($USER->lang)) {
+ } else if (!empty($USER->lang)) {
$return = $USER->lang;
} else {
}
}
-/**
- * @return array places to look for lang strings based on the prefix to the
- * module name. For example qtype_ in question/type. Used by get_string and
+/**
+ * @return array places to look for lang strings based on the prefix to the
+ * module name. For example qtype_ in question/type. Used by get_string and
* help.php.
*/
function places_to_search_for_lang_strings() {
global $CFG;
/// originally these special strings were stored in moodle.php now we are only in langconfig.php
- $langconfigstrs = array('alphabet', 'backupnameformat', 'firstdayofweek', 'locale',
+ $langconfigstrs = array('alphabet', 'backupnameformat', 'firstdayofweek', 'locale',
'localewin', 'localewincharset', 'oldcharset',
'parentlanguage', 'strftimedate', 'strftimedateshort', 'strftimedatetime',
'strftimedaydate', 'strftimedaydatetime', 'strftimedayshort', 'strftimedaytime',
$rules = places_to_search_for_lang_strings();
$exceptions = $rules['__exceptions'];
unset($rules['__exceptions']);
-
+
if (!in_array($module, $exceptions)) {
$dividerpos = strpos($module, '_');
if ($dividerpos === false) {
break;
case 'Opera': /// Opera
-
+
if (preg_match("/Opera\/([0-9\.]+)/i", $agent, $match)) {
if (version_compare($match[1], $version) >= 0) {
return true;
}
}
break;
-
+
case 'Safari': /// Safari
// Look for AppleWebKit, excluding strings with OmniWeb, Shiira and SimbianOS
if (strpos($agent, 'OmniWeb')) { // Reject OmniWeb
}
break;
-
+
}
return false;
* @deprecated Use textlib->strtolower($text) instead.
*/
function moodle_strtolower ($string, $encoding='') {
-
+
//If not specified use utf8
if (empty($encoding)) {
$encoding = 'UTF-8';
}
/**
- * This function will make a complete copy of anything it's given,
+ * This function will make a complete copy of anything it's given,
* regardless of whether it's an object or not.
* @param mixed $thing
* @return mixed
* This function expects to called during shutdown
* should be set via register_shutdown_function()
* in lib/setup.php .
- *
+ *
* Right now we do it only if we are under apache, to
* make sure apache children that hog too much mem are
* killed.
- *
+ *
*/
function moodle_request_shutdown() {
global $CFG;
- // initially, we are only ever called under apache
- // but check just in case
- if (function_exists('apache_child_terminate')
+ // initially, we are only ever called under apache
+ // but check just in case
+ if (function_exists('apache_child_terminate')
&& function_exists('memory_get_usage')
&& ini_get_bool('child_terminate')) {
if (empty($CFG->apachemaxmem)) {
$info['html'] .= '<span class="logwrites">Log writes '.$info['logwrites'].'</span> ';
$info['txt'] .= 'logwrites: '.$info['logwrites'].' ';
}
-
+
if (!empty($PERF->profiling) && $PERF->profiling) {
require_once($CFG->dirroot .'/lib/profilerlib.php');
$info['html'] .= '<span class="profilinginfo">'.Profiler::get_profiling(array('-R')).'</span>';
if (isset($rcache->hits) && isset($rcache->misses)) {
$info['rcachehits'] = $rcache->hits;
$info['rcachemisses'] = $rcache->misses;
- $info['html'] .= '<span class="rcache">Record cache hit/miss ratio : '.
+ $info['html'] .= '<span class="rcache">Record cache hit/miss ratio : '.
"{$rcache->hits}/{$rcache->misses}</span> ";
- $info['txt'] .= 'rcache: '.
+ $info['txt'] .= 'rcache: '.
"{$rcache->hits}/{$rcache->misses} ";
}
$info['html'] = '<div class="performanceinfo">'.$info['html'].'</div>';
/**
* Checks if a given plugin is in the list of enabled enrolment plugins.
- *
+ *
* @param string $auth Enrolment plugin.
* @return boolean Whether the plugin is enabled.
*/
continue; // language not allowed, try next one
}
if (file_exists($CFG->dataroot .'/lang/'. $lang) or file_exists($CFG->dirroot .'/lang/'. $lang)) {
- $SESSION->lang = $lang; /// Lang exists, set it in session
+ $SESSION->lang = $lang; /// Lang exists, set it in session
break; /// We have finished. Go out
}
}
/**
* This function will build the navigation string to be used by print_header
* and others
- * @uses $CFG
+ * @uses $CFG
* @uses $THEME
* @param $extranavlinks - array of associative arrays, keys: name, link, type
- * @return $navigation as an object so it can be differentiated from old style
+ * @return $navigation as an object so it can be differentiated from old style
* navigation strings.
*/
function build_navigation($extranavlinks) {
$navigation = '';
$navlinks = array();
-
+
//Site name
if ($site = get_site()) {
$navlinks[] = array('name' => format_string($site->shortname), 'link' => "$CFG->wwwroot/", 'type' => 'home');
if ($COURSE->id != SITEID) {
//Course
$navlinks[] = array('name' => format_string($COURSE->shortname), 'link' => "$CFG->wwwroot/course/view.php?id=$COURSE->id",'type' => 'course');
- }
+ }
}
//Merge in extra navigation links
}
// vim:autoindent:expandtab:shiftwidth=4:tabstop=4:tw=140:
-?>
\ No newline at end of file
+?>