Пример #1
0
function groups_delete_groups($courseid, $showfeedback = false)
{
    global $CFG;
    require_once $CFG->libdir . '/gdlib.php';
    // delete any uses of groups
    $sql = "DELETE FROM {$CFG->prefix}groupings_groups\n             WHERE groupid in (SELECT id FROM {$CFG->prefix}groups g WHERE g.courseid = {$courseid})";
    execute_sql($sql, false);
    groups_delete_group_members($courseid, false);
    // delete group pictures
    if ($groups = get_records('groups', 'courseid', $courseid)) {
        foreach ($groups as $group) {
            delete_profile_image($group->id, 'groups');
        }
    }
    delete_records('groups', 'courseid', $courseid);
    if ($showfeedback) {
        notify(get_string('deleted') . ' groups');
    }
    return true;
}
Пример #2
0
/**
 * Delete all groups from course
 * @param int $courseid
 * @param bool $showfeedback
 * @return bool success
 */
function groups_delete_groups($courseid, $showfeedback = false)
{
    global $CFG;
    require_once $CFG->libdir . '/gdlib.php';
    $groupssql = "SELECT id FROM {$CFG->prefix}groups g WHERE g.courseid = {$courseid}";
    // delete any uses of groups
    groups_delete_groupings_groups($courseid, $showfeedback);
    groups_delete_group_members($courseid, 0, $showfeedback);
    // delete group pictures
    if ($groups = get_records('groups', 'courseid', $courseid)) {
        foreach ($groups as $group) {
            delete_profile_image($group->id, 'groups');
        }
    }
    // delete group calendar events
    delete_records_select('event', "groupid IN ({$groupssql})");
    delete_records('groups', 'courseid', $courseid);
    //trigger groups events
    events_trigger('groups_groups_deleted', $courseid);
    if ($showfeedback) {
        notify(get_string('deleted') . ' groups');
    }
    return true;
}
Пример #3
0
/**
 * Delete all groups from course
 * @param int $courseid
 * @param bool $showfeedback
 * @return bool success
 */
function groups_delete_groups($courseid, $showfeedback = false)
{
    global $CFG, $DB, $OUTPUT;
    require_once $CFG->libdir . '/gdlib.php';
    // delete any uses of groups
    groups_delete_groupings_groups($courseid, $showfeedback);
    groups_delete_group_members($courseid, 0, $showfeedback);
    // delete group pictures
    if ($groups = $DB->get_records('groups', array('courseid' => $courseid))) {
        foreach ($groups as $group) {
            delete_profile_image($group->id, 'groups');
        }
    }
    // delete group calendar events
    $groupssql = "SELECT id FROM {groups} g WHERE g.courseid = ?";
    $DB->delete_records_select('event', "groupid IN ({$groupssql})", array($courseid));
    $DB->delete_records('groups', array('courseid' => $courseid));
    //trigger groups events
    events_trigger('groups_groups_deleted', $courseid);
    if ($showfeedback) {
        echo $OUTPUT->notification(get_string('deleted') . ' groups');
    }
    return true;
}