Esempio n. 1
0
/**
 * Builds and returns the body of the email notification in html format.
 *
 * @global object
 * @param object $course
 * @param object $cm
 * @param object $forum
 * @param object $discussion
 * @param object $post
 * @param object $userfrom
 * @param object $userto
 * @return string The email text in HTML format
 */
function forum_make_mail_html($course, $cm, $forum, $discussion, $post, $userfrom, $userto) {
    global $CFG;

    if ($userto->mailformat != 1) {  // Needs to be HTML
        return '';
    }

    if (!isset($userto->canpost[$discussion->id])) {
        $canreply = forum_user_can_post($forum, $discussion, $userto, $cm, $course);
    } else {
        $canreply = $userto->canpost[$discussion->id];
    }

    $strforums = get_string('forums', 'forum');
    $canunsubscribe = ! forum_is_forcesubscribed($forum);
    $shortname = format_string($course->shortname, true, array('context' => context_course::instance($course->id)));

    $posthtml = '<head>';
/*    foreach ($CFG->stylesheets as $stylesheet) {
        //TODO: MDL-21120
        $posthtml .= '<link rel="stylesheet" type="text/css" href="'.$stylesheet.'" />'."\n";
    }*/
    $posthtml .= '</head>';
    $posthtml .= "\n<body id=\"email\">\n\n";

    $posthtml .= '<div class="navbar">'.
    '<a target="_blank" href="'.$CFG->wwwroot.'/course/view.php?id='.$course->id.'">'.$shortname.'</a> &raquo; '.
    '<a target="_blank" href="'.$CFG->wwwroot.'/mod/forum/index.php?id='.$course->id.'">'.$strforums.'</a> &raquo; '.
    '<a target="_blank" href="'.$CFG->wwwroot.'/mod/forum/view.php?f='.$forum->id.'">'.format_string($forum->name,true).'</a>';
    if ($discussion->name == $forum->name) {
        $posthtml .= '</div>';
    } else {
        $posthtml .= ' &raquo; <a target="_blank" href="'.$CFG->wwwroot.'/mod/forum/discuss.php?d='.$discussion->id.'">'.
                     format_string($discussion->name,true).'</a></div>';
    }
    $posthtml .= forum_make_mail_post($course, $cm, $forum, $discussion, $post, $userfrom, $userto, false, $canreply, true, false);

    if ($canunsubscribe) {
        $posthtml .= '<hr /><div class="mdl-align unsubscribelink">
                      <a href="'.$CFG->wwwroot.'/mod/forum/subscribe.php?id='.$forum->id.'">'.get_string('unsubscribe', 'forum').'</a>&nbsp;
                      <a href="'.$CFG->wwwroot.'/mod/forum/unsubscribeall.php">'.get_string('unsubscribeall', 'forum').'</a></div>';
    }

    $posthtml .= '</body>';

    return $posthtml;
}
Esempio n. 2
0
/**
 * Builds and returns the body of the email notification in html format.
 *
 * @global object
 * @param object $course
 * @param object $cm
 * @param object $forum
 * @param object $discussion
 * @param object $post
 * @param object $userfrom
 * @param object $userto
 * @param string $replyaddress The inbound address that a user can reply to the generated e-mail with. [Since 2.8].
 * @return string The email text in HTML format
 */
