当前位置: 首页>>代码示例>>PHP>>正文


PHP forum_count_discussions函数代码示例

本文整理汇总了PHP中forum_count_discussions函数的典型用法代码示例。如果您正苦于以下问题:PHP forum_count_discussions函数的具体用法?PHP forum_count_discussions怎么用?PHP forum_count_discussions使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了forum_count_discussions函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: get_forums_by_courses

 /**
  * Returns a list of forums in a provided list of courses,
  * if no list is provided all forums that the user can view
  * will be returned.
  *
  * @param array $courseids the course ids
  * @return array the forum details
  * @since Moodle 2.5
  */
 public static function get_forums_by_courses($courseids = array())
 {
     global $CFG;
     require_once $CFG->dirroot . "/mod/forum/lib.php";
     $params = self::validate_parameters(self::get_forums_by_courses_parameters(), array('courseids' => $courseids));
     $courses = array();
     if (empty($params['courseids'])) {
         $courses = enrol_get_my_courses();
         $params['courseids'] = array_keys($courses);
     }
     // Array to store the forums to return.
     $arrforums = array();
     $warnings = array();
     // Ensure there are courseids to loop through.
     if (!empty($params['courseids'])) {
         list($courses, $warnings) = external_util::validate_courses($params['courseids'], $courses);
         // Get the forums in this course. This function checks users visibility permissions.
         $forums = get_all_instances_in_courses("forum", $courses);
         foreach ($forums as $forum) {
             $course = $courses[$forum->course];
             $cm = get_coursemodule_from_instance('forum', $forum->id, $course->id);
             $context = context_module::instance($cm->id);
             // Skip forums we are not allowed to see discussions.
             if (!has_capability('mod/forum:viewdiscussion', $context)) {
                 continue;
             }
             $forum->name = external_format_string($forum->name, $context->id);
             // Format the intro before being returning using the format setting.
             list($forum->intro, $forum->introformat) = external_format_text($forum->intro, $forum->introformat, $context->id, 'mod_forum', 'intro', null);
             $forum->introfiles = external_util::get_area_files($context->id, 'mod_forum', 'intro', false, false);
             // Discussions count. This function does static request cache.
             $forum->numdiscussions = forum_count_discussions($forum, $cm, $course);
             $forum->cmid = $forum->coursemodule;
             $forum->cancreatediscussions = forum_user_can_post_discussion($forum, null, -1, $cm, $context);
             // Add the forum to the array to return.
             $arrforums[$forum->id] = $forum;
         }
     }
     return $arrforums;
 }
开发者ID:lucaboesch,项目名称:moodle,代码行数:49,代码来源:externallib.php

