本文整理汇总了PHP中mod_forum_post_form::set_data方法的典型用法代码示例。如果您正苦于以下问题:PHP mod_forum_post_form::set_data方法的具体用法?PHP mod_forum_post_form::set_data怎么用?PHP mod_forum_post_form::set_data使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mod_forum_post_form
的用法示例。
在下文中一共展示了mod_forum_post_form::set_data方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: empty
$heading = get_string('yournewtopic', 'forum');
}
}
if (forum_is_subscribed($USER->id, $forum->id)) {
$subscribe = true;
} else {
if (forum_user_has_posted($forum->id, 0, $USER->id)) {
$subscribe = false;
} else {
// user not posted yet - use subscription default specified in profile
$subscribe = !empty($USER->autosubscribe);
}
}
$draftid_editor = file_get_submitted_draft_itemid('message');
$currenttext = file_prepare_draft_area($draftid_editor, $modcontext->id, 'mod_forum', 'post', empty($post->id) ? null : $post->id, array('subdirs' => true), $post->message);
$mform_post->set_data(array('attachments' => $draftitemid, 'general' => $heading, 'subject' => $post->subject, 'message' => array('text' => $currenttext, 'format' => empty($post->messageformat) ? editors_get_preferred_format() : $post->messageformat, 'itemid' => $draftid_editor), 'subscribe' => $subscribe ? 1 : 0, 'mailnow' => !empty($post->mailnow), 'userid' => $post->userid, 'parent' => $post->parent, 'discussion' => $post->discussion, 'course' => $course->id) + $page_params + (isset($post->format) ? array('format' => $post->format) : array()) + (isset($discussion->timestart) ? array('timestart' => $discussion->timestart) : array()) + (isset($discussion->timeend) ? array('timeend' => $discussion->timeend) : array()) + (isset($post->groupid) ? array('groupid' => $post->groupid) : array()) + (isset($discussion->id) ? array('discussion' => $discussion->id) : array()));
if ($fromform = $mform_post->get_data()) {
if (empty($SESSION->fromurl)) {
$errordestination = "{$CFG->wwwroot}/mod/forum/view.php?f={$forum->id}";
} else {
$errordestination = $SESSION->fromurl;
}
$fromform->itemid = $fromform->message['itemid'];
$fromform->messageformat = $fromform->message['format'];
$fromform->message = $fromform->message['text'];
// WARNING: the $fromform->message array has been overwritten, do not use it anymore!
$fromform->messagetrust = trusttext_trusted($modcontext);
$contextcheck = isset($fromform->groupinfo) && has_capability('mod/forum:movediscussions', $modcontext);
if ($fromform->edit) {
// Updating a post
unset($fromform->groupid);
示例2: trim
forum_print_posts_threaded($parent->id, $course->id, 0, false, false, $user_read_array, $discussion->forum, $modcontext);
}
}
$heading = get_string("yourreply", "forum");
} else {
$forum->intro = trim($forum->intro);
if (!empty($forum->intro)) {
print_box(format_text($forum->intro), 'generalbox', 'intro');
}
if ($forum->type == 'qanda') {
$heading = get_string('yournewquestion', 'forum');
} else {
$heading = get_string('yournewtopic', 'forum');
}
}
if ($USER->id != $post->userid) {
// Not the original author, so add a message to the end
$data->date = userdate($post->modified);
if ($post->format == FORMAT_HTML) {
$data->name = '<a href="' . $CFG->wwwroot . '/user/view.php?id=' . $USER->id . '&course=' . $post->course . '">' . fullname($USER) . '</a>';
$post->message .= '<p>(<span class="edited">' . get_string('editedby', 'forum', $data) . '</span>)</p>';
} else {
$data->name = fullname($USER);
$post->message .= "\n\n(" . get_string('editedby', 'forum', $data) . ')';
}
}
//load data into form
$subscribe = isset($post->forum) && forum_is_subscribed($USER->id, $post->forum) || !empty($USER->autosubscribe);
$mform_post->set_data(array('general' => $heading, 'subject' => $post->subject, 'message' => $post->message, 'subscribe' => $subscribe ? 1 : 0, 'mailnow' => !empty($post->mailnow), 'userid' => $post->userid, 'parent' => $post->parent, 'discussion' => $post->discussion, 'course' => $course->id) + $page_params + (isset($post->format) ? array('format' => $post->format) : array()) + (isset($dicussion->timestart) ? array('timestart' => $discussion->timestart) : array()) + (isset($discussion->timeend) ? array('timeend' => $discussion->timeend) : array()) + (isset($post->groupid) ? array('groupid' => $post->groupid) : array()) + (isset($discussion->id) ? array('discussion' => $discussion->id) : array()));
$mform_post->display();
print_footer($course);