Example #1
0
             $_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;
             $_SESSION['is_allowedCreateCourse'] = $is_allowedCreateCourse;
             // track user login
             $claroline->notifier->event('user_login', array('data' => array('ip' => $_SERVER['REMOTE_ADDR'])));
             // last user login date is now
             $user_last_login_datetime = 0;
             // used as a unix timestamp it will correspond to : 1 1 1970
             $_SESSION['user_last_login_datetime'] = $user_last_login_datetime;
             // send info to user by email
             $mailSent = user_send_registration_mail(claro_get_current_user_id(), $userData);
         } else {
             if ('MISSING_DATA' == claro_failure::get_last_failure()) {
                 $messageList[] = get_lang('Data missing');
             } else {
                 $messageList[] = get_lang('Unknown error');
             }
         }
     } else {
         // User validate form return error messages
         $error = true;
     }
 }
 if ('registration' == $cmd && $error == false) {
     $display = DISP_REGISTRATION_SUCCEED;
 } elseif ('agree' == $cmd || !get_conf('show_agreement_panel') || 'registration' == $cmd || '' == $agreementText) {
Example #2
0
     $dialogBox->question(get_lang('Do you really want to reset all the passwords ?') . '<br />' . '<small>' . get_lang('The platform administrators and course creators password will remain unchanged') . '</small>' . '<br />');
     $dialogBox->form(' <form method="post" action="' . claro_htmlspecialchars($_SERVER['PHP_SELF']) . '">' . '<input type="hidden" name="cmd" value="exResetAllPasswords" />' . '<input id="sendEmail" type="checkbox" name="sendEmail" value="yes" checked="checked" />' . '<label for="sendEmail">' . get_lang('send new password by email') . '</label>' . '<br />' . '<small>' . get_lang('Only the users with a valid address will receive their password by email') . '</small>' . '<br />' . '<input type="submit" value="' . get_lang('Yes') . '" />' . claro_html_button($_SERVER['PHP_SELF'], get_lang('Cancel')) . '</form>');
     $dialogBox->warning('<em>' . get_lang('This may take some time, please wait until the end of the process...') . '</em>');
     break;
 case 'exResetAllPasswords':
     $userList = getAllStudentUserId();
     $failedMailList = array();
     $failedList = array();
     $sendEmail = isset($_REQUEST['sendEmail']) && $_REQUEST['sendEmail'] ? true : false;
     foreach ($userList as $user) {
         $mailSent = FALSE;
         $userInfo = user_get_properties($user['id']);
         if (!$userInfo['isPlatformAdmin'] && !$userInfo['isCourseCreator']) {
             $userInfo['password'] = mk_password(8);
             if (user_set_properties($user['id'], array('password' => $userInfo['password']))) {
                 if ($sendEmail && user_send_registration_mail($user['id'], $userInfo)) {
                     $mailSent = TRUE;
                 }
             } else {
                 $failedList[] = $userInfo;
             }
         }
         if ($sendEmail && !$mailSent) {
             $failedMailList[] = $userInfo;
         }
     }
     if (empty($failedList)) {
         $dialogBox->success(get_lang('Password changed successfully for all concerned users'));
     } else {
         $failedStudents = '';
         foreach ($failedList as $failed) {
Example #3
0
 /**
  * Import users in course.
  *
  * @author Dimitri Rambout <*****@*****.**>
  * @param $courseId id of the course
  *
  * @return boolean
  */
 public function importUsersInCourse($userList, $courseId, $canCreateUser = true, $enrollUserInCourse = true, $class_id = 0, $sendEmail = 0)
 {
     if (empty($this->data)) {
         return false;
     }
     if (!(isset($userList) && count($userList))) {
         return false;
     }
     $logs = array();
     $tbl_mdb_names = claro_sql_get_main_tbl();
     $tbl_user = $tbl_mdb_names['user'];
     $tbl_course_user = $tbl_mdb_names['rel_course_user'];
     $tbl_cdb_names = claro_sql_get_course_tbl();
     $tbl_group_rel_team_user = $tbl_cdb_names['group_rel_team_user'];
     $groupsImported = array();
     $userInfo = array();
     foreach ($userList as $user_id) {
         if (!isset($this->data[$user_id])) {
             $logs['errors'][] = get_lang('Unable to find the user in the csv');
         } else {
             $userInfo['username'] = $this->data[$user_id]['username'];
             $userInfo['firstname'] = $this->data[$user_id]['firstname'];
             $userInfo['lastname'] = $this->data[$user_id]['lastname'];
             $userInfo['email'] = isset($this->data[$user_id]['email']) && !empty($this->data[$user_id]['email']) ? $this->data[$user_id]['email'] : '';
             $userInfo['password'] = isset($this->data[$user_id]['password']) && !empty($this->data[$user_id]['password']) ? $this->data[$user_id]['password'] : mk_password(8);
             $userInfo['officialCode'] = isset($this->data[$user_id]['officialCode']) ? $this->data[$user_id]['officialCode'] : '';
             if (isset($this->data[$user_id]['groupName'])) {
                 $groupNames = $this->data[$user_id]['groupName'];
             } else {
                 $groupNames = null;
             }
             //check user existe if not create is asked
             $resultSearch = user_search(array('username' => $userInfo['username']), null, true, true);
             if (empty($resultSearch)) {
                 if (!$canCreateUser) {
                     $userId = 0;
                     $logs['errors'][] = get_lang('Unable to create user %username, option is disabled in configuration', array('%username' => $userInfo['username']));
                 } else {
                     $userId = user_create($userInfo);
                     if ($userId != 0) {
                         $logs['success'][] = get_lang('User profile %username created successfully', array('%username' => $userInfo['username']));
                         if ($sendEmail) {
                             user_send_registration_mail($userId, $userInfo);
                         }
                     } else {
                         $logs['errors'][] = get_lang('Unable to create user %username', array('%username' => $userInfo['username']));
                     }
                 }
             } else {
                 $userId = $resultSearch[0]['uid'];
                 $logs['errors'][] = get_lang('User %username not created because it already exists in the database', array('%username' => $userInfo['username']));
             }
             if ($userId == 0) {
                 $logs['errors'][] = get_lang('Unable to add user %username in this course', array('%username' => $userInfo['username']));
             } else {
                 if (!$enrollUserInCourse) {
                     $logs['errors'][] = get_lang('Unable to add user %username in this course, option is disabled in configuration', array('%username' => $userInfo['username']));
                 } else {
                     if (!user_add_to_course($userId, $courseId, false, false, null)) {
                         $logs['errors'][] = get_lang('Unable to add user %username in this course', array('%username' => $userInfo['username']));
                     } else {
                         $logs['success'][] = get_lang('User %username added in course %courseId', array('%username' => $userInfo['username'], '%courseId' => $courseId));
                         //join class if needed
                         if ($class_id) {
                             if (!($return = user_add_to_class($userId, $class_id))) {
                                 $logs['errors'][] = get_lang('Unable to add %username in the selected class', array('%username' => $userInfo['username']));
                             } else {
                                 $logs['success'][] = get_lang('User %username added in the selected class', array('%username' => $userInfo['username']));
                             }
                         }
                         //join group
                         $groups = explode(',', $groupNames);
                         if (is_array($groups)) {
                             foreach ($groups as $group) {
                                 $group = trim($group);
                                 if (!empty($group)) {
                                     $groupsImported[$group][] = $userId;
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     foreach ($groupsImported as $group => $users) {
         $GLOBALS['currentCourseRepository'] = claro_get_course_path($courseId);
         $groupId = create_group($group, null);
         if ($groupId == 0) {
             $logs['errors'][] = get_lang('Unable to create group %groupname', array('%groupname' => $group));
         } else {
             foreach ($users as $userId) {
                 $sql = "INSERT INTO `" . $tbl_group_rel_team_user . "`\n                            SET user = "******",\n                                team = " . (int) $groupId;
                 if (!claro_sql_query($sql)) {
                     $logs['errors'][] = get_lang('Unable to add user in group %groupname', array('%groupname' => $group));
                 }
             }
         }
     }
     return $logs;
 }
Example #4
0
 // 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);
     if (false === $userId) {
         $dialogBox->error(claro_failure::get_last_failure());
     } else {
         $dialogBox->success(get_lang('The new user has been sucessfully created'));
         $newUserMenu[] = claro_html_cmd_link('../auth/courses.php?cmd=rqReg&amp;uidToEdit=' . $userId . '&amp;category=&amp;fromAdmin=settings', get_lang('Register this user to a course'));
         $newUserMenu[] = claro_html_cmd_link('admin_profile.php?uidToEdit=' . $userId . '&amp;category=', get_lang('User settings'));
         $newUserMenu[] = claro_html_cmd_link('adminaddnewuser.php', get_lang('Create another new user'));
         $newUserMenu[] = claro_html_cmd_link('index.php', get_lang('Back to administration page'));
         $display = DISP_REGISTRATION_SUCCEED;
         // Send a mail to the user
         if (false !== user_send_registration_mail($userId, $userData)) {
             $dialogBox->success(get_lang('Mail sent to user'));
         } else {
             $dialogBox->warning(get_lang('No mail sent to user'));
             // TODO  display in a popup "To Print" with  content to give to user.
         }
     }
 } else {
     // User validate form return error messages
     if (is_array($messageList) && !empty($messageList)) {
         foreach ($messageList as $message) {
             $dialogBox->error($message);
         }
     }
     $error = true;
 }
Example #5
0
             $displayResultTable = true;
         }
     } else {
         $userList = array();
     }
     if (!empty($errorMsgList) && count($userList) == 0) {
         foreach ($errorMsgList as $errorMsg) {
             $dialogBox->error($errorMsg);
         }
     }
 }
 if (!$userId && $validUserData && count($userList) == 0) {
     $userData['language'] = null;
     $userId = user_create($userData);
     if ($userId) {
         user_send_registration_mail($userId, $userData, claro_get_current_course_id());
     }
 }
 if ($userId) {
     $courseObj = new Claro_Course(claro_get_current_course_id());
     $courseObj->load();
     $courseRegistration = new Claro_CourseUserRegistration(AuthProfileManager::getUserAuthProfile($userId), $courseObj, null, null);
     if ($userData['courseAdmin']) {
         $courseRegistration->setCourseAdmin();
     }
     if ($userData['profileId']) {
         $courseRegistration->setUserProfileIdInCourse($userData['profileId']);
     }
     if ($userData['courseTutor']) {
         $courseRegistration->setCourseTutor();
     }