function get_content()
 {
     global $USER, $CFG;
     require_once $CFG->dirroot . '/blocks/contact_form/lib.php';
     if ($this->content !== NULL) {
         return $this->content;
     }
     $this->content = new stdClass();
     $this->content->footer = '';
     $this->content->text = '';
     //empty to start, will be populated below
     $this->content->header = $this->title;
     if (empty($this->instance)) {
         // We're being asked for content without an associated instance
         return $this->content;
     }
     $cid = $this->instance->pageid;
     // course id
     $bid = $this->instance->id;
     // block  id
     $allhiddenrecipients = getallhiddenrecipients($cid, $bid);
     $allstandardrecipients = getallstandardrecipients($bid);
     $debug = false;
     if ($debug) {
         echo '****** Written from line ' . __LINE__ . ' of ' . __FILE__ . ' ********<br />';
         echo '$cid = ' . $cid . '<br />';
         echo '$bid = ' . $bid . '<br />';
         echo '$rcp = ' . $this->receipt . '<br />';
         echo 'count($allhiddenrecipients) = ' . count($allhiddenrecipients) . '<br />';
         echo 'count($allstandardrecipients) = ' . count($allstandardrecipients) . '<br />';
     }
     if (!($allhiddenrecipients || $allstandardrecipients)) {
         $this->content->text = get_string('block_misconfigured', 'block_contact_form');
         $this->content->footer = get_string('block_misconfigured_footer', 'block_contact_form');
     } else {
         //print_object($this);
         //set displaytype and linktext to stored values if defined
         if (isset($CFG->block_contact_form_display_type)) {
             $displaytype = $CFG->block_contact_form_display_type;
         } else {
             $displaytype = 0;
         }
         if (empty($this->config->displaytype)) {
             $displaytype = 2;
         } else {
             $displaytype = $this->config->displaytype;
         }
         if (empty($this->config->linktext)) {
             if ($cid == 1) {
                 $linktext = get_string('contactus_site', 'block_contact_form');
             } else {
                 $linktext = get_string('contactus_course', 'block_contact_form');
             }
         } else {
             $linktext = $this->config->linktext;
         }
         //check our configuration setting to see what format we should display
         // 0 == display a form button
         // 1 == display a link
         if ($displaytype == 1) {
             $this->content->text = '<div style="text-align: center;">';
             $this->content->text .= '<a href="' . $CFG->wwwroot . '/blocks/contact_form/contact.php?cid=' . $cid . '&amp;bid=' . $bid . '&amp;rcp=' . $this->receipt . '">';
             $this->content->text .= $linktext;
             $this->content->text .= '</a>';
             $this->content->text .= '</div>';
         } else {
             $this->content->text = '<form id="form" method="post" action="' . $CFG->wwwroot . '/blocks/contact_form/contact.php">';
             $this->content->text .= '<div style="text-align: center;">';
             $this->content->text .= '<input type="hidden" name="cid" value="' . $cid . '" />';
             $this->content->text .= '<input type="hidden" name="bid" value="' . $bid . '" />';
             $this->content->text .= '<input type="hidden" name="rcp" value="' . $this->receipt . '" />';
             $this->content->text .= '<input type="submit" name="Submit" value="' . $linktext . '" />';
             $this->content->text .= '</div>';
             $this->content->text .= '</form>';
         }
     }
     return $this->content;
 }
Example #2
0
    echo '****** Written from line ' . __LINE__ . ' of ' . __FILE__ . ' ********<br />';
    echo 'course ID: $cid = ' . $cid . '<br />';
    echo 'block  ID: $bid = ' . $bid . '<br />';
    echo 'was receipt requested? $rcp = ' . $rcp . '<br />';
}
$strcontact_form = get_string('contactform_name', 'block_contact_form');
$navlinks = array();
$navlinks[] = array('name' => $strcontact_form, 'link' => "", 'type' => 'block');
// $COURSE is useless here but is needed if category is shown in the navigation menu. See MDL-
// $COURSE is used by build_navigation.
$COURSE = get_record('course', 'id', $cid);
$navigation = build_navigation($navlinks);
print_header_simple($strcontact_form, "", $navigation, "", "", true, "", "");
//----------------------------------------------------------------------------
$allhiddenrecipients = getallhiddenrecipients($cid, $bid);
$allstandardrecipients = getallstandardrecipients($bid);
$mform =& new block_contact_form($CFG->wwwroot . '/blocks/contact_form/contact.php');
if ($mform->is_cancelled()) {
    // submission was canceled.
    if ($cid == 1) {
        redirect($CFG->wwwroot . '/index.php', get_string('usercanceled', 'block_contact_form'));
    } else {
        redirect($CFG->wwwroot . '/course/view.php?id=' . $cid, get_string('usercanceled', 'block_contact_form'));
    }
} else {
    if ($fromform = $mform->get_data()) {
        // form was successfully submitted. Now send and redirect.
        include_once 'sendmessage.php';
        if ($cid == 1) {
            redirect($CFG->wwwroot . '/index.php', get_string('messagesent', 'block_contact_form'));
        } else {