public function definition()
 {
     global $CFG, $PAGE, $DB;
     $context = context_system::instance();
     $mform =& $this->_form;
     $strrequired = get_string('required');
     $mform->addElement('hidden', 'templateid', $this->templateid);
     $mform->addElement('hidden', 'templatename', $this->templaterecord->name);
     $mform->addElement('hidden', 'companyid', $this->companyid);
     $mform->setType('templateid', PARAM_INT);
     $mform->setType('companyid', PARAM_INT);
     $mform->setType('templatename', PARAM_CLEAN);
     $company = new company($this->companyid);
     // Then show the fields about where this block appears.
     $mform->addElement('header', 'header', get_string('email_template', 'local_email', array('name' => $this->templaterecord->name, 'companyname' => $company->get_name())));
     $mform->addElement('text', 'subject', get_string('subject', 'local_email'), array('size' => 100));
     $mform->setType('subject', PARAM_NOTAGS);
     $mform->addRule('subject', $strrequired, 'required');
     /* GWL : To replace text area with Rich text editor make textarea code commented 
     		$mform->addElement('textarea', 'body_editor', get_string('body', 'local_email'), 'wrap="virtual" rows="50" cols="100"');
     		 $mform->addHelpButton('body_editor', 'coursesummary');
     		 $mform->setType('body_editor', PARAM_NOTAGS);
     		 $mform->addRule('body_editor', $strrequired, 'required');
              */
     $mform->addElement('editor', 'emailbody_editor', get_string('body', 'local_email'), null, $this->editoroptions);
     $mform->setType('emailbody', PARAM_RAW);
     //end
     $vars = EmailVars::vars();
     $options = "<option value=''>" . get_string('select_email_var', 'local_email') . "</option>";
     foreach ($vars as $i) {
         $options .= "<option value='{{$i}}'>{$i}</option>";
     }
     /*GWL : Code Add for Placeholders $select = "<select class='emailvars' onchange='window.Perficio.onSelectEmailVar(this)'>
       $options</select>";*/
     $select = "<select class='emailvars'>{$options}</select>";
     // End Code
     $html = "<div class='fitem'><div class='fitemtitle'></div><div class='felement'>\n                 {$select}</div></div>";
     $mform->addElement('html', $html);
     global $PAGE;
     //GWL : Add JS
     $PAGE->requires->jquery();
     $PAGE->requires->js('/local/email/module.js');
     $submitlabel = null;
     // Default.
     if ($this->isadding) {
         $submitlabel = get_string('save_to_override_default_template', 'local_email');
         $mform->addElement('hidden', 'createnew', 1);
         $mform->setType('createnew', PARAM_INT);
     }
     $this->add_action_buttons(true, $submitlabel);
 }
Example #2
0
 /**
  * Sets up the email class vars for the given template
  *
  * Parameters - $templatestring = text;
  *
  **/
 public function fill($templatestring)
 {
     $amethods = EmailVars::vars();
     $vars = new EmailVars($this->company, $this->user, $this->course, $this->invoice, $this->classroom, $this->license, $this->sender, $this->approveuser, $this->event);
     foreach ($amethods as $funcname) {
         $replacement = "{" . $funcname . "}";
         if (stripos($templatestring, $replacement) !== false) {
             $val = $vars->{$funcname};
             $templatestring = str_replace($replacement, $val, $templatestring);
         }
     }
     return $templatestring;
 }