function forum_make_mail_html($course, $cm, $forum, $discussion, $post, $userfrom, $userto, $replyaddress = null)
{
    global $CFG;
    if ($userto->mailformat != 1) {
        // Needs to be HTML
        return '';
    }
    if (!isset($userto->canpost[$discussion->id])) {
        $canreply = forum_user_can_post($forum, $discussion, $userto, $cm, $course);
    } else {
        $canreply = $userto->canpost[$discussion->id];
    }
    $strforums = get_string('forums', 'forum');
    $canunsubscribe = !\mod_forum\subscriptions::is_forcesubscribed($forum);
    $shortname = format_string($course->shortname, true, array('context' => context_course::instance($course->id)));
    $posthtml = '<head>';
    /*    foreach ($CFG->stylesheets as $stylesheet) {
            //TODO: MDL-21120
            $posthtml .= '<link rel="stylesheet" type="text/css" href="'.$stylesheet.'" />'."\n";
        }*/
    $posthtml .= '</head>';
    $posthtml .= "\n<body id=\"email\">\n\n";
    $posthtml .= '<div class="navbar">' . '<a target="_blank" href="' . $CFG->wwwroot . '/course/view.php?id=' . $course->id . '">' . $shortname . '</a> &raquo; ' . '<a target="_blank" href="' . $CFG->wwwroot . '/mod/forum/index.php?id=' . $course->id . '">' . $strforums . '</a> &raquo; ' . '<a target="_blank" href="' . $CFG->wwwroot . '/mod/forum/view.php?f=' . $forum->id . '">' . format_string($forum->name, true) . '</a>';
    if ($discussion->name == $forum->name) {
        $posthtml .= '</div>';
    } else {
        $posthtml .= ' &raquo; <a target="_blank" href="' . $CFG->wwwroot . '/mod/forum/discuss.php?d=' . $discussion->id . '">' . format_string($discussion->name, true) . '</a></div>';
    }
    $posthtml .= forum_make_mail_post($course, $cm, $forum, $discussion, $post, $userfrom, $userto, false, $canreply, true, false);
    if ($replyaddress) {
        $posthtml .= html_writer::tag('p', get_string('replytopostbyemail', 'mod_forum'));
    }
    $footerlinks = array();
    if ($canunsubscribe) {
        if (\mod_forum\subscriptions::is_subscribed($userto->id, $forum, null, $cm)) {
            // If subscribed to this forum, offer the unsubscribe link.
            $unsublink = new moodle_url('/mod/forum/subscribe.php', array('id' => $forum->id));
            $footerlinks[] = html_writer::link($unsublink, get_string('unsubscribe', 'mod_forum'));
        }
        // Always offer the unsubscribe from discussion link.
        $unsublink = new moodle_url('/mod/forum/subscribe.php', array('id' => $forum->id, 'd' => $discussion->id));
        $footerlinks[] = html_writer::link($unsublink, get_string('unsubscribediscussion', 'mod_forum'));
        $footerlinks[] = '<a href="' . $CFG->wwwroot . '/mod/forum/unsubscribeall.php">' . get_string('unsubscribeall', 'forum') . '</a>';
    }
    $footerlinks[] = "<a href='{$CFG->wwwroot}/mod/forum/index.php?id={$forum->course}'>" . get_string('digestmailpost', 'forum') . '</a>';
    $posthtml .= '<hr /><div class="mdl-align unsubscribelink">' . implode('&nbsp;', $footerlinks) . '</div>';
    $posthtml .= '</body>';
    return $posthtml;
}
Esempio n. 3
0
/**
 * Builds and returns the body of the email notification in html format.
 *
 * @param object $course
 * @param object $cm
 * @param object $forum
 * @param object $discussion
 * @param object $post
 * @param object $userfrom
 * @param object $userto
 * @param string $replyaddress The inbound address that a user can reply to the generated e-mail with. [Since 2.8].
 * @return string The email text in HTML format
 * @deprecated since Moodle 3.0 use \mod_forum\output\forum_post_email instead
 */
function forum_make_mail_html($course, $cm, $forum, $discussion, $post, $userfrom, $userto, $replyaddress = null)
{
    return forum_make_mail_post($course, $cm, $forum, $discussion, $post, $userfrom, $userto, forum_user_can_post($forum, $discussion, $userto, $cm, $course));
}
Esempio n. 4
0
/**
 * Builds and returns the body of the email notification in html format.
 *
 * @param object $course
 * @param object $forum
 * @param object $discussion
 * @param object $post
 * @param object $userfrom
 * @param object $userto
 * @return string The email text in HTML format
 */
