Proyectos de Subversion Moodle

Rev

Rev 1 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1 Rev 1441
Línea 369... Línea 369...
369
        case FEATURE_BACKUP_MOODLE2:          return true;
369
        case FEATURE_BACKUP_MOODLE2:          return true;
370
        case FEATURE_SHOW_DESCRIPTION:        return true;
370
        case FEATURE_SHOW_DESCRIPTION:        return true;
371
        case FEATURE_PLAGIARISM:              return true;
371
        case FEATURE_PLAGIARISM:              return true;
372
        case FEATURE_ADVANCED_GRADING:        return true;
372
        case FEATURE_ADVANCED_GRADING:        return true;
373
        case FEATURE_MOD_PURPOSE:             return MOD_PURPOSE_COLLABORATION;
373
        case FEATURE_MOD_PURPOSE:             return MOD_PURPOSE_COLLABORATION;
-
 
374
        case FEATURE_CAN_UNINSTALL:
-
 
375
            return false;
Línea 374... Línea 376...
374
 
376
 
375
        default: return null;
377
        default: return null;
376
    }
378
    }
Línea 524... Línea 526...
524
        echo "<p>".get_string("noposts", "forum")."</p>";
526
        echo "<p>".get_string("noposts", "forum")."</p>";
525
    }
527
    }
526
}
528
}
Línea 527... Línea 529...
527
 
529
 
528
/**
-
 
529
 * @deprecated since Moodle 3.3, when the block_course_overview block was removed.
-
 
530
 */
-
 
531
function forum_filter_user_groups_discussions() {
-
 
532
    throw new coding_exception('forum_filter_user_groups_discussions() can not be used any more and is obsolete.');
-
 
533
}
-
 
534
 
-
 
535
/**
530
/**
536
 * Returns whether the discussion group is visible by the current user or not.
531
 * Returns whether the discussion group is visible by the current user or not.
537
 *
532
 *
538
 * @since Moodle 2.8, 2.7.1, 2.6.4
533
 * @since Moodle 2.8, 2.7.1, 2.6.4
539
 * @param cm_info $cm The discussion course module
534
 * @param cm_info $cm The discussion course module
Línea 557... Línea 552...
557
 
552
 
558
    return false;
553
    return false;
Línea 559... Línea 554...
559
}
554
}
560
 
-
 
561
/**
-
 
562
 * @deprecated since Moodle 3.3, when the block_course_overview block was removed.
-
 
563
 */
-
 
564
function forum_print_overview() {
-
 
565
    throw new coding_exception('forum_print_overview() can not be used any more and is obsolete.');
-
 
566
}
-
 
567
 
555
 
