Proyectos de Subversion Moodle

Rev

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

Rev 1 Rev 1441
Línea 160... Línea 160...
160
 *
160
 *
161
 * @param stdClass $data
161
 * @param stdClass $data
162
 * @return boolean|array
162
 * @return boolean|array
163
 */
163
 */
164
function wiki_reset_userdata($data) {
164
function wiki_reset_userdata($data) {
165
    global $CFG,$DB;
165
    global $CFG, $DB;
166
    require_once($CFG->dirroot . '/mod/wiki/pagelib.php');
166
    require_once($CFG->dirroot . '/mod/wiki/pagelib.php');
167
    require_once($CFG->dirroot . "/mod/wiki/locallib.php");
167
    require_once($CFG->dirroot . "/mod/wiki/locallib.php");
Línea 168... Línea 168...
168
 
168
 
169
    $componentstr = get_string('modulenameplural', 'wiki');
169
    $componentstr = get_string('modulenameplural', 'wiki');
Línea 170... Línea 170...
170
    $status = array();
170
    $status = [];
171
 
171
 
172
    //get the wiki(s) in this course.
172
    // Get the wiki(s) in this course.
173
    if (!$wikis = $DB->get_records('wiki', array('course' => $data->courseid))) {
173
    if (!$wikis = $DB->get_records('wiki', ['course' => $data->courseid])) {
174
        return false;
174
        return false;
175
    }
175
    }
176
    if (empty($data->reset_wiki_comments) && empty($data->reset_wiki_tags) && empty($data->reset_wiki_pages)) {
176
    if (empty($data->reset_wiki_comments) && empty($data->reset_wiki_tags) && empty($data->reset_wiki_pages)) {
Línea 203... Línea 203...
203
                        wiki_delete_pages($context, $pages, $subwiki->id);
203
                        wiki_delete_pages($context, $pages, $subwiki->id);
204
                    }
204
                    }
205
                }
205
                }
206
                if (!empty($data->reset_wiki_pages)) {
206
                if (!empty($data->reset_wiki_pages)) {
207
                    // Delete any subwikis.
207
                    // Delete any subwikis.
208
                    $DB->delete_records('wiki_subwikis', array('id' => $subwiki->id), IGNORE_MISSING);
208
                    $DB->delete_records('wiki_subwikis', ['id' => $subwiki->id]);
Línea 209... Línea 209...
209
 
209
 
210
                    // Delete any attached files.
210
                    // Delete any attached files.
211
                    $fs = get_file_storage();
211
                    $fs = get_file_storage();
212
                    $fs->delete_area_files($context->id, 'mod_wiki', 'attachments');
212
                    $fs->delete_area_files($context->id, 'mod_wiki', 'attachments');
213
                }
213
                }
Línea 214... Línea 214...
214
            }
214
            }
-
 
215
 
-
 
216
            if (!empty($data->reset_wiki_pages)) {
215
 
217
                $status[] = [
216
            if (!empty($data->reset_wiki_pages)) {
218
                    'component' => $componentstr,
-
 
219
                    'item' => get_string('deleteallpages', 'wiki'),
217
                $status[] = array('component' => $componentstr, 'item' => get_string('deleteallpages', 'wiki'),
220
                    'error' => false,
218
                    'error' => false);
221
                ];
-
 
222
            }
-
 
223
            if (!empty($data->reset_wiki_tags)) {
219
            }
224
                $status[] = [
-
 
225
                    'component' => $componentstr,
-
 
226
                    'item' => get_string('removeallwikitags', 'wiki'),
220
            if (!empty($data->reset_wiki_tags)) {
227
                    'error' => false,
221
                $status[] = array('component' => $componentstr, 'item' => get_string('tagsdeleted', 'wiki'), 'error' => false);
228
                ];
Línea 222... Línea 229...
222
            }
229
            }
223
        }
230
        }
224
 
231
 
225
        // Remove all comments.
232
        // Remove all comments.
-
 
233
        if (!empty($data->reset_wiki_comments) || !empty($data->reset_wiki_pages)) {
-
 
234
            $DB->delete_records_select('comments', "contextid = ? AND commentarea='wiki_page'", [$context->id]);
226
        if (!empty($data->reset_wiki_comments) || !empty($data->reset_wiki_pages)) {
235
            if (!empty($data->reset_wiki_comments)) {
-
 
236
                $status[] = [
-
 
237
                    'component' => $componentstr,
227
            $DB->delete_records_select('comments', "contextid = ? AND commentarea='wiki_page'", array($context->id));
238
                    'item' => get_string('deleteallcomments'),
228
            if (!empty($data->reset_wiki_comments)) {
239
                    'error' => false,
229
                $status[] = array('component' => $componentstr, 'item' => get_string('deleteallcomments'), 'error' => false);
240
                ];
Línea 230... Línea 241...
230
            }
241
            }
231
        }
242
        }
232
    }
243
    }
-
 
244
 
-
 
245
    // Any changes to the list of dates that needs to be rolled should be same during course restore and course reset.
233
 
246
    // See MDL-9367.
-
 
247
    shift_course_mod_dates('wiki', ['editbegin', 'editend'], $data->timeshift, $data->courseid);
-
 
248
    $status[] = [
Línea 234... Línea 249...
234
    // Any changes to the list of dates that needs to be rolled should be same during course restore and course reset.
249
        'component' => $componentstr,
235
    // See MDL-9367.
250
        'item' => get_string('date'),
Línea 236... Línea 251...
236
    shift_course_mod_dates('wiki', array('editbegin', 'editend'), $data->timeshift, $data->courseid);
251
        'error' => false,
237
    $status[] = array('component' => $componentstr, 'item' => get_string('datechanged'), 'error' => false);
252
    ];
-
 
253
 
238
 
254
    return $status;
239
    return $status;
255
}
240
}
256
 
241
 
257
 
Línea 366... Línea 382...
366
function wiki_grades($wikiid) {
382
function wiki_grades($wikiid) {
367
    return null;
383
    return null;
368
}
384
}
Línea 369... Línea 385...
369
 
385
 
370
/**
-
 
371
 * @deprecated since Moodle 3.8
-
 
372
 */
-
 
373
function wiki_scale_used() {
-
 
374
    throw new coding_exception('wiki_scale_used() can not be used anymore. Plugins can implement ' .
-
 
375
        '<modname>_scale_used_anywhere, all implementations of <modname>_scale_used are now ignored');
-
 
376
}
-
 
377
 
-
 
378
/**
386
/**
379
 * Checks if scale is being used by any instance of wiki.
387
 * Checks if scale is being used by any instance of wiki.
380
 * This function was added in 1.9
388
 * This function was added in 1.9
381
 *
389
 *
382
 * This is used to find out if scale used anywhere
390
 * This is used to find out if scale used anywhere