function definition()
 {
     global $USER, $CFG;
     require_once "{$CFG->dirroot}/blocks/ilp/block_ilp_lib.php";
     $mform =& $this->_form;
     $courseid = $this->_customdata['courseid'];
     $userid = $this->_customdata['userid'];
     $id = $this->_customdata['id'];
     $status = $this->_customdata['status'];
     $concernspost = $this->_customdata['concernspost'];
     $thisreporttype = $this->_customdata['reporttype'];
     $template = $this->_customdata['template'];
     $user = get_record('user', 'id', $userid);
     //$report_no = $status + 1;
     //$template = stripslashes(eval('return $CFG->ilpconcern_report'.$report_no.'_template;'));
     //}else{
     //$template = '';
     //}
     if ($concernspost > 0) {
         $report = get_record('ilpconcern_posts', 'setforuserid', $userid, 'id', $concernspost);
     }
     if ($user == $USER) {
         $mform->addElement('header', 'title', get_string('myreport', 'ilpconcern', $thisreporttype));
     } else {
         $mform->addElement('header', 'title', get_string('reportfor', 'ilpconcern', fullname($user)));
     }
     $mform->addElement('hidden', 'userid', $userid);
     if ($courseid != SITEID) {
         $mform->addElement('hidden', 'courseid', $courseid);
     }
     if ($id > 0) {
         $mform->addElement('hidden', 'id', $id);
     }
     if ($concernspost > 0 && $report) {
         $mform->addElement('hidden', 'concernspost', $concernspost);
     }
     $mform->addElement('hidden', 'status', $status);
     $mform->addElement('hidden', 'reporttype', $thisreporttype);
     $mform->addElement('checkbox', 'courserelated', get_string('courserelated', 'ilpconcern'));
     if ($concernspost > 0 && $report) {
         $mform->setDefault('courserelated', $report->courserelated);
     }
     $ilpcourses = get_my_ilp_courses($user->id);
     $options = array();
     foreach ($ilpcourses as $ilpcourse) {
         $options[$ilpcourse->id] = $ilpcourse->shortname;
     }
     $mform->addElement('select', 'targetcourse', get_string('course'), $options);
     $mform->disabledIf('targetcourse', 'courserelated');
     if ($concernspost > 0 && $report) {
         $mform->setDefault('targetcourse', $report->targetcourse);
     } else {
         $mform->setDefault('targetcourse', $courseid);
     }
     $mform->addElement('htmleditor', 'concernset', $thisreporttype, array('canUseHtmlEditor' => 'detect', 'rows' => 20, 'cols' => 65));
     $mform->setType('concernset', PARAM_RAW);
     $mform->addRule('concernset', null, 'required', null, 'client');
     $mform->setHelpButton('concernset', array('writing', 'richtext'), false, 'editorhelpbutton');
     if ($concernspost > 0 && $report) {
         $mform->setDefault('concernset', $report->concernset);
     } else {
         $select = "module = 'ilpconcern' AND status = {$status}";
         if ($CFG->ilpconcern_use_template == 1 && $template > 0) {
             $thistemplate = get_record('ilp_module_template', 'id', $template);
             $usetemplate = stripslashes($thistemplate->text);
         } elseif (count_records_select('ilp_module_template', $select) == 1) {
             $thistemplate = get_record_select('ilp_module_template', $select);
             $usetemplate = stripslashes($thistemplate->text);
         } else {
             $usetemplate = '';
         }
         $mform->setDefault('concernset', $usetemplate);
     }
     $mform->addElement('format', 'format', get_string('format'));
     $mform->addElement('date_selector', 'deadline', get_string('deadline', 'ilpconcern'));
     if ($concernspost > 0 && $report) {
         $mform->setDefault('deadline', $report->deadline);
     } else {
         $mform->setDefault('deadline', time());
     }
     $this->add_action_buttons($cancel = true, $submitlabel = get_string('savechanges'));
 }
 function definition()
 {
     global $USER, $CFG;
     require_once "{$CFG->dirroot}/blocks/ilp/block_ilp_lib.php";
     $mform =& $this->_form;
     $courseid = $this->_customdata['courseid'];
     $userid = $this->_customdata['userid'];
     $id = $this->_customdata['id'];
     $targetpost = $this->_customdata['targetpost'];
     $user = get_record('user', 'id', $userid);
     if ($targetpost > 0) {
         $report = get_record('ilptarget_posts', 'setforuserid', $userid, 'id', $targetpost);
     }
     if ($user->id == $USER->id) {
         $mform->addElement('header', 'title', get_string('mytarget', 'ilptarget'));
     } else {
         $mform->addElement('header', 'title', get_string('targetfor', 'ilptarget', fullname($user)));
     }
     $mform->addElement('hidden', 'userid', $userid);
     if ($courseid != SITEID) {
         $mform->addElement('hidden', 'courseid', $courseid);
     }
     if ($id > 0) {
         $mform->addElement('hidden', 'id', $id);
     }
     if ($targetpost > 0 && $report) {
         $mform->addElement('hidden', 'targetpost', $targetpost);
     }
     $mform->addElement('text', 'name', get_string('name', 'ilptarget'), array('size' => '60'));
     $mform->addRule('name', null, 'required', null, 'client');
     if ($targetpost > 0 && $report) {
         $mform->setDefault('name', $report->name);
     }
     $mform->addElement('checkbox', 'courserelated', get_string('courserelated', 'ilptarget'));
     if ($targetpost > 0 && $report) {
         $mform->setDefault('courserelated', $report->courserelated);
     }
     $ilpcourses = get_my_ilp_courses($user->id);
     $options = array();
     foreach ($ilpcourses as $ilpcourse) {
         $options[$ilpcourse->id] = $ilpcourse->shortname;
     }
     $mform->addElement('select', 'targetcourse', get_string('course'), $options);
     $mform->disabledIf('targetcourse', 'courserelated');
     if ($targetpost > 0 && $report) {
         $mform->setDefault('targetcourse', $report->targetcourse);
     } else {
         $mform->setDefault('targetcourse', $courseid);
     }
     $mform->addElement('htmleditor', 'targetset', get_string('targetagreed', 'ilptarget'));
     $mform->setType('targetset', PARAM_RAW);
     $mform->addRule('targetset', null, 'required', null, 'client');
     $mform->setHelpButton('targetset', array('writing', 'richtext'), false, 'editorhelpbutton');
     if ($targetpost > 0 && $report) {
         $mform->setDefault('targetset', $report->targetset);
     } else {
         if ($CFG->ilptarget_use_template == 1) {
             $template = stripslashes($CFG->ilptarget_template);
         } else {
             $template = '';
         }
         $mform->setDefault('targetset', $template);
     }
     $mform->addElement('format', 'format', get_string('format'));
     $mform->addElement('date_selector', 'deadline', get_string('deadline', 'ilptarget'));
     if ($targetpost > 0 && $report) {
         $mform->setDefault('deadline', $report->deadline);
     } else {
         $mform->setDefault('deadline', time());
     }
     $this->add_action_buttons($cancel = true, $submitlabel = get_string('savechanges'));
 }