Пример #1
0
    claro_disp_auth_form();
}
if (!claro_is_platform_admin()) {
    claro_die(get_lang('Not allowed'));
}
$nameTools = get_lang('User settings');
$dialogBox = new DialogBox();
// BC
ClaroBreadCrumbs::getInstance()->prepend(get_lang('Administration'), get_path('rootAdminWeb'));
$user_id = $_REQUEST['uidToEdit'];
//------------------------------------
// Execute COMMAND section
//------------------------------------
if (isset($_REQUEST['cmd']) && claro_is_platform_admin()) {
    if ($_REQUEST['cmd'] == 'UnReg') {
        if (user_remove_from_course($user_id, $_REQUEST['cidToEdit'], true, false)) {
            $dialogBox->success(get_lang('The user has been successfully unregistered'));
        } else {
            switch (claro_failure::get_last_failure()) {
                case 'cannot_unsubscribe_the_last_course_manager':
                    $dialogBox->error(get_lang('You cannot unsubscribe the last course manager of the course'));
                    break;
                case 'course_manager_cannot_unsubscribe_himself':
                    $dialogBox->error(get_lang('Course manager cannot unsubscribe himself'));
                    break;
                default:
            }
        }
    }
}
/**
Пример #2
0
/**
 * This function empties all classes,
 * remove link between classes and users
 * delete related users from related courses
 */
