$hide = optional_param('hide', 0, PARAM_INT);
$show = optional_param('show', 0, PARAM_INT);
$delete = optional_param('delete', 0, PARAM_INT);
+ $unprotect = optional_param('unprotect', 0, PARAM_INT);
+ $protect = optional_param('protect', 0, PARAM_INT);
/// Print headings
$strcourses = get_string('blockinstances', 'admin');
$strname = get_string('name');
$strshowblockcourse = get_string('showblockcourse');
+ $strprotecthdr = get_string('blockprotect', 'admin'). $OUTPUT->help_icon('blockprotect','admin');
+ $strprotect = get_string('blockprotect', 'admin');
+ $strunprotect = get_string('blockunprotect', 'admin');
/// If data submitted, then process and store.
admin_get_root(true, false); // settings not required - only pages
}
+ if (!isset($CFG->undeletableblocktypes) || (!is_array($CFG->undeletableblocktypes) && !is_string($CFG->undeletableblocktypes))) {
+ $undeletableblocktypes = array('navigation', 'settings');
+ } else if (is_string($CFG->undeletableblocktypes)) {
+ $undeletableblocktypes = explode(',', $CFG->undeletableblocktypes);
+ } else {
+ $undeletableblocktypes = $CFG->undeletableblocktypes;
+ }
+
+ if (!empty($protect) && confirm_sesskey()) {
+ if (!$block = $DB->get_record('block', array('id'=>$protect))) {
+ print_error('blockdoesnotexist', 'error');
+ }
+ if (!in_array($block->name, $undeletableblocktypes)) {
+ $undeletableblocktypes[] = $block->name;
+ set_config('undeletableblocktypes', implode(',', $undeletableblocktypes));
+ }
+ admin_get_root(true, false); // settings not required - only pages
+ }
+
+ if (!empty($unprotect) && confirm_sesskey()) {
+ if (!$block = $DB->get_record('block', array('id'=>$unprotect))) {
+ print_error('blockdoesnotexist', 'error');
+ }
+ if (in_array($block->name, $undeletableblocktypes)) {
+ $undeletableblocktypes = array_diff($undeletableblocktypes, array($block->name));
+ set_config('undeletableblocktypes', implode(',', $undeletableblocktypes));
+ }
+ admin_get_root(true, false); // settings not required - only pages
+ }
+
if (!empty($delete) && confirm_sesskey()) {
echo $OUTPUT->header();
echo $OUTPUT->heading($strmanageblocks);
$table = new flexible_table('admin-blocks-compatible');
- $table->define_columns(array('name', 'instances', 'version', 'hideshow', 'delete', 'settings'));
- $table->define_headers(array($strname, $strcourses, $strversion, $strhide.'/'.$strshow, $strdelete, $strsettings));
+ $table->define_columns(array('name', 'instances', 'version', 'hideshow', 'undeletable', 'delete', 'settings'));
+ $table->define_headers(array($strname, $strcourses, $strversion, $strhide.'/'.$strshow, $strprotecthdr, $strdelete, $strsettings));
$table->define_baseurl($CFG->wwwroot.'/'.$CFG->admin.'/blocks.php');
$table->set_attribute('class', 'compatibleblockstable blockstable generaltable');
$table->setup();
$version = "$block->version ($plugin->version)";
}
+ if (!$blockobject) {
+ // ignore
+ $undeletable = '';
+ } else if (in_array($blockname, $undeletableblocktypes)) {
+ $undeletable = '<a href="blocks.php?unprotect='.$blockid.'&sesskey='.sesskey().'" title="'.$strunprotect.'">'.
+ '<img src="'.$OUTPUT->pix_url('t/unlock') . '" class="icon" alt="'.$strunprotect.'" /></a>';
+ } else {
+ $undeletable = '<a href="blocks.php?protect='.$blockid.'&sesskey='.sesskey().'" title="'.$strprotect.'">'.
+ '<img src="'.$OUTPUT->pix_url('t/unlock_gray') . '" class="icon" alt="'.$strprotect.'" /></a>';
+ }
$table->add_data(array(
'<span'.$class.'>'.$strblockname.'</span>',
$blocklist,
'<span'.$class.'>'.$version.'</span>',
$visible,
+ $undeletable,
$delete,
$settings
));
define('MOODLE_INTERNAL', true);
// Check that PHP is of a sufficient version
-if (version_compare(phpversion(), "5.2.8") < 0) {
+if (version_compare(phpversion(), "5.3.2") < 0) {
$phpversion = phpversion();
// do NOT localise - lang strings would not work here and we CAN NOT move it after installib
- echo "Sorry, Moodle 2.0 requires PHP 5.2.8 or later (currently using version $phpversion).\n";
- echo "Please upgrade your server software or install latest Moodle 1.9.x instead.";
- die;
+ fwrite(STDERR, "Moodle 2.1 or later requires at least PHP 5.3.2 (currently using version $phpversion).\n");
+ fwrite(STDERR, "Please upgrade your server software or install older Moodle version.\n");
+ exit(1);
}
// set up configuration
--adminuser=USERNAME Username for the moodle admin account. Default is admin.
--adminpass=PASSWORD Password for the moodle admin account.
--agree-license Indicates agreement with software license.
+--fullname Name of the site
+--shortname Name of the site
-h, --help Print out this help
Example:
";
// Check that PHP is of a sufficient version
-if (version_compare(phpversion(), "5.2.8") < 0) {
+if (version_compare(phpversion(), "5.3.2") < 0) {
$phpversion = phpversion();
// do NOT localise - lang strings would not work here and we CAN NOT move it after installib
- fwrite(STDERR, "Sorry, Moodle 2.0 requires PHP 5.2.8 or later (currently using version $phpversion).\n");
- fwrite(STDERR, "Please upgrade your server software or install latest Moodle 1.9.x instead.\n");
- die(1);
+ fwrite(STDERR, "Moodle 2.1 or later requires at least PHP 5.3.2 (currently using version $phpversion).\n");
+ fwrite(STDERR, "Please upgrade your server software or install older Moodle version.\n");
+ exit(1);
}
// Nothing to do if config.php does not exist
if (!file_exists($configfile)) {
fwrite(STDERR, 'config.php does not exist, can not continue'); // do not localize
fwrite(STDERR, "\n");
- die(1);
+ exit(1);
}
// Include necessary libs
'lang' => 'en',
'adminuser' => 'admin',
'adminpass' => '',
+ 'fullname' => '',
+ 'shortname' => '',
'agree-license' => false,
'help' => false
),
}
// Check that PHP is of a sufficient version as soon as possible
-if (version_compare(phpversion(), '5.2.0') < 0) {
+if (version_compare(phpversion(), '5.3.2') < 0) {
$phpversion = phpversion();
// do NOT localise - lang strings would not work here and we CAN NOT move it to later place
- echo "Sorry, Moodle 2.0 requires PHP 5.2.8 or later (currently using version $phpversion). ";
- echo "Please upgrade your server software or use latest Moodle 1.9.x instead.";
+ echo "Moodle 2.1 or later requires at least PHP 5.3.2 (currently using version $phpversion).<br />";
+ echo "Please upgrade your server software or install older Moodle version.";
+ die;
+}
+
+// make sure iconv is available and actually works
+if (!function_exists('iconv')) {
+ // this should not happen, this must be very borked install
+ echo 'Moodle requires the iconv PHP extension. Please install or enable the iconv extension.';
+ die();
+}
+if (iconv('UTF-8', 'UTF-8//IGNORE', 'abc') !== 'abc') {
+ // known to be broken in mid-2011 MAMP installations
+ echo 'Broken iconv PHP extension detected, installation/upgrade can not continue.';
die;
}
$temp->add(new admin_setting_configcheckbox('navshowcategories', get_string('navshowcategories', 'admin'), get_string('confignavshowcategories', 'admin'), 1));
$temp->add(new admin_setting_configcheckbox('navshowallcourses', get_string('navshowallcourses', 'admin'), get_string('confignavshowallcourses', 'admin'), 0));
$temp->add(new admin_setting_configtext('navcourselimit',get_string('navcourselimit','admin'),get_string('confignavcourselimit', 'admin'),20,PARAM_INT));
+ $temp->add(new admin_setting_configcheckbox('navlinkcoursesections', get_string('navlinkcoursesections', 'admin'), get_string('navlinkcoursesections_help', 'admin'), 0));
$ADMIN->add('appearance', $temp);
$temp->add(new admin_setting_configcheckbox('disableuserimages', get_string('disableuserimages', 'admin'), get_string('configdisableuserimages', 'admin'), 0));
$temp->add(new admin_setting_configcheckbox('emailchangeconfirmation', get_string('emailchangeconfirmation', 'admin'), get_string('configemailchangeconfirmation', 'admin'), 1));
$temp->add(new admin_setting_configselect('rememberusername', get_string('rememberusername','admin'), get_string('rememberusername_desc','admin'), 2, array(1=>get_string('yes'), 0=>get_string('no'), 2=>get_string('optional'))));
+ $temp->add(new admin_setting_configcheckbox('strictformsrequired', get_string('strictformsrequired', 'admin'), get_string('configstrictformsrequired', 'admin'), 0));
$ADMIN->add('security', $temp);
900 => get_string('numminutes', '', 15),
300 => get_string('numminutes', '', 5))));
$temp->add(new admin_setting_configtext('sessioncookie', get_string('sessioncookie', 'admin'), get_string('configsessioncookie', 'admin'), '', PARAM_ALPHANUM));
-$temp->add(new admin_setting_configtext('sessioncookiepath', get_string('sessioncookiepath', 'admin'), get_string('configsessioncookiepath', 'admin'), '/', PARAM_LOCALURL));
-$temp->add(new admin_setting_configtext('sessioncookiedomain', get_string('sessioncookiedomain', 'admin'), get_string('configsessioncookiedomain', 'admin'), '', PARAM_TEXT, 50));
+$temp->add(new admin_setting_configtext('sessioncookiepath', get_string('sessioncookiepath', 'admin'), get_string('configsessioncookiepath', 'admin'), '', PARAM_RAW));
+$temp->add(new admin_setting_configtext('sessioncookiedomain', get_string('sessioncookiedomain', 'admin'), get_string('configsessioncookiedomain', 'admin'), '', PARAM_RAW, 50));
$ADMIN->add('server', $temp);
if (count($userlist)) {
list($notin_sql, $params) = $DB->get_in_or_equal($userlist, SQL_PARAMS_NAMED, 'u', false);
$params['authtype'] = $this->authtype;
- $sql = "SELECT u.id, u.username, u.email, u.auth
+ $sql = "SELECT u.*
FROM {user} u
WHERE u.auth=:authtype AND u.deleted=0 AND u.username $notin_sql";
} else {
- $sql = "SELECT u.id, u.username, u.email, u.auth
+ $sql = "SELECT u.*
FROM {user} u
WHERE u.auth=:authtype AND u.deleted=0";
$params = array();
// Find users in DB that aren't in ldap -- to be removed!
// this is still not as scalable (but how often do we mass delete?)
if ($this->config->removeuser !== AUTH_REMOVEUSER_KEEP) {
- $sql = 'SELECT u.id, u.username, u.email, u.auth
+ $sql = 'SELECT u.*
FROM {user} u
LEFT JOIN {tmp_extuser} e ON (u.username = e.username AND u.mnethostid = e.mnethostid)
WHERE u.auth = ?
// attach format plugin structure to $module element, only one allowed
$this->add_plugin_structure('format', $module, false);
- // attach plagiarism plugin structure to $module element, only one allowed
- $this->add_plugin_structure('plagiarism', $module, false);
+ // attach plagiarism plugin structure to $module element, there can be potentially
+ // many plagiarism plugins storing information about this course
+ $this->add_plugin_structure('plagiarism', $module, true);
// Define the tree
$module->add_child($availinfo);
// course reports can save course data if required
$this->add_plugin_structure('coursereport', $course, true);
- // attach plagiarism plugin structure to $course element, only one allowed
- $this->add_plugin_structure('plagiarism', $course, false);
+ // attach plagiarism plugin structure to $course element, there can be potentially
+ // many plagiarism plugins storing information about this course
+ $this->add_plugin_structure('plagiarism', $course, true);
// Build the tree
$category = new restore_path_element('question_category', '/question_categories/question_category');
$question = new restore_path_element('question', '/question_categories/question_category/questions/question');
+ $hint = new restore_path_element('question_hint',
+ '/question_categories/question_category/questions/question/question_hints/question_hint');
// Apply for 'qtype' plugins optional paths at question level
$this->add_plugin_structure('qtype', $question);
- return array($category, $question);
+ return array($category, $question, $hint);
}
protected function process_question_category($data) {
// Adjust some columns
$data->questionid = $newquestionid;
// Insert record
- $newitemid = $DB->insert_record('question_answers', $data);
+ $newitemid = $DB->insert_record('question_hints', $data);
- // The question existed, we need to map the existing question_answers
+ // The question existed, we need to map the existing question_hints
} else {
- // Look in question_answers by answertext matching
+ // Look in question_hints by hint text matching
$sql = 'SELECT id
FROM {question_hints}
WHERE questionid = ?
$params = array($newquestionid, $data->hint);
$newitemid = $DB->get_field_sql($sql, $params);
// If we haven't found the newitemid, something has gone really wrong, question in DB
- // is missing answers, exception
+ // is missing hints, exception
if (!$newitemid) {
$info = new stdClass();
$info->filequestionid = $oldquestionid;
throw new restore_step_exception('error_question_hint_missing_in_db', $info);
}
}
- // Create mapping (we'll use this intensively when restoring question_states. And also answerfeedback files)
+ // Create mapping (I'm not sure if this is really needed?)
$this->set_mapping('question_hint', $oldid, $newitemid);
}
$oldctxid, $this->task->get_userid(), 'question_answer', null, $newctxid, true);
restore_dbops::send_files_to_pool($this->get_basepath(), $this->get_restoreid(), 'question', 'hint',
$oldctxid, $this->task->get_userid(), 'question_hint', null, $newctxid, true);
+ restore_dbops::send_files_to_pool($this->get_basepath(), $this->get_restoreid(), 'question', 'correctfeedback',
+ $oldctxid, $this->task->get_userid(), 'question_created', $question->itemid, $newctxid, true);
+ restore_dbops::send_files_to_pool($this->get_basepath(), $this->get_restoreid(), 'question', 'partiallycorrectfeedback',
+ $oldctxid, $this->task->get_userid(), 'question_created', $question->itemid, $newctxid, true);
+ restore_dbops::send_files_to_pool($this->get_basepath(), $this->get_restoreid(), 'question', 'incorrectfeedback',
+ $oldctxid, $this->task->get_userid(), 'question_created', $question->itemid, $newctxid, true);
// Add qtype dependent files
$components = backup_qtype_plugin::get_components_and_fileareas($question->qtype);
foreach ($components as $component => $fileareas) {
$course->sortorder = 0;
$course->timecreated = time();
$course->timemodified = $course->timecreated;
- $course->visible = $category->visible;
+ // forcing skeleton courses to be hidden instead of going by $category->visible , until MDL-27790 is resolved.
+ $course->visible = 0;
$courseid = $DB->insert_record('course', $course);
}
$manager = has_capability('moodle/cohort:manage', $context);
+$canassign = has_capability('moodle/cohort:assign', $context);
if (!$manager) {
require_capability('moodle/cohort:view', $context);
}
$line[] = get_string('pluginname', $cohort->component);
}
- if ($manager) {
- if (empty($cohort->component)) {
- $buttons = html_writer::link(new moodle_url('/cohort/edit.php', array('id'=>$cohort->id, 'delete'=>1)), html_writer::empty_tag('img', array('src'=>$OUTPUT->pix_url('t/delete'), 'alt'=>get_string('delete'), 'class'=>'iconsmall')));
- $buttons .= ' ' . html_writer::link(new moodle_url('/cohort/edit.php', array('id'=>$cohort->id)), html_writer::empty_tag('img', array('src'=>$OUTPUT->pix_url('t/edit'), 'alt'=>get_string('edit'), 'class'=>'iconsmall')));
- $buttons .= ' ' . html_writer::link(new moodle_url('/cohort/assign.php', array('id'=>$cohort->id)), html_writer::empty_tag('img', array('src'=>$OUTPUT->pix_url('i/users'), 'alt'=>get_string('assign', 'core_cohort'), 'class'=>'iconsmall')));
- } else {
- $buttons = '';
+ $buttons = array();
+ if (empty($cohort->component)) {
+ if ($manager) {
+ $buttons[] = html_writer::link(new moodle_url('/cohort/edit.php', array('id'=>$cohort->id, 'delete'=>1)), html_writer::empty_tag('img', array('src'=>$OUTPUT->pix_url('t/delete'), 'alt'=>get_string('delete'), 'class'=>'iconsmall')));
+ $buttons[] = html_writer::link(new moodle_url('/cohort/edit.php', array('id'=>$cohort->id)), html_writer::empty_tag('img', array('src'=>$OUTPUT->pix_url('t/edit'), 'alt'=>get_string('edit'), 'class'=>'iconsmall')));
+ }
+ if ($manager or $canassign) {
+ $buttons[] = html_writer::link(new moodle_url('/cohort/assign.php', array('id'=>$cohort->id)), html_writer::empty_tag('img', array('src'=>$OUTPUT->pix_url('i/users'), 'alt'=>get_string('assign', 'core_cohort'), 'class'=>'iconsmall')));
}
- } else {
- $buttons = '';
}
- $line[] = $buttons;
+ $line[] = implode(' ', $buttons);
$data[] = $line;
}
* @var int
*/
protected $totalcommentcount = null;
- /**
- * When set to true any user to the system is able to view comments.
- *
- * This can be set to true by a plugin by implementing a allow_anonymous_access callback.
- * By default it is false except on the front page.
- *
- * @var bool
- */
- protected $allowanonymousaccess = false;
/**#@+
* static variable will be used by non-js comments UI
$this->comment_param->commentarea = $this->commentarea;
$this->comment_param->itemid = $this->itemid;
- $this->allowanonymousaccess = false;
- // By default everyone can view comments on the front page
- if ($this->context->contextlevel == CONTEXT_COURSE && $this->context->instanceid == SITEID) {
- $this->allowanonymousaccess = true;
- } else if ($this->context->contextlevel == CONTEXT_MODULE && $this->courseid == SITEID) {
- $this->allowanonymousaccess = true;
- }
- if (!empty($this->plugintype) && !empty($this->pluginname)) {
- // Plugins can override this if they wish.
- $this->allowanonymousaccess = plugin_callback($this->plugintype, $this->pluginname, 'comment', 'allow_anonymous_access', array($this), $this->allowanonymousaccess);
- }
-
// setup notoggle
if (!empty($options->notoggle)) {
$this->set_notoggle($options->notoggle);
$this->viewcap = has_capability('moodle/comment:view', $this->context);
if (!empty($this->plugintype)) {
$permissions = plugin_callback($this->plugintype, $this->pluginname, 'comment', 'permissions', array($this->comment_param), array('post'=>false, 'view'=>false));
- if ($this->allowanonymousaccess) {
- $this->postcap = $permissions['post'];
- $this->viewcap = $permissions['view'];
- } else {
- $this->postcap = $this->postcap && $permissions['post'];
- $this->viewcap = $this->viewcap && $permissions['view'];
- }
+ $this->postcap = $this->postcap && $permissions['post'];
+ $this->viewcap = $this->viewcap && $permissions['view'];
}
}
// These blocks are used when no other default setting is found.
// $CFG->defaultblocks = 'participants,activity_modules,search_forums,admin,course_list:news_items,calendar_upcoming,recent_activity';
//
-// The blocks in this list will be protected from deletion, and this is primarily
-// used to protect the navigation and settings blocks which can be very hard to
-// get back if accidentally delete.
-// $CFG->undeletableblocktypes = 'navigation,settings';
-//
// You can specify a different class to be created for the $PAGE global, and to
// compute which blocks appear on each page. However, I cannot think of any good
// reason why you would need to change that. It just felt wrong to hard-code the
$ajaxsupport->testedbrowsers = array('MSIE' => 6.0, 'Gecko' => 20061111, 'Safari' => 531, 'Chrome' => 6.0);
return $ajaxsupport;
}
+
+/**
+ * Returns a URL to arrive directly at a section
+ *
+ * @param int $courseid The id of the course to get the link for
+ * @param int $sectionnum The section number to jump to
+ * @return moodle_url
+ */
+function callback_topics_get_section_url($courseid, $sectionnum) {
+ return new moodle_url('/course/view.php', array('id' => $courseid, 'topic' => $sectionnum));
+}
\ No newline at end of file
$ajaxsupport->testedbrowsers = array('MSIE' => 6.0, 'Gecko' => 20061111, 'Safari' => 531, 'Chrome' => 6.0);
return $ajaxsupport;
}
+
+/**
+ * Returns a URL to arrive directly at a section
+ *
+ * @param int $courseid The id of the course to get the link for
+ * @param int $sectionnum The section number to jump to
+ * @return moodle_url
+ */
+function callback_weeks_get_section_url($courseid, $sectionnum) {
+ return new moodle_url('/course/view.php', array('id' => $courseid, 'week' => $sectionnum));
+}
header("Pragma: public");
echo get_string('savedat').userdate(time(), $strftimedatetime)."\n";
- echo $text;
+ echo $text."\n";
if (empty($logs['logs'])) {
return true;
$course->summaryformat = FORMAT_MOODLE;
}
echo highlight($highlightterms, format_text($course->summary, $course->summaryformat, $options, $course->id));
- if ((!isloggedin() || is_siteadmin()) && $icons = enrol_get_course_info_icons($course)) {
+ if ($icons = enrol_get_course_info_icons($course)) {
echo html_writer::start_tag('div', array('class'=>'enrolmenticons'));
foreach ($icons as $icon) {
echo $OUTPUT->render($icon);
require_login($course);
require_capability('moodle/course:enrolconfig', $context);
+require_capability('enrol/cohort:config', $context);
$PAGE->set_url('/enrol/cohort/addinstance.php', array('id'=>$course->id));
$PAGE->set_pagelayout('admin');
break;
case 'enrolcohort':
require_capability('moodle/course:enrolconfig', $context);
+ require_capability('enrol/cohort:config', $context);
$roleid = required_param('roleid', PARAM_INT);
$cohortid = required_param('cohortid', PARAM_INT);
enrol_cohort_sync($manager->get_course()->id);
break;
case 'enrolcohortusers':
- require_capability('moodle/course:enrolconfig', $context);
+ require_capability('enrol/manual:enrol', $context);
$roleid = required_param('roleid', PARAM_INT);
$cohortid = required_param('cohortid', PARAM_INT);
$result = enrol_cohort_enrol_all_users($manager, $cohortid, $roleid);
+
+ $roles = $manager->get_assignable_roles();
+ $cohorts = enrol_cohort_get_cohorts($manager);
+ if (!array_key_exists($cohortid, $cohorts) || !array_key_exists($roleid, $roles)) {
+ throw new enrol_ajax_exception('errorenrolcohort');
+ }
if ($result === false) {
throw new enrol_ajax_exception('errorenrolcohortusers');
}
$button->strings_for_js('users', 'moodle');
// No point showing this at all if the user cant manually enrol users
- $hasmanualinstance = has_capability('enrol/manual:manage', $manager->get_context()) && $manager->has_instance('manual');
+ $hasmanualinstance = has_capability('enrol/manual:enrol', $manager->get_context()) && $manager->has_instance('manual');
$modules = array('moodle-enrol_cohort-quickenrolment', 'moodle-enrol_cohort-quickenrolment-skin');
$function = 'M.enrol_cohort.quickenrolment.init';
$string['flashanimation'] = 'Flash animation';
$string['flashanimation_help'] = 'Files with extension *.swf. For security reasons this filter is used only in trusted texts.';
$string['flashvideo'] = 'Flash video';
-$string['flashvideo_help'] = 'Files with extension *.flv and *.f4v. Plays video clips using Flowplayer, requires Flash plugin and javascript. Uses HTML 5 video fallback if multiple sources psecified.';
+$string['flashvideo_help'] = 'Files with extension *.flv and *.f4v. Plays video clips using Flowplayer, requires Flash plugin and javascript. Uses HTML 5 video fallback if multiple sources specified.';
$string['html5audio'] = 'HTML 5 audio';
$string['html5audio_help'] = 'Audio files with extension *.ogg, *.aac and others. It is compatible with latest web browsers only, unfortunately there is no format that is supported by all browsers.
Workaround is to specify fallbacks separated with # (ex: http://example.org/audio.aac#http://example.org/audio.aac#http://example.org/audio.mp3#), QuickTime player is used as a fallback for old browsers, fallback can be any audio type.';
* see http://flowplayer.org/documentation/skinning/controlbar.html?skin=default for more color properties,
* any property that ends with '...Color' is supported here.
*/
-.mp3flowplayer_backgroundColor {color: #000000};
+.mp3flowplayer_backgroundColor {color: #000000;}
if (version_compare(phpversion(), "5.2.0") < 0) {
$phpversion = phpversion();
// do NOT localise - lang strings would not work here and we CAN not move it after installib
- echo "Sorry, Moodle 2.0 requires PHP 5.2.8 or later (currently using version $phpversion).<br />";
- echo "Please upgrade your server software or install latest Moodle 1.9.x instead.";
+ echo "Moodle 2.1 or later requires at least PHP 5.3.2 (currently using version $phpversion).<br />";
+ echo "Please upgrade your server software or install older Moodle version.";
+ die;
+}
+
+// make sure iconv is available and actually works
+if (!function_exists('iconv')) {
+ // this should not happen, this must be very borked install
+ echo 'Moodle requires the iconv PHP extension. Please install or enable the iconv extension.';
+ die();
+}
+if (iconv('UTF-8', 'UTF-8//IGNORE', 'abc') !== 'abc') {
+ // known to be broken in mid-2011 MAMP installations
+ echo 'Broken iconv PHP extension detected, installation can not continue.';
die;
}
if (!empty($memlimit) and $memlimit != -1) {
if (get_real_size($memlimit) < get_real_size($minrequiredmemory)) {
// do NOT localise - lang strings would not work here and we CAN not move it to later place
- echo "Sorry, Moodle 2.0 requires at least {$minrequiredmemory}B of PHP memory.<br />";
+ echo "Moodle requires at least {$minrequiredmemory}B of PHP memory.<br />";
echo "Please contact server administrator to fix PHP.ini memory settings.";
die;
}
install_print_help_page($_GET['help']);
}
-// send css?
-if (isset($_GET['css'])) {
- install_css_styles();
-}
-
//first time here? find out suitable dataroot
if (is_null($CFG->dataroot)) {
$CFG->dataroot = dirname(dirname(__FILE__)).DIRECTORY_SEPARATOR.'moodledata';
if ($config->stage == INSTALL_ENVIRONMENT or $config->stage == INSTALL_PATHS) {
- $version_fail = (version_compare(phpversion(), "5.2.8") < 0);
+ $version_fail = (version_compare(phpversion(), "5.3.2") < 0);
$curl_fail = ($lang !== 'en' and !extension_loaded('curl')); // needed for lang pack download
$zip_fail = ($lang !== 'en' and !extension_loaded('zip')); // needed for lang pack download
echo '<div id="envresult"><dl>';
if ($version_fail) {
- $a = (object)array('needed'=>'5.2.8', 'current'=>phpversion());
+ $a = (object)array('needed'=>'5.3.2', 'current'=>phpversion());
echo '<dt>'.get_string('phpversion', 'install').'</dt><dd>'.get_string('environmentrequireversion', 'admin', $a).'</dd>';
}
if ($curl_fail) {
--- /dev/null
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * This script prints basic CSS for the installer
+ *
+ * @package core
+ * @subpackage install
+ * @copyright 2011 Petr Skoda (http://skodak.org)
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+if (file_exists(dirname(dirname(__FILE__)).'/config.php')) {
+ // already installed
+ die;
+}
+
+// include only the necessary stuff from themes, keep this small otherwise IE will complain...
+$files = array(
+ 'base/style/pagelayout.css',
+ 'base/style/core.css',
+ 'standard/style/core.css',
+ 'standard/style/css3.css');
+
+
+$content = '';
+
+foreach($files as $file) {
+ $content .= file_get_contents(dirname(dirname(__FILE__)).'/theme/'.$file) . "\n";
+}
+
+$content .= "
+
+h2 {
+ text-align:center;
+}
+
+#installdiv {
+ width: 800px;
+ margin-left:auto;
+ margin-right:auto;
+}
+
+#installdiv dt {
+ font-weight: bold;
+}
+
+#installdiv dd {
+ padding-bottom: 0.5em;
+}
+
+.stage {
+ margin-top: 2em;
+ margin-bottom: 2em;
+ width: 100%;
+ padding:25px;
+}
+
+#installform {
+ width: 100%;
+}
+
+#nav_buttons input {
+ margin: 5px;
+}
+
+#envresult {
+ text-align:left;
+ width: auto;
+ margin-left:10em;
+}
+
+#envresult dd {
+ color: red;
+}
+
+.formrow {
+ clear:both;
+ text-align:left;
+ padding: 8px;
+}
+
+.formrow label.formlabel {
+ display:block;
+ float:left;
+ width: 260px;
+ margin-right:5px;
+ text-align:right;
+}
+
+.formrow .forminput {
+ display:block;
+ float:left;
+}
+
+fieldset {
+ text-align:center;
+ border:none;
+}
+
+.hint {
+ display:block;
+ clear:both;
+ padding-left: 265px;
+ color: red;
+}
+
+.configphp {
+ text-align:left;
+ background-color:white;
+ padding:1em;
+ width:95%;
+}
+
+.stage6 .stage {
+ font-weight: bold;
+ color: red;
+}
+
+";
+
+// fix used urls
+$content = str_replace('[[pix:theme|hgradient]]', '../theme/standard/pix/hgradient.jpg', $content);
+$content = str_replace('[[pix:theme|vgradient]]', '../theme/standard/pix/vgradient.jpg', $content);
+
+@header('Content-Disposition: inline; filename="css.php"');
+@header('Cache-Control: no-store, no-cache, must-revalidate');
+@header('Cache-Control: post-check=0, pre-check=0', false);
+@header('Pragma: no-cache');
+@header('Expires: Mon, 20 Aug 1969 09:23:00 GMT');
+@header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
+@header('Accept-Ranges: none');
+@header('Content-Type: text/css; charset=utf-8');
+
+echo $content;
$string['availablelangs'] = 'Списък на наличните езици';
$string['chooselanguagehead'] = 'Изберете език';
$string['chooselanguagesub'] = 'Моля, изберете език за инсталацията. Този език ще бъде, също така, език по подразбиране на сайта, но може да бъде променен и по-късно след инсталирането.';
+$string['databasehost'] = 'Хост на базата данни';
+$string['databasename'] = 'Потребителско име за базата данни';
+$string['databasetypehead'] = 'Избиране на драйвер за база данни';
$string['dataroot'] = 'Директория за данни';
+$string['dbprefix'] = 'Представка на таблиците';
$string['dirroot'] = 'Директория на Moodle';
$string['installation'] = 'Инсталиране';
$string['paths'] = 'Пътища';
$string['pathshead'] = 'Потвърждаване на пътищата';
$string['pathssubdataroot'] = 'Тази директория е място, където Moodle, записва качваните файлове. Тази директория трябва да е достъпна за четене И ЗА ЗАПИС от потребителя на интернет сървъра (обикновено \'nobody\' или \'apache\'), но не трябва да е достъпна пряко през Интернет. Инталаторът ще се опита да създаде директорията, ако тя не съществува.';
$string['pathssubdirroot'] = 'Пълен път до директорията на Moodle.';
-$string['pathssubwwwroot'] = 'Пълен интернет адрес, на който ще се отваря Moodle. Не е възможно Moodle да се отваря чрез различни адреси. Ако Вашият сайт има няколко адреса трябва на всеки от другите адреси да направите HTML пренасочване към този. Ако Вашият сайт се отваря както глобално от Интернет, така и от локална мрежа, настройте DNS така че потребителите от локалната мрежа също да могат да ползват глобалния адрес. Ако адресът не е коректен, моля, променете адреса в браузъра си и започнете инсталирането с правилния адрес.';
+$string['pathssubwwwroot'] = 'Пълен интернет адрес, на който ще се отваря Moodle. Не е възможно Moodle да се отваря чрез различни адреси. Ако Вашият сайт има няколко адреса трябва на всеки от другите адреси да направите пренасочване към този. Ако Вашият сайт се отваря както глобално от Интернет, така и от локална мрежа, настройте DNS, така че потребителите от локалната мрежа също да могат да ползват глобалния адрес. Ако адресът не е коректен, моля, променете адреса в браузъра си и започнете инсталирането с правилния адрес.';
$string['wwwroot'] = 'Уеб адрес';
$string['errorsinenvironment'] = 'Échec de la vérification de l\'environnement !';
$string['installation'] = 'Installation';
$string['langdownloaderror'] = 'La langue {$a} n\'a pas pu être téléchargée. La suite de l\'installation se déroulera en anglais. Vous pourrez télécharger et installer d\'autres langues à la fin de l\'installation';
-$string['memorylimithelp'] = '<p>La limite de mémoire de PHP sur votre serveur est actuellement de {$a}.</p><p>Cette valeur trop basse risque de générer des problèmes de manque de mémoire pour Moodle, notamment si vous utilisez beaucoup de modules et/ou si vous avez un grand nombre d\'utilisateurs.</p><p>Il est recommandé de configurer PHP avec une limite de mémoire aussi élevée que possible, par exemple 40 Mo. Vous pouvez obtenir cela de différentes façons :</p>
+$string['memorylimithelp'] = '<p>La limite de mémoire de PHP sur votre serveur est actuellement de {$a}.</p>
+<p>Cette valeur trop basse risque de générer des problèmes de manque de mémoire pour Moodle, notamment si vous utilisez beaucoup de modules et/ou si vous avez un grand nombre d\'utilisateurs.</p>
+<p>Il est recommandé de configurer PHP avec une limite de mémoire aussi élevée que possible, par exemple 40 Mo. Vous pouvez obtenir cela de différentes façons :</p>
<ol>
<li>si vous en avez la possibilité, recompilez PHP avec l\'option <em>--enable-memory-limit</em>. Cela permettra à Moodle de fixer lui-même sa limite de mémoire ;</li>
<li>si vous avez accès à votre fichier « php.ini », vous pouvez attribuer au paramètre <b>memory_limit</b> une valeur comme 40M. Si vous n\'y avez pas accès, demandez à l\'administrateur de le faire pour vous ;</li>
-<li>sur certains serveurs, vous pouvez créer dans le dossier principal de Moodle un fichier « .htaccess » contenant cette ligne : <blockquote><div>php_value memory_limit 40M</div></blockquote><p>Cependant, sur certains serveurs, cela empêchera le fonctionnement correct de <b>tous</b> les fichiers PHP (vous verrez s\'afficher des erreurs lors de la consultation de pages). Dans ce cas, vous devrez supprimer le fichier « .htaccess ».</li>
+<li>sur certains serveurs, vous pouvez créer dans le dossier principal de Moodle un fichier « .htaccess » contenant cette ligne :
+<blockquote><div>php_value memory_limit 40M</div></blockquote>
+<p>Cependant, sur certains serveurs, cela empêchera le fonctionnement correct de <b>tous</b> les fichiers PHP (vous verrez s\'afficher des erreurs lors de la consultation de pages). Dans ce cas, vous devrez supprimer le fichier « .htaccess ».</p></li>
</ol>';
$string['paths'] = 'Chemins';
$string['pathserrcreatedataroot'] = 'Le dossier de données ({$a->dataroot}) ne peut pas être créé par l\'installeur.';
$string['phpversionhelp'] = '<p>Moodle nécessite au minimum la version 4.3.0 ou 5.1.0 (5.0.x a bon nombre de problèmes).</p><p>Vous utilisez actuellement la version {$a}.</p><p>Pour que Moodle fonctionne, vous devez mettre à jour PHP ou aller chez un hébergeur ayant une version récente de PHP.<br />(Si vous avez une version 5.0.x, vous pouvez aussi re-passer à la version 4.4.x)</p>';
$string['welcomep10'] = '{$a->installername} ({$a->installerversion})';
$string['welcomep20'] = 'Vous voyez cette page, car vous avez installé Moodle correctement et lancé le logiciel <b>{$a->packname} {$a->packversion}</b> sur votre ordinateur. Félicitations !';
-$string['welcomep30'] = 'Cette version du paquet <b>{$a->installername}</b> comprend des logiciels qui créent un environnement dans lequel <b>Moodle</b> va fonctionner, à savoir :';
+$string['welcomep30'] = 'Cette version de <b>{$a->installername}</b> comprend des logiciels qui créent un environnement dans lequel <b>Moodle</b> va fonctionner, à savoir :';
$string['welcomep40'] = 'Ce paquet contient également <b>Moodle {$a->moodlerelease} ({$a->moodleversion})</b>.';
$string['welcomep50'] = 'L\'utilisation de tous les logiciels de ce paquet est soumis à l\'acceptation de leurs licences respectives. Le paquet <b>{$a->installername}</b> est un <a href="http://www.opensource.org/docs/definition_plain.html">logiciel libre</a>. Il est distribué sous licence <a href="http://www.gnu.org/copyleft/gpl.html">GPL</a>.';
$string['welcomep60'] = 'Les pages suivantes vous aideront pas à pas à configurer et mettre en place <b>Moodle</b> sur votre ordinateur. Il vous sera possible d\'accepter les réglages par défaut ou, facultativement, de les adapter à vos propres besoins.';
$string['blockediplist'] = 'Blocked IP List';
$string['blockinstances'] = 'Instances';
$string['blockmultiple'] = 'Multiple';
+$string['blockprotect'] = 'Protect from delete';
+$string['blockprotect_help'] = 'Selected block instances will be protected from deletion from the site-wide context. This is primarily used to protect the navigation and settings blocks which can be very hard to get back if accidentally deleted.';
+$string['blockunprotect'] = 'Unprotect';
$string['blocksettings'] = 'Manage blocks';
$string['bloglevel'] = 'Blog visibility';
$string['bloglevelupgrade'] = 'Blog visibility upgrade';
$string['configstatsruntimedays'] = 'Specify the maximum number of days processed in each stats execution. When stats are up-to-date, only one day will be processed, so adjust this value depending of your server load, reducing it if shorter cron executions are needed.';
$string['configstatsruntimestart'] = 'What time should the cronjob that does the stats processing <b>start</b>? Please specify different times if there are multiple Moodles on one physical server.';
$string['configstatsuserthreshold'] = 'This setting specifies the minimum number of enrolled users for a course to be included in statistics calculations.';
+$string['configstrictformsrequired'] = 'If enabled, users are prevented from entering a space or line break only in required fields in forms.';
$string['configstripalltitletags'] = 'Uncheck this setting to allow HTML tags in activity and resource names.';
$string['configsupportemail'] = 'This email address will be published to users of this site as the one to email when they need general help (for example, when new users create their own accounts). If this email is left blank then no such helpful email address is supplied.';
$string['configsupportname'] = 'This is the name of a person or other entity offering general help via the support email or web address.';
$string['mysql416required'] = 'MySQL 4.1.16 is the minimum version required for Moodle 1.6 in order to guarantee that all data can be converted to UTF-8 in the future.';
$string['navigationupgrade'] = 'This upgrade introduces two new navigation blocks that will replace these blocks: Administration, Courses, Activities and Participants. If you had set any special permissions on those blocks you should check to make sure everything is behaving as you want it.';
$string['navcourselimit'] = 'Course limit';
+$string['navlinkcoursesections'] = 'Link course sections';
+$string['navlinkcoursesections_help'] = 'If enabled course sections will be shown as links within the navigation.';
$string['navshowallcourses'] = 'Show all courses';
$string['navshowcategories'] = 'Show course categories';
$string['neverdeleteruns'] = 'Never delete runs';
$string['stickyblocksduplicatenotice'] = 'If any block you add here is already present in a particular page, it will result in a duplicate.<br />Only the pinned block will be non-editable, the duplicate will still be editable.';
$string['stickyblocksmymoodle'] = 'My Moodle';
$string['stickyblockspagetype'] = 'Page type to configure';
+$string['strictformsrequired'] = 'Strict validation of required fields';
$string['stripalltitletags'] = 'Remove HTML tags from all activity names';
$string['supportcontact'] = 'Support contact';
$string['supportemail'] = 'Support email';
$string['categorymove'] = 'The category \'{$a->name}\' contains {$a->count} questions (some of them may be old, hidden, questions that are still in use in some existing quizzes). Please choose another category to move them to.';
$string['categorymoveto'] = 'Save in category';
$string['categorynamecantbeblank'] = 'The category name cannot be blank.';
-$string['clicktoflag'] = 'Click to flag this question';
-$string['clicktounflag'] = 'Click to un-flag this question';
+$string['clickflag'] = 'Flag question';
+$string['clicktoflag'] = 'Flag this question for future reference';
+$string['clicktounflag'] = 'Remove flag';
+$string['clickunflag'] = 'Remove flag';
$string['contexterror'] = 'You shouldn\'t have got here if you\'re not moving a category to another context.';
$string['copy'] = 'Copy from {$a} and change links.';
$string['created'] = 'Created';
$string['changeoptions'] = 'Change options';
$string['check'] = 'Check';
$string['clearwrongparts'] = 'Clear incorrect responses';
-$string['clicktoflag'] = 'Click to flag this question';
-$string['clicktounflag'] = 'Click to un-flag this question';
$string['closepreview'] = 'Close preview';
$string['combinedfeedback'] = 'Combined feedback';
$string['commented'] = 'Commented: {$a}';
// make sure there is a real user specified
if ($user === null) {
- $userid = !empty($USER->id) ? $USER->id : 0;
+ $userid = isset($USER->id) ? $USER->id : 0;
} else {
- $userid = !empty($user->id) ? $user->id : $user;
+ $userid = is_object($user) ? $user->id : $user;
}
// capability must exist
// make sure there is a real user specified
if ($user === null) {
- $userid = !empty($USER->id) ? $USER->id : 0;
+ $userid = isset($USER->id) ? $USER->id : 0;
} else {
- $userid = !empty($user->id) ? $user->id : $user;
+ $userid = is_object($user) ? $user->id : $user;
}
if (isguestuser($userid)) {
// make sure there is a real user specified
if ($user === null) {
- $userid = !empty($USER->id) ? $USER->id : 0;
+ $userid = isset($USER->id) ? $USER->id : 0;
} else {
- $userid = !empty($user->id) ? $user->id : $user;
+ $userid = is_object($user) ? $user->id : $user;
}
if (empty($userid)) {
$storedcaps = array();
$filecaps = load_capability_def($component);
+ foreach($filecaps as $capname=>$unused) {
+ if (!preg_match('|^[a-z]+/[a-z_0-9]+:[a-z_0-9]+$|', $capname)) {
+ debugging("Coding problem: Invalid capability name '$capname', use 'clonepermissionsfrom' field for migration.");
+ }
+ }
+
$cachedcaps = get_cached_capabilities($component);
if ($cachedcaps) {
foreach ($cachedcaps as $cachedcap) {
// make sure there is a real user specified
if ($user === null) {
- $userid = !empty($USER->id) ? $USER->id : 0;
+ $userid = isset($USER->id) ? $USER->id : 0;
} else {
- $userid = !empty($user->id) ? $user->id : $user;
+ $userid = is_object($user) ? $user->id : $user;
}
if (!has_capability('moodle/role:assign', $context, $userid)) {
* @param string $name setting name
* @param string $visiblename localised setting name
* @param string $description setting description
+ * @param array $defaultsetting a plain array of default module ids
*/
- public function __construct($name, $visiblename, $description) {
- parent::__construct($name, $visiblename, $description, array(), null);
+ public function __construct($name, $visiblename, $description, $defaultsetting = array()) {
+ parent::__construct($name, $visiblename, $description, $defaultsetting, null);
}
/**
global $CFG;
if (!isset($CFG->undeletableblocktypes) || (!is_array($CFG->undeletableblocktypes) && !is_string($CFG->undeletableblocktypes))) {
- $CFG->undeletableblocktypes = array('navigation','settings');
+ $undeletableblocktypes = array('navigation','settings');
} else if (is_string($CFG->undeletableblocktypes)) {
- $CFG->undeletableblocktypes = explode(',', $CFG->undeletableblocktypes);
+ $undeletableblocktypes = explode(',', $CFG->undeletableblocktypes);
+ } else {
+ $undeletableblocktypes = $CFG->undeletableblocktypes;
}
$controls = array();
}
if ($this->page->user_can_edit_blocks() && $block->user_can_edit() && $block->user_can_addto($this->page)) {
- if (!in_array($block->instance->blockname, $CFG->undeletableblocktypes)) {
+ if (!in_array($block->instance->blockname, $undeletableblocktypes)
+ || !in_array($block->instance->pagetypepattern, array('*', 'site-index'))
+ || $block->instance->parentcontextid != SITEID) {
// Delete icon.
$controls[] = array('url' => $actionurl . '&bui_deleteid=' . $block->instance->id,
'icon' => 't/delete', 'caption' => get_string('delete'));
if (!empty($CFG->deleteincompleteusers)) {
$cuttime = $timenow - ($CFG->deleteincompleteusers * 3600);
- $rs = $DB->get_recordset_sql ("SELECT id, username
+ $rs = $DB->get_recordset_sql ("SELECT *
FROM {user}
WHERE confirmed = 1 AND lastaccess > 0
AND lastaccess < ? AND deleted = 0
$info = $info;
if (!empty($url)) { // could break doing html_entity_decode on an empty var.
$url = html_entity_decode($url);
+ } else {
+ $url = '';
}
// Restrict length of log lines to the space actually available in the
'contextlevel' => CONTEXT_COURSE,
'archetypes' => array(
'editingteacher' => CAP_ALLOW,
- 'coursecreator' => CAP_ALLOW,
'manager' => CAP_ALLOW,
)
),
'student' => CAP_ALLOW,
'teacher' => CAP_ALLOW,
'editingteacher' => CAP_ALLOW,
- 'coursecreator' => CAP_ALLOW,
'manager' => CAP_ALLOW
)
),
'student' => CAP_ALLOW,
'teacher' => CAP_ALLOW,
'editingteacher' => CAP_ALLOW,
- 'coursecreator' => CAP_ALLOW
)
),
'contextlevel' => CONTEXT_BLOCK,
'archetypes' => array(
'editingteacher' => CAP_ALLOW,
- 'coursecreator' => CAP_ALLOW
)
),
'student' => CAP_ALLOW,
'teacher' => CAP_ALLOW,
'editingteacher' => CAP_ALLOW,
- 'coursecreator' => CAP_ALLOW
)
),
'moodle/comment:view' => array(
-
'captype' => 'read',
'contextlevel' => CONTEXT_COURSE,
'archetypes' => array(
+ 'frontpage' => CAP_ALLOW,
+ 'guest' => CAP_ALLOW,
'user' => CAP_ALLOW,
'student' => CAP_ALLOW,
'teacher' => CAP_ALLOW,
'editingteacher' => CAP_ALLOW,
- 'coursecreator' => CAP_ALLOW,
'manager' => CAP_ALLOW
)
),
'student' => CAP_ALLOW,
'teacher' => CAP_ALLOW,
'editingteacher' => CAP_ALLOW,
- 'coursecreator' => CAP_ALLOW,
'manager' => CAP_ALLOW
)
),
'contextlevel' => CONTEXT_COURSE,
'archetypes' => array(
'editingteacher' => CAP_ALLOW,
- 'coursecreator' => CAP_ALLOW,
'manager' => CAP_ALLOW
)
),
'archetypes' => array(
'teacher' => CAP_ALLOW,
'editingteacher' => CAP_ALLOW,
- 'coursecreator' => CAP_ALLOW,
'manager' => CAP_ALLOW
)
),
'manager' => CAP_ALLOW,
'teacher' => CAP_ALLOW,
'editingteacher' => CAP_ALLOW,
- 'coursecreator' => CAP_ALLOW
)
),
'moodle/community:download' => array(
'archetypes' => array(
'manager' => CAP_ALLOW,
'editingteacher' => CAP_ALLOW,
- 'coursecreator' => CAP_ALLOW
)
)
);
$instanceids[] = $blockinstance->id;
// If we have more than 1000 block instances now remove all block positions
// and empty the array
- if (count($contextids) > 1000) {
+ if (count($instanceids) > 1000) {
$instanceidstring = join(',',$instanceids);
$DB->delete_records_select('block_positions', 'blockinstanceid IN ('.$instanceidstring.')');
$instanceids = array();
upgrade_cleanup_unwanted_block_contexts($contextids);
- $instanceidstring = join(',',$instanceids);
- $DB->delete_records_select('block_positions', 'blockinstanceid IN ('.$instanceidstring.')');
+ if ($instanceids) {
+ $instanceidstring = join(',',$instanceids);
+ $DB->delete_records_select('block_positions', 'blockinstanceid IN ('.$instanceidstring.')');
+ }
unset($allblockinstances);
unset($contextids);
if ($item->isFile()) {
if (!$item->isReadable()) {
- echo $OUTPUT->notification(" File not readable, skipping: ".$fullpathname.$item->getFilename());
+ $notification = "File not readable, skipping: ".$fullpathname.$item->getFilename();
+ echo $OUTPUT->notification($notification);
+ upgrade_log(UPGRADE_LOG_NOTICE, null, $notification);
continue;
}
}
if ($textlib->strlen($filepath) > 255) {
- echo $OUTPUT->notification(" File path longer than 255 chars, skipping: ".$fullpathname.$item->getFilename());
- continue;
+ // we need something unique and reproducible, sorry no shortening possible
+ $filepath = '/directory_over_255_chars/'.md5($filepath).'/';
+ $oldfile = $fullpathname.$item->getFilename();
+ $newfile = $filepath.$item->getFilename();
+ $notification = "File path longer than 255 chars '$oldfile', file path truncated to '$newfile'";
+ echo $OUTPUT->notification($notification);
+ upgrade_log(UPGRADE_LOG_NOTICE, null, $notification);
+ }
+
+ if ($textlib->strlen($filename) > 255) {
+ //try to shorten, but look for collisions
+ $oldfile = $fullpathname.$item->getFilename();
+ $parts = explode('.', $filename);
+ $ext = array_pop($parts);
+ $name = implode('.', $parts);
+ $name = $textlib->substr($name, 0, 254-$textlib->strlen($ext));
+ $newfilename = $name . '.' . $ext;
+ if (file_exists($fullpathname.$newfilename) or $fs->file_exists($context->id, $component, $filearea, '0', $filepath, $newfilename)) {
+ $filename = 'file_name_over_255_chars'.md5($filename).$ext; // bad luck, file with shortened name exists
+ } else {
+ $filename = $newfilename; // shortened name should not cause collisions
+ }
+ $notification = "File name longer than 255 chars '$oldfile', file name truncated to '$filename'";
+ echo $OUTPUT->notification($notification);
+ upgrade_log(UPGRADE_LOG_NOTICE, null, $notification);
}
if (!$fs->file_exists($context->id, $component, $filearea, '0', $filepath, $filename)) {
continue;
}
$filepath = ($filepath.$dirname.'/');
- if ($filepath !== '/backupdata/') {
+ if ($filepath !== '/backupdata/' and $textlib->strlen($filepath) <= 255) {
$fs->create_directory($context->id, $component, $filearea, 0, $filepath);
}
error('execute_sql() not available anymore');
}
/**
- * @deprecated
+ * @deprecated use $DB->record_exists_select() instead
+ * @see moodle_database::record_exists_select()
* @param mixed $table
* @param mixed $select
* @return void Throws an error and does nothing
error('record_exists_select() not available anymore');
}
/**
- * @deprecated
+ * @deprecated use $DB->record_exists_sql() instead
+ * @see moodle_database::record_exists_sql()
* @param mixed $sql
* @return void Throws an error and does nothing
*/
error('record_exists_sql() not available anymore');
}
/**
- * @deprecated
+ * @deprecated use $DB->count_records_select() instead
+ * @see moodle_database::count_records_select()
* @param mixed $table
* @param mixed $select
* @param mixed $countitem
error('count_records_select() not available anymore');
}
/**
- * @deprecated
+ * @deprecated use $DB->count_records_sql() instead
+ * @see moodle_database::count_records_sql()
* @param mixed $sql
* @return void Throws an error and does nothing
*/
error('count_records_sql() not available anymore');
}
/**
- * @deprecated
+ * @deprecated use $DB->get_record_sql() instead
+ * @see moodle_database::get_record_sql()
* @param mixed $sql
* @param bool $expectmultiple
* @param bool $nolimit
error('get_record_sql() not available anymore');
}
/**
- * @deprecated
+ * @deprecated use $DB->get_record_select() instead
+ * @see moodle_database::get_record_select()
* @param mixed $table
* @param mixed $select
* @param mixed $fields
error('get_record_select() not available anymore');
}
/**
- * @deprecated
+ * @deprecated use $DB->get_recordset() instead
+ * @see moodle_database::get_recordset()
* @param mixed $table
* @param mixed $field
* @param mixed $value
error('get_recordset() not available anymore');
}
/**
- * @deprecated
+ * @deprecated use $DB->get_recordset_sql() instead
+ * @see moodle_database::get_recordset_sql()
* @param mixed $sql
* @param mixed $limitfrom
* @param mixed $limitnum
error('rs_close() not available anymore');
}
/**
- * @deprecated
+ * @deprecated use $DB->get_records_select() instead
+ * @see moodle_database::get_records_select()
* @param mixed $table
* @param mixed $select
* @param mixed $sort
error('get_records_select() not available anymore');
}
/**
- * @deprecated
+ * @deprecated use $DB->get_field_select() instead
+ * @see moodle_database::get_field_select()
* @param mixed $table
* @param mixed $return
* @param mixed $select
error('get_field_select() not available anymore');
}
/**
- * @deprecated
+ * @deprecated use $DB->get_field_sql() instead
+ * @see moodle_database::get_field_sql()
* @param mixed $sql
* @return void Throws an error and does nothing
*/
error('get_field_sql() not available anymore');
}
/**
- * @deprecated
+ * @deprecated use $DB->delete_records_select() instead
+ * @see moodle_database::delete_records_select()
* @param mixed $sql
* @param mixed $select
* @return void Throws an error and does nothing
error('execute_sql_arr() removed');
}
/**
- * @deprecated
+ * @deprecated use $DB->get_records_list() instead
+ * @see moodle_database::get_records_list()
* @param mixed $table
* @param mixed $field
* @param mixed $values
error('get_records_list() removed');
}
/**
- * @deprecated
+ * @deprecated use $DB->get_recordset_list() instead
+ * @see moodle_database::get_recordset_list()
* @param mixed $table
* @param mixed $field
* @param mixed $values
error('get_recordset_list() removed');
}
/**
- * @deprecated
+ * @deprecated use $DB->get_records_menu() instead
+ * @see moodle_database::get_records_menu()
* @param mixed $table
* @param mixed $field
* @param mixed $value
error('get_records_menu() removed');
}
/**
- * @deprecated
+ * @deprecated use $DB->get_records_select_menu() instead
+ * @see moodle_database::get_records_select_menu()
* @param mixed $table
* @param mixed $select
* @param mixed $sort
error('get_records_select_menu() removed');
}
/**
- * @deprecated
+ * @deprecated use $DB->get_records_sql_menu() instead
+ * @see moodle_database::get_records_sql_menu()
* @param mixed $sql
* @param mixed $limitfrom
* @param mixed $limitnum
error('records_to_menu() removed');
}
/**
- * @deprecated
+ * @deprecated use $DB->set_field_select() instead
+ * @see moodle_database::set_field_select()
* @param mixed $table
* @param mixed $newfield
* @param mixed $newvalue
error('set_field_select() removed');
}
/**
- * @deprecated
+ * @deprecated use $DB->get_fieldset_select() instead
+ * @see moodle_database::get_fieldset_select()
* @param mixed $table
* @param mixed $return
* @param mixed $select
error('get_fieldset_select() removed');
}
/**
- * @deprecated
+ * @deprecated use $DB->get_fieldset_sql() instead
+ * @see moodle_database::get_fieldset_sql()
* @param mixed $sql
* @return void Throws an error and does nothing
*/
error('get_fieldset_sql() removed');
}
/**
- * @deprecated
+ * @deprecated use $DB->sql_like() instead
+ * @see moodle_database::sql_like()
* @return void Throws an error and does nothing
*/
function sql_ilike() {
error('rollback_sql() not available anymore');
}
/**
- * @deprecated
+ * @deprecated use $DB->insert_record() instead
+ * @see moodle_database::insert_record()
* @param mixed $table
* @param mixed $dataobject
* @param mixed $returnid
error('insert_record() not available anymore');
}
/**
- * @deprecated
+ * @deprecated use $DB->update_record() instead
+ * @see moodle_database::update_record()
* @param mixed $table
* @param mixed $dataobject
* @return void Throws an error and does nothing
error('update_record() not available anymore');
}
/**
- * @deprecated
+ * @deprecated use $DB->get_records() instead
+ * @see moodle_database::get_records()
* @param mixed $table
* @param mixed $field
* @param mixed $value
error('get_records() not available anymore');
}
/**
- * @deprecated
+ * @deprecated use $DB->get_record() instead
+ * @see moodle_database::get_record()
* @param mixed $table
* @param mixed $field1
* @param mixed $value1
error('get_record() not available anymore');
}
/**
- * @deprecated
+ * @deprecated use $DB->set_field() instead
+ * @see moodle_database::set_field()
* @param mixed $table
* @param mixed $newfield
* @param mixed $newvalue
error('set_field() not available anymore');
}
/**
- * @deprecated
+ * @deprecated use $DB->count_records() instead
+ * @see moodle_database::count_records()
* @param mixed $table
* @param mixed $field1
* @param mixed $value1
error('count_records() not available anymore');
}
/**
- * @deprecated
+ * @deprecated use $DB->record_exists() instead
+ * @see moodle_database::record_exists()
* @param mixed $table
* @param mixed $field1
* @param mixed $value1
error('record_exists() not available anymore');
}
/**
- * @deprecated
+ * @deprecated use $DB->delete_records() instead
+ * @see moodle_database::delete_records()
* @param mixed $table
* @param mixed $field1
* @param mixed $value1
error('delete_records() not available anymore');
}
/**
- * @deprecated
+ * @deprecated use $DB->get_field() instead
+ * @see moodle_database::get_field()
* @param mixed $table
* @param mixed $return
* @param mixed $field1
return $this->tables;
}
$this->tables = array();
- $prefix = str_replace('_', '\\\\_', $this->prefix);
+ $prefix = str_replace('_', '|_', $this->prefix);
// Get them from information_schema instead of catalog as far as
// we want to get only own session temp objects (catalog returns all)
$sql = "SELECT table_name
FROM information_schema.tables
- WHERE table_name LIKE '$prefix%'
+ WHERE table_name LIKE '$prefix%' ESCAPE '|'
AND table_type IN ('BASE TABLE', 'LOCAL TEMPORARY')";
$this->query_start($sql, null, SQL_QUERY_AUX);
$result = pg_query($this->pgsql, $sql);
if (isset($functions[$function->name]['description'])) {
$function->description = $functions[$function->name]['description'];
}
+ if (isset($functions[$function->name]['testclientpath'])) {
+ $function->testclientpath = $functions[$function->name]['testclientpath'];
+ }
}
return $function;
* @param $filename
*/
public function get_file_info($component, $filearea, $itemid, $filepath, $filename) {
+ // try to emulate require_login() tests here
+ if (!isloggedin()) {
+ return null;
+ }
+
if (!$this->course->visible and !has_capability('moodle/course:viewhiddencourses', $this->context)) {
return null;
}
+ if (!is_viewing($this->context) and !is_enrolled($this->context)) {
+ // no peaking here if not enrolled or inspector
+ return null;
+ }
+
if (empty($component)) {
return $this;
}
* @param $filename
*/
public function get_file_info($component, $filearea, $itemid, $filepath, $filename) {
- if (!is_enrolled($this->context) and !is_viewing($this->context)) {
+ // try to emulate require_login() tests here
+ if (!isloggedin()) {
+ return null;
+ }
+
+ $coursecontext = get_course_context($this->context);
+ if (!$this->course->visible and !has_capability('moodle/course:viewhiddencourses', $coursecontext)) {
+ return null;
+ }
+
+ if (!is_viewing($this->context) and !is_enrolled($this->context)) {
// no peaking here if not enrolled or inspector
return null;
}
+ $modinfo = get_fast_modinfo($this->course);
+ $cminfo = $modinfo->get_cm($this->cm->id);
+ if (!$cminfo->uservisible) {
+ // activity hidden sorry
+ return null;
+ }
+
if (empty($component)) {
return $this;
}
require_once 'HTML/QuickForm.php';
require_once 'HTML/QuickForm/DHTMLRulesTableless.php';
require_once 'HTML/QuickForm/Renderer/Tableless.php';
+require_once 'HTML/QuickForm/Rule.php';
require_once $CFG->libdir.'/filelib.php';
}
}
+/**
+ * Required elements validation
+ * This class overrides QuickForm validation since it allowed space or empty tag as a value
+ */
+class MoodleQuickForm_Rule_Required extends HTML_QuickForm_Rule {
+ /**
+ * Checks if an element is not empty.
+ * This is a server-side validation, it works for both text fields and editor fields
+ *
+ * @param string $value Value to check
+ * @param mixed $options Not used yet
+ * @return boolean true if value is not empty
+ */
+ function validate($value, $options = null) {
+ global $CFG;
+ if (is_array($value) && array_key_exists('text', $value)) {
+ $value = $value['text'];
+ }
+ $stripvalues = array(
+ '#</?(?!img|canvas|hr).*?>#im', // all tags except img, canvas and hr
+ '#(\xc2|\xa0|\s| )#', //any whitespaces actually
+ );
+ if (!empty($CFG->strictformsrequired)) {
+ $value = preg_replace($stripvalues, '', (string)$value);
+ }
+ if ((string)$value == '') {
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * This function returns Javascript code used to build client-side validation.
+ * It checks if an element is not empty.
+ * Note, that QuickForm does not know how to work with editor text field and builds not correct
+ * JS code for validation. If client check is enabled for editor field it will not be validated
+ * on client side no matter what this function returns.
+ *
+ * @param mixed $options Not used yet
+ * @return array
+ */
+ function getValidationScript($options = null) {
+ global $CFG;
+ if (!empty($CFG->strictformsrequired)) {
+ return array('', "{jsVar}.replace(/^\s+$/g, '') == ''");
+ } else {
+ return array('', "{jsVar} == ''");
+ }
+ }
+}
+
/**
* @global object $GLOBALS['_HTML_QuickForm_default_renderer']
* @name $_HTML_QuickForm_default_renderer
MoodleQuickForm::registerElementType('textarea', "$CFG->libdir/form/textarea.php", 'MoodleQuickForm_textarea');
MoodleQuickForm::registerElementType('url', "$CFG->libdir/form/url.php", 'MoodleQuickForm_url');
MoodleQuickForm::registerElementType('warning', "$CFG->libdir/form/warning.php", 'MoodleQuickForm_warning');
+
+MoodleQuickForm::registerRule('required', null, 'MoodleQuickForm_Rule_Required', "$CFG->libdir/formslib.php");
* @return void
*/
function _group_verify_activegroup($courseid, $groupmode, $groupingid, array $allowedgroups) {
- global $SESSION;
+ global $SESSION, $USER;
// init activegroup array if necessary
if (!isset($SESSION->activegroup)) {
$SESSION->activegroup[$courseid][$groupmode][$groupingid] = 0; // all groups by default if user has accessallgroups
} else if ($allowedgroups) {
- $firstgroup = reset($allowedgroups);
+ if ($groupmode != SEPARATEGROUPS and $mygroups = groups_get_all_groups($courseid, $USER->id, $groupingid)) {
+ $firstgroup = reset($mygroups);
+ } else {
+ $firstgroup = reset($allowedgroups);
+ }
$SESSION->activegroup[$courseid][$groupmode][$groupingid] = $firstgroup->id;
} else {
echo '<html dir="'.(right_to_left() ? 'rtl' : 'ltr').'">
<head>
<link rel="shortcut icon" href="theme/standard/pix/favicon.ico" />
- <link rel="stylesheet" type="text/css" href="'.$CFG->wwwroot.'/install.php?css=1" />
+ <link rel="stylesheet" type="text/css" href="'.$CFG->wwwroot.'/install/css.php" />
<title>'.get_string('installation','install').'</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<meta http-equiv="pragma" content="no-cache" />
<head>
<link rel="shortcut icon" href="theme/standard/pix/favicon.ico" />';
- $sheets = array('pagelayout','core');
- $csss = array();
- foreach ($sheets as $sheet) {
- $csss[] = $CFG->wwwroot.'/theme/base/style/'.$sheet.'.css';
- }
- $sheets = array('core', 'css3');
- foreach ($sheets as $sheet) {
- $csss[] = $CFG->wwwroot.'/theme/standard/style/'.$sheet.'.css';
- }
- foreach ($csss as $css) {
- echo '<link rel="stylesheet" type="text/css" href="'.$css.'" />'."\n";
- }
-
- echo '<link rel="stylesheet" type="text/css" href="'.$CFG->wwwroot.'/install.php?css=1" />
+ echo '<link rel="stylesheet" type="text/css" href="'.$CFG->wwwroot.'/install/css.php" />
<title>'.get_string('installation','install').' - Moodle '.$CFG->target_release.'</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<meta http-equiv="pragma" content="no-cache" />
echo '</div></body></html>';
}
-
-/**
- * Prints css needed on installation page, tries to look like the rest of installation.
- * Does not return.
- *
- * @global object
- */
-function install_css_styles() {
- global $CFG;
-
- @header('Content-type: text/css'); // Correct MIME type
- @header('Cache-Control: no-store, no-cache, must-revalidate');
- @header('Cache-Control: post-check=0, pre-check=0', false);
- @header('Pragma: no-cache');
- @header('Expires: Mon, 20 Aug 1969 09:23:00 GMT');
- @header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
-
-//TODO: add rtl support here, make it match new default theme MDL-21149
-
- echo '
-
-h2 {
- text-align:center;
-}
-
-#installdiv {
- width: 800px;
- margin-left:auto;
- margin-right:auto;
-}
-
-#installdiv dt {
- font-weight: bold;
-}
-
-#installdiv dd {
- padding-bottom: 0.5em;
-}
-
-.stage {
- margin-top: 2em;
- margin-bottom: 2em;
- width: 100%;
- padding:25px;
-}
-
-#installform {
- width: 100%;
-}
-
-#nav_buttons input {
- margin: 5px;
-}
-
-#envresult {
- text-align:left;
- width: auto;
- margin-left:10em;
-}
-
-#envresult dd {
- color: red;
-}
-
-.formrow {
- clear:both;
- text-align:left;
- padding: 8px;
-}
-
-.formrow label.formlabel {
- display:block;
- float:left;
- width: 260px;
- margin-right:5px;
- text-align:right;
-}
-
-.formrow .forminput {
- display:block;
- float:left;
-}
-
-fieldset {
- text-align:center;
- border:none;
-}
-
-.hint {
- display:block;
- clear:both;
- padding-left: 265px;
- color: red;
-}
-
-.configphp {
- text-align:left;
- background-color:white;
- padding:1em;
- width:95%;
-}
-
-.stage6 .stage {
- font-weight: bold;
- color: red;
-}
-
-';
-
- die;
-}
-
/**
* Install Moodle DB,
* config.php must exist, there must not be any tables in db yet.
var filteredCollection = [];
for (var i = 0; i < elCollection.length; ++i) {
var findParent = parentFinder(elCollection[i]);
- if (findParent.nodeName.toUpperCase != 'BODY') {
+ if (findParent.nodeName.toUpperCase() != 'BODY') {
filteredCollection.push(elCollection[i]);
}
}
*
* Any plugin that needs to purge user data should register the 'user_deleted' event.
*
- * @param object $user User object before delete
+ * @param stdClass $user full user object before delete
* @return boolean always true
*/
function delete_user($user) {
// last course access not necessary either
$DB->delete_records('user_lastaccess', array('userid'=>$user->id));
+ // force logout - may fail if file based sessions used, sorry
+ session_kill_user($user->id);
+
// now do a final accesslib cleanup - removes all role assignments in user context and context itself
delete_context(CONTEXT_USER, $user->id);
$namingfunction = 'callback_'.$courseformat.'_get_section_name';
$namingfunctionexists = (function_exists($namingfunction));
- $activesection = course_get_display($course->id);
+
$viewhiddensections = has_capability('moodle/course:viewhiddensections', $this->page->context);
+ $urlfunction = 'callback_'.$courseformat.'_get_section_url';
+ if (empty($CFG->navlinkcoursesections) || !function_exists($urlfunction)) {
+ $urlfunction = null;
+ }
+
+ $keyfunction = 'callback_'.$courseformat.'_request_key';
+ $key = course_get_display($course->id);
+ if (defined('AJAX_SCRIPT') && AJAX_SCRIPT == '0' && function_exists($keyfunction) && $this->page->url->compare(new moodle_url('/course/view.php'), URL_MATCH_BASE)) {
+ $key = optional_param($keyfunction(), $key, PARAM_INT);
+ }
+
$navigationsections = array();
foreach ($sections as $sectionid => $section) {
$section = clone($section);
} else {
$sectionname = get_string('section').' '.$section->section;
}
- //$url = new moodle_url('/course/view.php', array('id'=>$course->id));
+
$url = null;
+ if (!empty($urlfunction)) {
+ $url = $urlfunction($course->id, $section->section);
+ }
$sectionnode = $coursenode->add($sectionname, $url, navigation_node::TYPE_SECTION, null, $section->id);
$sectionnode->nodetype = navigation_node::NODETYPE_BRANCH;
$sectionnode->hidden = (!$section->visible);
- if ($this->page->context->contextlevel != CONTEXT_MODULE && $section->hasactivites && ($sectionnode->isactive || ($activesection && $section->section == $activesection))) {
- $sectionnode->force_open();
+ if ($key != '0' && $section->section != '0' && $section->section == $key && $this->page->context->contextlevel != CONTEXT_MODULE && $section->hasactivites) {
+ $sectionnode->make_active();
$this->load_section_activities($sectionnode, $section->section, $activities);
}
$section->sectionnode = $sectionnode;
if ($iscurrentuser && !$forceforcontext) {
// If it's the current user the information will go under the profile root node
$usernode = $this->rootnodes['myprofile'];
+ $course = get_site();
+ $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
+ $issitecourse = true;
} else {
if (!$issitecourse) {
// Not the current user so add it to the participants node for the current course
// Set Y's config.gallery to the version
$jscode = 'Y.config.gallery='.json_encode($galleryversion).';';
}
- $jscode .= 'Y.use('.join(',', array_map('json_encode', $modules)).',function() {'.js_writer::function_call($function, $arguments).'})';
+ $jscode .= 'Y.use('.join(',', array_map('json_encode', $modules)).',function() {'.js_writer::function_call($function, $arguments).'});';
if ($ondomready) {
$jscode = "Y.on('domready', function() { $jscode });";
}
* @return bool
*/
protected function magic_get_legacythemeinuse() {
- debugging('$PAGE->legacythemeinuse is a deprecated property - please use $PAGE->devicetypeinuse and check if it is equal to legacy.', DEVELOPER_DEBUG);
+ debugging('$PAGE->legacythemeinuse is a deprecated property - please use $PAGE->devicetypeinuse and check if it is equal to legacy.', DEBUG_DEVELOPER);
return ($this->devicetypeinuse == 'legacy');
}
$values[] = $this->getSubmitValue($elName);
}
$result = $registry->validate($rule['type'], $values, $rule['format'], true);
- } else if ($rule['type'] === 'required' and $this->getElement($target)->_type === 'editor') {
- //horrible horrible hack
- if (!isset($submitValue['text']) or $submitValue['text'] === '') {
- $result = false;
- } else {
- $result = true;
- }
} elseif (is_array($submitValue) && !isset($rule['howmany'])) {
$result = $registry->validate($rule['type'], $submitValue, $rule['format'], true);
} else {
4/ MDL-20876 - replaced deprecated split() with explode() or str_split() where appropriate
-5/ hardcoded editor element required rule validation
-
Such modifications should be carefully each time the Excel PEAR package is updated
to a new release within Moodle.
'wikimedia', 'youtube'
),
+ 'scormreport' => array(
+ 'basic'
+ ),
+
'theme' => array(
'afterburner', 'anomaly', 'arialist', 'base', 'binarius',
'boxxie', 'brick', 'canvas', 'formal_white', 'formfactor',
if (!isset($CFG->sessioncookie)) {
$CFG->sessioncookie = '';
}
+
+ // make sure cookie domain makes sense for this wwwroot
if (!isset($CFG->sessioncookiedomain)) {
$CFG->sessioncookiedomain = '';
+ } else if ($CFG->sessioncookiedomain !== '') {
+ $host = parse_url($CFG->wwwroot, PHP_URL_HOST);
+ if ($CFG->sessioncookiedomain !== $host) {
+ if (substr($CFG->sessioncookiedomain, 0, 1) === '.') {
+ if (!preg_match('|^.*'.preg_quote($CFG->sessioncookiedomain, '|').'$|', $host)) {
+ // invalid domain - it must be end part of host
+ $CFG->sessioncookiedomain = '';
+ }
+ } else {
+ if (!preg_match('|^.*\.'.preg_quote($CFG->sessioncookiedomain, '|').'$|', $host)) {
+ // invalid domain - it must be end part of host
+ $CFG->sessioncookiedomain = '';
+ }
+ }
+ }
}
+
+ // make sure the cookiepath is valid for this wwwroot or autodetect if not specified
if (!isset($CFG->sessioncookiepath)) {
- $CFG->sessioncookiepath = '/';
+ $CFG->sessioncookiepath = '';
+ }
+ if ($CFG->sessioncookiepath !== '/') {
+ $path = parse_url($CFG->wwwroot, PHP_URL_PATH).'/';
+ if ($CFG->sessioncookiepath === '') {
+ $CFG->sessioncookiepath = $path;
+ } else {
+ if (strpos($path, $CFG->sessioncookiepath) !== 0 or substr($CFG->sessioncookiepath, -1) !== '/') {
+ $CFG->sessioncookiepath = $path;
+ }
+ }
}
//discard session ID from POST, GET and globals to tighten security,
}
}
+ // when printing an error the continue button should never link offsite
+ if (stripos($link, $CFG->wwwroot) === false &&
+ stripos($link, $CFG->httpswwwroot) === false) {
+ $link = $CFG->wwwroot.'/';
+ }
+
$info = new stdClass();
$info->message = $message;
$info->errorcode = $errorcode;
// Used in load balancing scenarios.
// Do not abuse this to try to solve lan/wan access problems!!!!!
if (empty($CFG->reverseproxy)) {
- if (($rurl['host'] != $wwwroot['host']) or
+ if (empty($rurl['host'])) {
+ // missing host in request header, probably not a real browser, let's ignore them
+ } else if (($rurl['host'] !== $wwwroot['host']) or
(!empty($wwwroot['port']) and $rurl['port'] != $wwwroot['port'])) {
// Explain the problem and redirect them to the right URL
if (!defined('NO_MOODLE_COOKIES')) {
// hopefully this will stop all those "clever" admins trying to set up moodle
// with two different addresses in intranet and Internet
- if (!empty($CFG->reverseproxy) && $rurl['host'] == $wwwroot['host']) {
+ if (!empty($CFG->reverseproxy) && $rurl['host'] === $wwwroot['host']) {
print_error('reverseproxyabused', 'error');
}
*/
function setup_get_remote_url() {
$rurl = array();
- list($rurl['host']) = explode(':', $_SERVER['HTTP_HOST']);
+ if (isset($_SERVER['HTTP_HOST'])) {
+ list($rurl['host']) = explode(':', $_SERVER['HTTP_HOST']);
+ } else {
+ $rurl['host'] = null;
+ }
$rurl['port'] = $_SERVER['SERVER_PORT'];
$rurl['path'] = $_SERVER['SCRIPT_NAME']; // Script path without slash arguments
$rurl['scheme'] = (empty($_SERVER['HTTPS']) or $_SERVER['HTTPS'] === 'off' or $_SERVER['HTTPS'] === 'Off' or $_SERVER['HTTPS'] === 'OFF') ? 'http' : 'https';
--- /dev/null
+<?php
+
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
+
+
+/**
+ * Unit tests for /lib/formslib.php.
+ *
+ * @package file
+ * @copyright 2011 Sam Hemelryk
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+if (!defined('MOODLE_INTERNAL')) {
+ die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
+}
+require_once($CFG->libdir . '/formslib.php');
+
+class formslib_test extends UnitTestCase {
+
+ public function test_require_rule() {
+ global $CFG;
+
+ $strictformsrequired = false;
+ if (!empty($CFG->strictformsrequired)) {
+ $strictformsrequired = $CFG->strictformsrequired;
+ }
+
+ $rule = new MoodleQuickForm_Rule_Required();
+
+ // First run the tests with strictformsrequired off
+ $CFG->strictformsrequired = false;
+ // Passes
+ $this->assertTrue($rule->validate('Something'));
+ $this->assertTrue($rule->validate("Something\nmore"));
+ $this->assertTrue($rule->validate("\nmore"));
+ $this->assertTrue($rule->validate(" more "));
+ $this->assertTrue($rule->validate("0"));
+ $this->assertTrue($rule->validate(0));
+ $this->assertTrue($rule->validate(true));
+ $this->assertTrue($rule->validate(' '));
+ $this->assertTrue($rule->validate(' '));
+ $this->assertTrue($rule->validate("\t"));
+ $this->assertTrue($rule->validate("\n"));
+ $this->assertTrue($rule->validate("\r"));
+ $this->assertTrue($rule->validate("\r\n"));
+ $this->assertTrue($rule->validate(" \t \n \r "));
+ $this->assertTrue($rule->validate('<p></p>'));
+ $this->assertTrue($rule->validate('<p> </p>'));
+ $this->assertTrue($rule->validate('<p>x</p>'));
+ $this->assertTrue($rule->validate('<img src="smile.jpg" alt="smile" />'));
+ $this->assertTrue($rule->validate('<img src="smile.jpg" alt="smile"/>'));
+ $this->assertTrue($rule->validate('<img src="smile.jpg" alt="smile"></img>'));
+ $this->assertTrue($rule->validate('<hr />'));
+ $this->assertTrue($rule->validate('<hr/>'));
+ $this->assertTrue($rule->validate('<hr>'));
+ $this->assertTrue($rule->validate('<hr></hr>'));
+ $this->assertTrue($rule->validate('<br />'));
+ $this->assertTrue($rule->validate('<br/>'));
+ $this->assertTrue($rule->validate('<br>'));
+ $this->assertTrue($rule->validate(' '));
+ // Fails
+ $this->assertFalse($rule->validate(''));
+ $this->assertFalse($rule->validate(false));
+ $this->assertFalse($rule->validate(null));
+
+ // Now run the same tests with it on to make sure things work as expected
+ $CFG->strictformsrequired = true;
+ // Passes
+ $this->assertTrue($rule->validate('Something'));
+ $this->assertTrue($rule->validate("Something\nmore"));
+ $this->assertTrue($rule->validate("\nmore"));
+ $this->assertTrue($rule->validate(" more "));
+ $this->assertTrue($rule->validate("0"));
+ $this->assertTrue($rule->validate(0));
+ $this->assertTrue($rule->validate(true));
+ $this->assertTrue($rule->validate('<p>x</p>'));
+ $this->assertTrue($rule->validate('<img src="smile.jpg" alt="smile" />'));
+ $this->assertTrue($rule->validate('<img src="smile.jpg" alt="smile"/>'));
+ $this->assertTrue($rule->validate('<img src="smile.jpg" alt="smile"></img>'));
+ $this->assertTrue($rule->validate('<hr />'));
+ $this->assertTrue($rule->validate('<hr/>'));
+ $this->assertTrue($rule->validate('<hr>'));
+ $this->assertTrue($rule->validate('<hr></hr>'));
+ // Fails
+ $this->assertFalse($rule->validate(' '));
+ $this->assertFalse($rule->validate(' '));
+ $this->assertFalse($rule->validate("\t"));
+ $this->assertFalse($rule->validate("\n"));
+ $this->assertFalse($rule->validate("\r"));
+ $this->assertFalse($rule->validate("\r\n"));
+ $this->assertFalse($rule->validate(" \t \n \r "));
+ $this->assertFalse($rule->validate('<p></p>'));
+ $this->assertFalse($rule->validate('<p> </p>'));
+ $this->assertFalse($rule->validate('<br />'));
+ $this->assertFalse($rule->validate('<br/>'));
+ $this->assertFalse($rule->validate('<br>'));
+ $this->assertFalse($rule->validate(' '));
+ $this->assertFalse($rule->validate(''));
+ $this->assertFalse($rule->validate(false));
+ $this->assertFalse($rule->validate(null));
+
+ $CFG->strictformsrequired = $strictformsrequired;
+ }
+
+}
\ No newline at end of file
gc_collect_cycles(); // This was really helpful in PHP 5.2. Perhaps remove.
$a = new stdClass();
$a->done = $done;
- $a->todo = $outof;
+ $a->outof = $outof;
$this->progressbar->update($done, $outof,
get_string('resettingquizattemptsprogress', 'local_qeupgradehelper', $a));
}
*
* @param mixed $frm submitted form data
* @param bool $showicontext show text next to action icons?
- * @param object $user1 the current user
+ * @param object $currentuser the current user
* @return void
*/
-function message_print_search_results($frm, $showicontext=false, $user1=null) {
+function message_print_search_results($frm, $showicontext=false, $currentuser=null) {
global $USER, $DB, $OUTPUT;
- if (empty($user1)) {
- $user1 = $USER;
+ if (empty($currentuser)) {
+ $currentuser = $USER;
}
echo html_writer::start_tag('div', array('class' => 'mdl-left'));
echo message_get_fragment($message->fullmessage, $keywords);
echo html_writer::start_tag('div', array('class' => 'link'));
- //find the user involved that isn't the current user
- $user2id = null;
- if ($user1->id == $message->useridto) {
- $user2id = $message->useridfrom;
+ //If the user clicks the context link display message sender on the left
+ //EXCEPT if the current user is in the conversation. Current user == always on the left
+ $leftsideuserid = $rightsideuserid = null;
+ if ($currentuser->id == $message->useridto) {
+ $leftsideuserid = $message->useridto;
+ $rightsideuserid = $message->useridfrom;
} else {
- $user2id = $message->useridto;
+ $leftsideuserid = $message->useridfrom;
+ $rightsideuserid = $message->useridto;
}
- message_history_link($user1->id, $user2id, false,
+ message_history_link($leftsideuserid, $rightsideuserid, false,
$messagesearchstring, 'm'.$message->id, $strcontext);
echo html_writer::end_tag('div');
echo html_writer::end_tag('td');
* echo or return a link to take the user to the full message history between themselves and another user
*
* @staticvar type $strmessagehistory
- * @param int $userid1 the ID of the current user
+ * @param int $userid1 the ID of the user displayed on the left (usually the current user)
* @param int $userid2 the ID of the other user
* @param bool $return true to return the link as a string. False to echo the link.
* @param string $keywords any keywords to highlight in the message history
*/
function message_history_link($userid1, $userid2, $return=false, $keywords='', $position='', $linktext='') {
global $OUTPUT;
-
static $strmessagehistory;
if (empty($strmessagehistory)) {
'scrollbars' => true,
'resizable' => true);
- $link = new moodle_url('/message/index.php?history='.MESSAGE_HISTORY_ALL."&user=$userid1&id=$userid2$keywords$position");
+ $link = new moodle_url('/message/index.php?history='.MESSAGE_HISTORY_ALL."&user1=$userid1&user2=$userid2$keywords$position");
$action = null;
$str = $OUTPUT->action_link($link, $fulllink, $action, array('title' => $strmessagehistory));
$string['existingfiledeleted'] = 'Existing file has been deleted: {$a}';
$string['failedupdatefeedback'] = 'Failed to update submission feedback for user {$a}';
$string['feedback'] = 'Feedback';
-$string['feedbackfromteacher'] = 'Feedback from the {$a}';
+$string['feedbackfromteacher'] = 'Feedback from {$a}';
$string['feedbackupdated'] = 'Submissions feedback updated for {$a} people';
$string['finalize'] = 'Prevent submission updates';
$string['finalizeerror'] = 'An error occurred and that submission could not be finalised';
$string['displaymode'] = 'Display mode';
$string['displayvertical'] = 'Display vertically';
$string['expired'] = 'Sorry, this activity closed on {$a} and is no longer available';
-$string['fillinatleastoneoption'] = 'You need to provide at least two possible answers.';
+$string['atleastoneoption'] = 'You need to provide at least one possible answer.';
$string['full'] = '(Full)';
$string['havetologin'] = 'You have to log in before you can submit your choice';
$string['choice'] = 'Choice';
}
if ($choices < 1) {
- $errors['option[0]'] = get_string('fillinatleastoneoption', 'choice');
- }
-
- if ($choices < 2) {
- $errors['option[1]'] = get_string('fillinatleastoneoption', 'choice');
+ $errors['option[0]'] = get_string('atleastoneoption', 'choice');
}
return $errors;
// This fragment is called by /admin/index.php
////////////////////////////////////////////////////////////////////////////////
-$module->version = 2010101300;
+$module->version = 2010101301;
$module->requires = 2010080300; // Requires this Moodle version
$module->cron = 0;
$pbar = new progress_bar('q15upgrade');
$pbar->create();
$a = new stdClass();
- $a->todo = count($oldattempts);
+ $a->outof = count($oldattempts);
$a->done = 0;
- $pbar->update($a->done, $a->todo,
+ $pbar->update($a->done, $a->outof,
get_string('upgradingveryoldquizattempts', 'quiz', $a));
foreach ($oldattempts as $oldattempt) {
quiz_upgrade_very_old_question_sessions($oldattempt);
$a->done += 1;
- $pbar->update($a->done, $a->todo,
+ $pbar->update($a->done, $a->outof,
get_string('upgradingveryoldquizattempts', 'quiz', $a));
}
}
$quizhasattempts = quiz_has_attempts($quiz->id);
$PAGE->set_url($thispageurl);
-$PAGE->set_pagelayout('admin');
$pagetitle = get_string('editingquiz', 'quiz');
if ($quiz_reordertool) {
$reordercheckboxlabel = '<label for="s' . $question->id . '">';
$reordercheckboxlabelclose = '</label>';
}
- if (!$quiz->shufflequestions) {
- // Print and increment question number
- $questioncountstring = '';
- if ($questioncount>999 || ($reordertool && $questioncount>99)) {
- $questioncountstring =
- "$reordercheckboxlabel<small>$questioncount</small>" .
- $reordercheckboxlabelclose . $reordercheckbox;
+ if ($question->length == 0) {
+ $qnodisplay = get_string('infoshort', 'quiz');
+ } else if ($quiz->shufflequestions) {
+ $qnodisplay = '?';
+ } else {
+ if ($qno > 999 || ($reordertool && $qno > 99)) {
+ $qnodisplay = html_writer::tag('small', $qno);
} else {
- $questioncountstring = $reordercheckboxlabel . $questioncount .
- $reordercheckboxlabelclose . $reordercheckbox;
+ $qnodisplay = $qno;
}
- echo $questioncountstring;
$qno += $question->length;
- } else {
- echo "$reordercheckboxlabel ? $reordercheckboxlabelclose" .
- " $reordercheckbox";
}
+ echo $reordercheckboxlabel . $qnodisplay . $reordercheckboxlabelclose .
+ $reordercheckbox;
?>
</div>
$output .= $this->review_summary_table($summarydata, $page);
$output .= $this->review_form($page, $showall, $displayoptions,
$this->questions($attemptobj, true, $slots, $page, $showall, $displayoptions),
- $attemptobj, $showall);
+ $attemptobj);
$output .= $this->review_next_navigation($attemptobj, $page, $lastpage);
$output .= $this->footer();
* @param quiz_attempt $attemptobj instance of quiz_attempt
* @param bool $showall if true display attempt on one page
*/
- public function review_form($summarydata, $page, $displayoptions, $content, $attemptobj,
- $showall) {
+ public function review_form($page, $showall, $displayoptions, $content, $attemptobj) {
if ($displayoptions->flags != question_display_options::EDITABLE) {
return $content;
}
$output .= $this->view_information($course, $quiz, $cm, $context, $messages);
$guestno = html_writer::tag('p', get_string('guestsno', 'quiz'));
$liketologin = html_writer::tag('p', get_string('liketologin'));
- $output .= $this->confirm($guestno.'\n\n'.$liketologin.'\n', get_login_url(),
+ $output .= $this->confirm($guestno."\n\n".$liketologin."\n", get_login_url(),
get_referer(false));
return $output;
}
$youneedtoenrol = html_writer::tag('p', get_string('youneedtoenrol', 'quiz'));
$button = html_writer::tag('p',
$this->continue_button($CFG->wwwroot . '/course/view.php?id=' . $course->id));
- $output .= $this->box($youneedtoenrol.'\n\n'.$button.'\n', 'generalbox', 'notice');
+ $output .= $this->box($youneedtoenrol."\n\n".$button."\n", 'generalbox', 'notice');
return $output;
}
if ($viewobj->mygradeoverridden) {
$resultinfo .= html_writer::tag('p', get_string('overriddennotice', 'grades'),
- array('class' => 'overriddennotice')).'\n';
+ array('class' => 'overriddennotice'))."\n";
}
if ($viewobj->gradebookfeedback) {
$resultinfo .= $this->heading(get_string('comment', 'quiz'), 3, 'main');
$resultinfo .= $this->heading(get_string('overallfeedback', 'quiz'), 3, 'main');
$resultinfo .= html_writer::tag('p',
quiz_feedback_for_grade($viewobj->mygrade, $quiz, $context),
- array('class' => 'quizgradefeedback')).'\n';
+ array('class' => 'quizgradefeedback'))."\n";
}
if ($resultinfo) {
$string['allattempts'] = 'Show all attempts';
$string['allattemptscontributetograde'] = 'All attempts contribute to final grade for user.';
$string['allstudents'] = 'Show all {$a}';
-$string['attemptprogress'] = 'Attempt {$a->done} of {$a->todo}';
$string['attemptsonly'] = 'Show {$a} with attempts only';
$string['attemptsprepage'] = 'Attempts shown per page';
$string['deleteselected'] = 'Delete selected attempts';
$string['preferencespage'] = 'Preferences just for this page';
$string['preferencessave'] = 'Show report';
$string['preferencesuser'] = 'Your preferences for this report';
-$string['qprogress'] = 'Question {$a->done} of {$a->todo}';
$string['regrade'] = 'Regrade';
$string['regradeall'] = 'Regrade all';
$string['regradealldry'] = 'Dry run a full regrade';
// Back to overview link.
echo $OUTPUT->box('<a href="' . $reporturl->out() . '">' .
get_string('backtoquizreport', 'quiz_statistics') . '</a>',
- 'boxaligncenter generalbox boxwidthnormal mdl-align');
+ 'backtomainstats boxaligncenter generalbox boxwidthnormal mdl-align');
} else if ($qid) {
// Report on an individual sub-question indexed questionid.
echo $OUTPUT->box(format_text($question->questiontext, $question->questiontextformat,
array('overflowdiv' => true)) . $actions,
- 'boxaligncenter generalbox boxwidthnormal mdl-align');
+ 'questiontext boxaligncenter generalbox boxwidthnormal mdl-align');
echo $OUTPUT->heading(get_string('questionstatistics', 'quiz_statistics'));
echo html_writer::table($questionstatstable);
/**
* @return bool whether this analysis has a response class more than one
- * different acutal response.
+ * different acutal response, or if the actual response is different from
+ * the model response.
*/
public function has_actual_responses() {
foreach ($this->responseclasses as $subpartid => $partclasses) {
- foreach ($partclasses as $responseclassid => $notused) {
- if (count($this->responses[$subpartid][$responseclassid]) > 1) {
+ foreach ($partclasses as $responseclassid => $modelresponse) {
+ $numresponses = count($this->responses[$subpartid][$responseclassid]);
+ if ($numresponses > 1) {
+ return true;
+ }
+ $actualresponse = key($this->responses[$subpartid][$responseclassid]);
+ if ($numresponses == 1 && $actualresponse != $modelresponse->responseclass) {
return true;
}
}
.ie6#page-mod-quiz-edit div.question div.content .questionname {width:20%;}
.ie6#page-mod-quiz-edit .editq div.question div.content .randomquestioncategory a{width:40%;}
.ie6#page-mod-quiz-edit .reorder .questioncontentcontainer .randomquestioncategory label{width: 35%;}
+.qnum label {padding-right: 0.25em;}
/** settings.php */
#adminquizreviewoptions {margin-bottom: 0.5em;}
'cmi.learner_preference.delivery_speed':{'defaultvalue':'1', 'format':CMIDecimal, 'range':speed_range, 'mod':'rw'},
'cmi.learner_preference.audio_captioning':{'defaultvalue':'0', 'format':CMISInteger, 'range':text_range, 'mod':'rw'},
'cmi.location':{'defaultvalue':<?php echo isset($userdata->{'cmi.location'})?'\''.$userdata->{'cmi.location'}.'\'':'null' ?>, 'format':CMIString1000, 'mod':'rw'},
- 'cmi.max_time_allowed':{'defaultvalue':<?php echo isset($userdata->maxtimeallowed)?'\''.$userdata->maxtimeallowed.'\'':'null' ?>, 'mod':'r'},
+ 'cmi.max_time_allowed':{'defaultvalue':<?php echo isset($userdata->attemptAbsoluteDurationLimit)?'\''.$userdata->attemptAbsoluteDurationLimit.'\'':'null' ?>, 'mod':'r'},
'cmi.mode':{'defaultvalue':'<?php echo $userdata->mode ?>', 'mod':'r'},
'cmi.objectives._children':{'defaultvalue':objectives_children, 'mod':'r'},
'cmi.objectives._count':{'mod':'r', 'defaultvalue':'0'},
<?xml version="1.0" encoding="UTF-8" ?>
-<XMLDB PATH="mod/scorm/db" VERSION="20090420" COMMENT="XMLDB file for Moodle mod/scorm"
+<XMLDB PATH="mod/scorm/db" VERSION="20110731" COMMENT="XMLDB file for Moodle mod/scorm"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../lib/xmldb/xmldb.xsd"
>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="scoid"/>
<FIELD NAME="scoid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="id" NEXT="primaryobj"/>
<FIELD NAME="primaryobj" TYPE="int" LENGTH="1" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" PREVIOUS="scoid" NEXT="objectiveid"/>
- <FIELD NAME="objectiveid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="primaryobj" NEXT="satisfiedbymeasure"/>
+ <FIELD NAME="objectiveid" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" PREVIOUS="primaryobj" NEXT="satisfiedbymeasure"/>
<FIELD NAME="satisfiedbymeasure" TYPE="int" LENGTH="1" NOTNULL="true" UNSIGNED="false" DEFAULT="1" SEQUENCE="false" PREVIOUS="objectiveid" NEXT="minnormalizedmeasure"/>
<FIELD NAME="minnormalizedmeasure" TYPE="float" LENGTH="11" NOTNULL="true" UNSIGNED="true" DEFAULT="0.0000" SEQUENCE="false" DECIMALS="4" PREVIOUS="satisfiedbymeasure"/>
</FIELDS>
</KEYS>
</TABLE>
</TABLES>
-</XMLDB>
+</XMLDB>
\ No newline at end of file
unset_config('updatetime', 'scorm');
upgrade_mod_savepoint(true, 2011021402, 'scorm');
}
+
+ if ($oldversion < 2011073100) {
+ // change field type of objectiveid
+ $table = new xmldb_table('scorm_seq_objective');
+ $field = new xmldb_field('objectiveid', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, 'primaryobj');
+ $dbman->change_field_type($table, $field);
+ upgrade_mod_savepoint(true, 2011073100, 'scorm');
+ }
return true;
}
$string['status'] = 'Status';
$string['statusbar'] = 'Show the status bar';
$string['student_response'] = 'Response';
+$string['subplugintype_scormreport'] = 'Report';
+$string['subplugintype_scormreport_plural'] = 'Reports';
$string['suspended'] = 'Suspended';
$string['syntax'] = 'Syntax error';
$string['tag_error'] = 'Unknown tag ({$a->tag}) with this content: {$a->value}';
$string['whatgradedesc'] = 'This preference sets the default attempts grading';
$string['width'] = 'Width';
$string['window'] = 'Window';
-$string['zlibwarning'] = 'Warning: PHP Zlib compression has been enabled on this site, some users may experience issues loading SCORM objects in certain web browsers.';
if (! $cm = get_coursemodule_from_instance('scorm', $scorm->id, $course->id)) {
print_error('invalidcoursemodule');
}
+ $contextmodule = get_context_instance(CONTEXT_MODULE, $cm->id);
+ if ((has_capability('mod/scorm:skipview', $contextmodule))) {
+ scorm_simple_play($scorm, $user, $contextmodule);
+ }
$colspan = '';
$headertext = '<table width="100%"><tr><td class="title">'.get_string('name').': <b>'.format_string($scorm->name).'</b>';
if (has_capability('moodle/course:manageactivities', $context)) {
}
if ($scorm->skipview >= 1) {
$sco = current($scoes);
- if (scorm_get_tracks($sco->id, $user->id) === false) {
- header('Location: player.php?a='.$scorm->id.'&scoid='.$sco->id.'¤torg='.$orgidentifier);
- $result = true;
- } else if ($scorm->skipview == 2) {
- header('Location: player.php?a='.$scorm->id.'&scoid='.$sco->id.'¤torg='.$orgidentifier);
- $result = true;
+ $url = new moodle_url('/mod/scorm/player.php', array('a' => $scorm->id,
+ 'currentorg'=>$orgidentifier,
+ 'scoid'=>$sco->id));
+ if ($scorm->skipview == 2 || scorm_get_tracks($sco->id, $user->id) === false) {
+ redirect($url);
}
}
}
if (!$CFG->slasharguments) {
$mform->addElement('static', '', '', $OUTPUT->notification(get_string('slashargs', 'scorm'), 'notifyproblem'));
}
- $zlib = ini_get('zlib.output_compression'); //check for zlib compression - if used, throw error because of IE bug. - SEE MDL-16185
- if (isset($zlib) && $zlib) {
- $mform->addElement('static', '', '', $OUTPUT->notification(get_string('zlibwarning', 'scorm'), 'notifyproblem'));
- }
//-------------------------------------------------------------------------------
$mform->addElement('header', 'general', get_string('general', 'form'));
}
scorm_layout_widget.setStyle('height', '100%');
+ var center = scorm_layout_widget.getUnitByPosition('center');
+ center.setStyle('height', '100%');
+
+ // calculate the rough new height
+ newheight = YAHOO.util.Dom.getViewportHeight() *.82;
+ if (newheight < 600) {
+ newheight = 600;
+ }
+ scorm_layout_widget.set('height', newheight);
+
scorm_layout_widget.render();
scorm_resize_frame();
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-$module->version = 2011060500; // The (date) version of this module
+$module->version = 2011073100; // The (date) version of this module
$module->requires = 2010080300; // The version of Moodle that is required
$module->cron = 300; // How often should cron check this module (seconds)?
add_to_log($course->id, 'scorm', 'pre-view', 'view.php?id='.$cm->id, "$scorm->id", $cm->id);
-if ((has_capability('mod/scorm:skipview', $contextmodule)) && scorm_simple_play($scorm, $USER, $contextmodule)) {
- exit;
+if ((has_capability('mod/scorm:skipview', $contextmodule))) {
+ scorm_simple_play($scorm, $USER, $contextmodule);
}
//
$string['neverseen'] = 'Never seen';
$string['optionsheader'] = 'Options';
$string['page-mod-url-x'] = 'Any URL module page';
-$string['parameterinfo'] = 'parameter=variable';
+$string['parameterinfo'] = '&parameter=variable';
$string['parametersheader'] = 'Parameters';
+$string['parametersheader_help'] = 'Some internal Moodle variables may be automatically appended to the URL. Type your name for the parameter into each text box(es) and then select the required matching variable.';
$string['pluginadministration'] = 'URL module administration';
$string['pluginname'] = 'URL';
$string['popupheight'] = 'Popup height (in pixels)';
//-------------------------------------------------------
$mform->addElement('header', 'parameterssection', get_string('parametersheader', 'url'));
-
+ $mform->addElement('static', 'parametersinfo', '', get_string('parametersheader_help', 'url'));
+ $mform->setAdvanced('parametersinfo');
if (empty($this->current->parameters)) {
$parcount = 5;
}
}
$PAGE->set_url($url);
-$PAGE->set_pagelayout('standard');
$qcobject = new question_category_object($pagevars['cpage'], $thispageurl, $contexts->having_one_edit_tab_cap('categories'), $param->edit, $pagevars['cat'], $param->delete,
$contexts->having_cap('moodle/question:add'));
$url->param('cmid', $cmid);
}
$PAGE->set_url($url);
-$PAGE->set_pagelayout('standard');
list($thispageurl, $contexts, $cmid, $cm, $module, $pagevars) =
question_edit_setup('questions', '/question/edit.php');
$contexts = null;
}
+ $PAGE->set_pagelayout('admin');
+
$pagevars['qpage'] = optional_param('qpage', -1, PARAM_INT);
//pass 'cat' from page to page and when 'category' comes from a drop down menu
'requires' => array('base', 'dom', 'event-delegate', 'io-base'),
);
$actionurl = $CFG->wwwroot . '/question/toggleflag.php';
+ $flagtext = array(
+ 0 => get_string('clickflag', 'question'),
+ 1 => get_string('clickunflag', 'question')
+ );
$flagattributes = array(
0 => array(
'src' => $OUTPUT->pix_url('i/unflagged') . '',
'title' => get_string('clicktoflag', 'question'),
'alt' => get_string('notflagged', 'question'),
+ // 'text' => get_string('clickflag', 'question'),
),
1 => array(
'src' => $OUTPUT->pix_url('i/flagged') . '',
'title' => get_string('clicktounflag', 'question'),
'alt' => get_string('flagged', 'question'),
+ // 'text' => get_string('clickunflag', 'question'),
),
);
$PAGE->requires->js_init_call('M.core_question_flags.init',
- array($actionurl, $flagattributes), false, $module);
+ array($actionurl, $flagattributes, $flagtext), false, $module);
$done = true;
}
}
* @return string the img tag.
*/
protected function get_flag_html($flagged, $id = '') {
+ if ($flagged) {
+ $icon = 'i/flagged';
+ $alt = get_string('flagged', 'question');
+ } else {
+ $icon = 'i/unflagged';
+ $alt = get_string('notflagged', 'question');
+ }
+ $attributes = array(
+ 'src' => $this->pix_url($icon),
+ 'alt' => $alt,
+ );
if ($id) {
- $id = 'id="' . $id . '" ';
+ $attributes['id'] = $id;
}
+ $img = html_writer::empty_tag('img', $attributes);
if ($flagged) {
- $img = 'flagged';
- } else {
- $img = 'unflagged';
+ $img .= ' ' . get_string('flagged', 'question');
}
- return '<img ' . $id . 'src="' . $this->pix_url('/i/' . $img) .
- '" alt="' . get_string('flagthisquestion', 'question') . '" />';
+ return $img;
}
protected function edit_question_link(question_attempt $qa,
require_once($CFG->dirroot . '/question/editlib.php');
require_once($CFG->dirroot . '/question/export_form.php');
-$PAGE->set_pagelayout('standard');
-
list($thispageurl, $contexts, $cmid, $cm, $module, $pagevars) =
question_edit_setup('export', '/question/export.php');
M.core_question_flags = {
flagattributes: null,
actionurl: null,
+ flagtext: null,
listeners: [],
- init: function(Y, actionurl, flagattributes) {
+ init: function(Y, actionurl, flagattributes, flagtext) {
M.core_question_flags.flagattributes = flagattributes;
M.core_question_flags.actionurl = actionurl;
+ M.core_question_flags.flagtext = flagtext;
Y.all('div.questionflag').each(function(flagdiv, i) {
var checkbox = flagdiv.one('input[type=checkbox]');
return;
}
- var input = Y.Node.create('<input type="hidden" />');
+ var input = Y.Node.create('<input type="hidden" class="questionflagvalue" />');
input.set('id', checkbox.get('id'));
input.set('name', checkbox.get('name'));
input.set('value', checkbox.get('checked') ? 1 : 0);
// Create an image input to replace the img tag.
var image = Y.Node.create('<input type="image" class="questionflagimage" />');
- M.core_question_flags.update_flag(input, image);
+ var flagtext = Y.Node.create('<span class="questionflagtext">.</span>');
+ M.core_question_flags.update_flag(input, image, flagtext);
checkbox.remove();
flagdiv.one('label').remove();
flagdiv.append(input);
flagdiv.append(image);
+ flagdiv.append(flagtext);
});
Y.delegate('click', function(e) {
- var input = this.previous('input');
+ var input = this.one('input.questionflagvalue');
input.set('value', 1 - input.get('value'));
- M.core_question_flags.update_flag(input, this);
- var postdata = this.previous('input.questionflagpostdata').get('value') +
+ M.core_question_flags.update_flag(input, this.one('input.questionflagimage'),
+ this.one('span.questionflagtext'));
+ var postdata = this.one('input.questionflagpostdata').get('value') +
input.get('value');
e.halt();
Y.io(M.core_question_flags.actionurl , {method: 'POST', 'data': postdata});
M.core_question_flags.fire_listeners(postdata);
- }, document.body, 'input.questionflagimage');
+ }, document.body, 'div.questionflag');
},
- update_flag: function(input, image) {
- image.setAttrs(M.core_question_flags.flagattributes[input.get('value')]);
+ update_flag: function(input, image, flagtext) {
+ var value = input.get('value');
+ image.setAttrs(M.core_question_flags.flagattributes[value]);
+ flagtext.replaceChild(flagtext.create(M.core_question_flags.flagtext[value]),
+ flagtext.get('firstChild'));
+ flagtext.set('title', M.core_question_flags.flagattributes[value].title);
},
add_listener: function(listener) {
} else {
// Must be the first line of a new question, since no recognised prefix.
$question->qtype = MULTICHOICE;
- $question->name = htmlspecialchars(substr($nowline, 0, 50));
- $question->questiontext = htmlspecialchars($nowline);
+ $question->name = shorten_text(s($nowline), 50);
+ $question->questiontext = s($nowline);
$question->single = 1;
$question->feedback[] = '';
}
print_error('nocategory', 'question');
}
-$PAGE->set_pagelayout('standard');
-
$categorycontext = get_context_instance_by_id($category->contextid);
$category->context = $categorycontext;
//this page can be called without courseid or cmid in which case
$thiscontext = get_context_instance(CONTEXT_MODULE, $cmid);
} elseif ($courseid) {
require_login($courseid, false);
- $PAGE->set_pagelayout('course');
$thiscontext = get_context_instance(CONTEXT_COURSE, $courseid);
$module = null;
$cm = null;
print_error('missingcourseorcmid', 'question');
}
$contexts = new question_edit_contexts($thiscontext);
+$PAGE->set_pagelayout('admin');
if (optional_param('addcancel', false, PARAM_BOOL)) {
redirect($returnurl);
$fs->move_area_files_to_new_context($oldcontextid,
$newcontextid, 'qtype_match', 'subquestion', $subquestionid);
}
+
+ $this->move_files_in_combined_feedback($questionid, $oldcontextid, $newcontextid);
}
protected function delete_files($questionid, $contextid) {
$fs->delete_area_files($contextid, 'qtype_match', 'subquestion', $subquestionid);
}
- $fs->delete_area_files($contextid, 'qtype_multichoice',
- 'correctfeedback', $questionid);
- $fs->delete_area_files($contextid, 'qtype_multichoice',
- 'partiallycorrectfeedback', $questionid);
- $fs->delete_area_files($contextid, 'qtype_multichoice',
- 'incorrectfeedback', $questionid);
+ $this->delete_files_in_combined_feedback($questionid, $contextid);
}
}
return $plugin;
}
-
- /**
- * Returns one array with filearea => mappingname elements for the qtype
- *
- * Used by {@link get_components_and_fileareas} to know about all the qtype
- * files to be processed both in backup and restore.
- */
- public static function get_qtype_fileareas() {
- return array(
- 'correctfeedback' => 'question_created',
- 'partiallycorrectfeedback' => 'question_created',
- 'incorrectfeedback' => 'question_created');
- }
}
}
public function move_files($questionid, $oldcontextid, $newcontextid) {
- $fs = get_file_storage();
-
parent::move_files($questionid, $oldcontextid, $newcontextid);
$this->move_files_in_answers($questionid, $oldcontextid, $newcontextid, true);
-
- $fs->move_area_files_to_new_context($oldcontextid,
- $newcontextid, 'qtype_multichoice', 'correctfeedback', $questionid);
- $fs->move_area_files_to_new_context($oldcontextid,
- $newcontextid, 'qtype_multichoice', 'partiallycorrectfeedback', $questionid);
- $fs->move_area_files_to_new_context($oldcontextid,
- $newcontextid, 'qtype_multichoice', 'incorrectfeedback', $questionid);
+ $this->move_files_in_combined_feedback($questionid, $oldcontextid, $newcontextid);
}
protected function delete_files($questionid, $contextid) {
- $fs = get_file_storage();
-
parent::delete_files($questionid, $contextid);
$this->delete_files_in_answers($questionid, $contextid, true);
-
- $fs->delete_area_files($contextid,
- 'qtype_multichoice', 'correctfeedback', $questionid);
- $fs->delete_area_files($contextid,
- 'qtype_multichoice', 'partiallycorrectfeedback', $questionid);
- $fs->delete_area_files($contextid,
- 'qtype_multichoice', 'incorrectfeedback', $questionid);
+ $this->delete_files_in_combined_feedback($questionid, $contextid);
}
}
}
public static function no_response() {
- return new question_classified_response(null, null, null);
+ return new question_classified_response(null, get_string('noresponse', 'question'), null);
}
}
}
}
+ /**
+ * Move all the files belonging to this question's answers when the question
+ * is moved from one context to another.
+ * @param int $questionid the question being moved.
+ * @param int $oldcontextid the context it is moving from.
+ * @param int $newcontextid the context it is moving to.
+ * @param bool $answerstoo whether there is an 'answer' question area,
+ * as well as an 'answerfeedback' one. Default false.
+ */
+ protected function move_files_in_combined_feedback($questionid, $oldcontextid,
+ $newcontextid) {
+ global $DB;
+ $fs = get_file_storage();
+
+ $fs->move_area_files_to_new_context($oldcontextid,
+ $newcontextid, 'question', 'correctfeedback', $questionid);
+ $fs->move_area_files_to_new_context($oldcontextid,
+ $newcontextid, 'question', 'partiallycorrectfeedback', $questionid);
+ $fs->move_area_files_to_new_context($oldcontextid,
+ $newcontextid, 'question', 'incorrectfeedback', $questionid);
+ }
+
/**
* Delete all the files belonging to this question.
* @param int $questionid the question being deleted.
}
}
+ /**
+ * Delete all the files belonging to this question's answers.
+ * @param int $questionid the question being deleted.
+ * @param int $contextid the context the question is in.
+ * @param bool $answerstoo whether there is an 'answer' question area,
+ * as well as an 'answerfeedback' one. Default false.
+ */
+ protected function delete_files_in_combined_feedback($questionid, $contextid) {
+ global $DB;
+ $fs = get_file_storage();
+
+ $fs->delete_area_files($contextid,
+ 'question', 'correctfeedback', $questionid);
+ $fs->delete_area_files($contextid,
+ 'question', 'partiallycorrectfeedback', $questionid);
+ $fs->delete_area_files($contextid,
+ 'question', 'incorrectfeedback', $questionid);
+ }
+
public function import_file($context, $component, $filearea, $itemid, $file) {
$fs = get_file_storage();
$record = new stdClass();
}
}
+ /**
+ * Validate Admin Settings Moodle form
+ * @param object $mform Moodle form (passed by reference)
+ * @param array array of ("fieldname"=>value) of submitted data
+ * @param array array of ("fieldname"=>errormessage) of errors
+ * @return array array of errors
+ */
+ public static function type_form_validation($mform, $data, $errors) {
+ return $errors;
+ }
+
+
/**
* Edit/Create Instance Settings Moodle form
* @param object $mform Moodle form (passed by reference)
$this->add_action_buttons(true, get_string('save','repository'));
}
+
+ public function validation($data) {
+ $errors = array();
+ $plugin = $this->_customdata['plugin'];
+ $instance = (isset($this->_customdata['instance'])
+ && is_subclass_of($this->_customdata['instance'], 'repository'))
+ ? $this->_customdata['instance'] : null;
+ if (!$instance) {
+ $errors = repository::static_function($plugin, 'type_form_validation', $this, $data, $errors);
+ } else {
+ $errors = $instance->type_form_validation($this, $data, $errors);
+ }
+
+ return $errors;
+ }
}
/**
foreach ($xml->entry as $entry) {
$media = $entry->children('http://search.yahoo.com/mrss/');
$title = $media->group->title;
- $attrs = $media->group->thumbnail->attributes();
+ $attrs = $media->group->thumbnail[2]->attributes();
$thumbnail = $attrs['url'];
$arr = explode('/', $entry->id);
$id = $arr[count($arr)-1];
// include.
////////////////////////////////////////////////////
-// $THEME->renderfactory
+// $THEME->rendererfactory
////////////////////////////////////////////////////
// Sets a custom render factory to use with the
.que {clear: left;text-align: left;margin: 0 auto 1.8em auto;}
.dir-rtl .que {text-align: right;}
-.que .info {float: left;width: 6em;padding:0.5em;margin-bottom: 1.8em;background: #eee;}
+.que .info {float: left;width: 7em;padding:0.5em;margin-bottom: 1.8em;background: #eee;}
.que h2.no {margin: 0;font-size: 0.8em;line-height: 1;}
.que span.qno {font-size: 1.5em;font-weight:bold;}
-.que .state,
-.que .grade,
-.que .editquestion {font-size: 0.8em; margin-top: 0.7em;}
-.que .info .questionflag {margin-top: 1em;margin-right: 1em;text-align: center;}
+.que .info * {font-size: 0.8em;}
+.que .info .state,
+.que .info .grade,
+.que .info .editquestion,
+.que .info .questionflag {margin-top: 0.7em;}
+.que .info .questionflag {cursor:pointer;}
-.que .content {margin: 0 0 0 7.5em;}
+.que .content {margin: 0 0 0 8.5em;}
.que .formulation,
.que .outcome,
// include.
////////////////////////////////////////////////////
-// $THEME->renderfactory
+// $THEME->rendererfactory
////////////////////////////////////////////////////
// Sets a custom render factory to use with the
// include.
////////////////////////////////////////////////////
-// $THEME->renderfactory
+// $THEME->rendererfactory
////////////////////////////////////////////////////
// Sets a custom render factory to use with the
// include.
////////////////////////////////////////////////////
-// $THEME->renderfactory
+// $THEME->rendererfactory
////////////////////////////////////////////////////
// Sets a custom render factory to use with the
// include.
////////////////////////////////////////////////////
-// $THEME->renderfactory
+// $THEME->rendererfactory
////////////////////////////////////////////////////
// Sets a custom render factory to use with the
.maincalendar .calendarmonth th,
.minicalendar th {
- background: url([[pix:theme|gradient-sb]]) repeat-x 0 0;
+ background: none;
}
.maincalendar .calendar-controls {
// include.
////////////////////////////////////////////////////
-// $THEME->renderfactory
+// $THEME->rendererfactory
////////////////////////////////////////////////////
// Sets a custom render factory to use with the
// include.
////////////////////////////////////////////////////
-// $THEME->renderfactory
+// $THEME->rendererfactory
////////////////////////////////////////////////////
// Sets a custom render factory to use with the
echo $output->box_start();
echo format_text(get_string('choosereadme', 'theme_'.$theme->name), FORMAT_MOODLE);
echo $output->box_end();
- echo $output->continue_button($CFG->wwwroot . '/' . $CFG->admin . '/index.php');
+ echo $output->continue_button($CFG->wwwroot . '/theme/index.php');
echo $output->footer();
exit;
}
// include.
////////////////////////////////////////////////////
-// $THEME->renderfactory
+// $THEME->rendererfactory
////////////////////////////////////////////////////
// Sets a custom render factory to use with the
// include.
////////////////////////////////////////////////////
-// $THEME->renderfactory
+// $THEME->rendererfactory
//$THEME->rendererfactory = 'theme_simplespace_renderer_factory';
////////////////////////////////////////////////////
// Sets a custom render factory to use with the
// include.
////////////////////////////////////////////////////
-// $THEME->renderfactory
+// $THEME->rendererfactory
////////////////////////////////////////////////////
// Sets a custom render factory to use with the
// include.
////////////////////////////////////////////////////
-// $THEME->renderfactory
+// $THEME->rendererfactory
////////////////////////////////////////////////////
// Sets a custom render factory to use with the
// include.
////////////////////////////////////////////////////
-// $THEME->renderfactory
+// $THEME->rendererfactory
////////////////////////////////////////////////////
// Sets a custom render factory to use with the
// include.
////////////////////////////////////////////////////
-// $THEME->renderfactory
+// $THEME->rendererfactory
////////////////////////////////////////////////////
// Sets a custom render factory to use with the
// include.
////////////////////////////////////////////////////
-// $THEME->renderfactory
+// $THEME->rendererfactory
////////////////////////////////////////////////////
// Sets a custom render factory to use with the
die;
}
-function combo_not_found() {
+function combo_not_found($message = '') {
header('HTTP/1.0 404 not found');
- die('Combo resource not found, sorry.');
+ if ($message) {
+ echo $message;
+ } else {
+ echo 'Combo resource not found, sorry.';
+ }
+ die;
}
function combo_params() {
- if (!empty($_SERVER['REQUEST_URI'])) {
- $parts = explode('?', $_SERVER['REQUEST_URI']);
- if (count($parts) != 2) {
- return '';
- }
+ // note: buggy or misconfigured IIS does return the query string in REQUEST_URL
+ if (isset($_SERVER['REQUEST_URI']) and strpos($_SERVER['REQUEST_URI'], '?') !== false) {
+ $parts = explode('?', $_SERVER['REQUEST_URI'], 2);
return $parts[1];
- } else if (!empty($_SERVER['QUERY_STRING'])) {
+ } else if (isset($_SERVER['QUERY_STRING'])) {
return $_SERVER['QUERY_STRING'];
} else {
- return '';
+ // unsupported server, sorry!
+ combo_not_found('Unsupported server - query string can not be determined, try disabling YUI combo loading in admin settings.');
}
}
-$version = 2011071900.00; // YYYYMMDD = weekly release date of this DEV branch
+$version = 2011080300.00; // YYYYMMDD = weekly release date of this DEV branch
// RR = release increments - 00 in DEV branches
// .XX = incremental changes
-$release = '2.2dev (Build: 20110719)'; // Human-friendly version name
+$release = '2.2dev (Build: 20110803)'; // Human-friendly version name
$maturity = MATURITY_ALPHA; // this version's maturity level