568
/**
556
/**
569
 * Given a course and a date, prints a summary of all the new
557
 * Given a course and a date, prints a summary of all the new
570
 * messages posted in the course since that date
558
 * messages posted in the course since that date
571
 *
559
 *
Línea 1700... Línea 1688...
1700
        $groupselect = "";
1688
        $groupselect = "";
1701
    }
1689
    }
1702
    if (empty($forumsort)) {
1690
    if (empty($forumsort)) {
1703
        $forumsort = forum_get_default_sort_order();
1691
        $forumsort = forum_get_default_sort_order();
1704
    }
1692
    }
-
 
1693
    if (!str_contains($forumsort, 'id')) {
-
 
1694
        $forumsort .= ', d.id DESC';
-
 
1695
    }
1705
    if (empty($fullpost)) {
1696
    if (empty($fullpost)) {
1706
        $postdata = "p.id, p.subject, p.modified, p.discussion, p.userid, p.created";
1697
        $postdata = "p.id, p.subject, p.modified, p.discussion, p.userid, p.created";
1707
    } else {
1698
    } else {
1708
        $postdata = "p.*";
1699
        $postdata = "p.*";
1709
    }
1700
    }
Línea 1735... Línea 1726...
1735
                   JOIN {forum_posts} p ON p.discussion = d.id
1726
                   JOIN {forum_posts} p ON p.discussion = d.id
1736
                   JOIN {user} u ON p.userid = u.id
1727
                   JOIN {user} u ON p.userid = u.id
1737
                   $umtable
1728
                   $umtable
1738
             WHERE d.forum = ? AND p.parent = 0
1729
             WHERE d.forum = ? AND p.parent = 0
1739
                   $timelimit $groupselect $updatedsincesql
1730
                   $timelimit $groupselect $updatedsincesql
1740
          ORDER BY $forumsort, d.id DESC";
1731
          ORDER BY $forumsort";
Línea 1741... Línea 1732...
1741
 
1732
 
1742
    return $DB->get_records_sql($sql, $params, $limitfrom, $limitnum);
1733
    return $DB->get_records_sql($sql, $params, $limitfrom, $limitnum);
Línea 1743... Línea 1734...
1743
}
1734
}
Línea 2143... Línea 2134...
2143
    include_once("$CFG->dirroot/course/lib.php");
2134
    include_once("$CFG->dirroot/course/lib.php");
2144
    if (! $mod->coursemodule = add_course_module($mod) ) {
2135
    if (! $mod->coursemodule = add_course_module($mod) ) {
2145
        echo $OUTPUT->notification("Could not add a new course module to the course '" . $courseid . "'");
2136
        echo $OUTPUT->notification("Could not add a new course module to the course '" . $courseid . "'");
2146
        return false;
2137
        return false;
2147
    }
2138
    }
2148
    $sectionid = course_add_cm_to_section($courseid, $mod->coursemodule, 0);
2139
    $sectionid = course_add_cm_to_section($courseid, $mod->coursemodule, 0, null, 'forum');
2149
    return $DB->get_record("forum", array("id" => "$forum->id"));
2140
    return $DB->get_record("forum", array("id" => "$forum->id"));
2150
}
2141
}
Línea 2151... Línea 2142...
2151
 
2142
 
2152
/**
2143
/**
Línea 2579... Línea 2570...
2579
            $button = new portfolio_add_button();
2570
            $button = new portfolio_add_button();
2580
        }
2571
        }
2581
        foreach ($files as $file) {
2572
        foreach ($files as $file) {
2582
            $filename = $file->get_filename();
2573
            $filename = $file->get_filename();
2583
            $mimetype = $file->get_mimetype();
2574
            $mimetype = $file->get_mimetype();
2584
            $iconimage = $OUTPUT->pix_icon(file_file_icon($file), get_mimetype_description($file), 'moodle', array('class' => 'icon'));
2575
            $iconimage = $OUTPUT->pix_icon(file_file_icon($file),
-
 
2576
                    get_mimetype_description($file),
-
 
2577
                    'moodle',
-
 
2578
                    [
-
 
2579
                            'class' => 'icon',
-
 
2580
                            'style' => 'max-width: 24px; max-height: 24px; vertical-align: middle;',
-
 
2581
                    ]
-
 
2582
            );
2585
            $path = file_encode_url($CFG->wwwroot.'/pluginfile.php', '/'.$context->id.'/mod_forum/attachment/'.$post->id.'/'.$filename);
2583
            $path = file_encode_url($CFG->wwwroot.'/pluginfile.php', '/'.$context->id.'/mod_forum/attachment/'.$post->id.'/'.$filename);
Línea 2586... Línea 2584...
2586
 
2584
 
2587
            if ($type == 'html') {
2585
            if ($type == 'html') {
2588
                $output .= "<a href=\"$path\">$iconimage</a> ";
2586
                $output .= "<a href=\"$path\">$iconimage</a> ";
Línea 4822... Línea 4820...
4822
 
4820
 
4823
// Use SQL to find the last post for this discussion
4821
// Use SQL to find the last post for this discussion
4824
    $sql = "SELECT id, userid, modified
4822
    $sql = "SELECT id, userid, modified
4825
              FROM {forum_posts}
4823
              FROM {forum_posts}
4826
             WHERE discussion=?
4824
             WHERE discussion=?
Línea 4827... Línea 4825...
4827
             ORDER BY modified DESC";
4825
             ORDER BY modified DESC, id DESC";
4828
 
4826
 
4829
// Lets go find the last post
4827
// Lets go find the last post
4830
    if (($lastposts = $DB->get_records_sql($sql, array($discussionid), 0, 1))) {
4828
    if (($lastposts = $DB->get_records_sql($sql, array($discussionid), 0, 1))) {
Línea 5032... Línea 5030...
5032
 * This function will remove all posts from the specified forum
5030
 * This function will remove all posts from the specified forum
5033
 * and clean up any related data.
5031
 * and clean up any related data.
5034
 *
5032
 *
5035
 * @global object
5033
 * @global object
5036
 * @global object
5034
 * @global object
5037
 * @param $data the data submitted from the reset course.
5035
 * @param stdClass $data the data submitted from the reset course.
5038
 * @return array status array
5036
 * @return array status array
5039
 */
