本文整理汇总了PHP中mod_forum_post_form::attachment_options方法的典型用法代码示例。如果您正苦于以下问题:PHP mod_forum_post_form::attachment_options方法的具体用法?PHP mod_forum_post_form::attachment_options怎么用?PHP mod_forum_post_form::attachment_options使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mod_forum_post_form
的用法示例。
在下文中一共展示了mod_forum_post_form::attachment_options方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: forum_add_attachment
/**
* If successful, this function returns the name of the file
*
* @global object
* @param object $post is a full post record, including course and forum
* @param object $forum
* @param object $cm
* @param mixed $mform
* @param string $unused
* @return bool
*/
function forum_add_attachment($post, $forum, $cm, $mform=null, $unused=null) {
global $DB;
if (empty($mform)) {
return false;
}
if (empty($post->attachments)) {
return true; // Nothing to do
}
$context = context_module::instance($cm->id);
$info = file_get_draft_area_info($post->attachments);
$present = ($info['filecount']>0) ? '1' : '';
file_save_draft_area_files($post->attachments, $context->id, 'mod_forum', 'attachment', $post->id,
mod_forum_post_form::attachment_options($forum));
$DB->set_field('forum_posts', 'attachment', $present, array('id'=>$post->id));
return true;
}
示例2: print_error
print_error('invalidcoursemodule');
}
$modcontext = context_module::instance($cm->id);
require_login($course, false, $cm);
if (isguestuser()) {
// just in case
print_error('noguest');
}
if (!isset($forum->maxattachments)) {
// TODO - delete this once we add a field to the forum table
$forum->maxattachments = 3;
}
$thresholdwarning = forum_check_throttling($forum, $cm);
$mform_post = new mod_forum_post_form('post.php', array('course' => $course, 'cm' => $cm, 'coursecontext' => $coursecontext, 'modcontext' => $modcontext, 'forum' => $forum, 'post' => $post, 'subscribe' => \mod_forum\subscriptions::is_subscribed($USER->id, $forum, null, $cm), 'thresholdwarning' => $thresholdwarning, 'edit' => $edit), 'post', '', array('id' => 'mformforum'));
$draftitemid = file_get_submitted_draft_itemid('attachments');
file_prepare_draft_area($draftitemid, $modcontext->id, 'mod_forum', 'attachment', empty($post->id) ? null : $post->id, mod_forum_post_form::attachment_options($forum));
//load data into form NOW!
if ($USER->id != $post->userid) {
// Not the original author, so add a message to the end
$data = new stdClass();
$data->date = userdate($post->modified);
if ($post->messageformat == 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) . ')';
}
unset($data);
}
$formheading = '';