From: samhemelryk Date: Thu, 24 Sep 2009 04:25:40 +0000 (+0000) Subject: mod-data MDL-19806 Added set_url calls, replaced deprecated functions, and added... X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=6111b2b0302d733bde23031888b6ebb65a2ad49c;p=moodle.git mod-data MDL-19806 Added set_url calls, replaced deprecated functions, and added boilerplates --- diff --git a/mod/data/comment.php b/mod/data/comment.php index 151204394f..31ff2b026e 100755 --- a/mod/data/comment.php +++ b/mod/data/comment.php @@ -1,131 +1,167 @@ -get_record('data_records', array('id'=>$rid))) { - print_error('invalidrecord', 'data'); +. + +/** + * This file is part of the Database module for Moodle + * + * @copyright 2005 Martin Dougiamas http://dougiamas.com + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @package mod-data + */ + +require_once('../../config.php'); +require_once('lib.php'); +require_once('comment_form.php'); + +//param needed to go back to view.php +$rid = required_param('rid', PARAM_INT); // Record ID +$page = optional_param('page', 0, PARAM_INT); // Page ID + +//param needed for comment operations +$mode = optional_param('mode','add',PARAM_ALPHA); +$commentid = optional_param('commentid','',PARAM_INT); +$confirm = optional_param('confirm','',PARAM_INT); + +$url = new moodle_url($CFG->wwwroot.'/mod/data/comment.php', array('rid'=>$rid)); +if ($page !== 0) { + $url->param('page', $page); +} +if ($mode !== 'add') { + $url->param('mode', $mode); +} +if ($commentid !== '') { + $url->param('commentid', $commentid); +} +if ($confirm !== '') { + $url->param('confirm', $confirm); +} +$PAGE->set_url($url); + +if (! $record = $DB->get_record('data_records', array('id'=>$rid))) { + print_error('invalidrecord', 'data'); +} +if (! $data = $DB->get_record('data', array('id'=>$record->dataid))) { + print_error('invalidid', 'data'); +} +if (! $course = $DB->get_record('course', array('id'=>$data->course))) { + print_error('coursemisconf'); +} +if (! $cm = get_coursemodule_from_instance('data', $data->id, $course->id)) { + print_error('invalidcoursemodule'); +} + +require_login($course->id, false, $cm); +$context = get_context_instance(CONTEXT_MODULE, $cm->id); +require_capability('mod/data:comment', $context); + +if ($commentid) { + if (! $comment = $DB->get_record('data_comments', array('id'=>$commentid))) { + print_error('commentmisconf'); } - if (! $data = $DB->get_record('data', array('id'=>$record->dataid))) { - print_error('invalidid', 'data'); + if ($comment->recordid != $record->id) { + print_error('commentmisconf'); } - if (! $course = $DB->get_record('course', array('id'=>$data->course))) { - print_error('coursemisconf'); + if (!has_capability('mod/data:managecomments', $context) && $comment->userid != $USER->id) { + print_error('cannoteditcomment'); } - if (! $cm = get_coursemodule_from_instance('data', $data->id, $course->id)) { - print_error('invalidcoursemodule'); +} else { + $comment = false; +} + + +$mform = new mod_data_comment_form(); +$mform->set_data(array('mode'=>$mode, 'page'=>$page, 'rid'=>$record->id, 'commentid'=>$commentid)); +if ($comment) { + $format = $comment->format; + $content = $comment->content; + if (can_use_html_editor()) { + $options = new object(); + $options->smiley = false; + $options->filter = false; + $content = format_text($content, $format, $options); + $format = FORMAT_HTML; } + $mform->set_data(array('content'=>$content, 'format'=>$format)); +} - require_login($course->id, false, $cm); - $context = get_context_instance(CONTEXT_MODULE, $cm->id); - require_capability('mod/data:comment', $context); - if ($commentid) { - if (! $comment = $DB->get_record('data_comments', array('id'=>$commentid))) { - print_error('commentmisconf'); - } - if ($comment->recordid != $record->id) { - print_error('commentmisconf'); +if ($mform->is_cancelled()) { + redirect('view.php?rid='.$record->id.'&page='.$page); +} + +switch ($mode) { + case 'add': + if (!$formadata = $mform->get_data()) { + break; // something is wrong here, try again } - if (!has_capability('mod/data:managecomments', $context) && $comment->userid != $USER->id) { - print_error('cannoteditcomment'); + + $newcomment = new object(); + $newcomment->userid = $USER->id; + $newcomment->created = time(); + $newcomment->modified = time(); + $newcomment->content = $formadata->content; + $newcomment->recordid = $formadata->rid; + if ($DB->insert_record('data_comments',$newcomment)) { + redirect('view.php?rid='.$record->id.'&page='.$page); + } else { + print_error('cannotsavecomment'); } - } else { - $comment = false; - } + break; - $mform = new mod_data_comment_form(); - $mform->set_data(array('mode'=>$mode, 'page'=>$page, 'rid'=>$record->id, 'commentid'=>$commentid)); - if ($comment) { - $format = $comment->format; - $content = $comment->content; - if (can_use_html_editor()) { - $options = new object(); - $options->smiley = false; - $options->filter = false; - $content = format_text($content, $format, $options); - $format = FORMAT_HTML; + case 'edit': //print edit form + if (!$formadata = $mform->get_data()) { + break; // something is wrong here, try again } - $mform->set_data(array('content'=>$content, 'format'=>$format)); - } + $updatedcomment = new object(); + $updatedcomment->id = $formadata->commentid; + $updatedcomment->content = $formadata->content; + $updatedcomment->format = $formadata->format; + $updatedcomment->modified = time(); - if ($mform->is_cancelled()) { - redirect('view.php?rid='.$record->id.'&page='.$page); - } + if ($DB->update_record('data_comments', $updatedcomment)) { + redirect('view.php?rid='.$record->id.'&page='.$page); + } else { + print_error('cannotsavecomment'); + } + break; - switch ($mode) { - case 'add': - if (!$formadata = $mform->get_data()) { - break; // something is wrong here, try again - } - - $newcomment = new object(); - $newcomment->userid = $USER->id; - $newcomment->created = time(); - $newcomment->modified = time(); - $newcomment->content = $formadata->content; - $newcomment->recordid = $formadata->rid; - if ($DB->insert_record('data_comments',$newcomment)) { - redirect('view.php?rid='.$record->id.'&page='.$page); - } else { - print_error('cannotsavecomment'); - } - - break; - - case 'edit': //print edit form - if (!$formadata = $mform->get_data()) { - break; // something is wrong here, try again - } - - $updatedcomment = new object(); - $updatedcomment->id = $formadata->commentid; - $updatedcomment->content = $formadata->content; - $updatedcomment->format = $formadata->format; - $updatedcomment->modified = time(); - - if ($DB->update_record('data_comments', $updatedcomment)) { - redirect('view.php?rid='.$record->id.'&page='.$page); - } else { - print_error('cannotsavecomment'); - } - break; - - case 'delete': //deletes single comment from db - if ($confirm and confirm_sesskey() and $comment) { - $DB->delete_records('data_comments', array('id'=>$comment->id)); - redirect('view.php?rid='.$record->id.'&page='.$page, get_string('commentdeleted', 'data')); - - } else { //print confirm delete form - echo $OUTPUT->header(); - data_print_comment($data, $comment, $page); - - echo $OUTPUT->confirm(get_string('deletecomment','data'), - 'comment.php?rid='.$record->id.'&commentid='.$comment->id.'&page='.$page.'&mode=delete&confirm=1', - 'view.php?rid='.$record->id.'&page='.$page); - echo $OUTPUT->footer(); - } - die; - break; + case 'delete': //deletes single comment from db + if ($confirm and confirm_sesskey() and $comment) { + $DB->delete_records('data_comments', array('id'=>$comment->id)); + redirect('view.php?rid='.$record->id.'&page='.$page, get_string('commentdeleted', 'data')); - } + } else { //print confirm delete form + echo $OUTPUT->header(); + data_print_comment($data, $comment, $page); + + echo $OUTPUT->confirm(get_string('deletecomment','data'), + 'comment.php?rid='.$record->id.'&commentid='.$comment->id.'&page='.$page.'&mode=delete&confirm=1', + 'view.php?rid='.$record->id.'&page='.$page); + echo $OUTPUT->footer(); + } + die; + break; - echo $OUTPUT->header(); - data_print_comments($data, $record, $page, $mform); - echo $OUTPUT->footer(); +} +echo $OUTPUT->header(); +data_print_comments($data, $record, $page, $mform); +echo $OUTPUT->footer(); -?> +?> \ No newline at end of file diff --git a/mod/data/css.php b/mod/data/css.php index 5a59889491..a85d51a145 100755 --- a/mod/data/css.php +++ b/mod/data/css.php @@ -1,40 +1,43 @@ -get_record('data', array('id'=>$d))) { - header('Last-Modified: ' . gmdate('D, d M Y H:i:s', time()) . ' GMT'); - header('Expires: ' . gmdate("D, d M Y H:i:s", time() + $lifetime) . ' GMT'); - header('Cache-control: max_age = '. $lifetime); - header('Pragma: '); - header('Content-type: text/css'); // Correct MIME type - - echo $data->csstemplate; - } +. + +/** + * This file is part of the Database module for Moodle + * + * @copyright 2005 Martin Dougiamas http://dougiamas.com + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @package mod-data + */ + +define('NO_MOODLE_COOKIES', true); // session not used here + +require_once('../../config.php'); + +$d = optional_param('d', 0, PARAM_INT); // database id +$lifetime = 600; // Seconds to cache this stylesheet + +$PAGE->set_url(new moodle_url($CFG->wwwroot.'/mod/data/css.php', array('d'=>$d))); + +if ($data = $DB->get_record('data', array('id'=>$d))) { + header('Last-Modified: ' . gmdate('D, d M Y H:i:s', time()) . ' GMT'); + header('Expires: ' . gmdate("D, d M Y H:i:s", time() + $lifetime) . ' GMT'); + header('Cache-control: max_age = '. $lifetime); + header('Pragma: '); + header('Content-type: text/css'); // Correct MIME type + + echo $data->csstemplate; +} \ No newline at end of file diff --git a/mod/data/edit.php b/mod/data/edit.php index ac5c6dbdb4..a90a4d80fb 100755 --- a/mod/data/edit.php +++ b/mod/data/edit.php @@ -1,356 +1,372 @@ -libdir/rsslib.php"); - - $id = optional_param('id', 0, PARAM_INT); // course module id - $d = optional_param('d', 0, PARAM_INT); // database id - $rid = optional_param('rid', 0, PARAM_INT); //record id - $import = optional_param('import', 0, PARAM_INT); // show import form - $cancel = optional_param('cancel', '', PARAM_RAW); // cancel an add - $mode ='addtemplate'; //define the mode for this page, only 1 mode available - - if ($id) { - if (! $cm = get_coursemodule_from_id('data', $id)) { - print_error('invalidcoursemodule'); - } - if (! $course = $DB->get_record('course', array('id'=>$cm->course))) { - print_error('coursemisconf'); - } - if (! $data = $DB->get_record('data', array('id'=>$cm->instance))) { - print_error('invalidcoursemodule'); - } +. + +/** + * This file is part of the Database module for Moodle + * + * @copyright 2005 Martin Dougiamas http://dougiamas.com + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @package mod-data + */ + +require_once('../../config.php'); +require_once('lib.php'); +require_once("$CFG->libdir/rsslib.php"); + +$id = optional_param('id', 0, PARAM_INT); // course module id +$d = optional_param('d', 0, PARAM_INT); // database id +$rid = optional_param('rid', 0, PARAM_INT); //record id +$import = optional_param('import', 0, PARAM_INT); // show import form +$cancel = optional_param('cancel', '', PARAM_RAW); // cancel an add +$mode ='addtemplate'; //define the mode for this page, only 1 mode available + +$url = new moodle_url($CFG->wwwroot.'/mod/data/edit.php'); +if ($rid !== 0) { + $url->param('rid', $rid); +} +if ($import !== 0) { + $url->param('import', $import); +} +if ($cancel !== '') { + $url->param('cancel', $cancel); +} + +if ($id) { + $url->param('id', $id); + $PAGE->set_url($url); + if (! $cm = get_coursemodule_from_id('data', $id)) { + print_error('invalidcoursemodule'); + } + if (! $course = $DB->get_record('course', array('id'=>$cm->course))) { + print_error('coursemisconf'); + } + if (! $data = $DB->get_record('data', array('id'=>$cm->instance))) { + print_error('invalidcoursemodule'); + } - } else { - if (! $data = $DB->get_record('data', array('id'=>$d))) { - print_error('invalidid', 'data'); - } - if (! $course = $DB->get_record('course', array('id'=>$data->course))) { - print_error('coursemisconf'); - } - if (! $cm = get_coursemodule_from_instance('data', $data->id, $course->id)) { - print_error('invalidcoursemodule'); - } +} else { + $url->param('d', $d); + $PAGE->set_url($url); + if (! $data = $DB->get_record('data', array('id'=>$d))) { + print_error('invalidid', 'data'); } + if (! $course = $DB->get_record('course', array('id'=>$data->course))) { + print_error('coursemisconf'); + } + if (! $cm = get_coursemodule_from_instance('data', $data->id, $course->id)) { + print_error('invalidcoursemodule'); + } +} - require_login($course->id, false, $cm); +require_login($course->id, false, $cm); - if (!isloggedin() or isguest()) { - redirect('view.php?d='.$data->id); - } +if (!isloggedin() or has_capability('moodle/legacy:guest', get_context_instance(CONTEXT_SYSTEM), 0, false)) { + redirect('view.php?d='.$data->id); +} - $context = get_context_instance(CONTEXT_MODULE, $cm->id); +$context = get_context_instance(CONTEXT_MODULE, $cm->id); /// If it's hidden then it doesn't show anything. :) - if (empty($cm->visible) and !has_capability('moodle/course:viewhiddenactivities', $context)) { - $strdatabases = get_string("modulenameplural", "data"); +if (empty($cm->visible) and !has_capability('moodle/course:viewhiddenactivities', $context)) { + $strdatabases = get_string("modulenameplural", "data"); - $PAGE->set_title(format_string($data->name)); - echo $OUTPUT->header(); - notice(get_string("activityiscurrentlyhidden")); - } + $PAGE->set_title(format_string($data->name)); + echo $OUTPUT->header(); + notice(get_string("activityiscurrentlyhidden")); +} /// Can't use this if there are no fields - if (has_capability('mod/data:managetemplates', $context)) { - if (!$DB->record_exists('data_fields', array('dataid'=>$data->id))) { // Brand new database! - redirect($CFG->wwwroot.'/mod/data/field.php?d='.$data->id); // Redirect to field entry - } +if (has_capability('mod/data:managetemplates', $context)) { + if (!$DB->record_exists('data_fields', array('dataid'=>$data->id))) { // Brand new database! + redirect($CFG->wwwroot.'/mod/data/field.php?d='.$data->id); // Redirect to field entry } +} - if ($rid) { // So do you have access? - if (!(has_capability('mod/data:manageentries', $context) or data_isowner($rid)) or !confirm_sesskey() ) { - print_error('noaccess','data'); - } +if ($rid) { // So do you have access? + if (!(has_capability('mod/data:manageentries', $context) or data_isowner($rid)) or !confirm_sesskey() ) { + print_error('noaccess','data'); } +} - if ($cancel) { - redirect('view.php?d='.$data->id); - } +if ($cancel) { + redirect('view.php?d='.$data->id); +} /// RSS and CSS and JS meta - if (!empty($CFG->enablerssfeeds) && !empty($CFG->data_enablerssfeeds) && $data->rssarticles > 0) { - $rsspath = rss_get_url($course->id, $USER->id, 'data', $data->id); - $PAGE->add_alternate_version(format_string($course->shortname) . ': %fullname%', - $rsspath, 'application/rss+xml'); - } - if ($data->csstemplate) { - $PAGE->requires->css('mod/data/css.php?d='.$data->id); - } - if ($data->jstemplate) { - $PAGE->requires->js('mod/data/js.php?d='.$data->id)->in_head(); - } +if (!empty($CFG->enablerssfeeds) && !empty($CFG->data_enablerssfeeds) && $data->rssarticles > 0) { + $rsspath = rss_get_url($course->id, $USER->id, 'data', $data->id); + $PAGE->add_alternate_version(format_string($course->shortname) . ': %fullname%', + $rsspath, 'application/rss+xml'); +} +if ($data->csstemplate) { + $PAGE->requires->css('mod/data/css.php?d='.$data->id); +} +if ($data->jstemplate) { + $PAGE->requires->js('mod/data/js.php?d='.$data->id)->in_head(); +} /// Print the page header - $strdata = get_string('modulenameplural','data'); +$strdata = get_string('modulenameplural','data'); - if ($rid) { - $PAGE->navbar->add(get_string('editentry', 'data')); - } else { - $PAGE->navbar->add(get_string('add', 'data')); - } +if ($rid) { + $PAGE->navbar->add(get_string('editentry', 'data')); +} else { + $PAGE->navbar->add(get_string('add', 'data')); +} - $PAGE->set_title($data->name); - $PAGE->set_button(update_module_button($cm->id, $course->id, get_string('modulename', 'data'))); - echo $OUTPUT->header(); +$PAGE->set_title($data->name); +$PAGE->set_button($OUTPUT->update_module_button($cm->id, 'data')); +echo $OUTPUT->header(); /// Check to see if groups are being used here - groups_print_activity_menu($cm, 'edit.php?d='.$data->id); - $currentgroup = groups_get_activity_group($cm); - $groupmode = groups_get_activity_groupmode($cm); +groups_print_activity_menu($cm, 'edit.php?d='.$data->id); +$currentgroup = groups_get_activity_group($cm); +$groupmode = groups_get_activity_groupmode($cm); - echo $OUTPUT->heading(format_string($data->name)); +echo $OUTPUT->heading(format_string($data->name)); - if ($currentgroup) { - $groupselect = " AND groupid = '$currentgroup'"; - $groupparam = "&groupid=$currentgroup"; - } else { - $groupselect = ""; - $groupparam = ""; - $currentgroup = 0; - } +if ($currentgroup) { + $groupselect = " AND groupid = '$currentgroup'"; + $groupparam = "&groupid=$currentgroup"; +} else { + $groupselect = ""; + $groupparam = ""; + $currentgroup = 0; +} /// Print the tabs - $currenttab = 'add'; - if ($rid) { - $editentry = true; //used in tabs - } - include('tabs.php'); +$currenttab = 'add'; +if ($rid) { + $editentry = true; //used in tabs +} +include('tabs.php'); /// Process incoming data for adding/updating records - if ($datarecord = data_submitted() and confirm_sesskey()) { - - $ignorenames = array('MAX_FILE_SIZE','sesskey','d','rid','saveandview','cancel'); // strings to be ignored in input data +if ($datarecord = data_submitted() and confirm_sesskey()) { - if ($rid) { /// Update some records + $ignorenames = array('MAX_FILE_SIZE','sesskey','d','rid','saveandview','cancel'); // strings to be ignored in input data - /// All student edits are marked unapproved by default - $record = $DB->get_record('data_records', array('id'=>$rid)); + if ($rid) { /// Update some records - /// reset approved flag after student edit - if (!has_capability('mod/data:approve', $context)) { - $record->approved = 0; - } + /// All student edits are marked unapproved by default + $record = $DB->get_record('data_records', array('id'=>$rid)); - $record->groupid = $currentgroup; - $record->timemodified = time(); - $DB->update_record('data_records', $record); + /// reset approved flag after student edit + if (!has_capability('mod/data:approve', $context)) { + $record->approved = 0; + } - /// Update all content - $field = NULL; - foreach ($datarecord as $name => $value) { - if (!in_array($name, $ignorenames)) { - $namearr = explode('_',$name); // Second one is the field id - if (empty($field->field) || ($namearr[1] != $field->field->id)) { // Try to reuse classes - $field = data_get_field_from_id($namearr[1], $data); - } - if ($field) { - $field->update_content($rid, $value, $name); - } + $record->groupid = $currentgroup; + $record->timemodified = time(); + $DB->update_record('data_records', $record); + + /// Update all content + $field = NULL; + foreach ($datarecord as $name => $value) { + if (!in_array($name, $ignorenames)) { + $namearr = explode('_',$name); // Second one is the field id + if (empty($field->field) || ($namearr[1] != $field->field->id)) { // Try to reuse classes + $field = data_get_field_from_id($namearr[1], $data); + } + if ($field) { + $field->update_content($rid, $value, $name); } } + } - add_to_log($course->id, 'data', 'update', "view.php?d=$data->id&rid=$rid", $data->id, $cm->id); + add_to_log($course->id, 'data', 'update', "view.php?d=$data->id&rid=$rid", $data->id, $cm->id); - redirect($CFG->wwwroot.'/mod/data/view.php?d='.$data->id.'&rid='.$rid); + redirect($CFG->wwwroot.'/mod/data/view.php?d='.$data->id.'&rid='.$rid); - } else { /// Add some new records + } else { /// Add some new records - if (!data_user_can_add_entry($data, $currentgroup, $groupmode)) { - print_error('cannotadd', 'data'); - } + if (!data_user_can_add_entry($data, $currentgroup, $groupmode)) { + print_error('cannotadd', 'data'); + } - /// Check if maximum number of entry as specified by this database is reached - /// Of course, you can't be stopped if you are an editting teacher! =) + /// Check if maximum number of entry as specified by this database is reached + /// Of course, you can't be stopped if you are an editting teacher! =) + + if (data_atmaxentries($data) and !has_capability('mod/data:manageentries',$context)){ + echo $OUTPUT->notification(get_string('atmaxentry','data')); + echo $OUTPUT->footer(); + exit; + } - if (data_atmaxentries($data) and !has_capability('mod/data:manageentries',$context)){ - echo $OUTPUT->notification(get_string('atmaxentry','data')); - echo $OUTPUT->footer(); - exit; + ///Empty form checking - you can't submit an empty form! + + $emptyform = true; // assume the worst + + foreach ($datarecord as $name => $value) { + if (!in_array($name, $ignorenames)) { + $namearr = explode('_', $name); // Second one is the field id + if (empty($field->field) || ($namearr[1] != $field->field->id)) { // Try to reuse classes + $field = data_get_field_from_id($namearr[1], $data); + } + if ($field->notemptyfield($value, $name)) { + $emptyform = false; + break; // if anything has content, this form is not empty, so stop now! + } } + } - ///Empty form checking - you can't submit an empty form! + if ($emptyform){ //nothing gets written to database + echo $OUTPUT->notification(get_string('emptyaddform','data')); + } - $emptyform = true; // assume the worst + if (!$emptyform && $recordid = data_add_record($data, $currentgroup)) { //add instance to data_record - foreach ($datarecord as $name => $value) { + /// Insert a whole lot of empty records to make sure we have them + $fields = $DB->get_records('data_fields', array('dataid'=>$data->id)); + foreach ($fields as $field) { + $content->recordid = $recordid; + $content->fieldid = $field->id; + $DB->insert_record('data_content',$content); + } + + //for each field in the add form, add it to the data_content. + foreach ($datarecord as $name => $value){ if (!in_array($name, $ignorenames)) { $namearr = explode('_', $name); // Second one is the field id if (empty($field->field) || ($namearr[1] != $field->field->id)) { // Try to reuse classes $field = data_get_field_from_id($namearr[1], $data); } - if ($field->notemptyfield($value, $name)) { - $emptyform = false; - break; // if anything has content, this form is not empty, so stop now! + if ($field) { + $field->update_content($recordid, $value, $name); } } } - if ($emptyform){ //nothing gets written to database - echo $OUTPUT->notification(get_string('emptyaddform','data')); - } - - if (!$emptyform && $recordid = data_add_record($data, $currentgroup)) { //add instance to data_record - - /// Insert a whole lot of empty records to make sure we have them - $fields = $DB->get_records('data_fields', array('dataid'=>$data->id)); - foreach ($fields as $field) { - $content->recordid = $recordid; - $content->fieldid = $field->id; - $DB->insert_record('data_content',$content); - } - - //for each field in the add form, add it to the data_content. - foreach ($datarecord as $name => $value){ - if (!in_array($name, $ignorenames)) { - $namearr = explode('_', $name); // Second one is the field id - if (empty($field->field) || ($namearr[1] != $field->field->id)) { // Try to reuse classes - $field = data_get_field_from_id($namearr[1], $data); - } - if ($field) { - $field->update_content($recordid, $value, $name); - } - } - } + add_to_log($course->id, 'data', 'add', "view.php?d=$data->id&rid=$recordid", $data->id, $cm->id); - add_to_log($course->id, 'data', 'add', "view.php?d=$data->id&rid=$recordid", $data->id, $cm->id); + echo $OUTPUT->notification(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); - } + if (!empty($datarecord->saveandview)) { + redirect($CFG->wwwroot.'/mod/data/view.php?d='.$data->id.'&rid='.$recordid); } } - } // End of form processing + } +} // End of form processing - /// Print the browsing interface +/// Print the browsing interface - $patterns = array(); //tags to replace - $replacement = array(); //html to replace those yucky tags +$patterns = array(); //tags to replace +$replacement = array(); //html to replace those yucky tags - //form goes here first in case add template is empty - echo '
'; - echo '
'; - echo ''; - echo ''; - echo ''; - echo $OUTPUT->box_start('generalbox boxaligncenter boxwidthwide'); +//form goes here first in case add template is empty +echo ''; +echo '
'; +echo ''; +echo ''; +echo ''; +echo $OUTPUT->box_start('generalbox boxaligncenter boxwidthwide'); - if (!$rid){ - echo $OUTPUT->heading(get_string('newentry','data'), 2); - } +if (!$rid){ + echo $OUTPUT->heading(get_string('newentry','data'), 2); +} - /****************************************** - * Regular expression replacement section * - ******************************************/ - if ($data->addtemplate){ - $possiblefields = $DB->get_records('data_fields', array('dataid'=>$data->id), 'id'); - - ///then we generate strings to replace - foreach ($possiblefields as $eachfield){ - $field = data_get_field($eachfield, $data); - $patterns[]="[[".$field->field->name."]]"; - $replacements[] = $field->display_add_field($rid); - $patterns[]="[[".$field->field->name."#id]]"; - $replacements[] = 'field_'.$field->field->id; - } - $newtext = str_ireplace($patterns, $replacements, $data->{$mode}); +/****************************************** + * Regular expression replacement section * + ******************************************/ +if ($data->addtemplate){ + $possiblefields = $DB->get_records('data_fields', array('dataid'=>$data->id), 'id'); - } else { //if the add template is not yet defined, print the default form! - echo data_generate_default_template($data, 'addtemplate', $rid, true, false); - $newtext = ''; + ///then we generate strings to replace + foreach ($possiblefields as $eachfield){ + $field = data_get_field($eachfield, $data); + $patterns[]="[[".$field->field->name."]]"; + $replacements[] = $field->display_add_field($rid); + $patterns[]="[[".$field->field->name."#id]]"; + $replacements[] = 'field_'.$field->field->id; } + $newtext = str_ireplace($patterns, $replacements, $data->{$mode}); - echo $newtext; - echo '
'; - if ($rid) { - echo ' '; - } else { - echo ''; - } - echo '
'; - echo $OUTPUT->box_end(); - echo '
'; +} else { //if the add template is not yet defined, print the default form! + echo data_generate_default_template($data, 'addtemplate', $rid, true, false); + $newtext = ''; +} + +echo $newtext; +echo '
'; +if ($rid) { + echo ' '; +} else { + echo ''; +} +echo '
'; +echo $OUTPUT->box_end(); +echo '
'; /// Upload records section. Only for teachers and the admin. - if (has_capability('mod/data:manageentries',$context)) { - if ($import) { - echo $OUTPUT->box_start('generalbox boxaligncenter boxwidthwide'); - echo $OUTPUT->heading(get_string('uploadrecords', 'data'), 3); - - $maxuploadsize = get_max_upload_file_size(); - echo '
'; - echo '
'; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo '
'.get_string('csvfile', 'data').':'; - echo $OUTPUT->help_icon(moodle_help_icon::make('importcsv', get_string('csvimport', 'data'), 'data')); - echo '
'.get_string('fielddelimiter', 'data').':'; - echo get_string('defaultfielddelimiter', 'data').'
'.get_string('fieldenclosure', 'data').':'; - echo get_string('defaultfieldenclosure', 'data').'
'; - echo ''; - echo '
'; - echo '
'; - echo $OUTPUT->box_end(); - } else { - echo '
'; - echo ''.get_string('uploadrecords', 'data').''; - echo '
'; - } +if (has_capability('mod/data:manageentries',$context)) { + if ($import) { + echo $OUTPUT->box_start('generalbox boxaligncenter boxwidthwide'); + echo $OUTPUT->heading(get_string('uploadrecords', 'data'), 3); + + $maxuploadsize = get_max_upload_file_size(); + echo '
'; + echo '
'; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo '
'.get_string('csvfile', 'data').':'; + echo $OUTPUT->help_icon(moodle_help_icon::make('importcsv', get_string('csvimport', 'data'), 'data')); + echo '
'.get_string('fielddelimiter', 'data').':'; + echo get_string('defaultfielddelimiter', 'data').'
'.get_string('fieldenclosure', 'data').':'; + echo get_string('defaultfieldenclosure', 'data').'
'; + echo ''; + echo '
'; + echo '
'; + echo $OUTPUT->box_end(); + } else { + echo '
'; + echo ''.get_string('uploadrecords', 'data').''; + echo '
'; } +} /// Finish the page - // Print the stuff that need to come after the form fields. - if (!$fields = $DB->get_records('data_fields', array('dataid'=>$data->id))) { - print_error('nofieldindatabase', 'data'); - } - foreach ($fields as $eachfield) { - $field = data_get_field($eachfield, $data); - $field->print_after_form(); - } - - echo $OUTPUT->footer(); -?> +// Print the stuff that need to come after the form fields. +if (!$fields = $DB->get_records('data_fields', array('dataid'=>$data->id))) { + print_error('nofieldindatabase', 'data'); +} +foreach ($fields as $eachfield) { + $field = data_get_field($eachfield, $data); + $field->print_after_form(); +} + +echo $OUTPUT->footer(); +?> \ No newline at end of file diff --git a/mod/data/export.php b/mod/data/export.php index 20e8657f6f..31bf3fe02e 100644 --- a/mod/data/export.php +++ b/mod/data/export.php @@ -1,11 +1,36 @@ -. + +/** + * This file is part of the Database module for Moodle + * + * @copyright 2005 Martin Dougiamas http://dougiamas.com + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @package mod-data + */ require_once('../../config.php'); require_once('lib.php'); require_once('export_form.php'); -$d = required_param('d', PARAM_INT); // database ID +$d = required_param('d', PARAM_INT); + +$PAGE->set_url(new moodle_url($CFG->wwwroot.'/mod/data/export.php', array('d'=>$d))); if (! $data = $DB->get_record('data', array('id'=>$d))) { print_error('wrongdataid', 'data'); @@ -58,7 +83,7 @@ if($mform->is_cancelled()) { } elseif (!$formdata = (array) $mform->get_data()) { // build header to match the rest of the UI $PAGE->set_title($data->name); - $PAGE->set_button(update_module_button($cm->id, $course->id, get_string('modulename', 'data'))); + $PAGE->set_button($OUTPUT->update_module_button($cm->id, 'data')); echo $OUTPUT->header(); echo $OUTPUT->heading(format_string($data->name)); @@ -101,4 +126,4 @@ switch ($formdata['exporttype']) { } die(); -?> +?> \ No newline at end of file diff --git a/mod/data/field.php b/mod/data/field.php index 852d57785e..355026c6f1 100755 --- a/mod/data/field.php +++ b/mod/data/field.php @@ -1,342 +1,364 @@ -. + +/** + * This file is part of the Database module for Moodle + * + * @copyright 2005 Martin Dougiamas http://dougiamas.com + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @package mod-data + */ + +require_once('../../config.php'); +require_once('lib.php'); + +$id = optional_param('id', 0, PARAM_INT); // course module id +$d = optional_param('d', 0, PARAM_INT); // database id +$fid = optional_param('fid', 0 , PARAM_INT); // update field id +$newtype = optional_param('newtype','',PARAM_ALPHA); // type of the new field +$mode = optional_param('mode','',PARAM_ALPHA); +$defaultsort = optional_param('defaultsort', 0, PARAM_INT); +$defaultsortdir = optional_param('defaultsortdir', 0, PARAM_INT); +$cancel = optional_param('cancel', 0, PARAM_BOOL); + +if ($cancel) { + $mode = 'list'; +} + +$url = new moodle_url($CFG->wwwroot.'/mod/data/field.php'); +if ($fid !== 0) { + $url->param('fid', $fid); +} +if ($newtype !== '') { + $url->param('newtype', $newtype); +} +if ($mode !== '') { + $url->param('mode', $mode); +} +if ($defaultsort !== 0) { + $url->param('defaultsort', $defaultsort); +} +if ($defaultsortdir !== 0) { + $url->param('defaultsortdir', $defaultsortdir); +} +if ($cancel !== 0) { + $url->param('cancel', $cancel); +} + +if ($id) { + $url->param('id', $id); + $PAGE->set_url($url); + if (! $cm = get_coursemodule_from_id('data', $id)) { + print_error('invalidcoursemodule'); + } + if (! $course = $DB->get_record('course', array('id'=>$cm->course))) { + print_error('coursemisconf'); + } + if (! $data = $DB->get_record('data', array('id'=>$cm->instance))) { + print_error('invalidcoursemodule'); } - - if ($id) { - if (! $cm = get_coursemodule_from_id('data', $id)) { - print_error('invalidcoursemodule'); - } - if (! $course = $DB->get_record('course', array('id'=>$cm->course))) { - print_error('coursemisconf'); - } - if (! $data = $DB->get_record('data', array('id'=>$cm->instance))) { - print_error('invalidcoursemodule'); - } - - } else { - if (! $data = $DB->get_record('data', array('id'=>$d))) { - print_error('invalidid', 'data'); - } - if (! $course = $DB->get_record('course', array('id'=>$data->course))) { - print_error('invalidcoursemodule'); - } - if (! $cm = get_coursemodule_from_instance('data', $data->id, $course->id)) { - print_error('invalidcoursemodule'); - } +} else { + $url->param('d', $d); + $PAGE->set_url($url); + if (! $data = $DB->get_record('data', array('id'=>$d))) { + print_error('invalidid', 'data'); + } + if (! $course = $DB->get_record('course', array('id'=>$data->course))) { + print_error('invalidcoursemodule'); } + if (! $cm = get_coursemodule_from_instance('data', $data->id, $course->id)) { + print_error('invalidcoursemodule'); + } +} - require_login($course->id, true, $cm); +require_login($course->id, true, $cm); - $context = get_context_instance(CONTEXT_MODULE, $cm->id); - require_capability('mod/data:managetemplates', $context); +$context = get_context_instance(CONTEXT_MODULE, $cm->id); +require_capability('mod/data:managetemplates', $context); - /************************************ - * Data Processing * - ***********************************/ - switch ($mode) { +/************************************ + * Data Processing * + ***********************************/ +switch ($mode) { - case 'add': ///add a new field - if (confirm_sesskey() and $fieldinput = data_submitted()){ + case 'add': ///add a new field + if (confirm_sesskey() and $fieldinput = data_submitted()){ - //$fieldinput->name = data_clean_field_name($fieldinput->name); + //$fieldinput->name = data_clean_field_name($fieldinput->name); - /// Only store this new field if it doesn't already exist. - if (($fieldinput->name == '') or data_fieldname_exists($fieldinput->name, $data->id)) { + /// Only store this new field if it doesn't already exist. + if (($fieldinput->name == '') or data_fieldname_exists($fieldinput->name, $data->id)) { - $displaynoticebad = get_string('invalidfieldname','data'); + $displaynoticebad = get_string('invalidfieldname','data'); - } else { + } else { - /// Check for arrays and convert to a comma-delimited string - data_convert_arrays_to_strings($fieldinput); + /// Check for arrays and convert to a comma-delimited string + data_convert_arrays_to_strings($fieldinput); - /// Create a field object to collect and store the data safely - $type = required_param('type', PARAM_FILE); - $field = data_get_field_new($type, $data); + /// Create a field object to collect and store the data safely + $type = required_param('type', PARAM_FILE); + $field = data_get_field_new($type, $data); - $field->define_field($fieldinput); - $field->insert_field(); + $field->define_field($fieldinput); + $field->insert_field(); - /// Update some templates - data_append_new_field_to_templates($data, $fieldinput->name); + /// Update some templates + data_append_new_field_to_templates($data, $fieldinput->name); - add_to_log($course->id, 'data', 'fields add', - "field.php?d=$data->id&mode=display&fid=$fid", $fid, $cm->id); + add_to_log($course->id, 'data', 'fields add', + "field.php?d=$data->id&mode=display&fid=$fid", $fid, $cm->id); - $displaynoticegood = get_string('fieldadded','data'); - } + $displaynoticegood = get_string('fieldadded','data'); } - break; + } + break; - case 'update': ///update a field - if (confirm_sesskey() and $fieldinput = data_submitted()){ + case 'update': ///update a field + if (confirm_sesskey() and $fieldinput = data_submitted()){ - //$fieldinput->name = data_clean_field_name($fieldinput->name); + //$fieldinput->name = data_clean_field_name($fieldinput->name); - if (($fieldinput->name == '') or data_fieldname_exists($fieldinput->name, $data->id, $fieldinput->fid)) { + if (($fieldinput->name == '') or data_fieldname_exists($fieldinput->name, $data->id, $fieldinput->fid)) { - $displaynoticebad = get_string('invalidfieldname','data'); + $displaynoticebad = get_string('invalidfieldname','data'); - } else { - /// Check for arrays and convert to a comma-delimited string - data_convert_arrays_to_strings($fieldinput); + } else { + /// Check for arrays and convert to a comma-delimited string + data_convert_arrays_to_strings($fieldinput); - /// Create a field object to collect and store the data safely - $field = data_get_field_from_id($fid, $data); - $oldfieldname = $field->field->name; + /// Create a field object to collect and store the data safely + $field = data_get_field_from_id($fid, $data); + $oldfieldname = $field->field->name; - $field->field->name = $fieldinput->name; - $field->field->description = $fieldinput->description; + $field->field->name = $fieldinput->name; + $field->field->description = $fieldinput->description; - for ($i=1; $i<=10; $i++) { - if (isset($fieldinput->{'param'.$i})) { - $field->field->{'param'.$i} = $fieldinput->{'param'.$i}; - } else { - $field->field->{'param'.$i} = ''; - } + for ($i=1; $i<=10; $i++) { + if (isset($fieldinput->{'param'.$i})) { + $field->field->{'param'.$i} = $fieldinput->{'param'.$i}; + } else { + $field->field->{'param'.$i} = ''; } + } - $field->update_field(); + $field->update_field(); - /// Update the templates. - data_replace_field_in_templates($data, $oldfieldname, $field->field->name); + /// Update the templates. + data_replace_field_in_templates($data, $oldfieldname, $field->field->name); - add_to_log($course->id, 'data', 'fields update', - "field.php?d=$data->id&mode=display&fid=$fid", $fid, $cm->id); + add_to_log($course->id, 'data', 'fields update', + "field.php?d=$data->id&mode=display&fid=$fid", $fid, $cm->id); - $displaynoticegood = get_string('fieldupdated','data'); - } + $displaynoticegood = get_string('fieldupdated','data'); } - break; + } + break; - case 'delete': // Delete a field - if (confirm_sesskey()){ + case 'delete': // Delete a field + if (confirm_sesskey()){ - if ($confirm = optional_param('confirm', 0, PARAM_INT)) { + if ($confirm = optional_param('confirm', 0, PARAM_INT)) { - // Delete the field completely - if ($field = data_get_field_from_id($fid, $data)) { - $field->delete_field(); + // Delete the field completely + if ($field = data_get_field_from_id($fid, $data)) { + $field->delete_field(); - // Update the templates. - data_replace_field_in_templates($data, $field->field->name, ''); + // Update the templates. + data_replace_field_in_templates($data, $field->field->name, ''); - // Update the default sort field - if ($fid == $data->defaultsort) { - unset($rec); - $rec->id = $data->id; - $rec->defaultsort = 0; - $rec->defaultsortdir = 0; - $DB->update_record('data', $rec); - } + // Update the default sort field + if ($fid == $data->defaultsort) { + unset($rec); + $rec->id = $data->id; + $rec->defaultsort = 0; + $rec->defaultsortdir = 0; + $DB->update_record('data', $rec); + } - add_to_log($course->id, 'data', 'fields delete', - "field.php?d=$data->id", $field->field->name, $cm->id); + add_to_log($course->id, 'data', 'fields delete', + "field.php?d=$data->id", $field->field->name, $cm->id); - $displaynoticegood = get_string('fielddeleted', 'data'); - } + $displaynoticegood = get_string('fielddeleted', 'data'); + } - } else { + } else { - data_print_header($course,$cm,$data, false); + data_print_header($course,$cm,$data, false); - // Print confirmation message. - $field = data_get_field_from_id($fid, $data); + // Print confirmation message. + $field = data_get_field_from_id($fid, $data); - echo $OUTPUT->confirm(''.$field->name().': '.$field->field->name.'

'. get_string('confirmdeletefield','data'), - 'field.php?d='.$data->id.'&mode=delete&fid='.$fid.'&confirm=1', - 'field.php?d='.$data->id); + echo $OUTPUT->confirm(''.$field->name().': '.$field->field->name.'

'. get_string('confirmdeletefield','data'), + 'field.php?d='.$data->id.'&mode=delete&fid='.$fid.'&confirm=1', + 'field.php?d='.$data->id); - echo $OUTPUT->footer(); - exit; - } + echo $OUTPUT->footer(); + exit; } - break; + } + break; - case 'sort': // Set the default sort parameters - if (confirm_sesskey()) { - $rec->id = $data->id; - $rec->defaultsort = $defaultsort; - $rec->defaultsortdir = $defaultsortdir; + case 'sort': // Set the default sort parameters + if (confirm_sesskey()) { + $rec->id = $data->id; + $rec->defaultsort = $defaultsort; + $rec->defaultsortdir = $defaultsortdir; - $DB->update_record('data', $rec); - redirect($CFG->wwwroot.'/mod/data/field.php?d='.$data->id, get_string('changessaved'), 2); - exit; - } - break; + $DB->update_record('data', $rec); + redirect($CFG->wwwroot.'/mod/data/field.php?d='.$data->id, get_string('changessaved'), 2); + exit; + } + break; - default: - break; - } + default: + break; +} /// Print the browsing interface - ///get the list of possible fields (plugins) - $directories = get_list_of_plugins('mod/data/field/'); - $menufield = array(); +///get the list of possible fields (plugins) +$directories = get_list_of_plugins('mod/data/field/'); +$menufield = array(); - foreach ($directories as $directory){ - $menufield[$directory] = get_string($directory,'data'); //get from language files - } - asort($menufield); //sort in alphabetical order +foreach ($directories as $directory){ + $menufield[$directory] = get_string($directory,'data'); //get from language files +} +asort($menufield); //sort in alphabetical order - $PAGE->set_pagetype('mod-data-field-' . $newtype); - $PAGE->navbar->add(get_string('fields', 'data')); - if (($mode == 'new') && (!empty($newtype)) && confirm_sesskey()) { /// Adding a new field - data_print_header($course, $cm, $data,'fields'); +$PAGE->set_pagetype('mod-data-field-' . $newtype); +$PAGE->navbar->add(get_string('fields', 'data')); +if (($mode == 'new') && (!empty($newtype)) && confirm_sesskey()) { /// Adding a new field + data_print_header($course, $cm, $data,'fields'); - $field = data_get_field_new($newtype, $data); - $field->display_edit_field(); + $field = data_get_field_new($newtype, $data); + $field->display_edit_field(); - } else if ($mode == 'display' && confirm_sesskey()) { /// Display/edit existing field - data_print_header($course, $cm, $data,'fields'); +} else if ($mode == 'display' && confirm_sesskey()) { /// Display/edit existing field + data_print_header($course, $cm, $data,'fields'); - $field = data_get_field_from_id($fid, $data); - $field->display_edit_field(); + $field = data_get_field_from_id($fid, $data); + $field->display_edit_field(); - } else { /// Display the main listing of all fields - data_print_header($course, $cm, $data,'fields'); +} else { /// Display the main listing of all fields + data_print_header($course, $cm, $data,'fields'); - if (!$DB->record_exists('data_fields', array('dataid'=>$data->id))) { - 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 + if (!$DB->record_exists('data_fields', array('dataid'=>$data->id))) { + 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 + } else { //else print quiz style list of fields - $table = new html_table(); - $table->head = array(get_string('fieldname','data'), get_string('type','data'), get_string('fielddescription', 'data'), get_string('action','data')); - $table->align = array('left','left','left', 'center'); - $table->wrap = array(false,false,false,false); + $table = new html_table(); + $table->head = array(get_string('fieldname','data'), get_string('type','data'), get_string('fielddescription', 'data'), get_string('action','data')); + $table->align = array('left','left','left', 'center'); + $table->wrap = array(false,false,false,false); - if ($fff = $DB->get_records('data_fields', array('dataid'=>$data->id),'id')){ - foreach ($fff as $ff) { + if ($fff = $DB->get_records('data_fields', array('dataid'=>$data->id),'id')){ + foreach ($fff as $ff) { - $field = data_get_field($ff, $data); + $field = data_get_field($ff, $data); - $table->data[] = array( + $table->data[] = array( - ''.$field->field->name.'', + ''.$field->field->name.'', - $field->image().' '.get_string($field->type, 'data'), + $field->image().' '.get_string($field->type, 'data'), - shorten_text($field->field->description, 30), + shorten_text($field->field->description, 30), - ''. - ''.get_string('edit').''. - ' '. - ''. - ''.get_string('delete').'' + ''. + ''.get_string('edit').''. + ' '. + ''. + ''.get_string('delete').'' - ); - } + ); } - echo $OUTPUT->table($table); } + echo $OUTPUT->table($table); + } - echo '
'; - echo ''; - $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")); - echo $OUTPUT->help_icon(moodle_help_icon::make('fields', get_string('addafield','data'), 'data')); - echo '
'; - - echo '
'; - echo '
'; - echo '
'; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + echo ''; + echo ''; - $options = array(0 => get_string('ascending', 'data'), - 1 => get_string('descending', 'data')); - echo $OUTPUT->select(html_select::make($options, 'defaultsortdir', $data->defaultsortdir, false)); - echo ''; - echo '
'; - echo '
'; - echo '
'; + $options = array(0 => get_string('ascending', 'data'), + 1 => get_string('descending', 'data')); + echo $OUTPUT->select(html_select::make($options, 'defaultsortdir', $data->defaultsortdir, false)); + echo ''; + echo ''; + echo ''; + echo ''; - } +} /// Finish the page - echo $OUTPUT->footer(); - +echo $OUTPUT->footer(); -?> +?> \ No newline at end of file diff --git a/mod/data/field/latlong/kml.php b/mod/data/field/latlong/kml.php index fa451ac41b..29aebf6f71 100644 --- a/mod/data/field/latlong/kml.php +++ b/mod/data/field/latlong/kml.php @@ -1,5 +1,20 @@ . + // A lot of this initial stuff is copied from mod/data/view.php require_once('../../../../config.php'); @@ -11,6 +26,11 @@ $d = required_param('d', PARAM_INT); // database id $fieldid = required_param('fieldid', PARAM_INT); // field id $rid = optional_param('rid', 0, PARAM_INT); //record id +$url = new moodle_url($CFG->wwwroot.'/mod/data/field/latlong/kml.php', array('d'=>$d, 'fieldid'=>$fieldid)); +if ($rid !== 0) { + $url->param('rid', $rid); +} +$PAGE->set_url($url); if ($rid) { if (! $record = $DB->get_record('data_records', array('id'=>$rid))) { diff --git a/mod/data/import.php b/mod/data/import.php index 6aad72b4a3..1dba3c9fd7 100755 --- a/mod/data/import.php +++ b/mod/data/import.php @@ -1,184 +1,200 @@ -libdir.'/uploadlib.php'); - - require_login(); - - $id = optional_param('id', 0, PARAM_INT); // course module id - $d = optional_param('d', 0, PARAM_INT); // database id - $rid = optional_param('rid', 0, PARAM_INT); // record id - $fielddelimiter = optional_param('fielddelimiter', ',', PARAM_CLEANHTML); // characters used as field delimiters for csv file import - $fieldenclosure = optional_param('fieldenclosure', '', PARAM_CLEANHTML); // characters used as record delimiters for csv file import - - if ($id) { - if (! $cm = get_coursemodule_from_id('data', $id)) { - print_error('invalidcoursemodule'); - } - if (! $course = $DB->get_record('course', array('id'=>$cm->course))) { - print_error('coursemisconf'); - } - if (! $data = $DB->get_record('data', array('id'=>$cm->instance))) { - print_error('invalidcoursemodule'); - } +. + +/** + * This file is part of the Database module for Moodle + * + * @copyright 2005 Martin Dougiamas http://dougiamas.com + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @package mod-data + */ + +require_once('../../config.php'); +require_once('lib.php'); +require_once($CFG->libdir.'/uploadlib.php'); + +require_login(); + +$id = optional_param('id', 0, PARAM_INT); // course module id +$d = optional_param('d', 0, PARAM_INT); // database id +$rid = optional_param('rid', 0, PARAM_INT); // record id +$fielddelimiter = optional_param('fielddelimiter', ',', PARAM_CLEANHTML); // characters used as field delimiters for csv file import +$fieldenclosure = optional_param('fieldenclosure', '', PARAM_CLEANHTML); // characters used as record delimiters for csv file import + +$url = new moodle_url($CFG->wwwroot.'/mod/data/import.php'); +if ($rid !== 0) { + $url->param('rid', $rid); +} +if ($fielddelimiter !== '') { + $url->param('fielddelimiter', $fielddelimiter); +} +if ($fieldenclosure !== '') { + $url->param('fieldenclosure', $fieldenclosure); +} - } else { - if (! $data = $DB->get_record('data', array('id'=>$d))) { - print_error('invalidid', 'data'); - } - if (! $course = $DB->get_record('course', array('id'=>$data->course))) { - print_error('coursemisconf'); - } - if (! $cm = get_coursemodule_from_instance('data', $data->id, $course->id)) { - print_error('coursemisconf'); - } +if ($id) { + $url->param('id', $id); + $PAGE->set_url($url); + if (! $cm = get_coursemodule_from_id('data', $id)) { + print_error('invalidcoursemodule'); + } + if (! $course = $DB->get_record('course', array('id'=>$cm->course))) { + print_error('coursemisconf'); + } + if (! $data = $DB->get_record('data', array('id'=>$cm->instance))) { + print_error('invalidcoursemodule'); + } + +} else { + $url->param('d', $d); + $PAGE->set_url($url); + if (! $data = $DB->get_record('data', array('id'=>$d))) { + print_error('invalidid', 'data'); + } + if (! $course = $DB->get_record('course', array('id'=>$data->course))) { + print_error('coursemisconf'); } + if (! $cm = get_coursemodule_from_instance('data', $data->id, $course->id)) { + print_error('coursemisconf'); + } +} - require_login($course, false, $cm); +require_login($course, false, $cm); - $context = get_context_instance(CONTEXT_MODULE, $cm->id); - require_capability('mod/data:manageentries', $context); +$context = get_context_instance(CONTEXT_MODULE, $cm->id); +require_capability('mod/data:manageentries', $context); /// Print the page header - $strdata = get_string('modulenameplural','data'); - - $PAGE->set_title($data->name); - echo $OUTPUT->header(); - echo $OUTPUT->heading(format_string($data->name)); +$strdata = get_string('modulenameplural','data'); + +$PAGE->set_title($data->name); +echo $OUTPUT->header(); +echo $OUTPUT->heading(format_string($data->name)); /// Groups needed for Add entry tab - $currentgroup = groups_get_activity_group($cm); - $groupmode = groups_get_activity_groupmode($cm); +$currentgroup = groups_get_activity_group($cm); +$groupmode = groups_get_activity_groupmode($cm); /// Print the tabs - $currenttab = 'add'; - include('tabs.php'); - +$currenttab = 'add'; +include('tabs.php'); - $um = new upload_manager('recordsfile', false, false, null, false, 0); - if ($um->preprocess_files() && confirm_sesskey()) { - $filename = $um->files['recordsfile']['tmp_name']; +$um = new upload_manager('recordsfile', false, false, null, false, 0); - // Large files are likely to take their time and memory. Let PHP know - // that we'll take longer, and that the process should be recycled soon - // to free up memory. - @set_time_limit(0); - @raise_memory_limit("96M"); - if (function_exists('apache_child_terminate')) { - @apache_child_terminate(); - } +if ($um->preprocess_files() && confirm_sesskey()) { + $filename = $um->files['recordsfile']['tmp_name']; - //Fix mac/dos newlines - $text = my_file_get_contents($filename); - $text = preg_replace('!\r\n?!',"\n",$text); - $fp = fopen($filename, "w"); - fwrite($fp, $text); - fclose($fp); + // Large files are likely to take their time and memory. Let PHP know + // that we'll take longer, and that the process should be recycled soon + // to free up memory. + @set_time_limit(0); + @raise_memory_limit("96M"); + if (function_exists('apache_child_terminate')) { + @apache_child_terminate(); + } - $recordsadded = 0; + //Fix mac/dos newlines + $text = my_file_get_contents($filename); + $text = preg_replace('!\r\n?!',"\n",$text); + $fp = fopen($filename, "w"); + fwrite($fp, $text); + fclose($fp); - if (!$records = data_get_records_csv($filename, $fielddelimiter, $fieldenclosure)) { - print_error('csvfailed','data',"{$CFG->wwwroot}/mod/data/edit.php?d={$data->id}"); - } else { - $fieldnames = array_shift($records); + $recordsadded = 0; - // check the fieldnames are valid - $fields = $DB->get_records('data_fields', array('dataid'=>$data->id), '', 'name, id, type'); - $errorfield = ''; - foreach ($fieldnames as $name) { - if (!isset($fields[$name])) { - $errorfield .= "'$name' "; - } + if (!$records = data_get_records_csv($filename, $fielddelimiter, $fieldenclosure)) { + print_error('csvfailed','data',"{$CFG->wwwroot}/mod/data/edit.php?d={$data->id}"); + } else { + $fieldnames = array_shift($records); + + // check the fieldnames are valid + $fields = $DB->get_records('data_fields', array('dataid'=>$data->id), '', 'name, id, type'); + $errorfield = ''; + foreach ($fieldnames as $name) { + if (!isset($fields[$name])) { + $errorfield .= "'$name' "; } + } - if (!empty($errorfield)) { - print_error('fieldnotmatched','data',"{$CFG->wwwroot}/mod/data/edit.php?d={$data->id}",$errorfield); - } + if (!empty($errorfield)) { + print_error('fieldnotmatched','data',"{$CFG->wwwroot}/mod/data/edit.php?d={$data->id}",$errorfield); + } - foreach ($records as $record) { - if ($recordid = data_add_record($data, 0)) { // add instance to data_record - $fields = $DB->get_records('data_fields', array('dataid'=>$data->id), '', 'name, id, type'); + foreach ($records as $record) { + if ($recordid = data_add_record($data, 0)) { // add instance to data_record + $fields = $DB->get_records('data_fields', array('dataid'=>$data->id), '', 'name, id, type'); - // Insert new data_content fields with NULL contents: - foreach ($fields as $field) { - $content = new object(); - $content->recordid = $recordid; - $content->fieldid = $field->id; - $DB->insert_record('data_content', $content); + // Insert new data_content fields with NULL contents: + foreach ($fields as $field) { + $content = new object(); + $content->recordid = $recordid; + $content->fieldid = $field->id; + $DB->insert_record('data_content', $content); + } + // Fill data_content with the values imported from the CSV file: + foreach ($record as $key => $value) { + $name = $fieldnames[$key]; + $field = $fields[$name]; + $content = new object(); + $content->fieldid = $field->id; + $content->recordid = $recordid; + if ($field->type == 'textarea') { + // the only field type where HTML is possible + $value = clean_param($value, PARAM_CLEANHTML); + } else { + // remove potential HTML: + $patterns[] = '//'; + $replacements[] = '>'; + $value = preg_replace($patterns, $replacements, $value); } - // Fill data_content with the values imported from the CSV file: - foreach ($record as $key => $value) { - $name = $fieldnames[$key]; - $field = $fields[$name]; - $content = new object(); - $content->fieldid = $field->id; - $content->recordid = $recordid; - if ($field->type == 'textarea') { - // the only field type where HTML is possible - $value = clean_param($value, PARAM_CLEANHTML); - } else { - // remove potential HTML: - $patterns[] = '//'; - $replacements[] = '>'; - $value = preg_replace($patterns, $replacements, $value); - } - // for now, only for "latlong" and "url" fields, but that should better be looked up from - // $CFG->dirroot . '/mod/data/field/' . $field->type . '/field.class.php' - // once there is stored how many contents the field can have. - if (preg_match("/^(latlong|url)$/", $field->type)) { - $values = explode(" ", $value, 2); - $content->content = $values[0]; - $content->content1 = $values[1]; - } else { - $content->content = $value; - } - $oldcontent = $DB->get_record('data_content', array('fieldid'=>$field->id, 'recordid'=>$recordid)); - $content->id = $oldcontent->id; - $DB->update_record('data_content', $content); + // for now, only for "latlong" and "url" fields, but that should better be looked up from + // $CFG->dirroot . '/mod/data/field/' . $field->type . '/field.class.php' + // once there is stored how many contents the field can have. + if (preg_match("/^(latlong|url)$/", $field->type)) { + $values = explode(" ", $value, 2); + $content->content = $values[0]; + $content->content1 = $values[1]; + } else { + $content->content = $value; } - $recordsadded++; - print get_string('added', 'moodle', $recordsadded) . ". " . get_string('entry', 'data') . " (ID $recordid)
\n"; + $oldcontent = $DB->get_record('data_content', array('fieldid'=>$field->id, 'recordid'=>$recordid)); + $content->id = $oldcontent->id; + $DB->update_record('data_content', $content); } + $recordsadded++; + print get_string('added', 'moodle', $recordsadded) . ". " . get_string('entry', 'data') . " (ID $recordid)
\n"; } } } +} - if ($recordsadded > 0) { - echo $OUTPUT->notification($recordsadded. ' '. get_string('recordssaved', 'data')); - } else { - echo $OUTPUT->notification(get_string('recordsnotsaved', 'data')); - } - echo '

'; +if ($recordsadded > 0) { + echo $OUTPUT->notification($recordsadded. ' '. get_string('recordssaved', 'data')); +} else { + echo $OUTPUT->notification(get_string('recordsnotsaved', 'data')); +} +echo '

'; /// Finish the page - echo $OUTPUT->footer(); +echo $OUTPUT->footer(); diff --git a/mod/data/index.php b/mod/data/index.php index 9f1497e881..2731986dbd 100755 --- a/mod/data/index.php +++ b/mod/data/index.php @@ -1,143 +1,146 @@ -get_record('course', array('id'=>$id))) { - print_error('invalidcourseid'); +. + +/** + * This file is part of the Database module for Moodle + * + * @copyright 1990 Martin Dougiamas http://dougiamas.com + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @package mod-data + */ + +require_once("../../config.php"); +require_once("lib.php"); + +$id = required_param('id', PARAM_INT); // course + +$PAGE->set_url(new moodle_url($CFG->wwwroot.'/mod/data/index.php', array('id'=>$id))); + +if (!$course = $DB->get_record('course', array('id'=>$id))) { + print_error('invalidcourseid'); +} + +require_course_login($course); + +$context = get_context_instance(CONTEXT_COURSE, $course->id); + +add_to_log($course->id, "data", "view all", "index.php?id=$course->id", ""); + +$strweek = get_string('week'); +$strtopic = get_string('topic'); +$strname = get_string('name'); +$strdata = get_string('modulename','data'); +$strdataplural = get_string('modulenameplural','data'); + +$PAGE->navbar->add($strdata, new moodle_url($CFG->wwwroot.'/mod/data/index.php', array('id'=>$course->id))); +$PAGE->set_title($strdata); +echo $OUTPUT->header(); + +if (! $datas = get_all_instances_in_course("data", $course)) { + notice(get_string('thereareno', 'moodle',$strdataplural) , "$CFG->wwwroot/course/view.php?id=$course->id"); +} + +$timenow = time(); +$strname = get_string('name'); +$strweek = get_string('week'); +$strtopic = get_string('topic'); +$strdescription = get_string("description"); +$strentries = get_string('entries', 'data'); +$strnumnotapproved = get_string('numnotapproved', 'data'); + +$table = new html_table(); + +if ($course->format == 'weeks') { + $table->head = array ($strweek, $strname, $strdescription, $strentries, $strnumnotapproved); + $table->align = array ('center', 'center', 'center', 'center', 'center'); +} else if ($course->format == 'topics') { + $table->head = array ($strtopic, $strname, $strdescription, $strentries, $strnumnotapproved); + $table->align = array ('center', 'center', 'center', 'center', 'center'); +} else { + $table->head = array ($strname, $strdescription, $strentries, $strnumnotapproved); + $table->align = array ('center', 'center', 'center', 'center'); +} + +$rss = (!empty($CFG->enablerssfeeds) && !empty($CFG->data_enablerssfeeds)); + +if ($rss) { + require_once($CFG->libdir."/rsslib.php"); + array_push($table->head, 'RSS'); + array_push($table->align, 'center'); +} + +$options = new object(); +$options->noclean = true; + +$currentsection = ""; + +foreach ($datas as $data) { + + $printsection = ""; + + //Calculate the href + if (!$data->visible) { + //Show dimmed if the mod is hidden + $link = "coursemodule\">".format_string($data->name,true).""; + } else { + //Show normal if the mod is visible + $link = "coursemodule\">".format_string($data->name,true).""; } - require_course_login($course); - - $context = get_context_instance(CONTEXT_COURSE, $course->id); - - add_to_log($course->id, "data", "view all", "index.php?id=$course->id", ""); - - $strweek = get_string('week'); - $strtopic = get_string('topic'); - $strname = get_string('name'); - $strdata = get_string('modulename','data'); - $strdataplural = get_string('modulenameplural','data'); + // TODO: add group restricted counts here, and limit unapproved to ppl with approve cap only + link to approval page - $PAGE->navbar->add($strdata, new moodle_url($CFG->wwwroot.'/mod/data/index.php', array('id'=>$course->id))); - $PAGE->set_title($strdata); - echo $OUTPUT->header(); + $numrecords = $DB->count_records_sql('SELECT COUNT(r.id) FROM {data_records} r WHERE r.dataid =?', array($data->id)); - if (! $datas = get_all_instances_in_course("data", $course)) { - notice(get_string('thereareno', 'moodle',$strdataplural) , "$CFG->wwwroot/course/view.php?id=$course->id"); - } - - $timenow = time(); - $strname = get_string('name'); - $strweek = get_string('week'); - $strtopic = get_string('topic'); - $strdescription = get_string("description"); - $strentries = get_string('entries', 'data'); - $strnumnotapproved = get_string('numnotapproved', 'data'); - - $table = new html_table(); - - if ($course->format == 'weeks') { - $table->head = array ($strweek, $strname, $strdescription, $strentries, $strnumnotapproved); - $table->align = array ('center', 'center', 'center', 'center', 'center'); - } else if ($course->format == 'topics') { - $table->head = array ($strtopic, $strname, $strdescription, $strentries, $strnumnotapproved); - $table->align = array ('center', 'center', 'center', 'center', 'center'); + if ($data->approval == 1) { + $numunapprovedrecords = $DB->count_records_sql('SELECT COUNT(r.id) FROM {data_records} r WHERE r.dataid =? AND r.approved <> 1', array($data->id)); } else { - $table->head = array ($strname, $strdescription, $strentries, $strnumnotapproved); - $table->align = array ('center', 'center', 'center', 'center'); + $numunapprovedrecords = '-'; } - $rss = (!empty($CFG->enablerssfeeds) && !empty($CFG->data_enablerssfeeds)); - - if ($rss) { - require_once($CFG->libdir."/rsslib.php"); - array_push($table->head, 'RSS'); - array_push($table->align, 'center'); + $rsslink = ''; + if ($rss && $data->rssarticles > 0) { + $rsslink = rss_get_link($course->id, $USER->id, 'data', $data->id, 'RSS'); } - $options = new object(); - $options->noclean = true; - - $currentsection = ""; - - foreach ($datas as $data) { - - $printsection = ""; - - //Calculate the href - if (!$data->visible) { - //Show dimmed if the mod is hidden - $link = "coursemodule\">".format_string($data->name,true).""; - } else { - //Show normal if the mod is visible - $link = "coursemodule\">".format_string($data->name,true).""; - } - - // TODO: add group restricted counts here, and limit unapproved to ppl with approve cap only + link to approval page - - $numrecords = $DB->count_records_sql('SELECT COUNT(r.id) FROM {data_records} r WHERE r.dataid =?', array($data->id)); - - if ($data->approval == 1) { - $numunapprovedrecords = $DB->count_records_sql('SELECT COUNT(r.id) FROM {data_records} r WHERE r.dataid =? AND r.approved <> 1', array($data->id)); - } else { - $numunapprovedrecords = '-'; - } - - $rsslink = ''; - if ($rss && $data->rssarticles > 0) { - $rsslink = rss_get_link($course->id, $USER->id, 'data', $data->id, 'RSS'); - } - - if ($course->format == 'weeks' or $course->format == 'topics') { - if ($data->section !== $currentsection) { - if ($data->section) { - $printsection = $data->section; - } - if ($currentsection !== '') { - $table->data[] = 'hr'; - } - $currentsection = $data->section; + if ($course->format == 'weeks' or $course->format == 'topics') { + if ($data->section !== $currentsection) { + if ($data->section) { + $printsection = $data->section; } - $row = array ($printsection, $link, format_text($data->intro, $data->introformat, $options), $numrecords, $numunapprovedrecords); - - } else { - $row = array ($link, format_text($data->intro, $data->introformat, $options), $numrecords, $numunapprovedrecords); + if ($currentsection !== '') { + $table->data[] = 'hr'; + } + $currentsection = $data->section; } + $row = array ($printsection, $link, format_text($data->intro, $data->introformat, $options), $numrecords, $numunapprovedrecords); - if ($rss) { - array_push($row, $rsslink); - } + } else { + $row = array ($link, format_text($data->intro, $data->introformat, $options), $numrecords, $numunapprovedrecords); + } - $table->data[] = $row; + if ($rss) { + array_push($row, $rsslink); } - echo "
"; - echo $OUTPUT->table($table); - echo $OUTPUT->footer(); + $table->data[] = $row; +} + +echo "
"; +echo $OUTPUT->table($table); +echo $OUTPUT->footer(); -?> +?> \ No newline at end of file diff --git a/mod/data/js.php b/mod/data/js.php index 288be5ad5c..2b0bce5211 100644 --- a/mod/data/js.php +++ b/mod/data/js.php @@ -1,40 +1,44 @@ get_record('data', array('id'=>$d))) { - header('Last-Modified: ' . gmdate('D, d M Y H:i:s', time()) . ' GMT'); - header('Expires: ' . gmdate("D, d M Y H:i:s", time() + $lifetime) . ' GMT'); - header('Cache-control: max_age = '. $lifetime); - header('Pragma: '); - header('Content-type: text/css'); // Correct MIME type - - echo $data->jstemplate; - } + +// 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 . + +/** + * This file is part of the Database module for Moodle + * + * @copyright 2005 Martin Dougiamas http://dougiamas.com + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @package mod-data + */ + +define('NO_MOODLE_COOKIES', true); // session not used here + +require_once('../../config.php'); + +$d = optional_param('d', 0, PARAM_INT); // database id + +$PAGE->set_url(new moodle_url($CFG->wwwroot.'/mod/data/js.php', array('d'=>$d))); + +$lifetime = 600; // Seconds to cache this stylesheet + +if ($data = $DB->get_record('data', array('id'=>$d))) { + header('Last-Modified: ' . gmdate('D, d M Y H:i:s', time()) . ' GMT'); + header('Expires: ' . gmdate("D, d M Y H:i:s", time() + $lifetime) . ' GMT'); + header('Cache-control: max_age = '. $lifetime); + header('Pragma: '); + header('Content-type: text/css'); // Correct MIME type + + echo $data->jstemplate; +} \ No newline at end of file diff --git a/mod/data/lib.php b/mod/data/lib.php index 6f2af3454f..4b288ad5ac 100755 --- a/mod/data/lib.php +++ b/mod/data/lib.php @@ -1667,7 +1667,7 @@ function data_print_comments($data, $record, $page=0, $mform=false) { echo '
'; } - if (!isloggedin() or isguest() or !$cancomment) { + if (!isloggedin() or has_capability('moodle/legacy:guest', get_context_instance(CONTEXT_SYSTEM), 0, false) or !$cancomment) { return; } @@ -2054,7 +2054,7 @@ function data_print_header($course, $cm, $data, $currenttab='') { global $CFG, $displaynoticegood, $displaynoticebad, $OUTPUT, $PAGE; $PAGE->set_title($data->name); - $PAGE->set_button(update_module_button($cm->id, $course->id, get_string('modulename', 'data'))); + $PAGE->set_button($OUTPUT->update_module_button($cm->id, 'data')); echo $OUTPUT->header(); echo $OUTPUT->heading(format_string($data->name)); diff --git a/mod/data/preset.php b/mod/data/preset.php index 341456872a..5799c0c55c 100644 --- a/mod/data/preset.php +++ b/mod/data/preset.php @@ -1,8 +1,31 @@ -. + +/** + * Preset Menu * * This is the page that is the menu item in the config database * pages. + * + * This file is part of the Database module for Moodle + * + * @copyright 2005 Martin Dougiamas http://dougiamas.com + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @package mod-data */ require_once('../../config.php'); @@ -16,6 +39,17 @@ $action = optional_param('action', 'base', PARAM_ALPHANUM); // current action $fullname = optional_param('fullname', '', PARAM_PATH); // directory the preset is in $file = optional_param('file', '', PARAM_PATH); // uploaded file +$url = new moodle_url($CFG->wwwroot.'/mod/data/preset.php'); +if ($action !== 'base') { + $url->param('action', $action); +} +if ($fullname !== '') { + $url->param('fullname', $fullname); +} +if ($file !== '') { + $url->param('file', $file); +} + // find out preset owner userid and shortname $parts = explode('/', $fullname); $userid = empty($parts[0]) ? 0 : (int)$parts[0]; @@ -24,6 +58,8 @@ unset($parts); unset($fullname); if ($id) { + $url->param('id', $id); + $PAGE->set_url($url); if (! $cm = get_coursemodule_from_id('data', $id)) { print_error('invalidcoursemodule'); } @@ -34,6 +70,8 @@ if ($id) { print_error('invalidid', 'data'); } } else if ($d) { + $url->param('d', $d); + $PAGE->set_url($url); if (! $data = $DB->get_record('data', array('id'=>$d))) { print_error('invalidid', 'data'); } diff --git a/mod/data/rate.php b/mod/data/rate.php index 939ec26a14..8e10342e22 100755 --- a/mod/data/rate.php +++ b/mod/data/rate.php @@ -1,104 +1,107 @@ -get_record('data', array('id'=>$dataid))) { - print_error('invalidid', 'data'); - } +$dataid = required_param('dataid', PARAM_INT); // The forum the rated posts are from - if (!$course = $DB->get_record('course', array('id'=>$data->course))) { - print_error('invalidcourseid'); - } +$PAGE->set_url(new moodle_url($CFG->wwwroot.'/mod/data/rate.php', array('dataid'=>$dataid))); - if (!$cm = get_coursemodule_from_instance('data', $data->id)) { - print_error('invalidcoursemodule'); - } +if (!$data = $DB->get_record('data', array('id'=>$dataid))) { + print_error('invalidid', 'data'); +} - require_login($course, false, $cm); +if (!$course = $DB->get_record('course', array('id'=>$data->course))) { + print_error('invalidcourseid'); +} - if (isguestuser()) { - print_error('guestrate', 'data'); - } +if (!$cm = get_coursemodule_from_instance('data', $data->id)) { + print_error('invalidcoursemodule'); +} - $context = get_context_instance(CONTEXT_MODULE, $cm->id); - require_capability('mod/data:rate', $context); +require_login($course, false, $cm); - if (!$data->assessed) { - print_error('cannotrate', 'data'); - } +if (isguestuser()) { + print_error('guestrate', 'data'); +} - if (!$frmdata = data_submitted() or !confirm_sesskey()) { - print_error('invalidaccess', 'data'); - } +$context = get_context_instance(CONTEXT_MODULE, $cm->id); +require_capability('mod/data:rate', $context); -/// Calculate scale values - $scale_values = make_grades_menu($data->scale); +if (!$data->assessed) { + print_error('cannotrate', 'data'); +} - $count = 0; +if (!$frmdata = data_submitted() or !confirm_sesskey()) { + print_error('invalidaccess', 'data'); +} - foreach ((array)$frmdata as $recordid => $rating) { - if (!is_numeric($recordid)) { - continue; - } +/// Calculate scale values +$scale_values = make_grades_menu($data->scale); - if (!$record = $DB->get_record('data_records', array('id'=>$recordid))) { - print_error('invalidid', 'data'); - } +$count = 0; - if ($data->id != $record->dataid) { - print_error('invalidrecord', 'data'); - } +foreach ((array)$frmdata as $recordid => $rating) { + if (!is_numeric($recordid)) { + continue; + } - if ($record->userid == $USER->id) { - continue; - } + if (!$record = $DB->get_record('data_records', array('id'=>$recordid))) { + print_error('invalidid', 'data'); + } - /// Check rate is valid for that database scale values - if (!array_key_exists($rating, $scale_values) && $rating != -999) { - print_error('invalidrate', 'data', '', $rating); - } + if ($data->id != $record->dataid) { + print_error('invalidrecord', 'data'); + } - // input validation ok + if ($record->userid == $USER->id) { + continue; + } - $count++; +/// Check rate is valid for that database scale values + if (!array_key_exists($rating, $scale_values) && $rating != -999) { + print_error('invalidrate', 'data', '', $rating); + } - if ($oldrating = $DB->get_record('data_ratings', array('userid'=>$USER->id, 'recordid'=>$record->id))) { - if ($rating == -999) { - $DB->delete_records('data_ratings', array('userid'=>$oldrating->userid, 'recordid'=>$oldrating->recordid)); - data_update_grades($data, $record->userid); + // input validation ok - } else if ($rating != $oldrating->rating) { - $oldrating->rating = $rating; - $DB->update_record('data_ratings', $oldrating); - data_update_grades($data, $record->userid); + $count++; - } + if ($oldrating = $DB->get_record('data_ratings', array('userid'=>$USER->id, 'recordid'=>$record->id))) { + if ($rating == -999) { + $DB->delete_records('data_ratings', array('userid'=>$oldrating->userid, 'recordid'=>$oldrating->recordid)); + data_update_grades($data, $record->userid); - } else if ($rating) { - $newrating = new object(); - $newrating->userid = $USER->id; - $newrating->recordid = $record->id; - $newrating->rating = $rating; - $DB->insert_record('data_ratings', $newrating); + } else if ($rating != $oldrating->rating) { + $oldrating->rating = $rating; + $DB->update_record('data_ratings', $oldrating); data_update_grades($data, $record->userid); + } - } - if ($count == 0) { - print_error('invalidratedata', 'data'); + } else if ($rating) { + $newrating = new object(); + $newrating->userid = $USER->id; + $newrating->recordid = $record->id; + $newrating->rating = $rating; + $DB->insert_record('data_ratings', $newrating); + data_update_grades($data, $record->userid); } - - if (!empty($_SERVER['HTTP_REFERER'])) { - redirect($_SERVER['HTTP_REFERER'], get_string('ratingssaved', 'data')); +} + +if ($count == 0) { + print_error('invalidratedata', 'data'); +} + +if (!empty($_SERVER['HTTP_REFERER'])) { + redirect($_SERVER['HTTP_REFERER'], get_string('ratingssaved', 'data')); +} else { + // try to guess where to return + if ($count == 1) { + redirect('view.php?mode=single&rid='.$record->id, get_string('ratingssaved', 'data')); } else { - // try to guess where to return - if ($count == 1) { - redirect('view.php?mode=single&rid='.$record->id, get_string('ratingssaved', 'data')); - } else { - redirect('view.php?d='.$data->id, get_string('ratingssaved', 'data')); - } + redirect('view.php?d='.$data->id, get_string('ratingssaved', 'data')); } +} -?> +?> \ No newline at end of file diff --git a/mod/data/report.php b/mod/data/report.php index 6a181e008e..4cd8a7c3e6 100755 --- a/mod/data/report.php +++ b/mod/data/report.php @@ -1,84 +1,90 @@ -get_record('data_records', array('id'=>$id))) { - print_error('invalidrecord', 'data'); - } - - if (!$data = $DB->get_record('data', array('id'=>$record->dataid))) { - print_error('invalidid', 'data'); - } - - if (!$course = $DB->get_record('course', array('id'=>$data->course))) { - print_error('coursemisconf'); - } - - if (!$cm = get_coursemodule_from_instance('data', $data->id, $course->id)) { - print_error('invalidcoursemodule'); - } - - require_login($course->id, false, $cm); - $context = get_context_instance(CONTEXT_MODULE, $cm->id); - - if (!$data->assessed) { - print_error('norating', 'data'); - } - - if (!data_isowner($record->id) and !has_capability('mod/data:viewrating', $context) and !has_capability('mod/data:rate', $context)) { - print_error('cannotviewrate', 'data'); - } - - switch ($sort) { - case 'firstname': $sqlsort = "u.firstname ASC"; break; - case 'rating': $sqlsort = "r.rating ASC"; break; - default: $sqlsort = "r.id ASC"; - } - - $scalemenu = make_grades_menu($data->scale); - - $strratings = get_string('ratings', 'data'); - $strrating = get_string('rating', 'data'); - $strname = get_string('name'); - - $PAGE->set_title($strratings); - echo $OUTPUT->header(); - - if (!$ratings = data_get_ratings($record->id, $sqlsort)) { - print_error('noratingforrecord', 'data'); - - } else { - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - foreach ($ratings as $rating) { - if (has_capability('mod/data:manageentries', $context)) { - echo ''; - } else { - echo ''; - } - echo ''; - echo ''; - echo ''; - echo "\n"; +require_once("../../config.php"); +require_once("lib.php"); + +$id = required_param('id', PARAM_INT); +$sort = optional_param('sort', '', PARAM_ALPHA); + +$url = new moodle_url($CFG->wwwroot.'/mod/data/report.php', array('id'=>$id)); +if ($sort !== 0) { + $url->param('sort', $sort); +} +$PAGE->set_url($url); + +if (!$record = $DB->get_record('data_records', array('id'=>$id))) { + print_error('invalidrecord', 'data'); +} + +if (!$data = $DB->get_record('data', array('id'=>$record->dataid))) { + print_error('invalidid', 'data'); +} + +if (!$course = $DB->get_record('course', array('id'=>$data->course))) { + print_error('coursemisconf'); +} + +if (!$cm = get_coursemodule_from_instance('data', $data->id, $course->id)) { + print_error('invalidcoursemodule'); +} + +require_login($course->id, false, $cm); +$context = get_context_instance(CONTEXT_MODULE, $cm->id); + +if (!$data->assessed) { + print_error('norating', 'data'); +} + +if (!data_isowner($record->id) and !has_capability('mod/data:viewrating', $context) and !has_capability('mod/data:rate', $context)) { + print_error('cannotviewrate', 'data'); +} + +switch ($sort) { + case 'firstname': $sqlsort = "u.firstname ASC"; break; + case 'rating': $sqlsort = "r.rating ASC"; break; + default: $sqlsort = "r.id ASC"; +} + +$scalemenu = make_grades_menu($data->scale); + +$strratings = get_string('ratings', 'data'); +$strrating = get_string('rating', 'data'); +$strname = get_string('name'); + +$PAGE->set_title($strratings); +echo $OUTPUT->header(); + +if (!$ratings = data_get_ratings($record->id, $sqlsort)) { + print_error('noratingforrecord', 'data'); + +} else { + echo "
 id&sort=firstname\">$strname$strrating
'; - $userpic = moodle_user_picture::make($rating, $data->course); - $userpic->link = true; - echo $OUTPUT->user_picture($userpic); - echo '' . $OUTPUT->link($CFG->wwwroot.'/user/view.php?id='.$rating->id.'&course='.$data->course, fullname($rating)) . ''.$scalemenu[$rating->rating].'
"; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + foreach ($ratings as $rating) { + if (has_capability('mod/data:manageentries', $context)) { + echo ''; + } else { + echo ''; } - echo "
 id&sort=firstname\">$strname$strrating
"; - echo "
"; + echo ''; + $userpic = moodle_user_picture::make($rating, $data->course); + $userpic->link = true; + echo $OUTPUT->user_picture($userpic); + echo ''; + echo '' . $OUTPUT->link($CFG->wwwroot.'/user/view.php?id='.$rating->id.'&course='.$data->course, fullname($rating)) . ''; + echo ''.$scalemenu[$rating->rating].''; + echo "\n"; } + echo ""; + echo "
"; +} - echo $OUTPUT->close_window_button(); - echo $OUTPUT->footer(); -?> +echo $OUTPUT->close_window_button(); +echo $OUTPUT->footer(); +?> \ No newline at end of file diff --git a/mod/data/templates.php b/mod/data/templates.php index 3db76f0d9c..99068c30c8 100755 --- a/mod/data/templates.php +++ b/mod/data/templates.php @@ -1,291 +1,301 @@ -get_record('course', array('id'=>$cm->course))) { - print_error('coursemisconf'); - } - if (! $data = $DB->get_record('data', array('id'=>$cm->instance))) { - print_error('invalidcoursemodule'); - } +. + +/** + * This file is part of the Database module for Moodle + * + * @copyright 2005 Martin Dougiamas http://dougiamas.com + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @package mod-data + */ + +require_once('../../config.php'); +require_once('lib.php'); + +$id = optional_param('id', 0, PARAM_INT); // course module id +$d = optional_param('d', 0, PARAM_INT); // database id +$mode = optional_param('mode', 'singletemplate', PARAM_ALPHA); + +$url = new moodle_url($CFG->wwwroot.'/mod/data/templates.php'); +if ($mode !== 'singletemplate') { + $url->param('mode', $mode); +} + +if ($id) { + $url->param('id', $id); + $PAGE->set_url($url); + if (! $cm = get_coursemodule_from_id('data', $id)) { + print_error('invalidcoursemodule'); + } + if (! $course = $DB->get_record('course', array('id'=>$cm->course))) { + print_error('coursemisconf'); + } + if (! $data = $DB->get_record('data', array('id'=>$cm->instance))) { + print_error('invalidcoursemodule'); + } - } else { - if (! $data = $DB->get_record('data', array('id'=>$d))) { - print_error('invalidid', 'data'); - } - if (! $course = $DB->get_record('course', array('id'=>$data->course))) { - print_error('coursemisconf'); - } - if (! $cm = get_coursemodule_from_instance('data', $data->id, $course->id)) { - print_error('invalidcoursemodule'); - } +} else { + $url->param('d', $d); + $PAGE->set_url($url); + if (! $data = $DB->get_record('data', array('id'=>$d))) { + print_error('invalidid', 'data'); + } + if (! $course = $DB->get_record('course', array('id'=>$data->course))) { + print_error('coursemisconf'); + } + if (! $cm = get_coursemodule_from_instance('data', $data->id, $course->id)) { + print_error('invalidcoursemodule'); } +} - require_login($course->id, false, $cm); +require_login($course->id, false, $cm); - $context = get_context_instance(CONTEXT_MODULE, $cm->id); - require_capability('mod/data:managetemplates', $context); +$context = get_context_instance(CONTEXT_MODULE, $cm->id); +require_capability('mod/data:managetemplates', $context); - if (!$DB->count_records('data_fields', array('dataid'=>$data->id))) { // Brand new database! - redirect($CFG->wwwroot.'/mod/data/field.php?d='.$data->id); // Redirect to field entry - } +if (!$DB->count_records('data_fields', array('dataid'=>$data->id))) { // Brand new database! + redirect($CFG->wwwroot.'/mod/data/field.php?d='.$data->id); // Redirect to field entry +} - add_to_log($course->id, 'data', 'templates view', "templates.php?id=$cm->id&d=$data->id", $data->id, $cm->id); +add_to_log($course->id, 'data', 'templates view', "templates.php?id=$cm->id&d=$data->id", $data->id, $cm->id); /// Print the page header - $strdata = get_string('modulenameplural','data'); +$strdata = get_string('modulenameplural','data'); - // For the javascript for inserting template tags: initialise the default textarea to - // 'edit_template' - it is always present in all different possible views. +// For the javascript for inserting template tags: initialise the default textarea to +// 'edit_template' - it is always present in all different possible views. - $editorobj = 'editor_'.md5('template'); +$editorobj = 'editor_'.md5('template'); - $bodytag = 'onload="'; - $bodytag .= 'if (typeof('.$editorobj.') != \'undefined\') { currEditor = '.$editorobj.'; } '; - $bodytag .= 'currTextarea = document.getElementById(\'tempform\').template;'; - $bodytag .= '" '; +$bodytag = 'onload="'; +$bodytag .= 'if (typeof('.$editorobj.') != \'undefined\') { currEditor = '.$editorobj.'; } '; +$bodytag .= 'currTextarea = document.getElementById(\'tempform\').template;'; +$bodytag .= '" '; - $PAGE->navbar->add(get_string($mode,'data')); - $PAGE->requires->js('mod/data/data.js'); - $PAGE->set_title($data->name); - $PAGE->set_button(update_module_button($cm->id, $course->id, get_string('modulename', 'data'))); - echo $OUTPUT->header(); - echo $OUTPUT->heading(format_string($data->name)); +$PAGE->navbar->add(get_string($mode,'data')); +$PAGE->requires->js('mod/data/data.js'); +$PAGE->set_title($data->name); +$PAGE->set_button($OUTPUT->update_module_button($cm->id, 'data')); +echo $OUTPUT->header(); +echo $OUTPUT->heading(format_string($data->name)); /// Groups needed for Add entry tab - $currentgroup = groups_get_activity_group($cm); - $groupmode = groups_get_activity_groupmode($cm); +$currentgroup = groups_get_activity_group($cm); +$groupmode = groups_get_activity_groupmode($cm); /// Print the tabs. - $currenttab = 'templates'; - include('tabs.php'); +$currenttab = 'templates'; +include('tabs.php'); /// Processing submitted data, i.e updating form. - $resettemplate = false; - - if (($mytemplate = data_submitted()) && confirm_sesskey()) { - $newtemplate->id = $data->id; - $newtemplate->{$mode} = $mytemplate->template; - - if (!empty($mytemplate->defaultform)) { - // Reset the template to default, but don't save yet. - $resettemplate = true; - $data->{$mode} = data_generate_default_template($data, $mode, 0, false, false); - if ($mode == 'listtemplate') { - $data->listtemplateheader = ''; - $data->listtemplatefooter = ''; - } - } else { - if (isset($mytemplate->listtemplateheader)){ - $newtemplate->listtemplateheader = $mytemplate->listtemplateheader; - } - if (isset($mytemplate->listtemplatefooter)){ - $newtemplate->listtemplatefooter = $mytemplate->listtemplatefooter; - } - if (isset($mytemplate->rsstitletemplate)){ - $newtemplate->rsstitletemplate = $mytemplate->rsstitletemplate; - } +$resettemplate = false; + +if (($mytemplate = data_submitted()) && confirm_sesskey()) { + $newtemplate->id = $data->id; + $newtemplate->{$mode} = $mytemplate->template; + + if (!empty($mytemplate->defaultform)) { + // Reset the template to default, but don't save yet. + $resettemplate = true; + $data->{$mode} = data_generate_default_template($data, $mode, 0, false, false); + if ($mode == 'listtemplate') { + $data->listtemplateheader = ''; + $data->listtemplatefooter = ''; + } + } else { + if (isset($mytemplate->listtemplateheader)){ + $newtemplate->listtemplateheader = $mytemplate->listtemplateheader; + } + if (isset($mytemplate->listtemplatefooter)){ + $newtemplate->listtemplatefooter = $mytemplate->listtemplatefooter; + } + if (isset($mytemplate->rsstitletemplate)){ + $newtemplate->rsstitletemplate = $mytemplate->rsstitletemplate; + } - // 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)) { - echo $OUTPUT->notification(get_string('templatesaved', 'data'), 'notifysuccess'); - } + // 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)) { + 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); } - } else { - echo '

'.get_string('header'.$mode,'data').'
'; + add_to_log($course->id, 'data', 'templates saved', "templates.php?id=$cm->id&d=$data->id", $data->id, $cm->id); } +} else { + echo '
'.get_string('header'.$mode,'data').'
'; +} /// If everything is empty then generate some defaults - if (empty($data->addtemplate) and empty($data->singletemplate) and - empty($data->listtemplate) and empty($data->rsstemplate)) { - data_generate_default_template($data, 'singletemplate'); - data_generate_default_template($data, 'listtemplate'); - data_generate_default_template($data, 'addtemplate'); - data_generate_default_template($data, 'asearchtemplate'); //Template for advanced searches. - data_generate_default_template($data, 'rsstemplate'); - } - - - echo '
'; - echo '
'; - echo ''; - // Print button to autogen all forms, if all templates are empty - - if (!$resettemplate) { - // Only reload if we are not resetting the template to default. - $data = $DB->get_record('data', array('id'=>$d)); - } - echo $OUTPUT->box_start('generalbox boxaligncenter boxwidthwide'); - echo ''; +if (empty($data->addtemplate) and empty($data->singletemplate) and + empty($data->listtemplate) and empty($data->rsstemplate)) { + data_generate_default_template($data, 'singletemplate'); + data_generate_default_template($data, 'listtemplate'); + data_generate_default_template($data, 'addtemplate'); + data_generate_default_template($data, 'asearchtemplate'); //Template for advanced searches. + data_generate_default_template($data, 'rsstemplate'); +} + + +echo ''; +echo '
'; +echo ''; +// Print button to autogen all forms, if all templates are empty + +if (!$resettemplate) { + // Only reload if we are not resetting the template to default. + $data = $DB->get_record('data', array('id'=>$d)); +} +echo $OUTPUT->box_start('generalbox boxaligncenter boxwidthwide'); +echo '
'; /// Add the HTML editor(s). - $usehtmleditor = can_use_html_editor() && ($mode != 'csstemplate') && ($mode != 'jstemplate'); - if ($mode == 'listtemplate'){ - // Print the list template header. - echo ''; - echo ''; - echo ''; - echo ''; - } +$usehtmleditor = can_use_html_editor() && ($mode != 'csstemplate') && ($mode != 'jstemplate'); +if ($mode == 'listtemplate'){ + // Print the list template header. + echo ''; + echo ''; + echo ''; + echo ''; +} + +// Print the main template. - // Print the main template. +echo ''; + +echo ''; +echo ''; + +if ($mode == 'listtemplate'){ + echo ''; + echo ''; + echo ''; - + echo ''; +} else if ($mode == 'rsstemplate') { + echo ''; + echo ''; echo ''; echo ''; +} - if ($mode == 'listtemplate'){ - echo ''; - echo ''; - echo ''; - echo ''; - } else if ($mode == 'rsstemplate') { - echo ''; - echo ''; - echo ''; - echo ''; - } - - echo '
 '; - echo '
'; - print_textarea($usehtmleditor, 10, 72, 0, 0, 'listtemplateheader', $data->listtemplateheader); - echo '
 '; + echo '
'; + print_textarea($usehtmleditor, 10, 72, 0, 0, 'listtemplateheader', $data->listtemplateheader); + echo '
'; +if ($mode != 'csstemplate' and $mode != 'jstemplate') { + // Add all the available fields for this data. + echo ''; + echo $OUTPUT->help_icon(moodle_help_icon::make('tags', get_string('tags'), 'data')); + echo '
'; - echo '
'; - if ($mode != 'csstemplate' and $mode != 'jstemplate') { - // Add all the available fields for this data. - echo ''; - echo $OUTPUT->help_icon(moodle_help_icon::make('tags', get_string('tags'), 'data')); - echo '
'; + echo ''; + $fields = $DB->get_records('data_fields', array('dataid'=>$data->id)); + echo ''; + foreach ($fields as $field) { + echo ''; + } + echo ''; - $fields = $DB->get_records('data_fields', array('dataid'=>$data->id)); - echo ''; + if ($mode == 'addtemplate') { + echo ''; foreach ($fields as $field) { - echo ''; + if (in_array($field->type, array('picture', 'checkbox', 'date', 'latlong', 'radiobutton'))) { + continue; //ids are not usable for these composed items + } + echo ''; } echo ''; + } - if ($mode == 'addtemplate') { - echo ''; - foreach ($fields as $field) { - if (in_array($field->type, array('picture', 'checkbox', 'date', 'latlong', 'radiobutton'))) { - continue; //ids are not usable for these composed items - } - echo ''; - } - echo ''; + // Print special tags. fix for MDL-7031 + if ($mode != 'addtemplate' && $mode != 'asearchtemplate') { //Don't print special tags when viewing the advanced search template and add template. + echo ''; + echo ''; + echo ''; + echo ''; + if ($mode != 'rsstemplate') { + echo ''; } - - // Print special tags. fix for MDL-7031 - if ($mode != 'addtemplate' && $mode != 'asearchtemplate') { //Don't print special tags when viewing the advanced search template and add template. - echo ''; - echo ''; - echo ''; - echo ''; - if ($mode != 'rsstemplate') { - echo ''; - } - if ($mode != 'singletemplate') { - // more points to single template - not useable there - echo ''; - echo ''; - } - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - if ($mode != 'singletemplate') { - // more points to single template - not useable there - echo ''; - } - echo ''; + if ($mode != 'singletemplate') { + // more points to single template - not useable there + echo ''; + echo ''; } - - if ($mode == 'asearchtemplate') { - echo ''; - echo ''; - echo ''; - echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + if ($mode != 'singletemplate') { + // more points to single template - not useable there + echo ''; } + echo ''; + } - echo ''; - echo '



'; - if (can_use_html_editor()) { - echo '

'; - if ($usehtmleditor) { - $switcheditor = get_string('editordisable', 'data'); - } else { - $switcheditor = get_string('editorenable', 'data'); - } - echo ''; + if ($mode == 'asearchtemplate') { + echo ''; + echo ''; + echo ''; + echo ''; + } + + echo ''; + echo '



'; + if (can_use_html_editor()) { + echo '

'; + if ($usehtmleditor) { + $switcheditor = get_string('editordisable', 'data'); + } else { + $switcheditor = get_string('editorenable', 'data'); } - } else { - echo '



'; + echo ''; } +} else { + echo '



'; +} +echo '
'; +if ($mode == 'listtemplate'){ + echo '
'; +} else { + echo '
'; +} + +print_textarea($usehtmleditor, 20, 72, 0, 0, 'template', $data->{$mode}); +echo '
 '; + echo '
'; + print_textarea($usehtmleditor, 10, 72, 0, 0, 'listtemplatefooter', $data->listtemplatefooter); echo '
 '; - if ($mode == 'listtemplate'){ - echo '
'; - } else { - echo '
'; - } - - print_textarea($usehtmleditor, 20, 72, 0, 0, 'template', $data->{$mode}); + echo '
'; + print_textarea($usehtmleditor, 10, 72, 0, 0, 'rsstitletemplate', $data->rsstitletemplate); echo '
 '; - echo '
'; - print_textarea($usehtmleditor, 10, 72, 0, 0, 'listtemplatefooter', $data->listtemplatefooter); - echo '
 '; - echo '
'; - print_textarea($usehtmleditor, 10, 72, 0, 0, 'rsstitletemplate', $data->rsstitletemplate); - echo '
'; - echo ' '; +echo '
'; +echo ' '; - echo '
'; +echo ''; - echo $OUTPUT->box_end(); - echo '
'; - echo '
'; +echo $OUTPUT->box_end(); +echo ''; +echo ''; /// Finish the page - echo $OUTPUT->footer(); -?> +echo $OUTPUT->footer(); +?> \ No newline at end of file