5037
 */
5040
function forum_reset_userdata($data) {
5038
function forum_reset_userdata($data) {
5041
    global $CFG, $DB;
5039
    global $CFG, $DB;
5042
    require_once($CFG->dirroot.'/rating/lib.php');
5040
    require_once($CFG->dirroot.'/rating/lib.php');
Línea 5043... Línea 5041...
5043
 
5041
 
5044
    $componentstr = get_string('modulenameplural', 'forum');
5042
    $componentstr = get_string('modulenameplural', 'forum');
Línea 5045... Línea 5043...
5045
    $status = array();
5043
    $status = [];
Línea 5046... Línea 5044...
5046
 
5044
 
5047
    $params = array($data->courseid);
5045
    $params = [$data->courseid];
5048
 
5046
 
5049
    $removeposts = false;
5047
    $removeposts = false;
5050
    $typesql     = "";
5048
    $typesql = '';
5051
    if (!empty($data->reset_forum_all)) {
5049
    if (!empty($data->reset_forum_all)) {
5052
        $removeposts = true;
5050
        $removeposts = true;
5053
        $typesstr    = get_string('resetforumsall', 'forum');
5051
        $typesstr = get_string('resetforumsall', 'forum');
5054
        $types       = array();
5052
        $types = [];
5055
    } else if (!empty($data->reset_forum_types)){
5053
    } else if (!empty($data->reset_forum_types)) {
5056
        $removeposts = true;
5054
        $removeposts = true;
5057
        $types       = array();
5055
        $types = [];
5058
        $sqltypes    = array();
5056
        $sqltypes = [];
5059
        $forum_types_all = forum_get_forum_types_all();
5057
        $forumtypesall = forum_get_forum_types_all();
5060
        foreach ($data->reset_forum_types as $type) {
5058
        foreach ($data->reset_forum_types as $type) {
5061
            if (!array_key_exists($type, $forum_types_all)) {
5059
            if (!array_key_exists($type, $forumtypesall)) {
5062
                continue;
5060
                continue;
5063
            }
5061
            }
5064
            $types[] = $forum_types_all[$type];
5062
            $types[] = $forumtypesall[$type];
5065
            $sqltypes[] = $type;
5063
            $sqltypes[] = $type;
5066
        }
5064
        }
Línea 5073... Línea 5071...
5073
    }
5071
    }
5074
    $alldiscussionssql = "SELECT fd.id
5072
    $alldiscussionssql = "SELECT fd.id
5075
                            FROM {forum_discussions} fd, {forum} f
5073
                            FROM {forum_discussions} fd, {forum} f
5076
                           WHERE f.course=? AND f.id=fd.forum";
5074
                           WHERE f.course=? AND f.id=fd.forum";
Línea 5077... Línea 5075...
5077
 
5075
 
5078
    $allforumssql      = "SELECT f.id
5076
    $allforumssql = "SELECT f.id
5079
                            FROM {forum} f
5077
                       FROM {forum} f
5080
                           WHERE f.course=?";
5078
                      WHERE f.course=?";
5081
 
5079
 
5082
    $allpostssql       = "SELECT fp.id
5080
    $allpostssql = "SELECT fp.id
5083
                            FROM {forum_posts} fp, {forum_discussions} fd, {forum} f
5081
                      FROM {forum_posts} fp, {forum_discussions} fd, {forum} f
Línea 5084... Línea 5082...
5084
                           WHERE f.course=? AND f.id=fd.forum AND fd.id=fp.discussion";
5082
                     WHERE f.course=? AND f.id=fd.forum AND fd.id=fp.discussion";
Línea 5085... Línea 5083...
5085
 
5083
 
5086
    $forumssql = $forums = $rm = null;
5084
    $forumssql = $forums = $rm = null;
Línea 5098... Línea 5096...
5098
        $forums = $DB->get_records_sql($forumssql, $params);
5096
        $forums = $DB->get_records_sql($forumssql, $params);
5099
    }
5097
    }
Línea 5100... Línea 5098...
5100
 
5098
 
