if (!empty($dir) && ($storage == 1 || $storage == 2)) {
// Calculate backup filename regex, ignoring the date/time/info parts that can be
// variable, depending of languages, formats and automated backup settings
- $filename = $backupword . '-' . backup::FORMAT_MOODLE . '-' . backup::TYPE_1COURSE . '-' .$course->id . '-';
+
+
+ // MDL-33531: use different filenames depending on backup_shortname option
+ if ( !empty($config->backup_shortname) ) {
+ $context = get_context_instance(CONTEXT_COURSE, $course->id);
+ $courseref = format_string($course->shortname, true, array('context' => $context));
+ $courseref = str_replace(' ', '_', $courseref);
+ $courseref = textlib::strtolower(trim(clean_filename($courseref), '_'));
+ } else {
+ $courseref = $course->id;
+ }
+ $filename = $backupword . '-' . backup::FORMAT_MOODLE . '-' . backup::TYPE_1COURSE . '-' .$courseref . '-';
$regex = '#^'.preg_quote($filename, '#').'.*\.mbz$#';
// Store all the matching files into fullpath => timemodified array
$courses_limit = $courses_limit + 1;
}
- $courses = enrol_get_my_courses('id, shortname, modinfo', 'visible DESC,sortorder ASC', $courses_limit);
+ $courses = enrol_get_my_courses('id, shortname, modinfo, sectioncache', 'visible DESC,sortorder ASC', $courses_limit);
$site = get_site();
$course = $site; //just in case we need the old global $course hack
$allmodnames = array();
if (!empty($CFG->useblogassociations)) {
- if ((!empty($entry->courseassoc) || (!empty($courseid) && empty($modid))) && has_capability('moodle/blog:associatecourse', $sitecontext)) {
+ if ((!empty($entry->courseassoc) || (!empty($courseid) && empty($modid)))) {
if (!empty($courseid)) {
$course = $DB->get_record('course', array('id' => $courseid));
- $mform->addElement('header', 'assochdr', get_string('associations', 'blog'));
- $context = get_context_instance(CONTEXT_COURSE, $courseid);
+ $context = context_course::instance($courseid);
$a = new stdClass();
$a->coursename = format_string($course->fullname, true, array('context' => $context));
$contextid = $context->id;
} else {
+ $context = context::instance_by_id($entry->courseassoc);
$sql = 'SELECT fullname FROM {course} cr LEFT JOIN {context} ct ON ct.instanceid = cr.id WHERE ct.id = ?';
$a = new stdClass();
$a->coursename = $DB->get_field_sql($sql, array($entry->courseassoc));
$contextid = $entry->courseassoc;
}
- $mform->addElement('advcheckbox', 'courseassoc', get_string('associatewithcourse', 'blog', $a), null, null, array(0, $contextid));
- $mform->setDefault('courseassoc', $contextid);
- } else if ((!empty($entry->modassoc) || !empty($modid)) && has_capability('moodle/blog:associatemodule', $sitecontext)) {
+ if (has_capability('moodle/blog:associatecourse', $context)) {
+ $mform->addElement('header', 'assochdr', get_string('associations', 'blog'));\r
+ $mform->addElement('advcheckbox', 'courseassoc', get_string('associatewithcourse', 'blog', $a), null, null, array(0, $contextid));\r
+ $mform->setDefault('courseassoc', $contextid);
+ }
+
+ } else if ((!empty($entry->modassoc) || !empty($modid))) {
if (!empty($modid)) {
$mod = get_coursemodule_from_id(false, $modid);
$a = new stdClass();
$modid = $context->instanceid;
}
- $mform->addElement('header', 'assochdr', get_string('associations', 'blog'));
- $mform->addElement('advcheckbox', 'modassoc', get_string('associatewithmodule', 'blog', $a), null, null, array(0, $context->id));
- $mform->setDefault('modassoc', $context->id);
+ if (has_capability('moodle/blog:associatemodule', $context)) {
+ $mform->addElement('header', 'assochdr', get_string('associations', 'blog'));
+ $mform->addElement('advcheckbox', 'modassoc', get_string('associatewithmodule', 'blog', $a), null, null, array(0, $context->id));
+ $mform->setDefault('modassoc', $context->id);
+ }
}
}
global $CFG, $DB, $USER;
$errors = array();
- $sitecontext = get_context_instance(CONTEXT_SYSTEM);
// validate course association
- if (!empty($data['courseassoc']) && has_capability('moodle/blog:associatecourse', $sitecontext)) {
+ if (!empty($data['courseassoc'])) {
$coursecontext = context::instance_by_id($data['courseassoc'], IGNORE_MISSING);
- if ($coursecontext and $coursecontext->contextlevel == CONTEXT_COURSE) {
+ $canassociatecourse = has_capability('moodle/blog:associatecourse', $coursecontext);
+ if ($coursecontext->contextlevel == CONTEXT_COURSE && $canassociatecourse) {
if (!is_enrolled($coursecontext) and !is_viewing($coursecontext)) {
$errors['courseassoc'] = get_string('studentnotallowed', '', fullname($USER, true));
}
$modcontextid = $data['modassoc'];
$modcontext = context::instance_by_id($modcontextid, IGNORE_MISSING);
- if ($modcontext and $modcontext->contextlevel == CONTEXT_MODULE) {
+ $canassociatemodule = has_capability('moodle/blog:associatecourse', $modcontext);
+ if ($modcontext->contextlevel == CONTEXT_MODULE && $canassociatemodule) {
// get context of the mod's course
$coursecontext = $modcontext->get_course_context(true);
}
// Check that the user can associate with the course
- $sitecontext = get_context_instance(CONTEXT_SYSTEM);
- if (!has_capability('moodle/blog:associatecourse', $sitecontext)) {
+ $sitecontext = context_system::instance();
+ $coursecontext = context_course::instance($course->id);
+ if (!has_capability('moodle/blog:associatecourse', $coursecontext)) {
return $options;
}
// Generate the cache key
return $courseoptions[$key];
}
- $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
$canparticipate = (is_enrolled($coursecontext) or is_viewing($coursecontext));
if (has_capability('moodle/blog:view', $coursecontext)) {
}
// Check the user can associate with the module
- $sitecontext = get_context_instance(CONTEXT_SYSTEM);
- if (!has_capability('moodle/blog:associatemodule', $sitecontext)) {
+ $modcontext = context_module::instance($module->id);
+ $sitecontext = context_system::instance();
+ if (!has_capability('moodle/blog:associatemodule', $modcontext)) {
return $options;
}
return $moduleoptions[$module->id];
}
- $modcontext = get_context_instance(CONTEXT_MODULE, $module->id);
$canparticipate = (is_enrolled($modcontext) or is_viewing($modcontext));
if (has_capability('moodle/blog:view', $modcontext)) {
$PAGE->set_pagelayout('standard');
- if (!empty($modid) && $CFG->useblogassociations && has_capability('moodle/blog:associatemodule', $sitecontext)) { // modid always overrides courseid, so the $course object may be reset here
+ // modid always overrides courseid, so the $course object may be reset here
+ if (!empty($modid) && $CFG->useblogassociations) {
+
$headers['filters']['module'] = $modid;
// A groupid param may conflict with this coursemod's courseid. Ignore groupid in that case
$courseid = $DB->get_field('course_modules', 'course', array('id'=>$modid));
$renderer = $PAGE->get_renderer('format_topics');
-if (!empty($displaysection) && $course->coursedisplay == COURSE_DISPLAY_MULTIPAGE) {
+if (!empty($displaysection)) {
$renderer->print_single_section_page($course, $sections, $mods, $modnames, $modnamesused, $displaysection);
} else {
$renderer->print_multiple_section_page($course, $sections, $mods, $modnames, $modnamesused);
$renderer = $PAGE->get_renderer('format_weeks');
-if (!empty($displaysection) && $course->coursedisplay == COURSE_DISPLAY_MULTIPAGE) {
+if (!empty($displaysection)) {
$renderer->print_single_section_page($course, $sections, $mods, $modnames, $modnamesused, $displaysection);
} else {
$renderer->print_multiple_section_page($course, $sections, $mods, $modnames, $modnamesused);
$logparam = 'id='. $course->id;
$loglabel = 'view';
$infoid = $course->id;
- if(!empty($section)) {
+ if ($section and $section > 0) {
$loglabel = 'view section';
// Get section details and check it exists.
$column = (object)array_change_key_case((array)$column, CASE_LOWER);
if (stripos($column->type, 'unsigned') !== false) {
+ $maxvalue = 0;
+ if (preg_match('/^int/i', $column->type)) {
+ $maxvalue = 2147483647;
+ } else if (preg_match('/^medium/i', $column->type)) {
+ $maxvalue = 8388607;
+ } else if (preg_match('/^smallint/i', $column->type)) {
+ $maxvalue = 32767;
+ } else if (preg_match('/^tinyint/i', $column->type)) {
+ $maxvalue = 127;
+ }
+ if ($maxvalue) {
+ // Make sure nobody is abusing our integer ranges - moodle int sizes are in digits, not bytes!!!
+ $invalidcount = $DB->get_field_sql("SELECT COUNT('x') FROM `{{$table}}` WHERE `$column->field` > :maxnumber", array('maxnumber'=>$maxvalue));
+ if ($invalidcount) {
+ throw new moodle_exception('notlocalisederrormessage', 'error', new moodle_url('/admin/'), "Database table '{$table}'' contains unsigned column '{$column->field}' with $invalidcount values that are out of allowed range, upgrade can not continue.");
+ }
+ }
$type = preg_replace('/unsigned/i', 'signed', $column->type);
$notnull = ($column->null === 'NO') ? 'NOT NULL' : 'NULL';
$default = (!is_null($column->default) and $column->default !== '') ? "DEFAULT '$column->default'" : '';
return M.form.showAdvanced;
};
+/**
+ * Stores a list of the dependencyManager for each form on the page.
+ */
+M.form.dependencyManagers = {};
+
/**
* Initialises a manager for a forms dependencies.
* This should happen once per form.
return this.checkDependencies(null);
},
/**
- * Gets all elements in the form by thier name and returns
+ * Gets all elements in the form by their name and returns
* a YUI NodeList
* @return Y.NodeList
*/
return dependencyManager;
})();
- return new M.form.dependencyManager();
-};
\ No newline at end of file
+ M.form.dependencyManagers[formid] = new M.form.dependencyManager();
+ return M.form.dependencyManagers[formid];
+};
+
+/**
+ * Update the state of a form. You need to call this after, for example, changing
+ * the state of some of the form input elements in your own code, in order that
+ * things like the disableIf state of elements can be updated.
+ */
+M.form.updateFormState = function(formid) {
+ if (formid in M.form.dependencyManagers) {
+ M.form.dependencyManagers[formid].checkDependencies(null);
+ }
+};
*/
function can_use_rotated_text() {
global $USER;
- return ajaxenabled(array('Firefox' => 2.0)) && !$USER->screenreader;;
+ return (check_browser_version('MSIE', 9) || check_browser_version('Firefox', 2) ||
+ check_browser_version('Chrome', 21) || check_browser_version('Safari', 536.26) ||
+ check_browser_version('Opera', 12) || check_browser_version('Safari iOS', 533)) &&
+ !$USER->screenreader;
}
/**
* @return bool
*/
function phpunit_bootstrap_is_cygwin() {
- if (empty($_SERVER['SHELL']) or empty($_SERVER['OS'])) {
+ if (empty($_SERVER['OS']) or $_SERVER['OS'] !== 'Windows_NT') {
+ return false;
+
+ } else if (!empty($_SERVER['SHELL']) and $_SERVER['SHELL'] === '/bin/bash') {
+ return true;
+
+ } else if (!empty($_SERVER['TERM']) and $_SERVER['TERM'] === 'cygwin') {
+ return true;
+
+ } else {
return false;
}
- return ($_SERVER['OS'] === 'Windows_NT' and $_SERVER['SHELL'] === '/bin/bash');
}
*/
public function can_upgrade($type, $version) {
- if (($type == 'upload' || $type == 'uploadsingle') && $version >= 2011112900) {
+ if (($type == 'upload' || $type == 'uploadsingle' ||
+ $type == 'online' || $type == 'offline') && $version >= 2011112900) {
return true;
}
return false;
// Do assignment_base::isopen() here without loading the whole thing for speed
foreach ($assignments as $key => $assignment) {
$time = time();
- $isopen = $assignment->allowsubmissionsfromdate <= $time;
if ($assignment->duedate) {
+ $isopen = $assignment->allowsubmissionsfromdate <= $time;
if ($assignment->preventlatesubmissions) {
$isopen = ($isopen && $time <= $assignment->duedate);
}
}
if (has_all_capabilities(array('gradereport/grader:view', 'moodle/grade:viewall'), $this->get_course_context())) {
- $grade = $this->output->action_link(new moodle_url('/grade/report/grader/index.php',
+ $gradestring = $this->output->action_link(new moodle_url('/grade/report/grader/index.php',
array('id'=>$this->get_course()->id)),
$gradinginfo->items[0]->grades[$userid]->str_grade);
} else {
- $grade = $gradinginfo->items[0]->grades[$userid]->str_grade;
+ $gradestring = $gradinginfo->items[0]->grades[$userid]->str_grade;
}
- $mform->addElement('static', 'finalgrade', get_string('currentgrade', 'assign').':' ,$grade);
+ $mform->addElement('static', 'finalgrade', get_string('currentgrade', 'assign').':', $gradestring);
$mform->addElement('static', 'progress', '', get_string('gradingstudentprogress', 'assign', array('index'=>$rownum+1, 'count'=>count($useridlist))));
}
foreach ($status->feedbackplugins as $plugin) {
- if ($plugin->is_enabled() && $plugin->is_visible() && !$plugin->is_empty($status->grade)) {
+ if ($plugin->is_enabled() && $plugin->is_visible() && !empty($status->grade) && !$plugin->is_empty($status->grade)) {
$row = new html_table_row();
$cell1 = new html_table_cell($plugin->get_name());
$pluginfeedback = new assign_feedback_plugin_feedback($plugin, $status->grade, assign_feedback_plugin_feedback::SUMMARY, $status->coursemoduleid, $status->returnaction, $status->returnparams);
$options = array(0 => get_string('ascending', 'data'),
1 => get_string('descending', 'data'));
+ echo html_writer::label(get_string('sortby'), 'menudefaultsortdir', false, array('class' => 'accesshide'));
echo html_writer::select($options, 'defaultsortdir', $data->defaultsortdir, false);
echo '<input type="submit" value="'.get_string('save', 'data').'" />';
echo '</div>';
}
$str = '<div title="'.s($this->field->description).'">';
- $dayselector = html_writer::select_time('days', 'field_'.$this->field->id.'_day', $content);
- $monthselector = html_writer::select_time('months', 'field_'.$this->field->id.'_month', $content);
- $yearselector = html_writer::select_time('years', 'field_'.$this->field->id.'_year', $content);
+ $dayselector = html_writer::label(get_string('days'), 'menufield_'.$this->field->id.'_day', false, array('class' => 'accesshide'))
+ . html_writer::select_time('days', 'field_'.$this->field->id.'_day', $content);
+ $monthselector = html_writer::label(get_string('months'), 'menufield_'.$this->field->id.'_month', false, array('class' => 'accesshide'))
+ . html_writer::select_time('months', 'field_'.$this->field->id.'_month', $content);
+ $yearselector = html_writer::label(get_string('years'), 'menufield_'.$this->field->id.'_year', false, array('class' => 'accesshide'))
+ . html_writer::select_time('years', 'field_'.$this->field->id.'_year', $content);
$str .= $dayselector . $monthselector . $yearselector;
$str .= '</div>';
//Enable the following three functions once core API issues have been addressed.
function display_search_field($value=0) {
- $selectors = html_writer::select_time('days', 'f_'.$this->field->id.'_d', $value)
+ $selectors = html_writer::label(get_string('days'), 'menuf_'.$this->field->id.'_d', false, array('class' => 'accesshide'))
+ . html_writer::select_time('days', 'f_'.$this->field->id.'_d', $value)
+ . html_writer::label(get_string('months'), 'menuf_'.$this->field->id.'_m', false, array('class' => 'accesshide'))
. html_writer::select_time('months', 'f_'.$this->field->id.'_m', $value)
+ . html_writer::label(get_string('years'), 'menuf_'.$this->field->id.'_y', false, array('class' => 'accesshide'))
. html_writer::select_time('years', 'f_'.$this->field->id.'_y', $value);
return $selectors;
}
function display_search_field($value = '') {
- return '<input type="text" size="16" name="f_'.$this->field->id.'" value="'.$value.'" />';
+ return '<label class="accesshide" for=f_"' . $this->field->id . '">' . $this->field->name . '</label>' .
+ '<input type="text" size="16" id="f_'.$this->field->id.'" name="f_'.$this->field->id.'" value="'.$value.'" />';
}
function generate_sql($tablealias, $value) {
<?php
$course = $DB->get_record('course', array('id'=>$this->data->course));
$choices = get_max_upload_sizes($CFG->maxbytes, $course->maxbytes);
+ echo html_writer::label($this->field->param3, 'menuparam3', false, array('class' => 'accesshide'));
echo html_writer::select($choices, 'param3', $this->field->param3, false, array('id' => 'param3'));
?>
</td>
}
$latlongsrs->close();
- return html_writer::select($options, 'f_'.$this->field->id, $value);
+ $return = html_writer::label(get_string('latlong', 'data'), 'menuf_'.$this->field->id, false, array('class' => 'accesshide'));
+ $return .= html_writer::select($options, 'f_'.$this->field->id, $value);
+ return $return;
}
function parse_search_field() {
. str_replace(array_keys($urlreplacements), array_values($urlreplacements), $this->linkoutservices[$servicesshown[0]])
."' title='$servicesshown[0]'>$compasslat, $compasslong</a>";
} elseif (sizeof($servicesshown)>1) {
- $str .= "$compasslat, $compasslong\n<select name='jumpto'>";
+ $str .= "$compasslat, $compasslong\n";
+ $str .= "<label class='accesshide' for='jumpto'>". get_string('jumpto') ."</label>";
+ $str .= "<select id='jumpto' name='jumpto'>";
foreach($servicesshown as $servicename){
// Add a link to a service
$str .= "\n <option value='"
}
}
-
+ $str .= html_writer::label(get_string('menuchoose', 'data'), 'field_'.$this->field->id, false, array('class' => 'accesshide'));
$str .= html_writer::select($options, 'field_'.$this->field->id, $content, array(''=>get_string('menuchoose', 'data')), array('id'=>'field_'.$this->field->id));
$str .= '</div>';
return '';
}
- return html_writer::select($options, 'f_'.$this->field->id, $content);
+ $return = html_writer::label(get_string('namemenu', 'data'), 'menuf_'. $this->field->id, false, array('class' => 'accesshide'));
+ $return .= html_writer::select($options, 'f_'.$this->field->id, $content);
+ return $return;
}
function parse_search_field() {
$str = '<div title="'.s($this->field->description).'">';
$str .= '<input name="field_' . $this->field->id . '[xxx]" type="hidden" value="xxx"/>'; // hidden field - needed for empty selection
+ $str .= '<label class="accesshide" for="field_' . $this->field->id . '">' . $this->field->name. '</label>';
$str .= '<select name="field_' . $this->field->id . '[]" id="field_' . $this->field->id . '" multiple="multiple">';
foreach (explode("\n",$this->field->param1) as $option) {
static $c = 0;
- $str = '<select name="f_'.$this->field->id.'[]" multiple="multiple">';
+ $str = '<label class="accesshide" for="f_' . $this->field->id . '">' . $this->field->name . '</label>';
+ $str .= '<select id="f_'.$this->field->id.'" name="f_'.$this->field->id.'[]" multiple="multiple">';
// display only used options
$varcharcontent = $DB->sql_compare_text('content', 255);
}
function display_search_field($value = '') {
- return '<input type="text" size="16" name="f_'.$this->field->id.'" value="'.$value.'" />';
+ return '<label class="accesshide" for="f_'.$this->field->id.'">' . get_string('fieldname', 'data') . '</label>' .
+ '<input type="text" size="16" id="f_'.$this->field->id.'" name="f_'.$this->field->id.'" value="'.$value.'" />';
}
function parse_search_field() {
}
function display_search_field($value = '') {
- return '<input type="text" size="16" name="f_'.$this->field->id.'" value="'.$value.'" />';
+ return '<label class="accesshide" for="f_'.$this->field->id.'">' . get_string('fieldname', 'data') . '</label>' .
+ '<input type="text" size="16" id="f_'.$this->field->id.'" name="f_'.$this->field->id.'" value="'.$value.'" />';
}
function parse_search_field() {
<?php
$course = $DB->get_record('course', array('id'=>$this->data->course));
$choices = get_max_upload_sizes($CFG->maxbytes, $course->maxbytes);
+ echo html_writer::label($this->field->param3, 'menuparam3', false, array('class' => 'accesshide'));
echo html_writer::select($choices, 'param3', $this->field->param3, false, array('id'=>'param3'));
?>
</td>
$options[$rec->content] = $rec->content; //Build following indicies from the sql.
}
}
- return html_writer::select($options, 'f_'.$this->field->id, $value);
+ $return = html_writer::label(get_string('nameradiobutton', 'data'), 'menuf_'. $this->field->id, false, array('class' => 'accesshide'));
+ $return .= html_writer::select($options, 'f_'.$this->field->id, $value);
+ return $return;
}
function parse_search_field() {
var $type = 'text';
function display_search_field($value = '') {
- return '<input type="text" size="16" name="f_'.$this->field->id.'" value="'.$value.'" />';
+ return '<label class="accesshide" for="f_' . $this->field->id . '">'. $this->field->name.'</label>' . '<input type="text" size="16" id="f_'.$this->field->id.'" name="f_'.$this->field->id.'" value="'.$value.'" />';
}
function parse_search_field() {
$editor->use_editor($field, $options, $fpoptions);
$str .= '<input type="hidden" name="'.$field.'_itemid" value="'.$draftitemid.'" />';
$str .= '<div><textarea id="'.$field.'" name="'.$field.'" rows="'.$this->field->param3.'" cols="'.$this->field->param2.'">'.s($text).'</textarea></div>';
- $str .= '<div><select name="'.$field.'_content1">';
+ $str .= '<div><label class="accesshide" for="' . $field . '_content1">' . get_string('format') . '</label>';
+ $str .= '<select id="' . $field . '_content1" name="'.$field.'_content1">';
foreach ($formats as $key=>$desc) {
$selected = ($format == $key) ? 'selected="selected"' : '';
$str .= '<option value="'.s($key).'" '.$selected.'>'.$desc.'</option>';
function display_search_field($value = '') {
- return '<input type="text" size="16" name="f_'.$this->field->id.'" value="'.$value.'" />';
+ return '<label class="accesshide" for="f_' . $this->field->id . '">' . $this->field->name . '</label>' .
+ '<input type="text" size="16" id="f_'.$this->field->id.'" name="f_'.$this->field->id.'" value="'.$value.'" />';
}
function parse_search_field() {
$str = '<div title="'.s($this->field->description).'">';
if (!empty($this->field->param1) and empty($this->field->param2)) {
$str .= '<table><tr><td align="right">';
- $str .= get_string('url','data').':</td><td><input type="text" name="field_'.$this->field->id.'_0" id="'.$fieldid.'" value="'.$url.'" size="60" /></td></tr>';
+ $str .= get_string('url','data').':</td><td>';
+ $str .= '<label class="accesshide" for="' . $fieldid . '">'. $this->field->name .'</label>';
+ $str .= '<input type="text" name="field_'.$this->field->id.'_0" id="'.$fieldid.'" value="'.$url.'" size="60" /></td></tr>';
$str .= '<tr><td align="right">'.get_string('text','data').':</td><td><input type="text" name="field_'.$this->field->id.'_1" id="field_'.$this->field->id.'_1" value="'.s($text).'" size="60" /></td></tr>';
$str .= '</table>';
} else {
// Just the URL field
+ $str .= '<label class="accesshide" for="' . $fieldid . '">'. $this->field->name .'</label>';
$str .= '<input type="text" name="field_'.$this->field->id.'_0" id="'.$fieldid.'" value="'.s($url).'" size="60" />';
}
}
function display_search_field($value = '') {
- return '<input type="text" size="16" name="f_'.$this->field->id.'" value="'.$value.'" />';
+ return '<label class="accesshide" for="f_'.$this->field->id.'">' . get_string('fieldname', 'data') . '</label>' .
+ '<input type="text" size="16" id="f_'.$this->field->id.'" name="f_'.$this->field->id.'" value="'.$value.'" />';
}
function parse_search_field() {
$attachment = $attachname='';
$usetrueaddress = true;
- //directly email forum digests rather than sending them via messaging
+ // Directly email forum digests rather than sending them via messaging, use the
+ // site shortname as 'from name', the noreply address will be used by email_to_user.
$mailresult = email_to_user($userto, $site->shortname, $postsubject, $posttext, $posthtml, $attachment, $attachname, $usetrueaddress, $CFG->forum_replytouser);
if (!$mailresult) {
global $OUTPUT;
if ($forumtype == 'single') {
$select = new single_select(new moodle_url("/mod/forum/view.php", array('f'=>$id)), 'mode', forum_get_layout_modes(), $mode, null, "mode");
+ $select->set_label(get_string('displaymode', 'forum'), array('class' => 'accesshide'));
$select->class = "forummode";
} else {
$select = new single_select(new moodle_url("/mod/forum/discuss.php", array('d'=>$id)), 'mode', forum_get_layout_modes(), $mode, null, "mode");
+ $select->set_label(get_string('displaymode', 'forum'), array('class' => 'accesshide'));
}
echo $OUTPUT->render($select);
}
}
echo '<input name="timefromrestrict" type="checkbox" value="1" alt="'.get_string('searchdatefrom', 'forum').'" onclick="return lockoptions(\'searchform\', \'timefromrestrict\', timefromitems)" '. $datefromchecked . ' /> ';
- $selectors = html_writer::select_time('days', 'fromday', $datefrom)
+ $selectors = html_writer::label(get_string('days'), 'menufromday', false, array('class' => 'accesshide'))
+ . html_writer::select_time('days', 'fromday', $datefrom)
+ . html_writer::label(get_string('months'), 'menufrommonth', false, array('class' => 'accesshide'))
. html_writer::select_time('months', 'frommonth', $datefrom)
+ . html_writer::label(get_string('years'), 'menufromyear', false, array('class' => 'accesshide'))
. html_writer::select_time('years', 'fromyear', $datefrom)
+ . html_writer::label(get_string('hours'), 'menufromhour', false, array('class' => 'accesshide'))
. html_writer::select_time('hours', 'fromhour', $datefrom)
+ . html_writer::label(get_string('minutes'), 'menufromminute', false, array('class' => 'accesshide'))
. html_writer::select_time('minutes', 'fromminute', $datefrom);
echo $selectors;
echo '<input type="hidden" name="hfromday" value="0" />';
}
echo '<input name="timetorestrict" type="checkbox" value="1" alt="'.get_string('searchdateto', 'forum').'" onclick="return lockoptions(\'searchform\', \'timetorestrict\', timetoitems)" ' .$datetochecked. ' /> ';
- $selectors = html_writer::select_time('days', 'today', $dateto)
+ $selectors = html_writer::label(get_string('days'), 'menutoday', false, array('class' => 'accesshide'))
+ . html_writer::select_time('days', 'today', $dateto)
+ . html_writer::label(get_string('months'), 'menutomonth', false, array('class' => 'accesshide'))
. html_writer::select_time('months', 'tomonth', $dateto)
+ . html_writer::label(get_string('years'), 'menutoyear', false, array('class' => 'accesshide'))
. html_writer::select_time('years', 'toyear', $dateto)
+ . html_writer::label(get_string('hours'), 'menutohour', false, array('class' => 'accesshide'))
. html_writer::select_time('hours', 'tohour', $dateto)
+ . html_writer::label(get_string('minutes'), 'menutominute', false, array('class' => 'accesshide'))
. html_writer::select_time('minutes', 'tominute', $dateto);
echo $selectors;
require_once(dirname(__FILE__) . '/../config.php');
require_once($CFG->dirroot . '/question/editlib.php');
-$url = new moodle_url('/question/edit.php');
+list($thispageurl, $contexts, $cmid, $cm, $module, $pagevars) =
+ question_edit_setup('questions', '/question/edit.php');
+
+$url = new moodle_url($thispageurl);
if (($lastchanged = optional_param('lastchanged', 0, PARAM_INT)) !== 0) {
$url->param('lastchanged', $lastchanged);
}
-if (($category = optional_param('category', 0, PARAM_TEXT)) !== 0) {
- $url->param('category', $category);
-}
-if (($qpage = optional_param('qpage', 0, PARAM_INT)) !== 0) {
- $url->param('qpage', $qpage);
-}
-if (($cat = optional_param('cat', 0, PARAM_TEXT)) !== 0) {
- $url->param('cat', $cat);
-}
-if (($courseid = optional_param('courseid', 0, PARAM_INT)) !== 0) {
- $url->param('courseid', $courseid);
-}
-if (($returnurl = optional_param('returnurl', 0, PARAM_INT)) !== 0) {
- $url->param('returnurl', $returnurl);
-}
-if (($cmid = optional_param('cmid', 0, PARAM_INT)) !== 0) {
- $url->param('cmid', $cmid);
-}
$PAGE->set_url($url);
-list($thispageurl, $contexts, $cmid, $cm, $module, $pagevars) =
- question_edit_setup('questions', '/question/edit.php');
$questionbank = new question_bank_view($contexts, $thispageurl, $COURSE, $cm);
$questionbank->process_actions();
*/
protected $preferredbehaviour = null;
- /** @var object the context this usage belongs to. */
+ /** @var context the context this usage belongs to. */
protected $context;
/** @var string plugin name of the plugin this usage belongs to. */
return $this->preferredbehaviour;
}
- /** @return object the context this usage belongs to. */
+ /** @return context the context this usage belongs to. */
public function get_owning_context() {
return $this->context;
}
$PAGE->set_url(question_preview_url($id, $options->behaviour, $options->maxmark,
$options, $options->variant, $context));
-// Get and validate exitsing preview, or start a new one.
+// Get and validate existing preview, or start a new one.
$previewid = optional_param('previewid', 0, PARAM_INT);
if ($previewid) {
- if (!isset($SESSION->question_previews[$previewid])) {
- print_error('notyourpreview', 'question');
- }
-
try {
$quba = question_engine::load_questions_usage_by_activity($previewid);
$options->maxmark, $options, $options->variant, $context), null, $e);
}
+ if ($quba->get_owning_context()->instanceid != $USER->id) {
+ print_error('notyourpreview', 'question');
+ }
+
$slot = $quba->get_first_question_number();
$usedquestion = $quba->get_question($slot);
if ($usedquestion->id != $question->id) {
} else {
$quba = question_engine::make_questions_usage_by_activity(
- 'core_question_preview', $context);
+ 'core_question_preview', context_user::instance($USER->id));
$quba->set_preferred_behaviour($options->behaviour);
$slot = $quba->add_question($question, $options->maxmark);
$transaction = $DB->start_delegated_transaction();
question_engine::save_questions_usage_by_activity($quba);
$transaction->allow_commit();
-
- $SESSION->question_previews[$quba->get_id()] = true;
}
$options->behaviour = $quba->get_preferred_behaviour();
$options->maxmark = $quba->get_question_max_mark($slot);
var client_id = this.options.client_id;
var id = data.upload.id+'_'+client_id;
var content = this.fpnode.one('.fp-content');
- content.setContent(M.core_filepicker.templates.uploadform);
+ var template_name = 'uploadform_'+this.options.repositories[data.repo_id].type;
+ var template = M.core_filepicker.templates[template_name] || M.core_filepicker.templates['uploadform'];
+ content.setContent(template);
content.all('.fp-file,.fp-saveas,.fp-setauthor,.fp-setlicense').each(function (node) {
node.all('label').set('for', node.one('input,select').generateID());
$list['dynload'] = true;
$list['nologin'] = true;
$list['nosearch'] = true;
+ // retrieve list of files and directories and sort them
+ $fileslist = array();
+ $dirslist = array();
if ($dh = opendir($this->root_path)) {
while (($file = readdir($dh)) != false) {
if ( $file != '.' and $file !='..') {
- if (filetype($this->root_path.$file) == 'file') {
- $list['list'][] = array(
- 'title' => $file,
- 'source' => $path.'/'.$file,
- 'size' => filesize($this->root_path.$file),
- 'datecreated' => filectime($this->root_path.$file),
- 'datemodified' => filemtime($this->root_path.$file),
- 'thumbnail' => $OUTPUT->pix_url(file_extension_icon($file, 90))->out(false),
- 'icon' => $OUTPUT->pix_url(file_extension_icon($file, 24))->out(false)
- );
+ if (is_file($this->root_path.$file)) {
+ $fileslist[] = $file;
} else {
- if (!empty($path)) {
- $current_path = $path . '/'. $file;
- } else {
- $current_path = $file;
- }
- $list['list'][] = array(
- 'title' => $file,
- 'children' => array(),
- 'datecreated' => filectime($this->root_path.$file),
- 'datemodified' => filemtime($this->root_path.$file),
- 'thumbnail' => $OUTPUT->pix_url(file_folder_icon(90))->out(false),
- 'path' => $current_path
- );
+ $dirslist[] = $file;
}
}
}
}
+ collatorlib::asort($fileslist, collatorlib::SORT_STRING);
+ collatorlib::asort($dirslist, collatorlib::SORT_STRING);
+ // fill the $list['list']
+ foreach ($dirslist as $file) {
+ if (!empty($path)) {
+ $current_path = $path . '/'. $file;
+ } else {
+ $current_path = $file;
+ }
+ $list['list'][] = array(
+ 'title' => $file,
+ 'children' => array(),
+ 'datecreated' => filectime($this->root_path.$file),
+ 'datemodified' => filemtime($this->root_path.$file),
+ 'thumbnail' => $OUTPUT->pix_url(file_folder_icon(90))->out(false),
+ 'path' => $current_path
+ );
+ }
+ foreach ($fileslist as $file) {
+ $list['list'][] = array(
+ 'title' => $file,
+ 'source' => $path.'/'.$file,
+ 'size' => filesize($this->root_path.$file),
+ 'datecreated' => filectime($this->root_path.$file),
+ 'datemodified' => filemtime($this->root_path.$file),
+ 'thumbnail' => $OUTPUT->pix_url(file_extension_icon($file, 90))->out(false),
+ 'icon' => $OUTPUT->pix_url(file_extension_icon($file, 24))->out(false)
+ );
+ }
$list['list'] = array_filter($list['list'], array($this, 'filter'));
return $list;
}
*/
function initialise_filepicker($args) {
global $CFG, $USER, $PAGE, $OUTPUT;
- static $templatesinitialized;
+ static $templatesinitialized = array();
require_once($CFG->libdir . '/licenselib.php');
$return = new stdClass();
// provided by form element
$return->accepted_types = file_get_typegroup('extension', $args->accepted_types);
$return->return_types = $args->return_types;
+ $templates = array();
foreach ($repositories as $repository) {
$meta = $repository->get_meta();
// Please note that the array keys for repositories are used within
// JavaScript a lot, the key NEEDS to be the repository id.
$return->repositories[$repository->id] = $meta;
+ // Register custom repository template if it has one
+ if(method_exists($repository, 'get_upload_template') && !array_key_exists('uploadform_' . $meta->type, $templatesinitialized)) {
+ $templates['uploadform_' . $meta->type] = $repository->get_upload_template();
+ $templatesinitialized['uploadform_' . $meta->type] = true;
+ }
}
- if (!$templatesinitialized) {
- // we need to send filepicker templates to the browser just once
+ if (!array_key_exists('core', $templatesinitialized)) {
+ // we need to send each filepicker template to the browser just once
$fprenderer = $PAGE->get_renderer('core', 'files');
- $templates = $fprenderer->filepicker_js_templates();
+ $templates = array_merge($templates, $fprenderer->filepicker_js_templates());
+ $templatesinitialized['core'] = true;
+ }
+ if (sizeof($templates)) {
$PAGE->requires->js_init_call('M.core_filepicker.set_templates', array($templates), true);
- $templatesinitialized = true;
}
return $return;
}
/*********************************************************************************************
- right column: 28%
- padding left/right column: 10px
- padding center column: 20px
+ right column: 28%
+ padding left/right column: 10px
+ padding center column: 20px
**********************************************************************************************/
body {
- margin: auto 0px;
- width: auto;
+ margin: auto 0px;
+ width: auto;
}
#page {
- width: 100%;
+ width: 100%;
}
#page-header {
- float: left;
- width: 100%;
+ float: left;
+ width: 100%;
}
#page-content {
- clear: both;
- float: left;
- overflow: hidden;
- position: relative;
- width: 100%;
+ clear: both;
+ float: left;
+ overflow: hidden;
+ position: relative;
+ width: 100%;
}
#page-content #region-main-box {
- float: left;
- right: 28%;
- position: relative;
- width: 100%;
+ float: left;
+ right: 28%;
+ position: relative;
+ width: 100%;
}
#page-content #region-post-box {
- float: left;
- right: 72%;
- position: relative;
- width: 100%;
+ float: left;
+ right: 72%;
+ position: relative;
+ width: 100%;
}
#page-content #region-main {
- float: left;
- overflow: hidden;
- position: relative;
- margin-right: 0px;
- left: 100%;
- width: 72%;
+ float: left;
+ overflow: hidden;
+ position: relative;
+ margin-right: 0px;
+ left: 100%;
+ width: 72%;
}
#page-content #region-post {
- float: left;
- overflow: hidden;
- position: relative;
- left: 100%;
- width: 28%;
+ float: left;
+ overflow: hidden;
+ position: relative;
+ left: 100%;
+ width: 28%;
}
#page-content #region-main .region-content {
- overflow: hidden;
- padding: 50px 15px 20px 0;
+ overflow: hidden;
+ padding: 50px 15px 20px 0;
}
#page-content #region-post .region-content {
- overflow: hidden;
- padding: 0 0 0 10px;
+ overflow: hidden;
+ padding: 0 0 0 10px;
}
#page-footer {
- clear: both;
- float: left;
- width: 100%;
+ clear: both;
+ float: left;
+ width: 100%;
}
/** No blocks whatsoever **/
.content-only #page-content #region-main-box {
- right: 0%;
+ right: 0%;
}
.content-only #page-content #region-post-box {
- right: 100%;
+ right: 100%;
}
.content-only #page-content #region-main {
- left: 100%;
- width: 100%;
+ left: 100%;
+ width: 100%;
}
.content-only #page-content #region-pre {
- width: 0%;
+ width: 0%;
}
.content-only #page-content #region-post {
- width: 0%;
+ width: 0%;
}
.pagelayout-report #page-content #region-main {overflow:auto;}
-.pagelayout-report #page-content #region-main .region-content {overflow:visible;}
\ No newline at end of file
+.pagelayout-report #page-content #region-main .region-content {overflow:visible;}
+
+#page-enrol-manual-unenrolself #region-main .region-content #region-header.inside {
+ margin-bottom: 110px;
+}
\ No newline at end of file