function empty_all_class()
{
    $tbl = claro_sql_get_main_tbl();
    $sql = "\n        SELECT id FROM `" . $tbl['class'] . "`";
    $searchResultList = claro_sql_query_fetch_all($sql);
    foreach ($searchResultList as $thisClass) {
        $classId = $thisClass['id'];
        // find all the students enrolled in that class
        $sql2 = "\n            SELECT user_id from `" . $tbl['rel_class_user'] . "`\n            WHERE class_id = '" . claro_sql_escape($classId) . "'";
        $thisClassUser = claro_sql_query_fetch_all($sql2);
        // Find all the courses to whom the class is enrolled
        $sql2 = "\n            SELECT courseId\n            FROM `" . $tbl['rel_course_class'] . "`\n            WHERE classId = '" . claro_sql_escape($classId) . "'";
        $searchResultList2 = claro_sql_query_fetch_all($sql2);
        foreach ($searchResultList2 as $thisCourse) {
            $courseCode = $thisCourse['courseId'];
            foreach ($thisClassUser as $thisUser) {
                $user_id = $thisUser['user_id'];
                if (!user_remove_from_course($user_id, $courseCode, false, false, $classId)) {
                    return claro_failure::set_failure('PROBLEM_WITH_COURSE_UNSUSCRIBTION ' . $user_id . ' ' . $courseCode);
                    //TODO : ameliorer la detection d'erreur
                }
            }
        }
        class_remove_all_users($classId);
    }
    return true;
}
Пример #3
0
    $cidToEdit = $_REQUEST['cidToEdit'];
}
// See SESSION variables used for reorder criteria
$validCmdList = array('unsub');
$validRefererList = array('clist');
$cmd = isset($_REQUEST['cmd']) && in_array($_REQUEST['cmd'], $validCmdList) ? $_REQUEST['cmd'] : null;
$cfrom = isset($_REQUEST['cfrom']) && in_array($_REQUEST['cfrom'], $validRefererList) ? $_REQUEST['cfrom'] : null;
$pager_offset = isset($_REQUEST['pager_offset']) ? $_REQUEST['pager_offset'] : '0';
$addToURL = '';
$do = null;
// Parse command
if ($cmd == 'unsub') {
    $do = 'unsub';
}
if ($do == 'unsub') {
    if (user_remove_from_course($_REQUEST['user_id'], $_REQUEST['cidToEdit'], true, true, null)) {
        $dialogBox->success(get_lang('The user has been successfully unregistered'));
    } else {
        switch (claro_failure::get_last_failure()) {
            case 'cannot_unsubscribe_the_last_course_manager':
                $dialogBox->error(get_lang('You cannot unsubscribe the last course manager of the course'));
                break;
            case 'course_manager_cannot_unsubscribe_himself':
                $dialogBox->error(get_lang('Course manager cannot unsubscribe himself'));
                break;
            default:
        }
    }
}
// Build and call DB to get info about current course (for title) if needed :
$courseData = claro_get_course_data($cidToEdit);
Пример #4
0
if (!$userInfo) {
    $cmd = '';
    switch (claro_failure::get_last_failure()) {
        case 'user_not_found':
            $msg = get_lang('User not found');
            break;
        default:
            $msg = get_lang('User is not valid');
            break;
    }
}
/*----------------------------------------------------------------------------
Unsubscribe from a course
----------------------------------------------------------------------------*/
if ($cmd == 'exUnreg') {
    if (user_remove_from_course($userId, $courseCode, false, false, null)) {
        $claroline->log('COURSE_UNSUBSCRIBE', array('user' => $userId, 'course' => $courseCode));
        $dialogBox->success(get_lang('Your enrolment on the course has been removed'));
    } else {
        switch (claro_failure::get_last_failure()) {
            case 'cannot_unsubscribe_the_last_course_manager':
                $dialogBox->error(get_lang('You cannot unsubscribe the last course manager of the course'));
                break;
            case 'course_manager_cannot_unsubscribe_himself':
                $dialogBox->error(get_lang('Course manager cannot unsubscribe himself'));
                break;
            default:
                $dialogBox->error(get_lang('Unable to remove your registration to the course'));
                break;
        }
    }
Пример #5
0
if ('rqRmAll' == $cmd) {
    $courseList = claro_get_user_course_list($uidToEdit);
    $ok = true;
    foreach ($courseList as $course) {
        if (!user_remove_from_course($uidToEdit, $course['sysCode'], true, false)) {
            $ok = false;
            $dialogBox->error(get_lang('The user has not been successfully unregistered for course ' . $course['sysCode']));
        }
    }
    if ($ok) {
        $dialogBox->success(get_lang('The user has been successfully unregistered for all courses'));
    }
}
// Execute command
if ('rem_user' == $do) {
    if (user_remove_from_course($uidToEdit, $courseId, true, false)) {
        $dialogBox->success(get_lang('The user has been successfully unregistered'));
    } else {
        switch (claro_failure::get_last_failure()) {
            case 'cannot_unsubscribe_the_last_course_manager':
                $dialogBox->error(get_lang('You cannot unsubscribe the last course manager of the course'));
                break;
            case 'course_manager_cannot_unsubscribe_himself':
                $dialogBox->error(get_lang('Course manager cannot unsubscribe himself'));
                break;
            default:
                $dialogBox->error(get_lang('Unknow error during unsubscribing'));
        }
    }
}
$addToUrl = 'ulist' == $cfrom ? '&cfrom=ulist' : '';
Пример #6
0
 if ($forceUnenrolment) {
     $course = new Claro_Course(claro_get_current_course_id());
     $course->load();
     $userCourseRegistration = new Claro_CourseUserRegistration(AuthProfileManager::getUserAuthProfile($req['user_id']), $course);
     if (claro_is_platform_admin()) {
         $userCourseRegistration->forceUnregistrationOfManager();
     }
     if (!$userCourseRegistration->forceRemoveUser(false, array())) {
         $dialogBox->error(get_lang('The user cannot be removed from the course'));
     } else {
         Console::log("{$req['user_id']} removed [forced] by admin " . claro_get_current_user_id(), 'COURSE_UNSUBSCRIBE');
         $dialogBox->success(get_lang('The user has been successfully unregistered from course'));
     }
 } else {
     // delete user from course user list
     if (user_remove_from_course($req['user_id'], claro_get_current_course_id(), false, false, null)) {
         Console::log("{$req['user_id']} removed by user " . claro_get_current_user_id(), 'COURSE_UNSUBSCRIBE');
         $dialogBox->success(get_lang('The user has been successfully unregistered from course'));
     } else {
         switch (claro_failure::get_last_failure()) {
             case 'cannot_unsubscribe_the_last_course_manager':
                 $dialogBox->error(get_lang('You cannot unsubscribe the last course manager of the course'));
                 break;
             case 'course_manager_cannot_unsubscribe_himself':
                 $dialogBox->error(get_lang('Course manager cannot unsubscribe himself'));
                 break;
             default:
                 $dialogBox->error(get_lang('Error!! you cannot unregister a course manager'));
         }
     }
 }
Пример #7
0
/**
 * Delete user form claroline platform.
 *
 * @author Mathieu Laurent <*****@*****.**>
 * @param int $userId
 * @return boolean 'true' if it succeeds, 'false' otherwise
 */
function user_delete($userId)
{
    require_once dirname(__FILE__) . '/course_user.lib.php';
    if (claro_get_current_user_id() == $userId) {
        return claro_failure::set_failure('user_cannot_remove_himself');
    }
    // main tables name
    $tbl = claro_sql_get_main_tbl();
    // get the list of course code where the user is subscribed
    $sql = "SELECT c.code                          AS code\n            FROM `" . $tbl['rel_course_user'] . "` AS cu,\n                 `" . $tbl['course'] . "`          AS c\n            WHERE cu.code_cours = c.code\n            AND  cu.user_id    = " . $userId;
    $courseList = claro_sql_query_fetch_all_cols($sql);
    $log = array();
    if (user_remove_from_course($userId, $courseList['code'], true, true) == false) {
        return false;
    } else {
        foreach ($courseList['code'] as $k => $courseCode) {
            $log['course_' . $k] = $courseCode;
        }
        Claroline::log('UNROL_USER_COURS', array_merge(array('USER' => $userId), $log));
    }
    $sqlList = array("DELETE FROM `" . $tbl['user'] . "` WHERE user_id         = " . (int) $userId, "DELETE FROM `" . $tbl['tracking_event'] . "` WHERE user_id   = " . (int) $userId, "DELETE FROM `" . $tbl['rel_class_user'] . "` WHERE user_id         = " . (int) $userId, "DELETE FROM `" . $tbl['sso'] . "` WHERE user_id         = " . (int) $userId, "UPDATE `" . $tbl['user'] . "` SET `creatorId` = NULL WHERE `creatorId` = " . (int) $userId);
    Claroline::log('USER_DELETED', array_merge(array('USER' => $userId)));
    foreach ($sqlList as $thisSql) {
        if (claro_sql_query($thisSql) == false) {
            return false;
        } else {
            continue;
        }
    }
    return true;
}