5101
    if ($removeposts) {
5099
    if ($removeposts) {
5102
        $discussionssql = "$alldiscussionssql $typesql";
5100
        $discussionssql = "$alldiscussionssql $typesql";
Línea 5103... Línea 5101...
5103
        $postssql       = "$allpostssql $typesql";
5101
        $postssql = "$allpostssql $typesql";
5104
 
5102
 
5105
        // now get rid of all attachments
5103
        // Now get rid of all attachments.
5106
        $fs = get_file_storage();
5104
        $fs = get_file_storage();
5107
        if ($forums) {
5105
        if ($forums) {
5108
            foreach ($forums as $forumid=>$unused) {
5106
            foreach ($forums as $forumid => $unused) {
5109
                if (!$cm = get_coursemodule_from_instance('forum', $forumid)) {
5107
                if (!$cm = get_coursemodule_from_instance('forum', $forumid)) {
5110
                    continue;
5108
                    continue;
5111
                }
5109
                }
5112
                $context = context_module::instance($cm->id);
5110
                $context = context_module::instance($cm->id);
Línea 5113... Línea 5111...
5113
                $fs->delete_area_files($context->id, 'mod_forum', 'attachment');
5111
                $fs->delete_area_files($context->id, 'mod_forum', 'attachment');
5114
                $fs->delete_area_files($context->id, 'mod_forum', 'post');
5112
                $fs->delete_area_files($context->id, 'mod_forum', 'post');
5115
 
5113
 
Línea 5116... Línea 5114...
5116
                //remove ratings
5114
                // Remove ratings.
5117
                $ratingdeloptions->contextid = $context->id;
5115
                $ratingdeloptions->contextid = $context->id;
5118
                $rm->delete_ratings($ratingdeloptions);
5116
                $rm->delete_ratings($ratingdeloptions);
Línea 5119... Línea 5117...
5119
 
5117
 
5120
                core_tag_tag::delete_instances('mod_forum', null, $context->id);
5118
                core_tag_tag::delete_instances('mod_forum', null, $context->id);
Línea 5121... Línea 5119...
5121
            }
5119
            }
5122
        }
5120
        }
Línea 5123... Línea 5121...
5123
 
5121
 
5124
        // first delete all read flags
5122
        // First delete all read flags.
Línea 5125... Línea 5123...
5125
        $DB->delete_records_select('forum_read', "forumid IN ($forumssql)", $params);
5123
        $DB->delete_records_select('forum_read', "forumid IN ($forumssql)", $params);
-
 
5124
 
5126
 
5125
        // Remove tracking prefs.
-
 
5126
        $DB->delete_records_select('forum_track_prefs', "forumid IN ($forumssql)", $params);
-
 
5127
 
-
 
5128
        // Remove posts from queue.
5127
        // remove tracking prefs
5129
        $DB->delete_records_select('forum_queue', "discussionid IN ($discussionssql)", $params);
-
 
5130
 
-
 
5131
        // All posts - initial posts must be kept in single simple discussion forums.
Línea 5128... Línea 5132...
5128
        $DB->delete_records_select('forum_track_prefs', "forumid IN ($forumssql)", $params);
5132
        // First all children.
5129
 
5133
        $DB->delete_records_select('forum_posts', "discussion IN ($discussionssql) AND parent <> 0", $params);
Línea 5130... Línea 5134...
5130
        // remove posts from queue
5134
        // Now the initial posts for non single simple.
5131
        $DB->delete_records_select('forum_queue', "discussionid IN ($discussionssql)", $params);
5135
        $DB->delete_records_select(
5132
 
5136
            'forum_posts',
5133
        // all posts - initial posts must be kept in single simple discussion forums
5137
            "discussion IN ($discussionssql AND f.type <> 'single') AND parent = 0",
5134
        $DB->delete_records_select('forum_posts', "discussion IN ($discussionssql) AND parent <> 0", $params); // first all children
5138
            $params
5135
        $DB->delete_records_select('forum_posts', "discussion IN ($discussionssql AND f.type <> 'single') AND parent = 0", $params); // now the initial posts for non single simple
5139
        );
5136
 
5140
 
5137
        // finally all discussions except single simple forums
5141
        // Finally all discussions except single simple forums.
5138
        $DB->delete_records_select('forum_discussions', "forum IN ($forumssql AND f.type <> 'single')", $params);
5142
        $DB->delete_records_select('forum_discussions', "forum IN ($forumssql AND f.type <> 'single')", $params);
5139
 
5143
 
Línea -... Línea 5144...
-
 
5144
        // Remove all grades from gradebook.
5140
        // remove all grades from gradebook
5145
        if (empty($data->reset_gradebook_grades)) {
-
 
5146
            if (empty($types)) {
-
 
5147
                forum_reset_gradebook($data->courseid);
-
 
5148
            } else {
5141
        if (empty($data->reset_gradebook_grades)) {
5149
                foreach ($types as $type) {
Línea 5142... Línea 5150...
5142
            if (empty($types)) {
5150
                    forum_reset_gradebook($data->courseid, $type);
5143
                forum_reset_gradebook($data->courseid);
5151
                }
5144
            } else {
5152
            }
5145
                foreach ($types as $type) {
5153
        }
5146
                    forum_reset_gradebook($data->courseid, $type);
5154
 
5147
                }
5155
        $status[] = [
5148
            }
5156
            'component' => $componentstr,
5149
        }
5157
            'item' => $typesstr,
Línea 5150... Línea 5158...
5150
 
5158
            'error' => false,
5151
        $status[] = array('component'=>$componentstr, 'item'=>$typesstr, 'error'=>false);
5159
        ];
5152
    }
5160
    }
