/**
  * this is a very cut down version of what is in forum_make_mail_post
  *
  * @global object
  * @param int $post
  * @return string
  */
 protected function prepare_post($post, $usehtmls = true)
 {
     global $PAGE;
     $output = '';
     if ($usehtmls) {
         $output .= '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" ' . '"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">' . html_writer::start_tag('html', array('xmlns' => 'http://www.w3.org/1999/xhtml'));
         $output .= html_writer::tag('head', html_writer::empty_tag('meta', array('http-equiv' => 'Content-Type', 'content' => 'text/html; charset=utf-8')) . html_writer::tag('title', get_string('exportedpost', 'oublog')));
         $output .= html_writer::start_tag('body') . "\n";
     }
     if (!($oublog = oublog_get_blog_from_postid($post->id))) {
         print_error('invalidpost', 'oublog');
     }
     if (!($cm = get_coursemodule_from_instance('oublog', $oublog->id))) {
         print_error('invalidcoursemodule');
     }
     $oublogoutput = $PAGE->get_renderer('mod_oublog');
     $context = context_module::instance($cm->id);
     $canmanageposts = has_capability('mod/oublog:manageposts', $context);
     if ($oublog->global) {
         $blogtype = 'personal';
     } else {
         $blogtype = 'course';
     }
     $post->allowcomments = false;
     // Provide format from the exporter to renderers incase its required.
     $format = $this->get('exporter')->get('format');
     $output .= $oublogoutput->render_post($cm, $oublog, $post, false, $blogtype, $canmanageposts, false, false, true, $format);
     if (!empty($post->comments)) {
         $output .= $oublogoutput->render_comments($post, $oublog, false, false, true, $cm, $format);
     }
     if ($usehtmls) {
         $output .= html_writer::end_tag('body') . html_writer::end_tag('html');
     }
     return $output;
 }
Example #2
0
        print_error('invaliduser');
    }
    if (!(list($oublog, $oubloginstance) = oublog_get_personal_blog($user->id))) {
        // We redirect on error as system can create blog on access.
        redirect($redirectto);
    }
    // Get any posts matching user and time (If more than one just get first record).
    if (!($post = $DB->get_record('oublog_posts', array('oubloginstancesid' => $oubloginstance->id, 'timeposted' => $time), 'id', IGNORE_MULTIPLE))) {
        // Go to their blog home page if no post found.
        redirect($redirectto);
    }
    $postid = $post->id;
}
// This query based on the post id is so that we can get the blog etc to
// check permissions before calling oublog_get_post.
if (!($oublog = oublog_get_blog_from_postid($postid))) {
    print_error('invalidpost', 'oublog');
}
if (!($cm = get_coursemodule_from_instance('oublog', $oublog->id))) {
    print_error('invalidcoursemodule');
}
if (!($course = $DB->get_record("course", array("id" => $cm->course)))) {
    print_error('coursemisconf');
}
$url = new moodle_url('/mod/oublog/viewpost.php', array('post' => $postid));
$PAGE->set_url($url);
$context = context_module::instance($cm->id);
oublog_check_view_permissions($oublog, $context, $cm);
$oublogoutput = $PAGE->get_renderer('mod_oublog');
// Check security.
$canmanageposts = has_capability('mod/oublog:manageposts', $context);
Example #3
0
function oublog_oualerts_additional_recipients($type, $id)
{
    global $CFG, $USER, $DB;
    require_once $CFG->dirroot . '/mod/oublog/locallib.php';
    $additionalemails = '';
    switch ($type) {
        case 'post':
            $data = oublog_get_blog_from_postid($id);
            break;
        case 'comment':
            $postid = $DB->get_field('oublog_comments', 'postid', array('id' => $id));
            $data = oublog_get_blog_from_postid($postid);
            break;
        default:
            $data = false;
            break;
    }
    if ($data != false) {
        // Return alert recipients addresses for notification.
        $reportingemails = oublog_get_reportingemail($data);
        if ($reportingemails != false) {
            $additionalemails = explode(',', trim($reportingemails));
        }
    }
    return $additionalemails;
}