/**
  * This method checks the contact list generation for the block.  If the proper tags
  * are getting place in the divs, then it is pulling the right values from the DB.
  *
  */
 public function test_block_contacts()
 {
     $outputbuffer = '';
     $contactlist = new contact_list($this->testcourseid, $this->friend->id);
     $contactlist->display_contacts($outputbuffer);
     $matcher = array('tag' => 'div', 'attributes' => array('class' => 'contactList'));
     $this->assertTag($matcher, $outputbuffer);
     $this->check_for_contact_div($this->craig->id, 'Craig', 'Jamieson', $outputbuffer);
     $this->check_for_contact_div($this->martha->id, 'Martha', 'Stein', $outputbuffer);
     $this->check_for_contact_div($this->wade->id, 'Wade', 'Kelly', $outputbuffer);
     $this->check_for_contact_div("g{$this->testgroupid}", $this->testgroupname, '', $outputbuffer);
     $this->check_for_contact_div('s1', get_string('allstudents', BLOCK_CM_LANG_TABLE), '', $outputbuffer);
 }
Exemplo n.º 2
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 set the page header -> JS/CSS includes.
  *
  */
 private function set_header()
 {
     global $CFG, $COURSE, $PAGE, $USER;
     // 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);
     $PAGE->requires->css('/blocks/course_message/css/inbox.css');
     $PAGE->requires->yui_module('moodle-block_course_message-mail_lib', '(function(){})');
     $PAGE->requires->yui_module('moodle-block_course_message-send_from_block', 'M.block_course_message.init_send_from_block', array(array('courseid' => $COURSE->id, 'contacts' => $contacts, 'contactids' => $contactids, 'groups' => $groups, 'groupids' => $groupids)));
     $PAGE->requires->strings_for_js(array('nocontactswarning', 'nosubjectwarning', 'nomessagewarning', 'mailnotsent'), BLOCK_CM_LANG_TABLE);
 }