Example #1
0
 $mailSent = false;
 // Initialise field variable from subscription form
 $userData = user_initialise();
 if (isset($_REQUEST['cmd'])) {
     $cmd = $_REQUEST['cmd'];
 } else {
     $cmd = '';
 }
 /**
  * Main Section
  */
 if ('registration' == $cmd) {
     // get params from the form
     $userData = user_initialise();
     // validate forum params
     $messageList = user_validate_form_registration($userData);
     if (count($messageList) == 0) {
         // Register the new user in the claroline platform
         $userId = user_create($userData);
         set_user_property($userId, 'skype', $userData['skype']);
         if (claro_is_user_authenticated()) {
             // add value in session
             $_user = user_get_properties(claro_get_current_user_id());
             $_user['firstName'] = $_user['firstname'];
             $_user['lastName'] = $_user['lastname'];
             $_user['mail'] = $_user['email'];
             $_user['lastLogin'] = claro_time() - 24 * 60 * 60;
             // DATE_SUB(CURDATE(), INTERVAL 1 DAY)
             $is_allowedCreateCourse = $userData['isCourseCreator'] == 1 ? TRUE : FALSE;
             $_SESSION['_uid'] = claro_get_current_user_id();
             $_SESSION['_user'] = $_user;
Example #2
0
    }
} elseif ($cmd == 'registration' && !$userId) {
    if (!(get_conf('is_coursemanager_allowed_to_register_single_user') || claro_is_platform_admin())) {
        $dialogBox->error(get_lang('Not allowed'));
        $cmd = null;
    }
}
// Business logic
if ($cmd == 'registration') {
    /*
     * Two possible ways to enroll a user to a course :
     * Registration of a completly new user from $userData
     * Registration of an existing user form its $userId
     */
    if ($userData && !$userId) {
        $errorMsgList = user_validate_form_registration($userData);
        if (count($errorMsgList) == 0) {
            $validUserData = true;
        } else {
            $validUserData = false;
        }
        if (in_array(get_lang('This official code is already used by another user.'), $errorMsgList)) {
            $userList = user_search(array('officialCode' => $userData['officialCode']), claro_get_current_course_id(), false, true, false);
            $dialogBox->error(get_lang('This official code is already used by another user.') . '<br />' . get_lang('Take one of these options') . ' : ' . '<ul>' . '<li>' . '<a href="#resultTable">' . get_lang('Click on the enrollment command beside the concerned user') . '</a>' . '</li>' . '<li>' . '<a href="' . $_SERVER['PHP_SELF'] . '?cmd=cancel' . claro_url_relay_context('&') . '">' . get_lang('Cancel the operation') . '</a>' . '</li>' . '</ul>');
            $displayResultTable = true;
        } elseif (!$userData['confirmUserCreate'] && !(empty($userData['lastname']) && empty($userData['email']))) {
            $userList = user_search(array('lastname' => $userData['lastname'], 'email' => $userData['email']), claro_get_current_course_id(), false, true, false);
            if (count($userList) > 0) {
                // PREPARE THE URL command TO CONFIRM THE USER CREATION
                $confirmUserCreateUrl = array();
                foreach ($userData as $thisDataKey => $thisDataValue) {