示例2: get_string

    $learningtable->align[] = 'center';
}
/// Now let's process the learning forums
if ($course->id != SITEID) {
    // Only real courses have learning forums
    // 'format_.'$course->format only applicable when not SITEID (format_site is not a format)
    $strsectionname = get_string('sectionname', 'format_' . $course->format);
    // Add extra field for section number, at the front
    array_unshift($learningtable->head, $strsectionname);
    array_unshift($learningtable->align, 'center');
    if ($learningforums) {
        $currentsection = '';
        foreach ($learningforums as $forum) {
            $cm = $modinfo->instances['forum'][$forum->id];
            $context = context_module::instance($cm->id);
            $count = forum_count_discussions($forum, $cm, $course);
            if ($usetracking) {
                if ($forum->trackingtype == FORUM_TRACKING_OFF) {
                    $unreadlink = '-';
                    $trackedlink = '-';
                } else {
                    if (isset($untracked[$forum->id])) {
                        $unreadlink = '-';
                    } else {
                        if ($unread = forum_tp_count_forum_unread_posts($cm, $course)) {
                            $unreadlink = '<span class="unread"><a href="view.php?f=' . $forum->id . '">' . $unread . '</a>';
                            $unreadlink .= '<a title="' . $strmarkallread . '" href="markposts.php?f=' . $forum->id . '&amp;mark=read"><img src="' . $OUTPUT->pix_url('t/markasread') . '" alt="' . $strmarkallread . '" class="iconsmall" /></a></span>';
                        } else {
                            $unreadlink = '<span class="read">0</span>';
                        }
                    }
开发者ID:gwsd2015,项目名称:LogiClass,代码行数:31,代码来源:index.php

示例3: get_forums_by_courses

 /**
  * Returns a list of forums in a provided list of courses,
  * if no list is provided all forums that the user can view
  * will be returned.
  *
  * @param array $courseids the course ids
  * @return array the forum details
  * @since Moodle 2.5
  */
 public static function get_forums_by_courses($courseids = array())
 {
     global $CFG;
     require_once $CFG->dirroot . "/mod/forum/lib.php";
     $params = self::validate_parameters(self::get_forums_by_courses_parameters(), array('courseids' => $courseids));
     if (empty($params['courseids'])) {
         // Get all the courses the user can view.
         $courseids = array_keys(enrol_get_my_courses());
     } else {
         $courseids = $params['courseids'];
     }
     // Array to store the forums to return.
     $arrforums = array();
     // Ensure there are courseids to loop through.
     if (!empty($courseids)) {
         // Array of the courses we are going to retrieve the forums from.
         $dbcourses = array();
         // Mod info for courses.
         $modinfocourses = array();
         // Go through the courseids and return the forums.
         foreach ($courseids as $courseid) {
             // Check the user can function in this context.
             try {
                 $context = context_course::instance($courseid);
                 self::validate_context($context);
                 // Get the modinfo for the course.
                 $modinfocourses[$courseid] = get_fast_modinfo($courseid);
                 $dbcourses[$courseid] = $modinfocourses[$courseid]->get_course();
             } catch (Exception $e) {
                 continue;
             }
         }
         // Get the forums in this course. This function checks users visibility permissions.
         if ($forums = get_all_instances_in_courses("forum", $dbcourses)) {
             foreach ($forums as $forum) {
                 $course = $dbcourses[$forum->course];
                 $cm = $modinfocourses[$course->id]->get_cm($forum->coursemodule);
                 $context = context_module::instance($cm->id);
                 // Skip forums we are not allowed to see discussions.
                 if (!has_capability('mod/forum:viewdiscussion', $context)) {
                     continue;
                 }
                 // Format the intro before being returning using the format setting.
                 list($forum->intro, $forum->introformat) = external_format_text($forum->intro, $forum->introformat, $context->id, 'mod_forum', 'intro', 0);
                 // Discussions count. This function does static request cache.
                 $forum->numdiscussions = forum_count_discussions($forum, $cm, $course);
                 $forum->cmid = $forum->coursemodule;
                 // Add the forum to the array to return.
                 $arrforums[$forum->id] = $forum;
             }
         }
     }
     return $arrforums;
 }
开发者ID:educakanchay,项目名称:campus,代码行数:63,代码来源:externallib.php

示例4: get_forums_by_courses

 /**
  * Returns a list of forums in a provided list of courses,
  * if no list is provided all forums that the user can view
  * will be returned.
  *
  * @param array $courseids the course ids
  * @return array the forum details
  * @since Moodle 2.5
  */
 public static function get_forums_by_courses($courseids = array())
 {
     global $CFG, $DB, $USER;
     require_once $CFG->dirroot . "/mod/forum/lib.php";
     $params = self::validate_parameters(self::get_forums_by_courses_parameters(), array('courseids' => $courseids));
     if (empty($params['courseids'])) {
         // Get all the courses the user can view.
         $courseids = array_keys(enrol_get_my_courses());
     } else {
         $courseids = $params['courseids'];
     }
     // Array to store the forums to return.
     $arrforums = array();
     // Ensure there are courseids to loop through.
     if (!empty($courseids)) {
         // Go through the courseids and return the forums.
         foreach ($courseids as $cid) {
             // Get the course context.
             $context = context_course::instance($cid);
             // Check the user can function in this context.
             self::validate_context($context);
             // Get the forums in this course.
             if ($forums = $DB->get_records('forum', array('course' => $cid))) {
                 // Get the modinfo for the course.
                 $modinfo = get_fast_modinfo($cid);
                 // Get the course object.
                 $course = $modinfo->get_course();
                 // Get the forum instances.
                 $foruminstances = $modinfo->get_instances_of('forum');
                 // Loop through the forums returned by modinfo.
                 foreach ($foruminstances as $forumid => $cm) {
                     // If it is not visible or present in the forums get_records call, continue.
                     if (!$cm->uservisible || !isset($forums[$forumid])) {
                         continue;
                     }
                     // Set the forum object.
                     $forum = $forums[$forumid];
                     // Get the module context.
                     $context = context_module::instance($cm->id);
                     // Check they have the view forum capability.
                     require_capability('mod/forum:viewdiscussion', $context);
                     // Format the intro before being returning using the format setting.
                     list($forum->intro, $forum->introformat) = external_format_text($forum->intro, $forum->introformat, $context->id, 'mod_forum', 'intro', 0);
                     // Add the course module id to the object, this information is useful.
                     $forum->cmid = $cm->id;
                     // Discussions count. This function does static request cache.
                     $forum->numdiscussions = forum_count_discussions($forum, $cm, $course);
                     // Add the forum to the array to return.
                     $arrforums[$forum->id] = (array) $forum;
                 }
             }
         }
     }
     return $arrforums;
 }
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:64,代码来源:externallib.php


注:本文中的forum_count_discussions函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。