本文整理汇总了PHP中forum::get_course_forums方法的典型用法代码示例。如果您正苦于以下问题:PHP forum::get_course_forums方法的具体用法?PHP forum::get_course_forums怎么用?PHP forum::get_course_forums使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类forum
的用法示例。
在下文中一共展示了forum::get_course_forums方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
$table->head = array($strforum, $strdescription, $strdiscussionsunread);
$table->align = array('left', 'left', 'center');
if ($useweeks || $usesections) {
array_unshift($table->head, $useweeks ? $strweek : $strsection);
array_unshift($table->align, 'left');
}
if ($canmaybesubscribe) {
$table->head[] = $strsubscribed;
$table->align[] = 'center';
}
if ($showrss = ($canmaybesubscribe || $course->id == SITEID) && !empty($CFG->enablerssfeeds) && !empty($CFG->forumng_enablerssfeeds)) {
$table->head[] = $strfeeds;
$table->align[] = 'center';
}
// Construct forums array
$forums = forum::get_course_forums($course, 0, forum::UNREAD_DISCUSSIONS, array(), true);
// Display all forums
$currentsection = 0;
$cansubscribesomething = false;
$canunsubscribesomething = false;
foreach ($forums as $forum) {
$cm = $forum->get_course_module();
// Skip forum if it's not visible or you can't read discussions there
if (!$cm->uservisible || !has_capability('mod/forumng:viewdiscussion', $forum->get_context())) {
continue;
}
// Additional OU access restrictions
if (class_exists('ouflags')) {
list($accessible, $visible, $message) = is_module_student_accessible($cm, $course);
if (!$accessible) {
continue;
示例2: get_string
if ($requestingsubscribe_group && $groupid) {
$forum->subscribe(0, $groupid);
$confirmtext = get_string('subscribe_confirm_group', 'forumng');
} else {
print_error('error_invalidsubscriptionrequest', 'forumng');
}
}
}
}
}
}
// Handle whole course
if ($courseid) {
$course = get_record('course', 'id', $courseid);
require_login($course);
$forums = forum::get_course_forums($course, 0, forum::UNREAD_NONE, array(), true);
foreach ($forums as $forum) {
if (!$forum->can_change_subscription()) {
continue;
}
$subscription_info = $forum->get_subscription_info();
$discussionidcount = count($subscription_info->discussionids);
if ($subscription_info->wholeforum) {
//subscribed to the entire forum
$subscribed = forum::FULLY_SUBSCRIBED;
} else {
if ($discussionidcount == 0) {
$subscribed = forum::NOT_SUBSCRIBED;
} else {
$subscribed = forum::PARTIALLY_SUBSCRIBED;
}
示例3: forumng_print_overview
/**
* Create html fragment for display on myMoodle page, forums changed since
* user last visited
*
* @param $courses list of courses to output information from
* @param $htmlarray returned results appended html to display
*/
function forumng_print_overview($courses, &$htmlarray)
{
global $USER, $CFG;
require_once $CFG->dirroot . '/mod/forumng/forum.php';
if (empty($courses) || !is_array($courses) || count($courses) == 0) {
return array();
}
$strnumunread = get_string('discussionsunread', 'forumng');
$strforum = get_string('modulename', 'forumng');
foreach ($courses as $course) {
$str = "";
$forums = forum::get_course_forums($course, $USER->id, forum::UNREAD_DISCUSSIONS);
if (!empty($forums)) {
foreach ($forums as $forum) {
// note like all mymoodle, there's no check current user can see each forum
// ok for openlearn & vital but might need addressing if VLE ever use it
if ($forum->has_unread_discussions()) {
// only listing unread, not new & unread for performance
$str .= '<div class="overview forumng"><div class="name">' . $strforum . ':' . ' <a title="' . $strforum . '" href="' . $forum->get_url(forum::PARAM_HTML) . '">' . $forum->get_name() . '</a></div>';
$str .= '<div class="info">' . $forum->get_num_unread_discussions() . ' ' . $strnumunread . '</div></div>';
}
}
}
if (!empty($str)) {
if (!array_key_exists($course->id, $htmlarray)) {
$htmlarray[$course->id] = array();
}
if (!array_key_exists('forumng', $htmlarray[$course->id])) {
$htmlarray[$course->id]['forumng'] = '';
// initialize, avoid warnings
}
$htmlarray[$course->id]['forumng'] .= $str;
}
}
}