示例#1
0
/**
 * This function loads the YUI modules that I have written.  I've elected to
 * load these last so that the draftids can be passed directly to JS.
 *
 */
function load_yui_modules($composedraftid, $replydraftid)
{
    global $PAGE, $COURSE, $USER;
    // TODO: it would be nice to put this code in its own function.
    $contactlist = new contact_list($COURSE->id, $USER->id);
    $groups = array();
    $groupids = array();
    $contacts = array();
    $contactids = array();
    $contactlist->contacts_as_array($contacts, $contactids, $groups, $groupids);
    $editor = block_course_message_get_editor_preference($USER->id);
    $PAGE->requires->yui_module('moodle-block_course_message-mail_lib', '(function(){})');
    $PAGE->requires->yui_module('moodle-block_course_message-inbox', 'M.block_course_message.init_inbox', array(array('courseid' => $COURSE->id, 'contacts' => $contacts, 'contactids' => $contactids, 'groups' => $groups, 'groupids' => $groupids, 'folder' => 'inbox', 'editor' => $editor, 'composedraftid' => $composedraftid, 'replydraftid' => $replydraftid)));
}
 /**
  * This function tests the block_course_message_get_editor_preference() function.
  * The Craig user has no preference (defaults to 'atto'), the friend user prefers
  * 'tinymce' and the Martha user prefers 'atto'.
  *
  */
 public function test_get_editor_preference()
 {
     $this->setUser($this->craig);
     $this->assertEquals(block_course_message_get_editor_preference($this->craig->id), 'atto');
     $this->setUser($this->friend);
     $this->assertEquals(block_course_message_get_editor_preference($this->friend->id), 'tinymce');
     $this->setUser($this->martha);
     $this->assertEquals(block_course_message_get_editor_preference($this->martha->id), 'atto');
 }