* @category block * @copyright 2012 Craig Jamieson * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ require_once dirname(__FILE__) . '/../../config.php'; require_once 'attachment_form.class.php'; require_once 'contact_list.class.php'; require_once 'rich_text_form.class.php'; global $PAGE, $OUTPUT, $CFG, $USER, $COURSE; require_once $CFG->dirroot . '/blocks/course_message/locallib.php'; require_once $CFG->dirroot . '/local/yuigallerylibs/module_info.php'; require_once $CFG->libdir . '/formslib.php'; // Login -> no check for sesskey, since you cannot do anything further without it. $courseid = required_param("courseid", PARAM_INT); require_login($courseid, false); if (block_course_message_get_display_preference($USER->id) == BLOCK_CM_ON_PAGE) { $PAGE->set_pagelayout('base'); $title = get_string('pluginname', BLOCK_CM_LANG_TABLE) . ": " . $COURSE->fullname; $PAGE->set_title($title); $PAGE->navbar->add($title, new moodle_url('/blocks/course_message/inbox.php', array('courseid' => $courseid))); $PAGE->set_url(new moodle_url('/blocks/course_message/inbox.php', array('courseid' => $courseid))); } else { $PAGE->set_pagelayout('popup'); } set_header(); echo $OUTPUT->header(); echo '<div id="fullWindow">'; echo '<div id="leftContent">'; display_left_menu(); echo '</div>'; echo '<div id="rightContent">';
/** * This function tests the block_course_message_update_display_preference() function. * The ability to load in an iframe has been removed: no longer tested. * * To be clear: the function to change the preference will still do so, however, the * function that reads the preference will always return BLOCK_CM_ON_PAGE. * */ public function test_update_display_preference() { $this->setUser($this->craig); // Toggle to on page. block_course_message_update_display_preference(BLOCK_CM_ON_PAGE); $this->assertEquals(block_course_message_get_display_preference($this->craig->id), BLOCK_CM_ON_PAGE); // Toggle back to iframe -- no longer possible (no assert to test). block_course_message_update_display_preference(BLOCK_CM_IN_IFRAME); }
/** * This function edits the user's settings -> see locallib.php for the logic. * */ private function edit_settings() { global $USER; $inboxsetting = required_param('inboxsetting', PARAM_TEXT); $sentsetting = required_param('sentsetting', PARAM_TEXT); $displaypreference = required_param('displayonpagesetting', PARAM_TEXT); $olddisplaypreference = block_course_message_get_display_preference($USER->id); $displaypreference = $displaypreference == "new_page" ? BLOCK_CM_ON_PAGE : BLOCK_CM_IN_IFRAME; $result = true; $result = block_course_message_update_mail_preference('inbox', $inboxsetting); $result = block_course_message_update_mail_preference('sent', $sentsetting); $result = block_course_message_update_display_preference($displaypreference); if ($result) { echo json_encode(array('result' => true, 'text' => get_string('updatesettings', BLOCK_CM_LANG_TABLE))); } else { echo json_encode(array('result' => false, 'text' => get_string('updatesettingserror', BLOCK_CM_LANG_TABLE))); } }
/** * This method draws the inbox and send buttons at the bottom of the block. Notice that the button * function changes depending on the user preference setting. * */ private function draw_buttons() { global $USER, $COURSE; $this->content->footer .= '<div><button type="button" id="sendmailfromblock">' . get_string('sendbutton', BLOCK_CM_LANG_TABLE) . '</button>'; if (block_course_message_get_display_preference($USER->id) == BLOCK_CM_ON_PAGE) { $this->content->footer .= '<button type="button" onclick="window.open(\'/blocks/course_message/inbox.php?courseid=' . $COURSE->id . '\', \'inbox\');">' . get_string('openinboxbutton', BLOCK_CM_LANG_TABLE) . '</button>'; } else { $this->content->footer .= '<button type="button" id="dispInbox">' . get_string('openinboxbutton', BLOCK_CM_LANG_TABLE) . '</button>'; } $this->content->footer .= '</div>'; $this->content->footer .= '<div style="font-style:italic;">' . get_string('useinbox', BLOCK_CM_LANG_TABLE) . '</div>'; }