mod-feedback MDL-19807 Fixed up final deprecated methods

This commit is contained in:
Sam Hemelryk
2009-12-21 03:57:36 +00:00
parent aff69a26fc
commit d185ff44e1
5 changed files with 83 additions and 79 deletions
+53 -67
View File
@@ -82,73 +82,6 @@ if($itemid and $item = $DB->get_record('feedback_item', array('id'=>$itemid))) {
require_once($CFG->dirroot.'/mod/feedback/item/'.$typ.'/lib.php');
////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////
if(isset($formdata->cancel)){
redirect(htmlspecialchars('edit.php?id=' . $id));
}
// if(isset($formdata->editcancel) AND $formdata->editcancel == 1){
// redirect(htmlspecialchars('edit.php?id=' . $id));
// }
if(isset($formdata->saveitem) AND $formdata->saveitem == 1){
$newposition = $formdata->position;
$formdata->position = $newposition + 1;
if (!$newitemid = feedback_create_item($formdata)) {
$SESSION->feedback->errors[] = get_string('item_creation_failed', 'feedback');
}else {
$newitem = $DB->get_record('feedback_item', array('id'=>$newitemid));
if (!feedback_move_item($newitem, $newposition)){
$SESSION->feedback->errors[] = get_string('item_creation_failed', 'feedback');
}else {
redirect(htmlspecialchars('edit.php?id='.$id));
}
}
}
if(isset($formdata->updateitem) AND $formdata->updateitem == 1){
//update the item and go back
if (!feedback_update_item($item, $formdata)) {
$SESSION->feedback->errors[] = get_string('item_update_failed', 'feedback');
} else {
if (!feedback_move_item($item, $formdata->position)){
$SESSION->feedback->errors[] = get_string('item_update_failed', 'feedback');
}else {
redirect(htmlspecialchars('edit.php?id='.$id));
}
}
}
////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////
/// Print the page header
$strfeedbacks = get_string("modulenameplural", "feedback");
$strfeedback = get_string("modulename", "feedback");
$PAGE->navbar->add($strfeedbacks, new moodle_url($CFG->wwwroot.'/mod/feedback/index.php', array('id'=>$course->id)));
$PAGE->navbar->add(format_string($feedback->name));
$PAGE->set_title(format_string($feedback->name));
$PAGE->set_button($OUTPUT->update_module_button($cm->id, 'feedback'));
echo $OUTPUT->header();
/// print the tabs
include('tabs.php');
/// Print the main part of the page
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
echo $OUTPUT->heading(format_text($feedback->name));
//print errormsg
if(isset($error)){echo $error;}
feedback_print_errors();
//new formdefinition
$itemclass = 'feedback_item_'.$typ;
$itemobj = new $itemclass();
@@ -195,6 +128,59 @@ if(!empty($item->id)){
// $i_form->addElement('cancel');
$buttonarray[] = &$i_form->createElement('cancel');
$i_form->addGroup($buttonarray, 'buttonar', '', array(' '), false);
////////////////////////////////////////////////////////////////////////////////////
$item_form->set_data($item);
if ($formdata = $item_form->get_data()) {
if (isset($formdata->cancel)){
redirect(htmlspecialchars('edit.php?id=' . $id));
} else if (isset($formdata->saveitem) AND $formdata->saveitem == 1) {
$newposition = $formdata->position;
$formdata->position = $newposition + 1;
if (!$newitemid = feedback_create_item($formdata)) {
$SESSION->feedback->errors[] = get_string('item_creation_failed', 'feedback');
}else {
$newitem = $DB->get_record('feedback_item', array('id'=>$newitemid));
if (!feedback_move_item($newitem, $newposition)){
$SESSION->feedback->errors[] = get_string('item_creation_failed', 'feedback');
}else {
redirect(htmlspecialchars('edit.php?id='.$id));
}
}
} else if (isset($formdata->updateitem) AND $formdata->updateitem == 1) {
//update the item and go back
if (!feedback_update_item($item, $formdata)) {
$SESSION->feedback->errors[] = get_string('item_update_failed', 'feedback');
} else {
if (!feedback_move_item($item, $formdata->position)){
$SESSION->feedback->errors[] = get_string('item_update_failed', 'feedback');
}else {
redirect(htmlspecialchars('edit.php?id='.$id));
}
}
}
}
////////////////////////////////////////////////////////////////////////////////////
/// Print the page header
$strfeedbacks = get_string("modulenameplural", "feedback");
$strfeedback = get_string("modulename", "feedback");
$PAGE->navbar->add($strfeedbacks, new moodle_url($CFG->wwwroot.'/mod/feedback/index.php', array('id'=>$course->id)));
$PAGE->navbar->add(format_string($feedback->name));
$PAGE->set_title(format_string($feedback->name));
$PAGE->set_button($OUTPUT->update_module_button($cm->id, 'feedback'));
echo $OUTPUT->header();
/// print the tabs
include('tabs.php');
/// Print the main part of the page
echo $OUTPUT->heading(format_text($feedback->name));
//print errormsg
if(isset($error)) {
echo $error;
}
feedback_print_errors();
$item_form->display();
/*
+15 -1
View File
@@ -13,7 +13,21 @@ class feedback_label_form extends feedback_item_form {
$mform->addElement('hidden', 'itemname', $this->type);
$mform->setType('itemname', PARAM_INT);
$this->area = $mform->addElement('htmleditor', 'presentation', '', array('rows'=>20));
$mform->addElement('editor', 'presentation', '', null, null);
$mform->setType('presentation', PARAM_CLEANHTML);
}
function get_data() {
$data = parent::get_data();
if ($data) {
$data->presentation = $data->presentation['text'];
}
return $data;
}
function set_data($data) {
$data->presentation = array('text'=>$data->presentation, 'format'=>FORMAT_HTML, 'itemid'=>0);
return parent::set_data($data);
}
}
+2 -5
View File
@@ -14,16 +14,13 @@ class feedback_item_label extends feedback_item_base {
require_once('label_form.php');
$item_form = new feedback_label_form();
$item->presentation = isset($item->presentation) ? $item->presentation : '';
$item_form->area->setValue($item->presentation);
return $item_form;
}
function print_item($item){
?>
<td colspan="2">
<?php echo format_text($item->presentation);?>
<?php echo format_text($item->presentation, FORMAT_HTML);?>
</td>
<?php
}
+10 -4
View File
@@ -976,8 +976,11 @@ function feedback_create_item($data) {
$itemname = trim($data->itemname);
$item->name = ($itemname ? $data->itemname : get_string('no_itemname', 'feedback'));
$itemlabel = trim($data->itemlabel);
$item->label = ($itemlabel ? $data->itemlabel : get_string('no_itemlabel', 'feedback'));
if (!empty($data->itemlabel)) {
$item->label = trim($data->itemlabel);
} else {
$item->label = get_string('no_itemlabel', 'feedback');
}
//get the used class from item-typ
$itemclass = 'feedback_item_'.$data->typ;
@@ -1013,8 +1016,11 @@ function feedback_update_item($item, $data = null){
$itemname = trim($data->itemname);
$item->name = ($itemname ? $data->itemname : get_string('no_itemname', 'feedback'));
$itemlabel = trim($data->itemlabel);
$item->label = ($itemlabel ? $data->itemlabel : get_string('no_itemlabel', 'feedback'));
if (!empty($data->itemlabel)) {
$item->label = trim($data->itemlabel);
} else {
$item->label = get_string('no_itemlabel', 'feedback');
}
//get the used class from item-typ
$itemclass = 'feedback_item_'.$data->typ;
+3 -2
View File
@@ -26,6 +26,7 @@
//
//-----------------------------------------------------------
require_once($CFG->dirroot.'/calendar/lib.php');
define('FEEDBACK_MULTICHOICERESTORE_TYPE_SEP', '>>>>>');
function feedback_restore_mods($mod,$restore) {
@@ -84,7 +85,7 @@
$event->timeduration = 0;
}
add_event($event);
calendar_event::create($event);
}
// the close-event
@@ -102,7 +103,7 @@
$event->visible = instance_is_visible('feedback', $feedback);
$event->timeduration = 0;
add_event($event);
calendar_event::create($event);
}
//Do some output