// before any action that may take longer time to finish.
function xmldb_data_upgrade($oldversion) {
- global $CFG, $DB;
+ global $CFG, $DB, $OUTPUT;
$dbman = $DB->get_manager();
$result = true;
$a->text .= $database->fullname." - " .$database->name. " (course id: ".$database->course." - database id: ".$database->id.")<br/>";
}
//TODO: MDL-17427 send this info to "upgrade log" which will be implemented in 2.0
- notify(get_string('requiredentrieschanged', 'admin', $a));
+ echo $OUTPUT->notification(get_string('requiredentrieschanged', 'admin', $a));
}
}
unset_config('requiredentriesfixflag', 'data'); // remove old flag
/// Of course, you can't be stopped if you are an editting teacher! =)
if (data_atmaxentries($data) and !has_capability('mod/data:manageentries',$context)){
- notify (get_string('atmaxentry','data'));
+ echo $OUTPUT->notification(get_string('atmaxentry','data'));
echo $OUTPUT->footer();
exit;
}
}
if ($emptyform){ //nothing gets written to database
- notify(get_string('emptyaddform','data'));
+ echo $OUTPUT->notification(get_string('emptyaddform','data'));
}
if (!$emptyform && $recordid = data_add_record($data, $currentgroup)) { //add instance to data_record
add_to_log($course->id, 'data', 'add', "view.php?d=$data->id&rid=$recordid", $data->id, $cm->id);
- notify(get_string('entrysaved','data'));
+ echo $OUTPUT->notification(get_string('entrysaved','data'));
if (!empty($datarecord->saveandview)) {
redirect($CFG->wwwroot.'/mod/data/view.php?d='.$data->id.'&rid='.$recordid);
echo '<input name="d" value="'.$data->id.'" type="hidden" />';
echo '<input name="rid" value="'.$rid.'" type="hidden" />';
echo '<input name="sesskey" value="'.sesskey().'" type="hidden" />';
- print_simple_box_start('center','80%');
+ echo $OUTPUT->box_start('generalbox boxaligncenter boxwidthwide');
if (!$rid){
echo $OUTPUT->heading(get_string('newentry','data'), 2);
echo '<input type="submit" value="'.get_string('saveandadd','data').'" />';
}
echo '</div>';
- print_simple_box_end();
+ echo $OUTPUT->box_end();
echo '</div></form>';
if (has_capability('mod/data:manageentries',$context)) {
if ($import) {
- print_simple_box_start('center','80%');
+ echo $OUTPUT->box_start('generalbox boxaligncenter boxwidthwide');
echo $OUTPUT->heading(get_string('uploadrecords', 'data'), 3);
$maxuploadsize = get_max_upload_file_size();
echo '<tr>';
echo '<td align="right">'.get_string('csvfile', 'data').':</td>';
echo '<td><input type="file" name="recordsfile" size="30" />';
- helpbutton('importcsv', get_string('csvimport', 'data'), 'data', true, false);
+ echo $OUTPUT->help_icon(moodle_help_icon::make('importcsv', get_string('csvimport', 'data'), 'data'));
echo '</td><tr>';
echo '<td align="right">'.get_string('fielddelimiter', 'data').':</td>';
echo '<td><input type="text" name="fielddelimiter" size="6" />';
echo '<input type="submit" value="'.get_string('uploadfile', 'data').'" />';
echo '</form>';
echo '</div>';
- print_simple_box_end();
+ echo $OUTPUT->box_end();
} else {
echo '<div style="text-align:center">';
echo '<a href="edit.php?d='.$data->id.'&import=1">'.get_string('uploadrecords', 'data').'</a>';
data_print_header($course, $cm, $data,'fields');
if (!$DB->record_exists('data_fields', array('dataid'=>$data->id))) {
- notify(get_string('nofieldindatabase','data')); // nothing in database
- notify(get_string('pleaseaddsome','data', 'preset.php?id='.$cm->id)); // link to presets
+ echo $OUTPUT->notification(get_string('nofieldindatabase','data')); // nothing in database
+ echo $OUTPUT->notification(get_string('pleaseaddsome','data', 'preset.php?id='.$cm->id)); // link to presets
} else { //else print quiz style list of fields
echo '<label for="fieldform_jump">'.get_string('newfield','data').'</label>';
$popupurl = $CFG->wwwroot.'/mod/data/field.php?d='.$data->id.'&mode=new&sesskey='. sesskey();
echo $OUTPUT->select(html_select::make_popup_form($popupurl, 'newtype', $menufield, "fieldform"));
- helpbutton('fields', get_string('addafield','data'), 'data');
+ echo $OUTPUT->help_icon(moodle_help_icon::make('fields', get_string('addafield','data'), 'data'));
echo '</div>';
echo '<div class="sortdefault">';
}
function update_field() {
- global $DB;
+ global $DB, $OUTPUT;
// Get the old field data so that we can check whether the thumbnail dimensions have changed
$oldfield = $DB->get_record('data_fields', array('id'=>$this->field->id));
if ($contents = $DB->get_records('data_content', array('fieldid'=>$this->field->id))) {
$fs = get_file_storage();
if (count($contents) > 20) {
- notify(get_string('resizingimages', 'data'), 'notifysuccess');
+ echo $OUTPUT->notification(get_string('resizingimages', 'data'), 'notifysuccess');
echo "\n\n";
// To make sure that ob_flush() has the desired effect
ob_flush();
if (can_use_html_editor()) {
// Show a rich text html editor.
$str .= $this->gen_textarea(true, $text);
- $str .= helpbutton("richtext2", get_string("helprichtext"), 'moodle', true, true, '', true);
+ $str .= $OUTPUT->help_icon(moodle_help_icon::make("richtext2", get_string("helprichtext"), 'moodle', true));
$str .= '<input type="hidden" name="field_' . $this->field->id . '_content1' . '" value="' . FORMAT_HTML . '" />';
} else {
$select->nothingvalue = '';
$str .= $OUTPUT->select($select);
- $str .= helpbutton('textformat', get_string('helpformatting'), 'moodle', true, false, '', true);
+ $str .= $OUTPUT->help_icon(moodle_help_icon::make('textformat', get_string('helpformatting'), 'moodle'));
}
$str .= '</div>';
return $str;
}
if ($recordsadded > 0) {
- notify($recordsadded. ' '. get_string('recordssaved', 'data'));
+ echo $OUTPUT->notification($recordsadded. ' '. get_string('recordssaved', 'data'));
} else {
- notify(get_string('recordsnotsaved', 'data'));
+ echo $OUTPUT->notification(get_string('recordsnotsaved', 'data'));
}
echo '<p />';
* @return bool
*/
function define_default_field() {
+ global $OUTPUT;
if (empty($this->data->id)) {
- notify('Programmer error: dataid not defined in field class');
+ echo $OUTPUT->notification('Programmer error: dataid not defined in field class');
}
$this->field = new object;
$this->field->id = 0;
* @return bool
*/
function insert_field() {
- global $DB;
+ global $DB, $OUTPUT;
if (empty($this->field)) {
- notify('Programmer error: Field has not been defined yet! See define_field()');
+ echo $OUTPUT->notification('Programmer error: Field has not been defined yet! See define_field()');
return false;
}
if (empty($this->field)) { // No field has been defined yet, try and make one
$this->define_default_field();
}
- print_simple_box_start('center','80%');
+ echo $OUTPUT->box_start('generalbox boxaligncenter boxwidthwide');
echo '<form id="editfield" action="'.$CFG->wwwroot.'/mod/data/field.php" method="post">'."\n";
echo '<input type="hidden" name="d" value="'.$this->data->id.'" />'."\n";
echo '</form>';
- print_simple_box_end();
+ echo $OUTPUT->box_end();
}
/**
* @return bool
*/
function data_tags_check($dataid, $template) {
- global $DB;
+ global $DB, $OUTPUT;
// first get all the possible tags
$fields = $DB->get_records('data_fields', array('dataid'=>$dataid));
$pattern="/\[\[".$field->name."\]\]/i";
if (preg_match_all($pattern, $template, $dummy)>1){
$tagsok = false;
- notify ('[['.$field->name.']] - '.get_string('multipletags','data'));
+ echo $OUTPUT->notification('[['.$field->name.']] - '.get_string('multipletags','data'));
}
}
// else return true
* @return bool
*/
function data_update_instance($data) {
- global $DB;
+ global $DB, $OUTPUT;
$data->timemodified = time();
$data->id = $data->instance;
* @return boolean data module was converted or not
*/
function data_convert_to_roles($data, $teacherroles=array(), $studentroles=array(), $cmid=NULL) {
- global $CFG, $DB;
+ global $CFG, $DB, $OUTPUT;
if (!isset($data->participants) && !isset($data->assesspublic)
&& !isset($data->groupmode)) {
if (empty($cmid)) {
// We were not given the course_module id. Try to find it.
if (!$cm = get_coursemodule_from_instance('data', $data->id)) {
- notify('Could not get the course module for the data');
+ echo $OUTPUT->notification('Could not get the course module for the data');
return false;
} else {
$cmid = $cm->id;
// Print any notices
if (!empty($displaynoticegood)) {
- notify($displaynoticegood, 'notifysuccess'); // good (usually green)
+ echo $OUTPUT->notification($displaynoticegood, 'notifysuccess'); // good (usually green)
} else if (!empty($displaynoticebad)) {
- notify($displaynoticebad); // bad (usuually red)
+ echo $OUTPUT->notification($displaynoticebad); // bad (usuually red)
}
}
*
*/
function import_options() {
+ global $OUTPUT;
if (!confirm_sesskey()) {
print_error('invalidsesskey');
}
if (!empty($currentfields) && !empty($newfields)) {
echo "<h3>$strfieldmappings ";
- helpbutton('fieldmappings', $strfieldmappings, 'data');
+ echo $OUTPUT->help_icon(moodle_help_icon::make('fieldmappings', $strfieldmappings, 'data'));
echo '</h3><table>';
foreach ($newfields as $nid => $newfield) {
@rmdir($presetpath);
$strdeleted = get_string('deleted', 'data');
- notify("$shortname $strdeleted", 'notifysuccess');
+ echo $OUTPUT->notification("$shortname $strdeleted", 'notifysuccess');
break;
/***************** Importing *****************/
$straddentries = get_string('addentries', 'data');
$strtodatabase = get_string('todatabase', 'data');
if (!$DB->get_records('data_records', array('dataid'=>$data->id))) {
- notify("$strimportsuccess <a href='edit.php?d=$data->id'>$straddentries</a> $strtodatabase", 'notifysuccess');
+ echo $OUTPUT->notification("$strimportsuccess <a href='edit.php?d=$data->id'>$straddentries</a> $strtodatabase", 'notifysuccess');
} else {
- notify("$strimportsuccess", 'notifysuccess');
+ echo $OUTPUT->notification("$strimportsuccess", 'notifysuccess');
}
break;
$name = optional_param('name', $data->name, PARAM_FILE);
if (is_directory_a_preset("$CFG->dataroot/data/preset/$USER->id/$name")) {
- notify("Preset already exists: Pick another name or overwrite");
+ echo $OUTPUT->notification("Preset already exists: Pick another name or overwrite");
echo '<div style="text-align:center">';
echo '<form action="preset.php" method="post">';
if (!unzip_file($file, $CFG->dataroot.$presetdirectory, false)) {
print_error('cannotunziptopreset', 'data');
}
- notify(get_string('savesuccess', 'data'), 'notifysuccess');
+ echo $OUTPUT->notification(get_string('savesuccess', 'data'), 'notifysuccess');
break;
}
echo '<tr><td valign="top" colspan="2" align="center"><h3>'.$strexport.'</h3></td></tr>';
echo '<tr><td><label>'.$strexportaszip.'</label>';
-helpbutton('exportzip', '', 'data', true, true);
+echo $OUTPUT->help_icon(moodle_help_icon::make('exportzip', '', 'data', true));
echo '</td><td>';
$options = new object();
$options->action = 'export';
echo '</td></tr>';
echo '<tr><td><label>'.$strsaveaspreset.'</label>';
-helpbutton('savepreset', '', 'data', true, true);
+echo $OUTPUT->help_icon(moodle_help_icon::make('savepreset', '', 'data', true));
echo '</td><td>';
$options = new object();
$options->action = 'save1';
echo '</td></tr>';
echo '<tr><td valign="top" colspan="2" align="center"><h3>'.$strimport.'</h3></td></tr>';
echo '<tr><td><label for="fromfile">'.$strfromfile.'</label>';
-helpbutton('importfromfile', '', 'data', true, true);
+echo $OUTPUT->help_icon(moodle_help_icon::make('importfromfile', '', 'data', true));
echo '</td><td>';
echo '<form id="uploadpreset" method="post" action="preset.php">';
echo '<fieldset class="invisiblefieldset">';
echo '</td></tr>';
echo '<tr valign="top"><td><label>'.$strusestandard.'</label>';
-helpbutton('usepreset', '', 'data', true, true);
+echo $OUTPUT->help_icon(moodle_help_icon::make('usepreset', '', 'data', true));
echo '</td><td>';
echo '<form id="presets" method="post" action="preset.php" >';
// Check for multiple tags, only need to check for add template.
if ($mode != 'addtemplate' or data_tags_check($data->id, $newtemplate->{$mode})) {
if ($DB->update_record('data', $newtemplate)) {
- notify(get_string('templatesaved', 'data'), 'notifysuccess');
+ echo $OUTPUT->notification(get_string('templatesaved', 'data'), 'notifysuccess');
}
}
add_to_log($course->id, 'data', 'templates saved', "templates.php?id=$cm->id&d=$data->id", $data->id, $cm->id);
// Only reload if we are not resetting the template to default.
$data = $DB->get_record('data', array('id'=>$d));
}
- print_simple_box_start('center','80%');
+ echo $OUTPUT->box_start('generalbox boxaligncenter boxwidthwide');
echo '<table cellpadding="4" cellspacing="0" border="0">';
/// Add the HTML editor(s).
if ($mode != 'csstemplate' and $mode != 'jstemplate') {
// Add all the available fields for this data.
echo '<label for="availabletags">'.get_string('availabletags','data').'</label>';
- helpbutton('tags', get_string('tags'), 'data');
+ echo $OUTPUT->help_icon(moodle_help_icon::make('tags', get_string('tags'), 'data'));
echo '<br />';
echo '</td></tr></table>';
- print_simple_box_end();
+ echo $OUTPUT->box_end();
echo '</div>';
echo '</form>';
add_to_log($course->id, 'data', 'record delete', "view.php?id=$cm->id", $data->id, $cm->id);
- notify(get_string('recorddeleted','data'), 'notifysuccess');
+ echo $OUTPUT->notification(get_string('recorddeleted','data'), 'notifysuccess');
}
}
$newrecord->id = $approverecord->id;
$newrecord->approved = 1;
if ($DB->update_record('data_records', $newrecord)) {
- notify(get_string('recordapproved','data'), 'notifysuccess');
+ echo $OUTPUT->notification(get_string('recordapproved','data'), 'notifysuccess');
}
}
}
if ($data->requiredentries > 0 && $numentries < $data->requiredentries && !has_capability('mod/data:manageentries', $context)) {
$data->entriesleft = $data->requiredentries - $numentries;
$strentrieslefttoadd = get_string('entrieslefttoadd', 'data', $data);
- notify($strentrieslefttoadd);
+ echo $OUTPUT->notification($strentrieslefttoadd);
}
/// Check the number of entries required before to view other participant's entries against the number of entries already made (doesn't apply to teachers)
if ($data->requiredentriestoview > 0 && $numentries < $data->requiredentriestoview && !has_capability('mod/data:manageentries', $context)) {
$data->entrieslefttoview = $data->requiredentriestoview - $numentries;
$strentrieslefttoaddtoview = get_string('entrieslefttoaddtoview', 'data', $data);
- notify($strentrieslefttoaddtoview);
+ echo $OUTPUT->notification($strentrieslefttoaddtoview);
$requiredentries_allowed = false;
}
$a = new object();
$a->max = $maxcount;
$a->reseturl = "view.php?id=$cm->id&mode=$mode&search=&advanced=0";
- notify(get_string('foundnorecords','data', $a));
+ echo $OUTPUT->notification(get_string('foundnorecords','data', $a));
} else {
- notify(get_string('norecords','data'));
+ echo $OUTPUT->notification(get_string('norecords','data'));
}
} else { // We have some records to print
$a->num = $totalcount;
$a->max = $maxcount;
$a->reseturl = "view.php?id=$cm->id&mode=$mode&search=&advanced=0";
- notify(get_string('foundrecords', 'data', $a), 'notifysuccess');
+ echo $OUTPUT->notification(get_string('foundrecords', 'data', $a), 'notifysuccess');
}
if ($mode == 'single') { // Single template
echo $OUTPUT->paging_bar(moodle_paging_bar::make($totalcount, $page, $nowperpage, $baseurl));
if (empty($data->singletemplate)){
- notify(get_string('nosingletemplate','data'));
+ echo $OUTPUT->notification(get_string('nosingletemplate','data'));
data_generate_default_template($data, 'singletemplate', 0, false, false);
}
echo $OUTPUT->paging_bar(moodle_paging_bar::make($totalcount, $page, $nowperpage, $baseurl));
if (empty($data->listtemplate)){
- notify(get_string('nolisttemplate','data'));
+ echo $OUTPUT->notification(get_string('nolisttemplate','data'));
data_generate_default_template($data, 'listtemplate', 0, false, false);
}
echo $data->listtemplateheader;