]> git.mjollnir.org Git - moodle.git/commitdiff
mod-feedback MDL-19807 Fixed up final deprecated methods
authorSam Hemelryk <sam@moodle.com>
Mon, 21 Dec 2009 03:57:36 +0000 (03:57 +0000)
committerSam Hemelryk <sam@moodle.com>
Mon, 21 Dec 2009 03:57:36 +0000 (03:57 +0000)
mod/feedback/edit_item.php
mod/feedback/item/label/label_form.php
mod/feedback/item/label/lib.php
mod/feedback/lib.php
mod/feedback/restorelib.php

index 2d4b922f3dd45aa22f8e0024e59fcfec8b9b008f..3ac893703d76f74a7b5151beb65bcf55baf59054 100644 (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();
 
 /*
index 3c02cda7d92dcba40077c100b2211ba989bcf1b0..c577e6c6e209556e1b5112062f970d5d17c9c627 100644 (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);
     }
 }
 
index 64dbdfca4a120e7b40362786433ffc7fe36af365..9daa6ff12dc457ded30154c6530eca07c7f73cd8 100644 (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
     }
index 23a5e5267150ca03ed9f223cc7f1454a679eba30..46c355b6887d56b4fdd9ae059b14f230f621dca7 100644 (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;
index 0e36011d7f98679c5927b3dfcfe509204419c81e..bb99df082f492c537badab93b5bc010666f49744 100644 (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
                 $event->visible      = instance_is_visible('feedback', $feedback);
                 $event->timeduration = 0;
 
-                add_event($event);
+                calendar_event::create($event);
              }
 
             //Do some output