5153
 
5161
 
5154
    // remove all ratings in this course's forums
5162
    // Remove all ratings in this course's forums.
Línea 5155... Línea 5163...
5155
    if (!empty($data->reset_forum_ratings)) {
5163
    if (!empty($data->reset_forum_ratings)) {
5156
        if ($forums) {
5164
        if ($forums) {
5157
            foreach ($forums as $forumid=>$unused) {
5165
            foreach ($forums as $forumid => $unused) {
5158
                if (!$cm = get_coursemodule_from_instance('forum', $forumid)) {
5166
                if (!$cm = get_coursemodule_from_instance('forum', $forumid)) {
5159
                    continue;
5167
                    continue;
Línea 5183... Línea 5191...
5183
                $context = context_module::instance($cm->id);
5191
                $context = context_module::instance($cm->id);
5184
                core_tag_tag::delete_instances('mod_forum', null, $context->id);
5192
                core_tag_tag::delete_instances('mod_forum', null, $context->id);
5185
            }
5193
            }
5186
        }
5194
        }
Línea -... Línea 5195...
-
 
5195
 
-
 
5196
        $status[] = [
5187
 
5197
            'component' => $componentstr,
-
 
5198
            'item' => get_string('removeallforumtags', 'forum'),
-
 
5199
            'error' => false,
5188
        $status[] = array('component' => $componentstr, 'item' => get_string('tagsdeleted', 'forum'), 'error' => false);
5200
        ];
Línea 5189... Línea 5201...
5189
    }
5201
    }
5190
 
5202
 
5191
    // remove all digest settings unconditionally - even for users still enrolled in course.
5203
    // Remove all digest settings unconditionally - even for users still enrolled in course.
-
 
5204
    if (!empty($data->reset_forum_digests)) {
-
 
5205
        $DB->delete_records_select('forum_digests', "forum IN ($allforumssql)", $params);
5192
    if (!empty($data->reset_forum_digests)) {
5206
        $status[] = [
-
 
5207
            'component' => $componentstr,
-
 
5208
            'item' => get_string('resetdigests', 'forum'),
5193
        $DB->delete_records_select('forum_digests', "forum IN ($allforumssql)", $params);
5209
            'error' => false,
Línea 5194... Línea 5210...
5194
        $status[] = array('component' => $componentstr, 'item' => get_string('resetdigests', 'forum'), 'error' => false);
5210
        ];
5195
    }
5211
    }
5196
 
5212
 
5197
    // remove all subscriptions unconditionally - even for users still enrolled in course
5213
    // Remove all subscriptions unconditionally - even for users still enrolled in course.
-
 
5214
    if (!empty($data->reset_forum_subscriptions)) {
-
 
5215
        $DB->delete_records_select('forum_subscriptions', "forum IN ($allforumssql)", $params);
5198
    if (!empty($data->reset_forum_subscriptions)) {
5216
        $DB->delete_records_select('forum_discussion_subs', "forum IN ($allforumssql)", $params);
-
 
5217
        $status[] = [
-
 
5218
            'component' => $componentstr,
5199
        $DB->delete_records_select('forum_subscriptions', "forum IN ($allforumssql)", $params);
5219
            'item' => get_string('resetsubscriptions', 'forum'),
Línea 5200... Línea 5220...
5200
        $DB->delete_records_select('forum_discussion_subs', "forum IN ($allforumssql)", $params);
5220
            'error' => false,
5201
        $status[] = array('component' => $componentstr, 'item' => get_string('resetsubscriptions', 'forum'), 'error' => false);
5221
        ];
5202
    }
5222
    }
-
 
5223
 
-
 
5224
    // Remove all tracking prefs unconditionally - even for users still enrolled in course.
5203
 
5225
    if (!empty($data->reset_forum_track_prefs)) {
-
 
5226
        $DB->delete_records_select('forum_track_prefs', "forumid IN ($allforumssql)", $params);
-
 
5227
        $status[] = [
5204
    // remove all tracking prefs unconditionally - even for users still enrolled in course
5228
            'component' => $componentstr,
Línea 5205... Línea 5229...
5205
    if (!empty($data->reset_forum_track_prefs)) {
5229
            'item' => get_string('resettrackprefs', 'forum'),
5206
        $DB->delete_records_select('forum_track_prefs', "forumid IN ($allforumssql)", $params);
5230
            'error' => false,
5207
        $status[] = array('component'=>$componentstr, 'item'=>get_string('resettrackprefs','forum'), 'error'=>false);
5231
        ];
5208
    }
5232
    }
-
 
5233
 
-
 
5234
    // Updating dates - shift may be negative too.
-
 
5235
    if ($data->timeshift) {
-
 
5236
        // Any changes to the list of dates that needs to be rolled should be same during course restore and course reset.
-
 
5237
        // See MDL-9367.
5209
 
5238
        shift_course_mod_dates('forum', [
-
 
5239
            'assesstimestart',
-
 
5240
            'assesstimefinish',
-
 
5241
            'duedate',
5210
    /// updating dates - shift may be negative too
5242
            'cutoffdate',
-
 
5243
        ], $data->timeshift, $data->courseid);
-
 
5244
 
5211
    if ($data->timeshift) {
5245
        $status[] = [
Línea 5212... Línea 5246...
5212
        // Any changes to the list of dates that needs to be rolled should be same during course restore and course reset.
5246
            'component' => $componentstr,
5213
        // See MDL-9367.
5247
            'item' => get_string('date'),
Línea 5223... Línea 5257...
5223
 *
5257
 *
5224
 * @param MoodleQuickForm $mform form passed by reference
5258
 * @param MoodleQuickForm $mform form passed by reference
5225
 */
5259
 */
5226
function forum_reset_course_form_definition(&$mform) {
5260
function forum_reset_course_form_definition(&$mform) {
5227
    $mform->addElement('header', 'forumheader', get_string('modulenameplural', 'forum'));
5261
    $mform->addElement('header', 'forumheader', get_string('modulenameplural', 'forum'));
-
 
5262
    $mform->addElement('static', 'forumdelete', get_string('delete'));
Línea 5228... Línea 5263...
5228
 
5263
 
Línea 5229... Línea 5264...
5229
    $mform->addElement('checkbox', 'reset_forum_all', get_string('resetforumsall','forum'));
5264
    $mform->addElement('checkbox', 'reset_forum_digests', get_string('resetdigests', 'forum'));
5230
 
-
 
5231
    $mform->addElement('select', 'reset_forum_types', get_string('resetforums', 'forum'), forum_get_forum_types_all(), array('multiple' => 'multiple'));
-
 
Línea 5232... Línea 5265...
5232
    $mform->setAdvanced('reset_forum_types');
5265
 
5233
    $mform->disabledIf('reset_forum_types', 'reset_forum_all', 'checked');
-
 
Línea -... Línea 5266...
-
 
5266
    $mform->addElement('checkbox', 'reset_forum_subscriptions', get_string('resetsubscriptions', 'forum'));
-
 
5267
 
-
 
5268
    $mform->addElement('checkbox', 'reset_forum_all', get_string('resetforumsall', 'forum'));
5234
 
5269
 
-
 
5270
    $mform->addElement(
-
 
5271
        'select',
-
 
5272
        'reset_forum_types',
5235
    $mform->addElement('checkbox', 'reset_forum_digests', get_string('resetdigests','forum'));
5273
        get_string('resetforums', 'forum'),
Línea 5236... Línea 5274...
5236
    $mform->setAdvanced('reset_forum_digests');
5274
        forum_get_forum_types_all(),
5237
 
-
 
5238
    $mform->addElement('checkbox', 'reset_forum_subscriptions', get_string('resetsubscriptions','forum'));
5275
        ['multiple' => 'multiple'],
Línea 5239... Línea 5276...
5239
    $mform->setAdvanced('reset_forum_subscriptions');
5276
    );
5240
 
5277
    $mform->hideIf('reset_forum_types', 'reset_forum_all', 'checked');
Línea 5241... Línea 5278...
5241
    $mform->addElement('checkbox', 'reset_forum_track_prefs', get_string('resettrackprefs','forum'));
5278
 
5242
    $mform->setAdvanced('reset_forum_track_prefs');
5279
    $mform->addElement('checkbox', 'reset_forum_track_prefs', get_string('resettrackprefs', 'forum'));
5243
    $mform->disabledIf('reset_forum_track_prefs', 'reset_forum_all', 'checked');
5280
    $mform->hideIf('reset_forum_track_prefs', 'reset_forum_all', 'checked');
Línea 5244... Línea 5281...
5244
 
5281
 
5245
    $mform->addElement('checkbox', 'reset_forum_ratings', get_string('deleteallratings'));
5282
    $mform->addElement('checkbox', 'reset_forum_ratings', get_string('deleteallratings'));
5246
    $mform->disabledIf('reset_forum_ratings', 'reset_forum_all', 'checked');
5283
    $mform->hideIf('reset_forum_ratings', 'reset_forum_all', 'checked');
Línea 5598... Línea 5635...
5598
 *                       a discussion will be returned.
5635
 *                       a discussion will be returned.
5599
 * @param int $limitfrom The offset of records to return
5636
 * @param int $limitfrom The offset of records to return
5600
 * @param int $limitnum The number of records to return
5637
 * @param int $limitnum The number of records to return
5601
 * @return array An array of forums the user has posted within in the provided courses
5638
 * @return array An array of forums the user has posted within in the provided courses
5602
 */
5639
 */
5603
function forum_get_forums_user_posted_in($user, array $courseids = null, $discussionsonly = false, $limitfrom = null, $limitnum = null) {
5640
function forum_get_forums_user_posted_in($user, ?array $courseids = null, $discussionsonly = false, $limitfrom = null, $limitnum = null) {
5604
    global $DB;
5641
    global $DB;
Línea 5605... Línea 5642...
5605
 
5642
 
5606
    if (!is_null($courseids)) {
5643
    if (!is_null($courseids)) {
5607
        list($coursewhere, $params) = $DB->get_in_or_equal($courseids, SQL_PARAMS_NAMED, 'courseid');
5644
        list($coursewhere, $params) = $DB->get_in_or_equal($courseids, SQL_PARAMS_NAMED, 'courseid');
Línea 5885... Línea 5922...
5885
        $forumsearchwhere[] = "(d.forum $fullidsql)";
5922
        $forumsearchwhere[] = "(d.forum $fullidsql)";
5886
    }
5923
    }
Línea 5887... Línea 5924...
5887
 
5924
 
5888
    // Prepare SQL to both count and search.
5925
    // Prepare SQL to both count and search.
5889
    // We alias user.id to useridx because we forum_posts already has a userid field and not aliasing this would break
5926
    // We alias user.id to useridx because we forum_posts already has a userid field and not aliasing this would break
5890
    // oracle and mssql.
5927
    // mssql.
5891
    $userfieldsapi = \core_user\fields::for_userpic();
5928
    $userfieldsapi = \core_user\fields::for_userpic();
5892
    $userfields = $userfieldsapi->get_sql('u', false, '', 'useridx', false)->selects;
5929
    $userfields = $userfieldsapi->get_sql('u', false, '', 'useridx', false)->selects;
5893
    $countsql = 'SELECT COUNT(*) ';
5930
    $countsql = 'SELECT COUNT(*) ';
5894
    $selectsql = 'SELECT p.*, d.forum, d.name AS discussionname, '.$userfields.' ';
5931
    $selectsql = 'SELECT p.*, d.forum, d.name AS discussionname, '.$userfields.' ';
Línea 6362... Línea 6399...
6362
 *
6399
 *
6363
 * @return  array
6400
 * @return  array
6364
 */
6401
 */
6365
function mod_forum_get_fontawesome_icon_map() {
6402
function mod_forum_get_fontawesome_icon_map() {
6366
    return [
6403
    return [
6367
        'mod_forum:i/pinned' => 'fa-map-pin',
6404
        'mod_forum:i/pinned' => 'fa-thumbtack',
6368
        'mod_forum:t/selected' => 'fa-check',
6405
        'mod_forum:t/selected' => 'fa-check',
6369
        'mod_forum:t/subscribed' => 'fa-envelope-o',
-
 
6370
        'mod_forum:t/unsubscribed' => 'fa-envelope-open-o',
-
 
6371
        'mod_forum:t/star' => 'fa-star',
6406
        'mod_forum:t/star' => 'fa-star',
-
 
6407
        'mod_forum:t/subscribed' => 'fa-regular fa-envelope',
-
 
6408
        'mod_forum:t/unsubscribed' => 'fa-regular fa-envelope-open',
6372
    ];
6409
    ];
6373
}
6410
}
Línea 6374... Línea 6411...
6374
 
6411
 
6375
/**
6412
/**
Línea 6877... Línea 6914...
6877
    // This function is called by cron and we need to include the locallib for calls further down.
6914
    // This function is called by cron and we need to include the locallib for calls further down.
6878
    require_once($CFG->dirroot . '/mod/forum/locallib.php');
6915
    require_once($CFG->dirroot . '/mod/forum/locallib.php');
Línea 6879... Línea 6916...
6879
 
6916
 
6880
    forum_update_calendar($instance, $cm->id);
6917
    forum_update_calendar($instance, $cm->id);
-
 
6918
}
-
 
6919
 
-
 
6920
/**
-
 
6921
 * Callback adds navigation to view user posts if the navadduserpostslinks config is on.
-
 
6922
 *
-
 
6923
 * @param navigation_node $usernode User node within navigation
-
 
6924
 * @param stdClass $user User object
-
 
6925
 * @param \core\context\user $usercontext User context
-
 
6926
 * @param stdClass $course Current course
-
 
6927
 * @param \core\context $coursecontext Course context
-
 
6928
 */
-
 
6929
function mod_forum_extend_navigation_user(
-
 
6930
    navigation_node $usernode,
-
 
6931
    stdClass $user,
-
 
6932
    \core\context\user $usercontext,
-
 
6933
    stdClass $course,
-
 
6934
    \core\context $coursecontext,
-
 
6935
): void {
-
 
6936
    global $CFG;
-
 
6937
    if (!empty($CFG->navadduserpostslinks) && $coursecontext instanceof \core\context\system) {
-
 
6938
        $baseargs = ['id' => $user->id];
-
 
6939
 
-
 
6940
        // Add nodes for forum posts and discussions if the user can view either or both
-
 
6941
        // There are no capability checks here as the content of the page is based
-
 
6942
        // purely on the forums the current user has access too.
-
 
6943
        $forumtab = \navigation_node::create(get_string('forumposts', 'forum'));
-
 
6944
        $forumtab->add(
-
 
6945
            get_string('posts', 'forum'),
-
 
6946
            new moodle_url('/mod/forum/user.php', $baseargs),
-
 
6947
        );
-
 
6948
        $forumtab->add(
-
 
6949
            get_string('discussions', 'forum'),
-
 
6950
            new moodle_url('/mod/forum/user.php',
-
 
6951
                array_merge($baseargs, ['mode' => 'discussions']),
-
 
6952
            ),
-
 
6953
        );
-
 
6954
 
-
 
6955
        // We add the forum link either immediately after the 'viewuserdetails' link, or as the first item in the list.
-
 
6956
        foreach ($usernode->children as $child) {
-
 
6957
            if ($child->key === 'viewuserdetails') {
-
 
6958
                continue;
-
 
6959
            }
-
 
6960
            $addbefore = $child;
-
 
6961
            break;
-
 
6962
        }
-
 
6963
        $usernode->add_node($forumtab, $addbefore->key);
-
 
6964
    }