本文整理汇总了PHP中forum_get_course_forum函数的典型用法代码示例。如果您正苦于以下问题:PHP forum_get_course_forum函数的具体用法?PHP forum_get_course_forum怎么用?PHP forum_get_course_forum使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了forum_get_course_forum函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: FN_update_course
function FN_update_course($form, $oldformat = false)
{
global $CFG;
/// Updates course specific variables.
/// Variables are: 'showsection0', 'showannouncements'.
$config_vars = array('showsection0', 'showannouncements', 'sec0title', 'showhelpdoc', 'showclassforum', 'showclasschat', 'logo', 'mycourseblockdisplay', 'showgallery', 'gallerydefault', 'usesitegroups', 'mainheading', 'topicheading', 'activitytracking', 'ttmarking', 'ttgradebook', 'ttdocuments', 'ttstaff', 'defreadconfirmmess', 'usemandatory', 'expforumsec');
foreach ($config_vars as $config_var) {
if ($varrec = get_record('course_config_FN', 'courseid', $form->id, 'variable', $config_var)) {
$varrec->value = $form->{$config_var};
update_record('course_config_FN', $varrec);
} else {
$varrec->courseid = $form->id;
$varrec->variable = $config_var;
$varrec->value = $form->{$config_var};
insert_record('course_config_FN', $varrec);
}
}
/// We need to have the sections created ahead of time for the weekly nav to work,
/// so check and create here.
if (!($sections = get_all_sections($form->id))) {
$sections = array();
}
for ($i = 0; $i <= $form->numsections; $i++) {
if (empty($sections[$i])) {
$section = new Object();
$section->course = $form->id;
// Create a new section structure
$section->section = $i;
$section->summary = "";
$section->visible = 1;
if (!($section->id = insert_record("course_sections", $section))) {
notify("Error inserting new section!");
}
}
}
/// Check for a change to an FN format. If so, set some defaults as well...
if ($oldformat != 'FN') {
/// Set the news (announcements) forum to no force subscribe, and no posts or discussions.
require_once $CFG->dirroot . '/mod/forum/lib.php';
$news = forum_get_course_forum($form->id, 'news');
$news->open = 0;
$news->forcesubscribe = 0;
update_record('forum', $news);
}
rebuild_course_cache($form->id);
}
示例2: FN_update_course
function FN_update_course($form, $oldformat = false, $resubmission = false)
{
global $CFG, $DB, $OUTPUT;
$config_vars = array('showsection0', 'sec0title', 'mainheading', 'topicheading', 'maxtabs');
foreach ($config_vars as $config_var) {
if ($varrec = $DB->get_record('course_config_fn', array('courseid' => $form->id, 'variable' => $config_var))) {
$varrec->value = $form->{$config_var};
$DB->update_record('course_config_fn', $varrec);
} else {
$varrec->courseid = $form->id;
$varrec->variable = $config_var;
$varrec->value = $form->{$config_var};
$DB->insert_record('course_config_fn', $varrec);
}
}
/// We need to have the sections created ahead of time for the weekly nav to work,
/// so check and create here.
if (!($sections = get_all_sections($form->id))) {
$sections = array();
}
for ($i = 0; $i <= $form->numsections; $i++) {
if (empty($sections[$i])) {
$section = new Object();
$section->course = $form->id;
// Create a new section structure
$section->section = $i;
$section->summary = "";
$section->visible = 1;
if (!($section->id = $DB->insert_record("course_sections", $section))) {
$OUTPUT->notification("Error inserting new section!");
}
}
}
/// Check for a change to an FN format. If so, set some defaults as well...
if ($oldformat != 'FN') {
/// Set the news (announcements) forum to no force subscribe, and no posts or discussions.
require_once $CFG->dirroot . '/mod/forum/lib.php';
$news = forum_get_course_forum($form->id, 'news');
$news->open = 0;
$news->forcesubscribe = 0;
$DB->update_record('forum', $news);
}
rebuild_course_cache($form->id);
}
示例3: add_to_course
/**
* Append a news activity to the given course.
*
* @param stdClass $course The course to apply to.
*/
public function add_to_course($course)
{
global $DB;
$forum = forum_get_course_forum($course->id, 'news');
$data = $this->target->get_datatype()->get_data();
if (empty($data)) {
return;
}
// Set some extra vars.
if (isset($data->intro)) {
$DB->set_field('forum', 'intro', $data->intro, array('id' => $forum->id));
}
if (isset($data->showdescription)) {
$cm = get_coursemodule_from_instance('forum', $forum->id, $course->id);
if ($cm) {
$DB->set_field('course_modules', 'showdescription', $data->showdescription, array('id' => $cm->id));
}
}
}
示例4: print_box_end
print_box_end();
}
}
if (isloggedin() and !isguest() and isset($CFG->frontpageloggedin)) {
$frontpagelayout = $CFG->frontpageloggedin;
} else {
$frontpagelayout = $CFG->frontpage;
}
foreach (explode(',', $frontpagelayout) as $v) {
switch ($v) {
/// Display the main part of the front page.
case FRONTPAGENEWS:
if ($SITE->newsitems) {
// Print forums only when needed
require_once $CFG->dirroot . '/mod/forum/lib.php';
if (!($newsforum = forum_get_course_forum($SITE->id, 'news'))) {
error('Could not find or create a main news forum for the site');
}
if (!empty($USER->id)) {
$SESSION->fromdiscussion = $CFG->wwwroot;
$subtext = '';
if (forum_is_subscribed($USER->id, $newsforum)) {
if (!forum_is_forcesubscribed($newsforum)) {
$subtext = get_string('unsubscribe', 'forum');
}
} else {
$subtext = get_string('subscribe', 'forum');
}
print_heading_block($newsforum->name);
echo '<div class="subscribelink"><a href="mod/forum/subscribe.php?id=' . $newsforum->id . '">' . $subtext . '</a></div>';
} else {
示例5: get_content
function get_content()
{
global $CFG, $USER;
if ($this->content !== NULL) {
return $this->content;
}
$this->content = new stdClass();
$this->content->text = '';
$this->content->footer = '';
if (empty($this->instance)) {
return $this->content;
}
if ($this->page->course->newsitems) {
// Create a nice listing of recent postings
require_once $CFG->dirroot . '/mod/forum/lib.php';
// We'll need this
$text = '';
if (!($forum = forum_get_course_forum($this->page->course->id, 'news'))) {
return '';
}
$modinfo = get_fast_modinfo($this->page->course);
if (empty($modinfo->instances['forum'][$forum->id])) {
return '';
}
$cm = $modinfo->instances['forum'][$forum->id];
if (!$cm->uservisible) {
return '';
}
$context = context_module::instance($cm->id);
/// User must have perms to view discussions in that forum
if (!has_capability('mod/forum:viewdiscussion', $context)) {
return '';
}
/// First work out whether we can post to this group and if so, include a link
$groupmode = groups_get_activity_groupmode($cm);
$currentgroup = groups_get_activity_group($cm, true);
if (forum_user_can_post_discussion($forum, $currentgroup, $groupmode, $cm, $context)) {
$text .= '<div class="newlink"><a href="' . $CFG->wwwroot . '/mod/forum/post.php?forum=' . $forum->id . '">' . get_string('addanewtopic', 'forum') . '</a>...</div>';
}
/// Get all the recent discussions we're allowed to see
if (!($discussions = forum_get_discussions($cm, 'p.modified DESC', false, $currentgroup, $this->page->course->newsitems))) {
$text .= '(' . get_string('nonews', 'forum') . ')';
$this->content->text = $text;
return $this->content;
}
/// Actually create the listing now
$strftimerecent = get_string('strftimerecent');
$strmore = get_string('more', 'forum');
/// Accessibility: markup as a list.
$text .= "\n<ul class='unlist'>\n";
foreach ($discussions as $discussion) {
$discussion->subject = $discussion->name;
$discussion->subject = format_string($discussion->subject, true, $forum->course);
$text .= '<li class="post">' . '<div class="head clearfix">' . '<div class="date">' . userdate($discussion->modified, $strftimerecent) . '</div>' . '<div class="name">' . fullname($discussion) . '</div></div>' . '<div class="info"><a href="' . $CFG->wwwroot . '/mod/forum/discuss.php?d=' . $discussion->discussion . '">' . $discussion->subject . '</a></div>' . "</li>\n";
}
$text .= "</ul>\n";
$this->content->text = $text;
$this->content->footer = '<a href="' . $CFG->wwwroot . '/mod/forum/view.php?f=' . $forum->id . '">' . get_string('oldertopics', 'forum') . '</a> ...';
/// If RSS is activated at site and forum level and this forum has rss defined, show link
if (isset($CFG->enablerssfeeds) && isset($CFG->forum_enablerssfeeds) && $CFG->enablerssfeeds && $CFG->forum_enablerssfeeds && $forum->rsstype && $forum->rssarticles) {
require_once $CFG->dirroot . '/lib/rsslib.php';
// We'll need this
if ($forum->rsstype == 1) {
$tooltiptext = get_string('rsssubscriberssdiscussions', 'forum');
} else {
$tooltiptext = get_string('rsssubscriberssposts', 'forum');
}
if (!isloggedin()) {
$userid = $CFG->siteguest;
} else {
$userid = $USER->id;
}
$this->content->footer .= '<br />' . rss_get_link($context->id, $userid, 'mod_forum', $forum->id, $tooltiptext);
}
}
return $this->content;
}
示例6: main_upgrade
function main_upgrade($oldversion = 0)
{
global $CFG, $THEME, $db;
$result = true;
if ($oldversion == 0) {
execute_sql("\n CREATE TABLE `config` (\n `id` int(10) unsigned NOT NULL auto_increment,\n `name` varchar(255) NOT NULL default '',\n `value` varchar(255) NOT NULL default '',\n PRIMARY KEY (`id`),\n UNIQUE KEY `name` (`name`)\n ) COMMENT='Moodle configuration variables';");
notify("Created a new table 'config' to hold configuration data");
}
if ($oldversion < 2002073100) {
execute_sql(" DELETE FROM `modules` WHERE `name` = 'chat' ");
}
if ($oldversion < 2002080200) {
execute_sql(" ALTER TABLE `modules` DROP `fullname` ");
execute_sql(" ALTER TABLE `modules` DROP `search` ");
}
if ($oldversion < 2002080300) {
execute_sql(" ALTER TABLE `log_display` CHANGE `table` `mtable` VARCHAR( 20 ) NOT NULL ");
execute_sql(" ALTER TABLE `user_teachers` CHANGE `authority` `authority` TINYINT( 3 ) DEFAULT '3' NOT NULL ");
}
if ($oldversion < 2002082100) {
execute_sql(" ALTER TABLE `course` CHANGE `guest` `guest` TINYINT(2) UNSIGNED DEFAULT '0' NOT NULL ");
}
if ($oldversion < 2002082101) {
execute_sql(" ALTER TABLE `user` ADD `maildisplay` TINYINT(2) UNSIGNED DEFAULT '2' NOT NULL AFTER `mailformat` ");
}
if ($oldversion < 2002090100) {
execute_sql(" ALTER TABLE `course_sections` CHANGE `summary` `summary` TEXT NOT NULL ");
}
if ($oldversion < 2002090701) {
execute_sql(" ALTER TABLE `user_teachers` CHANGE `authority` `authority` TINYINT( 10 ) DEFAULT '3' NOT NULL ");
execute_sql(" ALTER TABLE `user_teachers` ADD `role` VARCHAR(40) NOT NULL AFTER `authority` ");
}
if ($oldversion < 2002090800) {
execute_sql(" ALTER TABLE `course` ADD `teachers` VARCHAR( 100 ) DEFAULT 'Teachers' NOT NULL AFTER `teacher` ");
execute_sql(" ALTER TABLE `course` ADD `students` VARCHAR( 100 ) DEFAULT 'Students' NOT NULL AFTER `student` ");
}
if ($oldversion < 2002091000) {
execute_sql(" ALTER TABLE `user` CHANGE `personality` `secret` VARCHAR( 15 ) NOT NULL DEFAULT '' ");
}
if ($oldversion < 2002091400) {
execute_sql(" ALTER TABLE `user` ADD `lang` VARCHAR( 3 ) DEFAULT 'en' NOT NULL AFTER `country` ");
}
if ($oldversion < 2002091900) {
notify("Most Moodle configuration variables have been moved to the database and can now be edited via the admin page.");
notify("Although it is not vital that you do so, you might want to edit <U>config.php</U> and remove all the unused settings (except the database, URL and directory definitions). See <U>config-dist.php</U> for an example of how your new slim config.php should look.");
}
if ($oldversion < 2002092000) {
execute_sql(" ALTER TABLE `user` CHANGE `lang` `lang` VARCHAR(5) DEFAULT 'en' NOT NULL ");
}
if ($oldversion < 2002092100) {
execute_sql(" ALTER TABLE `user` ADD `deleted` TINYINT(1) UNSIGNED DEFAULT '0' NOT NULL AFTER `confirmed` ");
}
if ($oldversion < 2002101001) {
execute_sql(" ALTER TABLE `user` ADD `htmleditor` TINYINT(1) UNSIGNED DEFAULT '1' NOT NULL AFTER `maildisplay` ");
}
if ($oldversion < 2002101701) {
execute_sql(" ALTER TABLE `reading` RENAME `resource` ");
// Small line with big consequences!
execute_sql(" DELETE FROM `log_display` WHERE module = 'reading'");
execute_sql(" INSERT INTO log_display (module, action, mtable, field) VALUES ('resource', 'view', 'resource', 'name') ");
execute_sql(" UPDATE log SET module = 'resource' WHERE module = 'reading' ");
execute_sql(" UPDATE modules SET name = 'resource' WHERE name = 'reading' ");
}
if ($oldversion < 2002102503) {
execute_sql(" ALTER TABLE `course` ADD `modinfo` TEXT NOT NULL AFTER `format` ");
require_once "{$CFG->dirroot}/mod/forum/lib.php";
require_once "{$CFG->dirroot}/course/lib.php";
if (!($module = get_record("modules", "name", "forum"))) {
notify("Could not find forum module!!");
return false;
}
// First upgrade the site forums
if ($site = get_site()) {
print_heading("Making News forums editable for main site (moving to section 1)...");
if ($news = forum_get_course_forum($site->id, "news")) {
$mod->course = $site->id;
$mod->module = $module->id;
$mod->instance = $news->id;
$mod->section = 1;
if (!($mod->coursemodule = add_course_module($mod))) {
notify("Could not add a new course module to the site");
return false;
}
if (!($sectionid = add_mod_to_section($mod))) {
notify("Could not add the new course module to that section");
return false;
}
if (!set_field("course_modules", "section", $sectionid, "id", $mod->coursemodule)) {
notify("Could not update the course module with the correct section");
return false;
}
}
}
// Now upgrade the courses.
if ($courses = get_records_sql("SELECT * FROM course WHERE category > 0")) {
print_heading("Making News and Social forums editable for each course (moving to section 0)...");
foreach ($courses as $course) {
if ($course->format == "social") {
// we won't touch them
continue;
//.........这里部分代码省略.........
示例7: get_string
$strgroups = get_string('groups');
$strgroupmy = get_string('groupmy');
$editing = $PAGE->user_is_editing();
echo '<table id="layout-table" cellspacing="0" summary="' . get_string('layouttable') . '">';
echo '<tr>';
if (blocks_have_content($pageblocks, BLOCK_POS_LEFT) || $editing) {
echo '<td style="width:' . $preferred_width_left . 'px" id="left-column">';
print_container_start();
blocks_print_group($PAGE, $pageblocks, BLOCK_POS_LEFT);
print_container_end();
echo '</td>';
}
echo '<td id="middle-column">';
print_container_start();
echo skip_main_destination();
if ($forum = forum_get_course_forum($course->id, 'social')) {
print_heading_block(get_string('socialheadline'));
$cm = get_coursemodule_from_instance('forum', $forum->id);
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
echo '<div class="subscribelink">', forum_get_subscribe_link($forum, $context), '</div>';
forum_print_latest_discussions($course, $forum, 10, 'plain', '', false);
} else {
notify('Could not find or create a social forum here');
}
print_container_end();
echo '</td>';
// The right column
if (blocks_have_content($pageblocks, BLOCK_POS_RIGHT) || $editing) {
echo '<td style="width:' . $preferred_width_right . 'px" id="right-column">';
print_container_start();
blocks_print_group($PAGE, $pageblocks, BLOCK_POS_RIGHT);
示例8: format_text
echo '<td class="left side"> </td>';
echo '<td class="content">';
echo '<div class="summary">';
// echo "<tr>";
// echo "<td nowrap class=\"fnweeklyside\" valign=top width=20> </td>";
// echo "<td valign=top class=\"fnweeklycontent\" width=\"100%\">";
echo '<table cellspacing="0" cellpadding="0" border="0" align="center">' . '<tr><td>';
$summaryformatoptions->noclean = true;
echo format_text($cobjectsection->summary, FORMAT_HTML, $summaryformatoptions);
if ($isediting) {
echo " <a title=\"{$streditsummary}\" " . " href=\"editsection.php?id={$cobjectsection->id}\"><img height=11 width=11 src=\"{$CFG->pixpath}/t/edit.gif\" " . " border=0 alt=\"{$streditsummary}\"></a><br />";
}
echo '<br clear="all">';
/// If showannouncements is off, remove the news forum from the mod list.
if (empty($cobject->course->showannouncements)) {
$news = forum_get_course_forum($course->id, 'news');
$modnum = get_field('modules', 'id', 'name', 'forum');
foreach ($mods as $key => $mod) {
if ($mod->module == $modnum && $mod->instance == $news->id) {
unset($mods[$key]);
break;
}
}
}
$cobject->print_section_fn($cobjectsection);
if ($isediting) {
$cobject->print_section_add_menus($section);
}
echo '</td></tr></table>';
echo '</td>';
echo '<td class="right side"> </td>';
示例9: site_frontpage_news
/**
* Alternative rendering of front page news, called from layout/faux_site_index.php which
* replaces the standard news output with this.
*
* @return string
*/
public function site_frontpage_news()
{
global $CFG, $SITE;
require_once $CFG->dirroot . '/mod/forum/lib.php';
if (!($forum = forum_get_course_forum($SITE->id, 'news'))) {
print_error('cannotfindorcreateforum', 'forum');
}
$cm = get_coursemodule_from_instance('forum', $forum->id, $SITE->id, false, MUST_EXIST);
$context = \context_module::instance($cm->id, MUST_EXIST);
$output = html_writer::start_tag('div', array('id' => 'site-news-forum', 'class' => 'clearfix'));
$output .= $this->heading(format_string($forum->name, true, array('context' => $context)));
$groupmode = groups_get_activity_groupmode($cm, $SITE);
$currentgroup = groups_get_activity_group($cm);
if (!($discussions = forum_get_discussions($cm, 'p.modified DESC', true, null, $SITE->newsitems, false, -1, $SITE->newsitems))) {
$output .= html_writer::tag('div', '(' . get_string('nonews', 'forum') . ')', array('class' => 'forumnodiscuss'));
if (forum_user_can_post_discussion($forum, $currentgroup, $groupmode, $cm, $context)) {
$output .= html_writer::link(new moodle_url('/mod/forum/post.php', array('forum' => $forum->id)), get_string('addanewtopic', 'forum'), array('class' => 'btn btn-primary'));
} else {
// No news and user cannot edit, so return nothing.
return '';
}
return $output . '</div>';
}
$output .= html_writer::start_div('', array('id' => 'news-articles'));
foreach ($discussions as $discussion) {
if (!forum_user_can_see_discussion($forum, $discussion, $context)) {
continue;
}
$message = file_rewrite_pluginfile_urls($discussion->message, 'pluginfile.php', $context->id, 'mod_forum', 'post', $discussion->id);
$imagestyle = '';
$imgarr = \theme_snap\local::extract_first_image($message);
if ($imgarr) {
$imageurl = s($imgarr['src']);
$imagestyle = " style=\"background-image:url('{$imageurl}')\"";
}
$name = format_string($discussion->name, true, array('context' => $context));
$date = userdate($discussion->timemodified, get_string('strftimedatetime', 'langconfig'));
$readmorebtn = "<a class='btn btn-default toggle' href='" . $CFG->wwwroot . "/mod/forum/discuss.php?d=" . $discussion->discussion . "'>" . get_string('readmore', 'theme_snap') . "</a>";
$preview = '';
$newsimage = '';
if (!$imagestyle) {
$preview = html_to_text($message, 0, false);
$preview = "<div class='news-article-preview'><p>" . shorten_text($preview, 200) . "</p>\n <p class='text-right'>" . $readmorebtn . "</p></div>";
} else {
$newsimage = '<div class="news-article-image toggle"' . $imagestyle . ' title="' . get_string('readmore', 'theme_snap') . '"></div>';
}
$close = get_string('close', 'theme_snap');
$output .= <<<HTML
<div class="news-article clearfix">
{$newsimage}
<div class="news-article-inner">
<div class="news-article-content">
<h3 class='toggle'><a href="{$CFG->wwwroot}/mod/forum/discuss.php?d={$discussion->discussion}">{$name}</a></h3>
<em class="news-article-date">{$date}</em>
</div>
</div>
{$preview}
<div class="news-article-message" tabindex="-1">
{$message}
<div><hr><a class="snap-action-icon toggle" href="#">
<i class="icon icon-close"></i><small>{$close}</small></a></div>
</div>
</div>
HTML;
}
$actionlinks = html_writer::link(new moodle_url('/mod/forum/view.php', array('id' => $cm->id)), get_string('morenews', 'theme_snap'), array('class' => 'btn btn-default'));
if (forum_user_can_post_discussion($forum, $currentgroup, $groupmode, $cm, $context)) {
$actionlinks .= html_writer::link(new moodle_url('/mod/forum/post.php', array('forum' => $forum->id)), get_string('addanewtopic', 'forum'), array('class' => 'btn btn-primary'));
}
$output .= html_writer::end_div();
$output .= "<br><div class='text-center'>{$actionlinks}</div>";
$output .= html_writer::end_tag('div');
return $output;
}
示例10: course_updated
/**
* Observer for \core\event\course_updated event.
*
* @param \core\event\course_updated $event
* @return void
*/
public static function course_updated(\core\event\course_updated $event)
{
global $CFG;
$course = $event->get_record_snapshot('course', $event->objectid);
$format = course_get_format($course);
if ($format->supports_news() && !empty($course->newsitems)) {
require_once $CFG->dirroot . '/mod/forum/lib.php';
// Auto create the announcements forum.
forum_get_course_forum($event->objectid, 'news');
}
}
示例11: get_course_mods
function get_course_mods($id, $username = '')
{
global $CFG, $DB;
$username = utf8_decode($username);
$username = strtolower($username);
if ($username) {
$user = get_complete_user_data('username', $username);
}
$modinfo = get_fast_modinfo($id);
$sections = $modinfo->get_section_info_all();
$forum = forum_get_course_forum($id, 'news');
$news_forum_id = $forum->id;
$mods = get_fast_modinfo($id)->get_cms();
$modnames = get_module_types_names();
$modnamesplural = get_module_types_names(true);
$modnamesused = get_fast_modinfo($id)->get_used_module_names();
$rawmods = get_course_mods($id);
$context = context_course::instance($id);
// Kludge to use username param to get non visible sections and modules
$username_orig = $username;
if ($username_orig == 'joomdle_get_not_visible') {
$username = '';
}
$e = array();
foreach ($sections as $section) {
if ($username_orig != 'joomdle_get_not_visible') {
if (!$section->visible) {
continue;
}
}
$sectionmods = explode(",", $section->sequence);
foreach ($sectionmods as $modnumber) {
if (empty($mods[$modnumber])) {
continue;
}
$mod = $mods[$modnumber];
if ($username_orig != 'joomdle_get_not_visible') {
if (!$mod->visible) {
continue;
}
}
$resource['completion_info'] = '';
if ($username) {
$cm = get_coursemodule_from_id(false, $mod->id);
if (!\core_availability\info_module::is_user_visible($cm, $user->id)) {
if (empty($mod->availableinfo)) {
// Mod not visible, and no completion info to show
continue;
}
$resource['available'] = 0;
$ci = new condition_info($mod);
$resource['completion_info'] = $ci->get_full_information();
} else {
$resource['available'] = 1;
}
} else {
$resource['available'] = 1;
}
$e[$section->section]['section'] = $section->section;
$e[$section->section]['name'] = $section->name;
$e[$section->section]['summary'] = file_rewrite_pluginfile_urls($section->summary, 'pluginfile.php', $context->id, 'course', 'section', $section->id);
$e[$section->section]['summary'] = str_replace('pluginfile.php', '/auth/joomdle/pluginfile_joomdle.php', $e[$section->section]['summary']);
$resource['id'] = $mod->id;
$resource['name'] = $mod->name;
$resource['mod'] = $mod->modname;
// Get content
$resource['content'] = '';
$modname = $mod->modname;
$functionname = $modname . "_get_coursemodule_info";
if (file_exists("{$CFG->dirroot}/mod/{$modname}/lib.php")) {
include_once "{$CFG->dirroot}/mod/{$modname}/lib.php";
if ($hasfunction = function_exists($functionname)) {
if ($info = $functionname($rawmods[$modnumber])) {
$resource['content'] = $info->content;
}
}
}
// Format for mod->icon is: f/type-24
$type = substr($mod->icon, 2);
$parts = explode('-', $type);
$type = $parts[0];
$resource['type'] = $type;
//In forum, type is unused, so we use it for forum type: news/general
if ($mod->modname == 'forum') {
$cm = get_coursemodule_from_id('forum', $mod->id);
if ($cm->instance == $news_forum_id) {
$resource['type'] = 'news';
}
}
/*
if ($mod->modname == 'resource')
{
// Get display options for resource
$params = array ($mod->instance);
$query = "SELECT display from {$CFG->prefix}resource where id = ?";
$record = $DB->get_record_sql ($query, $params);
$resource['display'] = $record->display;
}
else $resource['display'] = 0;
//.........这里部分代码省略.........
示例12: cms_render_news
function cms_render_news($course)
{
global $CFG;
if ($course->newsitems) {
// Print forums only when needed
require_once $CFG->dirroot . '/mod/forum/lib.php';
if (!($newsforum = forum_get_course_forum($course->id, 'news'))) {
error('Could not find or create a main news forum for the course');
}
if (isset($USER->id)) {
$SESSION->fromdiscussion = $CFG->wwwroot;
if (forum_is_subscribed($USER->id, $newsforum->id)) {
$subtext = get_string('unsubscribe', 'forum');
} else {
$subtext = get_string('subscribe', 'forum');
}
$headertext = '<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr>' . '<td><div class="title">' . $newsforum->name . '</div></td>' . '<td><div class="link"><a href="mod/forum/subscribe.php?id=' . $newsforum->id . '">' . $subtext . '</a></div></td>' . '</tr></table>';
} else {
$headertext = $newsforum->name;
}
ob_start();
print_heading_block($headertext);
forum_print_latest_discussions($course, $newsforum, $course->newsitems, 'plain', 'p.modified DESC');
$return = ob_get_contents();
ob_end_clean();
return $return;
}
return '';
}
示例13: local_my_print_latestnews_simple
/**
* Same as "full", but removes all subscription or any discussion commandes.
*/
function local_my_print_latestnews_simple()
{
global $PAGE, $SITE, $CFG, $OUTPUT, $USER, $DB, $SESSION;
$str = '';
if ($SITE->newsitems) {
// Print forums only when needed.
require_once $CFG->dirroot . '/mod/forum/lib.php';
if (!($newsforum = forum_get_course_forum($SITE->id, 'news'))) {
print_error('cannotfindorcreateforum', 'forum');
}
$renderer = $PAGE->get_renderer('local_my');
$renderer->print_forum_link($newforum);
if (isloggedin()) {
$SESSION->fromdiscussion = $CFG->wwwroot;
$subtext = '';
$str .= '<div class="block">';
$str .= '<div class="header">';
$str .= '<div class="title">';
$str .= '<h2>' . $forumname . '</h2>';
$str .= '</div></div>';
} else {
$str .= '<div class="block">';
$str .= '<div class="header">';
$str .= '<div class="title">';
$str .= '<h2>' . $forumname . '</h2>';
$str .= '</div></div>';
}
$str .= '<div class="content">';
$str .= '<table width="100%" class="newstable">';
$newsdiscussions = $DB->get_records('forum_discussions', array('forum' => $newsforum->id), 'timemodified DESC');
foreach ($newsdiscussions as $news) {
$str .= '<tr valign="top">';
$str .= '<td width="80%">';
$forumurl = new moodle_url('/mod/forum/discuss.php', array('d' => $news->id));
$str .= '<a href="' . $forumurl . '">' . $news->name . '</a>';
$str .= '</td>';
$str .= '<td align="right" width="20%">';
$str .= '(' . userdate($news->timemodified) . ')';
$str .= '</td>';
$str .= '</tr>';
}
$str .= '</table>';
$str .= '</div>';
$str .= '</div>';
$str .= html_writer::tag('span', '', array('class' => 'skip-block-to', 'id' => 'skipsitenews'));
}
return $str;
}
示例14: get_content
function get_content()
{
global $CFG, $USER, $COURSE;
if ($this->content !== NULL) {
return $this->content;
}
$this->content = new stdClass();
$this->content->text = '';
$this->content->footer = '';
if (empty($this->instance)) {
return $this->content;
}
if ($COURSE->newsitems) {
// Create a nice listing of recent postings
require_once $CFG->dirroot . '/mod/forum/lib.php';
// We'll need this
if (!($forum = forum_get_course_forum($COURSE->id, 'news'))) {
return '';
}
$modinfo = get_fast_modinfo($COURSE);
if (empty($modinfo->instances['forum'][$forum->id])) {
return '';
}
$cm = $modinfo->instances['forum'][$forum->id];
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
/// First work out whether we can post to this group and if so, include a link
$groupmode = groups_get_activity_groupmode($cm);
$currentgroup = groups_get_activity_group($cm, true);
/// Get all the recent discussions we're allowed to see
if (!($discussions = forum_get_discussions($cm, 'p.modified DESC', false, $currentgroup, $COURSE->newsitems))) {
$this->content->text = '(' . get_string('nonews', 'forum') . ')';
// add a link to add "a new news item" (nadavkav)
if (forum_user_can_post_discussion($forum, $currentgroup, $groupmode, $cm, $context)) {
$this->content->footer = '<div class="newlink"><a href="' . $CFG->wwwroot . '/mod/forum/post.php?forum=' . $forum->id . '">' . get_string('addanewitem', 'block_news_items_scrolling') . '</a>...</div>';
}
return $this->content;
}
// add scrolling effect <marquee> (nadavkav)
$text = '<marquee width="100%" height="120" align="right" direction="up" scrolldelay="50" scrollamount="1" onmouseout="this.start();" style="padding-top: 2px;" onmouseover="this.stop();" dir="rtl">';
/// Actually create the listing now
$strftimerecent = get_string('strftimerecent');
$strmore = get_string('more', 'block_news_items_scrolling');
/// Accessibility: markup as a list.
$text .= "\n<ul class='unlist'>\n";
foreach ($discussions as $discussion) {
$discussion->subject = $discussion->name;
$discussion->subject = format_string($discussion->subject, true, $forum->course);
//if (! $post = forum_get_post_full($discussion->discussion)) {
//error("Could not find the first post in this forum");
//}
$post = get_record("forum_posts", "discussion", $discussion->discussion);
$text .= '<li class="post">' . '<div class="head">' . '<div class="info">' . format_text($post->message) . ' ' . '<a href="' . $CFG->wwwroot . '/mod/forum/discuss.php?d=' . $discussion->discussion . '">' . $strmore . '...</a></div>' . "</li>\n";
}
$text .= "</ul>\n";
$text .= '</marquee>';
$this->content->text = $text;
$this->content->footer = '<a href="' . $CFG->wwwroot . '/mod/forum/view.php?f=' . $forum->id . '">' . get_string('olditems', 'block_news_items_scrolling') . '</a> ...';
if (forum_user_can_post_discussion($forum, $currentgroup, $groupmode, $cm, $context)) {
$this->content->footer = '<div class="newlink"><a href="' . $CFG->wwwroot . '/mod/forum/post.php?forum=' . $forum->id . '">' . get_string('addanewitem', 'block_news_items_scrolling') . '</a>...</div>';
}
/// If RSS is activated at site and forum level and this forum has rss defined, show link
if (isset($CFG->enablerssfeeds) && isset($CFG->forum_enablerssfeeds) && $CFG->enablerssfeeds && $CFG->forum_enablerssfeeds && $forum->rsstype && $forum->rssarticles) {
require_once $CFG->dirroot . '/lib/rsslib.php';
// We'll need this
if ($forum->rsstype == 1) {
$tooltiptext = get_string('rsssubscriberssdiscussions', 'forum', format_string($forum->name));
} else {
$tooltiptext = get_string('rsssubscriberssposts', 'forum', format_string($forum->name));
}
if (empty($USER->id)) {
$userid = 0;
} else {
$userid = $USER->id;
}
$this->content->footer .= '<br />' . rss_get_link($COURSE->id, $userid, 'forum', $forum->id, $tooltiptext);
}
}
return $this->content;
}
示例15: leaf_frontpage_carrousel
public function leaf_frontpage_carrousel($device)
{
global $COURSE, $CFG;
if (isloggedin() && !is_siteadmin() && $COURSE->id != 1) {
return '';
}
if (!($this->page->bodyid == 'page-login-index' || $this->page->bodyid == 'page-my-index')) {
return '';
}
require_once $CFG->dirroot . '/mod/forum/lib.php';
// We'll need this
$content = '';
if (!($forum = forum_get_course_forum($COURSE->id, 'news'))) {
return '';
}
$modinfo = get_fast_modinfo($COURSE);
if (empty($modinfo->instances['forum'][$forum->id])) {
return '';
}
$cm = $modinfo->instances['forum'][$forum->id];
if (!$cm->uservisible) {
return '';
}
$context = context_module::instance($cm->id);
/// First work out whether we can post to this group and if so, include a link
$groupmode = groups_get_activity_groupmode($cm);
$currentgroup = groups_get_activity_group($cm, true);
if (forum_user_can_post_discussion($forum, $currentgroup, $groupmode, $cm)) {
$link = '<li><a href="' . $CFG->wwwroot . '/mod/forum/post.php?forum=' . $forum->id . '">' . get_string('addsitenews', 'theme_leaf') . '</a></li>';
return $link;
}
if (!($discussions = leaf_forum_get_discussions($cm, 'p.modified DESC', true, $currentgroup, $COURSE->newsitems))) {
return '';
}
$strftimerecent = get_string('strftimerecent');
$indicators = '';
$carousel_items = '';
$extra = 'active ';
$count = 0;
$prev = html_writer::link('#myCarousel' . $device, "‹", array('class' => 'carousel-control left', 'data-slide' => 'prev'));
$next = html_writer::link('#myCarousel' . $device, "›", array('class' => 'carousel-control right', 'data-slide' => 'next'));
foreach ($discussions as $discussion) {
$strmore = get_string('read_more', 'theme_leaf');
if (isset($discussion->message)) {
if (strlen(strip_tags($discussion->message)) > 400) {
$message = substr(strip_tags($discussion->message), 0, 400) . '..';
} else {
$message = $discussion->message;
$strmore = '';
}
} else {
$message = '';
}
$discussion->subject = format_string($discussion->subject, true, $forum->course);
$carousel_items .= '<div class="' . $extra . 'item forumpost ">' . '<div class="head clearfix">' . '<div class="info"><h2>' . get_string('sitenews', 'theme_leaf') . '</h2></div>' . '<h3>' . $discussion->subject . '</h3>' . userdate($discussion->modified, $strftimerecent) . '
</div><br>' . '<div class="message">' . $message . ' </div>' . '<div class="readmore"><a href="' . $CFG->wwwroot . '/theme/leaf/layout/index.php?d=' . $discussion->discussion . '">' . $strmore . '</a></div>' . "</div>\n";
$extra = '';
}
// Carrousel markup
$content .= html_writer::start_tag('div', array('class' => 'sitenews' . $device));
$content .= html_writer::start_tag('div', array('id' => 'myCarousel' . $device, 'class' => 'carousel slide'));
$content .= html_writer::start_tag('div', array('class' => 'carousel-inner'));
$content .= '<div class="newscontrols">' . $next . $prev . '</div>';
$content .= $carousel_items;
$content .= html_writer::end_tag('div');
$content .= html_writer::end_tag('div');
$content .= html_writer::end_tag('div');
return $content;
}