// folder ID $folderoldid = optional_param('folderoldid', 0, PARAM_INT); // folder ID $filterid = optional_param('filterid', 0, PARAM_INT); // filter ID $olderrors = optional_param('error', 0, PARAM_INT); $subject = optional_param('subject', '', PARAM_ALPHANUM); // Subject of mail $body = optional_param('body', '', PARAM_ALPHANUM); // Body of mail $mails = optional_param('mails', '', PARAM_ALPHANUM); // Next and previous mails $selectedusers = optional_param('selectedusers', '', PARAM_ALPHANUM); // User who send mail // SSL encription $wwwroot = email_httpsrequired(); if (!($course = $DB->get_record('course', array('id' => $courseid)))) { print_error('invalidcourseid', 'block_email_list'); } require_login($course->id, false); // No autologin guest if (!email_is_enabled_email_list($course->id)) { print_error('blocknotavailable', 'block_email_list'); } if ($course->id == SITEID) { $context = get_context_instance(CONTEXT_SYSTEM, SITEID); // SYSTEM context } else { $context = get_context_instance(CONTEXT_COURSE, $course->id); // Course context }
function get_content() { global $USER, $CFG, $COURSE, $DB, $OUTPUT; // Get course id if (!empty($COURSE)) { $this->courseid = $COURSE->id; } // If block have content, skip. if ($this->content !== NULL) { return $this->content; } $this->content = new stdClass(); $this->content->items = array(); $this->content->icons = array(); // Security. $wwwroot = email_httpsrequired(); $emailicon = '<img src="' . $wwwroot . '/blocks/email_list/email/images/sobre.png" height="11" width="15" alt="' . get_string("course") . '" />'; $pixpath = "{$CFG->wwwroot}/pix"; $composeicon = '<img src="' . $pixpath . '/i/edit.gif" alt="" />'; $spacer = array('height' => 1, 'width' => 4); // Only show all course in principal course, others, show it if ($this->page->course->id == SITEID) { //Get the courses of the user $mycourses = enrol_get_my_courses(); $this->content->footer = '<br />' . $emailicon . $OUTPUT->spacer($spacer) . '<a href="' . $wwwroot . '/blocks/email_list/email/">' . get_string('view_all', 'block_email_list') . '</a>'; } else { if (!empty($CFG->mymoodleredirect) and $COURSE->id == 1) { //Get the courses of the user $mycourses = get_my_courses($USER->id); $this->content->footer = '<br />' . $emailicon . $OUTPUT->spacer($spacer) . '<a href="' . $wwwroot . '/blocks/email_list/email/">' . get_string('view_all', 'block_email_list') . '</a>'; } else { // Get this course $course = $DB->get_record('course', array('id' => $this->page->course->id)); $mycourses[] = $course; $this->content->footer = '<br />' . $emailicon . $OUTPUT->spacer($spacer) . '<a href="' . $wwwroot . '/blocks/email_list/email/index.php?id=' . $course->id . '">' . get_string('view_inbox', 'block_email_list') . '</a>'; $this->content->footer .= '<br />' . $composeicon . $OUTPUT->spacer($spacer) . '<a href="' . $wwwroot . '/blocks/email_list/email/sendmail.php?course=' . $course->id . '&folderid=0&filterid=0&folderoldid=0&action=newmail">' . get_string('compose', 'block_email_list') . '</a>'; } } // Count my courses $countmycourses = count($mycourses); //Configure item and icon for this account $icon = '<img src="' . $wwwroot . '/blocks/email_list/email/images/openicon.gif" height="16" width="16" alt="' . get_string("course") . '" />'; $number = 0; foreach ($mycourses as $mycourse) { ++$number; // increment for first course if ($number > $CFG->email_max_number_courses && !empty($CFG->email_max_number_courses)) { continue; } //Get the number of unread mails $numberunreadmails = email_count_unreaded_mails($USER->id, $mycourse->id); $coursename = $CFG->email_display_course_fullname ? $mycourse->fullname : $mycourse->shortname; // Only show if has unreaded mails if ($numberunreadmails > 0) { $unreadmails = '<b>(' . $numberunreadmails . ')</b>'; $this->content->items[] = '<a href="' . $wwwroot . '/blocks/email_list/email/index.php?id=' . $mycourse->id . '">' . $coursename . ' ' . $unreadmails . '</a>'; $this->content->icons[] = $icon; } } if (count($this->content->items) == 0) { $this->content->items[] = '<div align="center">' . get_string('emptymailbox', 'block_email_list') . '</div>'; } return $this->content; }