function forum_make_mail_html($course, $forum, $discussion, $post, $userfrom, $userto)
{
    global $CFG;
    if ($userto->mailformat != 1) {
        // Needs to be HTML
        return '';
    }
    if (empty($post->modcontext)) {
        if (!($cm = get_coursemodule_from_instance('forum', $forum->id, $course->id))) {
            error('Course Module ID was incorrect');
        }
        $post->modcontext = get_context_instance(CONTEXT_MODULE, $cm->id);
    }
    $strforums = get_string('forums', 'forum');
    $canreply = forum_user_can_post($forum, $userto, NULL, $post->modcontext);
    $canunsubscribe = !forum_is_forcesubscribed($forum);
    $posthtml = '<head>';
    foreach ($CFG->stylesheets as $stylesheet) {
        $posthtml .= '<link rel="stylesheet" type="text/css" href="' . $stylesheet . '" />' . "\n";
    }
    $posthtml .= '</head>';
    $posthtml .= "\n<body id=\"email\">\n\n";
    $posthtml .= '<div class="navbar">' . '<a target="_blank" href="' . $CFG->wwwroot . '/course/view.php?id=' . $course->id . '">' . $course->shortname . '</a> &raquo; ' . '<a target="_blank" href="' . $CFG->wwwroot . '/mod/forum/index.php?id=' . $course->id . '">' . $strforums . '</a> &raquo; ' . '<a target="_blank" href="' . $CFG->wwwroot . '/mod/forum/view.php?f=' . $forum->id . '">' . format_string($forum->name, true) . '</a>';
    if ($discussion->name == $forum->name) {
        $posthtml .= '</div>';
    } else {
        $posthtml .= ' &raquo; <a target="_blank" href="' . $CFG->wwwroot . '/mod/forum/discuss.php?d=' . $discussion->id . '">' . format_string($discussion->name, true) . '</a></div>';
    }
    $posthtml .= forum_make_mail_post($post, $userfrom, $userto, $course, false, $canreply, true, false);
    if ($canunsubscribe) {
        $posthtml .= '<hr /><div align="center" class="unsubscribelink"><a href="' . $CFG->wwwroot . '/mod/forum/subscribe.php?id=' . $forum->id . '">' . get_string('unsubscribe', 'forum') . '</a></div>';
    }
    $posthtml .= '</body>';
    return $posthtml;
}
Esempio n. 5
0
/**
 * Builds and returns the body of the email notification in html format.
 *
 * @param object $course
 * @param object $forum
 * @param object $discussion
 * @param object $post
 * @param object $userfrom
 * @param object $userto
 * @return string The email text in HTML format
 */
function forum_make_mail_html($course, $forum, $discussion, $post, $userfrom, $userto)
{
    global $CFG;
    if ($userto->mailformat != 1) {
        // Needs to be HTML
        return '';
    }
    $strforums = get_string('forums', 'forum');
    $canreply = forum_user_can_post($forum, $userto);
    $canunsubscribe = !$forum->forcesubscribe;
    $posthtml = '<head>';
    foreach ($CFG->stylesheets as $stylesheet) {
        $posthtml .= '<link rel="stylesheet" type="text/css" href="' . $stylesheet . '" />' . "\n";
    }
    $posthtml .= '</head>';
    $posthtml .= "\n<body id=\"email\">\n\n";
    $posthtml .= '<div class="navbar">' . '<a target="_blank" href="' . $CFG->wwwroot . '/course/view.php?id=' . $course->id . '">' . $course->shortname . '</a> &raquo; ' . '<a target="_blank" href="' . $CFG->wwwroot . '/mod/forum/index.php?id=' . $course->id . '">' . $strforums . '</a> &raquo; ' . '<a target="_blank" href="' . $CFG->wwwroot . '/mod/forum/view.php?f=' . $forum->id . '">' . format_string($forum->name, true) . '</a>';
    if ($discussion->name == $forum->name) {
        $posthtml .= '</div>';
    } else {
        $posthtml .= ' &raquo; <a target="_blank" href="' . $CFG->wwwroot . '/mod/forum/discuss.php?d=' . $discussion->id . '">' . format_string($discussion->name, true) . '</a></div>';
    }
    $posthtml .= forum_make_mail_post($post, $userfrom, $userto, $course, false, $canreply, true, false);
    if ($canunsubscribe) {
        $posthtml .= '<br /><div class="unsubscribelink"><a href="' . $CFG->wwwroot . '/mod/forum/subscribe.php?id=' . $forum->id . '">' . get_string('unsubscribe', 'forum') . '</a></div>';
    }
    $posthtml .= '</body>';
    return $posthtml;
}